summaryrefslogtreecommitdiff
path: root/ext/sqlite3
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-06-05 15:01:02 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2018-06-05 15:01:02 +0200
commitc4331b00be1a294fa20ee08a18cdd722f123c73a (patch)
treeb7116d2fc263b7d52d4469db3f0aebcadd1ab532 /ext/sqlite3
parent1ce4b484f84f9f43daee7e1fe75d42cac3b1ca34 (diff)
downloadphp-git-c4331b00be1a294fa20ee08a18cdd722f123c73a.tar.gz
Update to SQLite 3.24.0
Diffstat (limited to 'ext/sqlite3')
-rw-r--r--ext/sqlite3/libsqlite/sqlite3.c8843
-rw-r--r--ext/sqlite3/libsqlite/sqlite3.h275
-rw-r--r--ext/sqlite3/libsqlite/sqlite3ext.h30
3 files changed, 5679 insertions, 3469 deletions
diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c
index c49f89c923..ce4f343fdc 100644
--- a/ext/sqlite3/libsqlite/sqlite3.c
+++ b/ext/sqlite3/libsqlite/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.23.1. By combining all the individual C code files into this
+** version 3.24.0. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
@@ -311,6 +311,9 @@ static const char * const sqlite3azCompileOpt[] = {
#if SQLITE_ENABLE_SNAPSHOT
"ENABLE_SNAPSHOT",
#endif
+#if SQLITE_ENABLE_SORTER_REFERENCES
+ "ENABLE_SORTER_REFERENCES",
+#endif
#if SQLITE_ENABLE_SQLLOG
"ENABLE_SQLLOG",
#endif
@@ -1147,9 +1150,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.23.1"
-#define SQLITE_VERSION_NUMBER 3023001
-#define SQLITE_SOURCE_ID "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"
+#define SQLITE_VERSION "3.24.0"
+#define SQLITE_VERSION_NUMBER 3024000
+#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -1528,6 +1531,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
+#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
@@ -1535,6 +1539,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
+#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -2954,6 +2959,22 @@ struct sqlite3_mem_methods {
** I/O required to support statement rollback.
** The default value for this setting is controlled by the
** [SQLITE_STMTJRNL_SPILL] compile-time option.
+**
+** [[SQLITE_CONFIG_SORTERREF_SIZE]]
+** <dt>SQLITE_CONFIG_SORTERREF_SIZE
+** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
+** of type (int) - the new value of the sorter-reference size threshold.
+** Usually, when SQLite uses an external sort to order records according
+** to an ORDER BY clause, all fields required by the caller are present in the
+** sorted records. However, if SQLite determines based on the declared type
+** of a table column that its values are likely to be very large - larger
+** than the configured sorter-reference size threshold - then a reference
+** is stored in each sorted record and the required column values loaded
+** from the database as records are returned in sorted order. The default
+** value for this option is to never use this optimization. Specifying a
+** negative value for this option restores the default behaviour.
+** This option is only available if SQLite is compiled with the
+** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -2983,6 +3004,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
+#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -3119,6 +3141,21 @@ struct sqlite3_mem_methods {
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
** it is not disabled, 1 if it is.
** </dd>
+**
+** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
+** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
+** [VACUUM] in order to reset a database back to an empty database
+** with no schema and no content. The following process works even for
+** a badly corrupted database file:
+** <ol>
+** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
+** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
+** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
+** </ol>
+** Because resetting a database is destructive and irreversible, the
+** process requires the use of this obscure API and multiple steps to help
+** ensure that it does not happen by accident.
+** </dd>
** </dl>
*/
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
@@ -3130,7 +3167,8 @@ struct sqlite3_mem_methods {
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
-#define SQLITE_DBCONFIG_MAX 1008 /* Largest DBCONFIG */
+#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
+#define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
/*
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -6517,6 +6555,41 @@ SQLITE_API char *sqlite3_temp_directory;
SQLITE_API char *sqlite3_data_directory;
/*
+** CAPI3REF: Win32 Specific Interface
+**
+** These interfaces are available only on Windows. The
+** [sqlite3_win32_set_directory] interface is used to set the value associated
+** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to
+** zValue, depending on the value of the type parameter. The zValue parameter
+** should be NULL to cause the previous value to be freed via [sqlite3_free];
+** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]
+** prior to being used. The [sqlite3_win32_set_directory] interface returns
+** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,
+** or [SQLITE_NOMEM] if memory could not be allocated. The value of the
+** [sqlite3_data_directory] variable is intended to act as a replacement for
+** the current directory on the sub-platforms of Win32 where that concept is
+** not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and
+** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the
+** sqlite3_win32_set_directory interface except the string parameter must be
+** UTF-8 or UTF-16, respectively.
+*/
+SQLITE_API int sqlite3_win32_set_directory(
+ unsigned long type, /* Identifier for directory being set or reset */
+ void *zValue /* New value for directory being set or reset */
+);
+SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);
+SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);
+
+/*
+** CAPI3REF: Win32 Directory Types
+**
+** These macros are only available on Windows. They define the allowed values
+** for the type argument to the [sqlite3_win32_set_directory] interface.
+*/
+#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
+#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
+
+/*
** CAPI3REF: Test For Auto-Commit Mode
** KEYWORDS: {autocommit mode}
** METHOD: sqlite3
@@ -7248,6 +7321,10 @@ struct sqlite3_index_info {
/*
** CAPI3REF: Virtual Table Scan Flags
+**
+** Virtual table implementations are allowed to set the
+** [sqlite3_index_info].idxFlags field to some combination of
+** these bits.
*/
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
@@ -8023,7 +8100,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
-#define SQLITE_TESTCTRL_ISKEYWORD 16
+#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
@@ -8038,6 +8115,189 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */
/*
+** CAPI3REF: SQL Keyword Checking
+**
+** These routines provide access to the set of SQL language keywords
+** recognized by SQLite. Applications can uses these routines to determine
+** whether or not a specific identifier needs to be escaped (for example,
+** by enclosing in double-quotes) so as not to confuse the parser.
+**
+** The sqlite3_keyword_count() interface returns the number of distinct
+** keywords understood by SQLite.
+**
+** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
+** makes *Z point to that keyword expressed as UTF8 and writes the number
+** of bytes in the keyword into *L. The string that *Z points to is not
+** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns
+** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
+** or L are NULL or invalid pointers then calls to
+** sqlite3_keyword_name(N,Z,L) result in undefined behavior.
+**
+** The sqlite3_keyword_check(Z,L) interface checks to see whether or not
+** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
+** if it is and zero if not.
+**
+** The parser used by SQLite is forgiving. It is often possible to use
+** a keyword as an identifier as long as such use does not result in a
+** parsing ambiguity. For example, the statement
+** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
+** creates a new table named "BEGIN" with three columns named
+** "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid
+** using keywords as identifiers. Common techniques used to avoid keyword
+** name collisions include:
+** <ul>
+** <li> Put all identifier names inside double-quotes. This is the official
+** SQL way to escape identifier names.
+** <li> Put identifier names inside &#91;...&#93;. This is not standard SQL,
+** but it is what SQL Server does and so lots of programmers use this
+** technique.
+** <li> Begin every identifier with the letter "Z" as no SQL keywords start
+** with "Z".
+** <li> Include a digit somewhere in every identifier name.
+** </ul>
+**
+** Note that the number of keywords understood by SQLite can depend on
+** compile-time options. For example, "VACUUM" is not a keyword if
+** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also,
+** new keywords may be added to future releases of SQLite.
+*/
+SQLITE_API int sqlite3_keyword_count(void);
+SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
+SQLITE_API int sqlite3_keyword_check(const char*,int);
+
+/*
+** CAPI3REF: Dynamic String Object
+** KEYWORDS: {dynamic string}
+**
+** An instance of the sqlite3_str object contains a dynamically-sized
+** string under construction.
+**
+** The lifecycle of an sqlite3_str object is as follows:
+** <ol>
+** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
+** <li> ^Text is appended to the sqlite3_str object using various
+** methods, such as [sqlite3_str_appendf()].
+** <li> ^The sqlite3_str object is destroyed and the string it created
+** is returned using the [sqlite3_str_finish()] interface.
+** </ol>
+*/
+typedef struct sqlite3_str sqlite3_str;
+
+/*
+** CAPI3REF: Create A New Dynamic String Object
+** CONSTRUCTOR: sqlite3_str
+**
+** ^The [sqlite3_str_new(D)] interface allocates and initializes
+** a new [sqlite3_str] object. To avoid memory leaks, the object returned by
+** [sqlite3_str_new()] must be freed by a subsequent call to
+** [sqlite3_str_finish(X)].
+**
+** ^The [sqlite3_str_new(D)] interface always returns a pointer to a
+** valid [sqlite3_str] object, though in the event of an out-of-memory
+** error the returned object might be a special singleton that will
+** silently reject new text, always return SQLITE_NOMEM from
+** [sqlite3_str_errcode()], always return 0 for
+** [sqlite3_str_length()], and always return NULL from
+** [sqlite3_str_finish(X)]. It is always safe to use the value
+** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter
+** to any of the other [sqlite3_str] methods.
+**
+** The D parameter to [sqlite3_str_new(D)] may be NULL. If the
+** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum
+** length of the string contained in the [sqlite3_str] object will be
+** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead
+** of [SQLITE_MAX_LENGTH].
+*/
+SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
+
+/*
+** CAPI3REF: Finalize A Dynamic String
+** DESTRUCTOR: sqlite3_str
+**
+** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X
+** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]
+** that contains the constructed string. The calling application should
+** pass the returned value to [sqlite3_free()] to avoid a memory leak.
+** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
+** errors were encountered during construction of the string. ^The
+** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
+** string in [sqlite3_str] object X is zero bytes long.
+*/
+SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
+
+/*
+** CAPI3REF: Add Content To A Dynamic String
+** METHOD: sqlite3_str
+**
+** These interfaces add content to an sqlite3_str object previously obtained
+** from [sqlite3_str_new()].
+**
+** ^The [sqlite3_str_appendf(X,F,...)] and
+** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
+** functionality of SQLite to append formatted text onto the end of
+** [sqlite3_str] object X.
+**
+** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S
+** onto the end of the [sqlite3_str] object X. N must be non-negative.
+** S must contain at least N non-zero bytes of content. To append a
+** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]
+** method instead.
+**
+** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of
+** zero-terminated string S onto the end of [sqlite3_str] object X.
+**
+** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the
+** single-byte character C onto the end of [sqlite3_str] object X.
+** ^This method can be used, for example, to add whitespace indentation.
+**
+** ^The [sqlite3_str_reset(X)] method resets the string under construction
+** inside [sqlite3_str] object X back to zero bytes in length.
+**
+** These methods do not return a result code. ^If an error occurs, that fact
+** is recorded in the [sqlite3_str] object and can be recovered by a
+** subsequent call to [sqlite3_str_errcode(X)].
+*/
+SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
+SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
+SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
+SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
+SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
+SQLITE_API void sqlite3_str_reset(sqlite3_str*);
+
+/*
+** CAPI3REF: Status Of A Dynamic String
+** METHOD: sqlite3_str
+**
+** These interfaces return the current status of an [sqlite3_str] object.
+**
+** ^If any prior errors have occurred while constructing the dynamic string
+** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return
+** an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns
+** [SQLITE_NOMEM] following any out-of-memory error, or
+** [SQLITE_TOOBIG] if the size of the dynamic string exceeds
+** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.
+**
+** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,
+** of the dynamic string under construction in [sqlite3_str] object X.
+** ^The length returned by [sqlite3_str_length(X)] does not include the
+** zero-termination byte.
+**
+** ^The [sqlite3_str_value(X)] method returns a pointer to the current
+** content of the dynamic string under construction in X. The value
+** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
+** and might be freed or altered by any subsequent method on the same
+** [sqlite3_str] object. Applications must not used the pointer returned
+** [sqlite3_str_value(X)] after any subsequent method call on the same
+** object. ^Applications may change the content of the string returned
+** by [sqlite3_str_value(X)] as long as they do not write into any bytes
+** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
+** write any byte after any subsequent sqlite3_str method call.
+*/
+SQLITE_API int sqlite3_str_errcode(sqlite3_str*);
+SQLITE_API int sqlite3_str_length(sqlite3_str*);
+SQLITE_API char *sqlite3_str_value(sqlite3_str*);
+
+/*
** CAPI3REF: SQLite Runtime Status
**
** ^These interfaces are used to retrieve runtime status information
@@ -9306,11 +9566,11 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
** method of a [virtual table], then it returns true if and only if the
** column is being fetched as part of an UPDATE operation during which the
** column value will not change. Applications might use this to substitute
-** a lighter-weight value to return that the corresponding [xUpdate] method
-** understands as a "no-change" value.
+** a return value that is less expensive to compute and that the corresponding
+** [xUpdate] method understands as a "no-change" value.
**
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
-** the column is not changed by the UPDATE statement, they the xColumn
+** the column is not changed by the UPDATE statement, then the xColumn
** method can optionally return without setting a result, without calling
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
** In that case, [sqlite3_value_nochange(X)] will return true for the
@@ -9805,7 +10065,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
** values of D and S.
** The size of the database is written into *P even if the
-** SQLITE_SERIALIZE_NOCOPY bit is set but no contigious copy
+** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
** of the database exists.
**
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
@@ -12941,107 +13201,109 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
#define TK_ESCAPE 58
#define TK_ID 59
#define TK_COLUMNKW 60
-#define TK_FOR 61
-#define TK_IGNORE 62
-#define TK_INITIALLY 63
-#define TK_INSTEAD 64
-#define TK_NO 65
-#define TK_KEY 66
-#define TK_OF 67
-#define TK_OFFSET 68
-#define TK_PRAGMA 69
-#define TK_RAISE 70
-#define TK_RECURSIVE 71
-#define TK_REPLACE 72
-#define TK_RESTRICT 73
-#define TK_ROW 74
-#define TK_TRIGGER 75
-#define TK_VACUUM 76
-#define TK_VIEW 77
-#define TK_VIRTUAL 78
-#define TK_WITH 79
-#define TK_REINDEX 80
-#define TK_RENAME 81
-#define TK_CTIME_KW 82
-#define TK_ANY 83
-#define TK_BITAND 84
-#define TK_BITOR 85
-#define TK_LSHIFT 86
-#define TK_RSHIFT 87
-#define TK_PLUS 88
-#define TK_MINUS 89
-#define TK_STAR 90
-#define TK_SLASH 91
-#define TK_REM 92
-#define TK_CONCAT 93
-#define TK_COLLATE 94
-#define TK_BITNOT 95
-#define TK_INDEXED 96
-#define TK_STRING 97
-#define TK_JOIN_KW 98
-#define TK_CONSTRAINT 99
-#define TK_DEFAULT 100
-#define TK_NULL 101
-#define TK_PRIMARY 102
-#define TK_UNIQUE 103
-#define TK_CHECK 104
-#define TK_REFERENCES 105
-#define TK_AUTOINCR 106
-#define TK_ON 107
-#define TK_INSERT 108
-#define TK_DELETE 109
-#define TK_UPDATE 110
-#define TK_SET 111
-#define TK_DEFERRABLE 112
-#define TK_FOREIGN 113
-#define TK_DROP 114
-#define TK_UNION 115
-#define TK_ALL 116
-#define TK_EXCEPT 117
-#define TK_INTERSECT 118
-#define TK_SELECT 119
-#define TK_VALUES 120
-#define TK_DISTINCT 121
-#define TK_DOT 122
-#define TK_FROM 123
-#define TK_JOIN 124
-#define TK_USING 125
-#define TK_ORDER 126
-#define TK_GROUP 127
-#define TK_HAVING 128
-#define TK_LIMIT 129
-#define TK_WHERE 130
-#define TK_INTO 131
-#define TK_FLOAT 132
-#define TK_BLOB 133
-#define TK_INTEGER 134
-#define TK_VARIABLE 135
-#define TK_CASE 136
-#define TK_WHEN 137
-#define TK_THEN 138
-#define TK_ELSE 139
-#define TK_INDEX 140
-#define TK_ALTER 141
-#define TK_ADD 142
-#define TK_TRUEFALSE 143
-#define TK_ISNOT 144
-#define TK_FUNCTION 145
-#define TK_COLUMN 146
-#define TK_AGG_FUNCTION 147
-#define TK_AGG_COLUMN 148
-#define TK_UMINUS 149
-#define TK_UPLUS 150
-#define TK_TRUTH 151
-#define TK_REGISTER 152
-#define TK_VECTOR 153
-#define TK_SELECT_COLUMN 154
-#define TK_IF_NULL_ROW 155
-#define TK_ASTERISK 156
-#define TK_SPAN 157
-#define TK_END_OF_FILE 158
-#define TK_UNCLOSED_STRING 159
-#define TK_SPACE 160
-#define TK_ILLEGAL 161
+#define TK_DO 61
+#define TK_FOR 62
+#define TK_IGNORE 63
+#define TK_INITIALLY 64
+#define TK_INSTEAD 65
+#define TK_NO 66
+#define TK_KEY 67
+#define TK_OF 68
+#define TK_OFFSET 69
+#define TK_PRAGMA 70
+#define TK_RAISE 71
+#define TK_RECURSIVE 72
+#define TK_REPLACE 73
+#define TK_RESTRICT 74
+#define TK_ROW 75
+#define TK_TRIGGER 76
+#define TK_VACUUM 77
+#define TK_VIEW 78
+#define TK_VIRTUAL 79
+#define TK_WITH 80
+#define TK_REINDEX 81
+#define TK_RENAME 82
+#define TK_CTIME_KW 83
+#define TK_ANY 84
+#define TK_BITAND 85
+#define TK_BITOR 86
+#define TK_LSHIFT 87
+#define TK_RSHIFT 88
+#define TK_PLUS 89
+#define TK_MINUS 90
+#define TK_STAR 91
+#define TK_SLASH 92
+#define TK_REM 93
+#define TK_CONCAT 94
+#define TK_COLLATE 95
+#define TK_BITNOT 96
+#define TK_ON 97
+#define TK_INDEXED 98
+#define TK_STRING 99
+#define TK_JOIN_KW 100
+#define TK_CONSTRAINT 101
+#define TK_DEFAULT 102
+#define TK_NULL 103
+#define TK_PRIMARY 104
+#define TK_UNIQUE 105
+#define TK_CHECK 106
+#define TK_REFERENCES 107
+#define TK_AUTOINCR 108
+#define TK_INSERT 109
+#define TK_DELETE 110
+#define TK_UPDATE 111
+#define TK_SET 112
+#define TK_DEFERRABLE 113
+#define TK_FOREIGN 114
+#define TK_DROP 115
+#define TK_UNION 116
+#define TK_ALL 117
+#define TK_EXCEPT 118
+#define TK_INTERSECT 119
+#define TK_SELECT 120
+#define TK_VALUES 121
+#define TK_DISTINCT 122
+#define TK_DOT 123
+#define TK_FROM 124
+#define TK_JOIN 125
+#define TK_USING 126
+#define TK_ORDER 127
+#define TK_GROUP 128
+#define TK_HAVING 129
+#define TK_LIMIT 130
+#define TK_WHERE 131
+#define TK_INTO 132
+#define TK_NOTHING 133
+#define TK_FLOAT 134
+#define TK_BLOB 135
+#define TK_INTEGER 136
+#define TK_VARIABLE 137
+#define TK_CASE 138
+#define TK_WHEN 139
+#define TK_THEN 140
+#define TK_ELSE 141
+#define TK_INDEX 142
+#define TK_ALTER 143
+#define TK_ADD 144
+#define TK_TRUEFALSE 145
+#define TK_ISNOT 146
+#define TK_FUNCTION 147
+#define TK_COLUMN 148
+#define TK_AGG_FUNCTION 149
+#define TK_AGG_COLUMN 150
+#define TK_UMINUS 151
+#define TK_UPLUS 152
+#define TK_TRUTH 153
+#define TK_REGISTER 154
+#define TK_VECTOR 155
+#define TK_SELECT_COLUMN 156
+#define TK_IF_NULL_ROW 157
+#define TK_ASTERISK 158
+#define TK_SPAN 159
+#define TK_END_OF_FILE 160
+#define TK_UNCLOSED_STRING 161
+#define TK_SPACE 162
+#define TK_ILLEGAL 163
/* The token codes above must all fit in 8 bits */
#define TKFLG_MASK 0xff
@@ -13162,6 +13424,13 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
#endif
/*
+** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option.
+*/
+#ifndef SQLITE_DEFAULT_SORTERREF_SIZE
+# define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff
+#endif
+
+/*
** The compile-time options SQLITE_MMAP_READWRITE and
** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.
** You must choose one or the other (or neither) but not both.
@@ -13610,7 +13879,7 @@ typedef struct Select Select;
typedef struct SQLiteThread SQLiteThread;
typedef struct SelectDest SelectDest;
typedef struct SrcList SrcList;
-typedef struct StrAccum StrAccum;
+typedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */
typedef struct Table Table;
typedef struct TableLock TableLock;
typedef struct Token Token;
@@ -13619,6 +13888,7 @@ typedef struct Trigger Trigger;
typedef struct TriggerPrg TriggerPrg;
typedef struct TriggerStep TriggerStep;
typedef struct UnpackedRecord UnpackedRecord;
+typedef struct Upsert Upsert;
typedef struct VTable VTable;
typedef struct VtabCtx VtabCtx;
typedef struct Walker Walker;
@@ -13901,13 +14171,28 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
** entry in either an index or table btree.
**
** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
-** an arbitrary key and no data. These btrees have pKey,nKey set to their
-** key and pData,nData,nZero set to zero.
+** an arbitrary key and no data. These btrees have pKey,nKey set to the
+** key and the pData,nData,nZero fields are uninitialized. The aMem,nMem
+** fields give an array of Mem objects that are a decomposition of the key.
+** The nMem field might be zero, indicating that no decomposition is available.
**
** Table btrees (used for rowid tables) contain an integer rowid used as
** the key and passed in the nKey field. The pKey field is zero.
** pData,nData hold the content of the new entry. nZero extra zero bytes
** are appended to the end of the content when constructing the entry.
+** The aMem,nMem fields are uninitialized for table btrees.
+**
+** Field usage summary:
+**
+** Table BTrees Index Btrees
+**
+** pKey always NULL encoded key
+** nKey the ROWID length of pKey
+** pData data not used
+** aMem not used decomposed key value
+** nMem not used entries in aMem
+** nData length of pData not used
+** nZero extra zeros after pData not used
**
** This object is used to pass information into sqlite3BtreeInsert(). The
** same information used to be passed as five separate parameters. But placing
@@ -13918,7 +14203,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
struct BtreePayload {
const void *pKey; /* Key content for indexes. NULL for tables */
sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
- const void *pData; /* Data for tables. NULL for indexes */
+ const void *pData; /* Data for tables. */
sqlite3_value *aMem; /* First of nMem value in the unpacked pKey */
u16 nMem; /* Number of aMem[] value. Might be zero */
int nData; /* Size of pData. 0 if none. */
@@ -14276,22 +14561,22 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_RealAffinity 81
#define OP_Cast 82 /* synopsis: affinity(r[P1]) */
#define OP_Permutation 83
-#define OP_BitAnd 84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
-#define OP_BitOr 85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
-#define OP_ShiftLeft 86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
-#define OP_ShiftRight 87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
-#define OP_Add 88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
-#define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
-#define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
-#define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
-#define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
-#define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
-#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
-#define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
-#define OP_IsTrue 96 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
-#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
-#define OP_Offset 98 /* synopsis: r[P3] = sqlite_offset(P1) */
-#define OP_Column 99 /* synopsis: r[P3]=PX */
+#define OP_Compare 84 /* synopsis: r[P1@P3] <-> r[P2@P3] */
+#define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
+#define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
+#define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
+#define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
+#define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
+#define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
+#define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
+#define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
+#define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
+#define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
+#define OP_IsTrue 95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
+#define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
+#define OP_Offset 97 /* synopsis: r[P3] = sqlite_offset(P1) */
+#define OP_Column 98 /* synopsis: r[P3]=PX */
+#define OP_String8 99 /* same as TK_STRING, synopsis: r[P2]='P4' */
#define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */
#define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
#define OP_Count 102 /* synopsis: r[P2]=count() */
@@ -14324,9 +14609,9 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_IdxInsert 129 /* synopsis: key=r[P2] */
#define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */
#define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */
-#define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
-#define OP_IdxRowid 133 /* synopsis: r[P2]=rowid */
-#define OP_Destroy 134
+#define OP_IdxRowid 132 /* synopsis: r[P2]=rowid */
+#define OP_Destroy 133
+#define OP_Real 134 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
#define OP_Clear 135
#define OP_ResetSorter 136
#define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
@@ -14363,6 +14648,7 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_CursorHint 168
#define OP_Noop 169
#define OP_Explain 170
+#define OP_Abortable 171
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
@@ -14385,9 +14671,9 @@ typedef struct VdbeOpList VdbeOpList;
/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\
/* 64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
/* 72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
-/* 80 */ 0x02, 0x02, 0x02, 0x00, 0x26, 0x26, 0x26, 0x26,\
-/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
-/* 96 */ 0x12, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\
+/* 80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\
+/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\
+/* 96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
@@ -14396,7 +14682,7 @@ typedef struct VdbeOpList VdbeOpList;
/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 168 */ 0x00, 0x00, 0x00,}
+/* 168 */ 0x00, 0x00, 0x00, 0x00,}
/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
@@ -14438,7 +14724,24 @@ SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p);
# define sqlite3VdbeVerifyNoMallocRequired(A,B)
# define sqlite3VdbeVerifyNoResultRow(A)
#endif
-SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
+#if defined(SQLITE_DEBUG)
+SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int);
+#else
+# define sqlite3VdbeVerifyAbortable(A,B)
+#endif
+SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno);
+#ifndef SQLITE_OMIT_EXPLAIN
+SQLITE_PRIVATE void sqlite3VdbeExplain(Parse*,u8,const char*,...);
+SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse*);
+SQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse*);
+# define ExplainQueryPlan(P) sqlite3VdbeExplain P
+# define ExplainQueryPlanPop(P) sqlite3VdbeExplainPop(P)
+# define ExplainQueryPlanParent(P) sqlite3VdbeExplainParent(P)
+#else
+# define ExplainQueryPlan(P)
+# define ExplainQueryPlanPop(P)
+# define ExplainQueryPlanParent(P) 0
+#endif
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
@@ -14461,6 +14764,9 @@ SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
+#ifdef SQLITE_COVERAGE_TEST
+SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe*,int);
+#endif
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
@@ -15595,7 +15901,7 @@ struct sqlite3 {
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
u8 mTrace; /* zero or more SQLITE_TRACE flags */
- u8 skipBtreeMutex; /* True if no shared-cache backends */
+ u8 noSharedCache; /* True if no shared-cache backends */
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
int nextPagesize; /* Pagesize after VACUUM if >0 */
u32 magic; /* Magic number for detect library misuse */
@@ -15739,6 +16045,7 @@ struct sqlite3 {
#define SQLITE_Fts3Tokenizer 0x00400000 /* Enable fts3_tokenizer(2) */
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
#define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
+#define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
/* Flags used only if debugging */
#ifdef SQLITE_DEBUG
@@ -15755,6 +16062,7 @@ struct sqlite3 {
#define DBFLAG_SchemaChange 0x0001 /* Uncommitted Hash table changes */
#define DBFLAG_PreferBuiltin 0x0002 /* Preference to built-in funcs */
#define DBFLAG_Vacuum 0x0004 /* Currently in a VACUUM */
+#define DBFLAG_SchemaKnownOk 0x0008 /* Schema is known to be valid */
/*
** Bits of the sqlite3.dbOptFlags field that are used by the
@@ -16000,6 +16308,7 @@ struct Column {
#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */
#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */
#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */
+#define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */
/*
** A "Collating Sequence" is defined by an instance of the following
@@ -16287,13 +16596,12 @@ struct FKey {
#define OE_Fail 3 /* Stop the operation but leave all prior changes */
#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */
#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */
-
-#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
-#define OE_SetNull 7 /* Set the foreign key value to NULL */
-#define OE_SetDflt 8 /* Set the foreign key value to its default */
-#define OE_Cascade 9 /* Cascade the changes */
-
-#define OE_Default 10 /* Do whatever the default action is */
+#define OE_Update 6 /* Process as a DO UPDATE in an upsert */
+#define OE_Restrict 7 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
+#define OE_SetNull 8 /* Set the foreign key value to NULL */
+#define OE_SetDflt 9 /* Set the foreign key value to its default */
+#define OE_Cascade 10 /* Cascade the changes */
+#define OE_Default 11 /* Do whatever the default action is */
/*
@@ -16740,6 +17048,7 @@ struct ExprList {
unsigned done :1; /* A flag to indicate when processing is finished */
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
unsigned reusable :1; /* Constant expression is reusable */
+ unsigned bSorterRef :1; /* Defer evaluation until after sorting */
union {
struct {
u16 iOrderByCol; /* For ORDER BY, column number in result set */
@@ -16839,9 +17148,6 @@ struct SrcList {
unsigned viaCoroutine :1; /* Implemented as a co-routine */
unsigned isRecursive :1; /* True for recursive reference in WITH */
} fg;
-#ifndef SQLITE_OMIT_EXPLAIN
- u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
-#endif
int iCursor; /* The VDBE cursor number used to access this table */
Expr *pOn; /* The ON clause of a join */
IdList *pUsing; /* The USING clause of a join */
@@ -16923,8 +17229,11 @@ struct SrcList {
struct NameContext {
Parse *pParse; /* The parser */
SrcList *pSrcList; /* One or more tables used to resolve names */
- ExprList *pEList; /* Optional list of result-set columns */
- AggInfo *pAggInfo; /* Information about aggregates at this level */
+ union {
+ ExprList *pEList; /* Optional list of result-set columns */
+ AggInfo *pAggInfo; /* Information about aggregates at this level */
+ Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */
+ } uNC;
NameContext *pNext; /* Next outer name context. NULL for outermost */
int nRef; /* Number of names resolved by this context */
int nErr; /* Number of errors encountered while resolving names */
@@ -16946,18 +17255,48 @@ struct NameContext {
#define NC_HasAgg 0x0010 /* One or more aggregate functions seen */
#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */
#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */
+#define NC_UEList 0x0080 /* True if uNC.pEList is used */
+#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
+#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
#define NC_Complex 0x2000 /* True if a function or subquery seen */
/*
+** An instance of the following object describes a single ON CONFLICT
+** clause in an upsert.
+**
+** The pUpsertTarget field is only set if the ON CONFLICT clause includes
+** conflict-target clause. (In "ON CONFLICT(a,b)" the "(a,b)" is the
+** conflict-target clause.) The pUpsertTargetWhere is the optional
+** WHERE clause used to identify partial unique indexes.
+**
+** pUpsertSet is the list of column=expr terms of the UPDATE statement.
+** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING. The
+** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the
+** WHERE clause is omitted.
+*/
+struct Upsert {
+ ExprList *pUpsertTarget; /* Optional description of conflicting index */
+ Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */
+ ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */
+ Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */
+ /* The fields above comprise the parse tree for the upsert clause.
+ ** The fields below are used to transfer information from the INSERT
+ ** processing down into the UPDATE processing while generating code.
+ ** Upsert owns the memory allocated above, but not the memory below. */
+ Index *pUpsertIdx; /* Constraint that pUpsertTarget identifies */
+ SrcList *pUpsertSrc; /* Table to be updated */
+ int regData; /* First register holding array of VALUES */
+ int iDataCur; /* Index of the data cursor */
+ int iIdxCur; /* Index of the first index cursor */
+};
+
+/*
** An instance of the following structure contains all information
** needed to generate code for a single SELECT statement.
**
-** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0.
-** If there is a LIMIT clause, the parser sets nLimit to the value of the
-** limit and nOffset to the value of the offset (or 0 if there is not
-** offset). But later on, nLimit and nOffset become the memory locations
-** in the VDBE that record the limit and offset counters.
+** See the header comment on the computeLimitRegisters() routine for a
+** detailed description of the meaning of the iLimit and iOffset fields.
**
** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.
** These addresses must be stored so that we can go back and fill in
@@ -17017,8 +17356,7 @@ struct Select {
#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */
#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */
#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */
-#define SF_ComplexResult 0x40000 /* Result set contains subquery or function */
-
+#define SF_ComplexResult 0x40000 /* Result contains subquery or function */
/*
** The results of a SELECT can be distributed in several ways, as defined
@@ -17288,8 +17626,7 @@ struct Parse {
#endif
int nHeight; /* Expression tree height of current sub-select */
#ifndef SQLITE_OMIT_EXPLAIN
- int iSelectId; /* ID of current select for EXPLAIN output */
- int iNextSelectId; /* Next available select ID for EXPLAIN output */
+ int addrExplain; /* Address of current OP_Explain opcode */
#endif
VList *pVList; /* Mapping between variable names and numbers */
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
@@ -17448,8 +17785,9 @@ struct TriggerStep {
Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */
char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
- ExprList *pExprList; /* SET clause for UPDATE. */
+ ExprList *pExprList; /* SET clause for UPDATE */
IdList *pIdList; /* Column names for INSERT */
+ Upsert *pUpsert; /* Upsert clauses on an INSERT */
char *zSpan; /* Original SQL text of this command */
TriggerStep *pNext; /* Next in the link-list */
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
@@ -17474,17 +17812,15 @@ struct DbFixer {
** An objected used to accumulate the text of a string where we
** do not necessarily know how big the string will be in the end.
*/
-struct StrAccum {
+struct sqlite3_str {
sqlite3 *db; /* Optional database for lookaside. Can be NULL */
char *zText; /* The string collected so far */
u32 nAlloc; /* Amount of space allocated in zText */
u32 mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */
u32 nChar; /* Length of the string so far */
- u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
+ u8 accError; /* SQLITE_NOMEM or SQLITE_TOOBIG */
u8 printfFlags; /* SQLITE_PRINTF flags below */
};
-#define STRACCUM_NOMEM 1
-#define STRACCUM_TOOBIG 2
#define SQLITE_PRINTF_INTERNAL 0x01 /* Internal-use-only converters allowed */
#define SQLITE_PRINTF_SQLFUNC 0x02 /* SQL function arguments to VXPrintf */
#define SQLITE_PRINTF_MALLOCED 0x04 /* True if xText is allocated space */
@@ -17561,6 +17897,7 @@ struct Sqlite3Config {
#endif
int bLocaltimeFault; /* True to fail localtime() calls */
int iOnceResetThreshold; /* When to reset OP_Once counters */
+ u32 szSorterRef; /* Min size in bytes to use sorter-refs */
};
/*
@@ -17852,8 +18189,6 @@ struct PrintfArguments {
sqlite3_value **apArg; /* The argument values */
};
-SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, const char*, va_list);
-SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);
SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
@@ -17981,7 +18316,7 @@ SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse);
# define sqlite3AutoincrementBegin(X)
# define sqlite3AutoincrementEnd(X)
#endif
-SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);
+SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
@@ -18011,7 +18346,8 @@ SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
-SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*);
+SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
+ Upsert*);
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
@@ -18104,7 +18440,7 @@ SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
- u8,u8,int,int*,int*);
+ u8,u8,int,int*,int*,Upsert*);
#ifdef SQLITE_ENABLE_NULL_TRIM
SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
#else
@@ -18157,7 +18493,8 @@ SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
const char*,const char*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
- Select*,u8,const char*,const char*);
+ Select*,u8,Upsert*,
+ const char*,const char*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
const char*,const char*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
@@ -18343,7 +18680,7 @@ SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
-SQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);
+SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);
SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
@@ -18368,17 +18705,14 @@ SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
FuncDestructor *pDestructor
);
+SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
-SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
-SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
-SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
-SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
@@ -18405,10 +18739,10 @@ SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
** The interface to the LEMON-generated parser
*/
#ifndef SQLITE_AMALGAMATION
-SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64));
+SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
#endif
-SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
+SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
#ifdef YYTRACKMAXSTACKDEPTH
SQLITE_PRIVATE int sqlite3ParserStackPeak(void*);
#endif
@@ -18474,7 +18808,6 @@ SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
-SQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
@@ -18496,6 +18829,18 @@ SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8);
#define sqlite3WithPush(x,y,z)
#define sqlite3WithDelete(x,y)
#endif
+#ifndef SQLITE_OMIT_UPSERT
+SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*);
+SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3*,Upsert*);
+SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
+SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);
+SQLITE_PRIVATE void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
+#else
+#define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0)
+#define sqlite3UpsertDelete(x,y)
+#define sqlite3UpsertDup(x,y) ((Upsert*)0)
+#endif
+
/* Declarations for functions in fkey.c. All of these are replaced by
** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
@@ -18928,7 +19273,8 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
- 0x7ffffffe /* iOnceResetThreshold */
+ 0x7ffffffe, /* iOnceResetThreshold */
+ SQLITE_DEFAULT_SORTERREF_SIZE /* szSorterRef */
};
/*
@@ -19391,6 +19737,7 @@ struct Vdbe {
int nOp; /* Number of instructions in the program */
#ifdef SQLITE_DEBUG
int rcApp; /* errcode set by sqlite3_result_error_code() */
+ u32 nWrite; /* Number of write operations that have occurred */
#endif
u16 nResColumn; /* Number of columns in one row of the result set */
u8 errorAction; /* Recovery action to do in case of an error */
@@ -19526,6 +19873,14 @@ SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
+#ifdef SQLITE_DEBUG
+SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);
+SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe*);
+#else
+# define sqlite3VdbeIncrWriteCounter(V,C)
+# define sqlite3VdbeAssertAbortable(V)
+#endif
+
#if !defined(SQLITE_OMIT_SHARED_CACHE)
SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*);
#else
@@ -24218,7 +24573,6 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
#endif /* !defined(SQLITE_MUTEX_OMIT) */
-
/************** End of mutex.c ***********************************************/
/************** Begin file mutex_noop.c **************************************/
/*
@@ -26382,7 +26736,7 @@ static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
** Set the StrAccum object to an error mode.
*/
static void setStrAccumError(StrAccum *p, u8 eError){
- assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );
+ assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG );
p->accError = eError;
p->nAlloc = 0;
}
@@ -26416,8 +26770,8 @@ static char *getTextArg(PrintfArguments *p){
/*
** Render a string given by "fmt" into the StrAccum object.
*/
-SQLITE_PRIVATE void sqlite3VXPrintf(
- StrAccum *pAccum, /* Accumulate results here */
+SQLITE_API void sqlite3_str_vappendf(
+ sqlite3_str *pAccum, /* Accumulate results here */
const char *fmt, /* Format string */
va_list ap /* arguments */
){
@@ -26474,11 +26828,11 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
#else
do{ fmt++; }while( *fmt && *fmt != '%' );
#endif
- sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));
+ sqlite3_str_append(pAccum, bufpt, (int)(fmt - bufpt));
if( *fmt==0 ) break;
}
if( (c=(*++fmt))==0 ){
- sqlite3StrAccumAppend(pAccum, "%", 1);
+ sqlite3_str_append(pAccum, "%", 1);
break;
}
/* Find out what flags are present */
@@ -26656,7 +27010,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
u64 n = (u64)precision + 10 + precision/3;
zOut = zExtra = sqlite3Malloc( n );
if( zOut==0 ){
- setStrAccumError(pAccum, STRACCUM_NOMEM);
+ setStrAccumError(pAccum, SQLITE_NOMEM);
return;
}
nOut = (int)n;
@@ -26781,7 +27135,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
bufpt = zExtra
= sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
if( bufpt==0 ){
- setStrAccumError(pAccum, STRACCUM_NOMEM);
+ setStrAccumError(pAccum, SQLITE_NOMEM);
return;
}
}
@@ -26913,11 +27267,11 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
if( precision>1 ){
width -= precision-1;
if( width>1 && !flag_leftjustify ){
- sqlite3AppendChar(pAccum, width-1, ' ');
+ sqlite3_str_appendchar(pAccum, width-1, ' ');
width = 0;
}
while( precision-- > 1 ){
- sqlite3StrAccumAppend(pAccum, buf, length);
+ sqlite3_str_append(pAccum, buf, length);
}
}
bufpt = buf;
@@ -27003,7 +27357,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
if( n>etBUFSIZE ){
bufpt = zExtra = sqlite3Malloc( n );
if( bufpt==0 ){
- setStrAccumError(pAccum, STRACCUM_NOMEM);
+ setStrAccumError(pAccum, SQLITE_NOMEM);
return;
}
}else{
@@ -27027,7 +27381,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
pToken = va_arg(ap, Token*);
assert( bArgList==0 );
if( pToken && pToken->n ){
- sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);
+ sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
}
length = width = 0;
break;
@@ -27043,10 +27397,10 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
assert( bArgList==0 );
assert( k>=0 && k<pSrc->nSrc );
if( pItem->zDatabase ){
- sqlite3StrAccumAppendAll(pAccum, pItem->zDatabase);
- sqlite3StrAccumAppend(pAccum, ".", 1);
+ sqlite3_str_appendall(pAccum, pItem->zDatabase);
+ sqlite3_str_append(pAccum, ".", 1);
}
- sqlite3StrAccumAppendAll(pAccum, pItem->zName);
+ sqlite3_str_appendall(pAccum, pItem->zName);
length = width = 0;
break;
}
@@ -27065,11 +27419,11 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
*/
width -= length;
if( width>0 ){
- if( !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
- sqlite3StrAccumAppend(pAccum, bufpt, length);
- if( flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
+ if( !flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');
+ sqlite3_str_append(pAccum, bufpt, length);
+ if( flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');
}else{
- sqlite3StrAccumAppend(pAccum, bufpt, length);
+ sqlite3_str_append(pAccum, bufpt, length);
}
if( zExtra ){
@@ -27090,13 +27444,13 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zNew;
assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
if( p->accError ){
- testcase(p->accError==STRACCUM_TOOBIG);
- testcase(p->accError==STRACCUM_NOMEM);
+ testcase(p->accError==SQLITE_TOOBIG);
+ testcase(p->accError==SQLITE_NOMEM);
return 0;
}
if( p->mxAlloc==0 ){
N = p->nAlloc - p->nChar - 1;
- setStrAccumError(p, STRACCUM_TOOBIG);
+ setStrAccumError(p, SQLITE_TOOBIG);
return N;
}else{
char *zOld = isMalloced(p) ? p->zText : 0;
@@ -27108,8 +27462,8 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
szNew += p->nChar;
}
if( szNew > p->mxAlloc ){
- sqlite3StrAccumReset(p);
- setStrAccumError(p, STRACCUM_TOOBIG);
+ sqlite3_str_reset(p);
+ setStrAccumError(p, SQLITE_TOOBIG);
return 0;
}else{
p->nAlloc = (int)szNew;
@@ -27126,8 +27480,8 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
p->nAlloc = sqlite3DbMallocSize(p->db, zNew);
p->printfFlags |= SQLITE_PRINTF_MALLOCED;
}else{
- sqlite3StrAccumReset(p);
- setStrAccumError(p, STRACCUM_NOMEM);
+ sqlite3_str_reset(p);
+ setStrAccumError(p, SQLITE_NOMEM);
return 0;
}
}
@@ -27137,7 +27491,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
/*
** Append N copies of character c to the given string buffer.
*/
-SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
+SQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){
testcase( p->nChar + (i64)N > 0x7fffffff );
if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
return;
@@ -27149,9 +27503,9 @@ SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
** The StrAccum "p" is not large enough to accept N new bytes of z[].
** So enlarge if first, then do the append.
**
-** This is a helper routine to sqlite3StrAccumAppend() that does special-case
+** This is a helper routine to sqlite3_str_append() that does special-case
** work (enlarging the buffer) using tail recursion, so that the
-** sqlite3StrAccumAppend() routine can use fast calling semantics.
+** sqlite3_str_append() routine can use fast calling semantics.
*/
static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){
N = sqlite3StrAccumEnlarge(p, N);
@@ -27165,7 +27519,7 @@ static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){
** Append N bytes of text from z to the StrAccum object. Increase the
** size of the memory allocation for StrAccum if necessary.
*/
-SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
+SQLITE_API void sqlite3_str_append(sqlite3_str *p, const char *z, int N){
assert( z!=0 || N==0 );
assert( p->zText!=0 || p->nChar==0 || p->accError );
assert( N>=0 );
@@ -27182,8 +27536,8 @@ SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
/*
** Append the complete text of zero-terminated string z[] to the p string.
*/
-SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){
- sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z));
+SQLITE_API void sqlite3_str_appendall(sqlite3_str *p, const char *z){
+ sqlite3_str_append(p, z, sqlite3Strlen30(z));
}
@@ -27200,7 +27554,7 @@ static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){
memcpy(zText, p->zText, p->nChar+1);
p->printfFlags |= SQLITE_PRINTF_MALLOCED;
}else{
- setStrAccumError(p, STRACCUM_NOMEM);
+ setStrAccumError(p, SQLITE_NOMEM);
}
p->zText = zText;
return zText;
@@ -27216,13 +27570,55 @@ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
}
/*
+** This singleton is an sqlite3_str object that is returned if
+** sqlite3_malloc() fails to provide space for a real one. This
+** sqlite3_str object accepts no new text and always returns
+** an SQLITE_NOMEM error.
+*/
+static sqlite3_str sqlite3OomStr = {
+ 0, 0, 0, 0, 0, SQLITE_NOMEM, 0
+};
+
+/* Finalize a string created using sqlite3_str_new().
+*/
+SQLITE_API char *sqlite3_str_finish(sqlite3_str *p){
+ char *z;
+ if( p!=0 && p!=&sqlite3OomStr ){
+ z = sqlite3StrAccumFinish(p);
+ sqlite3_free(p);
+ }else{
+ z = 0;
+ }
+ return z;
+}
+
+/* Return any error code associated with p */
+SQLITE_API int sqlite3_str_errcode(sqlite3_str *p){
+ return p ? p->accError : SQLITE_NOMEM;
+}
+
+/* Return the current length of p in bytes */
+SQLITE_API int sqlite3_str_length(sqlite3_str *p){
+ return p ? p->nChar : 0;
+}
+
+/* Return the current value for p */
+SQLITE_API char *sqlite3_str_value(sqlite3_str *p){
+ if( p==0 || p->nChar==0 ) return 0;
+ p->zText[p->nChar] = 0;
+ return p->zText;
+}
+
+/*
** Reset an StrAccum string. Reclaim all malloced memory.
*/
-SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
+SQLITE_API void sqlite3_str_reset(StrAccum *p){
if( isMalloced(p) ){
sqlite3DbFree(p->db, p->zText);
p->printfFlags &= ~SQLITE_PRINTF_MALLOCED;
}
+ p->nAlloc = 0;
+ p->nChar = 0;
p->zText = 0;
}
@@ -27250,6 +27646,18 @@ SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, i
p->printfFlags = 0;
}
+/* Allocate and initialize a new dynamic string object */
+SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3 *db){
+ sqlite3_str *p = sqlite3_malloc64(sizeof(*p));
+ if( p ){
+ sqlite3StrAccumInit(p, 0, 0, 0,
+ db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
+ }else{
+ p = &sqlite3OomStr;
+ }
+ return p;
+}
+
/*
** Print into memory obtained from sqliteMalloc(). Use the internal
** %-conversion extensions.
@@ -27262,9 +27670,9 @@ SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list a
sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),
db->aLimit[SQLITE_LIMIT_LENGTH]);
acc.printfFlags = SQLITE_PRINTF_INTERNAL;
- sqlite3VXPrintf(&acc, zFormat, ap);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
- if( acc.accError==STRACCUM_NOMEM ){
+ if( acc.accError==SQLITE_NOMEM ){
sqlite3OomFault(db);
}
return z;
@@ -27302,7 +27710,7 @@ SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
if( sqlite3_initialize() ) return 0;
#endif
sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
- sqlite3VXPrintf(&acc, zFormat, ap);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
return z;
}
@@ -27347,7 +27755,7 @@ SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_li
}
#endif
sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);
- sqlite3VXPrintf(&acc, zFormat, ap);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
zBuf[acc.nChar] = 0;
return zBuf;
}
@@ -27369,7 +27777,7 @@ SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
** allocate memory because it might be called while the memory allocator
** mutex is held.
**
-** sqlite3VXPrintf() might ask for *temporary* memory allocations for
+** sqlite3_str_vappendf() might ask for *temporary* memory allocations for
** certain format characters (%q) or for very large precisions or widths.
** Care must be taken that any sqlite3_log() calls that occur while the
** memory mutex is held do not use these mechanisms.
@@ -27379,7 +27787,7 @@ static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);
- sqlite3VXPrintf(&acc, zFormat, ap);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,
sqlite3StrAccumFinish(&acc));
}
@@ -27408,7 +27816,7 @@ SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
char zBuf[500];
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
va_start(ap,zFormat);
- sqlite3VXPrintf(&acc, zFormat, ap);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
va_end(ap);
sqlite3StrAccumFinish(&acc);
#ifdef SQLITE_OS_TRACE_PROC
@@ -27425,13 +27833,13 @@ SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
/*
-** variable-argument wrapper around sqlite3VXPrintf(). The bFlags argument
+** variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument
** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.
*/
-SQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){
+SQLITE_API void sqlite3_str_appendf(StrAccum *p, const char *zFormat, ...){
va_list ap;
va_start(ap,zFormat);
- sqlite3VXPrintf(p, zFormat, ap);
+ sqlite3_str_vappendf(p, zFormat, ap);
va_end(ap);
}
@@ -27497,15 +27905,17 @@ static void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
if( p ){
for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
- sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4);
+ sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
}
- sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
+ sqlite3_str_append(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
+ }
+ if( zFormat!=0 ){
+ va_start(ap, zFormat);
+ sqlite3_str_vappendf(&acc, zFormat, ap);
+ va_end(ap);
+ assert( acc.nChar>0 );
+ sqlite3_str_append(&acc, "\n", 1);
}
- va_start(ap, zFormat);
- sqlite3VXPrintf(&acc, zFormat, ap);
- va_end(ap);
- assert( acc.nChar>0 );
- if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1);
sqlite3StrAccumFinish(&acc);
fprintf(stdout,"%s", zBuf);
fflush(stdout);
@@ -27538,17 +27948,17 @@ SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 m
char zLine[1000];
const struct Cte *pCte = &pWith->a[i];
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
- sqlite3XPrintf(&x, "%s", pCte->zName);
+ sqlite3_str_appendf(&x, "%s", pCte->zName);
if( pCte->pCols && pCte->pCols->nExpr>0 ){
char cSep = '(';
int j;
for(j=0; j<pCte->pCols->nExpr; j++){
- sqlite3XPrintf(&x, "%c%s", cSep, pCte->pCols->a[j].zName);
+ sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zName);
cSep = ',';
}
- sqlite3XPrintf(&x, ")");
+ sqlite3_str_appendf(&x, ")");
}
- sqlite3XPrintf(&x, " AS");
+ sqlite3_str_appendf(&x, " AS");
sqlite3StrAccumFinish(&x);
sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1);
sqlite3TreeViewSelect(pView, pCte->pSelect, 0);
@@ -27613,20 +28023,20 @@ SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 m
StrAccum x;
char zLine[100];
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
- sqlite3XPrintf(&x, "{%d,*}", pItem->iCursor);
+ sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
if( pItem->zDatabase ){
- sqlite3XPrintf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
+ sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
}else if( pItem->zName ){
- sqlite3XPrintf(&x, " %s", pItem->zName);
+ sqlite3_str_appendf(&x, " %s", pItem->zName);
}
if( pItem->pTab ){
- sqlite3XPrintf(&x, " tabname=%Q", pItem->pTab->zName);
+ sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
}
if( pItem->zAlias ){
- sqlite3XPrintf(&x, " (AS %s)", pItem->zAlias);
+ sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
}
if( pItem->fg.jointype & JT_LEFT ){
- sqlite3XPrintf(&x, " LEFT-JOIN");
+ sqlite3_str_appendf(&x, " LEFT-JOIN");
}
sqlite3StrAccumFinish(&x);
sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1);
@@ -27975,16 +28385,21 @@ SQLITE_PRIVATE void sqlite3TreeViewBareExprList(
for(i=0; i<pList->nExpr; i++){
int j = pList->a[i].u.x.iOrderByCol;
char *zName = pList->a[i].zName;
+ int moreToFollow = i<pList->nExpr - 1;
if( j || zName ){
- sqlite3TreeViewPush(pView, 0);
- }
- if( zName ){
- sqlite3TreeViewLine(pView, "AS %s", zName);
- }
- if( j ){
- sqlite3TreeViewLine(pView, "iOrderByCol=%d", j);
+ sqlite3TreeViewPush(pView, moreToFollow);
+ moreToFollow = 0;
+ sqlite3TreeViewLine(pView, 0);
+ if( zName ){
+ fprintf(stdout, "AS %s ", zName);
+ }
+ if( j ){
+ fprintf(stdout, "iOrderByCol=%d", j);
+ }
+ fprintf(stdout, "\n");
+ fflush(stdout);
}
- sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
+ sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow);
if( j || zName ){
sqlite3TreeViewPop(pView);
}
@@ -30950,22 +31365,22 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 81 */ "RealAffinity" OpHelp(""),
/* 82 */ "Cast" OpHelp("affinity(r[P1])"),
/* 83 */ "Permutation" OpHelp(""),
- /* 84 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
- /* 85 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
- /* 86 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
- /* 87 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
- /* 88 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
- /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
- /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
- /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
- /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
- /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
- /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
- /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
- /* 96 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
- /* 97 */ "String8" OpHelp("r[P2]='P4'"),
- /* 98 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
- /* 99 */ "Column" OpHelp("r[P3]=PX"),
+ /* 84 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
+ /* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
+ /* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
+ /* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
+ /* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
+ /* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
+ /* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
+ /* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
+ /* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
+ /* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
+ /* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
+ /* 95 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
+ /* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
+ /* 97 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
+ /* 98 */ "Column" OpHelp("r[P3]=PX"),
+ /* 99 */ "String8" OpHelp("r[P2]='P4'"),
/* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
/* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
/* 102 */ "Count" OpHelp("r[P2]=count()"),
@@ -30998,9 +31413,9 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 129 */ "IdxInsert" OpHelp("key=r[P2]"),
/* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
/* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
- /* 132 */ "Real" OpHelp("r[P2]=P4"),
- /* 133 */ "IdxRowid" OpHelp("r[P2]=rowid"),
- /* 134 */ "Destroy" OpHelp(""),
+ /* 132 */ "IdxRowid" OpHelp("r[P2]=rowid"),
+ /* 133 */ "Destroy" OpHelp(""),
+ /* 134 */ "Real" OpHelp("r[P2]=P4"),
/* 135 */ "Clear" OpHelp(""),
/* 136 */ "ResetSorter" OpHelp(""),
/* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
@@ -31037,6 +31452,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 168 */ "CursorHint" OpHelp(""),
/* 169 */ "Noop" OpHelp(""),
/* 170 */ "Explain" OpHelp(""),
+ /* 171 */ "Abortable" OpHelp(""),
};
return azName[i];
}
@@ -35023,7 +35439,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
do{
err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);
}while( err==EINTR );
- if( err ) return SQLITE_IOERR_WRITE;
+ if( err && err!=EINVAL ) return SQLITE_IOERR_WRITE;
#else
/* If the OS does not have posix_fallocate(), fake it. Write a
** single byte to the last byte in each block that falls entirely
@@ -39549,22 +39965,6 @@ struct winVfsAppData {
#endif
/*
- * The value used with sqlite3_win32_set_directory() to specify that
- * the data directory should be changed.
- */
-#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE
-# define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1)
-#endif
-
-/*
- * The value used with sqlite3_win32_set_directory() to specify that
- * the temporary directory should be changed.
- */
-#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE
-# define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2)
-#endif
-
-/*
* If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the
* various Win32 API heap functions instead of our own.
*/
@@ -41160,13 +41560,13 @@ SQLITE_API char *sqlite3_win32_utf8_to_mbcs_v2(const char *zText, int useAnsi){
}
/*
-** This function sets the data directory or the temporary directory based on
-** the provided arguments. The type argument must be 1 in order to set the
-** data directory or 2 in order to set the temporary directory. The zValue
-** argument is the name of the directory to use. The return value will be
-** SQLITE_OK if successful.
+** This function is the same as sqlite3_win32_set_directory (below); however,
+** it accepts a UTF-8 string.
*/
-SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
+SQLITE_API int sqlite3_win32_set_directory8(
+ unsigned long type, /* Identifier for directory being set or reset */
+ const char *zValue /* New value for directory being set or reset */
+){
char **ppDirectory = 0;
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
@@ -41182,21 +41582,54 @@ SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
);
assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );
if( ppDirectory ){
- char *zValueUtf8 = 0;
+ char *zCopy = 0;
if( zValue && zValue[0] ){
- zValueUtf8 = winUnicodeToUtf8(zValue);
- if ( zValueUtf8==0 ){
+ zCopy = sqlite3_mprintf("%s", zValue);
+ if ( zCopy==0 ){
return SQLITE_NOMEM_BKPT;
}
}
sqlite3_free(*ppDirectory);
- *ppDirectory = zValueUtf8;
+ *ppDirectory = zCopy;
return SQLITE_OK;
}
return SQLITE_ERROR;
}
/*
+** This function is the same as sqlite3_win32_set_directory (below); however,
+** it accepts a UTF-16 string.
+*/
+SQLITE_API int sqlite3_win32_set_directory16(
+ unsigned long type, /* Identifier for directory being set or reset */
+ const void *zValue /* New value for directory being set or reset */
+){
+ int rc;
+ char *zUtf8 = 0;
+ if( zValue ){
+ zUtf8 = sqlite3_win32_unicode_to_utf8(zValue);
+ if( zUtf8==0 ) return SQLITE_NOMEM_BKPT;
+ }
+ rc = sqlite3_win32_set_directory8(type, zUtf8);
+ if( zUtf8 ) sqlite3_free(zUtf8);
+ return rc;
+}
+
+/*
+** This function sets the data directory or the temporary directory based on
+** the provided arguments. The type argument must be 1 in order to set the
+** data directory or 2 in order to set the temporary directory. The zValue
+** argument is the name of the directory to use. The return value will be
+** SQLITE_OK if successful.
+*/
+SQLITE_API int sqlite3_win32_set_directory(
+ unsigned long type, /* Identifier for directory being set or reset */
+ void *zValue /* New value for directory being set or reset */
+){
+ return sqlite3_win32_set_directory16(type, zValue);
+}
+
+/*
** The return value of winGetLastErrorMsg
** is zero if the error message fits in the buffer, or non-zero
** otherwise (if the message was truncated).
@@ -61482,10 +61915,10 @@ static void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){
skipOk = 0;
}
}
- db->skipBtreeMutex = skipOk;
+ db->noSharedCache = skipOk;
}
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
- if( db->skipBtreeMutex==0 ) btreeEnterAll(db);
+ if( db->noSharedCache==0 ) btreeEnterAll(db);
}
static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){
int i;
@@ -61497,7 +61930,7 @@ static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){
}
}
SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
- if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);
+ if( db->noSharedCache==0 ) btreeLeaveAll(db);
}
#ifndef NDEBUG
@@ -62462,7 +62895,11 @@ static int btreeRestoreCursorPosition(BtCursor *pCur){
** back to where it ought to be if this routine returns true.
*/
SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur){
- return pCur->eState!=CURSOR_VALID;
+ assert( EIGHT_BYTE_ALIGNMENT(pCur)
+ || pCur==sqlite3BtreeFakeValidCursor() );
+ assert( offsetof(BtCursor, eState)==0 );
+ assert( sizeof(pCur->eState)==1 );
+ return CURSOR_VALID != *(u8*)pCur;
}
/*
@@ -64570,6 +65007,10 @@ static void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){
# define setDefaultSyncFlag(pBt,safety_level)
#endif
+/* Forward declaration */
+static int newDatabase(BtShared*);
+
+
/*
** Get a reference to pPage1 of the database file. This will
** also acquire a readlock on that file.
@@ -64601,6 +65042,9 @@ static int lockBtree(BtShared *pBt){
if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
nPage = nPageFile;
}
+ if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){
+ nPage = 0;
+ }
if( nPage>0 ){
u32 pageSize;
u32 usableSize;
@@ -67817,7 +68261,9 @@ static int clearCell(
if( pInfo->nLocal==pInfo->nPayload ){
return SQLITE_OK; /* No overflow pages. Return without doing anything */
}
- if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){
+ testcase( pCell + pInfo->nSize == pPage->aDataEnd );
+ testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
+ if( pCell + pInfo->nSize > pPage->aDataEnd ){
/* Cell extends past end of page */
return SQLITE_CORRUPT_PAGE(pPage);
}
@@ -69743,6 +70189,94 @@ static int balance(BtCursor *pCur){
return rc;
}
+/* Overwrite content from pX into pDest. Only do the write if the
+** content is different from what is already there.
+*/
+static int btreeOverwriteContent(
+ MemPage *pPage, /* MemPage on which writing will occur */
+ u8 *pDest, /* Pointer to the place to start writing */
+ const BtreePayload *pX, /* Source of data to write */
+ int iOffset, /* Offset of first byte to write */
+ int iAmt /* Number of bytes to be written */
+){
+ int nData = pX->nData - iOffset;
+ if( nData<=0 ){
+ /* Overwritting with zeros */
+ int i;
+ for(i=0; i<iAmt && pDest[i]==0; i++){}
+ if( i<iAmt ){
+ int rc = sqlite3PagerWrite(pPage->pDbPage);
+ if( rc ) return rc;
+ memset(pDest + i, 0, iAmt - i);
+ }
+ }else{
+ if( nData<iAmt ){
+ /* Mixed read data and zeros at the end. Make a recursive call
+ ** to write the zeros then fall through to write the real data */
+ int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
+ iAmt-nData);
+ if( rc ) return rc;
+ iAmt = nData;
+ }
+ if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
+ int rc = sqlite3PagerWrite(pPage->pDbPage);
+ if( rc ) return rc;
+ memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
+ }
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Overwrite the cell that cursor pCur is pointing to with fresh content
+** contained in pX.
+*/
+static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
+ int iOffset; /* Next byte of pX->pData to write */
+ int nTotal = pX->nData + pX->nZero; /* Total bytes of to write */
+ int rc; /* Return code */
+ MemPage *pPage = pCur->pPage; /* Page being written */
+ BtShared *pBt; /* Btree */
+ Pgno ovflPgno; /* Next overflow page to write */
+ u32 ovflPageSize; /* Size to write on overflow page */
+
+ if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd ){
+ return SQLITE_CORRUPT_BKPT;
+ }
+ /* Overwrite the local portion first */
+ rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
+ 0, pCur->info.nLocal);
+ if( rc ) return rc;
+ if( pCur->info.nLocal==nTotal ) return SQLITE_OK;
+
+ /* Now overwrite the overflow pages */
+ iOffset = pCur->info.nLocal;
+ assert( nTotal>=0 );
+ assert( iOffset>=0 );
+ ovflPgno = get4byte(pCur->info.pPayload + iOffset);
+ pBt = pPage->pBt;
+ ovflPageSize = pBt->usableSize - 4;
+ do{
+ rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
+ if( rc ) return rc;
+ if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
+ rc = SQLITE_CORRUPT_BKPT;
+ }else{
+ if( iOffset+ovflPageSize<(u32)nTotal ){
+ ovflPgno = get4byte(pPage->aData);
+ }else{
+ ovflPageSize = nTotal - iOffset;
+ }
+ rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
+ iOffset, ovflPageSize);
+ }
+ sqlite3PagerUnref(pPage->pDbPage);
+ if( rc ) return rc;
+ iOffset += ovflPageSize;
+ }while( iOffset<nTotal );
+ return SQLITE_OK;
+}
+
/*
** Insert a new record into the BTree. The content of the new record
@@ -69833,35 +70367,86 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
/* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
- ** to a row with the same key as the new entry being inserted. */
- assert( (flags & BTREE_SAVEPOSITION)==0 ||
- ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );
+ ** to a row with the same key as the new entry being inserted.
+ */
+#ifdef SQLITE_DEBUG
+ if( flags & BTREE_SAVEPOSITION ){
+ assert( pCur->curFlags & BTCF_ValidNKey );
+ assert( pX->nKey==pCur->info.nKey );
+ assert( pCur->info.nSize!=0 );
+ assert( loc==0 );
+ }
+#endif
- /* If the cursor is currently on the last row and we are appending a
- ** new row onto the end, set the "loc" to avoid an unnecessary
- ** btreeMoveto() call */
+ /* On the other hand, BTREE_SAVEPOSITION==0 does not imply
+ ** that the cursor is not pointing to a row to be overwritten.
+ ** So do a complete check.
+ */
if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){
- loc = 0;
+ /* The cursor is pointing to the entry that is to be
+ ** overwritten */
+ assert( pX->nData>=0 && pX->nZero>=0 );
+ if( pCur->info.nSize!=0
+ && pCur->info.nPayload==(u32)pX->nData+pX->nZero
+ ){
+ /* New entry is the same size as the old. Do an overwrite */
+ return btreeOverwriteCell(pCur, pX);
+ }
+ assert( loc==0 );
}else if( loc==0 ){
+ /* The cursor is *not* pointing to the cell to be overwritten, nor
+ ** to an adjacent cell. Move the cursor so that it is pointing either
+ ** to the cell to be overwritten or an adjacent cell.
+ */
rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
if( rc ) return rc;
}
- }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
- if( pX->nMem ){
- UnpackedRecord r;
- r.pKeyInfo = pCur->pKeyInfo;
- r.aMem = pX->aMem;
- r.nField = pX->nMem;
- r.default_rc = 0;
- r.errCode = 0;
- r.r1 = 0;
- r.r2 = 0;
- r.eqSeen = 0;
- rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
- }else{
- rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
+ }else{
+ /* This is an index or a WITHOUT ROWID table */
+
+ /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
+ ** to a row with the same key as the new entry being inserted.
+ */
+ assert( (flags & BTREE_SAVEPOSITION)==0 || loc==0 );
+
+ /* If the cursor is not already pointing either to the cell to be
+ ** overwritten, or if a new cell is being inserted, if the cursor is
+ ** not pointing to an immediately adjacent cell, then move the cursor
+ ** so that it does.
+ */
+ if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
+ if( pX->nMem ){
+ UnpackedRecord r;
+ r.pKeyInfo = pCur->pKeyInfo;
+ r.aMem = pX->aMem;
+ r.nField = pX->nMem;
+ r.default_rc = 0;
+ r.errCode = 0;
+ r.r1 = 0;
+ r.r2 = 0;
+ r.eqSeen = 0;
+ rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
+ }else{
+ rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
+ }
+ if( rc ) return rc;
}
- if( rc ) return rc;
+
+ /* If the cursor is currently pointing to an entry to be overwritten
+ ** and the new content is the same as as the old, then use the
+ ** overwrite optimization.
+ */
+ if( loc==0 ){
+ getCellInfo(pCur);
+ if( pCur->info.nKey==pX->nKey ){
+ BtreePayload x2;
+ x2.pData = pX->pKey;
+ x2.nData = pX->nKey;
+ x2.nZero = 0;
+ return btreeOverwriteCell(pCur, &x2);
+ }
+ }
+
}
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -70700,14 +71285,14 @@ static void checkAppendMsg(
pCheck->nErr++;
va_start(ap, zFormat);
if( pCheck->errMsg.nChar ){
- sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1);
+ sqlite3_str_append(&pCheck->errMsg, "\n", 1);
}
if( pCheck->zPfx ){
- sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
+ sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
}
- sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);
+ sqlite3_str_vappendf(&pCheck->errMsg, zFormat, ap);
va_end(ap);
- if( pCheck->errMsg.accError==STRACCUM_NOMEM ){
+ if( pCheck->errMsg.accError==SQLITE_NOMEM ){
pCheck->mallocFailed = 1;
}
}
@@ -71291,11 +71876,11 @@ integrity_ck_cleanup:
sqlite3PageFree(sCheck.heap);
sqlite3_free(sCheck.aPgRef);
if( sCheck.mallocFailed ){
- sqlite3StrAccumReset(&sCheck.errMsg);
+ sqlite3_str_reset(&sCheck.errMsg);
sCheck.nErr++;
}
*pnErr = sCheck.nErr;
- if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);
+ if( sCheck.nErr==0 ) sqlite3_str_reset(&sCheck.errMsg);
/* Make sure this analysis did not leave any unref() pages. */
assert( nRef==sqlite3PagerRefcount(pBt->pPager) );
sqlite3BtreeLeave(p);
@@ -73195,7 +73780,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
}
/* A no-op destructor */
-static void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }
+SQLITE_PRIVATE void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }
/*
** Set the value stored in *pMem should already be a NULL.
@@ -73873,12 +74458,16 @@ static int valueFromExpr(
0, SQLITE_DYNAMIC);
}
#endif
-
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
else if( op==TK_FUNCTION && pCtx!=0 ){
rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
}
#endif
+ else if( op==TK_TRUEFALSE ){
+ pVal = valueNew(db, pCtx);
+ pVal->flags = MEM_Int;
+ pVal->u.i = pExpr->u.zToken[4]==0;
+ }
*ppVal = pVal;
return rc;
@@ -74537,6 +75126,49 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(
return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);
}
+#ifndef SQLITE_OMIT_EXPLAIN
+/*
+** Return the address of the current EXPLAIN QUERY PLAN baseline.
+** 0 means "none".
+*/
+SQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse *pParse){
+ VdbeOp *pOp;
+ if( pParse->addrExplain==0 ) return 0;
+ pOp = sqlite3VdbeGetOp(pParse->pVdbe, pParse->addrExplain);
+ return pOp->p2;
+}
+
+/*
+** Add a new OP_Explain opcode.
+**
+** If the bPush flag is true, then make this opcode the parent for
+** subsequent Explains until sqlite3VdbeExplainPop() is called.
+*/
+SQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
+ if( pParse->explain==2 ){
+ char *zMsg;
+ Vdbe *v = pParse->pVdbe;
+ va_list ap;
+ int iThis;
+ va_start(ap, zFmt);
+ zMsg = sqlite3VMPrintf(pParse->db, zFmt, ap);
+ va_end(ap);
+ v = pParse->pVdbe;
+ iThis = v->nOp;
+ sqlite3VdbeAddOp4(v, OP_Explain, iThis, pParse->addrExplain, 0,
+ zMsg, P4_DYNAMIC);
+ if( bPush) pParse->addrExplain = iThis;
+ }
+}
+
+/*
+** Pop the EXPLAIN QUERY PLAN stack one level.
+*/
+SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse *pParse){
+ pParse->addrExplain = sqlite3VdbeExplainParent(pParse);
+}
+#endif /* SQLITE_OMIT_EXPLAIN */
+
/*
** Add an OP_ParseSchema opcode. This routine is broken out from
** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
@@ -74626,10 +75258,29 @@ SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){
assert( j<p->nLabel );
assert( j>=0 );
if( p->aLabel ){
+#ifdef SQLITE_DEBUG
+ if( p->db->flags & SQLITE_VdbeAddopTrace ){
+ printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
+ }
+#endif
+ assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
p->aLabel[j] = v->nOp;
}
}
+#ifdef SQLITE_COVERAGE_TEST
+/*
+** Return TRUE if and only if the label x has already been resolved.
+** Return FALSE (zero) if label x is still unresolved.
+**
+** This routine is only used inside of testcase() macros, and so it
+** only exists when measuring test coverage.
+*/
+SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe *v, int x){
+ return v->pParse->aLabel && v->pParse->aLabel[ADDR(x)]>=0;
+}
+#endif /* SQLITE_COVERAGE_TEST */
+
/*
** Mark the VDBE as one that can only be run one time.
*/
@@ -74775,6 +75426,32 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
}
#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */
+#ifdef SQLITE_DEBUG
+/*
+** Increment the nWrite counter in the VDBE if the cursor is not an
+** ephemeral cursor, or if the cursor argument is NULL.
+*/
+SQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe *p, VdbeCursor *pC){
+ if( pC==0
+ || (pC->eCurType!=CURTYPE_SORTER
+ && pC->eCurType!=CURTYPE_PSEUDO
+ && !pC->isEphemeral)
+ ){
+ p->nWrite++;
+ }
+}
+#endif
+
+#ifdef SQLITE_DEBUG
+/*
+** Assert if an Abort at this point in time might result in a corrupt
+** database.
+*/
+SQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe *p){
+ assert( p->nWrite==0 || p->usesStmtJournal );
+}
+#endif
+
/*
** This routine is called after all opcodes have been inserted. It loops
** through all the opcodes and fixes up some details.
@@ -74935,6 +75612,17 @@ SQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p){
#endif
/*
+** Generate code (a single OP_Abortable opcode) that will
+** verify that the VDBE program can safely call Abort in the current
+** context.
+*/
+#if defined(SQLITE_DEBUG)
+SQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int onError){
+ if( onError==OE_Abort ) sqlite3VdbeAddOp0(p, OP_Abortable);
+}
+#endif
+
+/*
** This function returns a pointer to the array of opcodes associated with
** the Vdbe passed as the first argument. It is the callers responsibility
** to arrange for the returned array to be eventually freed using the
@@ -75478,23 +76166,23 @@ static void displayP4Expr(StrAccum *p, Expr *pExpr){
const char *zOp = 0;
switch( pExpr->op ){
case TK_STRING:
- sqlite3XPrintf(p, "%Q", pExpr->u.zToken);
+ sqlite3_str_appendf(p, "%Q", pExpr->u.zToken);
break;
case TK_INTEGER:
- sqlite3XPrintf(p, "%d", pExpr->u.iValue);
+ sqlite3_str_appendf(p, "%d", pExpr->u.iValue);
break;
case TK_NULL:
- sqlite3XPrintf(p, "NULL");
+ sqlite3_str_appendf(p, "NULL");
break;
case TK_REGISTER: {
- sqlite3XPrintf(p, "r[%d]", pExpr->iTable);
+ sqlite3_str_appendf(p, "r[%d]", pExpr->iTable);
break;
}
case TK_COLUMN: {
if( pExpr->iColumn<0 ){
- sqlite3XPrintf(p, "rowid");
+ sqlite3_str_appendf(p, "rowid");
}else{
- sqlite3XPrintf(p, "c%d", (int)pExpr->iColumn);
+ sqlite3_str_appendf(p, "c%d", (int)pExpr->iColumn);
}
break;
}
@@ -75526,18 +76214,18 @@ static void displayP4Expr(StrAccum *p, Expr *pExpr){
case TK_NOTNULL: zOp = "NOTNULL"; break;
default:
- sqlite3XPrintf(p, "%s", "expr");
+ sqlite3_str_appendf(p, "%s", "expr");
break;
}
if( zOp ){
- sqlite3XPrintf(p, "%s(", zOp);
+ sqlite3_str_appendf(p, "%s(", zOp);
displayP4Expr(p, pExpr->pLeft);
if( pExpr->pRight ){
- sqlite3StrAccumAppend(p, ",", 1);
+ sqlite3_str_append(p, ",", 1);
displayP4Expr(p, pExpr->pRight);
}
- sqlite3StrAccumAppend(p, ")", 1);
+ sqlite3_str_append(p, ")", 1);
}
}
#endif /* VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS) */
@@ -75558,14 +76246,15 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
int j;
KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
assert( pKeyInfo->aSortOrder!=0 );
- sqlite3XPrintf(&x, "k(%d", pKeyInfo->nKeyField);
+ sqlite3_str_appendf(&x, "k(%d", pKeyInfo->nKeyField);
for(j=0; j<pKeyInfo->nKeyField; j++){
CollSeq *pColl = pKeyInfo->aColl[j];
const char *zColl = pColl ? pColl->zName : "";
if( strcmp(zColl, "BINARY")==0 ) zColl = "B";
- sqlite3XPrintf(&x, ",%s%s", pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
+ sqlite3_str_appendf(&x, ",%s%s",
+ pKeyInfo->aSortOrder[j] ? "-" : "", zColl);
}
- sqlite3StrAccumAppend(&x, ")", 1);
+ sqlite3_str_append(&x, ")", 1);
break;
}
#ifdef SQLITE_ENABLE_CURSOR_HINTS
@@ -75576,31 +76265,31 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
#endif
case P4_COLLSEQ: {
CollSeq *pColl = pOp->p4.pColl;
- sqlite3XPrintf(&x, "(%.20s)", pColl->zName);
+ sqlite3_str_appendf(&x, "(%.20s)", pColl->zName);
break;
}
case P4_FUNCDEF: {
FuncDef *pDef = pOp->p4.pFunc;
- sqlite3XPrintf(&x, "%s(%d)", pDef->zName, pDef->nArg);
+ sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
break;
}
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
case P4_FUNCCTX: {
FuncDef *pDef = pOp->p4.pCtx->pFunc;
- sqlite3XPrintf(&x, "%s(%d)", pDef->zName, pDef->nArg);
+ sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg);
break;
}
#endif
case P4_INT64: {
- sqlite3XPrintf(&x, "%lld", *pOp->p4.pI64);
+ sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64);
break;
}
case P4_INT32: {
- sqlite3XPrintf(&x, "%d", pOp->p4.i);
+ sqlite3_str_appendf(&x, "%d", pOp->p4.i);
break;
}
case P4_REAL: {
- sqlite3XPrintf(&x, "%.16g", *pOp->p4.pReal);
+ sqlite3_str_appendf(&x, "%.16g", *pOp->p4.pReal);
break;
}
case P4_MEM: {
@@ -75608,9 +76297,9 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
if( pMem->flags & MEM_Str ){
zP4 = pMem->z;
}else if( pMem->flags & MEM_Int ){
- sqlite3XPrintf(&x, "%lld", pMem->u.i);
+ sqlite3_str_appendf(&x, "%lld", pMem->u.i);
}else if( pMem->flags & MEM_Real ){
- sqlite3XPrintf(&x, "%.16g", pMem->u.r);
+ sqlite3_str_appendf(&x, "%.16g", pMem->u.r);
}else if( pMem->flags & MEM_Null ){
zP4 = "NULL";
}else{
@@ -75622,7 +76311,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
#ifndef SQLITE_OMIT_VIRTUALTABLE
case P4_VTAB: {
sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
- sqlite3XPrintf(&x, "vtab:%p", pVtab);
+ sqlite3_str_appendf(&x, "vtab:%p", pVtab);
break;
}
#endif
@@ -75632,14 +76321,14 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
int n = ai[0]; /* The first element of an INTARRAY is always the
** count of the number of elements to follow */
for(i=1; i<=n; i++){
- sqlite3XPrintf(&x, ",%d", ai[i]);
+ sqlite3_str_appendf(&x, ",%d", ai[i]);
}
zTemp[0] = '[';
- sqlite3StrAccumAppend(&x, "]", 1);
+ sqlite3_str_append(&x, "]", 1);
break;
}
case P4_SUBPROGRAM: {
- sqlite3XPrintf(&x, "program");
+ sqlite3_str_appendf(&x, "program");
break;
}
case P4_DYNBLOB:
@@ -75648,7 +76337,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
break;
}
case P4_TABLE: {
- sqlite3XPrintf(&x, "%s", pOp->p4.pTab->zName);
+ sqlite3_str_appendf(&x, "%s", pOp->p4.pTab->zName);
break;
}
default: {
@@ -75860,6 +76549,9 @@ SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){
** p->explain==2, only OP_Explain instructions are listed and these
** are shown in a different format. p->explain==2 is used to implement
** EXPLAIN QUERY PLAN.
+** 2018-04-24: In p->explain==2 mode, the OP_Init opcodes of triggers
+** are also shown, so that the boundaries between the main program and
+** each trigger are clear.
**
** When p->explain==1, first the main program is listed, then each of
** the trigger subprograms are listed one by one.
@@ -75922,7 +76614,7 @@ SQLITE_PRIVATE int sqlite3VdbeList(
}
}
- do{
+ while(1){ /* Loop exits via break */
i = p->pc++;
if( i>=nRow ){
p->rc = SQLITE_OK;
@@ -75968,7 +76660,10 @@ SQLITE_PRIVATE int sqlite3VdbeList(
nRow += pOp->p4.pProgram->nOp;
}
}
- }while( p->explain==2 && pOp->opcode!=OP_Explain );
+ if( p->explain<2 ) break;
+ if( pOp->opcode==OP_Explain ) break;
+ if( pOp->opcode==OP_Init && p->pc>1 ) break;
+ }
if( rc==SQLITE_OK ){
if( db->u1.isInterrupted ){
@@ -77160,6 +77855,9 @@ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){
sqlite3DbFree(db, p->zErrMsg);
p->zErrMsg = 0;
p->pResultSet = 0;
+#ifdef SQLITE_DEBUG
+ p->nWrite = 0;
+#endif
/* Save profiling information from this VDBE run.
*/
@@ -78082,13 +78780,10 @@ static int sqlite3IntFloatCompare(i64 i, double r){
i64 y;
double s;
if( r<-9223372036854775808.0 ) return +1;
- if( r>9223372036854775807.0 ) return -1;
+ if( r>=9223372036854775808.0 ) return -1;
y = (i64)r;
if( i<y ) return -1;
- if( i>y ){
- if( y==SMALLEST_INT64 && r>0.0 ) return -1;
- return +1;
- }
+ if( i>y ) return +1;
s = (double)i;
if( s<r ) return -1;
if( s>r ) return +1;
@@ -79767,28 +80462,6 @@ SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
}
/*
-** The following is the implementation of an SQL function that always
-** fails with an error message stating that the function is used in the
-** wrong context. The sqlite3_overload_function() API might construct
-** SQL function that use this routine so that the functions will exist
-** for name resolution but are actually overloaded by the xFindFunction
-** method of virtual tables.
-*/
-SQLITE_PRIVATE void sqlite3InvalidFunction(
- sqlite3_context *context, /* The function calling context */
- int NotUsed, /* Number of arguments to the function */
- sqlite3_value **NotUsed2 /* Value of each argument */
-){
- const char *zName = context->pFunc->zName;
- char *zErr;
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
- zErr = sqlite3_mprintf(
- "unable to use function %s in the requested context", zName);
- sqlite3_result_error(context, zErr, -1);
- sqlite3_free(zErr);
-}
-
-/*
** Create a new aggregate context for p and return a pointer to
** its pMem->z element.
*/
@@ -81055,17 +81728,17 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
while( *zRawSql ){
const char *zStart = zRawSql;
while( *(zRawSql++)!='\n' && *zRawSql );
- sqlite3StrAccumAppend(&out, "-- ", 3);
+ sqlite3_str_append(&out, "-- ", 3);
assert( (zRawSql - zStart) > 0 );
- sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
+ sqlite3_str_append(&out, zStart, (int)(zRawSql-zStart));
}
}else if( p->nVar==0 ){
- sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));
+ sqlite3_str_append(&out, zRawSql, sqlite3Strlen30(zRawSql));
}else{
while( zRawSql[0] ){
n = findNextHostParameter(zRawSql, &nToken);
assert( n>0 );
- sqlite3StrAccumAppend(&out, zRawSql, n);
+ sqlite3_str_append(&out, zRawSql, n);
zRawSql += n;
assert( zRawSql[0] || nToken==0 );
if( nToken==0 ) break;
@@ -81091,11 +81764,11 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
assert( idx>0 && idx<=p->nVar );
pVar = &p->aVar[idx-1];
if( pVar->flags & MEM_Null ){
- sqlite3StrAccumAppend(&out, "NULL", 4);
+ sqlite3_str_append(&out, "NULL", 4);
}else if( pVar->flags & MEM_Int ){
- sqlite3XPrintf(&out, "%lld", pVar->u.i);
+ sqlite3_str_appendf(&out, "%lld", pVar->u.i);
}else if( pVar->flags & MEM_Real ){
- sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
+ sqlite3_str_appendf(&out, "%!.15g", pVar->u.r);
}else if( pVar->flags & MEM_Str ){
int nOut; /* Number of bytes of the string text to include in output */
#ifndef SQLITE_OMIT_UTF16
@@ -81105,7 +81778,7 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
utf8.db = db;
sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
- out.accError = STRACCUM_NOMEM;
+ out.accError = SQLITE_NOMEM;
out.nAlloc = 0;
}
pVar = &utf8;
@@ -81118,38 +81791,38 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }
}
#endif
- sqlite3XPrintf(&out, "'%.*q'", nOut, pVar->z);
+ sqlite3_str_appendf(&out, "'%.*q'", nOut, pVar->z);
#ifdef SQLITE_TRACE_SIZE_LIMIT
if( nOut<pVar->n ){
- sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
+ sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
}
#endif
#ifndef SQLITE_OMIT_UTF16
if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);
#endif
}else if( pVar->flags & MEM_Zero ){
- sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero);
+ sqlite3_str_appendf(&out, "zeroblob(%d)", pVar->u.nZero);
}else{
int nOut; /* Number of bytes of the blob to include in output */
assert( pVar->flags & MEM_Blob );
- sqlite3StrAccumAppend(&out, "x'", 2);
+ sqlite3_str_append(&out, "x'", 2);
nOut = pVar->n;
#ifdef SQLITE_TRACE_SIZE_LIMIT
if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;
#endif
for(i=0; i<nOut; i++){
- sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff);
+ sqlite3_str_appendf(&out, "%02x", pVar->z[i]&0xff);
}
- sqlite3StrAccumAppend(&out, "'", 1);
+ sqlite3_str_append(&out, "'", 1);
#ifdef SQLITE_TRACE_SIZE_LIMIT
if( nOut<pVar->n ){
- sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
+ sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
}
#endif
}
}
}
- if( out.accError ) sqlite3StrAccumReset(&out);
+ if( out.accError ) sqlite3_str_reset(&out);
return sqlite3StrAccumFinish(&out);
}
@@ -82163,6 +82836,9 @@ case OP_Yield: { /* in1, jump */
*/
case OP_HaltIfNull: { /* in3 */
pIn3 = &aMem[pOp->p3];
+#ifdef SQLITE_DEBUG
+ if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }
+#endif
if( (pIn3->flags & MEM_Null)==0 ) break;
/* Fall through into OP_Halt */
}
@@ -82202,6 +82878,9 @@ case OP_Halt: {
int pcx;
pcx = (int)(pOp - aOp);
+#ifdef SQLITE_DEBUG
+ if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }
+#endif
if( pOp->p1==SQLITE_OK && p->pFrame ){
/* Halt the sub-program. Return control to the parent frame. */
pFrame = p->pFrame;
@@ -84572,6 +85251,8 @@ case OP_ReadCookie: { /* out2 */
*/
case OP_SetCookie: {
Db *pDb;
+
+ sqlite3VdbeIncrWriteCounter(p, 0);
assert( pOp->p2<SQLITE_N_BTREE_META );
assert( pOp->p1>=0 && pOp->p1<db->nDb );
assert( DbMaskTest(p->btreeMask, pOp->p1) );
@@ -85535,11 +86216,8 @@ case OP_NewRowid: { /* out2 */
pOut = out2Prerelease(p, pOp);
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
- if( !pC->isTable ){
- rc = SQLITE_CORRUPT_BKPT;
- goto abort_due_to_error;
- }
assert( pC!=0 );
+ assert( pC->isTable );
assert( pC->eCurType==CURTYPE_BTREE );
assert( pC->uc.pCursor!=0 );
{
@@ -85708,6 +86386,7 @@ case OP_InsertInt: {
assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable );
assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );
REGISTER_TRACE(pOp->p2, pData);
+ sqlite3VdbeIncrWriteCounter(p, pC);
if( pOp->opcode==OP_Insert ){
pKey = &aMem[pOp->p3];
@@ -85822,6 +86501,7 @@ case OP_Delete: {
assert( pC->eCurType==CURTYPE_BTREE );
assert( pC->uc.pCursor!=0 );
assert( pC->deferredMoveto==0 );
+ sqlite3VdbeIncrWriteCounter(p, pC);
#ifdef SQLITE_DEBUG
if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
@@ -85990,10 +86670,10 @@ case OP_SorterData: {
** If the P1 cursor must be pointing to a valid row (not a NULL row)
** of a real table, not a pseudo-table.
**
-** If P3!=0 then this opcode is allowed to make an ephermeral pointer
+** If P3!=0 then this opcode is allowed to make an ephemeral pointer
** into the database page. That means that the content of the output
** register will be invalidated as soon as the cursor moves - including
-** moves caused by other cursors that "save" the the current cursors
+** moves caused by other cursors that "save" the current cursors
** position in order that they can write to the same table. If P3==0
** then a copy of the data is made into memory. P3!=0 is faster, but
** P3==0 is safer.
@@ -86440,6 +87120,7 @@ case OP_IdxInsert: { /* in2 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
+ sqlite3VdbeIncrWriteCounter(p, pC);
assert( pC!=0 );
assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
pIn2 = &aMem[pOp->p2];
@@ -86486,6 +87167,7 @@ case OP_IdxDelete: {
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
assert( pC->eCurType==CURTYPE_BTREE );
+ sqlite3VdbeIncrWriteCounter(p, pC);
pCrsr = pC->uc.pCursor;
assert( pCrsr!=0 );
assert( pOp->p5==0 );
@@ -86708,6 +87390,7 @@ case OP_Destroy: { /* out2 */
int iMoved;
int iDb;
+ sqlite3VdbeIncrWriteCounter(p, 0);
assert( p->readOnly==0 );
assert( pOp->p1>1 );
pOut = out2Prerelease(p, pOp);
@@ -86757,6 +87440,7 @@ case OP_Destroy: { /* out2 */
case OP_Clear: {
int nChange;
+ sqlite3VdbeIncrWriteCounter(p, 0);
nChange = 0;
assert( p->readOnly==0 );
assert( DbMaskTest(p->btreeMask, pOp->p2) );
@@ -86806,13 +87490,14 @@ case OP_ResetSorter: {
** Allocate a new b-tree in the main database file if P1==0 or in the
** TEMP database file if P1==1 or in an attached database if
** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table
-** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.
+** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table.
** The root page number of the new b-tree is stored in register P2.
*/
case OP_CreateBtree: { /* out2 */
int pgno;
Db *pDb;
+ sqlite3VdbeIncrWriteCounter(p, 0);
pOut = out2Prerelease(p, pOp);
pgno = 0;
assert( pOp->p3==BTREE_INTKEY || pOp->p3==BTREE_BLOBKEY );
@@ -86832,6 +87517,7 @@ case OP_CreateBtree: { /* out2 */
** Run the SQL statement or statements specified in the P4 string.
*/
case OP_SqlExec: {
+ sqlite3VdbeIncrWriteCounter(p, 0);
db->nSqlExec++;
rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
db->nSqlExec--;
@@ -86921,6 +87607,7 @@ case OP_LoadAnalysis: {
** schema consistent with what is on disk.
*/
case OP_DropTable: {
+ sqlite3VdbeIncrWriteCounter(p, 0);
sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);
break;
}
@@ -86934,6 +87621,7 @@ case OP_DropTable: {
** schema consistent with what is on disk.
*/
case OP_DropIndex: {
+ sqlite3VdbeIncrWriteCounter(p, 0);
sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);
break;
}
@@ -86947,6 +87635,7 @@ case OP_DropIndex: {
** schema consistent with what is on disk.
*/
case OP_DropTrigger: {
+ sqlite3VdbeIncrWriteCounter(p, 0);
sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);
break;
}
@@ -87993,7 +88682,7 @@ case OP_VFilter: { /* jump */
** If the VColumn opcode is being used to fetch the value of
** an unchanging column during an UPDATE operation, then the P5
** value is 1. Otherwise, P5 is 0. The P5 value is returned
-** by sqlite3_vtab_nochange() routine can can be used
+** by sqlite3_vtab_nochange() routine and can be used
** by virtual table implementations to return special "no-change"
** marks which can be more efficient, depending on the virtual table.
*/
@@ -88156,6 +88845,7 @@ case OP_VUpdate: {
|| pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
);
assert( p->readOnly==0 );
+ sqlite3VdbeIncrWriteCounter(p, 0);
pVtab = pOp->p4.pVtab->pVtab;
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
rc = SQLITE_LOCKED;
@@ -88473,6 +89163,22 @@ case OP_CursorHint: {
}
#endif /* SQLITE_ENABLE_CURSOR_HINTS */
+#ifdef SQLITE_DEBUG
+/* Opcode: Abortable * * * * *
+**
+** Verify that an Abort can happen. Assert if an Abort at this point
+** might cause database corruption. This opcode only appears in debugging
+** builds.
+**
+** An Abort is safe if either there have been no writes, or if there is
+** an active statement journal.
+*/
+case OP_Abortable: {
+ sqlite3VdbeAssertAbortable(p);
+ break;
+}
+#endif
+
/* Opcode: Noop * * * * *
**
** Do nothing. This instruction is often useful as a jump
@@ -88484,8 +89190,9 @@ case OP_CursorHint: {
** This opcode records information from the optimizer. It is the
** the same as a no-op. This opcodesnever appears in a real VM program.
*/
-default: { /* This is really OP_Noop and OP_Explain */
+default: { /* This is really OP_Noop, OP_Explain */
assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );
+
break;
}
@@ -92530,29 +93237,31 @@ static void resolveAlias(
assert( pOrig!=0 );
db = pParse->db;
pDup = sqlite3ExprDup(db, pOrig, 0);
- if( pDup==0 ) return;
- if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery);
- if( pExpr->op==TK_COLLATE ){
- pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
- }
- ExprSetProperty(pDup, EP_Alias);
+ if( pDup!=0 ){
+ if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery);
+ if( pExpr->op==TK_COLLATE ){
+ pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
+ }
+ ExprSetProperty(pDup, EP_Alias);
- /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
- ** prevents ExprDelete() from deleting the Expr structure itself,
- ** allowing it to be repopulated by the memcpy() on the following line.
- ** The pExpr->u.zToken might point into memory that will be freed by the
- ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to
- ** make a copy of the token before doing the sqlite3DbFree().
- */
- ExprSetProperty(pExpr, EP_Static);
- sqlite3ExprDelete(db, pExpr);
- memcpy(pExpr, pDup, sizeof(*pExpr));
- if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
- assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
- pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
- pExpr->flags |= EP_MemToken;
+ /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
+ ** prevents ExprDelete() from deleting the Expr structure itself,
+ ** allowing it to be repopulated by the memcpy() on the following line.
+ ** The pExpr->u.zToken might point into memory that will be freed by the
+ ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to
+ ** make a copy of the token before doing the sqlite3DbFree().
+ */
+ ExprSetProperty(pExpr, EP_Static);
+ sqlite3ExprDelete(db, pExpr);
+ memcpy(pExpr, pDup, sizeof(*pExpr));
+ if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
+ assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
+ pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
+ pExpr->flags |= EP_MemToken;
+ }
+ sqlite3DbFree(db, pDup);
}
- sqlite3DbFree(db, pDup);
+ ExprSetProperty(pExpr, EP_Alias);
}
@@ -92646,7 +93355,7 @@ static int lookupName(
struct SrcList_item *pMatch = 0; /* The matching pSrcList item */
NameContext *pTopNC = pNC; /* First namecontext in the list */
Schema *pSchema = 0; /* Schema of the expression */
- int isTrigger = 0; /* True if resolved to a trigger column */
+ int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */
Table *pTab = 0; /* Table hold the row */
Column *pCol; /* A column of pTab */
@@ -92751,22 +93460,35 @@ static int lookupName(
}
} /* if( pSrcList ) */
-#ifndef SQLITE_OMIT_TRIGGER
+#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
/* If we have not already resolved the name, then maybe
- ** it is a new.* or old.* trigger argument reference
+ ** it is a new.* or old.* trigger argument reference. Or
+ ** maybe it is an excluded.* from an upsert.
*/
- if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){
- int op = pParse->eTriggerOp;
- assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
- if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
- pExpr->iTable = 1;
- pTab = pParse->pTriggerTab;
- }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
- pExpr->iTable = 0;
- pTab = pParse->pTriggerTab;
- }else{
- pTab = 0;
+ if( zDb==0 && zTab!=0 && cntTab==0 ){
+ pTab = 0;
+#ifndef SQLITE_OMIT_TRIGGER
+ if( pParse->pTriggerTab!=0 ){
+ int op = pParse->eTriggerOp;
+ assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
+ if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
+ pExpr->iTable = 1;
+ pTab = pParse->pTriggerTab;
+ }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
+ pExpr->iTable = 0;
+ pTab = pParse->pTriggerTab;
+ }
}
+#endif /* SQLITE_OMIT_TRIGGER */
+#ifndef SQLITE_OMIT_UPSERT
+ if( (pNC->ncFlags & NC_UUpsert)!=0 ){
+ Upsert *pUpsert = pNC->uNC.pUpsert;
+ if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){
+ pTab = pUpsert->pUpsertSrc->a[0].pTab;
+ pExpr->iTable = 2;
+ }
+ }
+#endif /* SQLITE_OMIT_UPSERT */
if( pTab ){
int iCol;
@@ -92786,24 +93508,36 @@ static int lookupName(
}
if( iCol<pTab->nCol ){
cnt++;
- if( iCol<0 ){
- pExpr->affinity = SQLITE_AFF_INTEGER;
- }else if( pExpr->iTable==0 ){
- testcase( iCol==31 );
- testcase( iCol==32 );
- pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
- }else{
- testcase( iCol==31 );
- testcase( iCol==32 );
- pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
+#ifndef SQLITE_OMIT_UPSERT
+ if( pExpr->iTable==2 ){
+ testcase( iCol==(-1) );
+ pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
+ eNewExprOp = TK_REGISTER;
+ ExprSetProperty(pExpr, EP_Alias);
+ }else
+#endif /* SQLITE_OMIT_UPSERT */
+ {
+#ifndef SQLITE_OMIT_TRIGGER
+ if( iCol<0 ){
+ pExpr->affinity = SQLITE_AFF_INTEGER;
+ }else if( pExpr->iTable==0 ){
+ testcase( iCol==31 );
+ testcase( iCol==32 );
+ pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
+ }else{
+ testcase( iCol==31 );
+ testcase( iCol==32 );
+ pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
+ }
+ pExpr->pTab = pTab;
+ pExpr->iColumn = (i16)iCol;
+ eNewExprOp = TK_TRIGGER;
+#endif /* SQLITE_OMIT_TRIGGER */
}
- pExpr->iColumn = (i16)iCol;
- pExpr->pTab = pTab;
- isTrigger = 1;
}
}
}
-#endif /* !defined(SQLITE_OMIT_TRIGGER) */
+#endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */
/*
** Perhaps the name is a reference to the ROWID
@@ -92838,10 +93572,12 @@ static int lookupName(
** is supported for backwards compatibility only. Hence, we issue a warning
** on sqlite3_log() whenever the capability is used.
*/
- if( (pEList = pNC->pEList)!=0
- && zTab==0
+ if( (pNC->ncFlags & NC_UEList)!=0
&& cnt==0
+ && zTab==0
){
+ pEList = pNC->uNC.pEList;
+ assert( pEList!=0 );
for(j=0; j<pEList->nExpr; j++){
char *zAs = pEList->a[j].zName;
if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
@@ -92938,7 +93674,7 @@ static int lookupName(
pExpr->pLeft = 0;
sqlite3ExprDelete(db, pExpr->pRight);
pExpr->pRight = 0;
- pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
+ pExpr->op = eNewExprOp;
ExprSetProperty(pExpr, EP_Leaf);
lookupname_end:
if( cnt==1 ){
@@ -93370,8 +94106,8 @@ static int resolveOrderByTermToExprList(
memset(&nc, 0, sizeof(nc));
nc.pParse = pParse;
nc.pSrcList = pSelect->pSrc;
- nc.pEList = pEList;
- nc.ncFlags = NC_AllowAgg;
+ nc.uNC.pEList = pEList;
+ nc.ncFlags = NC_AllowAgg|NC_UEList;
nc.nErr = 0;
db = pParse->db;
savedSuppErr = db->suppressErr;
@@ -93754,7 +94490,9 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
** Minor point: If this is the case, then the expression will be
** re-evaluated for each reference to it.
*/
- sNC.pEList = p->pEList;
+ assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 );
+ sNC.uNC.pEList = p->pEList;
+ sNC.ncFlags |= NC_UEList;
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
@@ -93987,7 +94725,7 @@ SQLITE_PRIVATE void sqlite3ResolveSelfReference(
Table *pTab, /* The table being referenced */
int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */
Expr *pExpr, /* Expression to resolve. May be NULL. */
- ExprList *pList /* Expression list to resolve. May be NUL. */
+ ExprList *pList /* Expression list to resolve. May be NULL. */
){
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
NameContext sNC; /* Name context for pParse->pNewTable */
@@ -95373,6 +96111,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags)
pItem->sortOrder = pOldItem->sortOrder;
pItem->done = 0;
pItem->bSpanIsTab = pOldItem->bSpanIsTab;
+ pItem->bSorterRef = pOldItem->bSorterRef;
pItem->u = pOldItem->u;
}
return pNew;
@@ -95835,6 +96574,8 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
}
/* Fall through */
case TK_IF_NULL_ROW:
+ case TK_REGISTER:
+ testcase( pExpr->op==TK_REGISTER );
testcase( pExpr->op==TK_IF_NULL_ROW );
pWalker->eCode = 0;
return WRC_Abort;
@@ -95852,8 +96593,8 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
}
/* Fall through */
default:
- testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail will disallow */
- testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail will disallow */
+ testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */
+ testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */
return WRC_Continue;
}
}
@@ -96417,11 +97158,8 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
if( colUsed==(MASKBIT(nExpr)-1) ){
/* If we reach this point, that means the index pIdx is usable */
int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
-#ifndef SQLITE_OMIT_EXPLAIN
- sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,
- sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
- P4_DYNAMIC);
-#endif
+ ExplainQueryPlan((pParse, 0,
+ "USING INDEX %s FOR IN-OPERATOR",pIdx->zName));
sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "%s", pIdx->zName));
@@ -96616,17 +97354,6 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
}
-#ifndef SQLITE_OMIT_EXPLAIN
- if( pParse->explain==2 ){
- char *zMsg = sqlite3MPrintf(pParse->db, "EXECUTE %s%s SUBQUERY %d",
- jmpIfDynamic>=0?"":"CORRELATED ",
- pExpr->op==TK_IN?"LIST":"SCALAR",
- pParse->iNextSelectId
- );
- sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
- }
-#endif
-
switch( pExpr->op ){
case TK_IN: {
int addr; /* Address of OP_OpenEphemeral instruction */
@@ -96664,6 +97391,9 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
Select *pSelect = pExpr->x.pSelect;
ExprList *pEList = pSelect->pEList;
+ ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY",
+ jmpIfDynamic>=0?"":"CORRELATED "
+ ));
assert( !isRowid );
/* If the LHS and RHS of the IN operator do not match, that
** error will have been caught long before we reach this point. */
@@ -96705,7 +97435,6 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
ExprList *pList = pExpr->x.pList;
struct ExprList_item *pItem;
int r1, r2, r3;
-
affinity = sqlite3ExprAffinity(pLeft);
if( !affinity ){
affinity = SQLITE_AFF_BLOB;
@@ -96786,6 +97515,8 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
assert( ExprHasProperty(pExpr, EP_xIsSelect) );
pSel = pExpr->x.pSelect;
+ ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY",
+ jmpIfDynamic>=0?"":"CORRELATED "));
nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
pParse->nMem += nReg;
@@ -97548,6 +98279,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
return 0;
}
+expr_code_doover:
if( pExpr==0 ){
op = TK_NULL;
}else{
@@ -98008,7 +98740,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
case TK_SPAN:
case TK_COLLATE:
case TK_UPLUS: {
- return sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
+ pExpr = pExpr->pLeft;
+ goto expr_code_doover; /* 2018-04-28: Prevent deep recursion. OSSFuzz. */
}
case TK_TRIGGER: {
@@ -98046,10 +98779,9 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
assert( p1>=0 && p1<(pTab->nCol*2+2) );
sqlite3VdbeAddOp2(v, OP_Param, p1, target);
- VdbeComment((v, "%s.%s -> $%d",
+ VdbeComment((v, "r[%d]=%s.%s", target,
(pExpr->iTable ? "new" : "old"),
- (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName),
- target
+ (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName)
));
#ifndef SQLITE_OMIT_FLOATING_POINT
@@ -98381,6 +99113,12 @@ SQLITE_PRIVATE int sqlite3ExprCodeExprList(
if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;
for(pItem=pList->a, i=0; i<n; i++, pItem++){
Expr *pExpr = pItem->pExpr;
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( pItem->bSorterRef ){
+ i--;
+ n--;
+ }else
+#endif
if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){
if( flags & SQLITE_ECEL_OMITREF ){
i--;
@@ -98909,8 +99647,10 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa
if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
if( pA->op==TK_FUNCTION ){
if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
+ }else if( pA->op==TK_COLLATE ){
+ if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
}else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
- return pA->op==TK_COLLATE ? 1 : 2;
+ return 2;
}
}
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
@@ -98919,7 +99659,8 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa
if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
- if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
+ assert( (combinedFlags & EP_Reduced)==0 );
+ if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
if( pA->iColumn!=pB->iColumn ) return 2;
if( pA->iTable!=pB->iTable
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -99265,8 +100006,9 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
NameContext *pNC = pWalker->u.pNC;
Parse *pParse = pNC->pParse;
SrcList *pSrcList = pNC->pSrcList;
- AggInfo *pAggInfo = pNC->pAggInfo;
+ AggInfo *pAggInfo = pNC->uNC.pAggInfo;
+ assert( pNC->ncFlags & NC_UAggInfo );
switch( pExpr->op ){
case TK_AGG_COLUMN:
case TK_COLUMN: {
@@ -102436,7 +103178,7 @@ static void attachFunc(
sqlite3_free( zPath );
db->nDb++;
}
- db->skipBtreeMutex = 0;
+ db->noSharedCache = 0;
if( rc==SQLITE_CONSTRAINT ){
rc = SQLITE_ERROR;
zErrDyn = sqlite3MPrintf(db, "database is already attached");
@@ -102508,6 +103250,7 @@ static void attachFunc(
if( rc==SQLITE_OK ){
sqlite3BtreeEnterAll(db);
db->init.iDb = 0;
+ db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
rc = sqlite3Init(db, &zErrDyn);
sqlite3BtreeLeaveAll(db);
assert( zErrDyn==0 || rc!=SQLITE_OK );
@@ -102780,6 +103523,9 @@ SQLITE_PRIVATE int sqlite3FixSrcList(
if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
#endif
+ if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){
+ return 1;
+ }
}
return 0;
}
@@ -102879,6 +103625,18 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep(
if( sqlite3FixExprList(pFix, pStep->pExprList) ){
return 1;
}
+#ifndef SQLITE_OMIT_UPSERT
+ if( pStep->pUpsert ){
+ Upsert *pUp = pStep->pUpsert;
+ if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
+ || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
+ || sqlite3FixExprList(pFix, pUp->pUpsertSet)
+ || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
+ ){
+ return 1;
+ }
+ }
+#endif
pStep = pStep->pNext;
}
return 0;
@@ -103039,6 +103797,7 @@ SQLITE_PRIVATE void sqlite3AuthRead(
int iDb; /* The index of the database the expression refers to */
int iCol; /* Index of column in table */
+ assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
if( db->xAuth==0 ) return;
iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
if( iDb<0 ){
@@ -103047,7 +103806,6 @@ SQLITE_PRIVATE void sqlite3AuthRead(
return;
}
- assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
if( pExpr->op==TK_TRIGGER ){
pTab = pParse->pTriggerTab;
}else{
@@ -103506,24 +104264,27 @@ SQLITE_PRIVATE Table *sqlite3LocateTable(
const char *zDbase /* Name of the database. Might be NULL */
){
Table *p;
+ sqlite3 *db = pParse->db;
/* Read the database schema. If an error occurs, leave an error message
** and code in pParse and return NULL. */
- if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
+ if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0
+ && SQLITE_OK!=sqlite3ReadSchema(pParse)
+ ){
return 0;
}
- p = sqlite3FindTable(pParse->db, zName, zDbase);
+ p = sqlite3FindTable(db, zName, zDbase);
if( p==0 ){
const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE
- if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
+ if( sqlite3FindDbName(db, zDbase)<1 ){
/* If zName is the not the name of a table in the schema created using
** CREATE, then check to see if it is the name of an virtual table that
** can be an eponymous virtual table. */
- Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
+ Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
- pMod = sqlite3PragmaVtabRegister(pParse->db, zName);
+ pMod = sqlite3PragmaVtabRegister(db, zName);
}
if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
return pMod->pEpoTab;
@@ -103688,6 +104449,7 @@ SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
DbSetProperty(db, iDb, DB_ResetWanted);
DbSetProperty(db, 1, DB_ResetWanted);
+ db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
}
if( db->nSchemaLock==0 ){
@@ -103713,7 +104475,7 @@ SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){
sqlite3SchemaClear(pDb->pSchema);
}
}
- db->mDbFlags &= ~DBFLAG_SchemaChange;
+ db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);
sqlite3VtabUnlockList(db);
sqlite3BtreeLeaveAll(db);
sqlite3CollapseDatabaseArray(db);
@@ -104258,15 +105020,20 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
if( pType->n==0 ){
/* If there is no type specified, columns have the default affinity
- ** 'BLOB'. */
+ ** 'BLOB' with a default size of 4 bytes. */
pCol->affinity = SQLITE_AFF_BLOB;
pCol->szEst = 1;
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( 4>=sqlite3GlobalConfig.szSorterRef ){
+ pCol->colFlags |= COLFLAG_SORTERREF;
+ }
+#endif
}else{
zType = z + sqlite3Strlen30(z) + 1;
memcpy(zType, pType->z, pType->n);
zType[pType->n] = 0;
sqlite3Dequote(zType);
- pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
+ pCol->affinity = sqlite3AffinityType(zType, pCol);
pCol->colFlags |= COLFLAG_HASTYPE;
}
p->nCol++;
@@ -104326,7 +105093,7 @@ SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
** If none of the substrings in the above table are found,
** SQLITE_AFF_NUMERIC is returned.
*/
-SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
+SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){
u32 h = 0;
char aff = SQLITE_AFF_NUMERIC;
const char *zChar = 0;
@@ -104363,27 +105130,32 @@ SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
}
}
- /* If pszEst is not NULL, store an estimate of the field size. The
+ /* If pCol is not NULL, store an estimate of the field size. The
** estimate is scaled so that the size of an integer is 1. */
- if( pszEst ){
- *pszEst = 1; /* default size is approx 4 bytes */
+ if( pCol ){
+ int v = 0; /* default size is approx 4 bytes */
if( aff<SQLITE_AFF_NUMERIC ){
if( zChar ){
while( zChar[0] ){
if( sqlite3Isdigit(zChar[0]) ){
- int v = 0;
+ /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
sqlite3GetInt32(zChar, &v);
- v = v/4 + 1;
- if( v>255 ) v = 255;
- *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
break;
}
zChar++;
}
}else{
- *pszEst = 5; /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/
+ v = 16; /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/
}
}
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( v>=sqlite3GlobalConfig.szSorterRef ){
+ pCol->colFlags |= COLFLAG_SORTERREF;
+ }
+#endif
+ v = v/4 + 1;
+ if( v>255 ) v = 255;
+ pCol->szEst = v;
}
return aff;
}
@@ -105992,6 +106764,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);
regRecord = sqlite3GetTempReg(pParse);
+ sqlite3MultiWrite(pParse);
sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);
sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
@@ -106005,12 +106778,13 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);
if( IsUniqueIndex(pIndex) ){
- int j2 = sqlite3VdbeCurrentAddr(v) + 3;
- sqlite3VdbeGoto(v, j2);
+ int j2 = sqlite3VdbeGoto(v, 1);
addr2 = sqlite3VdbeCurrentAddr(v);
+ sqlite3VdbeVerifyAbortable(v, OE_Abort);
sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
pIndex->nKeyCol); VdbeCoverage(v);
sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
+ sqlite3VdbeJumpHere(v, j2);
}else{
addr2 = sqlite3VdbeCurrentAddr(v);
}
@@ -106173,7 +106947,11 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
#if SQLITE_USER_AUTHENTICATION
&& sqlite3UserAuthTable(pTab->zName)==0
#endif
- && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){
+#ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX
+ && sqlite3StrICmp(&pTab->zName[7],"master")!=0
+#endif
+ && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0
+ ){
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
goto exit_create_index;
}
@@ -107352,16 +108130,16 @@ SQLITE_PRIVATE void sqlite3UniqueConstraint(
sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);
if( pIdx->aColExpr ){
- sqlite3XPrintf(&errMsg, "index '%q'", pIdx->zName);
+ sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);
}else{
for(j=0; j<pIdx->nKeyCol; j++){
char *zCol;
assert( pIdx->aiColumn[j]>=0 );
zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
- if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
- sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
- sqlite3StrAccumAppend(&errMsg, ".", 1);
- sqlite3StrAccumAppendAll(&errMsg, zCol);
+ if( j ) sqlite3_str_append(&errMsg, ", ", 2);
+ sqlite3_str_appendall(&errMsg, pTab->zName);
+ sqlite3_str_append(&errMsg, ".", 1);
+ sqlite3_str_appendall(&errMsg, zCol);
}
}
zErr = sqlite3StrAccumFinish(&errMsg);
@@ -108047,10 +108825,12 @@ SQLITE_PRIVATE FuncDef *sqlite3FindFunction(
if( createFlag && bestScore<FUNC_PERFECT_MATCH &&
(pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){
FuncDef *pOther;
+ u8 *z;
pBest->zName = (const char*)&pBest[1];
pBest->nArg = (u16)nArg;
pBest->funcFlags = enc;
memcpy((char*)&pBest[1], zName, nName+1);
+ for(z=(u8*)pBest->zName; *z; z++) *z = sqlite3UpperToLower[*z];
pOther = (FuncDef*)sqlite3HashInsert(&db->aFunc, pBest->zName, pBest);
if( pOther==pBest ){
sqlite3DbFree(db, pBest);
@@ -108368,7 +109148,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
AuthContext sContext; /* Authorization context */
NameContext sNC; /* Name context to resolve expressions in */
int iDb; /* Database number */
- int memCnt = -1; /* Memory cell used for change counting */
+ int memCnt = 0; /* Memory cell used for change counting */
int rcauth; /* Value returned by authorization callback */
int eOnePass; /* ONEPASS_OFF or _SINGLE or _MULTI */
int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */
@@ -108473,7 +109253,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
goto delete_from_cleanup;
}
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
- sqlite3BeginWriteOperation(pParse, 1, iDb);
+ sqlite3BeginWriteOperation(pParse, bComplex, iDb);
/* If we are trying to delete from a view, realize that view into
** an ephemeral table.
@@ -108501,7 +109281,10 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
/* Initialize the counter of the number of rows deleted, if
** we are counting rows.
*/
- if( db->flags & SQLITE_CountRows ){
+ if( (db->flags & SQLITE_CountRows)!=0
+ && !pParse->nested
+ && !pParse->pTriggerTab
+ ){
memCnt = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);
}
@@ -108529,7 +109312,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
assert( !isView );
sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
if( HasRowid(pTab) ){
- sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
+ sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt ? memCnt : -1,
pTab->zName, P4_STATIC);
}
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
@@ -108574,9 +109357,10 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );
+ if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse);
/* Keep track of the number of rows to be deleted */
- if( db->flags & SQLITE_CountRows ){
+ if( memCnt ){
sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
}
@@ -108679,13 +109463,16 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
if( IsVirtual(pTab) ){
const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
sqlite3VtabMakeWritable(pParse, pTab);
- sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);
- sqlite3VdbeChangeP5(v, OE_Abort);
assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );
sqlite3MayAbort(pParse);
- if( eOnePass==ONEPASS_SINGLE && sqlite3IsToplevel(pParse) ){
- pParse->isMultiWrite = 0;
+ if( eOnePass==ONEPASS_SINGLE ){
+ sqlite3VdbeAddOp1(v, OP_Close, iTabCur);
+ if( sqlite3IsToplevel(pParse) ){
+ pParse->isMultiWrite = 0;
+ }
}
+ sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);
+ sqlite3VdbeChangeP5(v, OE_Abort);
}else
#endif
{
@@ -108719,7 +109506,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
- if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
+ if( memCnt ){
sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
@@ -109327,7 +110114,7 @@ static void printfFunc(
x.apArg = argv+1;
sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
str.printfFlags = SQLITE_PRINTF_SQLFUNC;
- sqlite3XPrintf(&str, zFormat, &x);
+ sqlite3_str_appendf(&str, zFormat, &x);
n = str.nChar;
sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
SQLITE_DYNAMIC);
@@ -110730,20 +111517,20 @@ static void groupConcatStep(
zSep = ",";
nSep = 1;
}
- if( zSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep);
+ if( zSep ) sqlite3_str_append(pAccum, zSep, nSep);
}
zVal = (char*)sqlite3_value_text(argv[0]);
nVal = sqlite3_value_bytes(argv[0]);
- if( zVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal);
+ if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);
}
}
static void groupConcatFinalize(sqlite3_context *context){
StrAccum *pAccum;
pAccum = sqlite3_aggregate_context(context, 0);
if( pAccum ){
- if( pAccum->accError==STRACCUM_TOOBIG ){
+ if( pAccum->accError==SQLITE_TOOBIG ){
sqlite3_result_error_toobig(context);
- }else if( pAccum->accError==STRACCUM_NOMEM ){
+ }else if( pAccum->accError==SQLITE_NOMEM ){
sqlite3_result_error_nomem(context);
}else{
sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1,
@@ -111320,6 +112107,12 @@ static void fkLookupParent(
int iCur = pParse->nTab - 1; /* Cursor number to use */
int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */
+ sqlite3VdbeVerifyAbortable(v,
+ (!pFKey->isDeferred
+ && !(pParse->db->flags & SQLITE_DeferFKs)
+ && !pParse->pToplevel
+ && !pParse->isMultiWrite) ? OE_Abort : OE_Ignore);
+
/* If nIncr is less than zero, then check at runtime if there are any
** outstanding constraints to resolve. If there are not, there is no need
** to check if deleting this row resolves any outstanding violations.
@@ -111727,6 +112520,7 @@ SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTa
** constraints are violated.
*/
if( (db->flags & SQLITE_DeferFKs)==0 ){
+ sqlite3VdbeVerifyAbortable(v, OE_Abort);
sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
VdbeCoverage(v);
sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
@@ -112639,11 +113433,26 @@ static int autoIncBegin(
Table *pTab /* The table we are writing to */
){
int memId = 0; /* Register holding maximum rowid */
+ assert( pParse->db->aDb[iDb].pSchema!=0 );
if( (pTab->tabFlags & TF_Autoincrement)!=0
&& (pParse->db->mDbFlags & DBFLAG_Vacuum)==0
){
Parse *pToplevel = sqlite3ParseToplevel(pParse);
AutoincInfo *pInfo;
+ Table *pSeqTab = pParse->db->aDb[iDb].pSchema->pSeqTab;
+
+ /* Verify that the sqlite_sequence table exists and is an ordinary
+ ** rowid table with exactly two columns.
+ ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */
+ if( pSeqTab==0
+ || !HasRowid(pSeqTab)
+ || IsVirtual(pSeqTab)
+ || pSeqTab->nCol!=2
+ ){
+ pParse->nErr++;
+ pParse->rc = SQLITE_CORRUPT_SEQUENCE;
+ return 0;
+ }
pInfo = pToplevel->pAinc;
while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }
@@ -112901,7 +113710,8 @@ SQLITE_PRIVATE void sqlite3Insert(
SrcList *pTabList, /* Name of table into which we are inserting */
Select *pSelect, /* A SELECT statement to use as the data source */
IdList *pColumn, /* Column names corresponding to IDLIST. */
- int onError /* How to handle constraint errors */
+ int onError, /* How to handle constraint errors */
+ Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */
){
sqlite3 *db; /* The main database structure */
Table *pTab; /* The table to insert into. aka TABLE */
@@ -113196,7 +114006,10 @@ SQLITE_PRIVATE void sqlite3Insert(
/* Initialize the count of rows to be inserted
*/
- if( db->flags & SQLITE_CountRows ){
+ if( (db->flags & SQLITE_CountRows)!=0
+ && !pParse->nested
+ && !pParse->pTriggerTab
+ ){
regRowCount = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
}
@@ -113216,6 +114029,19 @@ SQLITE_PRIVATE void sqlite3Insert(
pParse->nMem += pIdx->nColumn;
}
}
+#ifndef SQLITE_OMIT_UPSERT
+ if( pUpsert ){
+ pTabList->a[0].iCursor = iDataCur;
+ pUpsert->pUpsertSrc = pTabList;
+ pUpsert->regData = regData;
+ pUpsert->iDataCur = iDataCur;
+ pUpsert->iIdxCur = iIdxCur;
+ if( pUpsert->pUpsertTarget ){
+ sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);
+ }
+ }
+#endif
+
/* This is the top of the main insertion loop */
if( useTempTable ){
@@ -113418,7 +114244,7 @@ SQLITE_PRIVATE void sqlite3Insert(
int isReplace; /* Set to true if constraints may cause a replace */
int bUseSeek; /* True to use OPFLAG_SEEKRESULT */
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
- regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
+ regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert
);
sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
@@ -113441,7 +114267,7 @@ SQLITE_PRIVATE void sqlite3Insert(
/* Update the count of rows that are inserted
*/
- if( (db->flags & SQLITE_CountRows)!=0 ){
+ if( regRowCount ){
sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
}
@@ -113478,7 +114304,7 @@ insert_end:
** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function.
*/
- if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
+ if( regRowCount ){
sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
@@ -113487,6 +114313,7 @@ insert_end:
insert_cleanup:
sqlite3SrcListDelete(db, pTabList);
sqlite3ExprListDelete(db, pList);
+ sqlite3UpsertDelete(db, pUpsert);
sqlite3SelectDelete(db, pSelect);
sqlite3IdListDelete(db, pColumn);
sqlite3DbFree(db, aRegIdx);
@@ -113559,6 +114386,44 @@ static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
}
/*
+** An instance of the ConstraintAddr object remembers the byte-code addresses
+** for sections of the constraint checks that deal with uniqueness constraints
+** on the rowid and on the upsert constraint.
+**
+** This information is passed into checkReorderConstraintChecks() to insert
+** some OP_Goto operations so that the rowid and upsert constraints occur
+** in the correct order relative to other constraints.
+*/
+typedef struct ConstraintAddr ConstraintAddr;
+struct ConstraintAddr {
+ int ipkTop; /* Subroutine for rowid constraint check */
+ int upsertTop; /* Label for upsert constraint check subroutine */
+ int upsertTop2; /* Copy of upsertTop not cleared by the call */
+ int upsertBtm; /* upsert constraint returns to this label */
+ int ipkBtm; /* Return opcode rowid constraint check */
+};
+
+/*
+** Generate any OP_Goto operations needed to cause constraints to be
+** run that haven't already been run.
+*/
+static void reorderConstraintChecks(Vdbe *v, ConstraintAddr *p){
+ if( p->upsertTop ){
+ testcase( sqlite3VdbeLabelHasBeenResolved(v, p->upsertTop) );
+ sqlite3VdbeGoto(v, p->upsertTop);
+ VdbeComment((v, "call upsert subroutine"));
+ sqlite3VdbeResolveLabel(v, p->upsertBtm);
+ p->upsertTop = 0;
+ }
+ if( p->ipkTop ){
+ sqlite3VdbeGoto(v, p->ipkTop);
+ VdbeComment((v, "call rowid unique-check subroutine"));
+ sqlite3VdbeJumpHere(v, p->ipkBtm);
+ p->ipkTop = 0;
+ }
+}
+
+/*
** Generate code to do constraint checks prior to an INSERT or an UPDATE
** on table pTab.
**
@@ -113653,7 +114518,8 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
u8 overrideError, /* Override onError to this if not OE_Default */
int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */
- int *aiChng /* column i is unchanged if aiChng[i]<0 */
+ int *aiChng, /* column i is unchanged if aiChng[i]<0 */
+ Upsert *pUpsert /* ON CONFLICT clauses, if any. NULL otherwise */
){
Vdbe *v; /* VDBE under constrution */
Index *pIdx; /* Pointer to one of the indices */
@@ -113666,10 +114532,11 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
int addr1; /* Address of jump instruction */
int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
- int ipkTop = 0; /* Top of the rowid change constraint check */
- int ipkBottom = 0; /* Bottom of the rowid change constraint check */
+ ConstraintAddr sAddr;/* Address information for constraint reordering */
+ Index *pUpIdx = 0; /* Index to which to apply the upsert */
u8 isUpdate; /* True if this is an UPDATE operation */
u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */
+ int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */
isUpdate = regOldData!=0;
db = pParse->db;
@@ -113677,6 +114544,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
assert( v!=0 );
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
nCol = pTab->nCol;
+ memset(&sAddr, 0, sizeof(sAddr));
/* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
** normal rowid tables. nPkField is the number of key fields in the
@@ -113759,6 +114627,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
Expr *pExpr = pCheck->a[i].pExpr;
if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
allOk = sqlite3VdbeMakeLabel(v);
+ sqlite3VdbeVerifyAbortable(v, onError);
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
if( onError==OE_Ignore ){
sqlite3VdbeGoto(v, ignoreDest);
@@ -113776,6 +114645,46 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
}
#endif /* !defined(SQLITE_OMIT_CHECK) */
+ /* UNIQUE and PRIMARY KEY constraints should be handled in the following
+ ** order:
+ **
+ ** (1) OE_Abort, OE_Fail, OE_Rollback, OE_Ignore
+ ** (2) OE_Update
+ ** (3) OE_Replace
+ **
+ ** OE_Fail and OE_Ignore must happen before any changes are made.
+ ** OE_Update guarantees that only a single row will change, so it
+ ** must happen before OE_Replace. Technically, OE_Abort and OE_Rollback
+ ** could happen in any order, but they are grouped up front for
+ ** convenience.
+ **
+ ** Constraint checking code is generated in this order:
+ ** (A) The rowid constraint
+ ** (B) Unique index constraints that do not have OE_Replace as their
+ ** default conflict resolution strategy
+ ** (C) Unique index that do use OE_Replace by default.
+ **
+ ** The ordering of (2) and (3) is accomplished by making sure the linked
+ ** list of indexes attached to a table puts all OE_Replace indexes last
+ ** in the list. See sqlite3CreateIndex() for where that happens.
+ */
+
+ if( pUpsert ){
+ if( pUpsert->pUpsertTarget==0 ){
+ /* An ON CONFLICT DO NOTHING clause, without a constraint-target.
+ ** Make all unique constraint resolution be OE_Ignore */
+ assert( pUpsert->pUpsertSet==0 );
+ overrideError = OE_Ignore;
+ pUpsert = 0;
+ }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
+ /* If the constraint-target is on some column other than
+ ** then ROWID, then we might need to move the UPSERT around
+ ** so that it occurs in the correct order. */
+ sAddr.upsertTop = sAddr.upsertTop2 = sqlite3VdbeMakeLabel(v);
+ sAddr.upsertBtm = sqlite3VdbeMakeLabel(v);
+ }
+ }
+
/* If rowid is changing, make sure the new rowid does not previously
** exist in the table.
*/
@@ -113790,13 +114699,13 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
onError = OE_Abort;
}
- if( isUpdate ){
- /* pkChng!=0 does not mean that the rowid has changed, only that
- ** it might have changed. Skip the conflict logic below if the rowid
- ** is unchanged. */
- sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
- sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
- VdbeCoverage(v);
+ /* figure out whether or not upsert applies in this case */
+ if( pUpsert && pUpsert->pUpsertIdx==0 ){
+ if( pUpsert->pUpsertSet==0 ){
+ onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */
+ }else{
+ onError = OE_Update; /* DO UPDATE */
+ }
}
/* If the response to a rowid conflict is REPLACE but the response
@@ -113804,21 +114713,34 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
** to defer the running of the rowid conflict checking until after
** the UNIQUE constraints have run.
*/
- if( onError==OE_Replace && overrideError!=OE_Replace ){
- for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
- if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){
- ipkTop = sqlite3VdbeAddOp0(v, OP_Goto);
- break;
- }
- }
+ assert( OE_Update>OE_Replace );
+ assert( OE_Ignore<OE_Replace );
+ assert( OE_Fail<OE_Replace );
+ assert( OE_Abort<OE_Replace );
+ assert( OE_Rollback<OE_Replace );
+ if( onError>=OE_Replace
+ && (pUpsert || onError!=overrideError)
+ && pTab->pIndex
+ ){
+ sAddr.ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
+ }
+
+ if( isUpdate ){
+ /* pkChng!=0 does not mean that the rowid has changed, only that
+ ** it might have changed. Skip the conflict logic below if the rowid
+ ** is unchanged. */
+ sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
+ sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
+ VdbeCoverage(v);
}
/* Check to see if the new rowid already exists in the table. Skip
** the following conflict logic if it does not. */
+ VdbeNoopComment((v, "uniqueness check for ROWID"));
+ sqlite3VdbeVerifyAbortable(v, onError);
sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
VdbeCoverage(v);
- /* Generate code that deals with a rowid collision */
switch( onError ){
default: {
onError = OE_Abort;
@@ -113827,6 +114749,9 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
case OE_Rollback:
case OE_Abort:
case OE_Fail: {
+ testcase( onError==OE_Rollback );
+ testcase( onError==OE_Abort );
+ testcase( onError==OE_Fail );
sqlite3RowidConstraint(pParse, onError, pTab);
break;
}
@@ -113863,14 +114788,13 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
regNewData, 1, 0, OE_Replace, 1, -1);
}else{
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
- if( HasRowid(pTab) ){
- /* This OP_Delete opcode fires the pre-update-hook only. It does
- ** not modify the b-tree. It is more efficient to let the coming
- ** OP_Insert replace the existing entry than it is to delete the
- ** existing entry and then insert a new one. */
- sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
- sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
- }
+ assert( HasRowid(pTab) );
+ /* This OP_Delete opcode fires the pre-update-hook only. It does
+ ** not modify the b-tree. It is more efficient to let the coming
+ ** OP_Insert replace the existing entry than it is to delete the
+ ** existing entry and then insert a new one. */
+ sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
+ sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
if( pTab->pIndex ){
sqlite3MultiWrite(pParse);
@@ -113880,16 +114804,22 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
seenReplace = 1;
break;
}
+#ifndef SQLITE_OMIT_UPSERT
+ case OE_Update: {
+ sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);
+ /* Fall through */
+ }
+#endif
case OE_Ignore: {
- /*assert( seenReplace==0 );*/
+ testcase( onError==OE_Ignore );
sqlite3VdbeGoto(v, ignoreDest);
break;
}
}
sqlite3VdbeResolveLabel(v, addrRowidOk);
- if( ipkTop ){
- ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);
- sqlite3VdbeJumpHere(v, ipkTop);
+ if( sAddr.ipkTop ){
+ sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
+ sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
}
}
@@ -113907,12 +114837,21 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */
if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */
+ if( pUpIdx==pIdx ){
+ addrUniqueOk = sAddr.upsertBtm;
+ upsertBypass = sqlite3VdbeGoto(v, 0);
+ VdbeComment((v, "Skip upsert subroutine"));
+ sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
+ }else{
+ addrUniqueOk = sqlite3VdbeMakeLabel(v);
+ }
+ VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
if( bAffinityDone==0 ){
sqlite3TableAffinity(v, pTab, regNewData+1);
bAffinityDone = 1;
}
iThisCur = iIdxCur+ix;
- addrUniqueOk = sqlite3VdbeMakeLabel(v);
+
/* Skip partial indices for which the WHERE clause is not true */
if( pIdx->pPartIdxWhere ){
@@ -113972,6 +114911,24 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
onError = OE_Abort;
}
+ /* Figure out if the upsert clause applies to this index */
+ if( pUpIdx==pIdx ){
+ if( pUpsert->pUpsertSet==0 ){
+ onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */
+ }else{
+ onError = OE_Update; /* DO UPDATE */
+ }
+ }
+
+ /* Invoke subroutines to handle IPK replace and upsert prior to running
+ ** the first REPLACE constraint check. */
+ if( onError==OE_Replace ){
+ testcase( sAddr.ipkTop );
+ testcase( sAddr.upsertTop
+ && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
+ reorderConstraintChecks(v, &sAddr);
+ }
+
/* Collision detection may be omitted if all of the following are true:
** (1) The conflict resolution algorithm is REPLACE
** (2) The table is a WITHOUT ROWID table
@@ -113993,6 +114950,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
/* Check to see if the new index entry will be unique */
sqlite3ExprCachePush(pParse);
+ sqlite3VdbeVerifyAbortable(v, onError);
sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
regIdx, pIdx->nKeyCol); VdbeCoverage(v);
@@ -114054,25 +115012,37 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
/* Generate code that executes if the new index entry is not unique */
assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
- || onError==OE_Ignore || onError==OE_Replace );
+ || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update );
switch( onError ){
case OE_Rollback:
case OE_Abort:
case OE_Fail: {
+ testcase( onError==OE_Rollback );
+ testcase( onError==OE_Abort );
+ testcase( onError==OE_Fail );
sqlite3UniqueConstraint(pParse, onError, pIdx);
break;
}
+#ifndef SQLITE_OMIT_UPSERT
+ case OE_Update: {
+ sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
+ /* Fall through */
+ }
+#endif
case OE_Ignore: {
+ testcase( onError==OE_Ignore );
sqlite3VdbeGoto(v, ignoreDest);
break;
}
default: {
Trigger *pTrigger = 0;
assert( onError==OE_Replace );
- sqlite3MultiWrite(pParse);
if( db->flags&SQLITE_RecTriggers ){
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
}
+ if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
+ sqlite3MultiWrite(pParse);
+ }
sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
regR, nPkField, 0, OE_Replace,
(pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
@@ -114080,14 +115050,19 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
break;
}
}
- sqlite3VdbeResolveLabel(v, addrUniqueOk);
+ if( pUpIdx==pIdx ){
+ sqlite3VdbeJumpHere(v, upsertBypass);
+ }else{
+ sqlite3VdbeResolveLabel(v, addrUniqueOk);
+ }
sqlite3ExprCachePop(pParse);
if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
+
}
- if( ipkTop ){
- sqlite3VdbeGoto(v, ipkTop+1);
- sqlite3VdbeJumpHere(v, ipkBottom);
- }
+ testcase( sAddr.ipkTop!=0 );
+ testcase( sAddr.upsertTop
+ && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
+ reorderConstraintChecks(v, &sAddr);
*pbMayReplace = seenReplace;
VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
@@ -114587,6 +115562,7 @@ static int xferOptimization(
emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
if( pDest->iPKey>=0 ){
addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);
+ sqlite3VdbeVerifyAbortable(v, onError);
addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);
VdbeCoverage(v);
sqlite3RowidConstraint(pParse, onError, pDest);
@@ -115144,6 +116120,21 @@ struct sqlite3_api_routines {
int (*vtab_nochange)(sqlite3_context*);
int (*value_nochange)(sqlite3_value*);
const char *(*vtab_collation)(sqlite3_index_info*,int);
+ /* Version 3.24.0 and later */
+ int (*keyword_count)(void);
+ int (*keyword_name)(int,const char**,int*);
+ int (*keyword_check)(const char*,int);
+ sqlite3_str *(*str_new)(sqlite3*);
+ char *(*str_finish)(sqlite3_str*);
+ void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
+ void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
+ void (*str_append)(sqlite3_str*, const char *zIn, int N);
+ void (*str_appendall)(sqlite3_str*, const char *zIn);
+ void (*str_appendchar)(sqlite3_str*, int N, char C);
+ void (*str_reset)(sqlite3_str*);
+ int (*str_errcode)(sqlite3_str*);
+ int (*str_length)(sqlite3_str*);
+ char *(*str_value)(sqlite3_str*);
};
/*
@@ -115414,6 +116405,21 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
#define sqlite3_value_nochange sqlite3_api->value_nochange
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
+/* Version 3.24.0 and later */
+#define sqlite3_keyword_count sqlite3_api->keyword_count
+#define sqlite3_keyword_name sqlite3_api->keyword_name
+#define sqlite3_keyword_check sqlite3_api->keyword_check
+#define sqlite3_str_new sqlite3_api->str_new
+#define sqlite3_str_finish sqlite3_api->str_finish
+#define sqlite3_str_appendf sqlite3_api->str_appendf
+#define sqlite3_str_vappendf sqlite3_api->str_vappendf
+#define sqlite3_str_append sqlite3_api->str_append
+#define sqlite3_str_appendall sqlite3_api->str_appendall
+#define sqlite3_str_appendchar sqlite3_api->str_appendchar
+#define sqlite3_str_reset sqlite3_api->str_reset
+#define sqlite3_str_errcode sqlite3_api->str_errcode
+#define sqlite3_str_length sqlite3_api->str_length
+#define sqlite3_str_value sqlite3_api->str_value
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
@@ -115852,7 +116858,22 @@ static const sqlite3_api_routines sqlite3Apis = {
/* Version 3.22.0 and later */
sqlite3_vtab_nochange,
sqlite3_value_nochange,
- sqlite3_vtab_collation
+ sqlite3_vtab_collation,
+ /* Version 3.24.0 and later */
+ sqlite3_keyword_count,
+ sqlite3_keyword_name,
+ sqlite3_keyword_check,
+ sqlite3_str_new,
+ sqlite3_str_finish,
+ sqlite3_str_appendf,
+ sqlite3_str_vappendf,
+ sqlite3_str_append,
+ sqlite3_str_appendall,
+ sqlite3_str_appendchar,
+ sqlite3_str_reset,
+ sqlite3_str_errcode,
+ sqlite3_str_length,
+ sqlite3_str_value
};
/*
@@ -115918,10 +116939,8 @@ static int sqlite3LoadExtension(
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
- int bExists = 0;
if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
- sqlite3OsAccess(pVfs, zAltFile, SQLITE_ACCESS_EXISTS, &bExists);
- if( bExists ) handle = sqlite3OsDlOpen(pVfs, zAltFile);
+ handle = sqlite3OsDlOpen(pVfs, zAltFile);
sqlite3_free(zAltFile);
}
#endif
@@ -119093,26 +120112,26 @@ static int pragmaVtabConnect(
UNUSED_PARAMETER(argc);
UNUSED_PARAMETER(argv);
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
- sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
+ sqlite3_str_appendall(&acc, "CREATE TABLE x");
for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){
- sqlite3XPrintf(&acc, "%c\"%s\"", cSep, pragCName[j]);
+ sqlite3_str_appendf(&acc, "%c\"%s\"", cSep, pragCName[j]);
cSep = ',';
}
if( i==0 ){
- sqlite3XPrintf(&acc, "(\"%s\"", pPragma->zName);
+ sqlite3_str_appendf(&acc, "(\"%s\"", pPragma->zName);
cSep = ',';
i++;
}
j = 0;
if( pPragma->mPragFlg & PragFlg_Result1 ){
- sqlite3StrAccumAppendAll(&acc, ",arg HIDDEN");
+ sqlite3_str_appendall(&acc, ",arg HIDDEN");
j++;
}
if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){
- sqlite3StrAccumAppendAll(&acc, ",schema HIDDEN");
+ sqlite3_str_appendall(&acc, ",schema HIDDEN");
j++;
}
- sqlite3StrAccumAppend(&acc, ")", 1);
+ sqlite3_str_append(&acc, ")", 1);
sqlite3StrAccumFinish(&acc);
assert( strlen(zBuf) < sizeof(zBuf)-1 );
rc = sqlite3_declare_vtab(db, zBuf);
@@ -119264,13 +120283,13 @@ static int pragmaVtabFilter(
}
}
sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
- sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
+ sqlite3_str_appendall(&acc, "PRAGMA ");
if( pCsr->azArg[1] ){
- sqlite3XPrintf(&acc, "%Q.", pCsr->azArg[1]);
+ sqlite3_str_appendf(&acc, "%Q.", pCsr->azArg[1]);
}
- sqlite3StrAccumAppendAll(&acc, pTab->pName->zName);
+ sqlite3_str_appendall(&acc, pTab->pName->zName);
if( pCsr->azArg[0] ){
- sqlite3XPrintf(&acc, "=%Q", pCsr->azArg[0]);
+ sqlite3_str_appendf(&acc, "=%Q", pCsr->azArg[0]);
}
zSql = sqlite3StrAccumFinish(&acc);
if( zSql==0 ) return SQLITE_NOMEM;
@@ -119513,6 +120532,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
const char *zMasterName;
int openedTransaction = 0;
+ assert( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 );
assert( iDb>=0 && iDb<db->nDb );
assert( db->aDb[iDb].pSchema );
assert( sqlite3_mutex_held(db->mutex) );
@@ -119583,6 +120603,9 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
for(i=0; i<ArraySize(meta); i++){
sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);
}
+ if( (db->flags & SQLITE_ResetDatabase)!=0 ){
+ memset(meta, 0, sizeof(meta));
+ }
pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];
/* If opening a non-empty database, check the text encoding. For the
@@ -119742,6 +120765,7 @@ SQLITE_PRIVATE int sqlite3Init(sqlite3 *db, char **pzErrMsg){
}
/* All other schemas after the main schema. The "temp" schema must be last */
for(i=db->nDb-1; i>0; i--){
+ assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
rc = sqlite3InitOne(db, i, pzErrMsg);
if( rc ) return rc;
@@ -119763,10 +120787,12 @@ SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){
assert( sqlite3_mutex_held(db->mutex) );
if( !db->init.busy ){
rc = sqlite3Init(db, &pParse->zErrMsg);
- }
- if( rc!=SQLITE_OK ){
- pParse->rc = rc;
- pParse->nErr++;
+ if( rc!=SQLITE_OK ){
+ pParse->rc = rc;
+ pParse->nErr++;
+ }else if( db->noSharedCache ){
+ db->mDbFlags |= DBFLAG_SchemaKnownOk;
+ }
}
return rc;
}
@@ -119977,7 +121003,7 @@ static int sqlite3Prepare(
if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
static const char * const azColName[] = {
"addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
- "selectid", "order", "from", "detail"
+ "id", "parent", "notused", "detail"
};
int iFirst, mx;
if( sParse.explain==2 ){
@@ -120291,7 +121317,7 @@ SQLITE_API int sqlite3_prepare16_v3(
/***/ int sqlite3SelectTrace = 0;
# define SELECTTRACE(K,P,S,X) \
if(sqlite3SelectTrace&(K)) \
- sqlite3DebugPrintf("%s/%p: ",(S)->zSelName,(S)),\
+ sqlite3DebugPrintf("%s/%d/%p: ",(S)->zSelName,(P)->addrExplain,(S)),\
sqlite3DebugPrintf X
#else
# define SELECTTRACE(K,P,S,X)
@@ -120314,6 +121340,20 @@ struct DistinctCtx {
/*
** An instance of the following object is used to record information about
** the ORDER BY (or GROUP BY) clause of query is being coded.
+**
+** The aDefer[] array is used by the sorter-references optimization. For
+** example, assuming there is no index that can be used for the ORDER BY,
+** for the query:
+**
+** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
+**
+** it may be more efficient to add just the "a" values to the sorter, and
+** retrieve the associated "bigblob" values directly from table t1 as the
+** 10 smallest "a" values are extracted from the sorter.
+**
+** When the sorter-reference optimization is used, there is one entry in the
+** aDefer[] array for each database table that may be read as values are
+** extracted from the sorter.
*/
typedef struct SortCtx SortCtx;
struct SortCtx {
@@ -120326,6 +121366,15 @@ struct SortCtx {
int labelDone; /* Jump here when done, ex: LIMIT reached */
u8 sortFlags; /* Zero or more SORTFLAG_* bits */
u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ u8 nDefer; /* Number of valid entries in aDefer[] */
+ struct DeferredCsr {
+ Table *pTab; /* Table definition */
+ int iCsr; /* Cursor number for table */
+ int nKey; /* Number of PK columns for table pTab (>=1) */
+ } aDefer[4];
+#endif
+ struct RowLoadInfo *pDeferredRowLoad; /* Deferred row loading info or NULL */
};
#define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
@@ -120785,6 +121834,62 @@ static KeyInfo *keyInfoFromExprList(
);
/*
+** An instance of this object holds information (beyond pParse and pSelect)
+** needed to load the next result row that is to be added to the sorter.
+*/
+typedef struct RowLoadInfo RowLoadInfo;
+struct RowLoadInfo {
+ int regResult; /* Store results in array of registers here */
+ u8 ecelFlags; /* Flag argument to ExprCodeExprList() */
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ ExprList *pExtra; /* Extra columns needed by sorter refs */
+ int regExtraResult; /* Where to load the extra columns */
+#endif
+};
+
+/*
+** This routine does the work of loading query data into an array of
+** registers so that it can be added to the sorter.
+*/
+static void innerLoopLoadRow(
+ Parse *pParse, /* Statement under construction */
+ Select *pSelect, /* The query being coded */
+ RowLoadInfo *pInfo /* Info needed to complete the row load */
+){
+ sqlite3ExprCodeExprList(pParse, pSelect->pEList, pInfo->regResult,
+ 0, pInfo->ecelFlags);
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( pInfo->pExtra ){
+ sqlite3ExprCodeExprList(pParse, pInfo->pExtra, pInfo->regExtraResult, 0, 0);
+ sqlite3ExprListDelete(pParse->db, pInfo->pExtra);
+ }
+#endif
+}
+
+/*
+** Code the OP_MakeRecord instruction that generates the entry to be
+** added into the sorter.
+**
+** Return the register in which the result is stored.
+*/
+static int makeSorterRecord(
+ Parse *pParse,
+ SortCtx *pSort,
+ Select *pSelect,
+ int regBase,
+ int nBase
+){
+ int nOBSat = pSort->nOBSat;
+ Vdbe *v = pParse->pVdbe;
+ int regOut = ++pParse->nMem;
+ if( pSort->pDeferredRowLoad ){
+ innerLoopLoadRow(pParse, pSelect, pSort->pDeferredRowLoad);
+ }
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regOut);
+ return regOut;
+}
+
+/*
** Generate code that will push the record in registers regData
** through regData+nData-1 onto the sorter.
*/
@@ -120794,7 +121899,7 @@ static void pushOntoSorter(
Select *pSelect, /* The whole SELECT statement */
int regData, /* First register holding data to be sorted */
int regOrigData, /* First register holding data before packing */
- int nData, /* Number of elements in the data array */
+ int nData, /* Number of elements in the regData data array */
int nPrefixReg /* No. of reg prior to regData available for use */
){
Vdbe *v = pParse->pVdbe; /* Stmt under construction */
@@ -120802,16 +121907,32 @@ static void pushOntoSorter(
int nExpr = pSort->pOrderBy->nExpr; /* No. of ORDER BY terms */
int nBase = nExpr + bSeq + nData; /* Fields in sorter record */
int regBase; /* Regs for sorter record */
- int regRecord = ++pParse->nMem; /* Assembled sorter record */
+ int regRecord = 0; /* Assembled sorter record */
int nOBSat = pSort->nOBSat; /* ORDER BY terms to skip */
int op; /* Opcode to add sorter record to sorter */
int iLimit; /* LIMIT counter */
+ int iSkip = 0; /* End of the sorter insert loop */
assert( bSeq==0 || bSeq==1 );
+
+ /* Three cases:
+ ** (1) The data to be sorted has already been packed into a Record
+ ** by a prior OP_MakeRecord. In this case nData==1 and regData
+ ** will be completely unrelated to regOrigData.
+ ** (2) All output columns are included in the sort record. In that
+ ** case regData==regOrigData.
+ ** (3) Some output columns are omitted from the sort record due to
+ ** the SQLITE_ENABLE_SORTER_REFERENCE optimization, or due to the
+ ** SQLITE_ECEL_OMITREF optimization, or due to the
+ ** SortCtx.pDeferredRowLoad optimiation. In any of these cases
+ ** regOrigData is 0 to prevent this routine from trying to copy
+ ** values that might not yet exist.
+ */
assert( nData==1 || regData==regOrigData || regOrigData==0 );
+
if( nPrefixReg ){
assert( nPrefixReg==nExpr+bSeq );
- regBase = regData - nExpr - bSeq;
+ regBase = regData - nPrefixReg;
}else{
regBase = pParse->nMem + 1;
pParse->nMem += nBase;
@@ -120827,7 +121948,6 @@ static void pushOntoSorter(
if( nPrefixReg==0 && nData>0 ){
sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);
}
- sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord);
if( nOBSat>0 ){
int regPrevKey; /* The first nOBSat columns of the previous row */
int addrFirst; /* Address of the OP_IfNot opcode */
@@ -120836,6 +121956,7 @@ static void pushOntoSorter(
int nKey; /* Number of sorting key columns, including OP_Sequence */
KeyInfo *pKI; /* Original KeyInfo on the sorter table */
+ regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);
regPrevKey = pParse->nMem+1;
pParse->nMem += pSort->nOBSat;
nKey = nExpr - pSort->nOBSat + bSeq;
@@ -120869,6 +121990,34 @@ static void pushOntoSorter(
sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);
sqlite3VdbeJumpHere(v, addrJmp);
}
+ if( iLimit ){
+ /* At this point the values for the new sorter entry are stored
+ ** in an array of registers. They need to be composed into a record
+ ** and inserted into the sorter if either (a) there are currently
+ ** less than LIMIT+OFFSET items or (b) the new record is smaller than
+ ** the largest record currently in the sorter. If (b) is true and there
+ ** are already LIMIT+OFFSET items in the sorter, delete the largest
+ ** entry before inserting the new one. This way there are never more
+ ** than LIMIT+OFFSET items in the sorter.
+ **
+ ** If the new record does not need to be inserted into the sorter,
+ ** jump to the next iteration of the loop. Or, if the
+ ** pSort->bOrderedInnerLoop flag is set to indicate that the inner
+ ** loop delivers items in sorted order, jump to the next iteration
+ ** of the outer loop.
+ */
+ int iCsr = pSort->iECursor;
+ sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);
+ iSkip = sqlite3VdbeAddOp4Int(v, OP_IdxLE,
+ iCsr, 0, regBase+nOBSat, nExpr-nOBSat);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp1(v, OP_Delete, iCsr);
+ }
+ if( regRecord==0 ){
+ regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);
+ }
if( pSort->sortFlags & SORTFLAG_UseSorter ){
op = OP_SorterInsert;
}else{
@@ -120876,33 +122025,10 @@ static void pushOntoSorter(
}
sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,
regBase+nOBSat, nBase-nOBSat);
- if( iLimit ){
- int addr;
- int r1 = 0;
- /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit
- ** register is initialized with value of LIMIT+OFFSET.) After the sorter
- ** fills up, delete the least entry in the sorter after each insert.
- ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
- addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v);
- sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
- if( pSort->bOrderedInnerLoop ){
- r1 = ++pParse->nMem;
- sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
- VdbeComment((v, "seq"));
- }
- sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
- if( pSort->bOrderedInnerLoop ){
- /* If the inner loop is driven by an index such that values from
- ** the same iteration of the inner loop are in sorted order, then
- ** immediately jump to the next iteration of an inner loop if the
- ** entry from the current iteration does not fit into the top
- ** LIMIT+OFFSET entries of the sorter. */
- int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
- sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
- sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
- VdbeCoverage(v);
- }
- sqlite3VdbeJumpHere(v, addr);
+ if( iSkip ){
+ assert( pSort->bOrderedInnerLoop==0 || pSort->bOrderedInnerLoop==1 );
+ sqlite3VdbeChangeP2(v, iSkip,
+ sqlite3VdbeCurrentAddr(v) + pSort->bOrderedInnerLoop);
}
}
@@ -120948,6 +122074,87 @@ static void codeDistinct(
sqlite3ReleaseTempReg(pParse, r1);
}
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+/*
+** This function is called as part of inner-loop generation for a SELECT
+** statement with an ORDER BY that is not optimized by an index. It
+** determines the expressions, if any, that the sorter-reference
+** optimization should be used for. The sorter-reference optimization
+** is used for SELECT queries like:
+**
+** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10
+**
+** If the optimization is used for expression "bigblob", then instead of
+** storing values read from that column in the sorter records, the PK of
+** the row from table t1 is stored instead. Then, as records are extracted from
+** the sorter to return to the user, the required value of bigblob is
+** retrieved directly from table t1. If the values are very large, this
+** can be more efficient than storing them directly in the sorter records.
+**
+** The ExprList_item.bSorterRef flag is set for each expression in pEList
+** for which the sorter-reference optimization should be enabled.
+** Additionally, the pSort->aDefer[] array is populated with entries
+** for all cursors required to evaluate all selected expressions. Finally.
+** output variable (*ppExtra) is set to an expression list containing
+** expressions for all extra PK values that should be stored in the
+** sorter records.
+*/
+static void selectExprDefer(
+ Parse *pParse, /* Leave any error here */
+ SortCtx *pSort, /* Sorter context */
+ ExprList *pEList, /* Expressions destined for sorter */
+ ExprList **ppExtra /* Expressions to append to sorter record */
+){
+ int i;
+ int nDefer = 0;
+ ExprList *pExtra = 0;
+ for(i=0; i<pEList->nExpr; i++){
+ struct ExprList_item *pItem = &pEList->a[i];
+ if( pItem->u.x.iOrderByCol==0 ){
+ Expr *pExpr = pItem->pExpr;
+ Table *pTab = pExpr->pTab;
+ if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab)
+ && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
+ ){
+ int j;
+ for(j=0; j<nDefer; j++){
+ if( pSort->aDefer[j].iCsr==pExpr->iTable ) break;
+ }
+ if( j==nDefer ){
+ if( nDefer==ArraySize(pSort->aDefer) ){
+ continue;
+ }else{
+ int nKey = 1;
+ int k;
+ Index *pPk = 0;
+ if( !HasRowid(pTab) ){
+ pPk = sqlite3PrimaryKeyIndex(pTab);
+ nKey = pPk->nKeyCol;
+ }
+ for(k=0; k<nKey; k++){
+ Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
+ if( pNew ){
+ pNew->iTable = pExpr->iTable;
+ pNew->pTab = pExpr->pTab;
+ pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
+ pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
+ }
+ }
+ pSort->aDefer[nDefer].pTab = pExpr->pTab;
+ pSort->aDefer[nDefer].iCsr = pExpr->iTable;
+ pSort->aDefer[nDefer].nKey = nKey;
+ nDefer++;
+ }
+ }
+ pItem->bSorterRef = 1;
+ }
+ }
+ }
+ pSort->nDefer = (u8)nDefer;
+ *ppExtra = pExtra;
+}
+#endif
+
/*
** This routine generates the code for the inside of the inner loop
** of a SELECT.
@@ -120974,6 +122181,7 @@ static void selectInnerLoop(
int iParm = pDest->iSDParm; /* First argument to disposal method */
int nResultCol; /* Number of result columns */
int nPrefixReg = 0; /* Number of extra registers before regResult */
+ RowLoadInfo sRowLoadInfo; /* Info for deferred row loading */
/* Usually, regResult is the first cell in an array of memory cells
** containing the current result row. In this case regOrig is set to the
@@ -121020,10 +122228,14 @@ static void selectInnerLoop(
VdbeComment((v, "%s", p->pEList->a[i].zName));
}
}else if( eDest!=SRT_Exists ){
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ ExprList *pExtra = 0;
+#endif
/* If the destination is an EXISTS(...) expression, the actual
** values returned by the SELECT are not required.
*/
- u8 ecelFlags;
+ u8 ecelFlags; /* "ecel" is an abbreviation of "ExprCodeExprList" */
+ ExprList *pEList;
if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){
ecelFlags = SQLITE_ECEL_DUP;
}else{
@@ -121037,18 +122249,68 @@ static void selectInnerLoop(
** This allows the p->pEList field to be omitted from the sorted record,
** saving space and CPU cycles. */
ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);
+
for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){
int j;
if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){
p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;
}
}
- regOrig = 0;
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ selectExprDefer(pParse, pSort, p->pEList, &pExtra);
+ if( pExtra && pParse->db->mallocFailed==0 ){
+ /* If there are any extra PK columns to add to the sorter records,
+ ** allocate extra memory cells and adjust the OpenEphemeral
+ ** instruction to account for the larger records. This is only
+ ** required if there are one or more WITHOUT ROWID tables with
+ ** composite primary keys in the SortCtx.aDefer[] array. */
+ VdbeOp *pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
+ pOp->p2 += (pExtra->nExpr - pSort->nDefer);
+ pOp->p4.pKeyInfo->nAllField += (pExtra->nExpr - pSort->nDefer);
+ pParse->nMem += pExtra->nExpr;
+ }
+#endif
+
+ /* Adjust nResultCol to account for columns that are omitted
+ ** from the sorter by the optimizations in this branch */
+ pEList = p->pEList;
+ for(i=0; i<pEList->nExpr; i++){
+ if( pEList->a[i].u.x.iOrderByCol>0
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ || pEList->a[i].bSorterRef
+#endif
+ ){
+ nResultCol--;
+ regOrig = 0;
+ }
+ }
+
+ testcase( regOrig );
+ testcase( eDest==SRT_Set );
+ testcase( eDest==SRT_Mem );
+ testcase( eDest==SRT_Coroutine );
+ testcase( eDest==SRT_Output );
assert( eDest==SRT_Set || eDest==SRT_Mem
|| eDest==SRT_Coroutine || eDest==SRT_Output );
}
- nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult,
- 0,ecelFlags);
+ sRowLoadInfo.regResult = regResult;
+ sRowLoadInfo.ecelFlags = ecelFlags;
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ sRowLoadInfo.pExtra = pExtra;
+ sRowLoadInfo.regExtraResult = regResult + nResultCol;
+ if( pExtra ) nResultCol += pExtra->nExpr;
+#endif
+ if( p->iLimit
+ && (ecelFlags & SQLITE_ECEL_OMITREF)!=0
+ && nPrefixReg>0
+ ){
+ assert( pSort!=0 );
+ assert( hasDistinct==0 );
+ pSort->pDeferredRowLoad = &sRowLoadInfo;
+ regOrig = 0;
+ }else{
+ innerLoopLoadRow(pParse, p, &sRowLoadInfo);
+ }
}
/* If the DISTINCT keyword was present on the SELECT statement
@@ -121164,7 +122426,8 @@ static void selectInnerLoop(
}
#endif
if( pSort ){
- pushOntoSorter(pParse, pSort, p, r1+nPrefixReg,regResult,1,nPrefixReg);
+ assert( regResult==regOrig );
+ pushOntoSorter(pParse, pSort, p, r1+nPrefixReg, regOrig, 1, nPrefixReg);
}else{
int r2 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);
@@ -121431,11 +122694,7 @@ static const char *selectOpName(int id){
** is determined by the zUsage argument.
*/
static void explainTempTable(Parse *pParse, const char *zUsage){
- if( pParse->explain==2 ){
- Vdbe *v = pParse->pVdbe;
- char *zMsg = sqlite3MPrintf(pParse->db, "USE TEMP B-TREE FOR %s", zUsage);
- sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
- }
+ ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s", zUsage));
}
/*
@@ -121453,42 +122712,6 @@ static void explainTempTable(Parse *pParse, const char *zUsage){
# define explainSetInteger(y,z)
#endif
-#if !defined(SQLITE_OMIT_EXPLAIN) && !defined(SQLITE_OMIT_COMPOUND_SELECT)
-/*
-** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
-** is a no-op. Otherwise, it adds a single row of output to the EQP result,
-** where the caption is of one of the two forms:
-**
-** "COMPOSITE SUBQUERIES iSub1 and iSub2 (op)"
-** "COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)"
-**
-** where iSub1 and iSub2 are the integers passed as the corresponding
-** function parameters, and op is the text representation of the parameter
-** of the same name. The parameter "op" must be one of TK_UNION, TK_EXCEPT,
-** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is
-** false, or the second form if it is true.
-*/
-static void explainComposite(
- Parse *pParse, /* Parse context */
- int op, /* One of TK_UNION, TK_EXCEPT etc. */
- int iSub1, /* Subquery id 1 */
- int iSub2, /* Subquery id 2 */
- int bUseTmp /* True if a temp table was used */
-){
- assert( op==TK_UNION || op==TK_EXCEPT || op==TK_INTERSECT || op==TK_ALL );
- if( pParse->explain==2 ){
- Vdbe *v = pParse->pVdbe;
- char *zMsg = sqlite3MPrintf(
- pParse->db, "COMPOUND SUBQUERIES %d AND %d %s(%s)", iSub1, iSub2,
- bUseTmp?"USING TEMP B-TREE ":"", selectOpName(op)
- );
- sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
- }
-}
-#else
-/* No-op versions of the explainXXX() functions and macros. */
-# define explainComposite(v,w,x,y,z)
-#endif
/*
** If the inner loop was generated using a non-null pOrderBy argument,
@@ -121506,7 +122729,7 @@ static void generateSortTail(
Vdbe *v = pParse->pVdbe; /* The prepared statement */
int addrBreak = pSort->labelDone; /* Jump here to exit loop */
int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */
- int addr;
+ int addr; /* Top of output loop. Jump for Next. */
int addrOnce = 0;
int iTab;
ExprList *pOrderBy = pSort->pOrderBy;
@@ -121515,11 +122738,11 @@ static void generateSortTail(
int regRow;
int regRowid;
int iCol;
- int nKey;
+ int nKey; /* Number of key columns in sorter record */
int iSortTab; /* Sorter cursor to read from */
- int nSortData; /* Trailing values to read from sorter */
int i;
int bSeq; /* True if sorter record includes seq. no. */
+ int nRefKey = 0;
struct ExprList_item *aOutEx = p->pEList->a;
assert( addrBreak<0 );
@@ -121528,15 +122751,24 @@ static void generateSortTail(
sqlite3VdbeGoto(v, addrBreak);
sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
}
+
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ /* Open any cursors needed for sorter-reference expressions */
+ for(i=0; i<pSort->nDefer; i++){
+ Table *pTab = pSort->aDefer[i].pTab;
+ int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
+ sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead);
+ nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey);
+ }
+#endif
+
iTab = pSort->iECursor;
if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
regRowid = 0;
regRow = pDest->iSdst;
- nSortData = nColumn;
}else{
regRowid = sqlite3GetTempReg(pParse);
regRow = sqlite3GetTempRange(pParse, nColumn);
- nSortData = nColumn;
}
nKey = pOrderBy->nExpr - pSort->nOBSat;
if( pSort->sortFlags & SORTFLAG_UseSorter ){
@@ -121545,7 +122777,8 @@ static void generateSortTail(
if( pSort->labelBkOut ){
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
}
- sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);
+ sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut,
+ nKey+1+nColumn+nRefKey);
if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
VdbeCoverage(v);
@@ -121558,18 +122791,59 @@ static void generateSortTail(
iSortTab = iTab;
bSeq = 1;
}
- for(i=0, iCol=nKey+bSeq-1; i<nSortData; i++){
+ for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( aOutEx[i].bSorterRef ) continue;
+#endif
if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++;
}
- for(i=nSortData-1; i>=0; i--){
- int iRead;
- if( aOutEx[i].u.x.iOrderByCol ){
- iRead = aOutEx[i].u.x.iOrderByCol-1;
- }else{
- iRead = iCol--;
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( pSort->nDefer ){
+ int iKey = iCol+1;
+ int regKey = sqlite3GetTempRange(pParse, nRefKey);
+
+ for(i=0; i<pSort->nDefer; i++){
+ int iCsr = pSort->aDefer[i].iCsr;
+ Table *pTab = pSort->aDefer[i].pTab;
+ int nKey = pSort->aDefer[i].nKey;
+
+ sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
+ if( HasRowid(pTab) ){
+ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey);
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iCsr,
+ sqlite3VdbeCurrentAddr(v)+1, regKey);
+ }else{
+ int k;
+ int iJmp;
+ assert( sqlite3PrimaryKeyIndex(pTab)->nKeyCol==nKey );
+ for(k=0; k<nKey; k++){
+ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey+k);
+ }
+ iJmp = sqlite3VdbeCurrentAddr(v);
+ sqlite3VdbeAddOp4Int(v, OP_SeekGE, iCsr, iJmp+2, regKey, nKey);
+ sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp+3, regKey, nKey);
+ sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
+ }
+ }
+ sqlite3ReleaseTempRange(pParse, regKey, nRefKey);
+ }
+#endif
+ for(i=nColumn-1; i>=0; i--){
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ if( aOutEx[i].bSorterRef ){
+ sqlite3ExprCode(pParse, aOutEx[i].pExpr, regRow+i);
+ }else
+#endif
+ {
+ int iRead;
+ if( aOutEx[i].u.x.iOrderByCol ){
+ iRead = aOutEx[i].u.x.iOrderByCol-1;
+ }else{
+ iRead = iCol--;
+ }
+ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
+ VdbeComment((v, "%s", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan));
}
- sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
- VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
}
switch( eDest ){
case SRT_Table:
@@ -121887,7 +123161,7 @@ static void generateColumnNames(
}
#endif
- if( pParse->colNamesSet || db->mallocFailed ) return;
+ if( pParse->colNamesSet ) return;
/* Column names are determined by the left-most term of a compound select */
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
SELECTTRACE(1,pParse,pSelect,("generating column names\n"));
@@ -122414,6 +123688,7 @@ static void generateWithRecursiveQuery(
/* Store the results of the setup-query in Queue. */
pSetup->pNext = 0;
+ ExplainQueryPlan((pParse, 1, "SETUP"));
rc = sqlite3Select(pParse, pSetup, &destQueue);
pSetup->pNext = p;
if( rc ) goto end_of_recursive_query;
@@ -122448,6 +123723,7 @@ static void generateWithRecursiveQuery(
sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported");
}else{
p->pPrior = 0;
+ ExplainQueryPlan((pParse, 1, "RECURSIVE STEP"));
sqlite3Select(pParse, p, &destQueue);
assert( p->pPrior==0 );
p->pPrior = pSetup;
@@ -122493,10 +123769,9 @@ static int multiSelectValues(
Select *p, /* The right-most of SELECTs to be coded */
SelectDest *pDest /* What to do with query results */
){
- Select *pPrior;
- Select *pRightmost = p;
int nRow = 1;
int rc = 0;
+ int bShowAll = p->pLimit==0;
assert( p->selFlags & SF_MultiValue );
do{
assert( p->selFlags & SF_Values );
@@ -122505,14 +123780,13 @@ static int multiSelectValues(
if( p->pPrior==0 ) break;
assert( p->pPrior->pNext==p );
p = p->pPrior;
- nRow++;
+ nRow += bShowAll;
}while(1);
+ ExplainQueryPlan((pParse, 0, "SCAN %d CONSTANT ROW%s", nRow,
+ nRow==1 ? "" : "S"));
while( p ){
- pPrior = p->pPrior;
- p->pPrior = 0;
- rc = sqlite3Select(pParse, p, pDest);
- p->pPrior = pPrior;
- if( rc || pRightmost->pLimit ) break;
+ selectInnerLoop(pParse, p, -1, 0, 0, pDest, 1, 1);
+ if( !bShowAll ) break;
p->nSelectRow = nRow;
p = p->pNext;
}
@@ -122561,10 +123835,6 @@ static int multiSelect(
SelectDest dest; /* Alternative data destination */
Select *pDelete = 0; /* Chain of simple selects to delete */
sqlite3 *db; /* Database connection */
-#ifndef SQLITE_OMIT_EXPLAIN
- int iSub1 = 0; /* EQP id of left-hand query */
- int iSub2 = 0; /* EQP id of right-hand query */
-#endif
/* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
@@ -122615,217 +123885,231 @@ static int multiSelect(
*/
if( p->pOrderBy ){
return multiSelectOrderBy(pParse, p, pDest);
- }else
+ }else{
- /* Generate code for the left and right SELECT statements.
- */
- switch( p->op ){
- case TK_ALL: {
- int addr = 0;
- int nLimit;
- assert( !pPrior->pLimit );
- pPrior->iLimit = p->iLimit;
- pPrior->iOffset = p->iOffset;
- pPrior->pLimit = p->pLimit;
- explainSetInteger(iSub1, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, pPrior, &dest);
- p->pLimit = 0;
- if( rc ){
- goto multi_select_end;
- }
- p->pPrior = 0;
- p->iLimit = pPrior->iLimit;
- p->iOffset = pPrior->iOffset;
- if( p->iLimit ){
- addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
- VdbeComment((v, "Jump ahead if LIMIT reached"));
- if( p->iOffset ){
- sqlite3VdbeAddOp3(v, OP_OffsetLimit,
- p->iLimit, p->iOffset+1, p->iOffset);
+#ifndef SQLITE_OMIT_EXPLAIN
+ if( pPrior->pPrior==0 ){
+ ExplainQueryPlan((pParse, 1, "COMPOUND QUERY"));
+ ExplainQueryPlan((pParse, 1, "LEFT-MOST SUBQUERY"));
+ }
+#endif
+
+ /* Generate code for the left and right SELECT statements.
+ */
+ switch( p->op ){
+ case TK_ALL: {
+ int addr = 0;
+ int nLimit;
+ assert( !pPrior->pLimit );
+ pPrior->iLimit = p->iLimit;
+ pPrior->iOffset = p->iOffset;
+ pPrior->pLimit = p->pLimit;
+ rc = sqlite3Select(pParse, pPrior, &dest);
+ p->pLimit = 0;
+ if( rc ){
+ goto multi_select_end;
+ }
+ p->pPrior = 0;
+ p->iLimit = pPrior->iLimit;
+ p->iOffset = pPrior->iOffset;
+ if( p->iLimit ){
+ addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
+ VdbeComment((v, "Jump ahead if LIMIT reached"));
+ if( p->iOffset ){
+ sqlite3VdbeAddOp3(v, OP_OffsetLimit,
+ p->iLimit, p->iOffset+1, p->iOffset);
+ }
}
+ ExplainQueryPlan((pParse, 1, "UNION ALL"));
+ rc = sqlite3Select(pParse, p, &dest);
+ testcase( rc!=SQLITE_OK );
+ pDelete = p->pPrior;
+ p->pPrior = pPrior;
+ p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
+ if( pPrior->pLimit
+ && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)
+ && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit)
+ ){
+ p->nSelectRow = sqlite3LogEst((u64)nLimit);
+ }
+ if( addr ){
+ sqlite3VdbeJumpHere(v, addr);
+ }
+ break;
}
- explainSetInteger(iSub2, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, p, &dest);
- testcase( rc!=SQLITE_OK );
- pDelete = p->pPrior;
- p->pPrior = pPrior;
- p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
- if( pPrior->pLimit
- && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)
- && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit)
- ){
- p->nSelectRow = sqlite3LogEst((u64)nLimit);
- }
- if( addr ){
- sqlite3VdbeJumpHere(v, addr);
- }
- break;
- }
- case TK_EXCEPT:
- case TK_UNION: {
- int unionTab; /* Cursor number of the temporary table holding result */
- u8 op = 0; /* One of the SRT_ operations to apply to self */
- int priorOp; /* The SRT_ operation to apply to prior selects */
- Expr *pLimit; /* Saved values of p->nLimit */
- int addr;
- SelectDest uniondest;
-
- testcase( p->op==TK_EXCEPT );
- testcase( p->op==TK_UNION );
- priorOp = SRT_Union;
- if( dest.eDest==priorOp ){
- /* We can reuse a temporary table generated by a SELECT to our
- ** right.
+ case TK_EXCEPT:
+ case TK_UNION: {
+ int unionTab; /* Cursor number of the temp table holding result */
+ u8 op = 0; /* One of the SRT_ operations to apply to self */
+ int priorOp; /* The SRT_ operation to apply to prior selects */
+ Expr *pLimit; /* Saved values of p->nLimit */
+ int addr;
+ SelectDest uniondest;
+
+ testcase( p->op==TK_EXCEPT );
+ testcase( p->op==TK_UNION );
+ priorOp = SRT_Union;
+ if( dest.eDest==priorOp ){
+ /* We can reuse a temporary table generated by a SELECT to our
+ ** right.
+ */
+ assert( p->pLimit==0 ); /* Not allowed on leftward elements */
+ unionTab = dest.iSDParm;
+ }else{
+ /* We will need to create our own temporary table to hold the
+ ** intermediate results.
+ */
+ unionTab = pParse->nTab++;
+ assert( p->pOrderBy==0 );
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);
+ assert( p->addrOpenEphm[0] == -1 );
+ p->addrOpenEphm[0] = addr;
+ findRightmost(p)->selFlags |= SF_UsesEphemeral;
+ assert( p->pEList );
+ }
+
+ /* Code the SELECT statements to our left
*/
- assert( p->pLimit==0 ); /* Not allowed on leftward elements */
- unionTab = dest.iSDParm;
- }else{
- /* We will need to create our own temporary table to hold the
- ** intermediate results.
+ assert( !pPrior->pOrderBy );
+ sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
+ rc = sqlite3Select(pParse, pPrior, &uniondest);
+ if( rc ){
+ goto multi_select_end;
+ }
+
+ /* Code the current SELECT statement
*/
- unionTab = pParse->nTab++;
+ if( p->op==TK_EXCEPT ){
+ op = SRT_Except;
+ }else{
+ assert( p->op==TK_UNION );
+ op = SRT_Union;
+ }
+ p->pPrior = 0;
+ pLimit = p->pLimit;
+ p->pLimit = 0;
+ uniondest.eDest = op;
+ ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
+ selectOpName(p->op)));
+ rc = sqlite3Select(pParse, p, &uniondest);
+ testcase( rc!=SQLITE_OK );
+ /* Query flattening in sqlite3Select() might refill p->pOrderBy.
+ ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
+ sqlite3ExprListDelete(db, p->pOrderBy);
+ pDelete = p->pPrior;
+ p->pPrior = pPrior;
+ p->pOrderBy = 0;
+ if( p->op==TK_UNION ){
+ p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
+ }
+ sqlite3ExprDelete(db, p->pLimit);
+ p->pLimit = pLimit;
+ p->iLimit = 0;
+ p->iOffset = 0;
+
+ /* Convert the data in the temporary table into whatever form
+ ** it is that we currently need.
+ */
+ assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
+ if( dest.eDest!=priorOp ){
+ int iCont, iBreak, iStart;
+ assert( p->pEList );
+ iBreak = sqlite3VdbeMakeLabel(v);
+ iCont = sqlite3VdbeMakeLabel(v);
+ computeLimitRegisters(pParse, p, iBreak);
+ sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
+ iStart = sqlite3VdbeCurrentAddr(v);
+ selectInnerLoop(pParse, p, unionTab,
+ 0, 0, &dest, iCont, iBreak);
+ sqlite3VdbeResolveLabel(v, iCont);
+ sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);
+ sqlite3VdbeResolveLabel(v, iBreak);
+ sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
+ }
+ break;
+ }
+ default: assert( p->op==TK_INTERSECT ); {
+ int tab1, tab2;
+ int iCont, iBreak, iStart;
+ Expr *pLimit;
+ int addr;
+ SelectDest intersectdest;
+ int r1;
+
+ /* INTERSECT is different from the others since it requires
+ ** two temporary tables. Hence it has its own case. Begin
+ ** by allocating the tables we will need.
+ */
+ tab1 = pParse->nTab++;
+ tab2 = pParse->nTab++;
assert( p->pOrderBy==0 );
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);
+
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);
assert( p->addrOpenEphm[0] == -1 );
p->addrOpenEphm[0] = addr;
findRightmost(p)->selFlags |= SF_UsesEphemeral;
assert( p->pEList );
- }
-
- /* Code the SELECT statements to our left
- */
- assert( !pPrior->pOrderBy );
- sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
- explainSetInteger(iSub1, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, pPrior, &uniondest);
- if( rc ){
- goto multi_select_end;
- }
-
- /* Code the current SELECT statement
- */
- if( p->op==TK_EXCEPT ){
- op = SRT_Except;
- }else{
- assert( p->op==TK_UNION );
- op = SRT_Union;
- }
- p->pPrior = 0;
- pLimit = p->pLimit;
- p->pLimit = 0;
- uniondest.eDest = op;
- explainSetInteger(iSub2, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, p, &uniondest);
- testcase( rc!=SQLITE_OK );
- /* Query flattening in sqlite3Select() might refill p->pOrderBy.
- ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
- sqlite3ExprListDelete(db, p->pOrderBy);
- pDelete = p->pPrior;
- p->pPrior = pPrior;
- p->pOrderBy = 0;
- if( p->op==TK_UNION ){
- p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
- }
- sqlite3ExprDelete(db, p->pLimit);
- p->pLimit = pLimit;
- p->iLimit = 0;
- p->iOffset = 0;
-
- /* Convert the data in the temporary table into whatever form
- ** it is that we currently need.
- */
- assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
- if( dest.eDest!=priorOp ){
- int iCont, iBreak, iStart;
+
+ /* Code the SELECTs to our left into temporary table "tab1".
+ */
+ sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
+ rc = sqlite3Select(pParse, pPrior, &intersectdest);
+ if( rc ){
+ goto multi_select_end;
+ }
+
+ /* Code the current SELECT into temporary table "tab2"
+ */
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
+ assert( p->addrOpenEphm[1] == -1 );
+ p->addrOpenEphm[1] = addr;
+ p->pPrior = 0;
+ pLimit = p->pLimit;
+ p->pLimit = 0;
+ intersectdest.iSDParm = tab2;
+ ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
+ selectOpName(p->op)));
+ rc = sqlite3Select(pParse, p, &intersectdest);
+ testcase( rc!=SQLITE_OK );
+ pDelete = p->pPrior;
+ p->pPrior = pPrior;
+ if( p->nSelectRow>pPrior->nSelectRow ){
+ p->nSelectRow = pPrior->nSelectRow;
+ }
+ sqlite3ExprDelete(db, p->pLimit);
+ p->pLimit = pLimit;
+
+ /* Generate code to take the intersection of the two temporary
+ ** tables.
+ */
assert( p->pEList );
iBreak = sqlite3VdbeMakeLabel(v);
iCont = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, iBreak);
- sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
- iStart = sqlite3VdbeCurrentAddr(v);
- selectInnerLoop(pParse, p, unionTab,
+ sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
+ r1 = sqlite3GetTempReg(pParse);
+ iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
+ VdbeCoverage(v);
+ sqlite3ReleaseTempReg(pParse, r1);
+ selectInnerLoop(pParse, p, tab1,
0, 0, &dest, iCont, iBreak);
sqlite3VdbeResolveLabel(v, iCont);
- sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
sqlite3VdbeResolveLabel(v, iBreak);
- sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
+ sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
+ sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
+ break;
}
- break;
}
- default: assert( p->op==TK_INTERSECT ); {
- int tab1, tab2;
- int iCont, iBreak, iStart;
- Expr *pLimit;
- int addr;
- SelectDest intersectdest;
- int r1;
-
- /* INTERSECT is different from the others since it requires
- ** two temporary tables. Hence it has its own case. Begin
- ** by allocating the tables we will need.
- */
- tab1 = pParse->nTab++;
- tab2 = pParse->nTab++;
- assert( p->pOrderBy==0 );
-
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);
- assert( p->addrOpenEphm[0] == -1 );
- p->addrOpenEphm[0] = addr;
- findRightmost(p)->selFlags |= SF_UsesEphemeral;
- assert( p->pEList );
-
- /* Code the SELECTs to our left into temporary table "tab1".
- */
- sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
- explainSetInteger(iSub1, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, pPrior, &intersectdest);
- if( rc ){
- goto multi_select_end;
- }
-
- /* Code the current SELECT into temporary table "tab2"
- */
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
- assert( p->addrOpenEphm[1] == -1 );
- p->addrOpenEphm[1] = addr;
- p->pPrior = 0;
- pLimit = p->pLimit;
- p->pLimit = 0;
- intersectdest.iSDParm = tab2;
- explainSetInteger(iSub2, pParse->iNextSelectId);
- rc = sqlite3Select(pParse, p, &intersectdest);
- testcase( rc!=SQLITE_OK );
- pDelete = p->pPrior;
- p->pPrior = pPrior;
- if( p->nSelectRow>pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;
- sqlite3ExprDelete(db, p->pLimit);
- p->pLimit = pLimit;
-
- /* Generate code to take the intersection of the two temporary
- ** tables.
- */
- assert( p->pEList );
- iBreak = sqlite3VdbeMakeLabel(v);
- iCont = sqlite3VdbeMakeLabel(v);
- computeLimitRegisters(pParse, p, iBreak);
- sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
- r1 = sqlite3GetTempReg(pParse);
- iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
- sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); VdbeCoverage(v);
- sqlite3ReleaseTempReg(pParse, r1);
- selectInnerLoop(pParse, p, tab1,
- 0, 0, &dest, iCont, iBreak);
- sqlite3VdbeResolveLabel(v, iCont);
- sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
- sqlite3VdbeResolveLabel(v, iBreak);
- sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
- sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
- break;
+
+ #ifndef SQLITE_OMIT_EXPLAIN
+ if( p->pNext==0 ){
+ ExplainQueryPlanPop(pParse);
}
+ #endif
}
-
- explainComposite(pParse, p->op, iSub1, iSub2, p->op!=TK_ALL);
-
+
/* Compute collating sequences used by
** temporary tables needed to implement the compound select.
** Attach the KeyInfo structure to all temporary tables.
@@ -123163,10 +124447,6 @@ static int multiSelectOrderBy(
ExprList *pOrderBy; /* The ORDER BY clause */
int nOrderBy; /* Number of terms in the ORDER BY clause */
int *aPermute; /* Mapping from ORDER BY terms to result set columns */
-#ifndef SQLITE_OMIT_EXPLAIN
- int iSub1; /* EQP id of left-hand query */
- int iSub2; /* EQP id of right-hand query */
-#endif
assert( p->pOrderBy!=0 );
assert( pKeyDup==0 ); /* "Managed" code needs this. Ticket #3382. */
@@ -123286,6 +124566,8 @@ static int multiSelectOrderBy(
sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);
sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);
+ ExplainQueryPlan((pParse, 1, "MERGE (%s)", selectOpName(p->op)));
+
/* Generate a coroutine to evaluate the SELECT statement to the
** left of the compound operator - the "A" select.
*/
@@ -123293,7 +124575,7 @@ static int multiSelectOrderBy(
addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);
VdbeComment((v, "left SELECT"));
pPrior->iLimit = regLimitA;
- explainSetInteger(iSub1, pParse->iNextSelectId);
+ ExplainQueryPlan((pParse, 1, "LEFT"));
sqlite3Select(pParse, pPrior, &destA);
sqlite3VdbeEndCoroutine(v, regAddrA);
sqlite3VdbeJumpHere(v, addr1);
@@ -123308,7 +124590,7 @@ static int multiSelectOrderBy(
savedOffset = p->iOffset;
p->iLimit = regLimitB;
p->iOffset = 0;
- explainSetInteger(iSub2, pParse->iNextSelectId);
+ ExplainQueryPlan((pParse, 1, "RIGHT"));
sqlite3Select(pParse, p, &destB);
p->iLimit = savedLimit;
p->iOffset = savedOffset;
@@ -123420,7 +124702,7 @@ static int multiSelectOrderBy(
/*** TBD: Insert subroutine calls to close cursors on incomplete
**** subqueries ****/
- explainComposite(pParse, p->op, iSub1, iSub2, 0);
+ ExplainQueryPlanPop(pParse);
return pParse->nErr!=0;
}
#endif
@@ -123907,9 +125189,8 @@ static int flattenSubquery(
if( pPrior ) pPrior->pNext = pNew;
pNew->pNext = p;
p->pPrior = pNew;
- SELECTTRACE(2,pParse,p,
- ("compound-subquery flattener creates %s.%p as peer\n",
- pNew->zSelName, pNew));
+ SELECTTRACE(2,pParse,p,("compound-subquery flattener"
+ " creates %s.%p as peer\n",pNew->zSelName, pNew));
}
if( db->mallocFailed ) return 1;
}
@@ -125209,14 +126490,11 @@ static void explainSimpleCount(
){
if( pParse->explain==2 ){
int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));
- char *zEqp = sqlite3MPrintf(pParse->db, "SCAN TABLE %s%s%s",
+ sqlite3VdbeExplain(pParse, 0, "SCAN TABLE %s%s%s",
pTab->zName,
bCover ? " USING COVERING INDEX " : "",
bCover ? pIdx->zName : ""
);
- sqlite3VdbeAddOp4(
- pParse->pVdbe, OP_Explain, pParse->iSelectId, 0, 0, zEqp, P4_DYNAMIC
- );
}
}
#else
@@ -125429,19 +126707,15 @@ SQLITE_PRIVATE int sqlite3Select(
ExprList *pMinMaxOrderBy = 0; /* Added ORDER BY for min/max queries */
u8 minMaxFlag; /* Flag for min/max queries */
-#ifndef SQLITE_OMIT_EXPLAIN
- int iRestoreSelectId = pParse->iSelectId;
- pParse->iSelectId = pParse->iNextSelectId++;
-#endif
-
db = pParse->db;
+ v = sqlite3GetVdbe(pParse);
if( p==0 || db->mallocFailed || pParse->nErr ){
return 1;
}
if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
memset(&sAggInfo, 0, sizeof(sAggInfo));
#if SELECTTRACE_ENABLED
- SELECTTRACE(1,pParse,p, ("begin processing:\n"));
+ SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain));
if( sqlite3SelectTrace & 0x100 ){
sqlite3TreeViewSelect(0, p, 0);
}
@@ -125472,16 +126746,12 @@ SQLITE_PRIVATE int sqlite3Select(
assert( p->pEList!=0 );
isAgg = (p->selFlags & SF_Aggregate)!=0;
#if SELECTTRACE_ENABLED
- if( sqlite3SelectTrace & 0x100 ){
- SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
+ if( sqlite3SelectTrace & 0x104 ){
+ SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
sqlite3TreeViewSelect(0, p, 0);
}
#endif
- /* Get a pointer the VDBE under construction, allocating a new VDBE if one
- ** does not already exist */
- v = sqlite3GetVdbe(pParse);
- if( v==0 ) goto select_end;
if( pDest->eDest==SRT_Output ){
generateColumnNames(pParse, p);
}
@@ -125574,10 +126844,13 @@ SQLITE_PRIVATE int sqlite3Select(
*/
if( p->pPrior ){
rc = multiSelect(pParse, p, pDest);
- explainSetInteger(pParse->iSelectId, iRestoreSelectId);
#if SELECTTRACE_ENABLED
- SELECTTRACE(1,pParse,p,("end compound-select processing\n"));
+ SELECTTRACE(0x1,pParse,p,("end compound-select processing\n"));
+ if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){
+ sqlite3TreeViewSelect(0, p, 0);
+ }
#endif
+ if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
return rc;
}
#endif
@@ -125689,7 +126962,7 @@ SQLITE_PRIVATE int sqlite3Select(
VdbeComment((v, "%s", pItem->pTab->zName));
pItem->addrFillSub = addrTop;
sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);
- explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
+ ExplainQueryPlan((pParse, 1, "CO-ROUTINE 0x%p", pSub));
sqlite3Select(pParse, pSub, &dest);
pItem->pTab->nRowLogEst = pSub->nSelectRow;
pItem->fg.viaCoroutine = 1;
@@ -125724,12 +126997,11 @@ SQLITE_PRIVATE int sqlite3Select(
pPrior = isSelfJoinView(pTabList, pItem);
if( pPrior ){
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
- explainSetInteger(pItem->iSelectId, pPrior->iSelectId);
assert( pPrior->pSelect!=0 );
pSub->nSelectRow = pPrior->pSelect->nSelectRow;
}else{
sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
- explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
+ ExplainQueryPlan((pParse, 1, "MATERIALIZE 0x%p", pSub));
sqlite3Select(pParse, pSub, &dest);
}
pItem->pTab->nRowLogEst = pSub->nSelectRow;
@@ -125956,7 +127228,8 @@ SQLITE_PRIVATE int sqlite3Select(
memset(&sNC, 0, sizeof(sNC));
sNC.pParse = pParse;
sNC.pSrcList = pTabList;
- sNC.pAggInfo = &sAggInfo;
+ sNC.uNC.pAggInfo = &sAggInfo;
+ VVA_ONLY( sNC.ncFlags = NC_UAggInfo; )
sAggInfo.mnReg = pParse->nMem+1;
sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;
sAggInfo.pGroupBy = pGroupBy;
@@ -126345,6 +127618,7 @@ SQLITE_PRIVATE int sqlite3Select(
if( sSort.pOrderBy ){
explainTempTable(pParse,
sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY");
+ assert( p->pEList==pEList );
generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);
}
@@ -126360,13 +127634,16 @@ SQLITE_PRIVATE int sqlite3Select(
** successful coding of the SELECT.
*/
select_end:
- explainSetInteger(pParse->iSelectId, iRestoreSelectId);
sqlite3ExprListDelete(db, pMinMaxOrderBy);
sqlite3DbFree(db, sAggInfo.aCol);
sqlite3DbFree(db, sAggInfo.aFunc);
#if SELECTTRACE_ENABLED
- SELECTTRACE(1,pParse,p,("end processing\n"));
+ SELECTTRACE(0x1,pParse,p,("end processing\n"));
+ if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){
+ sqlite3TreeViewSelect(0, p, 0);
+ }
#endif
+ ExplainQueryPlanPop(pParse);
return rc;
}
@@ -126600,6 +127877,7 @@ SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerS
sqlite3ExprListDelete(db, pTmp->pExprList);
sqlite3SelectDelete(db, pTmp->pSelect);
sqlite3IdListDelete(db, pTmp->pIdList);
+ sqlite3UpsertDelete(db, pTmp->pUpsert);
sqlite3DbFree(db, pTmp->zSpan);
sqlite3DbFree(db, pTmp);
@@ -126991,6 +128269,7 @@ SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
IdList *pColumn, /* List of columns in pTableName to insert into */
Select *pSelect, /* A SELECT statement that supplies values */
u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
+ Upsert *pUpsert, /* ON CONFLICT clauses for upsert */
const char *zStart, /* Start of SQL text */
const char *zEnd /* End of SQL text */
){
@@ -127002,9 +128281,13 @@ SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
if( pTriggerStep ){
pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
pTriggerStep->pIdList = pColumn;
+ pTriggerStep->pUpsert = pUpsert;
pTriggerStep->orconf = orconf;
}else{
+ testcase( pColumn );
sqlite3IdListDelete(db, pColumn);
+ testcase( pUpsert );
+ sqlite3UpsertDelete(db, pUpsert);
}
sqlite3SelectDelete(db, pSelect);
@@ -127321,7 +128604,7 @@ static int codeTriggerProgram(
targetSrcList(pParse, pStep),
sqlite3ExprListDup(db, pStep->pExprList, 0),
sqlite3ExprDup(db, pStep->pWhere, 0),
- pParse->eOrconf, 0, 0
+ pParse->eOrconf, 0, 0, 0
);
break;
}
@@ -127330,7 +128613,8 @@ static int codeTriggerProgram(
targetSrcList(pParse, pStep),
sqlite3SelectDup(db, pStep->pSelect, 0),
sqlite3IdListDup(db, pStep->pIdList),
- pParse->eOrconf
+ pParse->eOrconf,
+ sqlite3UpsertDup(db, pStep->pUpsert)
);
break;
}
@@ -127808,7 +129092,8 @@ SQLITE_PRIVATE void sqlite3Update(
Expr *pWhere, /* The WHERE clause. May be null */
int onError, /* How to handle constraint errors */
ExprList *pOrderBy, /* ORDER BY clause. May be null */
- Expr *pLimit /* LIMIT clause. May be null */
+ Expr *pLimit, /* LIMIT clause. May be null */
+ Upsert *pUpsert /* ON CONFLICT clause, or null */
){
int i, j; /* Loop counters */
Table *pTab; /* The table to be updated */
@@ -127915,16 +129200,23 @@ SQLITE_PRIVATE void sqlite3Update(
** need to occur right after the database cursor. So go ahead and
** allocate enough space, just in case.
*/
- pTabList->a[0].iCursor = iBaseCur = iDataCur = pParse->nTab++;
+ iBaseCur = iDataCur = pParse->nTab++;
iIdxCur = iDataCur+1;
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
+ testcase( pPk!=0 && pPk!=pTab->pIndex );
for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
- if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){
+ if( pPk==pIdx ){
iDataCur = pParse->nTab;
- pTabList->a[0].iCursor = iDataCur;
}
pParse->nTab++;
}
+ if( pUpsert ){
+ /* On an UPSERT, reuse the same cursors already opened by INSERT */
+ iDataCur = pUpsert->iDataCur;
+ iIdxCur = pUpsert->iIdxCur;
+ pParse->nTab = iBaseCur;
+ }
+ pTabList->a[0].iCursor = iDataCur;
/* Allocate space for aXRef[], aRegIdx[], and aToOpen[].
** Initialize aXRef[] and aToOpen[] to their default values.
@@ -127941,6 +129233,8 @@ SQLITE_PRIVATE void sqlite3Update(
memset(&sNC, 0, sizeof(sNC));
sNC.pParse = pParse;
sNC.pSrcList = pTabList;
+ sNC.uNC.pUpsert = pUpsert;
+ sNC.ncFlags = NC_UUpsert;
/* Resolve the column names in all the expressions of the
** of the UPDATE statement. Also find the column index
@@ -128044,7 +129338,7 @@ SQLITE_PRIVATE void sqlite3Update(
v = sqlite3GetVdbe(pParse);
if( v==0 ) goto update_cleanup;
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
- sqlite3BeginWriteOperation(pParse, 1, iDb);
+ sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);
/* Allocate required registers. */
if( !IsVirtual(pTab) ){
@@ -128095,8 +129389,16 @@ SQLITE_PRIVATE void sqlite3Update(
}
#endif
- /* Initialize the count of updated rows */
- if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){
+ /* Jump to labelBreak to abandon further processing of this UPDATE */
+ labelContinue = labelBreak = sqlite3VdbeMakeLabel(v);
+
+ /* Not an UPSERT. Normal processing. Begin by
+ ** initialize the count of updated rows */
+ if( (db->flags&SQLITE_CountRows)!=0
+ && !pParse->pTriggerTab
+ && !pParse->nested
+ && pUpsert==0
+ ){
regRowCount = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
}
@@ -128109,46 +129411,61 @@ SQLITE_PRIVATE void sqlite3Update(
iPk = pParse->nMem+1;
pParse->nMem += nPk;
regKey = ++pParse->nMem;
- iEph = pParse->nTab++;
-
- sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
- addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
- sqlite3VdbeSetP4KeyInfo(pParse, pPk);
- }
-
- /* Begin the database scan.
- **
- ** Do not consider a single-pass strategy for a multi-row update if
- ** there are any triggers or foreign keys to process, or rows may
- ** be deleted as a result of REPLACE conflict handling. Any of these
- ** things might disturb a cursor being used to scan through the table
- ** or index, causing a single-pass approach to malfunction. */
- flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
- if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
- flags |= WHERE_ONEPASS_MULTIROW;
- }
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
- if( pWInfo==0 ) goto update_cleanup;
-
- /* A one-pass strategy that might update more than one row may not
- ** be used if any column of the index used for the scan is being
- ** updated. Otherwise, if there is an index on "b", statements like
- ** the following could create an infinite loop:
- **
- ** UPDATE t1 SET b=b+1 WHERE b>?
- **
- ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
- ** strategy that uses an index for which one or more columns are being
- ** updated. */
- eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
- if( eOnePass==ONEPASS_MULTI ){
- int iCur = aiCurOnePass[1];
- if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
- eOnePass = ONEPASS_OFF;
+ if( pUpsert==0 ){
+ iEph = pParse->nTab++;
+ sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
+ addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
+ sqlite3VdbeSetP4KeyInfo(pParse, pPk);
}
- assert( iCur!=iDataCur || !HasRowid(pTab) );
}
+ if( pUpsert ){
+ /* If this is an UPSERT, then all cursors have already been opened by
+ ** the outer INSERT and the data cursor should be pointing at the row
+ ** that is to be updated. So bypass the code that searches for the
+ ** row(s) to be updated.
+ */
+ pWInfo = 0;
+ eOnePass = ONEPASS_SINGLE;
+ sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL);
+ }else{
+ /* Begin the database scan.
+ **
+ ** Do not consider a single-pass strategy for a multi-row update if
+ ** there are any triggers or foreign keys to process, or rows may
+ ** be deleted as a result of REPLACE conflict handling. Any of these
+ ** things might disturb a cursor being used to scan through the table
+ ** or index, causing a single-pass approach to malfunction. */
+ flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
+ if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
+ flags |= WHERE_ONEPASS_MULTIROW;
+ }
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
+ if( pWInfo==0 ) goto update_cleanup;
+
+ /* A one-pass strategy that might update more than one row may not
+ ** be used if any column of the index used for the scan is being
+ ** updated. Otherwise, if there is an index on "b", statements like
+ ** the following could create an infinite loop:
+ **
+ ** UPDATE t1 SET b=b+1 WHERE b>?
+ **
+ ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
+ ** strategy that uses an index for which one or more columns are being
+ ** updated. */
+ eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
+ if( eOnePass!=ONEPASS_SINGLE ){
+ sqlite3MultiWrite(pParse);
+ if( eOnePass==ONEPASS_MULTI ){
+ int iCur = aiCurOnePass[1];
+ if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
+ eOnePass = ONEPASS_OFF;
+ }
+ assert( iCur!=iDataCur || !HasRowid(pTab) );
+ }
+ }
+ }
+
if( HasRowid(pTab) ){
/* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF
** mode, write the rowid into the FIFO. In either of the one-pass modes,
@@ -128168,7 +129485,7 @@ SQLITE_PRIVATE void sqlite3Update(
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);
}
if( eOnePass ){
- sqlite3VdbeChangeToNoop(v, addrOpen);
+ if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
nKey = nPk;
regKey = iPk;
}else{
@@ -128178,59 +129495,58 @@ SQLITE_PRIVATE void sqlite3Update(
}
}
- if( eOnePass!=ONEPASS_MULTI ){
- sqlite3WhereEnd(pWInfo);
- }
-
- labelBreak = sqlite3VdbeMakeLabel(v);
- if( !isView ){
- int addrOnce = 0;
-
- /* Open every index that needs updating. */
- if( eOnePass!=ONEPASS_OFF ){
- if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
- if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
- }
-
- if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
- addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ if( pUpsert==0 ){
+ if( eOnePass!=ONEPASS_MULTI ){
+ sqlite3WhereEnd(pWInfo);
}
- sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen,
- 0, 0);
- if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
- }
-
- /* Top of the update loop */
- if( eOnePass!=ONEPASS_OFF ){
- if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
- assert( pPk );
- sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey, nKey);
- VdbeCoverageNeverTaken(v);
+
+ if( !isView ){
+ int addrOnce = 0;
+
+ /* Open every index that needs updating. */
+ if( eOnePass!=ONEPASS_OFF ){
+ if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
+ if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
+ }
+
+ if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ }
+ sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur,
+ aToOpen, 0, 0);
+ if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
}
- if( eOnePass==ONEPASS_SINGLE ){
- labelContinue = labelBreak;
- }else{
+
+ /* Top of the update loop */
+ if( eOnePass!=ONEPASS_OFF ){
+ if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
+ assert( pPk );
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
+ VdbeCoverageNeverTaken(v);
+ }
+ if( eOnePass!=ONEPASS_SINGLE ){
+ labelContinue = sqlite3VdbeMakeLabel(v);
+ }
+ sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
+ VdbeCoverageIf(v, pPk==0);
+ VdbeCoverageIf(v, pPk!=0);
+ }else if( pPk ){
labelContinue = sqlite3VdbeMakeLabel(v);
+ sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
+ addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
+ VdbeCoverage(v);
+ }else{
+ labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak,
+ regOldRowid);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
+ VdbeCoverage(v);
}
- sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
- VdbeCoverageIf(v, pPk==0);
- VdbeCoverageIf(v, pPk!=0);
- }else if( pPk ){
- labelContinue = sqlite3VdbeMakeLabel(v);
- sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
- addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
- sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
- VdbeCoverage(v);
- }else{
- labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,
- regOldRowid);
- VdbeCoverage(v);
- sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
- VdbeCoverage(v);
}
- /* If the record number will change, set register regNewRowid to
- ** contain the new value. If the record number is not being modified,
+ /* If the rowid value will change, set register regNewRowid to
+ ** contain the new value. If the rowid is not being modified,
** then regNewRowid is the same register as regOldRowid, which is
** already populated. */
assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );
@@ -128294,6 +129610,12 @@ SQLITE_PRIVATE void sqlite3Update(
testcase( i==31 );
testcase( i==32 );
sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i);
+ if( tmask & TRIGGER_BEFORE ){
+ /* This value will be recomputed in After-BEFORE-trigger-reload-loop
+ ** below, so make sure that it is not cached and reused.
+ ** Ticket d85fffd6ffe856092ed8daefa811b1e399706b28. */
+ sqlite3ExprCacheRemove(pParse, regNew+i, 1);
+ }
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
}
@@ -128322,10 +129644,14 @@ SQLITE_PRIVATE void sqlite3Update(
VdbeCoverage(v);
}
- /* If it did not delete it, the row-trigger may still have modified
+ /* After-BEFORE-trigger-reload-loop:
+ ** If it did not delete it, the BEFORE trigger may still have modified
** some of the columns of the row being updated. Load the values for
- ** all columns not modified by the update statement into their
- ** registers in case this has happened.
+ ** all columns not modified by the update statement into their registers
+ ** in case this has happened. Only unmodified columns are reloaded.
+ ** The values computed for modified columns use the values before the
+ ** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26)
+ ** for an example.
*/
for(i=0; i<pTab->nCol; i++){
if( aXRef[i]<0 && i!=pTab->iPKey ){
@@ -128341,7 +129667,7 @@ SQLITE_PRIVATE void sqlite3Update(
assert( regOldRowid>0 );
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
- aXRef);
+ aXRef, 0);
/* Do FK constraint checks. */
if( hasFK ){
@@ -128411,7 +129737,7 @@ SQLITE_PRIVATE void sqlite3Update(
/* Increment the row counter
*/
- if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
+ if( regRowCount ){
sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
}
@@ -128438,16 +129764,15 @@ SQLITE_PRIVATE void sqlite3Update(
** maximum rowid counter values recorded while inserting into
** autoincrement tables.
*/
- if( pParse->nested==0 && pParse->pTriggerTab==0 ){
+ if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){
sqlite3AutoincrementEnd(pParse);
}
/*
- ** Return the number of rows that were changed. If this routine is
- ** generating code because of a call to sqlite3NestedParse(), do not
- ** invoke the callback function.
+ ** Return the number of rows that were changed, if we are tracking
+ ** that information.
*/
- if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){
+ if( regRowCount ){
sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
@@ -128519,7 +129844,7 @@ static void updateVirtualTable(
int regRowid; /* Register for ephem table rowid */
int iCsr = pSrc->a[0].iCursor; /* Cursor used for virtual table scan */
int aDummy[2]; /* Unused arg for sqlite3WhereOkOnePass() */
- int bOnePass; /* True to use onepass strategy */
+ int eOnePass; /* True to use onepass strategy */
int addr; /* Address of OP_OpenEphemeral */
/* Allocate nArg registers in which to gather the arguments for VUpdate. Then
@@ -128564,19 +129889,20 @@ static void updateVirtualTable(
sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);
}
- bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);
+ eOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);
+
+ /* There is no ONEPASS_MULTI on virtual tables */
+ assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );
- if( bOnePass ){
+ if( eOnePass ){
/* If using the onepass strategy, no-op out the OP_OpenEphemeral coded
- ** above. Also, if this is a top-level parse (not a trigger), clear the
- ** multi-write flag so that the VM does not open a statement journal */
+ ** above. */
sqlite3VdbeChangeToNoop(v, addr);
- if( sqlite3IsToplevel(pParse) ){
- pParse->isMultiWrite = 0;
- }
+ sqlite3VdbeAddOp1(v, OP_Close, iCsr);
}else{
/* Create a record from the argument register contents and insert it into
** the ephemeral table. */
+ sqlite3MultiWrite(pParse);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);
#ifdef SQLITE_DEBUG
/* Signal an assert() within OP_MakeRecord that it is allowed to
@@ -128588,7 +129914,7 @@ static void updateVirtualTable(
}
- if( bOnePass==0 ){
+ if( eOnePass==ONEPASS_OFF ){
/* End the virtual table scan */
sqlite3WhereEnd(pWInfo);
@@ -128608,7 +129934,7 @@ static void updateVirtualTable(
/* End of the ephemeral table scan. Or, if using the onepass strategy,
** jump to here if the scan visited zero rows. */
- if( bOnePass==0 ){
+ if( eOnePass==ONEPASS_OFF ){
sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);
sqlite3VdbeJumpHere(v, addr);
sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);
@@ -128619,6 +129945,259 @@ static void updateVirtualTable(
#endif /* SQLITE_OMIT_VIRTUALTABLE */
/************** End of update.c **********************************************/
+/************** Begin file upsert.c ******************************************/
+/*
+** 2018-04-12
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This file contains code to implement various aspects of UPSERT
+** processing and handling of the Upsert object.
+*/
+/* #include "sqliteInt.h" */
+
+#ifndef SQLITE_OMIT_UPSERT
+/*
+** Free a list of Upsert objects
+*/
+SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){
+ if( p ){
+ sqlite3ExprListDelete(db, p->pUpsertTarget);
+ sqlite3ExprDelete(db, p->pUpsertTargetWhere);
+ sqlite3ExprListDelete(db, p->pUpsertSet);
+ sqlite3ExprDelete(db, p->pUpsertWhere);
+ sqlite3DbFree(db, p);
+ }
+}
+
+/*
+** Duplicate an Upsert object.
+*/
+SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){
+ if( p==0 ) return 0;
+ return sqlite3UpsertNew(db,
+ sqlite3ExprListDup(db, p->pUpsertTarget, 0),
+ sqlite3ExprDup(db, p->pUpsertTargetWhere, 0),
+ sqlite3ExprListDup(db, p->pUpsertSet, 0),
+ sqlite3ExprDup(db, p->pUpsertWhere, 0)
+ );
+}
+
+/*
+** Create a new Upsert object.
+*/
+SQLITE_PRIVATE Upsert *sqlite3UpsertNew(
+ sqlite3 *db, /* Determines which memory allocator to use */
+ ExprList *pTarget, /* Target argument to ON CONFLICT, or NULL */
+ Expr *pTargetWhere, /* Optional WHERE clause on the target */
+ ExprList *pSet, /* UPDATE columns, or NULL for a DO NOTHING */
+ Expr *pWhere /* WHERE clause for the ON CONFLICT UPDATE */
+){
+ Upsert *pNew;
+ pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));
+ if( pNew==0 ){
+ sqlite3ExprListDelete(db, pTarget);
+ sqlite3ExprDelete(db, pTargetWhere);
+ sqlite3ExprListDelete(db, pSet);
+ sqlite3ExprDelete(db, pWhere);
+ return 0;
+ }else{
+ pNew->pUpsertTarget = pTarget;
+ pNew->pUpsertTargetWhere = pTargetWhere;
+ pNew->pUpsertSet = pSet;
+ pNew->pUpsertWhere = pWhere;
+ pNew->pUpsertIdx = 0;
+ }
+ return pNew;
+}
+
+/*
+** Analyze the ON CONFLICT clause described by pUpsert. Resolve all
+** symbols in the conflict-target.
+**
+** Return SQLITE_OK if everything works, or an error code is something
+** is wrong.
+*/
+SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(
+ Parse *pParse, /* The parsing context */
+ SrcList *pTabList, /* Table into which we are inserting */
+ Upsert *pUpsert /* The ON CONFLICT clauses */
+){
+ Table *pTab; /* That table into which we are inserting */
+ int rc; /* Result code */
+ int iCursor; /* Cursor used by pTab */
+ Index *pIdx; /* One of the indexes of pTab */
+ ExprList *pTarget; /* The conflict-target clause */
+ Expr *pTerm; /* One term of the conflict-target clause */
+ NameContext sNC; /* Context for resolving symbolic names */
+ Expr sCol[2]; /* Index column converted into an Expr */
+
+ assert( pTabList->nSrc==1 );
+ assert( pTabList->a[0].pTab!=0 );
+ assert( pUpsert!=0 );
+ assert( pUpsert->pUpsertTarget!=0 );
+
+ /* Resolve all symbolic names in the conflict-target clause, which
+ ** includes both the list of columns and the optional partial-index
+ ** WHERE clause.
+ */
+ memset(&sNC, 0, sizeof(sNC));
+ sNC.pParse = pParse;
+ sNC.pSrcList = pTabList;
+ rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
+ if( rc ) return rc;
+ rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
+ if( rc ) return rc;
+
+ /* Check to see if the conflict target matches the rowid. */
+ pTab = pTabList->a[0].pTab;
+ pTarget = pUpsert->pUpsertTarget;
+ iCursor = pTabList->a[0].iCursor;
+ if( HasRowid(pTab)
+ && pTarget->nExpr==1
+ && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN
+ && pTerm->iColumn==XN_ROWID
+ ){
+ /* The conflict-target is the rowid of the primary table */
+ assert( pUpsert->pUpsertIdx==0 );
+ return SQLITE_OK;
+ }
+
+ /* Initialize sCol[0..1] to be an expression parse tree for a
+ ** single column of an index. The sCol[0] node will be the TK_COLLATE
+ ** operator and sCol[1] will be the TK_COLUMN operator. Code below
+ ** will populate the specific collation and column number values
+ ** prior to comparing against the conflict-target expression.
+ */
+ memset(sCol, 0, sizeof(sCol));
+ sCol[0].op = TK_COLLATE;
+ sCol[0].pLeft = &sCol[1];
+ sCol[1].op = TK_COLUMN;
+ sCol[1].iTable = pTabList->a[0].iCursor;
+
+ /* Check for matches against other indexes */
+ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
+ int ii, jj, nn;
+ if( !IsUniqueIndex(pIdx) ) continue;
+ if( pTarget->nExpr!=pIdx->nKeyCol ) continue;
+ if( pIdx->pPartIdxWhere ){
+ if( pUpsert->pUpsertTargetWhere==0 ) continue;
+ if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere,
+ pIdx->pPartIdxWhere, iCursor)!=0 ){
+ continue;
+ }
+ }
+ nn = pIdx->nKeyCol;
+ for(ii=0; ii<nn; ii++){
+ Expr *pExpr;
+ sCol[0].u.zToken = (char*)pIdx->azColl[ii];
+ if( pIdx->aiColumn[ii]==XN_EXPR ){
+ assert( pIdx->aColExpr!=0 );
+ assert( pIdx->aColExpr->nExpr>ii );
+ pExpr = pIdx->aColExpr->a[ii].pExpr;
+ if( pExpr->op!=TK_COLLATE ){
+ sCol[0].pLeft = pExpr;
+ pExpr = &sCol[0];
+ }
+ }else{
+ sCol[0].pLeft = &sCol[1];
+ sCol[1].iColumn = pIdx->aiColumn[ii];
+ pExpr = &sCol[0];
+ }
+ for(jj=0; jj<nn; jj++){
+ if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){
+ break; /* Column ii of the index matches column jj of target */
+ }
+ }
+ if( jj>=nn ){
+ /* The target contains no match for column jj of the index */
+ break;
+ }
+ }
+ if( ii<nn ){
+ /* Column ii of the index did not match any term of the conflict target.
+ ** Continue the search with the next index. */
+ continue;
+ }
+ pUpsert->pUpsertIdx = pIdx;
+ return SQLITE_OK;
+ }
+ sqlite3ErrorMsg(pParse, "ON CONFLICT clause does not match any "
+ "PRIMARY KEY or UNIQUE constraint");
+ return SQLITE_ERROR;
+}
+
+/*
+** Generate bytecode that does an UPDATE as part of an upsert.
+**
+** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.
+** In this case parameter iCur is a cursor open on the table b-tree that
+** currently points to the conflicting table row. Otherwise, if pIdx
+** is not NULL, then pIdx is the constraint that failed and iCur is a
+** cursor points to the conflicting row.
+*/
+SQLITE_PRIVATE void sqlite3UpsertDoUpdate(
+ Parse *pParse, /* The parsing and code-generating context */
+ Upsert *pUpsert, /* The ON CONFLICT clause for the upsert */
+ Table *pTab, /* The table being updated */
+ Index *pIdx, /* The UNIQUE constraint that failed */
+ int iCur /* Cursor for pIdx (or pTab if pIdx==NULL) */
+){
+ Vdbe *v = pParse->pVdbe;
+ sqlite3 *db = pParse->db;
+ SrcList *pSrc; /* FROM clause for the UPDATE */
+ int iDataCur = pUpsert->iDataCur;
+
+ assert( v!=0 );
+ VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
+ if( pIdx && iCur!=iDataCur ){
+ if( HasRowid(pTab) ){
+ int regRowid = sqlite3GetTempReg(pParse);
+ sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid);
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid);
+ VdbeCoverage(v);
+ sqlite3ReleaseTempReg(pParse, regRowid);
+ }else{
+ Index *pPk = sqlite3PrimaryKeyIndex(pTab);
+ int nPk = pPk->nKeyCol;
+ int iPk = pParse->nMem+1;
+ int i;
+ pParse->nMem += nPk;
+ for(i=0; i<nPk; i++){
+ int k;
+ assert( pPk->aiColumn[i]>=0 );
+ k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
+ sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
+ VdbeComment((v, "%s.%s", pIdx->zName,
+ pTab->aCol[pPk->aiColumn[i]].zName));
+ }
+ sqlite3VdbeVerifyAbortable(v, OE_Abort);
+ i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0,
+ "corrupt database", P4_STATIC);
+ sqlite3VdbeJumpHere(v, i);
+ }
+ }
+ /* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So
+ ** we have to make a copy before passing it down into sqlite3Update() */
+ pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
+ sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
+ pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
+ pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */
+ pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */
+ VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
+}
+
+#endif /* SQLITE_OMIT_UPSERT */
+
+/************** End of upsert.c **********************************************/
/************** Begin file vacuum.c ******************************************/
/*
** 2003 April 6
@@ -128661,8 +130240,14 @@ static int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){
while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){
const char *zSubSql = (const char*)sqlite3_column_text(pStmt,0);
assert( sqlite3_strnicmp(zSql,"SELECT",6)==0 );
- assert( sqlite3_strnicmp(zSubSql,"SELECT",6)!=0 || CORRUPT_DB );
- if( zSubSql && zSubSql[0]!='S' ){
+ /* The secondary SQL must be one of CREATE TABLE, CREATE INDEX,
+ ** or INSERT. Historically there have been attacks that first
+ ** corrupt the sqlite_master.sql field with other kinds of statements
+ ** then run VACUUM to get those statements to execute at inappropriate
+ ** times. */
+ if( zSubSql
+ && (strncmp(zSubSql,"CRE",3)==0 || strncmp(zSubSql,"INS",3)==0)
+ ){
rc = execSql(db, pzErrMsg, zSubSql);
if( rc!=SQLITE_OK ) break;
}
@@ -128875,7 +130460,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = execSqlF(db, pzErrMsg,
"SELECT sql FROM \"%w\".sqlite_master"
- " WHERE type='index' AND length(sql)>10",
+ " WHERE type='index'",
zDbMain
);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
@@ -130045,9 +131630,6 @@ SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(
void *pArg = 0;
FuncDef *pNew;
int rc = 0;
- char *zLowerName;
- unsigned char *z;
-
/* Check to see the left operand is a column in a virtual table */
if( NEVER(pExpr==0) ) return pDef;
@@ -130062,16 +131644,22 @@ SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(
if( pMod->xFindFunction==0 ) return pDef;
/* Call the xFindFunction method on the virtual table implementation
- ** to see if the implementation wants to overload this function
+ ** to see if the implementation wants to overload this function.
+ **
+ ** Though undocumented, we have historically always invoked xFindFunction
+ ** with an all lower-case function name. Continue in this tradition to
+ ** avoid any chance of an incompatibility.
*/
- zLowerName = sqlite3DbStrDup(db, pDef->zName);
- if( zLowerName ){
- for(z=(unsigned char*)zLowerName; *z; z++){
- *z = sqlite3UpperToLower[*z];
+#ifdef SQLITE_DEBUG
+ {
+ int i;
+ for(i=0; pDef->zName[i]; i++){
+ unsigned char x = (unsigned char)pDef->zName[i];
+ assert( x==sqlite3UpperToLower[x] );
}
- rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg);
- sqlite3DbFree(db, zLowerName);
}
+#endif
+ rc = pMod->xFindFunction(pVtab, nArg, pDef->zName, &xSFunc, &pArg);
if( rc==0 ){
return pDef;
}
@@ -130731,12 +132319,10 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
Parse *pParse, /* Parse context */
SrcList *pTabList, /* Table list this loop refers to */
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
- int iLevel, /* Value for "level" column of output */
- int iFrom, /* Value for "from" column of output */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
);
#else
-# define sqlite3WhereExplainOneScan(u,v,w,x,y,z) 0
+# define sqlite3WhereExplainOneScan(u,v,w,x) 0
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
@@ -130856,23 +132442,23 @@ static void explainAppendTerm(
int i;
assert( nTerm>=1 );
- if( bAnd ) sqlite3StrAccumAppend(pStr, " AND ", 5);
+ if( bAnd ) sqlite3_str_append(pStr, " AND ", 5);
- if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
+ if( nTerm>1 ) sqlite3_str_append(pStr, "(", 1);
for(i=0; i<nTerm; i++){
- if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
- sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
+ if( i ) sqlite3_str_append(pStr, ",", 1);
+ sqlite3_str_appendall(pStr, explainIndexColumnName(pIdx, iTerm+i));
}
- if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
+ if( nTerm>1 ) sqlite3_str_append(pStr, ")", 1);
- sqlite3StrAccumAppend(pStr, zOp, 1);
+ sqlite3_str_append(pStr, zOp, 1);
- if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
+ if( nTerm>1 ) sqlite3_str_append(pStr, "(", 1);
for(i=0; i<nTerm; i++){
- if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
- sqlite3StrAccumAppend(pStr, "?", 1);
+ if( i ) sqlite3_str_append(pStr, ",", 1);
+ sqlite3_str_append(pStr, "?", 1);
}
- if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
+ if( nTerm>1 ) sqlite3_str_append(pStr, ")", 1);
}
/*
@@ -130896,11 +132482,11 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){
int i, j;
if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;
- sqlite3StrAccumAppend(pStr, " (", 2);
+ sqlite3_str_append(pStr, " (", 2);
for(i=0; i<nEq; i++){
const char *z = explainIndexColumnName(pIndex, i);
- if( i ) sqlite3StrAccumAppend(pStr, " AND ", 5);
- sqlite3XPrintf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
+ if( i ) sqlite3_str_append(pStr, " AND ", 5);
+ sqlite3_str_appendf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
}
j = i;
@@ -130911,7 +132497,7 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){
if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<");
}
- sqlite3StrAccumAppend(pStr, ")", 1);
+ sqlite3_str_append(pStr, ")", 1);
}
/*
@@ -130927,8 +132513,6 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
Parse *pParse, /* Parse context */
SrcList *pTabList, /* Table list this loop refers to */
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
- int iLevel, /* Value for "level" column of output */
- int iFrom, /* Value for "from" column of output */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
){
int ret = 0;
@@ -130939,7 +132523,6 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
Vdbe *v = pParse->pVdbe; /* VM being constructed */
sqlite3 *db = pParse->db; /* Database handle */
- int iId = pParse->iSelectId; /* Select id (left-most output column) */
int isSearch; /* True for a SEARCH. False for SCAN. */
WhereLoop *pLoop; /* The controlling WhereLoop object */
u32 flags; /* Flags that describe this loop */
@@ -130956,15 +132539,15 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
- sqlite3StrAccumAppendAll(&str, isSearch ? "SEARCH" : "SCAN");
+ sqlite3_str_appendall(&str, isSearch ? "SEARCH" : "SCAN");
if( pItem->pSelect ){
- sqlite3XPrintf(&str, " SUBQUERY %d", pItem->iSelectId);
+ sqlite3_str_appendf(&str, " SUBQUERY 0x%p", pItem->pSelect);
}else{
- sqlite3XPrintf(&str, " TABLE %s", pItem->zName);
+ sqlite3_str_appendf(&str, " TABLE %s", pItem->zName);
}
if( pItem->zAlias ){
- sqlite3XPrintf(&str, " AS %s", pItem->zAlias);
+ sqlite3_str_appendf(&str, " AS %s", pItem->zAlias);
}
if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
const char *zFmt = 0;
@@ -130987,8 +132570,8 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
zFmt = "INDEX %s";
}
if( zFmt ){
- sqlite3StrAccumAppend(&str, " USING ", 7);
- sqlite3XPrintf(&str, zFmt, pIdx->zName);
+ sqlite3_str_append(&str, " USING ", 7);
+ sqlite3_str_appendf(&str, zFmt, pIdx->zName);
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
@@ -131003,23 +132586,26 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
assert( flags&WHERE_TOP_LIMIT);
zRangeOp = "<";
}
- sqlite3XPrintf(&str, " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
+ sqlite3_str_appendf(&str,
+ " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
- sqlite3XPrintf(&str, " VIRTUAL TABLE INDEX %d:%s",
+ sqlite3_str_appendf(&str, " VIRTUAL TABLE INDEX %d:%s",
pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);
}
#endif
#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
if( pLoop->nOut>=10 ){
- sqlite3XPrintf(&str, " (~%llu rows)", sqlite3LogEstToInt(pLoop->nOut));
+ sqlite3_str_appendf(&str, " (~%llu rows)",
+ sqlite3LogEstToInt(pLoop->nOut));
}else{
- sqlite3StrAccumAppend(&str, " (~1 row)", 9);
+ sqlite3_str_append(&str, " (~1 row)", 9);
}
#endif
zMsg = sqlite3StrAccumFinish(&str);
- ret = sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,P4_DYNAMIC);
+ ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
+ pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
}
return ret;
}
@@ -132020,6 +133606,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** initialize a memory cell that records if this table matches any
** row of the left table of the join.
*/
+ assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
+ || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
+ );
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
pLevel->iLeftJoin = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
@@ -132553,9 +134142,16 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
/* If pIdx is an index on one or more expressions, then look through
** all the expressions in pWInfo and try to transform matching expressions
** into reference to index columns.
+ **
+ ** Do not do this for the RHS of a LEFT JOIN. This is because the
+ ** expression may be evaluated after OP_NullRow has been executed on
+ ** the cursor. In this case it is important to do the full evaluation,
+ ** as the result of the expression may not be NULL, even if all table
+ ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
*/
- whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
-
+ if( pLevel->iLeftJoin==0 ){
+ whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
+ }
/* Record the instruction used to terminate the loop. */
if( pLoop->wsFlags & WHERE_ONEROW ){
@@ -132711,7 +134307,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
Expr *pExpr = pWC->a[iTerm].pExpr;
if( &pWC->a[iTerm] == pTerm ) continue;
- if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
@@ -132730,13 +134325,17 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
*/
wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
+ ExplainQueryPlan((pParse, 1, "MULTI-INDEX OR"));
for(ii=0; ii<pOrWc->nTerm; ii++){
WhereTerm *pOrTerm = &pOrWc->a[ii];
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
int jmp1 = 0; /* Address of jump operation */
- if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
+ assert( (pTabItem[0].fg.jointype & JT_LEFT)==0
+ || ExprHasProperty(pOrExpr, EP_FromJoin)
+ );
+ if( pAndExpr ){
pAndExpr->pLeft = pOrExpr;
pOrExpr = pAndExpr;
}
@@ -132748,7 +134347,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
if( pSubWInfo ){
WhereLoop *pSubLoop;
int addrExplain = sqlite3WhereExplainOneScan(
- pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
+ pParse, pOrTab, &pSubWInfo->a[0], 0
);
sqlite3WhereAddScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);
@@ -132847,6 +134446,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
}
}
}
+ ExplainQueryPlanPop(pParse);
pLevel->u.pCovidx = pCov;
if( pCov ) pLevel->iIdxCur = iCovCur;
if( pAndExpr ){
@@ -132919,7 +134519,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
}
pE = pTerm->pExpr;
assert( pE!=0 );
- if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
+ if( (pTabItem->fg.jointype&JT_LEFT) && !ExprHasProperty(pE,EP_FromJoin) ){
continue;
}
@@ -133846,7 +135446,6 @@ static void exprAnalyzeOrTerm(
}else{
sqlite3ExprListDelete(db, pList);
}
- pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */
}
}
}
@@ -136983,15 +138582,12 @@ static int whereLoopAddBtreeIndex(
** to mix with a lower range bound from some other source */
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
- /* Do not allow IS constraints from the WHERE clause to be used by the
+ /* Do not allow constraints from the WHERE clause to be used by the
** right table of a LEFT JOIN. Only constraints in the ON clause are
** allowed */
if( (pSrc->fg.jointype & JT_LEFT)!=0
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- && (eOp & (WO_IS|WO_ISNULL))!=0
){
- testcase( eOp & WO_IS );
- testcase( eOp & WO_ISNULL );
continue;
}
@@ -137428,14 +139024,16 @@ static int whereLoopAddBtree(
/* TUNING: One-time cost for computing the automatic index is
** estimated to be X*N*log2(N) where N is the number of rows in
** the table being indexed and where X is 7 (LogEst=28) for normal
- ** tables or 1.375 (LogEst=4) for views and subqueries. The value
+ ** tables or 0.5 (LogEst=-10) for views and subqueries. The value
** of X is smaller for views and subqueries so that the query planner
** will be more aggressive about generating automatic indexes for
** those objects, since there is no opportunity to add schema
** indexes on subqueries and views. */
- pNew->rSetup = rLogSize + rSize + 4;
+ pNew->rSetup = rLogSize + rSize;
if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
- pNew->rSetup += 24;
+ pNew->rSetup += 28;
+ }else{
+ pNew->rSetup -= 10;
}
ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
if( pNew->rSetup<0 ) pNew->rSetup = 0;
@@ -138571,12 +140169,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;
- if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<10 ){
+ if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<3 ){
/* Do not use an automatic index if the this loop is expected
- ** to run less than 2 times. */
+ ** to run less than 1.25 times. It is tempting to also exclude
+ ** automatic index usage on an outer loop, but sometimes an automatic
+ ** index is useful in the outer loop of a correlated subquery. */
assert( 10==sqlite3LogEst(2) );
continue;
}
+
/* At this point, pWLoop is a candidate to be the next loop.
** Compute its cost */
rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);
@@ -139158,6 +140759,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( wctrlFlags & WHERE_WANT_DISTINCT ){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
+ ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
}else{
/* Assign a bit from the bitmask to every term in the FROM clause.
**
@@ -139553,7 +141155,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
}
#endif
addrExplain = sqlite3WhereExplainOneScan(
- pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
+ pParse, pTabList, pLevel, wctrlFlags
);
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
@@ -139985,8 +141587,10 @@ static void disableLookaside(Parse *pParse){
** zero the stack is dynamically sized using realloc()
** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument
** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument
+** sqlite3ParserARG_PARAM Code to pass %extra_argument as a subroutine parameter
** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser
** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser
+** sqlite3ParserCTX_* As sqlite3ParserARG_ except for %extra_context
** YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing.
** YYNSTATE the combined number of states.
@@ -140006,44 +141610,51 @@ static void disableLookaside(Parse *pParse){
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
-#define YYNOCODE 253
+#define YYNOCODE 255
#define YYACTIONTYPE unsigned short int
-#define YYWILDCARD 83
+#define YYWILDCARD 84
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
- int yy4;
- struct TrigEvent yy90;
- TriggerStep* yy203;
- struct {int value; int mask;} yy215;
- SrcList* yy259;
- Expr* yy314;
- ExprList* yy322;
- const char* yy336;
- IdList* yy384;
- Select* yy387;
- With* yy451;
+ const char* yy36;
+ TriggerStep* yy47;
+ With* yy91;
+ struct {int value; int mask;} yy107;
+ Expr* yy182;
+ Upsert* yy198;
+ ExprList* yy232;
+ struct TrigEvent yy300;
+ Select* yy399;
+ SrcList* yy427;
+ int yy502;
+ IdList* yy510;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
-#define sqlite3ParserARG_SDECL Parse *pParse;
-#define sqlite3ParserARG_PDECL ,Parse *pParse
-#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
-#define sqlite3ParserARG_STORE yypParser->pParse = pParse
+#define sqlite3ParserARG_SDECL
+#define sqlite3ParserARG_PDECL
+#define sqlite3ParserARG_PARAM
+#define sqlite3ParserARG_FETCH
+#define sqlite3ParserARG_STORE
+#define sqlite3ParserCTX_SDECL Parse *pParse;
+#define sqlite3ParserCTX_PDECL ,Parse *pParse
+#define sqlite3ParserCTX_PARAM ,pParse
+#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
+#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
-#define YYNSTATE 472
-#define YYNRULE 333
-#define YYNTOKEN 143
-#define YY_MAX_SHIFT 471
-#define YY_MIN_SHIFTREDUCE 681
-#define YY_MAX_SHIFTREDUCE 1013
-#define YY_ERROR_ACTION 1014
-#define YY_ACCEPT_ACTION 1015
-#define YY_NO_ACTION 1016
-#define YY_MIN_REDUCE 1017
-#define YY_MAX_REDUCE 1349
+#define YYNSTATE 490
+#define YYNRULE 341
+#define YYNTOKEN 145
+#define YY_MAX_SHIFT 489
+#define YY_MIN_SHIFTREDUCE 705
+#define YY_MAX_SHIFTREDUCE 1045
+#define YY_ERROR_ACTION 1046
+#define YY_ACCEPT_ACTION 1047
+#define YY_NO_ACTION 1048
+#define YY_MIN_REDUCE 1049
+#define YY_MAX_REDUCE 1389
/************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined
@@ -140109,481 +141720,503 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (1566)
+#define YY_ACTTAB_COUNT (1657)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 1169, 1015, 167, 167, 1, 168, 466, 1313, 466, 1083,
- /* 10 */ 1062, 466, 97, 94, 183, 1057, 466, 329, 1083, 342,
- /* 20 */ 97, 94, 183, 459, 459, 459, 436, 57, 57, 57,
- /* 30 */ 57, 807, 57, 57, 367, 367, 367, 57, 57, 808,
- /* 40 */ 1270, 1088, 1088, 104, 105, 95, 991, 991, 868, 871,
- /* 50 */ 860, 860, 102, 102, 103, 103, 103, 103, 233, 233,
- /* 60 */ 326, 1011, 449, 437, 449, 446, 351, 449, 461, 1142,
- /* 70 */ 463, 342, 449, 426, 1316, 209, 180, 742, 80, 299,
- /* 80 */ 857, 857, 869, 872, 101, 101, 101, 101, 100, 100,
- /* 90 */ 99, 99, 99, 98, 368, 104, 105, 95, 991, 991,
- /* 100 */ 868, 871, 860, 860, 102, 102, 103, 103, 103, 103,
- /* 110 */ 99, 99, 99, 98, 368, 355, 97, 94, 183, 228,
- /* 120 */ 106, 1012, 407, 342, 101, 101, 101, 101, 100, 100,
- /* 130 */ 99, 99, 99, 98, 368, 861, 101, 101, 101, 101,
- /* 140 */ 100, 100, 99, 99, 99, 98, 368, 104, 105, 95,
- /* 150 */ 991, 991, 868, 871, 860, 860, 102, 102, 103, 103,
- /* 160 */ 103, 103, 201, 368, 375, 420, 417, 416, 387, 273,
- /* 170 */ 65, 97, 94, 183, 168, 342, 415, 951, 1343, 396,
- /* 180 */ 66, 1343, 320, 959, 371, 970, 334, 340, 101, 101,
- /* 190 */ 101, 101, 100, 100, 99, 99, 99, 98, 368, 104,
- /* 200 */ 105, 95, 991, 991, 868, 871, 860, 860, 102, 102,
- /* 210 */ 103, 103, 103, 103, 373, 100, 100, 99, 99, 99,
- /* 220 */ 98, 368, 970, 971, 972, 201, 1100, 342, 420, 417,
- /* 230 */ 416, 287, 366, 365, 337, 970, 1162, 463, 949, 415,
- /* 240 */ 101, 101, 101, 101, 100, 100, 99, 99, 99, 98,
- /* 250 */ 368, 104, 105, 95, 991, 991, 868, 871, 860, 860,
- /* 260 */ 102, 102, 103, 103, 103, 103, 777, 241, 233, 233,
- /* 270 */ 9, 847, 970, 971, 972, 390, 998, 1141, 998, 342,
- /* 280 */ 463, 252, 829, 719, 98, 368, 840, 298, 338, 142,
- /* 290 */ 839, 339, 101, 101, 101, 101, 100, 100, 99, 99,
- /* 300 */ 99, 98, 368, 104, 105, 95, 991, 991, 868, 871,
- /* 310 */ 860, 860, 102, 102, 103, 103, 103, 103, 272, 466,
- /* 320 */ 392, 839, 839, 841, 97, 94, 183, 390, 1317, 253,
- /* 330 */ 456, 342, 125, 166, 807, 712, 208, 407, 386, 970,
- /* 340 */ 57, 57, 808, 238, 101, 101, 101, 101, 100, 100,
- /* 350 */ 99, 99, 99, 98, 368, 104, 105, 95, 991, 991,
- /* 360 */ 868, 871, 860, 860, 102, 102, 103, 103, 103, 103,
- /* 370 */ 466, 108, 466, 267, 465, 442, 970, 971, 972, 261,
- /* 380 */ 951, 1344, 909, 342, 1344, 142, 829, 848, 1292, 959,
- /* 390 */ 371, 55, 55, 57, 57, 242, 101, 101, 101, 101,
- /* 400 */ 100, 100, 99, 99, 99, 98, 368, 104, 105, 95,
- /* 410 */ 991, 991, 868, 871, 860, 860, 102, 102, 103, 103,
- /* 420 */ 103, 103, 272, 382, 262, 253, 456, 310, 364, 253,
- /* 430 */ 456, 86, 264, 84, 266, 342, 441, 176, 175, 834,
- /* 440 */ 464, 949, 767, 767, 332, 313, 1094, 396, 101, 101,
- /* 450 */ 101, 101, 100, 100, 99, 99, 99, 98, 368, 104,
- /* 460 */ 105, 95, 991, 991, 868, 871, 860, 860, 102, 102,
- /* 470 */ 103, 103, 103, 103, 227, 227, 233, 233, 233, 233,
- /* 480 */ 387, 273, 234, 234, 326, 950, 463, 342, 463, 298,
- /* 490 */ 463, 914, 914, 404, 463, 1037, 123, 265, 27, 970,
- /* 500 */ 101, 101, 101, 101, 100, 100, 99, 99, 99, 98,
- /* 510 */ 368, 104, 105, 95, 991, 991, 868, 871, 860, 860,
- /* 520 */ 102, 102, 103, 103, 103, 103, 435, 233, 233, 466,
- /* 530 */ 285, 686, 687, 688, 127, 271, 970, 971, 972, 463,
- /* 540 */ 1345, 327, 342, 407, 157, 1012, 988, 13, 13, 181,
- /* 550 */ 41, 41, 101, 101, 101, 101, 100, 100, 99, 99,
- /* 560 */ 99, 98, 368, 715, 794, 378, 104, 105, 95, 991,
- /* 570 */ 991, 868, 871, 860, 860, 102, 102, 103, 103, 103,
- /* 580 */ 103, 970, 378, 377, 346, 239, 847, 1086, 1086, 280,
- /* 590 */ 1169, 283, 204, 203, 202, 177, 298, 342, 407, 298,
- /* 600 */ 715, 840, 169, 299, 407, 839, 82, 101, 101, 101,
- /* 610 */ 101, 100, 100, 99, 99, 99, 98, 368, 970, 971,
- /* 620 */ 972, 104, 105, 95, 991, 991, 868, 871, 860, 860,
- /* 630 */ 102, 102, 103, 103, 103, 103, 839, 839, 841, 362,
- /* 640 */ 240, 124, 1169, 172, 126, 378, 1269, 1169, 1066, 342,
- /* 650 */ 253, 456, 407, 407, 407, 396, 352, 401, 407, 429,
- /* 660 */ 398, 85, 101, 101, 101, 101, 100, 100, 99, 99,
- /* 670 */ 99, 98, 368, 104, 105, 95, 991, 991, 868, 871,
- /* 680 */ 860, 860, 102, 102, 103, 103, 103, 103, 1169, 466,
- /* 690 */ 230, 233, 233, 792, 1235, 1095, 1091, 1293, 1, 77,
- /* 700 */ 278, 342, 205, 463, 974, 911, 1040, 348, 353, 911,
- /* 710 */ 42, 42, 79, 403, 101, 101, 101, 101, 100, 100,
- /* 720 */ 99, 99, 99, 98, 368, 104, 93, 95, 991, 991,
- /* 730 */ 868, 871, 860, 860, 102, 102, 103, 103, 103, 103,
- /* 740 */ 402, 9, 974, 243, 772, 458, 348, 232, 180, 771,
- /* 750 */ 946, 312, 342, 328, 363, 349, 143, 831, 389, 1278,
- /* 760 */ 211, 211, 21, 347, 432, 182, 101, 101, 101, 101,
- /* 770 */ 100, 100, 99, 99, 99, 98, 368, 105, 95, 991,
- /* 780 */ 991, 868, 871, 860, 860, 102, 102, 103, 103, 103,
- /* 790 */ 103, 792, 724, 22, 732, 731, 233, 233, 1239, 256,
- /* 800 */ 391, 274, 342, 211, 79, 360, 257, 413, 463, 397,
- /* 810 */ 207, 288, 260, 450, 79, 1239, 1241, 101, 101, 101,
- /* 820 */ 101, 100, 100, 99, 99, 99, 98, 368, 95, 991,
- /* 830 */ 991, 868, 871, 860, 860, 102, 102, 103, 103, 103,
- /* 840 */ 103, 91, 457, 296, 3, 233, 233, 5, 438, 212,
- /* 850 */ 331, 394, 739, 740, 295, 898, 894, 463, 460, 207,
- /* 860 */ 801, 1237, 722, 211, 698, 843, 1283, 101, 101, 101,
- /* 870 */ 101, 100, 100, 99, 99, 99, 98, 368, 1239, 380,
- /* 880 */ 357, 369, 233, 233, 989, 219, 236, 297, 423, 292,
- /* 890 */ 422, 206, 454, 898, 463, 970, 91, 457, 290, 3,
- /* 900 */ 722, 142, 268, 843, 847, 466, 1258, 149, 388, 425,
- /* 910 */ 88, 89, 769, 460, 930, 87, 447, 90, 369, 468,
- /* 920 */ 467, 385, 989, 839, 1257, 439, 57, 57, 395, 931,
- /* 930 */ 1065, 158, 970, 971, 972, 772, 369, 471, 1019, 399,
- /* 940 */ 771, 253, 456, 254, 932, 119, 891, 454, 233, 233,
- /* 950 */ 4, 970, 1096, 275, 839, 839, 841, 842, 19, 847,
- /* 960 */ 463, 449, 448, 163, 453, 88, 89, 776, 970, 1127,
- /* 970 */ 279, 930, 90, 369, 468, 467, 91, 457, 839, 3,
- /* 980 */ 235, 1064, 466, 1228, 233, 233, 931, 970, 970, 971,
- /* 990 */ 972, 970, 908, 460, 908, 2, 463, 81, 457, 212,
- /* 1000 */ 3, 932, 282, 10, 10, 970, 971, 972, 189, 839,
- /* 1010 */ 839, 841, 842, 19, 460, 284, 369, 354, 907, 286,
- /* 1020 */ 907, 753, 466, 1079, 970, 971, 972, 454, 970, 971,
- /* 1030 */ 972, 754, 970, 1063, 989, 372, 792, 369, 1118, 847,
- /* 1040 */ 291, 452, 466, 10, 10, 88, 89, 142, 454, 168,
- /* 1050 */ 300, 412, 90, 369, 468, 467, 793, 356, 839, 706,
- /* 1060 */ 847, 341, 121, 10, 10, 301, 88, 89, 379, 970,
- /* 1070 */ 971, 972, 989, 90, 369, 468, 467, 244, 205, 839,
- /* 1080 */ 1306, 245, 1135, 245, 250, 1168, 1114, 253, 456, 839,
- /* 1090 */ 839, 841, 842, 19, 1125, 237, 122, 451, 1174, 733,
- /* 1100 */ 324, 324, 323, 222, 321, 466, 1046, 695, 182, 225,
- /* 1110 */ 839, 839, 841, 842, 19, 103, 103, 103, 103, 96,
- /* 1120 */ 185, 466, 259, 1039, 1028, 170, 10, 10, 1027, 421,
- /* 1130 */ 258, 1029, 1300, 708, 792, 466, 408, 734, 8, 347,
- /* 1140 */ 444, 174, 12, 12, 290, 101, 101, 101, 101, 100,
- /* 1150 */ 100, 99, 99, 99, 98, 368, 32, 32, 466, 187,
- /* 1160 */ 466, 1111, 103, 103, 103, 103, 188, 466, 325, 138,
- /* 1170 */ 186, 708, 303, 305, 307, 358, 970, 270, 393, 43,
- /* 1180 */ 43, 44, 44, 1157, 333, 178, 418, 294, 45, 45,
- /* 1190 */ 1232, 318, 101, 101, 101, 101, 100, 100, 99, 99,
- /* 1200 */ 99, 98, 368, 381, 343, 366, 365, 466, 263, 253,
- /* 1210 */ 456, 466, 1062, 970, 971, 972, 1231, 997, 309, 466,
- /* 1220 */ 455, 466, 427, 466, 995, 173, 996, 1303, 46, 46,
- /* 1230 */ 145, 376, 37, 37, 1006, 1277, 466, 214, 1275, 64,
- /* 1240 */ 47, 47, 33, 33, 34, 34, 1003, 67, 466, 998,
- /* 1250 */ 350, 998, 466, 155, 233, 233, 466, 36, 36, 24,
- /* 1260 */ 140, 77, 1154, 466, 383, 466, 463, 428, 466, 48,
- /* 1270 */ 48, 466, 147, 49, 49, 466, 150, 50, 50, 466,
- /* 1280 */ 151, 152, 466, 384, 11, 11, 51, 51, 466, 110,
- /* 1290 */ 110, 153, 52, 52, 411, 466, 38, 38, 466, 191,
- /* 1300 */ 53, 53, 466, 54, 54, 466, 400, 466, 330, 39,
- /* 1310 */ 39, 466, 1164, 466, 25, 466, 56, 56, 466, 131,
- /* 1320 */ 131, 72, 466, 132, 132, 159, 133, 133, 61, 61,
- /* 1330 */ 1226, 195, 40, 40, 111, 111, 58, 58, 406, 112,
- /* 1340 */ 112, 466, 277, 113, 113, 466, 226, 466, 1246, 466,
- /* 1350 */ 197, 466, 164, 466, 409, 466, 198, 466, 199, 466,
- /* 1360 */ 335, 281, 109, 109, 466, 1030, 130, 130, 129, 129,
- /* 1370 */ 117, 117, 116, 116, 114, 114, 115, 115, 60, 60,
- /* 1380 */ 62, 62, 466, 359, 466, 59, 59, 424, 1082, 1081,
- /* 1390 */ 1080, 724, 1073, 1054, 336, 293, 1053, 1052, 1315, 431,
- /* 1400 */ 361, 76, 248, 31, 31, 35, 35, 1072, 249, 440,
- /* 1410 */ 302, 434, 213, 1122, 6, 311, 1212, 107, 83, 251,
- /* 1420 */ 78, 1123, 445, 220, 443, 1036, 304, 23, 1121, 469,
- /* 1430 */ 965, 221, 223, 1104, 314, 224, 344, 317, 315, 316,
- /* 1440 */ 470, 306, 1025, 1120, 308, 1262, 1020, 134, 120, 246,
- /* 1450 */ 682, 370, 171, 255, 1263, 135, 184, 1261, 1260, 374,
- /* 1460 */ 118, 906, 904, 827, 1050, 146, 136, 137, 148, 1049,
- /* 1470 */ 63, 1047, 756, 190, 269, 920, 154, 156, 68, 69,
- /* 1480 */ 70, 71, 139, 923, 192, 193, 144, 919, 345, 128,
- /* 1490 */ 14, 194, 276, 211, 1000, 405, 196, 161, 912, 160,
- /* 1500 */ 26, 697, 410, 295, 200, 289, 414, 162, 419, 73,
- /* 1510 */ 15, 16, 141, 74, 28, 247, 846, 845, 735, 874,
- /* 1520 */ 954, 75, 430, 955, 29, 433, 179, 229, 231, 800,
- /* 1530 */ 165, 795, 87, 210, 889, 79, 875, 17, 873, 877,
- /* 1540 */ 929, 18, 928, 216, 215, 878, 20, 30, 462, 844,
- /* 1550 */ 707, 92, 766, 770, 7, 322, 217, 218, 319, 1308,
- /* 1560 */ 960, 1016, 1016, 1016, 1016, 1307,
+ /* 0 */ 349, 99, 96, 185, 99, 96, 185, 233, 1047, 1,
+ /* 10 */ 1, 489, 2, 1051, 484, 477, 477, 477, 260, 351,
+ /* 20 */ 121, 1310, 1120, 1120, 1178, 1115, 1094, 1128, 380, 380,
+ /* 30 */ 380, 835, 454, 410, 1115, 59, 59, 1357, 425, 836,
+ /* 40 */ 710, 711, 712, 106, 107, 97, 1023, 1023, 900, 903,
+ /* 50 */ 892, 892, 104, 104, 105, 105, 105, 105, 346, 238,
+ /* 60 */ 238, 99, 96, 185, 238, 238, 889, 889, 901, 904,
+ /* 70 */ 460, 481, 351, 99, 96, 185, 481, 347, 1177, 82,
+ /* 80 */ 388, 214, 182, 23, 194, 103, 103, 103, 103, 102,
+ /* 90 */ 102, 101, 101, 101, 100, 381, 106, 107, 97, 1023,
+ /* 100 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
+ /* 110 */ 105, 10, 385, 484, 24, 484, 1333, 489, 2, 1051,
+ /* 120 */ 335, 1043, 108, 893, 260, 351, 121, 99, 96, 185,
+ /* 130 */ 100, 381, 386, 1128, 59, 59, 59, 59, 103, 103,
+ /* 140 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
+ /* 150 */ 107, 97, 1023, 1023, 900, 903, 892, 892, 104, 104,
+ /* 160 */ 105, 105, 105, 105, 360, 238, 238, 170, 170, 467,
+ /* 170 */ 455, 467, 464, 67, 381, 329, 169, 481, 351, 343,
+ /* 180 */ 338, 400, 1044, 68, 101, 101, 101, 100, 381, 393,
+ /* 190 */ 194, 103, 103, 103, 103, 102, 102, 101, 101, 101,
+ /* 200 */ 100, 381, 106, 107, 97, 1023, 1023, 900, 903, 892,
+ /* 210 */ 892, 104, 104, 105, 105, 105, 105, 483, 385, 103,
+ /* 220 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
+ /* 230 */ 268, 351, 946, 946, 422, 296, 102, 102, 101, 101,
+ /* 240 */ 101, 100, 381, 861, 103, 103, 103, 103, 102, 102,
+ /* 250 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
+ /* 260 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
+ /* 270 */ 484, 983, 1383, 206, 1353, 1383, 438, 435, 434, 281,
+ /* 280 */ 396, 269, 1089, 941, 351, 1002, 433, 861, 743, 401,
+ /* 290 */ 282, 57, 57, 482, 145, 791, 791, 103, 103, 103,
+ /* 300 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 107,
+ /* 310 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
+ /* 320 */ 105, 105, 105, 281, 1002, 1003, 1004, 206, 879, 319,
+ /* 330 */ 438, 435, 434, 981, 259, 474, 360, 351, 1118, 1118,
+ /* 340 */ 433, 736, 379, 378, 872, 1002, 1356, 322, 871, 766,
+ /* 350 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
+ /* 360 */ 381, 106, 107, 97, 1023, 1023, 900, 903, 892, 892,
+ /* 370 */ 104, 104, 105, 105, 105, 105, 484, 801, 484, 871,
+ /* 380 */ 871, 873, 401, 282, 1002, 1003, 1004, 1030, 360, 1030,
+ /* 390 */ 351, 983, 1384, 213, 880, 1384, 145, 59, 59, 59,
+ /* 400 */ 59, 1002, 244, 103, 103, 103, 103, 102, 102, 101,
+ /* 410 */ 101, 101, 100, 381, 106, 107, 97, 1023, 1023, 900,
+ /* 420 */ 903, 892, 892, 104, 104, 105, 105, 105, 105, 274,
+ /* 430 */ 484, 110, 467, 479, 467, 444, 259, 474, 232, 232,
+ /* 440 */ 1002, 1003, 1004, 351, 210, 335, 982, 866, 1385, 336,
+ /* 450 */ 481, 59, 59, 981, 245, 307, 103, 103, 103, 103,
+ /* 460 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
+ /* 470 */ 1023, 1023, 900, 903, 892, 892, 104, 104, 105, 105,
+ /* 480 */ 105, 105, 453, 459, 484, 408, 377, 259, 474, 271,
+ /* 490 */ 183, 273, 209, 208, 207, 356, 351, 307, 178, 177,
+ /* 500 */ 127, 1006, 1098, 14, 14, 43, 43, 1044, 425, 103,
+ /* 510 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
+ /* 520 */ 106, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
+ /* 530 */ 104, 105, 105, 105, 105, 294, 1132, 408, 160, 484,
+ /* 540 */ 408, 1006, 129, 962, 1209, 239, 239, 481, 307, 425,
+ /* 550 */ 1309, 1097, 351, 235, 243, 272, 820, 481, 963, 425,
+ /* 560 */ 11, 11, 103, 103, 103, 103, 102, 102, 101, 101,
+ /* 570 */ 101, 100, 381, 964, 362, 1002, 106, 107, 97, 1023,
+ /* 580 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105,
+ /* 590 */ 105, 1275, 161, 126, 777, 289, 1209, 292, 1072, 357,
+ /* 600 */ 1209, 1127, 476, 357, 778, 425, 247, 425, 351, 248,
+ /* 610 */ 414, 364, 414, 171, 1002, 1003, 1004, 84, 103, 103,
+ /* 620 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 1002,
+ /* 630 */ 184, 484, 106, 107, 97, 1023, 1023, 900, 903, 892,
+ /* 640 */ 892, 104, 104, 105, 105, 105, 105, 1123, 1209, 287,
+ /* 650 */ 484, 1209, 11, 11, 179, 820, 259, 474, 307, 237,
+ /* 660 */ 182, 351, 321, 365, 414, 308, 367, 366, 1002, 1003,
+ /* 670 */ 1004, 44, 44, 87, 103, 103, 103, 103, 102, 102,
+ /* 680 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023,
+ /* 690 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105,
+ /* 700 */ 246, 368, 280, 128, 10, 358, 146, 796, 835, 258,
+ /* 710 */ 1020, 88, 795, 86, 351, 421, 836, 943, 376, 348,
+ /* 720 */ 191, 943, 1318, 267, 308, 279, 456, 103, 103, 103,
+ /* 730 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 95,
+ /* 740 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105,
+ /* 750 */ 105, 105, 105, 420, 249, 238, 238, 238, 238, 79,
+ /* 760 */ 375, 125, 305, 29, 262, 978, 351, 481, 337, 481,
+ /* 770 */ 756, 755, 304, 278, 415, 15, 81, 940, 1126, 940,
+ /* 780 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
+ /* 790 */ 381, 107, 97, 1023, 1023, 900, 903, 892, 892, 104,
+ /* 800 */ 104, 105, 105, 105, 105, 457, 263, 484, 174, 484,
+ /* 810 */ 238, 238, 863, 407, 402, 216, 216, 351, 409, 193,
+ /* 820 */ 283, 216, 481, 81, 763, 764, 266, 5, 13, 13,
+ /* 830 */ 34, 34, 103, 103, 103, 103, 102, 102, 101, 101,
+ /* 840 */ 101, 100, 381, 97, 1023, 1023, 900, 903, 892, 892,
+ /* 850 */ 104, 104, 105, 105, 105, 105, 93, 475, 1002, 4,
+ /* 860 */ 403, 1002, 340, 431, 1002, 297, 212, 1277, 81, 746,
+ /* 870 */ 1163, 152, 926, 478, 166, 212, 757, 829, 930, 939,
+ /* 880 */ 216, 939, 858, 103, 103, 103, 103, 102, 102, 101,
+ /* 890 */ 101, 101, 100, 381, 238, 238, 382, 1002, 1003, 1004,
+ /* 900 */ 1002, 1003, 1004, 1002, 1003, 1004, 481, 439, 472, 746,
+ /* 910 */ 105, 105, 105, 105, 98, 758, 1162, 145, 930, 412,
+ /* 920 */ 879, 406, 793, 81, 395, 89, 90, 91, 105, 105,
+ /* 930 */ 105, 105, 1323, 92, 484, 382, 486, 485, 240, 275,
+ /* 940 */ 871, 103, 103, 103, 103, 102, 102, 101, 101, 101,
+ /* 950 */ 100, 381, 1096, 371, 355, 45, 45, 259, 474, 103,
+ /* 960 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
+ /* 970 */ 1150, 871, 871, 873, 874, 21, 1332, 991, 384, 730,
+ /* 980 */ 722, 242, 123, 1298, 124, 875, 333, 333, 332, 227,
+ /* 990 */ 330, 991, 384, 719, 256, 242, 484, 391, 413, 1297,
+ /* 1000 */ 333, 333, 332, 227, 330, 748, 187, 719, 265, 470,
+ /* 1010 */ 1279, 1002, 484, 417, 391, 390, 264, 11, 11, 284,
+ /* 1020 */ 187, 732, 265, 93, 475, 875, 4, 1279, 1281, 419,
+ /* 1030 */ 264, 369, 416, 11, 11, 1159, 288, 484, 399, 1346,
+ /* 1040 */ 478, 379, 378, 291, 484, 293, 189, 250, 295, 1027,
+ /* 1050 */ 1002, 1003, 1004, 190, 1029, 1111, 140, 188, 11, 11,
+ /* 1060 */ 189, 732, 1028, 382, 923, 46, 46, 190, 1095, 230,
+ /* 1070 */ 140, 188, 462, 93, 475, 472, 4, 300, 309, 391,
+ /* 1080 */ 373, 6, 1069, 217, 739, 310, 1030, 879, 1030, 1171,
+ /* 1090 */ 478, 352, 1279, 90, 91, 800, 259, 474, 1208, 484,
+ /* 1100 */ 92, 1268, 382, 486, 485, 352, 1002, 871, 879, 426,
+ /* 1110 */ 259, 474, 172, 382, 238, 238, 1146, 170, 1021, 389,
+ /* 1120 */ 47, 47, 1157, 739, 872, 472, 481, 469, 871, 350,
+ /* 1130 */ 1214, 83, 475, 389, 4, 1078, 1071, 879, 871, 871,
+ /* 1140 */ 873, 874, 21, 90, 91, 1002, 1003, 1004, 478, 251,
+ /* 1150 */ 92, 251, 382, 486, 485, 443, 370, 871, 1021, 871,
+ /* 1160 */ 871, 873, 224, 241, 306, 441, 301, 440, 211, 1060,
+ /* 1170 */ 820, 382, 822, 447, 299, 1059, 484, 1061, 1143, 962,
+ /* 1180 */ 430, 796, 484, 472, 1340, 312, 795, 465, 871, 871,
+ /* 1190 */ 873, 874, 21, 314, 963, 879, 316, 59, 59, 1002,
+ /* 1200 */ 9, 90, 91, 48, 48, 238, 238, 210, 92, 964,
+ /* 1210 */ 382, 486, 485, 176, 334, 871, 242, 481, 1193, 238,
+ /* 1220 */ 238, 333, 333, 332, 227, 330, 394, 270, 719, 277,
+ /* 1230 */ 471, 481, 467, 466, 484, 145, 217, 1201, 1002, 1003,
+ /* 1240 */ 1004, 187, 3, 265, 184, 445, 871, 871, 873, 874,
+ /* 1250 */ 21, 264, 1337, 450, 1051, 39, 39, 392, 356, 260,
+ /* 1260 */ 342, 121, 468, 411, 436, 821, 180, 1094, 1128, 820,
+ /* 1270 */ 303, 1021, 1272, 1271, 299, 259, 474, 238, 238, 1002,
+ /* 1280 */ 473, 189, 484, 318, 327, 238, 238, 484, 190, 481,
+ /* 1290 */ 446, 140, 188, 1343, 238, 238, 1038, 481, 148, 175,
+ /* 1300 */ 238, 238, 484, 49, 49, 219, 481, 484, 35, 35,
+ /* 1310 */ 1317, 1021, 481, 484, 1035, 484, 1315, 484, 1002, 1003,
+ /* 1320 */ 1004, 484, 66, 36, 36, 194, 352, 484, 38, 38,
+ /* 1330 */ 484, 259, 474, 69, 50, 50, 51, 51, 52, 52,
+ /* 1340 */ 359, 484, 12, 12, 484, 1198, 484, 158, 53, 53,
+ /* 1350 */ 405, 112, 112, 385, 389, 484, 26, 484, 143, 484,
+ /* 1360 */ 150, 484, 54, 54, 397, 40, 40, 55, 55, 484,
+ /* 1370 */ 79, 484, 153, 1190, 484, 154, 56, 56, 41, 41,
+ /* 1380 */ 58, 58, 133, 133, 484, 398, 484, 429, 484, 155,
+ /* 1390 */ 134, 134, 135, 135, 484, 63, 63, 484, 341, 484,
+ /* 1400 */ 339, 484, 196, 484, 156, 42, 42, 113, 113, 60,
+ /* 1410 */ 60, 484, 404, 484, 27, 114, 114, 1204, 115, 115,
+ /* 1420 */ 111, 111, 132, 132, 131, 131, 1266, 418, 484, 162,
+ /* 1430 */ 484, 200, 119, 119, 118, 118, 484, 74, 424, 484,
+ /* 1440 */ 1286, 484, 231, 484, 202, 484, 167, 286, 427, 116,
+ /* 1450 */ 116, 117, 117, 290, 203, 442, 1062, 62, 62, 204,
+ /* 1460 */ 64, 64, 61, 61, 33, 33, 37, 37, 344, 372,
+ /* 1470 */ 1114, 1105, 748, 1113, 374, 1112, 254, 458, 1086, 255,
+ /* 1480 */ 345, 1085, 302, 1084, 1355, 78, 1154, 311, 1104, 449,
+ /* 1490 */ 452, 1155, 1153, 218, 7, 313, 315, 320, 1152, 85,
+ /* 1500 */ 1252, 317, 109, 80, 463, 225, 461, 1068, 25, 487,
+ /* 1510 */ 997, 323, 257, 226, 229, 228, 1136, 324, 325, 326,
+ /* 1520 */ 488, 136, 1057, 1052, 1302, 1303, 1301, 706, 1300, 137,
+ /* 1530 */ 122, 138, 383, 173, 1082, 261, 186, 252, 1081, 65,
+ /* 1540 */ 387, 120, 938, 936, 855, 353, 149, 1079, 139, 151,
+ /* 1550 */ 192, 780, 195, 276, 952, 157, 141, 361, 70, 363,
+ /* 1560 */ 859, 159, 71, 72, 142, 73, 955, 354, 147, 197,
+ /* 1570 */ 198, 951, 130, 16, 199, 285, 216, 1032, 201, 423,
+ /* 1580 */ 164, 944, 163, 28, 721, 428, 304, 165, 205, 759,
+ /* 1590 */ 75, 432, 298, 17, 18, 437, 76, 253, 878, 144,
+ /* 1600 */ 877, 906, 77, 986, 30, 448, 987, 31, 451, 181,
+ /* 1610 */ 234, 236, 168, 828, 823, 89, 910, 921, 81, 907,
+ /* 1620 */ 215, 905, 909, 961, 960, 19, 221, 20, 220, 22,
+ /* 1630 */ 32, 331, 876, 731, 94, 790, 794, 8, 992, 222,
+ /* 1640 */ 480, 328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
+ /* 1650 */ 223, 1048, 1048, 1048, 1048, 1348, 1347,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 152, 144, 145, 146, 147, 152, 152, 172, 152, 180,
- /* 10 */ 181, 152, 223, 224, 225, 180, 152, 164, 189, 19,
- /* 20 */ 223, 224, 225, 168, 169, 170, 163, 173, 174, 173,
- /* 30 */ 174, 31, 173, 174, 168, 169, 170, 173, 174, 39,
- /* 40 */ 243, 191, 192, 43, 44, 45, 46, 47, 48, 49,
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 195, 196,
- /* 60 */ 22, 23, 208, 209, 208, 209, 218, 208, 209, 176,
- /* 70 */ 207, 19, 208, 209, 23, 212, 213, 26, 26, 152,
- /* 80 */ 46, 47, 48, 49, 84, 85, 86, 87, 88, 89,
- /* 90 */ 90, 91, 92, 93, 94, 43, 44, 45, 46, 47,
- /* 100 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 110 */ 90, 91, 92, 93, 94, 188, 223, 224, 225, 171,
- /* 120 */ 68, 83, 152, 19, 84, 85, 86, 87, 88, 89,
- /* 130 */ 90, 91, 92, 93, 94, 101, 84, 85, 86, 87,
- /* 140 */ 88, 89, 90, 91, 92, 93, 94, 43, 44, 45,
- /* 150 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- /* 160 */ 56, 57, 99, 94, 194, 102, 103, 104, 109, 110,
- /* 170 */ 66, 223, 224, 225, 152, 19, 113, 22, 23, 152,
- /* 180 */ 24, 26, 160, 1, 2, 59, 164, 173, 84, 85,
- /* 190 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 43,
- /* 200 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 210 */ 54, 55, 56, 57, 244, 88, 89, 90, 91, 92,
- /* 220 */ 93, 94, 96, 97, 98, 99, 196, 19, 102, 103,
- /* 230 */ 104, 23, 88, 89, 173, 59, 163, 207, 83, 113,
- /* 240 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- /* 250 */ 94, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 260 */ 52, 53, 54, 55, 56, 57, 90, 240, 195, 196,
- /* 270 */ 171, 82, 96, 97, 98, 152, 132, 176, 134, 19,
- /* 280 */ 207, 200, 72, 23, 93, 94, 97, 152, 173, 79,
- /* 290 */ 101, 210, 84, 85, 86, 87, 88, 89, 90, 91,
- /* 300 */ 92, 93, 94, 43, 44, 45, 46, 47, 48, 49,
- /* 310 */ 50, 51, 52, 53, 54, 55, 56, 57, 108, 152,
- /* 320 */ 152, 132, 133, 134, 223, 224, 225, 152, 186, 119,
- /* 330 */ 120, 19, 197, 234, 31, 23, 26, 152, 239, 59,
- /* 340 */ 173, 174, 39, 220, 84, 85, 86, 87, 88, 89,
- /* 350 */ 90, 91, 92, 93, 94, 43, 44, 45, 46, 47,
- /* 360 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 370 */ 152, 22, 152, 16, 152, 208, 96, 97, 98, 194,
- /* 380 */ 22, 23, 11, 19, 26, 79, 72, 23, 0, 1,
- /* 390 */ 2, 173, 174, 173, 174, 220, 84, 85, 86, 87,
- /* 400 */ 88, 89, 90, 91, 92, 93, 94, 43, 44, 45,
- /* 410 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- /* 420 */ 56, 57, 108, 109, 110, 119, 120, 152, 208, 119,
- /* 430 */ 120, 137, 75, 139, 77, 19, 152, 88, 89, 23,
- /* 440 */ 115, 83, 117, 118, 163, 227, 163, 152, 84, 85,
- /* 450 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 43,
- /* 460 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 470 */ 54, 55, 56, 57, 195, 196, 195, 196, 195, 196,
- /* 480 */ 109, 110, 195, 196, 22, 23, 207, 19, 207, 152,
- /* 490 */ 207, 108, 109, 110, 207, 163, 22, 140, 24, 59,
- /* 500 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- /* 510 */ 94, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 520 */ 52, 53, 54, 55, 56, 57, 152, 195, 196, 152,
- /* 530 */ 16, 7, 8, 9, 197, 240, 96, 97, 98, 207,
- /* 540 */ 249, 250, 19, 152, 22, 83, 26, 173, 174, 152,
- /* 550 */ 173, 174, 84, 85, 86, 87, 88, 89, 90, 91,
- /* 560 */ 92, 93, 94, 59, 124, 152, 43, 44, 45, 46,
- /* 570 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- /* 580 */ 57, 59, 169, 170, 157, 194, 82, 191, 192, 75,
- /* 590 */ 152, 77, 108, 109, 110, 26, 152, 19, 152, 152,
- /* 600 */ 96, 97, 24, 152, 152, 101, 138, 84, 85, 86,
- /* 610 */ 87, 88, 89, 90, 91, 92, 93, 94, 96, 97,
- /* 620 */ 98, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 630 */ 52, 53, 54, 55, 56, 57, 132, 133, 134, 188,
- /* 640 */ 194, 197, 152, 123, 197, 232, 194, 152, 182, 19,
- /* 650 */ 119, 120, 152, 152, 152, 152, 218, 230, 152, 163,
- /* 660 */ 233, 138, 84, 85, 86, 87, 88, 89, 90, 91,
- /* 670 */ 92, 93, 94, 43, 44, 45, 46, 47, 48, 49,
- /* 680 */ 50, 51, 52, 53, 54, 55, 56, 57, 152, 152,
- /* 690 */ 23, 195, 196, 26, 194, 194, 194, 146, 147, 130,
- /* 700 */ 194, 19, 46, 207, 59, 29, 166, 167, 218, 33,
- /* 710 */ 173, 174, 26, 218, 84, 85, 86, 87, 88, 89,
- /* 720 */ 90, 91, 92, 93, 94, 43, 44, 45, 46, 47,
- /* 730 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 740 */ 64, 171, 97, 240, 116, 166, 167, 212, 213, 121,
- /* 750 */ 23, 152, 19, 26, 218, 247, 248, 23, 23, 152,
- /* 760 */ 26, 26, 22, 107, 163, 98, 84, 85, 86, 87,
- /* 770 */ 88, 89, 90, 91, 92, 93, 94, 44, 45, 46,
- /* 780 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- /* 790 */ 57, 124, 106, 53, 100, 101, 195, 196, 152, 152,
- /* 800 */ 23, 23, 19, 26, 26, 19, 152, 23, 207, 239,
- /* 810 */ 26, 23, 152, 163, 26, 169, 170, 84, 85, 86,
- /* 820 */ 87, 88, 89, 90, 91, 92, 93, 94, 45, 46,
- /* 830 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- /* 840 */ 57, 19, 20, 101, 22, 195, 196, 22, 19, 24,
- /* 850 */ 163, 19, 7, 8, 112, 59, 23, 207, 36, 26,
- /* 860 */ 23, 152, 59, 26, 21, 59, 152, 84, 85, 86,
- /* 870 */ 87, 88, 89, 90, 91, 92, 93, 94, 232, 221,
- /* 880 */ 94, 59, 195, 196, 59, 99, 100, 101, 102, 103,
- /* 890 */ 104, 105, 70, 97, 207, 59, 19, 20, 112, 22,
- /* 900 */ 97, 79, 152, 97, 82, 152, 152, 71, 221, 90,
- /* 910 */ 88, 89, 23, 36, 12, 26, 163, 95, 96, 97,
- /* 920 */ 98, 78, 97, 101, 152, 96, 173, 174, 96, 27,
- /* 930 */ 182, 22, 96, 97, 98, 116, 59, 148, 149, 152,
- /* 940 */ 121, 119, 120, 154, 42, 156, 103, 70, 195, 196,
- /* 950 */ 22, 59, 163, 152, 132, 133, 134, 135, 136, 82,
- /* 960 */ 207, 208, 209, 71, 62, 88, 89, 90, 59, 152,
- /* 970 */ 152, 12, 95, 96, 97, 98, 19, 20, 101, 22,
- /* 980 */ 22, 182, 152, 140, 195, 196, 27, 59, 96, 97,
- /* 990 */ 98, 59, 132, 36, 134, 22, 207, 19, 20, 24,
- /* 1000 */ 22, 42, 152, 173, 174, 96, 97, 98, 219, 132,
- /* 1010 */ 133, 134, 135, 136, 36, 152, 59, 187, 132, 152,
- /* 1020 */ 134, 62, 152, 152, 96, 97, 98, 70, 96, 97,
- /* 1030 */ 98, 72, 59, 152, 59, 246, 26, 59, 214, 82,
- /* 1040 */ 152, 192, 152, 173, 174, 88, 89, 79, 70, 152,
- /* 1050 */ 152, 19, 95, 96, 97, 98, 124, 187, 101, 23,
- /* 1060 */ 82, 164, 26, 173, 174, 152, 88, 89, 100, 96,
- /* 1070 */ 97, 98, 97, 95, 96, 97, 98, 187, 46, 101,
- /* 1080 */ 122, 184, 152, 186, 211, 152, 152, 119, 120, 132,
- /* 1090 */ 133, 134, 135, 136, 152, 5, 22, 152, 152, 35,
- /* 1100 */ 10, 11, 12, 13, 14, 152, 152, 17, 98, 235,
- /* 1110 */ 132, 133, 134, 135, 136, 54, 55, 56, 57, 58,
- /* 1120 */ 30, 152, 32, 152, 152, 198, 173, 174, 152, 65,
- /* 1130 */ 40, 152, 152, 59, 124, 152, 236, 73, 199, 107,
- /* 1140 */ 187, 171, 173, 174, 112, 84, 85, 86, 87, 88,
- /* 1150 */ 89, 90, 91, 92, 93, 94, 173, 174, 152, 69,
- /* 1160 */ 152, 211, 54, 55, 56, 57, 76, 152, 150, 79,
- /* 1170 */ 80, 97, 211, 211, 211, 111, 59, 241, 241, 173,
- /* 1180 */ 174, 173, 174, 202, 202, 185, 177, 176, 173, 174,
- /* 1190 */ 176, 201, 84, 85, 86, 87, 88, 89, 90, 91,
- /* 1200 */ 92, 93, 94, 215, 114, 88, 89, 152, 215, 119,
- /* 1210 */ 120, 152, 181, 96, 97, 98, 176, 100, 215, 152,
- /* 1220 */ 229, 152, 163, 152, 107, 199, 109, 155, 173, 174,
- /* 1230 */ 245, 141, 173, 174, 60, 159, 152, 122, 159, 242,
- /* 1240 */ 173, 174, 173, 174, 173, 174, 38, 242, 152, 132,
- /* 1250 */ 159, 134, 152, 22, 195, 196, 152, 173, 174, 222,
- /* 1260 */ 43, 130, 202, 152, 18, 152, 207, 208, 152, 173,
- /* 1270 */ 174, 152, 190, 173, 174, 152, 193, 173, 174, 152,
- /* 1280 */ 193, 193, 152, 159, 173, 174, 173, 174, 152, 173,
- /* 1290 */ 174, 193, 173, 174, 18, 152, 173, 174, 152, 158,
- /* 1300 */ 173, 174, 152, 173, 174, 152, 159, 152, 202, 173,
- /* 1310 */ 174, 152, 190, 152, 222, 152, 173, 174, 152, 173,
- /* 1320 */ 174, 137, 152, 173, 174, 190, 173, 174, 173, 174,
- /* 1330 */ 202, 158, 173, 174, 173, 174, 173, 174, 61, 173,
- /* 1340 */ 174, 152, 237, 173, 174, 152, 159, 152, 238, 152,
- /* 1350 */ 158, 152, 22, 152, 178, 152, 158, 152, 158, 152,
- /* 1360 */ 178, 159, 173, 174, 152, 159, 173, 174, 173, 174,
- /* 1370 */ 173, 174, 173, 174, 173, 174, 173, 174, 173, 174,
- /* 1380 */ 173, 174, 152, 63, 152, 173, 174, 107, 175, 175,
- /* 1390 */ 175, 106, 183, 175, 178, 175, 177, 175, 175, 178,
- /* 1400 */ 94, 107, 231, 173, 174, 173, 174, 183, 231, 125,
- /* 1410 */ 216, 178, 159, 217, 22, 159, 226, 129, 137, 228,
- /* 1420 */ 128, 217, 126, 25, 127, 162, 216, 26, 217, 161,
- /* 1430 */ 13, 153, 153, 206, 205, 6, 251, 202, 204, 203,
- /* 1440 */ 151, 216, 151, 217, 216, 171, 151, 165, 179, 179,
- /* 1450 */ 4, 3, 22, 142, 171, 165, 15, 171, 171, 81,
- /* 1460 */ 16, 23, 23, 120, 171, 131, 165, 111, 123, 171,
- /* 1470 */ 171, 171, 20, 125, 16, 1, 123, 131, 53, 53,
- /* 1480 */ 53, 53, 111, 96, 34, 122, 248, 1, 251, 5,
- /* 1490 */ 22, 107, 140, 26, 74, 41, 122, 107, 67, 67,
- /* 1500 */ 24, 20, 19, 112, 105, 23, 66, 22, 66, 22,
- /* 1510 */ 22, 22, 37, 22, 22, 66, 23, 23, 28, 23,
- /* 1520 */ 23, 26, 24, 23, 22, 24, 122, 23, 23, 96,
- /* 1530 */ 22, 124, 26, 34, 23, 26, 23, 34, 23, 23,
- /* 1540 */ 23, 34, 23, 22, 26, 11, 22, 22, 26, 23,
- /* 1550 */ 23, 22, 116, 23, 22, 15, 122, 122, 23, 122,
- /* 1560 */ 1, 252, 252, 252, 252, 122, 252, 252, 252, 252,
- /* 1570 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1580 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1590 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1600 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1610 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1620 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1630 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1640 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1650 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1660 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1670 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1680 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1690 */ 252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
- /* 1700 */ 252, 252, 252, 252, 252, 252, 252, 252, 252,
+ /* 0 */ 174, 226, 227, 228, 226, 227, 228, 172, 145, 146,
+ /* 10 */ 147, 148, 149, 150, 153, 169, 170, 171, 155, 19,
+ /* 20 */ 157, 246, 192, 193, 177, 181, 182, 164, 169, 170,
+ /* 30 */ 171, 31, 164, 153, 190, 174, 175, 187, 153, 39,
+ /* 40 */ 7, 8, 9, 43, 44, 45, 46, 47, 48, 49,
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 196,
+ /* 60 */ 197, 226, 227, 228, 196, 197, 46, 47, 48, 49,
+ /* 70 */ 209, 208, 19, 226, 227, 228, 208, 174, 177, 26,
+ /* 80 */ 195, 213, 214, 22, 221, 85, 86, 87, 88, 89,
+ /* 90 */ 90, 91, 92, 93, 94, 95, 43, 44, 45, 46,
+ /* 100 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 110 */ 57, 172, 249, 153, 53, 153, 147, 148, 149, 150,
+ /* 120 */ 22, 23, 69, 103, 155, 19, 157, 226, 227, 228,
+ /* 130 */ 94, 95, 247, 164, 174, 175, 174, 175, 85, 86,
+ /* 140 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 43,
+ /* 150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ /* 160 */ 54, 55, 56, 57, 153, 196, 197, 153, 153, 209,
+ /* 170 */ 210, 209, 210, 67, 95, 161, 237, 208, 19, 165,
+ /* 180 */ 165, 242, 84, 24, 91, 92, 93, 94, 95, 223,
+ /* 190 */ 221, 85, 86, 87, 88, 89, 90, 91, 92, 93,
+ /* 200 */ 94, 95, 43, 44, 45, 46, 47, 48, 49, 50,
+ /* 210 */ 51, 52, 53, 54, 55, 56, 57, 153, 249, 85,
+ /* 220 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 230 */ 219, 19, 109, 110, 111, 23, 89, 90, 91, 92,
+ /* 240 */ 93, 94, 95, 73, 85, 86, 87, 88, 89, 90,
+ /* 250 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
+ /* 260 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 270 */ 153, 22, 23, 101, 173, 26, 104, 105, 106, 109,
+ /* 280 */ 110, 111, 181, 11, 19, 59, 114, 73, 23, 110,
+ /* 290 */ 111, 174, 175, 116, 80, 118, 119, 85, 86, 87,
+ /* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
+ /* 310 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ /* 320 */ 55, 56, 57, 109, 98, 99, 100, 101, 83, 153,
+ /* 330 */ 104, 105, 106, 84, 120, 121, 153, 19, 192, 193,
+ /* 340 */ 114, 23, 89, 90, 99, 59, 23, 230, 103, 26,
+ /* 350 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
+ /* 360 */ 95, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 370 */ 52, 53, 54, 55, 56, 57, 153, 91, 153, 134,
+ /* 380 */ 135, 136, 110, 111, 98, 99, 100, 134, 153, 136,
+ /* 390 */ 19, 22, 23, 26, 23, 26, 80, 174, 175, 174,
+ /* 400 */ 175, 59, 219, 85, 86, 87, 88, 89, 90, 91,
+ /* 410 */ 92, 93, 94, 95, 43, 44, 45, 46, 47, 48,
+ /* 420 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 16,
+ /* 430 */ 153, 22, 209, 210, 209, 210, 120, 121, 196, 197,
+ /* 440 */ 98, 99, 100, 19, 46, 22, 23, 23, 252, 253,
+ /* 450 */ 208, 174, 175, 84, 219, 153, 85, 86, 87, 88,
+ /* 460 */ 89, 90, 91, 92, 93, 94, 95, 43, 44, 45,
+ /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 480 */ 56, 57, 153, 153, 153, 153, 209, 120, 121, 76,
+ /* 490 */ 153, 78, 109, 110, 111, 97, 19, 153, 89, 90,
+ /* 500 */ 198, 59, 183, 174, 175, 174, 175, 84, 153, 85,
+ /* 510 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 520 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ /* 530 */ 53, 54, 55, 56, 57, 16, 197, 153, 22, 153,
+ /* 540 */ 153, 99, 198, 12, 153, 196, 197, 208, 153, 153,
+ /* 550 */ 195, 183, 19, 23, 222, 142, 26, 208, 27, 153,
+ /* 560 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
+ /* 570 */ 93, 94, 95, 42, 188, 59, 43, 44, 45, 46,
+ /* 580 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 590 */ 57, 195, 22, 198, 63, 76, 153, 78, 167, 168,
+ /* 600 */ 153, 195, 167, 168, 73, 153, 222, 153, 19, 222,
+ /* 610 */ 153, 220, 153, 24, 98, 99, 100, 140, 85, 86,
+ /* 620 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 59,
+ /* 630 */ 100, 153, 43, 44, 45, 46, 47, 48, 49, 50,
+ /* 640 */ 51, 52, 53, 54, 55, 56, 57, 195, 153, 195,
+ /* 650 */ 153, 153, 174, 175, 26, 125, 120, 121, 153, 213,
+ /* 660 */ 214, 19, 153, 220, 153, 153, 188, 220, 98, 99,
+ /* 670 */ 100, 174, 175, 140, 85, 86, 87, 88, 89, 90,
+ /* 680 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47,
+ /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 700 */ 243, 189, 243, 198, 172, 250, 251, 117, 31, 201,
+ /* 710 */ 26, 139, 122, 141, 19, 220, 39, 29, 220, 211,
+ /* 720 */ 24, 33, 153, 164, 153, 164, 19, 85, 86, 87,
+ /* 730 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44,
+ /* 740 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ /* 750 */ 55, 56, 57, 65, 243, 196, 197, 196, 197, 131,
+ /* 760 */ 189, 22, 103, 24, 153, 23, 19, 208, 26, 208,
+ /* 770 */ 102, 103, 113, 23, 242, 22, 26, 134, 164, 136,
+ /* 780 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
+ /* 790 */ 95, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ /* 800 */ 53, 54, 55, 56, 57, 98, 153, 153, 124, 153,
+ /* 810 */ 196, 197, 23, 23, 61, 26, 26, 19, 23, 123,
+ /* 820 */ 23, 26, 208, 26, 7, 8, 153, 22, 174, 175,
+ /* 830 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92,
+ /* 840 */ 93, 94, 95, 45, 46, 47, 48, 49, 50, 51,
+ /* 850 */ 52, 53, 54, 55, 56, 57, 19, 20, 59, 22,
+ /* 860 */ 111, 59, 164, 23, 59, 23, 26, 153, 26, 59,
+ /* 870 */ 153, 72, 23, 36, 72, 26, 35, 23, 59, 134,
+ /* 880 */ 26, 136, 133, 85, 86, 87, 88, 89, 90, 91,
+ /* 890 */ 92, 93, 94, 95, 196, 197, 59, 98, 99, 100,
+ /* 900 */ 98, 99, 100, 98, 99, 100, 208, 66, 71, 99,
+ /* 910 */ 54, 55, 56, 57, 58, 74, 153, 80, 99, 19,
+ /* 920 */ 83, 223, 23, 26, 153, 26, 89, 90, 54, 55,
+ /* 930 */ 56, 57, 153, 96, 153, 98, 99, 100, 22, 153,
+ /* 940 */ 103, 85, 86, 87, 88, 89, 90, 91, 92, 93,
+ /* 950 */ 94, 95, 183, 112, 158, 174, 175, 120, 121, 85,
+ /* 960 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 970 */ 215, 134, 135, 136, 137, 138, 0, 1, 2, 23,
+ /* 980 */ 21, 5, 26, 153, 22, 59, 10, 11, 12, 13,
+ /* 990 */ 14, 1, 2, 17, 212, 5, 153, 153, 98, 153,
+ /* 1000 */ 10, 11, 12, 13, 14, 108, 30, 17, 32, 193,
+ /* 1010 */ 153, 59, 153, 153, 170, 171, 40, 174, 175, 153,
+ /* 1020 */ 30, 59, 32, 19, 20, 99, 22, 170, 171, 233,
+ /* 1030 */ 40, 188, 236, 174, 175, 153, 153, 153, 79, 123,
+ /* 1040 */ 36, 89, 90, 153, 153, 153, 70, 188, 153, 97,
+ /* 1050 */ 98, 99, 100, 77, 102, 153, 80, 81, 174, 175,
+ /* 1060 */ 70, 99, 110, 59, 105, 174, 175, 77, 153, 238,
+ /* 1070 */ 80, 81, 188, 19, 20, 71, 22, 153, 153, 235,
+ /* 1080 */ 19, 22, 164, 24, 59, 153, 134, 83, 136, 153,
+ /* 1090 */ 36, 115, 235, 89, 90, 91, 120, 121, 153, 153,
+ /* 1100 */ 96, 142, 98, 99, 100, 115, 59, 103, 83, 239,
+ /* 1110 */ 120, 121, 199, 59, 196, 197, 153, 153, 59, 143,
+ /* 1120 */ 174, 175, 153, 98, 99, 71, 208, 153, 103, 165,
+ /* 1130 */ 153, 19, 20, 143, 22, 153, 153, 83, 134, 135,
+ /* 1140 */ 136, 137, 138, 89, 90, 98, 99, 100, 36, 185,
+ /* 1150 */ 96, 187, 98, 99, 100, 91, 95, 103, 99, 134,
+ /* 1160 */ 135, 136, 101, 102, 103, 104, 105, 106, 107, 153,
+ /* 1170 */ 26, 59, 125, 164, 113, 153, 153, 153, 212, 12,
+ /* 1180 */ 19, 117, 153, 71, 153, 212, 122, 164, 134, 135,
+ /* 1190 */ 136, 137, 138, 212, 27, 83, 212, 174, 175, 59,
+ /* 1200 */ 200, 89, 90, 174, 175, 196, 197, 46, 96, 42,
+ /* 1210 */ 98, 99, 100, 172, 151, 103, 5, 208, 203, 196,
+ /* 1220 */ 197, 10, 11, 12, 13, 14, 216, 216, 17, 244,
+ /* 1230 */ 63, 208, 209, 210, 153, 80, 24, 203, 98, 99,
+ /* 1240 */ 100, 30, 22, 32, 100, 164, 134, 135, 136, 137,
+ /* 1250 */ 138, 40, 148, 164, 150, 174, 175, 102, 97, 155,
+ /* 1260 */ 203, 157, 164, 244, 178, 125, 186, 182, 164, 125,
+ /* 1270 */ 177, 59, 177, 177, 113, 120, 121, 196, 197, 59,
+ /* 1280 */ 232, 70, 153, 216, 202, 196, 197, 153, 77, 208,
+ /* 1290 */ 209, 80, 81, 156, 196, 197, 60, 208, 248, 200,
+ /* 1300 */ 196, 197, 153, 174, 175, 123, 208, 153, 174, 175,
+ /* 1310 */ 160, 99, 208, 153, 38, 153, 160, 153, 98, 99,
+ /* 1320 */ 100, 153, 245, 174, 175, 221, 115, 153, 174, 175,
+ /* 1330 */ 153, 120, 121, 245, 174, 175, 174, 175, 174, 175,
+ /* 1340 */ 160, 153, 174, 175, 153, 225, 153, 22, 174, 175,
+ /* 1350 */ 97, 174, 175, 249, 143, 153, 224, 153, 43, 153,
+ /* 1360 */ 191, 153, 174, 175, 18, 174, 175, 174, 175, 153,
+ /* 1370 */ 131, 153, 194, 203, 153, 194, 174, 175, 174, 175,
+ /* 1380 */ 174, 175, 174, 175, 153, 160, 153, 18, 153, 194,
+ /* 1390 */ 174, 175, 174, 175, 153, 174, 175, 153, 225, 153,
+ /* 1400 */ 203, 153, 159, 153, 194, 174, 175, 174, 175, 174,
+ /* 1410 */ 175, 153, 203, 153, 224, 174, 175, 191, 174, 175,
+ /* 1420 */ 174, 175, 174, 175, 174, 175, 203, 160, 153, 191,
+ /* 1430 */ 153, 159, 174, 175, 174, 175, 153, 139, 62, 153,
+ /* 1440 */ 241, 153, 160, 153, 159, 153, 22, 240, 179, 174,
+ /* 1450 */ 175, 174, 175, 160, 159, 97, 160, 174, 175, 159,
+ /* 1460 */ 174, 175, 174, 175, 174, 175, 174, 175, 179, 64,
+ /* 1470 */ 176, 184, 108, 176, 95, 176, 234, 126, 176, 234,
+ /* 1480 */ 179, 178, 176, 176, 176, 97, 218, 217, 184, 179,
+ /* 1490 */ 179, 218, 218, 160, 22, 217, 217, 160, 218, 139,
+ /* 1500 */ 229, 217, 130, 129, 127, 25, 128, 163, 26, 162,
+ /* 1510 */ 13, 206, 231, 154, 6, 154, 207, 205, 204, 203,
+ /* 1520 */ 152, 166, 152, 152, 172, 172, 172, 4, 172, 166,
+ /* 1530 */ 180, 166, 3, 22, 172, 144, 15, 180, 172, 172,
+ /* 1540 */ 82, 16, 23, 23, 121, 254, 132, 172, 112, 124,
+ /* 1550 */ 24, 20, 126, 16, 1, 124, 112, 61, 53, 37,
+ /* 1560 */ 133, 132, 53, 53, 112, 53, 98, 254, 251, 34,
+ /* 1570 */ 123, 1, 5, 22, 97, 142, 26, 75, 123, 41,
+ /* 1580 */ 97, 68, 68, 24, 20, 19, 113, 22, 107, 28,
+ /* 1590 */ 22, 67, 23, 22, 22, 67, 22, 67, 23, 37,
+ /* 1600 */ 23, 23, 26, 23, 22, 24, 23, 22, 24, 123,
+ /* 1610 */ 23, 23, 22, 98, 125, 26, 11, 23, 26, 23,
+ /* 1620 */ 34, 23, 23, 23, 23, 34, 22, 34, 26, 22,
+ /* 1630 */ 22, 15, 23, 23, 22, 117, 23, 22, 1, 123,
+ /* 1640 */ 26, 23, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1650 */ 123, 255, 255, 255, 255, 123, 123, 255, 255, 255,
+ /* 1660 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1670 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1680 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1690 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1700 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1710 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1720 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1730 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1740 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1750 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1760 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1770 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1780 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1790 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1800 */ 255, 255,
};
-#define YY_SHIFT_COUNT (471)
+#define YY_SHIFT_COUNT (489)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (1559)
+#define YY_SHIFT_MAX (1637)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 182, 1090, 822, 822, 306, 957, 957, 957, 957, 210,
- /* 10 */ 0, 0, 104, 630, 957, 957, 957, 957, 957, 957,
- /* 20 */ 957, 1117, 1117, 126, 968, 306, 306, 306, 306, 306,
- /* 30 */ 306, 52, 156, 208, 260, 312, 364, 416, 468, 523,
- /* 40 */ 578, 630, 630, 630, 630, 630, 630, 630, 630, 630,
- /* 50 */ 630, 630, 630, 630, 630, 630, 630, 630, 682, 630,
- /* 60 */ 733, 783, 783, 877, 957, 957, 957, 957, 957, 957,
- /* 70 */ 957, 957, 957, 957, 957, 957, 957, 957, 957, 957,
- /* 80 */ 957, 957, 957, 957, 957, 957, 957, 957, 957, 957,
- /* 90 */ 957, 957, 957, 957, 957, 978, 957, 957, 957, 957,
- /* 100 */ 957, 957, 957, 957, 957, 957, 957, 957, 957, 1061,
- /* 110 */ 1108, 1108, 1108, 1108, 1108, 40, 127, 20, 280, 843,
- /* 120 */ 1032, 144, 144, 280, 310, 310, 310, 310, 59, 191,
- /* 130 */ 69, 1566, 1566, 1566, 786, 786, 786, 522, 836, 522,
- /* 140 */ 959, 959, 892, 155, 358, 280, 280, 280, 280, 280,
- /* 150 */ 280, 280, 280, 280, 280, 280, 280, 280, 280, 280,
- /* 160 */ 280, 280, 280, 280, 280, 280, 371, 388, 645, 645,
- /* 170 */ 531, 1566, 1566, 1566, 504, 189, 189, 909, 63, 176,
- /* 180 */ 928, 440, 932, 973, 280, 280, 280, 280, 280, 314,
- /* 190 */ 280, 280, 280, 280, 280, 280, 280, 280, 280, 280,
- /* 200 */ 280, 280, 1064, 1064, 1064, 280, 280, 280, 280, 667,
- /* 210 */ 280, 280, 280, 825, 280, 280, 902, 280, 280, 280,
- /* 220 */ 280, 280, 280, 280, 280, 383, 676, 325, 975, 975,
- /* 230 */ 975, 975, 1010, 325, 325, 819, 349, 524, 569, 829,
- /* 240 */ 829, 832, 569, 832, 686, 51, 656, 303, 303, 303,
- /* 250 */ 829, 294, 520, 628, 474, 1174, 1115, 1115, 1208, 1208,
- /* 260 */ 1115, 1231, 1217, 1131, 1246, 1246, 1246, 1246, 1115, 1276,
- /* 270 */ 1131, 1231, 1217, 1217, 1131, 1115, 1276, 1184, 1277, 1115,
- /* 280 */ 1276, 1330, 1115, 1276, 1115, 1276, 1330, 1280, 1280, 1280,
- /* 290 */ 1320, 1330, 1280, 1285, 1280, 1320, 1280, 1280, 1330, 1306,
- /* 300 */ 1306, 1330, 1284, 1294, 1284, 1294, 1284, 1294, 1284, 1294,
- /* 310 */ 1115, 1392, 1115, 1281, 1288, 1296, 1292, 1297, 1131, 1398,
- /* 320 */ 1401, 1417, 1417, 1429, 1429, 1429, 1566, 1566, 1566, 1566,
- /* 330 */ 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566,
- /* 340 */ 1566, 1566, 34, 357, 38, 462, 514, 484, 1074, 727,
- /* 350 */ 740, 734, 735, 777, 778, 784, 788, 803, 694, 845,
- /* 360 */ 742, 796, 833, 837, 889, 860, 886, 1036, 806, 958,
- /* 370 */ 1446, 1448, 1430, 1311, 1441, 1378, 1444, 1438, 1439, 1343,
- /* 380 */ 1334, 1356, 1345, 1452, 1348, 1458, 1474, 1353, 1346, 1425,
- /* 390 */ 1426, 1427, 1428, 1371, 1387, 1450, 1363, 1486, 1484, 1468,
- /* 400 */ 1384, 1352, 1431, 1467, 1432, 1420, 1454, 1374, 1390, 1476,
- /* 410 */ 1481, 1483, 1391, 1399, 1485, 1440, 1487, 1488, 1482, 1489,
- /* 420 */ 1442, 1490, 1491, 1449, 1475, 1493, 1494, 1496, 1495, 1497,
- /* 430 */ 1492, 1498, 1500, 1502, 1501, 1404, 1504, 1505, 1433, 1499,
- /* 440 */ 1508, 1407, 1506, 1503, 1509, 1507, 1511, 1513, 1515, 1506,
- /* 450 */ 1516, 1517, 1518, 1519, 1521, 1534, 1524, 1525, 1526, 1527,
- /* 460 */ 1529, 1530, 1532, 1522, 1436, 1434, 1435, 1437, 1443, 1535,
- /* 470 */ 1540, 1559,
+ /* 0 */ 990, 976, 1211, 837, 837, 316, 1054, 1054, 1054, 1054,
+ /* 10 */ 214, 0, 0, 106, 642, 1054, 1054, 1054, 1054, 1054,
+ /* 20 */ 1054, 1054, 1054, 952, 952, 226, 1155, 316, 316, 316,
+ /* 30 */ 316, 316, 316, 53, 159, 212, 265, 318, 371, 424,
+ /* 40 */ 477, 533, 589, 642, 642, 642, 642, 642, 642, 642,
+ /* 50 */ 642, 642, 642, 642, 642, 642, 642, 642, 642, 642,
+ /* 60 */ 695, 642, 747, 798, 798, 1004, 1054, 1054, 1054, 1054,
+ /* 70 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
+ /* 80 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
+ /* 90 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054,
+ /* 100 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
+ /* 110 */ 1054, 856, 874, 874, 874, 874, 874, 134, 147, 93,
+ /* 120 */ 342, 959, 1161, 253, 253, 342, 367, 367, 367, 367,
+ /* 130 */ 179, 36, 79, 1657, 1657, 1657, 1061, 1061, 1061, 516,
+ /* 140 */ 799, 516, 516, 531, 531, 802, 249, 369, 342, 342,
+ /* 150 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 342,
+ /* 160 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 272,
+ /* 170 */ 442, 442, 536, 1657, 1657, 1657, 1025, 245, 245, 570,
+ /* 180 */ 172, 286, 805, 1047, 1140, 1220, 342, 342, 342, 342,
+ /* 190 */ 342, 342, 342, 342, 170, 342, 342, 342, 342, 342,
+ /* 200 */ 342, 342, 342, 342, 342, 342, 342, 841, 841, 841,
+ /* 210 */ 342, 342, 342, 342, 530, 342, 342, 342, 1059, 342,
+ /* 220 */ 342, 1167, 342, 342, 342, 342, 342, 342, 342, 342,
+ /* 230 */ 123, 688, 177, 1212, 1212, 1212, 1212, 1144, 177, 177,
+ /* 240 */ 1064, 409, 33, 628, 707, 707, 900, 628, 628, 900,
+ /* 250 */ 897, 323, 398, 677, 677, 677, 707, 572, 684, 590,
+ /* 260 */ 739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315,
+ /* 270 */ 1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253,
+ /* 280 */ 1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369,
+ /* 290 */ 1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405,
+ /* 300 */ 1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379,
+ /* 310 */ 1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182,
+ /* 320 */ 1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482,
+ /* 330 */ 1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657,
+ /* 340 */ 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
+ /* 350 */ 1657, 20, 413, 98, 423, 519, 383, 962, 742, 61,
+ /* 360 */ 696, 749, 750, 753, 789, 790, 795, 797, 840, 842,
+ /* 370 */ 810, 668, 817, 659, 819, 849, 854, 899, 643, 745,
+ /* 380 */ 956, 926, 916, 1523, 1529, 1511, 1391, 1521, 1458, 1525,
+ /* 390 */ 1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537,
+ /* 400 */ 1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510,
+ /* 410 */ 1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433,
+ /* 420 */ 1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566,
+ /* 430 */ 1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561,
+ /* 440 */ 1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581,
+ /* 450 */ 1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489,
+ /* 460 */ 1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600,
+ /* 470 */ 1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613,
+ /* 480 */ 1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637,
};
-#define YY_REDUCE_COUNT (341)
-#define YY_REDUCE_MIN (-211)
-#define YY_REDUCE_MAX (1301)
+#define YY_REDUCE_COUNT (350)
+#define YY_REDUCE_MIN (-225)
+#define YY_REDUCE_MAX (1375)
static const short yy_reduce_ofst[] = {
- /* 0 */ -143, 789, 753, 1059, -137, -146, -144, -141, -136, 687,
- /* 10 */ -107, 101, -203, -52, 830, 870, 890, 167, 953, 218,
- /* 20 */ 220, 413, 646, 897, 73, 281, 283, 332, 496, 601,
- /* 30 */ 650, -211, -211, -211, -211, -211, -211, -211, -211, -211,
- /* 40 */ -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
- /* 50 */ -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
- /* 60 */ -211, -211, -211, 374, 377, 537, 969, 983, 1006, 1008,
- /* 70 */ 1015, 1055, 1067, 1069, 1071, 1084, 1096, 1100, 1104, 1111,
- /* 80 */ 1113, 1116, 1119, 1123, 1127, 1130, 1136, 1143, 1146, 1150,
- /* 90 */ 1153, 1155, 1159, 1161, 1163, 1166, 1170, 1189, 1193, 1195,
- /* 100 */ 1197, 1199, 1201, 1203, 1205, 1207, 1212, 1230, 1232, -211,
- /* 110 */ -211, -211, -211, -211, -211, -211, -211, -211, -30, 427,
- /* 120 */ -171, -145, -134, 22, 279, 287, 279, 287, 99, -211,
- /* 130 */ -211, -211, -211, -211, -165, -165, -165, 123, 135, 175,
- /* 140 */ -150, 396, 337, 291, 291, -147, 185, 391, 446, 444,
- /* 150 */ 452, 500, 501, 502, 27, -152, 295, 438, 490, 503,
- /* 160 */ 495, 506, -73, 447, 451, 536, 570, 551, 540, 579,
- /* 170 */ 30, 508, 535, 81, 14, 61, 115, 168, 142, 222,
- /* 180 */ 275, 284, 397, 599, 607, 647, 654, 660, 709, 658,
- /* 190 */ 714, 750, 754, 772, 787, 801, 817, 818, 850, 863,
- /* 200 */ 867, 871, 466, 748, 799, 881, 888, 898, 913, 824,
- /* 210 */ 930, 933, 934, 873, 942, 945, 849, 946, 222, 954,
- /* 220 */ 971, 972, 976, 979, 980, 900, 874, 927, 950, 961,
- /* 230 */ 962, 963, 824, 927, 927, 939, 970, 1018, 981, 988,
- /* 240 */ 993, 936, 982, 937, 1009, 1000, 1031, 1011, 1014, 1040,
- /* 250 */ 1003, 991, 990, 1026, 1072, 985, 1076, 1079, 997, 1005,
- /* 260 */ 1091, 1037, 1082, 1060, 1083, 1087, 1088, 1098, 1124, 1141,
- /* 270 */ 1106, 1092, 1122, 1135, 1128, 1147, 1173, 1110, 1105, 1187,
- /* 280 */ 1192, 1176, 1202, 1198, 1206, 1200, 1182, 1213, 1214, 1215,
- /* 290 */ 1209, 1216, 1218, 1219, 1220, 1224, 1222, 1223, 1221, 1171,
- /* 300 */ 1177, 1233, 1196, 1194, 1204, 1210, 1211, 1225, 1226, 1228,
- /* 310 */ 1253, 1190, 1256, 1191, 1227, 1229, 1234, 1236, 1235, 1263,
- /* 320 */ 1268, 1278, 1279, 1289, 1291, 1295, 1185, 1237, 1238, 1282,
- /* 330 */ 1274, 1283, 1286, 1287, 1290, 1269, 1270, 1293, 1298, 1299,
- /* 340 */ 1300, 1301,
+ /* 0 */ -137, -31, 1104, 1023, 1081, -132, -40, -38, 223, 225,
+ /* 10 */ 698, -153, -99, -225, -165, 386, 478, 843, 859, -139,
+ /* 20 */ 884, 117, 277, 844, 857, 964, 559, 561, 614, 918,
+ /* 30 */ 1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222,
+ /* 40 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
+ /* 50 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
+ /* 60 */ -222, -222, -222, -222, -222, 329, 331, 497, 654, 656,
+ /* 70 */ 781, 891, 946, 1029, 1129, 1134, 1149, 1154, 1160, 1162,
+ /* 80 */ 1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206,
+ /* 90 */ 1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246,
+ /* 100 */ 1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290,
+ /* 110 */ 1292, -222, -222, -222, -222, -222, -222, -222, -222, -222,
+ /* 120 */ -115, 796, -156, -154, -141, 14, 242, 349, 242, 349,
+ /* 130 */ -61, -222, -222, -222, -222, -222, 101, 101, 101, 332,
+ /* 140 */ 302, 384, 387, -170, 146, 344, 196, 196, 15, 11,
+ /* 150 */ 183, 235, 395, 355, 396, 406, 452, 457, 391, 459,
+ /* 160 */ 443, 447, 511, 495, 454, 512, 505, 571, 498, 532,
+ /* 170 */ 431, 435, 339, 455, 446, 508, -174, -116, -97, -120,
+ /* 180 */ -150, 64, 176, 330, 337, 509, 569, 611, 653, 673,
+ /* 190 */ 714, 717, 763, 771, -34, 779, 786, 830, 846, 860,
+ /* 200 */ 866, 882, 883, 890, 892, 895, 902, 319, 368, 769,
+ /* 210 */ 915, 924, 925, 932, 755, 936, 945, 963, 782, 969,
+ /* 220 */ 974, 816, 977, 64, 982, 983, 1016, 1022, 1024, 1031,
+ /* 230 */ 870, 831, 913, 966, 973, 981, 984, 755, 913, 913,
+ /* 240 */ 1000, 1041, 1063, 1015, 1010, 1011, 985, 1034, 1057, 1019,
+ /* 250 */ 1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099,
+ /* 260 */ 1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169,
+ /* 270 */ 1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173,
+ /* 280 */ 1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285,
+ /* 290 */ 1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287,
+ /* 300 */ 1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245,
+ /* 310 */ 1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333,
+ /* 320 */ 1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347,
+ /* 330 */ 1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352,
+ /* 340 */ 1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375,
+ /* 350 */ 1365,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1297, 1349, 1221, 1014, 1119, 1221, 1221, 1221, 1221, 1014,
- /* 10 */ 1145, 1145, 1272, 1045, 1014, 1014, 1014, 1014, 1014, 1220,
- /* 20 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 30 */ 1014, 1151, 1014, 1014, 1014, 1014, 1222, 1223, 1014, 1014,
- /* 40 */ 1014, 1271, 1273, 1161, 1160, 1159, 1158, 1254, 1132, 1156,
- /* 50 */ 1149, 1153, 1216, 1217, 1215, 1219, 1222, 1223, 1014, 1152,
- /* 60 */ 1186, 1200, 1185, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 70 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 80 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 90 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 100 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1194,
- /* 110 */ 1199, 1206, 1198, 1195, 1188, 1187, 1189, 1190, 1014, 1035,
- /* 120 */ 1084, 1014, 1014, 1014, 1289, 1288, 1014, 1014, 1045, 1191,
- /* 130 */ 1192, 1203, 1202, 1201, 1279, 1305, 1304, 1014, 1014, 1014,
- /* 140 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 150 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 160 */ 1014, 1014, 1014, 1014, 1014, 1014, 1045, 1297, 1041, 1041,
- /* 170 */ 1014, 1284, 1119, 1110, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 180 */ 1014, 1014, 1014, 1014, 1014, 1276, 1274, 1014, 1236, 1014,
- /* 190 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 200 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 210 */ 1014, 1014, 1014, 1115, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 220 */ 1014, 1014, 1014, 1014, 1299, 1014, 1249, 1098, 1115, 1115,
- /* 230 */ 1115, 1115, 1117, 1099, 1097, 1109, 1045, 1021, 1155, 1134,
- /* 240 */ 1134, 1338, 1155, 1338, 1059, 1319, 1056, 1145, 1145, 1145,
- /* 250 */ 1134, 1218, 1116, 1109, 1014, 1341, 1124, 1124, 1340, 1340,
- /* 260 */ 1124, 1166, 1087, 1155, 1093, 1093, 1093, 1093, 1124, 1032,
- /* 270 */ 1155, 1166, 1087, 1087, 1155, 1124, 1032, 1253, 1335, 1124,
- /* 280 */ 1032, 1229, 1124, 1032, 1124, 1032, 1229, 1085, 1085, 1085,
- /* 290 */ 1074, 1229, 1085, 1059, 1085, 1074, 1085, 1085, 1229, 1233,
- /* 300 */ 1233, 1229, 1138, 1133, 1138, 1133, 1138, 1133, 1138, 1133,
- /* 310 */ 1124, 1224, 1124, 1014, 1150, 1139, 1148, 1146, 1155, 1038,
- /* 320 */ 1077, 1302, 1302, 1298, 1298, 1298, 1346, 1346, 1284, 1314,
- /* 330 */ 1045, 1045, 1045, 1045, 1314, 1061, 1061, 1045, 1045, 1045,
- /* 340 */ 1045, 1314, 1014, 1014, 1014, 1014, 1014, 1014, 1309, 1014,
- /* 350 */ 1238, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 360 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1171,
- /* 370 */ 1014, 1017, 1281, 1014, 1014, 1280, 1014, 1014, 1014, 1014,
- /* 380 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 390 */ 1014, 1014, 1014, 1014, 1014, 1014, 1337, 1014, 1014, 1014,
- /* 400 */ 1014, 1014, 1014, 1252, 1251, 1014, 1014, 1126, 1014, 1014,
- /* 410 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 420 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 430 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 440 */ 1014, 1014, 1147, 1014, 1140, 1014, 1014, 1014, 1014, 1328,
- /* 450 */ 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
- /* 460 */ 1014, 1014, 1014, 1323, 1101, 1173, 1014, 1172, 1176, 1014,
- /* 470 */ 1026, 1014,
+ /* 0 */ 1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261,
+ /* 10 */ 1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046,
+ /* 20 */ 1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 30 */ 1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263,
+ /* 40 */ 1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294,
+ /* 50 */ 1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263,
+ /* 60 */ 1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046,
+ /* 70 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 80 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 90 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 100 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 110 */ 1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230,
+ /* 120 */ 1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046,
+ /* 130 */ 1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046,
+ /* 140 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 150 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 160 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077,
+ /* 170 */ 1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046,
+ /* 180 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046,
+ /* 190 */ 1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 200 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 210 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046,
+ /* 220 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339,
+ /* 230 */ 1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129,
+ /* 240 */ 1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378,
+ /* 250 */ 1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141,
+ /* 260 */ 1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119,
+ /* 270 */ 1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200,
+ /* 280 */ 1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064,
+ /* 290 */ 1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106,
+ /* 300 */ 1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273,
+ /* 310 */ 1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156,
+ /* 320 */ 1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109,
+ /* 330 */ 1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077,
+ /* 340 */ 1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077,
+ /* 350 */ 1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278,
+ /* 360 */ 1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 370 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 380 */ 1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046,
+ /* 390 */ 1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046,
+ /* 400 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 410 */ 1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046,
+ /* 420 */ 1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046,
+ /* 430 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 440 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 450 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 460 */ 1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046,
+ /* 470 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
+ /* 480 */ 1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -140664,6 +142297,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* ESCAPE => nothing */
0, /* ID => nothing */
59, /* COLUMNKW => ID */
+ 59, /* DO => ID */
59, /* FOR => ID */
59, /* IGNORE => ID */
59, /* INITIALLY => ID */
@@ -140725,6 +142359,7 @@ struct yyParser {
int yyerrcnt; /* Shifts left before out of the error */
#endif
sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
+ sqlite3ParserCTX_SDECL /* A place to hold %extra_context */
#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */
@@ -140833,197 +142468,200 @@ static const char *const yyTokenName[] = {
/* 58 */ "ESCAPE",
/* 59 */ "ID",
/* 60 */ "COLUMNKW",
- /* 61 */ "FOR",
- /* 62 */ "IGNORE",
- /* 63 */ "INITIALLY",
- /* 64 */ "INSTEAD",
- /* 65 */ "NO",
- /* 66 */ "KEY",
- /* 67 */ "OF",
- /* 68 */ "OFFSET",
- /* 69 */ "PRAGMA",
- /* 70 */ "RAISE",
- /* 71 */ "RECURSIVE",
- /* 72 */ "REPLACE",
- /* 73 */ "RESTRICT",
- /* 74 */ "ROW",
- /* 75 */ "TRIGGER",
- /* 76 */ "VACUUM",
- /* 77 */ "VIEW",
- /* 78 */ "VIRTUAL",
- /* 79 */ "WITH",
- /* 80 */ "REINDEX",
- /* 81 */ "RENAME",
- /* 82 */ "CTIME_KW",
- /* 83 */ "ANY",
- /* 84 */ "BITAND",
- /* 85 */ "BITOR",
- /* 86 */ "LSHIFT",
- /* 87 */ "RSHIFT",
- /* 88 */ "PLUS",
- /* 89 */ "MINUS",
- /* 90 */ "STAR",
- /* 91 */ "SLASH",
- /* 92 */ "REM",
- /* 93 */ "CONCAT",
- /* 94 */ "COLLATE",
- /* 95 */ "BITNOT",
- /* 96 */ "INDEXED",
- /* 97 */ "STRING",
- /* 98 */ "JOIN_KW",
- /* 99 */ "CONSTRAINT",
- /* 100 */ "DEFAULT",
- /* 101 */ "NULL",
- /* 102 */ "PRIMARY",
- /* 103 */ "UNIQUE",
- /* 104 */ "CHECK",
- /* 105 */ "REFERENCES",
- /* 106 */ "AUTOINCR",
- /* 107 */ "ON",
- /* 108 */ "INSERT",
- /* 109 */ "DELETE",
- /* 110 */ "UPDATE",
- /* 111 */ "SET",
- /* 112 */ "DEFERRABLE",
- /* 113 */ "FOREIGN",
- /* 114 */ "DROP",
- /* 115 */ "UNION",
- /* 116 */ "ALL",
- /* 117 */ "EXCEPT",
- /* 118 */ "INTERSECT",
- /* 119 */ "SELECT",
- /* 120 */ "VALUES",
- /* 121 */ "DISTINCT",
- /* 122 */ "DOT",
- /* 123 */ "FROM",
- /* 124 */ "JOIN",
- /* 125 */ "USING",
- /* 126 */ "ORDER",
- /* 127 */ "GROUP",
- /* 128 */ "HAVING",
- /* 129 */ "LIMIT",
- /* 130 */ "WHERE",
- /* 131 */ "INTO",
- /* 132 */ "FLOAT",
- /* 133 */ "BLOB",
- /* 134 */ "INTEGER",
- /* 135 */ "VARIABLE",
- /* 136 */ "CASE",
- /* 137 */ "WHEN",
- /* 138 */ "THEN",
- /* 139 */ "ELSE",
- /* 140 */ "INDEX",
- /* 141 */ "ALTER",
- /* 142 */ "ADD",
- /* 143 */ "error",
- /* 144 */ "input",
- /* 145 */ "cmdlist",
- /* 146 */ "ecmd",
- /* 147 */ "explain",
+ /* 61 */ "DO",
+ /* 62 */ "FOR",
+ /* 63 */ "IGNORE",
+ /* 64 */ "INITIALLY",
+ /* 65 */ "INSTEAD",
+ /* 66 */ "NO",
+ /* 67 */ "KEY",
+ /* 68 */ "OF",
+ /* 69 */ "OFFSET",
+ /* 70 */ "PRAGMA",
+ /* 71 */ "RAISE",
+ /* 72 */ "RECURSIVE",
+ /* 73 */ "REPLACE",
+ /* 74 */ "RESTRICT",
+ /* 75 */ "ROW",
+ /* 76 */ "TRIGGER",
+ /* 77 */ "VACUUM",
+ /* 78 */ "VIEW",
+ /* 79 */ "VIRTUAL",
+ /* 80 */ "WITH",
+ /* 81 */ "REINDEX",
+ /* 82 */ "RENAME",
+ /* 83 */ "CTIME_KW",
+ /* 84 */ "ANY",
+ /* 85 */ "BITAND",
+ /* 86 */ "BITOR",
+ /* 87 */ "LSHIFT",
+ /* 88 */ "RSHIFT",
+ /* 89 */ "PLUS",
+ /* 90 */ "MINUS",
+ /* 91 */ "STAR",
+ /* 92 */ "SLASH",
+ /* 93 */ "REM",
+ /* 94 */ "CONCAT",
+ /* 95 */ "COLLATE",
+ /* 96 */ "BITNOT",
+ /* 97 */ "ON",
+ /* 98 */ "INDEXED",
+ /* 99 */ "STRING",
+ /* 100 */ "JOIN_KW",
+ /* 101 */ "CONSTRAINT",
+ /* 102 */ "DEFAULT",
+ /* 103 */ "NULL",
+ /* 104 */ "PRIMARY",
+ /* 105 */ "UNIQUE",
+ /* 106 */ "CHECK",
+ /* 107 */ "REFERENCES",
+ /* 108 */ "AUTOINCR",
+ /* 109 */ "INSERT",
+ /* 110 */ "DELETE",
+ /* 111 */ "UPDATE",
+ /* 112 */ "SET",
+ /* 113 */ "DEFERRABLE",
+ /* 114 */ "FOREIGN",
+ /* 115 */ "DROP",
+ /* 116 */ "UNION",
+ /* 117 */ "ALL",
+ /* 118 */ "EXCEPT",
+ /* 119 */ "INTERSECT",
+ /* 120 */ "SELECT",
+ /* 121 */ "VALUES",
+ /* 122 */ "DISTINCT",
+ /* 123 */ "DOT",
+ /* 124 */ "FROM",
+ /* 125 */ "JOIN",
+ /* 126 */ "USING",
+ /* 127 */ "ORDER",
+ /* 128 */ "GROUP",
+ /* 129 */ "HAVING",
+ /* 130 */ "LIMIT",
+ /* 131 */ "WHERE",
+ /* 132 */ "INTO",
+ /* 133 */ "NOTHING",
+ /* 134 */ "FLOAT",
+ /* 135 */ "BLOB",
+ /* 136 */ "INTEGER",
+ /* 137 */ "VARIABLE",
+ /* 138 */ "CASE",
+ /* 139 */ "WHEN",
+ /* 140 */ "THEN",
+ /* 141 */ "ELSE",
+ /* 142 */ "INDEX",
+ /* 143 */ "ALTER",
+ /* 144 */ "ADD",
+ /* 145 */ "input",
+ /* 146 */ "cmdlist",
+ /* 147 */ "ecmd",
/* 148 */ "cmdx",
- /* 149 */ "cmd",
- /* 150 */ "transtype",
- /* 151 */ "trans_opt",
- /* 152 */ "nm",
- /* 153 */ "savepoint_opt",
- /* 154 */ "create_table",
- /* 155 */ "create_table_args",
- /* 156 */ "createkw",
- /* 157 */ "temp",
- /* 158 */ "ifnotexists",
- /* 159 */ "dbnm",
- /* 160 */ "columnlist",
- /* 161 */ "conslist_opt",
- /* 162 */ "table_options",
- /* 163 */ "select",
- /* 164 */ "columnname",
- /* 165 */ "carglist",
- /* 166 */ "typetoken",
- /* 167 */ "typename",
- /* 168 */ "signed",
- /* 169 */ "plus_num",
- /* 170 */ "minus_num",
- /* 171 */ "scanpt",
- /* 172 */ "ccons",
- /* 173 */ "term",
- /* 174 */ "expr",
- /* 175 */ "onconf",
- /* 176 */ "sortorder",
- /* 177 */ "autoinc",
- /* 178 */ "eidlist_opt",
- /* 179 */ "refargs",
- /* 180 */ "defer_subclause",
- /* 181 */ "refarg",
- /* 182 */ "refact",
- /* 183 */ "init_deferred_pred_opt",
- /* 184 */ "conslist",
- /* 185 */ "tconscomma",
- /* 186 */ "tcons",
- /* 187 */ "sortlist",
- /* 188 */ "eidlist",
- /* 189 */ "defer_subclause_opt",
- /* 190 */ "orconf",
- /* 191 */ "resolvetype",
- /* 192 */ "raisetype",
- /* 193 */ "ifexists",
- /* 194 */ "fullname",
- /* 195 */ "selectnowith",
- /* 196 */ "oneselect",
- /* 197 */ "wqlist",
- /* 198 */ "multiselect_op",
- /* 199 */ "distinct",
- /* 200 */ "selcollist",
- /* 201 */ "from",
- /* 202 */ "where_opt",
- /* 203 */ "groupby_opt",
- /* 204 */ "having_opt",
- /* 205 */ "orderby_opt",
- /* 206 */ "limit_opt",
- /* 207 */ "values",
- /* 208 */ "nexprlist",
- /* 209 */ "exprlist",
- /* 210 */ "sclp",
- /* 211 */ "as",
- /* 212 */ "seltablist",
- /* 213 */ "stl_prefix",
- /* 214 */ "joinop",
- /* 215 */ "indexed_opt",
- /* 216 */ "on_opt",
- /* 217 */ "using_opt",
- /* 218 */ "idlist",
- /* 219 */ "with",
- /* 220 */ "setlist",
- /* 221 */ "insert_cmd",
- /* 222 */ "idlist_opt",
- /* 223 */ "likeop",
- /* 224 */ "between_op",
- /* 225 */ "in_op",
- /* 226 */ "paren_exprlist",
- /* 227 */ "case_operand",
- /* 228 */ "case_exprlist",
- /* 229 */ "case_else",
- /* 230 */ "uniqueflag",
- /* 231 */ "collate",
- /* 232 */ "nmnum",
- /* 233 */ "trigger_decl",
- /* 234 */ "trigger_cmd_list",
- /* 235 */ "trigger_time",
- /* 236 */ "trigger_event",
- /* 237 */ "foreach_clause",
- /* 238 */ "when_clause",
- /* 239 */ "trigger_cmd",
- /* 240 */ "trnm",
- /* 241 */ "tridxby",
- /* 242 */ "database_kw_opt",
- /* 243 */ "key_opt",
- /* 244 */ "add_column_fullname",
- /* 245 */ "kwcolumn_opt",
- /* 246 */ "create_vtab",
- /* 247 */ "vtabarglist",
- /* 248 */ "vtabarg",
- /* 249 */ "vtabargtoken",
- /* 250 */ "lp",
- /* 251 */ "anylist",
+ /* 149 */ "explain",
+ /* 150 */ "cmd",
+ /* 151 */ "transtype",
+ /* 152 */ "trans_opt",
+ /* 153 */ "nm",
+ /* 154 */ "savepoint_opt",
+ /* 155 */ "create_table",
+ /* 156 */ "create_table_args",
+ /* 157 */ "createkw",
+ /* 158 */ "temp",
+ /* 159 */ "ifnotexists",
+ /* 160 */ "dbnm",
+ /* 161 */ "columnlist",
+ /* 162 */ "conslist_opt",
+ /* 163 */ "table_options",
+ /* 164 */ "select",
+ /* 165 */ "columnname",
+ /* 166 */ "carglist",
+ /* 167 */ "typetoken",
+ /* 168 */ "typename",
+ /* 169 */ "signed",
+ /* 170 */ "plus_num",
+ /* 171 */ "minus_num",
+ /* 172 */ "scanpt",
+ /* 173 */ "ccons",
+ /* 174 */ "term",
+ /* 175 */ "expr",
+ /* 176 */ "onconf",
+ /* 177 */ "sortorder",
+ /* 178 */ "autoinc",
+ /* 179 */ "eidlist_opt",
+ /* 180 */ "refargs",
+ /* 181 */ "defer_subclause",
+ /* 182 */ "refarg",
+ /* 183 */ "refact",
+ /* 184 */ "init_deferred_pred_opt",
+ /* 185 */ "conslist",
+ /* 186 */ "tconscomma",
+ /* 187 */ "tcons",
+ /* 188 */ "sortlist",
+ /* 189 */ "eidlist",
+ /* 190 */ "defer_subclause_opt",
+ /* 191 */ "orconf",
+ /* 192 */ "resolvetype",
+ /* 193 */ "raisetype",
+ /* 194 */ "ifexists",
+ /* 195 */ "fullname",
+ /* 196 */ "selectnowith",
+ /* 197 */ "oneselect",
+ /* 198 */ "wqlist",
+ /* 199 */ "multiselect_op",
+ /* 200 */ "distinct",
+ /* 201 */ "selcollist",
+ /* 202 */ "from",
+ /* 203 */ "where_opt",
+ /* 204 */ "groupby_opt",
+ /* 205 */ "having_opt",
+ /* 206 */ "orderby_opt",
+ /* 207 */ "limit_opt",
+ /* 208 */ "values",
+ /* 209 */ "nexprlist",
+ /* 210 */ "exprlist",
+ /* 211 */ "sclp",
+ /* 212 */ "as",
+ /* 213 */ "seltablist",
+ /* 214 */ "stl_prefix",
+ /* 215 */ "joinop",
+ /* 216 */ "indexed_opt",
+ /* 217 */ "on_opt",
+ /* 218 */ "using_opt",
+ /* 219 */ "xfullname",
+ /* 220 */ "idlist",
+ /* 221 */ "with",
+ /* 222 */ "setlist",
+ /* 223 */ "insert_cmd",
+ /* 224 */ "idlist_opt",
+ /* 225 */ "upsert",
+ /* 226 */ "likeop",
+ /* 227 */ "between_op",
+ /* 228 */ "in_op",
+ /* 229 */ "paren_exprlist",
+ /* 230 */ "case_operand",
+ /* 231 */ "case_exprlist",
+ /* 232 */ "case_else",
+ /* 233 */ "uniqueflag",
+ /* 234 */ "collate",
+ /* 235 */ "nmnum",
+ /* 236 */ "trigger_decl",
+ /* 237 */ "trigger_cmd_list",
+ /* 238 */ "trigger_time",
+ /* 239 */ "trigger_event",
+ /* 240 */ "foreach_clause",
+ /* 241 */ "when_clause",
+ /* 242 */ "trigger_cmd",
+ /* 243 */ "trnm",
+ /* 244 */ "tridxby",
+ /* 245 */ "database_kw_opt",
+ /* 246 */ "key_opt",
+ /* 247 */ "add_column_fullname",
+ /* 248 */ "kwcolumn_opt",
+ /* 249 */ "create_vtab",
+ /* 250 */ "vtabarglist",
+ /* 251 */ "vtabarg",
+ /* 252 */ "vtabargtoken",
+ /* 253 */ "lp",
+ /* 254 */ "anylist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -141142,228 +142780,236 @@ static const char *const yyRuleName[] = {
/* 108 */ "dbnm ::= DOT nm",
/* 109 */ "fullname ::= nm",
/* 110 */ "fullname ::= nm DOT nm",
- /* 111 */ "joinop ::= COMMA|JOIN",
- /* 112 */ "joinop ::= JOIN_KW JOIN",
- /* 113 */ "joinop ::= JOIN_KW nm JOIN",
- /* 114 */ "joinop ::= JOIN_KW nm nm JOIN",
- /* 115 */ "on_opt ::= ON expr",
- /* 116 */ "on_opt ::=",
- /* 117 */ "indexed_opt ::=",
- /* 118 */ "indexed_opt ::= INDEXED BY nm",
- /* 119 */ "indexed_opt ::= NOT INDEXED",
- /* 120 */ "using_opt ::= USING LP idlist RP",
- /* 121 */ "using_opt ::=",
- /* 122 */ "orderby_opt ::=",
- /* 123 */ "orderby_opt ::= ORDER BY sortlist",
- /* 124 */ "sortlist ::= sortlist COMMA expr sortorder",
- /* 125 */ "sortlist ::= expr sortorder",
- /* 126 */ "sortorder ::= ASC",
- /* 127 */ "sortorder ::= DESC",
- /* 128 */ "sortorder ::=",
- /* 129 */ "groupby_opt ::=",
- /* 130 */ "groupby_opt ::= GROUP BY nexprlist",
- /* 131 */ "having_opt ::=",
- /* 132 */ "having_opt ::= HAVING expr",
- /* 133 */ "limit_opt ::=",
- /* 134 */ "limit_opt ::= LIMIT expr",
- /* 135 */ "limit_opt ::= LIMIT expr OFFSET expr",
- /* 136 */ "limit_opt ::= LIMIT expr COMMA expr",
- /* 137 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
- /* 138 */ "where_opt ::=",
- /* 139 */ "where_opt ::= WHERE expr",
- /* 140 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
- /* 141 */ "setlist ::= setlist COMMA nm EQ expr",
- /* 142 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
- /* 143 */ "setlist ::= nm EQ expr",
- /* 144 */ "setlist ::= LP idlist RP EQ expr",
- /* 145 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
- /* 146 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
- /* 147 */ "insert_cmd ::= INSERT orconf",
- /* 148 */ "insert_cmd ::= REPLACE",
- /* 149 */ "idlist_opt ::=",
- /* 150 */ "idlist_opt ::= LP idlist RP",
- /* 151 */ "idlist ::= idlist COMMA nm",
- /* 152 */ "idlist ::= nm",
- /* 153 */ "expr ::= LP expr RP",
- /* 154 */ "expr ::= ID|INDEXED",
- /* 155 */ "expr ::= JOIN_KW",
- /* 156 */ "expr ::= nm DOT nm",
- /* 157 */ "expr ::= nm DOT nm DOT nm",
- /* 158 */ "term ::= NULL|FLOAT|BLOB",
- /* 159 */ "term ::= STRING",
- /* 160 */ "term ::= INTEGER",
- /* 161 */ "expr ::= VARIABLE",
- /* 162 */ "expr ::= expr COLLATE ID|STRING",
- /* 163 */ "expr ::= CAST LP expr AS typetoken RP",
- /* 164 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
- /* 165 */ "expr ::= ID|INDEXED LP STAR RP",
- /* 166 */ "term ::= CTIME_KW",
- /* 167 */ "expr ::= LP nexprlist COMMA expr RP",
- /* 168 */ "expr ::= expr AND expr",
- /* 169 */ "expr ::= expr OR expr",
- /* 170 */ "expr ::= expr LT|GT|GE|LE expr",
- /* 171 */ "expr ::= expr EQ|NE expr",
- /* 172 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
- /* 173 */ "expr ::= expr PLUS|MINUS expr",
- /* 174 */ "expr ::= expr STAR|SLASH|REM expr",
- /* 175 */ "expr ::= expr CONCAT expr",
- /* 176 */ "likeop ::= NOT LIKE_KW|MATCH",
- /* 177 */ "expr ::= expr likeop expr",
- /* 178 */ "expr ::= expr likeop expr ESCAPE expr",
- /* 179 */ "expr ::= expr ISNULL|NOTNULL",
- /* 180 */ "expr ::= expr NOT NULL",
- /* 181 */ "expr ::= expr IS expr",
- /* 182 */ "expr ::= expr IS NOT expr",
- /* 183 */ "expr ::= NOT expr",
- /* 184 */ "expr ::= BITNOT expr",
- /* 185 */ "expr ::= MINUS expr",
- /* 186 */ "expr ::= PLUS expr",
- /* 187 */ "between_op ::= BETWEEN",
- /* 188 */ "between_op ::= NOT BETWEEN",
- /* 189 */ "expr ::= expr between_op expr AND expr",
- /* 190 */ "in_op ::= IN",
- /* 191 */ "in_op ::= NOT IN",
- /* 192 */ "expr ::= expr in_op LP exprlist RP",
- /* 193 */ "expr ::= LP select RP",
- /* 194 */ "expr ::= expr in_op LP select RP",
- /* 195 */ "expr ::= expr in_op nm dbnm paren_exprlist",
- /* 196 */ "expr ::= EXISTS LP select RP",
- /* 197 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 198 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 199 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 200 */ "case_else ::= ELSE expr",
- /* 201 */ "case_else ::=",
- /* 202 */ "case_operand ::= expr",
- /* 203 */ "case_operand ::=",
- /* 204 */ "exprlist ::=",
- /* 205 */ "nexprlist ::= nexprlist COMMA expr",
- /* 206 */ "nexprlist ::= expr",
- /* 207 */ "paren_exprlist ::=",
- /* 208 */ "paren_exprlist ::= LP exprlist RP",
- /* 209 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
- /* 210 */ "uniqueflag ::= UNIQUE",
- /* 211 */ "uniqueflag ::=",
- /* 212 */ "eidlist_opt ::=",
- /* 213 */ "eidlist_opt ::= LP eidlist RP",
- /* 214 */ "eidlist ::= eidlist COMMA nm collate sortorder",
- /* 215 */ "eidlist ::= nm collate sortorder",
- /* 216 */ "collate ::=",
- /* 217 */ "collate ::= COLLATE ID|STRING",
- /* 218 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 219 */ "cmd ::= VACUUM",
- /* 220 */ "cmd ::= VACUUM nm",
- /* 221 */ "cmd ::= PRAGMA nm dbnm",
- /* 222 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 223 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 224 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 225 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 226 */ "plus_num ::= PLUS INTEGER|FLOAT",
- /* 227 */ "minus_num ::= MINUS INTEGER|FLOAT",
- /* 228 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 229 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 230 */ "trigger_time ::= BEFORE|AFTER",
- /* 231 */ "trigger_time ::= INSTEAD OF",
- /* 232 */ "trigger_time ::=",
- /* 233 */ "trigger_event ::= DELETE|INSERT",
- /* 234 */ "trigger_event ::= UPDATE",
- /* 235 */ "trigger_event ::= UPDATE OF idlist",
- /* 236 */ "when_clause ::=",
- /* 237 */ "when_clause ::= WHEN expr",
- /* 238 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 239 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 240 */ "trnm ::= nm DOT nm",
- /* 241 */ "tridxby ::= INDEXED BY nm",
- /* 242 */ "tridxby ::= NOT INDEXED",
- /* 243 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
- /* 244 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt",
- /* 245 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
- /* 246 */ "trigger_cmd ::= scanpt select scanpt",
- /* 247 */ "expr ::= RAISE LP IGNORE RP",
- /* 248 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 249 */ "raisetype ::= ROLLBACK",
- /* 250 */ "raisetype ::= ABORT",
- /* 251 */ "raisetype ::= FAIL",
- /* 252 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 253 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 254 */ "cmd ::= DETACH database_kw_opt expr",
- /* 255 */ "key_opt ::=",
- /* 256 */ "key_opt ::= KEY expr",
- /* 257 */ "cmd ::= REINDEX",
- /* 258 */ "cmd ::= REINDEX nm dbnm",
- /* 259 */ "cmd ::= ANALYZE",
- /* 260 */ "cmd ::= ANALYZE nm dbnm",
- /* 261 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 262 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
- /* 263 */ "add_column_fullname ::= fullname",
- /* 264 */ "cmd ::= create_vtab",
- /* 265 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 266 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
- /* 267 */ "vtabarg ::=",
- /* 268 */ "vtabargtoken ::= ANY",
- /* 269 */ "vtabargtoken ::= lp anylist RP",
- /* 270 */ "lp ::= LP",
- /* 271 */ "with ::= WITH wqlist",
- /* 272 */ "with ::= WITH RECURSIVE wqlist",
- /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
- /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
- /* 275 */ "input ::= cmdlist",
- /* 276 */ "cmdlist ::= cmdlist ecmd",
- /* 277 */ "cmdlist ::= ecmd",
- /* 278 */ "ecmd ::= SEMI",
- /* 279 */ "ecmd ::= explain cmdx SEMI",
- /* 280 */ "explain ::=",
- /* 281 */ "trans_opt ::=",
- /* 282 */ "trans_opt ::= TRANSACTION",
- /* 283 */ "trans_opt ::= TRANSACTION nm",
- /* 284 */ "savepoint_opt ::= SAVEPOINT",
- /* 285 */ "savepoint_opt ::=",
- /* 286 */ "cmd ::= create_table create_table_args",
- /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
- /* 288 */ "columnlist ::= columnname carglist",
- /* 289 */ "nm ::= ID|INDEXED",
- /* 290 */ "nm ::= STRING",
- /* 291 */ "nm ::= JOIN_KW",
- /* 292 */ "typetoken ::= typename",
- /* 293 */ "typename ::= ID|STRING",
- /* 294 */ "signed ::= plus_num",
- /* 295 */ "signed ::= minus_num",
- /* 296 */ "carglist ::= carglist ccons",
- /* 297 */ "carglist ::=",
- /* 298 */ "ccons ::= NULL onconf",
- /* 299 */ "conslist_opt ::= COMMA conslist",
- /* 300 */ "conslist ::= conslist tconscomma tcons",
- /* 301 */ "conslist ::= tcons",
- /* 302 */ "tconscomma ::=",
- /* 303 */ "defer_subclause_opt ::= defer_subclause",
- /* 304 */ "resolvetype ::= raisetype",
- /* 305 */ "selectnowith ::= oneselect",
- /* 306 */ "oneselect ::= values",
- /* 307 */ "sclp ::= selcollist COMMA",
- /* 308 */ "as ::= ID|STRING",
- /* 309 */ "expr ::= term",
- /* 310 */ "likeop ::= LIKE_KW|MATCH",
- /* 311 */ "exprlist ::= nexprlist",
- /* 312 */ "nmnum ::= plus_num",
- /* 313 */ "nmnum ::= nm",
- /* 314 */ "nmnum ::= ON",
- /* 315 */ "nmnum ::= DELETE",
- /* 316 */ "nmnum ::= DEFAULT",
- /* 317 */ "plus_num ::= INTEGER|FLOAT",
- /* 318 */ "foreach_clause ::=",
- /* 319 */ "foreach_clause ::= FOR EACH ROW",
- /* 320 */ "trnm ::= nm",
- /* 321 */ "tridxby ::=",
- /* 322 */ "database_kw_opt ::= DATABASE",
- /* 323 */ "database_kw_opt ::=",
- /* 324 */ "kwcolumn_opt ::=",
- /* 325 */ "kwcolumn_opt ::= COLUMNKW",
- /* 326 */ "vtabarglist ::= vtabarg",
- /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 329 */ "anylist ::=",
- /* 330 */ "anylist ::= anylist LP anylist RP",
- /* 331 */ "anylist ::= anylist ANY",
- /* 332 */ "with ::=",
+ /* 111 */ "xfullname ::= nm",
+ /* 112 */ "xfullname ::= nm DOT nm",
+ /* 113 */ "xfullname ::= nm DOT nm AS nm",
+ /* 114 */ "xfullname ::= nm AS nm",
+ /* 115 */ "joinop ::= COMMA|JOIN",
+ /* 116 */ "joinop ::= JOIN_KW JOIN",
+ /* 117 */ "joinop ::= JOIN_KW nm JOIN",
+ /* 118 */ "joinop ::= JOIN_KW nm nm JOIN",
+ /* 119 */ "on_opt ::= ON expr",
+ /* 120 */ "on_opt ::=",
+ /* 121 */ "indexed_opt ::=",
+ /* 122 */ "indexed_opt ::= INDEXED BY nm",
+ /* 123 */ "indexed_opt ::= NOT INDEXED",
+ /* 124 */ "using_opt ::= USING LP idlist RP",
+ /* 125 */ "using_opt ::=",
+ /* 126 */ "orderby_opt ::=",
+ /* 127 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 128 */ "sortlist ::= sortlist COMMA expr sortorder",
+ /* 129 */ "sortlist ::= expr sortorder",
+ /* 130 */ "sortorder ::= ASC",
+ /* 131 */ "sortorder ::= DESC",
+ /* 132 */ "sortorder ::=",
+ /* 133 */ "groupby_opt ::=",
+ /* 134 */ "groupby_opt ::= GROUP BY nexprlist",
+ /* 135 */ "having_opt ::=",
+ /* 136 */ "having_opt ::= HAVING expr",
+ /* 137 */ "limit_opt ::=",
+ /* 138 */ "limit_opt ::= LIMIT expr",
+ /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr",
+ /* 140 */ "limit_opt ::= LIMIT expr COMMA expr",
+ /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
+ /* 142 */ "where_opt ::=",
+ /* 143 */ "where_opt ::= WHERE expr",
+ /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
+ /* 145 */ "setlist ::= setlist COMMA nm EQ expr",
+ /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
+ /* 147 */ "setlist ::= nm EQ expr",
+ /* 148 */ "setlist ::= LP idlist RP EQ expr",
+ /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
+ /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
+ /* 151 */ "upsert ::=",
+ /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
+ /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
+ /* 154 */ "upsert ::= ON CONFLICT DO NOTHING",
+ /* 155 */ "insert_cmd ::= INSERT orconf",
+ /* 156 */ "insert_cmd ::= REPLACE",
+ /* 157 */ "idlist_opt ::=",
+ /* 158 */ "idlist_opt ::= LP idlist RP",
+ /* 159 */ "idlist ::= idlist COMMA nm",
+ /* 160 */ "idlist ::= nm",
+ /* 161 */ "expr ::= LP expr RP",
+ /* 162 */ "expr ::= ID|INDEXED",
+ /* 163 */ "expr ::= JOIN_KW",
+ /* 164 */ "expr ::= nm DOT nm",
+ /* 165 */ "expr ::= nm DOT nm DOT nm",
+ /* 166 */ "term ::= NULL|FLOAT|BLOB",
+ /* 167 */ "term ::= STRING",
+ /* 168 */ "term ::= INTEGER",
+ /* 169 */ "expr ::= VARIABLE",
+ /* 170 */ "expr ::= expr COLLATE ID|STRING",
+ /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
+ /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
+ /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
+ /* 174 */ "term ::= CTIME_KW",
+ /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
+ /* 176 */ "expr ::= expr AND expr",
+ /* 177 */ "expr ::= expr OR expr",
+ /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
+ /* 179 */ "expr ::= expr EQ|NE expr",
+ /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
+ /* 181 */ "expr ::= expr PLUS|MINUS expr",
+ /* 182 */ "expr ::= expr STAR|SLASH|REM expr",
+ /* 183 */ "expr ::= expr CONCAT expr",
+ /* 184 */ "likeop ::= NOT LIKE_KW|MATCH",
+ /* 185 */ "expr ::= expr likeop expr",
+ /* 186 */ "expr ::= expr likeop expr ESCAPE expr",
+ /* 187 */ "expr ::= expr ISNULL|NOTNULL",
+ /* 188 */ "expr ::= expr NOT NULL",
+ /* 189 */ "expr ::= expr IS expr",
+ /* 190 */ "expr ::= expr IS NOT expr",
+ /* 191 */ "expr ::= NOT expr",
+ /* 192 */ "expr ::= BITNOT expr",
+ /* 193 */ "expr ::= MINUS expr",
+ /* 194 */ "expr ::= PLUS expr",
+ /* 195 */ "between_op ::= BETWEEN",
+ /* 196 */ "between_op ::= NOT BETWEEN",
+ /* 197 */ "expr ::= expr between_op expr AND expr",
+ /* 198 */ "in_op ::= IN",
+ /* 199 */ "in_op ::= NOT IN",
+ /* 200 */ "expr ::= expr in_op LP exprlist RP",
+ /* 201 */ "expr ::= LP select RP",
+ /* 202 */ "expr ::= expr in_op LP select RP",
+ /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist",
+ /* 204 */ "expr ::= EXISTS LP select RP",
+ /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 207 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 208 */ "case_else ::= ELSE expr",
+ /* 209 */ "case_else ::=",
+ /* 210 */ "case_operand ::= expr",
+ /* 211 */ "case_operand ::=",
+ /* 212 */ "exprlist ::=",
+ /* 213 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 214 */ "nexprlist ::= expr",
+ /* 215 */ "paren_exprlist ::=",
+ /* 216 */ "paren_exprlist ::= LP exprlist RP",
+ /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
+ /* 218 */ "uniqueflag ::= UNIQUE",
+ /* 219 */ "uniqueflag ::=",
+ /* 220 */ "eidlist_opt ::=",
+ /* 221 */ "eidlist_opt ::= LP eidlist RP",
+ /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder",
+ /* 223 */ "eidlist ::= nm collate sortorder",
+ /* 224 */ "collate ::=",
+ /* 225 */ "collate ::= COLLATE ID|STRING",
+ /* 226 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 227 */ "cmd ::= VACUUM",
+ /* 228 */ "cmd ::= VACUUM nm",
+ /* 229 */ "cmd ::= PRAGMA nm dbnm",
+ /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT",
+ /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT",
+ /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 238 */ "trigger_time ::= BEFORE|AFTER",
+ /* 239 */ "trigger_time ::= INSTEAD OF",
+ /* 240 */ "trigger_time ::=",
+ /* 241 */ "trigger_event ::= DELETE|INSERT",
+ /* 242 */ "trigger_event ::= UPDATE",
+ /* 243 */ "trigger_event ::= UPDATE OF idlist",
+ /* 244 */ "when_clause ::=",
+ /* 245 */ "when_clause ::= WHEN expr",
+ /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 248 */ "trnm ::= nm DOT nm",
+ /* 249 */ "tridxby ::= INDEXED BY nm",
+ /* 250 */ "tridxby ::= NOT INDEXED",
+ /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
+ /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
+ /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
+ /* 254 */ "trigger_cmd ::= scanpt select scanpt",
+ /* 255 */ "expr ::= RAISE LP IGNORE RP",
+ /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 257 */ "raisetype ::= ROLLBACK",
+ /* 258 */ "raisetype ::= ABORT",
+ /* 259 */ "raisetype ::= FAIL",
+ /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 262 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 263 */ "key_opt ::=",
+ /* 264 */ "key_opt ::= KEY expr",
+ /* 265 */ "cmd ::= REINDEX",
+ /* 266 */ "cmd ::= REINDEX nm dbnm",
+ /* 267 */ "cmd ::= ANALYZE",
+ /* 268 */ "cmd ::= ANALYZE nm dbnm",
+ /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 271 */ "add_column_fullname ::= fullname",
+ /* 272 */ "cmd ::= create_vtab",
+ /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 275 */ "vtabarg ::=",
+ /* 276 */ "vtabargtoken ::= ANY",
+ /* 277 */ "vtabargtoken ::= lp anylist RP",
+ /* 278 */ "lp ::= LP",
+ /* 279 */ "with ::= WITH wqlist",
+ /* 280 */ "with ::= WITH RECURSIVE wqlist",
+ /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
+ /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
+ /* 283 */ "input ::= cmdlist",
+ /* 284 */ "cmdlist ::= cmdlist ecmd",
+ /* 285 */ "cmdlist ::= ecmd",
+ /* 286 */ "ecmd ::= SEMI",
+ /* 287 */ "ecmd ::= cmdx SEMI",
+ /* 288 */ "ecmd ::= explain cmdx",
+ /* 289 */ "trans_opt ::=",
+ /* 290 */ "trans_opt ::= TRANSACTION",
+ /* 291 */ "trans_opt ::= TRANSACTION nm",
+ /* 292 */ "savepoint_opt ::= SAVEPOINT",
+ /* 293 */ "savepoint_opt ::=",
+ /* 294 */ "cmd ::= create_table create_table_args",
+ /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 296 */ "columnlist ::= columnname carglist",
+ /* 297 */ "nm ::= ID|INDEXED",
+ /* 298 */ "nm ::= STRING",
+ /* 299 */ "nm ::= JOIN_KW",
+ /* 300 */ "typetoken ::= typename",
+ /* 301 */ "typename ::= ID|STRING",
+ /* 302 */ "signed ::= plus_num",
+ /* 303 */ "signed ::= minus_num",
+ /* 304 */ "carglist ::= carglist ccons",
+ /* 305 */ "carglist ::=",
+ /* 306 */ "ccons ::= NULL onconf",
+ /* 307 */ "conslist_opt ::= COMMA conslist",
+ /* 308 */ "conslist ::= conslist tconscomma tcons",
+ /* 309 */ "conslist ::= tcons",
+ /* 310 */ "tconscomma ::=",
+ /* 311 */ "defer_subclause_opt ::= defer_subclause",
+ /* 312 */ "resolvetype ::= raisetype",
+ /* 313 */ "selectnowith ::= oneselect",
+ /* 314 */ "oneselect ::= values",
+ /* 315 */ "sclp ::= selcollist COMMA",
+ /* 316 */ "as ::= ID|STRING",
+ /* 317 */ "expr ::= term",
+ /* 318 */ "likeop ::= LIKE_KW|MATCH",
+ /* 319 */ "exprlist ::= nexprlist",
+ /* 320 */ "nmnum ::= plus_num",
+ /* 321 */ "nmnum ::= nm",
+ /* 322 */ "nmnum ::= ON",
+ /* 323 */ "nmnum ::= DELETE",
+ /* 324 */ "nmnum ::= DEFAULT",
+ /* 325 */ "plus_num ::= INTEGER|FLOAT",
+ /* 326 */ "foreach_clause ::=",
+ /* 327 */ "foreach_clause ::= FOR EACH ROW",
+ /* 328 */ "trnm ::= nm",
+ /* 329 */ "tridxby ::=",
+ /* 330 */ "database_kw_opt ::= DATABASE",
+ /* 331 */ "database_kw_opt ::=",
+ /* 332 */ "kwcolumn_opt ::=",
+ /* 333 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 334 */ "vtabarglist ::= vtabarg",
+ /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 337 */ "anylist ::=",
+ /* 338 */ "anylist ::= anylist LP anylist RP",
+ /* 339 */ "anylist ::= anylist ANY",
+ /* 340 */ "with ::=",
};
#endif /* NDEBUG */
@@ -141412,28 +143058,29 @@ static int yyGrowStack(yyParser *p){
/* Initialize a new parser that has already been allocated.
*/
-SQLITE_PRIVATE void sqlite3ParserInit(void *yypParser){
- yyParser *pParser = (yyParser*)yypParser;
+SQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL){
+ yyParser *yypParser = (yyParser*)yypRawParser;
+ sqlite3ParserCTX_STORE
#ifdef YYTRACKMAXSTACKDEPTH
- pParser->yyhwm = 0;
+ yypParser->yyhwm = 0;
#endif
#if YYSTACKDEPTH<=0
- pParser->yytos = NULL;
- pParser->yystack = NULL;
- pParser->yystksz = 0;
- if( yyGrowStack(pParser) ){
- pParser->yystack = &pParser->yystk0;
- pParser->yystksz = 1;
+ yypParser->yytos = NULL;
+ yypParser->yystack = NULL;
+ yypParser->yystksz = 0;
+ if( yyGrowStack(yypParser) ){
+ yypParser->yystack = &yypParser->yystk0;
+ yypParser->yystksz = 1;
}
#endif
#ifndef YYNOERRORRECOVERY
- pParser->yyerrcnt = -1;
+ yypParser->yyerrcnt = -1;
#endif
- pParser->yytos = pParser->yystack;
- pParser->yystack[0].stateno = 0;
- pParser->yystack[0].major = 0;
+ yypParser->yytos = yypParser->yystack;
+ yypParser->yystack[0].stateno = 0;
+ yypParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0
- pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
+ yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
#endif
}
@@ -141450,11 +143097,14 @@ SQLITE_PRIVATE void sqlite3ParserInit(void *yypParser){
** A pointer to a parser. This pointer is used in subsequent calls
** to sqlite3Parser and sqlite3ParserFree.
*/
-SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
- yyParser *pParser;
- pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
- if( pParser ) sqlite3ParserInit(pParser);
- return pParser;
+SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) sqlite3ParserCTX_PDECL){
+ yyParser *yypParser;
+ yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
+ if( yypParser ){
+ sqlite3ParserCTX_STORE
+ sqlite3ParserInit(yypParser sqlite3ParserCTX_PARAM);
+ }
+ return (void*)yypParser;
}
#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */
@@ -141471,7 +143121,8 @@ static void yy_destructor(
YYCODETYPE yymajor, /* Type code for object to destroy */
YYMINORTYPE *yypminor /* The object to be destroyed */
){
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
+ sqlite3ParserCTX_FETCH
switch( yymajor ){
/* Here is inserted the actions which take place when a
** terminal or non-terminal is destroyed. This can happen
@@ -141484,72 +143135,73 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 163: /* select */
- case 195: /* selectnowith */
- case 196: /* oneselect */
- case 207: /* values */
+ case 164: /* select */
+ case 196: /* selectnowith */
+ case 197: /* oneselect */
+ case 208: /* values */
{
-sqlite3SelectDelete(pParse->db, (yypminor->yy387));
+sqlite3SelectDelete(pParse->db, (yypminor->yy399));
}
break;
- case 173: /* term */
- case 174: /* expr */
- case 202: /* where_opt */
- case 204: /* having_opt */
- case 216: /* on_opt */
- case 227: /* case_operand */
- case 229: /* case_else */
- case 238: /* when_clause */
- case 243: /* key_opt */
+ case 174: /* term */
+ case 175: /* expr */
+ case 203: /* where_opt */
+ case 205: /* having_opt */
+ case 217: /* on_opt */
+ case 230: /* case_operand */
+ case 232: /* case_else */
+ case 241: /* when_clause */
+ case 246: /* key_opt */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy314));
+sqlite3ExprDelete(pParse->db, (yypminor->yy182));
}
break;
- case 178: /* eidlist_opt */
- case 187: /* sortlist */
- case 188: /* eidlist */
- case 200: /* selcollist */
- case 203: /* groupby_opt */
- case 205: /* orderby_opt */
- case 208: /* nexprlist */
- case 209: /* exprlist */
- case 210: /* sclp */
- case 220: /* setlist */
- case 226: /* paren_exprlist */
- case 228: /* case_exprlist */
+ case 179: /* eidlist_opt */
+ case 188: /* sortlist */
+ case 189: /* eidlist */
+ case 201: /* selcollist */
+ case 204: /* groupby_opt */
+ case 206: /* orderby_opt */
+ case 209: /* nexprlist */
+ case 210: /* exprlist */
+ case 211: /* sclp */
+ case 222: /* setlist */
+ case 229: /* paren_exprlist */
+ case 231: /* case_exprlist */
{
-sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
}
break;
- case 194: /* fullname */
- case 201: /* from */
- case 212: /* seltablist */
- case 213: /* stl_prefix */
+ case 195: /* fullname */
+ case 202: /* from */
+ case 213: /* seltablist */
+ case 214: /* stl_prefix */
+ case 219: /* xfullname */
{
-sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
}
break;
- case 197: /* wqlist */
+ case 198: /* wqlist */
{
-sqlite3WithDelete(pParse->db, (yypminor->yy451));
+sqlite3WithDelete(pParse->db, (yypminor->yy91));
}
break;
- case 217: /* using_opt */
- case 218: /* idlist */
- case 222: /* idlist_opt */
+ case 218: /* using_opt */
+ case 220: /* idlist */
+ case 224: /* idlist_opt */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy384));
+sqlite3IdListDelete(pParse->db, (yypminor->yy510));
}
break;
- case 234: /* trigger_cmd_list */
- case 239: /* trigger_cmd */
+ case 237: /* trigger_cmd_list */
+ case 242: /* trigger_cmd */
{
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
}
break;
- case 236: /* trigger_event */
+ case 239: /* trigger_event */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
}
break;
/********* End destructor definitions *****************************************/
@@ -141661,13 +143313,12 @@ SQLITE_PRIVATE int sqlite3ParserCoverage(FILE *out){
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
-static unsigned int yy_find_shift_action(
- yyParser *pParser, /* The parser */
- YYCODETYPE iLookAhead /* The look-ahead token */
+static YYACTIONTYPE yy_find_shift_action(
+ YYCODETYPE iLookAhead, /* The look-ahead token */
+ YYACTIONTYPE stateno /* Current state number */
){
int i;
- int stateno = pParser->yytos->stateno;
-
+
if( stateno>YY_MAX_SHIFT ) return stateno;
assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
@@ -141731,7 +143382,7 @@ static unsigned int yy_find_shift_action(
** look-ahead token iLookAhead.
*/
static int yy_find_reduce_action(
- int stateno, /* Current state number */
+ YYACTIONTYPE stateno, /* Current state number */
YYCODETYPE iLookAhead /* The look-ahead token */
){
int i;
@@ -141760,7 +143411,8 @@ static int yy_find_reduce_action(
** The following routine is called if the stack overflows.
*/
static void yyStackOverflow(yyParser *yypParser){
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
+ sqlite3ParserCTX_FETCH
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
@@ -141773,7 +143425,8 @@ static void yyStackOverflow(yyParser *yypParser){
sqlite3ErrorMsg(pParse, "parser stack overflow");
/******** End %stack_overflow code ********************************************/
- sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
+ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */
+ sqlite3ParserCTX_STORE
}
/*
@@ -141802,8 +143455,8 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
*/
static void yy_shift(
yyParser *yypParser, /* The parser to be shifted */
- int yyNewState, /* The new state to shift in */
- int yyMajor, /* The major token to shift in */
+ YYACTIONTYPE yyNewState, /* The new state to shift in */
+ YYCODETYPE yyMajor, /* The major token to shift in */
sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
){
yyStackEntry *yytos;
@@ -141833,8 +143486,8 @@ static void yy_shift(
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
}
yytos = yypParser->yytos;
- yytos->stateno = (YYACTIONTYPE)yyNewState;
- yytos->major = (YYCODETYPE)yyMajor;
+ yytos->stateno = yyNewState;
+ yytos->major = yyMajor;
yytos->minor.yy0 = yyMinor;
yyTraceShift(yypParser, yyNewState, "Shift");
}
@@ -141846,339 +143499,347 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 147, -1 }, /* (0) explain ::= EXPLAIN */
- { 147, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
+ { 149, -1 }, /* (0) explain ::= EXPLAIN */
+ { 149, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
{ 148, -1 }, /* (2) cmdx ::= cmd */
- { 149, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
- { 150, 0 }, /* (4) transtype ::= */
- { 150, -1 }, /* (5) transtype ::= DEFERRED */
- { 150, -1 }, /* (6) transtype ::= IMMEDIATE */
- { 150, -1 }, /* (7) transtype ::= EXCLUSIVE */
- { 149, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
- { 149, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
- { 149, -2 }, /* (10) cmd ::= SAVEPOINT nm */
- { 149, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
- { 149, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
- { 154, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
- { 156, -1 }, /* (14) createkw ::= CREATE */
- { 158, 0 }, /* (15) ifnotexists ::= */
- { 158, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
- { 157, -1 }, /* (17) temp ::= TEMP */
- { 157, 0 }, /* (18) temp ::= */
- { 155, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
- { 155, -2 }, /* (20) create_table_args ::= AS select */
- { 162, 0 }, /* (21) table_options ::= */
- { 162, -2 }, /* (22) table_options ::= WITHOUT nm */
- { 164, -2 }, /* (23) columnname ::= nm typetoken */
- { 166, 0 }, /* (24) typetoken ::= */
- { 166, -4 }, /* (25) typetoken ::= typename LP signed RP */
- { 166, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
- { 167, -2 }, /* (27) typename ::= typename ID|STRING */
- { 171, 0 }, /* (28) scanpt ::= */
- { 172, -2 }, /* (29) ccons ::= CONSTRAINT nm */
- { 172, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
- { 172, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
- { 172, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
- { 172, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
- { 172, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
- { 172, -3 }, /* (35) ccons ::= NOT NULL onconf */
- { 172, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
- { 172, -2 }, /* (37) ccons ::= UNIQUE onconf */
- { 172, -4 }, /* (38) ccons ::= CHECK LP expr RP */
- { 172, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
- { 172, -1 }, /* (40) ccons ::= defer_subclause */
- { 172, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
- { 177, 0 }, /* (42) autoinc ::= */
- { 177, -1 }, /* (43) autoinc ::= AUTOINCR */
- { 179, 0 }, /* (44) refargs ::= */
- { 179, -2 }, /* (45) refargs ::= refargs refarg */
- { 181, -2 }, /* (46) refarg ::= MATCH nm */
- { 181, -3 }, /* (47) refarg ::= ON INSERT refact */
- { 181, -3 }, /* (48) refarg ::= ON DELETE refact */
- { 181, -3 }, /* (49) refarg ::= ON UPDATE refact */
- { 182, -2 }, /* (50) refact ::= SET NULL */
- { 182, -2 }, /* (51) refact ::= SET DEFAULT */
- { 182, -1 }, /* (52) refact ::= CASCADE */
- { 182, -1 }, /* (53) refact ::= RESTRICT */
- { 182, -2 }, /* (54) refact ::= NO ACTION */
- { 180, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
- { 180, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
- { 183, 0 }, /* (57) init_deferred_pred_opt ::= */
- { 183, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
- { 183, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
- { 161, 0 }, /* (60) conslist_opt ::= */
- { 185, -1 }, /* (61) tconscomma ::= COMMA */
- { 186, -2 }, /* (62) tcons ::= CONSTRAINT nm */
- { 186, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
- { 186, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
- { 186, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
- { 186, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
- { 189, 0 }, /* (67) defer_subclause_opt ::= */
- { 175, 0 }, /* (68) onconf ::= */
- { 175, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
- { 190, 0 }, /* (70) orconf ::= */
- { 190, -2 }, /* (71) orconf ::= OR resolvetype */
- { 191, -1 }, /* (72) resolvetype ::= IGNORE */
- { 191, -1 }, /* (73) resolvetype ::= REPLACE */
- { 149, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
- { 193, -2 }, /* (75) ifexists ::= IF EXISTS */
- { 193, 0 }, /* (76) ifexists ::= */
- { 149, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
- { 149, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
- { 149, -1 }, /* (79) cmd ::= select */
- { 163, -3 }, /* (80) select ::= WITH wqlist selectnowith */
- { 163, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
- { 163, -1 }, /* (82) select ::= selectnowith */
- { 195, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
- { 198, -1 }, /* (84) multiselect_op ::= UNION */
- { 198, -2 }, /* (85) multiselect_op ::= UNION ALL */
- { 198, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
- { 196, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
- { 207, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
- { 207, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
- { 199, -1 }, /* (90) distinct ::= DISTINCT */
- { 199, -1 }, /* (91) distinct ::= ALL */
- { 199, 0 }, /* (92) distinct ::= */
- { 210, 0 }, /* (93) sclp ::= */
- { 200, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
- { 200, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
- { 200, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
- { 211, -2 }, /* (97) as ::= AS nm */
- { 211, 0 }, /* (98) as ::= */
- { 201, 0 }, /* (99) from ::= */
- { 201, -2 }, /* (100) from ::= FROM seltablist */
- { 213, -2 }, /* (101) stl_prefix ::= seltablist joinop */
- { 213, 0 }, /* (102) stl_prefix ::= */
- { 212, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
- { 212, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
- { 212, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
- { 212, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
- { 159, 0 }, /* (107) dbnm ::= */
- { 159, -2 }, /* (108) dbnm ::= DOT nm */
- { 194, -1 }, /* (109) fullname ::= nm */
- { 194, -3 }, /* (110) fullname ::= nm DOT nm */
- { 214, -1 }, /* (111) joinop ::= COMMA|JOIN */
- { 214, -2 }, /* (112) joinop ::= JOIN_KW JOIN */
- { 214, -3 }, /* (113) joinop ::= JOIN_KW nm JOIN */
- { 214, -4 }, /* (114) joinop ::= JOIN_KW nm nm JOIN */
- { 216, -2 }, /* (115) on_opt ::= ON expr */
- { 216, 0 }, /* (116) on_opt ::= */
- { 215, 0 }, /* (117) indexed_opt ::= */
- { 215, -3 }, /* (118) indexed_opt ::= INDEXED BY nm */
- { 215, -2 }, /* (119) indexed_opt ::= NOT INDEXED */
- { 217, -4 }, /* (120) using_opt ::= USING LP idlist RP */
- { 217, 0 }, /* (121) using_opt ::= */
- { 205, 0 }, /* (122) orderby_opt ::= */
- { 205, -3 }, /* (123) orderby_opt ::= ORDER BY sortlist */
- { 187, -4 }, /* (124) sortlist ::= sortlist COMMA expr sortorder */
- { 187, -2 }, /* (125) sortlist ::= expr sortorder */
- { 176, -1 }, /* (126) sortorder ::= ASC */
- { 176, -1 }, /* (127) sortorder ::= DESC */
- { 176, 0 }, /* (128) sortorder ::= */
- { 203, 0 }, /* (129) groupby_opt ::= */
- { 203, -3 }, /* (130) groupby_opt ::= GROUP BY nexprlist */
- { 204, 0 }, /* (131) having_opt ::= */
- { 204, -2 }, /* (132) having_opt ::= HAVING expr */
- { 206, 0 }, /* (133) limit_opt ::= */
- { 206, -2 }, /* (134) limit_opt ::= LIMIT expr */
- { 206, -4 }, /* (135) limit_opt ::= LIMIT expr OFFSET expr */
- { 206, -4 }, /* (136) limit_opt ::= LIMIT expr COMMA expr */
- { 149, -6 }, /* (137) cmd ::= with DELETE FROM fullname indexed_opt where_opt */
- { 202, 0 }, /* (138) where_opt ::= */
- { 202, -2 }, /* (139) where_opt ::= WHERE expr */
- { 149, -8 }, /* (140) cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
- { 220, -5 }, /* (141) setlist ::= setlist COMMA nm EQ expr */
- { 220, -7 }, /* (142) setlist ::= setlist COMMA LP idlist RP EQ expr */
- { 220, -3 }, /* (143) setlist ::= nm EQ expr */
- { 220, -5 }, /* (144) setlist ::= LP idlist RP EQ expr */
- { 149, -6 }, /* (145) cmd ::= with insert_cmd INTO fullname idlist_opt select */
- { 149, -7 }, /* (146) cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
- { 221, -2 }, /* (147) insert_cmd ::= INSERT orconf */
- { 221, -1 }, /* (148) insert_cmd ::= REPLACE */
- { 222, 0 }, /* (149) idlist_opt ::= */
- { 222, -3 }, /* (150) idlist_opt ::= LP idlist RP */
- { 218, -3 }, /* (151) idlist ::= idlist COMMA nm */
- { 218, -1 }, /* (152) idlist ::= nm */
- { 174, -3 }, /* (153) expr ::= LP expr RP */
- { 174, -1 }, /* (154) expr ::= ID|INDEXED */
- { 174, -1 }, /* (155) expr ::= JOIN_KW */
- { 174, -3 }, /* (156) expr ::= nm DOT nm */
- { 174, -5 }, /* (157) expr ::= nm DOT nm DOT nm */
- { 173, -1 }, /* (158) term ::= NULL|FLOAT|BLOB */
- { 173, -1 }, /* (159) term ::= STRING */
- { 173, -1 }, /* (160) term ::= INTEGER */
- { 174, -1 }, /* (161) expr ::= VARIABLE */
- { 174, -3 }, /* (162) expr ::= expr COLLATE ID|STRING */
- { 174, -6 }, /* (163) expr ::= CAST LP expr AS typetoken RP */
- { 174, -5 }, /* (164) expr ::= ID|INDEXED LP distinct exprlist RP */
- { 174, -4 }, /* (165) expr ::= ID|INDEXED LP STAR RP */
- { 173, -1 }, /* (166) term ::= CTIME_KW */
- { 174, -5 }, /* (167) expr ::= LP nexprlist COMMA expr RP */
- { 174, -3 }, /* (168) expr ::= expr AND expr */
- { 174, -3 }, /* (169) expr ::= expr OR expr */
- { 174, -3 }, /* (170) expr ::= expr LT|GT|GE|LE expr */
- { 174, -3 }, /* (171) expr ::= expr EQ|NE expr */
- { 174, -3 }, /* (172) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
- { 174, -3 }, /* (173) expr ::= expr PLUS|MINUS expr */
- { 174, -3 }, /* (174) expr ::= expr STAR|SLASH|REM expr */
- { 174, -3 }, /* (175) expr ::= expr CONCAT expr */
- { 223, -2 }, /* (176) likeop ::= NOT LIKE_KW|MATCH */
- { 174, -3 }, /* (177) expr ::= expr likeop expr */
- { 174, -5 }, /* (178) expr ::= expr likeop expr ESCAPE expr */
- { 174, -2 }, /* (179) expr ::= expr ISNULL|NOTNULL */
- { 174, -3 }, /* (180) expr ::= expr NOT NULL */
- { 174, -3 }, /* (181) expr ::= expr IS expr */
- { 174, -4 }, /* (182) expr ::= expr IS NOT expr */
- { 174, -2 }, /* (183) expr ::= NOT expr */
- { 174, -2 }, /* (184) expr ::= BITNOT expr */
- { 174, -2 }, /* (185) expr ::= MINUS expr */
- { 174, -2 }, /* (186) expr ::= PLUS expr */
- { 224, -1 }, /* (187) between_op ::= BETWEEN */
- { 224, -2 }, /* (188) between_op ::= NOT BETWEEN */
- { 174, -5 }, /* (189) expr ::= expr between_op expr AND expr */
- { 225, -1 }, /* (190) in_op ::= IN */
- { 225, -2 }, /* (191) in_op ::= NOT IN */
- { 174, -5 }, /* (192) expr ::= expr in_op LP exprlist RP */
- { 174, -3 }, /* (193) expr ::= LP select RP */
- { 174, -5 }, /* (194) expr ::= expr in_op LP select RP */
- { 174, -5 }, /* (195) expr ::= expr in_op nm dbnm paren_exprlist */
- { 174, -4 }, /* (196) expr ::= EXISTS LP select RP */
- { 174, -5 }, /* (197) expr ::= CASE case_operand case_exprlist case_else END */
- { 228, -5 }, /* (198) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- { 228, -4 }, /* (199) case_exprlist ::= WHEN expr THEN expr */
- { 229, -2 }, /* (200) case_else ::= ELSE expr */
- { 229, 0 }, /* (201) case_else ::= */
- { 227, -1 }, /* (202) case_operand ::= expr */
- { 227, 0 }, /* (203) case_operand ::= */
- { 209, 0 }, /* (204) exprlist ::= */
- { 208, -3 }, /* (205) nexprlist ::= nexprlist COMMA expr */
- { 208, -1 }, /* (206) nexprlist ::= expr */
- { 226, 0 }, /* (207) paren_exprlist ::= */
- { 226, -3 }, /* (208) paren_exprlist ::= LP exprlist RP */
- { 149, -12 }, /* (209) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- { 230, -1 }, /* (210) uniqueflag ::= UNIQUE */
- { 230, 0 }, /* (211) uniqueflag ::= */
- { 178, 0 }, /* (212) eidlist_opt ::= */
- { 178, -3 }, /* (213) eidlist_opt ::= LP eidlist RP */
- { 188, -5 }, /* (214) eidlist ::= eidlist COMMA nm collate sortorder */
- { 188, -3 }, /* (215) eidlist ::= nm collate sortorder */
- { 231, 0 }, /* (216) collate ::= */
- { 231, -2 }, /* (217) collate ::= COLLATE ID|STRING */
- { 149, -4 }, /* (218) cmd ::= DROP INDEX ifexists fullname */
- { 149, -1 }, /* (219) cmd ::= VACUUM */
- { 149, -2 }, /* (220) cmd ::= VACUUM nm */
- { 149, -3 }, /* (221) cmd ::= PRAGMA nm dbnm */
- { 149, -5 }, /* (222) cmd ::= PRAGMA nm dbnm EQ nmnum */
- { 149, -6 }, /* (223) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- { 149, -5 }, /* (224) cmd ::= PRAGMA nm dbnm EQ minus_num */
- { 149, -6 }, /* (225) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- { 169, -2 }, /* (226) plus_num ::= PLUS INTEGER|FLOAT */
- { 170, -2 }, /* (227) minus_num ::= MINUS INTEGER|FLOAT */
- { 149, -5 }, /* (228) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- { 233, -11 }, /* (229) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- { 235, -1 }, /* (230) trigger_time ::= BEFORE|AFTER */
- { 235, -2 }, /* (231) trigger_time ::= INSTEAD OF */
- { 235, 0 }, /* (232) trigger_time ::= */
- { 236, -1 }, /* (233) trigger_event ::= DELETE|INSERT */
- { 236, -1 }, /* (234) trigger_event ::= UPDATE */
- { 236, -3 }, /* (235) trigger_event ::= UPDATE OF idlist */
- { 238, 0 }, /* (236) when_clause ::= */
- { 238, -2 }, /* (237) when_clause ::= WHEN expr */
- { 234, -3 }, /* (238) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- { 234, -2 }, /* (239) trigger_cmd_list ::= trigger_cmd SEMI */
- { 240, -3 }, /* (240) trnm ::= nm DOT nm */
- { 241, -3 }, /* (241) tridxby ::= INDEXED BY nm */
- { 241, -2 }, /* (242) tridxby ::= NOT INDEXED */
- { 239, -8 }, /* (243) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
- { 239, -7 }, /* (244) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
- { 239, -6 }, /* (245) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- { 239, -3 }, /* (246) trigger_cmd ::= scanpt select scanpt */
- { 174, -4 }, /* (247) expr ::= RAISE LP IGNORE RP */
- { 174, -6 }, /* (248) expr ::= RAISE LP raisetype COMMA nm RP */
- { 192, -1 }, /* (249) raisetype ::= ROLLBACK */
- { 192, -1 }, /* (250) raisetype ::= ABORT */
- { 192, -1 }, /* (251) raisetype ::= FAIL */
- { 149, -4 }, /* (252) cmd ::= DROP TRIGGER ifexists fullname */
- { 149, -6 }, /* (253) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- { 149, -3 }, /* (254) cmd ::= DETACH database_kw_opt expr */
- { 243, 0 }, /* (255) key_opt ::= */
- { 243, -2 }, /* (256) key_opt ::= KEY expr */
- { 149, -1 }, /* (257) cmd ::= REINDEX */
- { 149, -3 }, /* (258) cmd ::= REINDEX nm dbnm */
- { 149, -1 }, /* (259) cmd ::= ANALYZE */
- { 149, -3 }, /* (260) cmd ::= ANALYZE nm dbnm */
- { 149, -6 }, /* (261) cmd ::= ALTER TABLE fullname RENAME TO nm */
- { 149, -7 }, /* (262) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- { 244, -1 }, /* (263) add_column_fullname ::= fullname */
- { 149, -1 }, /* (264) cmd ::= create_vtab */
- { 149, -4 }, /* (265) cmd ::= create_vtab LP vtabarglist RP */
- { 246, -8 }, /* (266) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- { 248, 0 }, /* (267) vtabarg ::= */
- { 249, -1 }, /* (268) vtabargtoken ::= ANY */
- { 249, -3 }, /* (269) vtabargtoken ::= lp anylist RP */
- { 250, -1 }, /* (270) lp ::= LP */
- { 219, -2 }, /* (271) with ::= WITH wqlist */
- { 219, -3 }, /* (272) with ::= WITH RECURSIVE wqlist */
- { 197, -6 }, /* (273) wqlist ::= nm eidlist_opt AS LP select RP */
- { 197, -8 }, /* (274) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
- { 144, -1 }, /* (275) input ::= cmdlist */
- { 145, -2 }, /* (276) cmdlist ::= cmdlist ecmd */
- { 145, -1 }, /* (277) cmdlist ::= ecmd */
- { 146, -1 }, /* (278) ecmd ::= SEMI */
- { 146, -3 }, /* (279) ecmd ::= explain cmdx SEMI */
- { 147, 0 }, /* (280) explain ::= */
- { 151, 0 }, /* (281) trans_opt ::= */
- { 151, -1 }, /* (282) trans_opt ::= TRANSACTION */
- { 151, -2 }, /* (283) trans_opt ::= TRANSACTION nm */
- { 153, -1 }, /* (284) savepoint_opt ::= SAVEPOINT */
- { 153, 0 }, /* (285) savepoint_opt ::= */
- { 149, -2 }, /* (286) cmd ::= create_table create_table_args */
- { 160, -4 }, /* (287) columnlist ::= columnlist COMMA columnname carglist */
- { 160, -2 }, /* (288) columnlist ::= columnname carglist */
- { 152, -1 }, /* (289) nm ::= ID|INDEXED */
- { 152, -1 }, /* (290) nm ::= STRING */
- { 152, -1 }, /* (291) nm ::= JOIN_KW */
- { 166, -1 }, /* (292) typetoken ::= typename */
- { 167, -1 }, /* (293) typename ::= ID|STRING */
- { 168, -1 }, /* (294) signed ::= plus_num */
- { 168, -1 }, /* (295) signed ::= minus_num */
- { 165, -2 }, /* (296) carglist ::= carglist ccons */
- { 165, 0 }, /* (297) carglist ::= */
- { 172, -2 }, /* (298) ccons ::= NULL onconf */
- { 161, -2 }, /* (299) conslist_opt ::= COMMA conslist */
- { 184, -3 }, /* (300) conslist ::= conslist tconscomma tcons */
- { 184, -1 }, /* (301) conslist ::= tcons */
- { 185, 0 }, /* (302) tconscomma ::= */
- { 189, -1 }, /* (303) defer_subclause_opt ::= defer_subclause */
- { 191, -1 }, /* (304) resolvetype ::= raisetype */
- { 195, -1 }, /* (305) selectnowith ::= oneselect */
- { 196, -1 }, /* (306) oneselect ::= values */
- { 210, -2 }, /* (307) sclp ::= selcollist COMMA */
- { 211, -1 }, /* (308) as ::= ID|STRING */
- { 174, -1 }, /* (309) expr ::= term */
- { 223, -1 }, /* (310) likeop ::= LIKE_KW|MATCH */
- { 209, -1 }, /* (311) exprlist ::= nexprlist */
- { 232, -1 }, /* (312) nmnum ::= plus_num */
- { 232, -1 }, /* (313) nmnum ::= nm */
- { 232, -1 }, /* (314) nmnum ::= ON */
- { 232, -1 }, /* (315) nmnum ::= DELETE */
- { 232, -1 }, /* (316) nmnum ::= DEFAULT */
- { 169, -1 }, /* (317) plus_num ::= INTEGER|FLOAT */
- { 237, 0 }, /* (318) foreach_clause ::= */
- { 237, -3 }, /* (319) foreach_clause ::= FOR EACH ROW */
- { 240, -1 }, /* (320) trnm ::= nm */
- { 241, 0 }, /* (321) tridxby ::= */
- { 242, -1 }, /* (322) database_kw_opt ::= DATABASE */
- { 242, 0 }, /* (323) database_kw_opt ::= */
- { 245, 0 }, /* (324) kwcolumn_opt ::= */
- { 245, -1 }, /* (325) kwcolumn_opt ::= COLUMNKW */
- { 247, -1 }, /* (326) vtabarglist ::= vtabarg */
- { 247, -3 }, /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */
- { 248, -2 }, /* (328) vtabarg ::= vtabarg vtabargtoken */
- { 251, 0 }, /* (329) anylist ::= */
- { 251, -4 }, /* (330) anylist ::= anylist LP anylist RP */
- { 251, -2 }, /* (331) anylist ::= anylist ANY */
- { 219, 0 }, /* (332) with ::= */
+ { 150, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
+ { 151, 0 }, /* (4) transtype ::= */
+ { 151, -1 }, /* (5) transtype ::= DEFERRED */
+ { 151, -1 }, /* (6) transtype ::= IMMEDIATE */
+ { 151, -1 }, /* (7) transtype ::= EXCLUSIVE */
+ { 150, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
+ { 150, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
+ { 150, -2 }, /* (10) cmd ::= SAVEPOINT nm */
+ { 150, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
+ { 150, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ { 155, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ { 157, -1 }, /* (14) createkw ::= CREATE */
+ { 159, 0 }, /* (15) ifnotexists ::= */
+ { 159, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
+ { 158, -1 }, /* (17) temp ::= TEMP */
+ { 158, 0 }, /* (18) temp ::= */
+ { 156, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
+ { 156, -2 }, /* (20) create_table_args ::= AS select */
+ { 163, 0 }, /* (21) table_options ::= */
+ { 163, -2 }, /* (22) table_options ::= WITHOUT nm */
+ { 165, -2 }, /* (23) columnname ::= nm typetoken */
+ { 167, 0 }, /* (24) typetoken ::= */
+ { 167, -4 }, /* (25) typetoken ::= typename LP signed RP */
+ { 167, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
+ { 168, -2 }, /* (27) typename ::= typename ID|STRING */
+ { 172, 0 }, /* (28) scanpt ::= */
+ { 173, -2 }, /* (29) ccons ::= CONSTRAINT nm */
+ { 173, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
+ { 173, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
+ { 173, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
+ { 173, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
+ { 173, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
+ { 173, -3 }, /* (35) ccons ::= NOT NULL onconf */
+ { 173, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ { 173, -2 }, /* (37) ccons ::= UNIQUE onconf */
+ { 173, -4 }, /* (38) ccons ::= CHECK LP expr RP */
+ { 173, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
+ { 173, -1 }, /* (40) ccons ::= defer_subclause */
+ { 173, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
+ { 178, 0 }, /* (42) autoinc ::= */
+ { 178, -1 }, /* (43) autoinc ::= AUTOINCR */
+ { 180, 0 }, /* (44) refargs ::= */
+ { 180, -2 }, /* (45) refargs ::= refargs refarg */
+ { 182, -2 }, /* (46) refarg ::= MATCH nm */
+ { 182, -3 }, /* (47) refarg ::= ON INSERT refact */
+ { 182, -3 }, /* (48) refarg ::= ON DELETE refact */
+ { 182, -3 }, /* (49) refarg ::= ON UPDATE refact */
+ { 183, -2 }, /* (50) refact ::= SET NULL */
+ { 183, -2 }, /* (51) refact ::= SET DEFAULT */
+ { 183, -1 }, /* (52) refact ::= CASCADE */
+ { 183, -1 }, /* (53) refact ::= RESTRICT */
+ { 183, -2 }, /* (54) refact ::= NO ACTION */
+ { 181, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ { 181, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ { 184, 0 }, /* (57) init_deferred_pred_opt ::= */
+ { 184, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ { 184, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ { 162, 0 }, /* (60) conslist_opt ::= */
+ { 186, -1 }, /* (61) tconscomma ::= COMMA */
+ { 187, -2 }, /* (62) tcons ::= CONSTRAINT nm */
+ { 187, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ { 187, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
+ { 187, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
+ { 187, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ { 190, 0 }, /* (67) defer_subclause_opt ::= */
+ { 176, 0 }, /* (68) onconf ::= */
+ { 176, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
+ { 191, 0 }, /* (70) orconf ::= */
+ { 191, -2 }, /* (71) orconf ::= OR resolvetype */
+ { 192, -1 }, /* (72) resolvetype ::= IGNORE */
+ { 192, -1 }, /* (73) resolvetype ::= REPLACE */
+ { 150, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
+ { 194, -2 }, /* (75) ifexists ::= IF EXISTS */
+ { 194, 0 }, /* (76) ifexists ::= */
+ { 150, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ { 150, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
+ { 150, -1 }, /* (79) cmd ::= select */
+ { 164, -3 }, /* (80) select ::= WITH wqlist selectnowith */
+ { 164, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
+ { 164, -1 }, /* (82) select ::= selectnowith */
+ { 196, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
+ { 199, -1 }, /* (84) multiselect_op ::= UNION */
+ { 199, -2 }, /* (85) multiselect_op ::= UNION ALL */
+ { 199, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
+ { 197, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ { 208, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
+ { 208, -5 }, /* (89) values ::= values COMMA LP exprlist RP */
+ { 200, -1 }, /* (90) distinct ::= DISTINCT */
+ { 200, -1 }, /* (91) distinct ::= ALL */
+ { 200, 0 }, /* (92) distinct ::= */
+ { 211, 0 }, /* (93) sclp ::= */
+ { 201, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
+ { 201, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
+ { 201, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
+ { 212, -2 }, /* (97) as ::= AS nm */
+ { 212, 0 }, /* (98) as ::= */
+ { 202, 0 }, /* (99) from ::= */
+ { 202, -2 }, /* (100) from ::= FROM seltablist */
+ { 214, -2 }, /* (101) stl_prefix ::= seltablist joinop */
+ { 214, 0 }, /* (102) stl_prefix ::= */
+ { 213, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ { 213, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ { 213, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ { 213, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ { 160, 0 }, /* (107) dbnm ::= */
+ { 160, -2 }, /* (108) dbnm ::= DOT nm */
+ { 195, -1 }, /* (109) fullname ::= nm */
+ { 195, -3 }, /* (110) fullname ::= nm DOT nm */
+ { 219, -1 }, /* (111) xfullname ::= nm */
+ { 219, -3 }, /* (112) xfullname ::= nm DOT nm */
+ { 219, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
+ { 219, -3 }, /* (114) xfullname ::= nm AS nm */
+ { 215, -1 }, /* (115) joinop ::= COMMA|JOIN */
+ { 215, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
+ { 215, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
+ { 215, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
+ { 217, -2 }, /* (119) on_opt ::= ON expr */
+ { 217, 0 }, /* (120) on_opt ::= */
+ { 216, 0 }, /* (121) indexed_opt ::= */
+ { 216, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
+ { 216, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
+ { 218, -4 }, /* (124) using_opt ::= USING LP idlist RP */
+ { 218, 0 }, /* (125) using_opt ::= */
+ { 206, 0 }, /* (126) orderby_opt ::= */
+ { 206, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
+ { 188, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
+ { 188, -2 }, /* (129) sortlist ::= expr sortorder */
+ { 177, -1 }, /* (130) sortorder ::= ASC */
+ { 177, -1 }, /* (131) sortorder ::= DESC */
+ { 177, 0 }, /* (132) sortorder ::= */
+ { 204, 0 }, /* (133) groupby_opt ::= */
+ { 204, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
+ { 205, 0 }, /* (135) having_opt ::= */
+ { 205, -2 }, /* (136) having_opt ::= HAVING expr */
+ { 207, 0 }, /* (137) limit_opt ::= */
+ { 207, -2 }, /* (138) limit_opt ::= LIMIT expr */
+ { 207, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
+ { 207, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
+ { 150, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
+ { 203, 0 }, /* (142) where_opt ::= */
+ { 203, -2 }, /* (143) where_opt ::= WHERE expr */
+ { 150, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
+ { 222, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
+ { 222, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ { 222, -3 }, /* (147) setlist ::= nm EQ expr */
+ { 222, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
+ { 150, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ { 150, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
+ { 225, 0 }, /* (151) upsert ::= */
+ { 225, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+ { 225, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+ { 225, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
+ { 223, -2 }, /* (155) insert_cmd ::= INSERT orconf */
+ { 223, -1 }, /* (156) insert_cmd ::= REPLACE */
+ { 224, 0 }, /* (157) idlist_opt ::= */
+ { 224, -3 }, /* (158) idlist_opt ::= LP idlist RP */
+ { 220, -3 }, /* (159) idlist ::= idlist COMMA nm */
+ { 220, -1 }, /* (160) idlist ::= nm */
+ { 175, -3 }, /* (161) expr ::= LP expr RP */
+ { 175, -1 }, /* (162) expr ::= ID|INDEXED */
+ { 175, -1 }, /* (163) expr ::= JOIN_KW */
+ { 175, -3 }, /* (164) expr ::= nm DOT nm */
+ { 175, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
+ { 174, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
+ { 174, -1 }, /* (167) term ::= STRING */
+ { 174, -1 }, /* (168) term ::= INTEGER */
+ { 175, -1 }, /* (169) expr ::= VARIABLE */
+ { 175, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
+ { 175, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
+ { 175, -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
+ { 175, -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
+ { 174, -1 }, /* (174) term ::= CTIME_KW */
+ { 175, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
+ { 175, -3 }, /* (176) expr ::= expr AND expr */
+ { 175, -3 }, /* (177) expr ::= expr OR expr */
+ { 175, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
+ { 175, -3 }, /* (179) expr ::= expr EQ|NE expr */
+ { 175, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ { 175, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
+ { 175, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
+ { 175, -3 }, /* (183) expr ::= expr CONCAT expr */
+ { 226, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
+ { 175, -3 }, /* (185) expr ::= expr likeop expr */
+ { 175, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
+ { 175, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
+ { 175, -3 }, /* (188) expr ::= expr NOT NULL */
+ { 175, -3 }, /* (189) expr ::= expr IS expr */
+ { 175, -4 }, /* (190) expr ::= expr IS NOT expr */
+ { 175, -2 }, /* (191) expr ::= NOT expr */
+ { 175, -2 }, /* (192) expr ::= BITNOT expr */
+ { 175, -2 }, /* (193) expr ::= MINUS expr */
+ { 175, -2 }, /* (194) expr ::= PLUS expr */
+ { 227, -1 }, /* (195) between_op ::= BETWEEN */
+ { 227, -2 }, /* (196) between_op ::= NOT BETWEEN */
+ { 175, -5 }, /* (197) expr ::= expr between_op expr AND expr */
+ { 228, -1 }, /* (198) in_op ::= IN */
+ { 228, -2 }, /* (199) in_op ::= NOT IN */
+ { 175, -5 }, /* (200) expr ::= expr in_op LP exprlist RP */
+ { 175, -3 }, /* (201) expr ::= LP select RP */
+ { 175, -5 }, /* (202) expr ::= expr in_op LP select RP */
+ { 175, -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */
+ { 175, -4 }, /* (204) expr ::= EXISTS LP select RP */
+ { 175, -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */
+ { 231, -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ { 231, -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */
+ { 232, -2 }, /* (208) case_else ::= ELSE expr */
+ { 232, 0 }, /* (209) case_else ::= */
+ { 230, -1 }, /* (210) case_operand ::= expr */
+ { 230, 0 }, /* (211) case_operand ::= */
+ { 210, 0 }, /* (212) exprlist ::= */
+ { 209, -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */
+ { 209, -1 }, /* (214) nexprlist ::= expr */
+ { 229, 0 }, /* (215) paren_exprlist ::= */
+ { 229, -3 }, /* (216) paren_exprlist ::= LP exprlist RP */
+ { 150, -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ { 233, -1 }, /* (218) uniqueflag ::= UNIQUE */
+ { 233, 0 }, /* (219) uniqueflag ::= */
+ { 179, 0 }, /* (220) eidlist_opt ::= */
+ { 179, -3 }, /* (221) eidlist_opt ::= LP eidlist RP */
+ { 189, -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */
+ { 189, -3 }, /* (223) eidlist ::= nm collate sortorder */
+ { 234, 0 }, /* (224) collate ::= */
+ { 234, -2 }, /* (225) collate ::= COLLATE ID|STRING */
+ { 150, -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */
+ { 150, -1 }, /* (227) cmd ::= VACUUM */
+ { 150, -2 }, /* (228) cmd ::= VACUUM nm */
+ { 150, -3 }, /* (229) cmd ::= PRAGMA nm dbnm */
+ { 150, -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ { 150, -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ { 150, -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ { 150, -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ { 170, -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */
+ { 171, -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */
+ { 150, -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ { 236, -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ { 238, -1 }, /* (238) trigger_time ::= BEFORE|AFTER */
+ { 238, -2 }, /* (239) trigger_time ::= INSTEAD OF */
+ { 238, 0 }, /* (240) trigger_time ::= */
+ { 239, -1 }, /* (241) trigger_event ::= DELETE|INSERT */
+ { 239, -1 }, /* (242) trigger_event ::= UPDATE */
+ { 239, -3 }, /* (243) trigger_event ::= UPDATE OF idlist */
+ { 241, 0 }, /* (244) when_clause ::= */
+ { 241, -2 }, /* (245) when_clause ::= WHEN expr */
+ { 237, -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ { 237, -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */
+ { 243, -3 }, /* (248) trnm ::= nm DOT nm */
+ { 244, -3 }, /* (249) tridxby ::= INDEXED BY nm */
+ { 244, -2 }, /* (250) tridxby ::= NOT INDEXED */
+ { 242, -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+ { 242, -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ { 242, -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ { 242, -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */
+ { 175, -4 }, /* (255) expr ::= RAISE LP IGNORE RP */
+ { 175, -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */
+ { 193, -1 }, /* (257) raisetype ::= ROLLBACK */
+ { 193, -1 }, /* (258) raisetype ::= ABORT */
+ { 193, -1 }, /* (259) raisetype ::= FAIL */
+ { 150, -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */
+ { 150, -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ { 150, -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */
+ { 246, 0 }, /* (263) key_opt ::= */
+ { 246, -2 }, /* (264) key_opt ::= KEY expr */
+ { 150, -1 }, /* (265) cmd ::= REINDEX */
+ { 150, -3 }, /* (266) cmd ::= REINDEX nm dbnm */
+ { 150, -1 }, /* (267) cmd ::= ANALYZE */
+ { 150, -3 }, /* (268) cmd ::= ANALYZE nm dbnm */
+ { 150, -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ { 150, -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ { 247, -1 }, /* (271) add_column_fullname ::= fullname */
+ { 150, -1 }, /* (272) cmd ::= create_vtab */
+ { 150, -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
+ { 249, -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ { 251, 0 }, /* (275) vtabarg ::= */
+ { 252, -1 }, /* (276) vtabargtoken ::= ANY */
+ { 252, -3 }, /* (277) vtabargtoken ::= lp anylist RP */
+ { 253, -1 }, /* (278) lp ::= LP */
+ { 221, -2 }, /* (279) with ::= WITH wqlist */
+ { 221, -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
+ { 198, -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
+ { 198, -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ { 145, -1 }, /* (283) input ::= cmdlist */
+ { 146, -2 }, /* (284) cmdlist ::= cmdlist ecmd */
+ { 146, -1 }, /* (285) cmdlist ::= ecmd */
+ { 147, -1 }, /* (286) ecmd ::= SEMI */
+ { 147, -2 }, /* (287) ecmd ::= cmdx SEMI */
+ { 147, -2 }, /* (288) ecmd ::= explain cmdx */
+ { 152, 0 }, /* (289) trans_opt ::= */
+ { 152, -1 }, /* (290) trans_opt ::= TRANSACTION */
+ { 152, -2 }, /* (291) trans_opt ::= TRANSACTION nm */
+ { 154, -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
+ { 154, 0 }, /* (293) savepoint_opt ::= */
+ { 150, -2 }, /* (294) cmd ::= create_table create_table_args */
+ { 161, -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
+ { 161, -2 }, /* (296) columnlist ::= columnname carglist */
+ { 153, -1 }, /* (297) nm ::= ID|INDEXED */
+ { 153, -1 }, /* (298) nm ::= STRING */
+ { 153, -1 }, /* (299) nm ::= JOIN_KW */
+ { 167, -1 }, /* (300) typetoken ::= typename */
+ { 168, -1 }, /* (301) typename ::= ID|STRING */
+ { 169, -1 }, /* (302) signed ::= plus_num */
+ { 169, -1 }, /* (303) signed ::= minus_num */
+ { 166, -2 }, /* (304) carglist ::= carglist ccons */
+ { 166, 0 }, /* (305) carglist ::= */
+ { 173, -2 }, /* (306) ccons ::= NULL onconf */
+ { 162, -2 }, /* (307) conslist_opt ::= COMMA conslist */
+ { 185, -3 }, /* (308) conslist ::= conslist tconscomma tcons */
+ { 185, -1 }, /* (309) conslist ::= tcons */
+ { 186, 0 }, /* (310) tconscomma ::= */
+ { 190, -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
+ { 192, -1 }, /* (312) resolvetype ::= raisetype */
+ { 196, -1 }, /* (313) selectnowith ::= oneselect */
+ { 197, -1 }, /* (314) oneselect ::= values */
+ { 211, -2 }, /* (315) sclp ::= selcollist COMMA */
+ { 212, -1 }, /* (316) as ::= ID|STRING */
+ { 175, -1 }, /* (317) expr ::= term */
+ { 226, -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
+ { 210, -1 }, /* (319) exprlist ::= nexprlist */
+ { 235, -1 }, /* (320) nmnum ::= plus_num */
+ { 235, -1 }, /* (321) nmnum ::= nm */
+ { 235, -1 }, /* (322) nmnum ::= ON */
+ { 235, -1 }, /* (323) nmnum ::= DELETE */
+ { 235, -1 }, /* (324) nmnum ::= DEFAULT */
+ { 170, -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
+ { 240, 0 }, /* (326) foreach_clause ::= */
+ { 240, -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
+ { 243, -1 }, /* (328) trnm ::= nm */
+ { 244, 0 }, /* (329) tridxby ::= */
+ { 245, -1 }, /* (330) database_kw_opt ::= DATABASE */
+ { 245, 0 }, /* (331) database_kw_opt ::= */
+ { 248, 0 }, /* (332) kwcolumn_opt ::= */
+ { 248, -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
+ { 250, -1 }, /* (334) vtabarglist ::= vtabarg */
+ { 250, -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
+ { 251, -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
+ { 254, 0 }, /* (337) anylist ::= */
+ { 254, -4 }, /* (338) anylist ::= anylist LP anylist RP */
+ { 254, -2 }, /* (339) anylist ::= anylist ANY */
+ { 221, 0 }, /* (340) with ::= */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -142193,17 +143854,18 @@ static void yy_accept(yyParser*); /* Forward Declaration */
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
-static void yy_reduce(
+static YYACTIONTYPE yy_reduce(
yyParser *yypParser, /* The parser */
unsigned int yyruleno, /* Number of the rule by which to reduce */
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
sqlite3ParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
+ sqlite3ParserCTX_PDECL /* %extra_context */
){
int yygoto; /* The next state */
int yyact; /* The next action */
yyStackEntry *yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
(void)yyLookahead;
(void)yyLookaheadToken;
yymsp = yypParser->yytos;
@@ -142234,13 +143896,19 @@ static void yy_reduce(
#if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser);
- return;
+ /* The call to yyStackOverflow() above pops the stack until it is
+ ** empty, causing the main parser loop to exit. So the return value
+ ** is never used and does not matter. */
+ return 0;
}
#else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser);
- return;
+ /* The call to yyStackOverflow() above pops the stack until it is
+ ** empty, causing the main parser loop to exit. So the return value
+ ** is never used and does not matter. */
+ return 0;
}
yymsp = yypParser->yytos;
}
@@ -142268,15 +143936,15 @@ static void yy_reduce(
{ sqlite3FinishCoding(pParse); }
break;
case 3: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
break;
case 4: /* transtype ::= */
-{yymsp[1].minor.yy4 = TK_DEFERRED;}
+{yymsp[1].minor.yy502 = TK_DEFERRED;}
break;
case 5: /* transtype ::= DEFERRED */
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
-{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/}
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
break;
case 8: /* cmd ::= COMMIT|END trans_opt */
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
@@ -142299,7 +143967,7 @@ static void yy_reduce(
break;
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4);
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
}
break;
case 14: /* createkw ::= CREATE */
@@ -142313,33 +143981,33 @@ static void yy_reduce(
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
case 92: /* distinct ::= */ yytestcase(yyruleno==92);
- case 216: /* collate ::= */ yytestcase(yyruleno==216);
-{yymsp[1].minor.yy4 = 0;}
+ case 224: /* collate ::= */ yytestcase(yyruleno==224);
+{yymsp[1].minor.yy502 = 0;}
break;
case 16: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy4 = 1;}
+{yymsp[-2].minor.yy502 = 1;}
break;
case 17: /* temp ::= TEMP */
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
-{yymsp[0].minor.yy4 = 1;}
+{yymsp[0].minor.yy502 = 1;}
break;
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
{
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy4,0);
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
}
break;
case 20: /* create_table_args ::= AS select */
{
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy387);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
break;
case 22: /* table_options ::= WITHOUT nm */
{
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
- yymsp[-1].minor.yy4 = TF_WithoutRowid | TF_NoVisibleRowid;
+ yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
}else{
- yymsp[-1].minor.yy4 = 0;
+ yymsp[-1].minor.yy502 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
@@ -142368,7 +144036,7 @@ static void yy_reduce(
case 28: /* scanpt ::= */
{
assert( yyLookahead!=YYNOCODE );
- yymsp[1].minor.yy336 = yyLookaheadToken.z;
+ yymsp[1].minor.yy36 = yyLookaheadToken.z;
}
break;
case 29: /* ccons ::= CONSTRAINT nm */
@@ -142376,18 +144044,18 @@ static void yy_reduce(
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
case 30: /* ccons ::= DEFAULT scanpt term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy336,yymsp[0].minor.yy336);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
break;
case 31: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
break;
case 32: /* ccons ::= DEFAULT PLUS term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
break;
case 33: /* ccons ::= DEFAULT MINUS term scanpt */
{
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy314, 0);
- sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
+ sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
}
break;
case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
@@ -142401,170 +144069,170 @@ static void yy_reduce(
}
break;
case 35: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
break;
case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
break;
case 37: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 38: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy314);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
break;
case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
break;
case 40: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
break;
case 41: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
case 44: /* refargs ::= */
-{ yymsp[1].minor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
case 45: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; }
+{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
break;
case 46: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy215.value = 0; yymsp[-1].minor.yy215.mask = 0x000000; }
+{ yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; }
break;
case 47: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy215.value = 0; yymsp[-2].minor.yy215.mask = 0x000000; }
+{ yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; }
break;
case 48: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4; yymsp[-2].minor.yy215.mask = 0x0000ff; }
+{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; }
break;
case 49: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4<<8; yymsp[-2].minor.yy215.mask = 0x00ff00; }
+{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; }
break;
case 50: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy4 = OE_SetNull; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
break;
case 51: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
case 52: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy4 = OE_Cascade; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
break;
case 53: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy4 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
break;
case 54: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy4 = OE_None; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
break;
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy4 = 0;}
+{yymsp[-2].minor.yy502 = 0;}
break;
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
- case 147: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==147);
-{yymsp[-1].minor.yy4 = yymsp[0].minor.yy4;}
+ case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
+{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
break;
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
- case 188: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==188);
- case 191: /* in_op ::= NOT IN */ yytestcase(yyruleno==191);
- case 217: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==217);
-{yymsp[-1].minor.yy4 = 1;}
+ case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196);
+ case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199);
+ case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225);
+{yymsp[-1].minor.yy502 = 1;}
break;
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy4 = 0;}
+{yymsp[-1].minor.yy502 = 0;}
break;
case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
break;
case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 65: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy314);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
break;
case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4);
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4);
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
}
break;
case 68: /* onconf ::= */
case 70: /* orconf ::= */ yytestcase(yyruleno==70);
-{yymsp[1].minor.yy4 = OE_Default;}
+{yymsp[1].minor.yy502 = OE_Default;}
break;
case 69: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy4 = yymsp[0].minor.yy4;}
+{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
break;
case 72: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy4 = OE_Ignore;}
+{yymsp[0].minor.yy502 = OE_Ignore;}
break;
case 73: /* resolvetype ::= REPLACE */
- case 148: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==148);
-{yymsp[0].minor.yy4 = OE_Replace;}
+ case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
+{yymsp[0].minor.yy502 = OE_Replace;}
break;
case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
}
break;
case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
{
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy387, yymsp[-7].minor.yy4, yymsp[-5].minor.yy4);
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
}
break;
case 78: /* cmd ::= DROP VIEW ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
}
break;
case 79: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
- sqlite3Select(pParse, yymsp[0].minor.yy387, &dest);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
+ sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
break;
case 80: /* select ::= WITH wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy387;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
- p->pWith = yymsp[-1].minor.yy451;
+ p->pWith = yymsp[-1].minor.yy91;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
}
- yymsp[-2].minor.yy387 = p;
+ yymsp[-2].minor.yy399 = p;
}
break;
case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy387;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
- p->pWith = yymsp[-1].minor.yy451;
+ p->pWith = yymsp[-1].minor.yy91;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
}
- yymsp[-3].minor.yy387 = p;
+ yymsp[-3].minor.yy399 = p;
}
break;
case 82: /* select ::= selectnowith */
{
- Select *p = yymsp[0].minor.yy387;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
parserDoubleLinkSelect(pParse, p);
}
- yymsp[0].minor.yy387 = p; /*A-overwrites-X*/
+ yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
}
break;
case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
- Select *pRhs = yymsp[0].minor.yy387;
- Select *pLhs = yymsp[-2].minor.yy387;
+ Select *pRhs = yymsp[0].minor.yy399;
+ Select *pLhs = yymsp[-2].minor.yy399;
if( pRhs && pRhs->pPrior ){
SrcList *pFrom;
Token x;
@@ -142574,30 +144242,30 @@ static void yy_reduce(
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
}
if( pRhs ){
- pRhs->op = (u8)yymsp[-1].minor.yy4;
+ pRhs->op = (u8)yymsp[-1].minor.yy502;
pRhs->pPrior = pLhs;
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
pRhs->selFlags &= ~SF_MultiValue;
- if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1;
+ if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, pLhs);
}
- yymsp[-2].minor.yy387 = pRhs;
+ yymsp[-2].minor.yy399 = pRhs;
}
break;
case 84: /* multiselect_op ::= UNION */
case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
-{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-OP*/}
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
break;
case 85: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy4 = TK_ALL;}
+{yymsp[-1].minor.yy502 = TK_ALL;}
break;
case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
#if SELECTTRACE_ENABLED
Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
#endif
- yymsp[-8].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy314);
+ yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
#if SELECTTRACE_ENABLED
/* Populate the Select.zSelName[] string that is used to help with
** query planner debugging, to differentiate between multiple Select
@@ -142608,16 +144276,16 @@ static void yy_reduce(
** comment to be the zSelName value. Otherwise, the label is #N where
** is an integer that is incremented with each SELECT statement seen.
*/
- if( yymsp[-8].minor.yy387!=0 ){
+ if( yymsp[-8].minor.yy399!=0 ){
const char *z = s.z+6;
int i;
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName,"#%d",++pParse->nSelect);
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect);
while( z[0]==' ' ) z++;
if( z[0]=='/' && z[1]=='*' ){
z += 2;
while( z[0]==' ' ) z++;
for(i=0; sqlite3Isalnum(z[i]); i++){}
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName, "%.*s", i, z);
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName, "%.*s", i, z);
}
}
#endif /* SELECTRACE_ENABLED */
@@ -142625,48 +144293,48 @@ static void yy_reduce(
break;
case 88: /* values ::= VALUES LP nexprlist RP */
{
- yymsp[-3].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
+ yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
}
break;
case 89: /* values ::= values COMMA LP exprlist RP */
{
- Select *pRight, *pLeft = yymsp[-4].minor.yy387;
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
+ Select *pRight, *pLeft = yymsp[-4].minor.yy399;
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
if( pRight ){
pRight->op = TK_ALL;
pRight->pPrior = pLeft;
- yymsp[-4].minor.yy387 = pRight;
+ yymsp[-4].minor.yy399 = pRight;
}else{
- yymsp[-4].minor.yy387 = pLeft;
+ yymsp[-4].minor.yy399 = pLeft;
}
}
break;
case 90: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy4 = SF_Distinct;}
+{yymsp[0].minor.yy502 = SF_Distinct;}
break;
case 91: /* distinct ::= ALL */
-{yymsp[0].minor.yy4 = SF_All;}
+{yymsp[0].minor.yy502 = SF_All;}
break;
case 93: /* sclp ::= */
- case 122: /* orderby_opt ::= */ yytestcase(yyruleno==122);
- case 129: /* groupby_opt ::= */ yytestcase(yyruleno==129);
- case 204: /* exprlist ::= */ yytestcase(yyruleno==204);
- case 207: /* paren_exprlist ::= */ yytestcase(yyruleno==207);
- case 212: /* eidlist_opt ::= */ yytestcase(yyruleno==212);
-{yymsp[1].minor.yy322 = 0;}
+ case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
+ case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
+ case 212: /* exprlist ::= */ yytestcase(yyruleno==212);
+ case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215);
+ case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220);
+{yymsp[1].minor.yy232 = 0;}
break;
case 94: /* selcollist ::= sclp scanpt expr scanpt as */
{
- yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy336,yymsp[-1].minor.yy336);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
}
break;
case 95: /* selcollist ::= sclp scanpt STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
- yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
+ yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
}
break;
case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
@@ -142674,252 +144342,278 @@ static void yy_reduce(
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
- yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
}
break;
case 97: /* as ::= AS nm */
case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
- case 226: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==226);
- case 227: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==227);
+ case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
+ case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 99: /* from ::= */
-{yymsp[1].minor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy259));}
+{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
break;
case 100: /* from ::= FROM seltablist */
{
- yymsp[-1].minor.yy259 = yymsp[0].minor.yy259;
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy259);
+ yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
}
break;
case 101: /* stl_prefix ::= seltablist joinop */
{
- if( ALWAYS(yymsp[-1].minor.yy259 && yymsp[-1].minor.yy259->nSrc>0) ) yymsp[-1].minor.yy259->a[yymsp[-1].minor.yy259->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy4;
+ if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
}
break;
case 102: /* stl_prefix ::= */
-{yymsp[1].minor.yy259 = 0;}
+{yymsp[1].minor.yy427 = 0;}
break;
case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
- yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy259, &yymsp[-2].minor.yy0);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0);
}
break;
case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
- yymsp[-8].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy259,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy259, yymsp[-4].minor.yy322);
+ yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
}
break;
case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
- yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
}
break;
case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
- if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){
- yymsp[-6].minor.yy259 = yymsp[-4].minor.yy259;
- }else if( yymsp[-4].minor.yy259->nSrc==1 ){
- yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
- if( yymsp[-6].minor.yy259 ){
- struct SrcList_item *pNew = &yymsp[-6].minor.yy259->a[yymsp[-6].minor.yy259->nSrc-1];
- struct SrcList_item *pOld = yymsp[-4].minor.yy259->a;
+ if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
+ yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
+ }else if( yymsp[-4].minor.yy427->nSrc==1 ){
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ if( yymsp[-6].minor.yy427 ){
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
+ struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy259);
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
}else{
Select *pSubquery;
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259);
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,SF_NestedFrom,0);
- yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
}
}
break;
case 107: /* dbnm ::= */
- case 117: /* indexed_opt ::= */ yytestcase(yyruleno==117);
+ case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
break;
case 109: /* fullname ::= nm */
-{yymsp[0].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+ case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
+{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
break;
case 110: /* fullname ::= nm DOT nm */
-{yymsp[-2].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
+{yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ break;
+ case 113: /* xfullname ::= nm DOT nm AS nm */
+{
+ yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+ if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+}
+ break;
+ case 114: /* xfullname ::= nm AS nm */
+{
+ yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+ if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+}
break;
- case 111: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy4 = JT_INNER; }
+ case 115: /* joinop ::= COMMA|JOIN */
+{ yymsp[0].minor.yy502 = JT_INNER; }
break;
- case 112: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
+ case 116: /* joinop ::= JOIN_KW JOIN */
+{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
break;
- case 113: /* joinop ::= JOIN_KW nm JOIN */
-{yymsp[-2].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+ case 117: /* joinop ::= JOIN_KW nm JOIN */
+{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
break;
- case 114: /* joinop ::= JOIN_KW nm nm JOIN */
-{yymsp[-3].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+ case 118: /* joinop ::= JOIN_KW nm nm JOIN */
+{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
- case 115: /* on_opt ::= ON expr */
- case 132: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==132);
- case 139: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==139);
- case 200: /* case_else ::= ELSE expr */ yytestcase(yyruleno==200);
-{yymsp[-1].minor.yy314 = yymsp[0].minor.yy314;}
+ case 119: /* on_opt ::= ON expr */
+ case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
+ case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
+ case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208);
+{yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
break;
- case 116: /* on_opt ::= */
- case 131: /* having_opt ::= */ yytestcase(yyruleno==131);
- case 133: /* limit_opt ::= */ yytestcase(yyruleno==133);
- case 138: /* where_opt ::= */ yytestcase(yyruleno==138);
- case 201: /* case_else ::= */ yytestcase(yyruleno==201);
- case 203: /* case_operand ::= */ yytestcase(yyruleno==203);
-{yymsp[1].minor.yy314 = 0;}
+ case 120: /* on_opt ::= */
+ case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
+ case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
+ case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
+ case 209: /* case_else ::= */ yytestcase(yyruleno==209);
+ case 211: /* case_operand ::= */ yytestcase(yyruleno==211);
+{yymsp[1].minor.yy182 = 0;}
break;
- case 118: /* indexed_opt ::= INDEXED BY nm */
+ case 122: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
break;
- case 119: /* indexed_opt ::= NOT INDEXED */
+ case 123: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
break;
- case 120: /* using_opt ::= USING LP idlist RP */
-{yymsp[-3].minor.yy384 = yymsp[-1].minor.yy384;}
+ case 124: /* using_opt ::= USING LP idlist RP */
+{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
break;
- case 121: /* using_opt ::= */
- case 149: /* idlist_opt ::= */ yytestcase(yyruleno==149);
-{yymsp[1].minor.yy384 = 0;}
+ case 125: /* using_opt ::= */
+ case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
+{yymsp[1].minor.yy510 = 0;}
break;
- case 123: /* orderby_opt ::= ORDER BY sortlist */
- case 130: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==130);
-{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
+ case 127: /* orderby_opt ::= ORDER BY sortlist */
+ case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
+{yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
break;
- case 124: /* sortlist ::= sortlist COMMA expr sortorder */
+ case 128: /* sortlist ::= sortlist COMMA expr sortorder */
{
- yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314);
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy322,yymsp[0].minor.yy4);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
}
break;
- case 125: /* sortlist ::= expr sortorder */
+ case 129: /* sortlist ::= expr sortorder */
{
- yymsp[-1].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); /*A-overwrites-Y*/
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy322,yymsp[0].minor.yy4);
+ yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
}
break;
- case 126: /* sortorder ::= ASC */
-{yymsp[0].minor.yy4 = SQLITE_SO_ASC;}
+ case 130: /* sortorder ::= ASC */
+{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
break;
- case 127: /* sortorder ::= DESC */
-{yymsp[0].minor.yy4 = SQLITE_SO_DESC;}
+ case 131: /* sortorder ::= DESC */
+{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
break;
- case 128: /* sortorder ::= */
-{yymsp[1].minor.yy4 = SQLITE_SO_UNDEFINED;}
+ case 132: /* sortorder ::= */
+{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
break;
- case 134: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,0);}
+ case 138: /* limit_opt ::= LIMIT expr */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
break;
- case 135: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
+ case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
+{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
break;
- case 136: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,yymsp[-2].minor.yy314);}
+ case 140: /* limit_opt ::= LIMIT expr COMMA expr */
+{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
break;
- case 137: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
+ case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0);
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
}
break;
- case 140: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
+ case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0);
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list");
- sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy4,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list");
+ sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
}
break;
- case 141: /* setlist ::= setlist COMMA nm EQ expr */
+ case 145: /* setlist ::= setlist COMMA nm EQ expr */
{
- yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
}
break;
- case 142: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
+ case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
- yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
+ yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
break;
- case 143: /* setlist ::= nm EQ expr */
+ case 147: /* setlist ::= nm EQ expr */
{
- yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy314);
- sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
+ yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
+ sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
}
- yymsp[-2].minor.yy322 = yylhsminor.yy322;
+ yymsp[-2].minor.yy232 = yylhsminor.yy232;
break;
- case 144: /* setlist ::= LP idlist RP EQ expr */
+ case 148: /* setlist ::= LP idlist RP EQ expr */
{
- yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
break;
- case 145: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
+ case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
- sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy4);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
}
break;
- case 146: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
+ case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy4);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
}
break;
- case 150: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy384 = yymsp[-1].minor.yy384;}
+ case 151: /* upsert ::= */
+{ yymsp[1].minor.yy198 = 0; }
+ break;
+ case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+{ yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
break;
- case 151: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);}
+ case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+{ yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
break;
- case 152: /* idlist ::= nm */
-{yymsp[0].minor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+ case 154: /* upsert ::= ON CONFLICT DO NOTHING */
+{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
break;
- case 153: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy314 = yymsp[-1].minor.yy314;}
+ case 158: /* idlist_opt ::= LP idlist RP */
+{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
break;
- case 154: /* expr ::= ID|INDEXED */
- case 155: /* expr ::= JOIN_KW */ yytestcase(yyruleno==155);
-{yymsp[0].minor.yy314=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 159: /* idlist ::= idlist COMMA nm */
+{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
break;
- case 156: /* expr ::= nm DOT nm */
+ case 160: /* idlist ::= nm */
+{yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+ break;
+ case 161: /* expr ::= LP expr RP */
+{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
+ break;
+ case 162: /* expr ::= ID|INDEXED */
+ case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
+{yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ break;
+ case 164: /* expr ::= nm DOT nm */
{
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
- yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+ yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
- yymsp[-2].minor.yy314 = yylhsminor.yy314;
+ yymsp[-2].minor.yy182 = yylhsminor.yy182;
break;
- case 157: /* expr ::= nm DOT nm DOT nm */
+ case 165: /* expr ::= nm DOT nm DOT nm */
{
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
- yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+ yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
- yymsp[-4].minor.yy314 = yylhsminor.yy314;
+ yymsp[-4].minor.yy182 = yylhsminor.yy182;
break;
- case 158: /* term ::= NULL|FLOAT|BLOB */
- case 159: /* term ::= STRING */ yytestcase(yyruleno==159);
-{yymsp[0].minor.yy314=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 166: /* term ::= NULL|FLOAT|BLOB */
+ case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
+{yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
- case 160: /* term ::= INTEGER */
+ case 168: /* term ::= INTEGER */
{
- yylhsminor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
- yymsp[0].minor.yy314 = yylhsminor.yy314;
+ yymsp[0].minor.yy182 = yylhsminor.yy182;
break;
- case 161: /* expr ::= VARIABLE */
+ case 169: /* expr ::= VARIABLE */
{
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
u32 n = yymsp[0].minor.yy0.n;
- yymsp[0].minor.yy314 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy314, n);
+ yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
}else{
/* When doing a nested parse, one can include terms in an expression
** that look like this: #1 #2 ... These terms refer to registers
@@ -142928,146 +144622,146 @@ static void yy_reduce(
assert( t.n>=2 );
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
- yymsp[0].minor.yy314 = 0;
+ yymsp[0].minor.yy182 = 0;
}else{
- yymsp[0].minor.yy314 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
- if( yymsp[0].minor.yy314 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy314->iTable);
+ yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+ if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
}
}
}
break;
- case 162: /* expr ::= expr COLLATE ID|STRING */
+ case 170: /* expr ::= expr COLLATE ID|STRING */
{
- yymsp[-2].minor.yy314 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy314, &yymsp[0].minor.yy0, 1);
+ yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
}
break;
- case 163: /* expr ::= CAST LP expr AS typetoken RP */
+ case 171: /* expr ::= CAST LP expr AS typetoken RP */
{
- yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy314, yymsp[-3].minor.yy314, 0);
+ yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
}
break;
- case 164: /* expr ::= ID|INDEXED LP distinct exprlist RP */
+ case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
- if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
+ if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
}
- yylhsminor.yy314 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
- if( yymsp[-2].minor.yy4==SF_Distinct && yylhsminor.yy314 ){
- yylhsminor.yy314->flags |= EP_Distinct;
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0);
+ if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){
+ yylhsminor.yy182->flags |= EP_Distinct;
}
}
- yymsp[-4].minor.yy314 = yylhsminor.yy314;
+ yymsp[-4].minor.yy182 = yylhsminor.yy182;
break;
- case 165: /* expr ::= ID|INDEXED LP STAR RP */
+ case 173: /* expr ::= ID|INDEXED LP STAR RP */
{
- yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
}
- yymsp[-3].minor.yy314 = yylhsminor.yy314;
+ yymsp[-3].minor.yy182 = yylhsminor.yy182;
break;
- case 166: /* term ::= CTIME_KW */
+ case 174: /* term ::= CTIME_KW */
{
- yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy314 = yylhsminor.yy314;
+ yymsp[0].minor.yy182 = yylhsminor.yy182;
break;
- case 167: /* expr ::= LP nexprlist COMMA expr RP */
+ case 175: /* expr ::= LP nexprlist COMMA expr RP */
{
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314);
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
- if( yymsp[-4].minor.yy314 ){
- yymsp[-4].minor.yy314->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
}
break;
- case 168: /* expr ::= expr AND expr */
- case 169: /* expr ::= expr OR expr */ yytestcase(yyruleno==169);
- case 170: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==170);
- case 171: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==171);
- case 172: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==172);
- case 173: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==173);
- case 174: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==174);
- case 175: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==175);
-{yymsp[-2].minor.yy314=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
+ case 176: /* expr ::= expr AND expr */
+ case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177);
+ case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178);
+ case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
+ case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
+ case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
+ case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
+ case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
+{yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
break;
- case 176: /* likeop ::= NOT LIKE_KW|MATCH */
+ case 184: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
break;
- case 177: /* expr ::= expr likeop expr */
+ case 185: /* expr ::= expr likeop expr */
{
ExprList *pList;
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
yymsp[-1].minor.yy0.n &= 0x7fffffff;
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy314);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy314);
- yymsp[-2].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
- if( bNot ) yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy314, 0);
- if( yymsp[-2].minor.yy314 ) yymsp[-2].minor.yy314->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
+ yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
+ if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
+ if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
}
break;
- case 178: /* expr ::= expr likeop expr ESCAPE expr */
+ case 186: /* expr ::= expr likeop expr ESCAPE expr */
{
ExprList *pList;
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
yymsp[-3].minor.yy0.n &= 0x7fffffff;
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy314);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
- yymsp[-4].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
- if( bNot ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
- if( yymsp[-4].minor.yy314 ) yymsp[-4].minor.yy314->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
+ if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
}
break;
- case 179: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy314,0);}
+ case 187: /* expr ::= expr ISNULL|NOTNULL */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
break;
- case 180: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy314,0);}
+ case 188: /* expr ::= expr NOT NULL */
+{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
break;
- case 181: /* expr ::= expr IS expr */
+ case 189: /* expr ::= expr IS expr */
{
- yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-2].minor.yy314, TK_ISNULL);
+ yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
}
break;
- case 182: /* expr ::= expr IS NOT expr */
+ case 190: /* expr ::= expr IS NOT expr */
{
- yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy314,yymsp[0].minor.yy314);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-3].minor.yy314, TK_NOTNULL);
+ yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL);
}
break;
- case 183: /* expr ::= NOT expr */
- case 184: /* expr ::= BITNOT expr */ yytestcase(yyruleno==184);
-{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy314, 0);/*A-overwrites-B*/}
+ case 191: /* expr ::= NOT expr */
+ case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
break;
- case 185: /* expr ::= MINUS expr */
-{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy314, 0);}
+ case 193: /* expr ::= MINUS expr */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);}
break;
- case 186: /* expr ::= PLUS expr */
-{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy314, 0);}
+ case 194: /* expr ::= PLUS expr */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);}
break;
- case 187: /* between_op ::= BETWEEN */
- case 190: /* in_op ::= IN */ yytestcase(yyruleno==190);
-{yymsp[0].minor.yy4 = 0;}
+ case 195: /* between_op ::= BETWEEN */
+ case 198: /* in_op ::= IN */ yytestcase(yyruleno==198);
+{yymsp[0].minor.yy502 = 0;}
break;
- case 189: /* expr ::= expr between_op expr AND expr */
+ case 197: /* expr ::= expr between_op expr AND expr */
{
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy314, 0);
- if( yymsp[-4].minor.yy314 ){
- yymsp[-4].minor.yy314->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
- if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 192: /* expr ::= expr in_op LP exprlist RP */
+ case 200: /* expr ::= expr in_op LP exprlist RP */
{
- if( yymsp[-1].minor.yy322==0 ){
+ if( yymsp[-1].minor.yy232==0 ){
/* Expressions of the form
**
** expr1 IN ()
@@ -143076,9 +144770,9 @@ static void yy_reduce(
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy314);
- yymsp[-4].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy4],1);
- }else if( yymsp[-1].minor.yy322->nExpr==1 ){
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
+ }else if( yymsp[-1].minor.yy232->nExpr==1 ){
/* Expressions of the form:
**
** expr1 IN (?1)
@@ -143095,195 +144789,195 @@ static void yy_reduce(
** affinity or the collating sequence to use for comparison. Otherwise,
** the semantics would be subtly different from IN or NOT IN.
*/
- Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
- yymsp[-1].minor.yy322->a[0].pExpr = 0;
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+ Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
+ yymsp[-1].minor.yy232->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
/* pRHS cannot be NULL because a malloc error would have been detected
** before now and control would have never reached this point */
if( ALWAYS(pRHS) ){
pRHS->flags &= ~EP_Collate;
pRHS->flags |= EP_Generic;
}
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, yymsp[-3].minor.yy4 ? TK_NE : TK_EQ, yymsp[-4].minor.yy314, pRHS);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
}else{
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
- if( yymsp[-4].minor.yy314 ){
- yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy322;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
}
- if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
}
break;
- case 193: /* expr ::= LP select RP */
+ case 201: /* expr ::= LP select RP */
{
- yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy314, yymsp[-1].minor.yy387);
+ yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
}
break;
- case 194: /* expr ::= expr in_op LP select RP */
+ case 202: /* expr ::= expr in_op LP select RP */
{
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, yymsp[-1].minor.yy387);
- if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 195: /* expr ::= expr in_op nm dbnm paren_exprlist */
+ case 203: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
- if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, pSelect);
- if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
+ if( yymsp[0].minor.yy232 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 196: /* expr ::= EXISTS LP select RP */
+ case 204: /* expr ::= EXISTS LP select RP */
{
Expr *p;
- p = yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy387);
+ p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
}
break;
- case 197: /* expr ::= CASE case_operand case_exprlist case_else END */
+ case 205: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, 0);
- if( yymsp[-4].minor.yy314 ){
- yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy314 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy314) : yymsp[-2].minor.yy322;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314);
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
}
}
break;
- case 198: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ case 206: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
- yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
- yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
}
break;
- case 199: /* case_exprlist ::= WHEN expr THEN expr */
+ case 207: /* case_exprlist ::= WHEN expr THEN expr */
{
- yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
- yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy314);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
}
break;
- case 202: /* case_operand ::= expr */
-{yymsp[0].minor.yy314 = yymsp[0].minor.yy314; /*A-overwrites-X*/}
+ case 210: /* case_operand ::= expr */
+{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
break;
- case 205: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy314);}
+ case 213: /* nexprlist ::= nexprlist COMMA expr */
+{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
break;
- case 206: /* nexprlist ::= expr */
-{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy314); /*A-overwrites-Y*/}
+ case 214: /* nexprlist ::= expr */
+{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
break;
- case 208: /* paren_exprlist ::= LP exprlist RP */
- case 213: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==213);
-{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
+ case 216: /* paren_exprlist ::= LP exprlist RP */
+ case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221);
+{yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
break;
- case 209: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ case 217: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy4,
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy314, SQLITE_SO_ASC, yymsp[-8].minor.yy4, SQLITE_IDXTYPE_APPDEF);
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
}
break;
- case 210: /* uniqueflag ::= UNIQUE */
- case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
-{yymsp[0].minor.yy4 = OE_Abort;}
+ case 218: /* uniqueflag ::= UNIQUE */
+ case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258);
+{yymsp[0].minor.yy502 = OE_Abort;}
break;
- case 211: /* uniqueflag ::= */
-{yymsp[1].minor.yy4 = OE_None;}
+ case 219: /* uniqueflag ::= */
+{yymsp[1].minor.yy502 = OE_None;}
break;
- case 214: /* eidlist ::= eidlist COMMA nm collate sortorder */
+ case 222: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
- yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4);
+ yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
}
break;
- case 215: /* eidlist ::= nm collate sortorder */
+ case 223: /* eidlist ::= nm collate sortorder */
{
- yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4); /*A-overwrites-Y*/
+ yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
}
break;
- case 218: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
+ case 226: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
break;
- case 219: /* cmd ::= VACUUM */
+ case 227: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
break;
- case 220: /* cmd ::= VACUUM nm */
+ case 228: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
break;
- case 221: /* cmd ::= PRAGMA nm dbnm */
+ case 229: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
- case 222: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+ case 230: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
- case 223: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ case 231: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
- case 224: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+ case 232: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
- case 225: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ case 233: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
break;
- case 228: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ case 236: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
Token all;
all.z = yymsp[-3].minor.yy0.z;
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all);
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
}
break;
- case 229: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ case 237: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4);
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
- case 230: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/ }
+ case 238: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
break;
- case 231: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy4 = TK_INSTEAD;}
+ case 239: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
break;
- case 232: /* trigger_time ::= */
-{ yymsp[1].minor.yy4 = TK_BEFORE; }
+ case 240: /* trigger_time ::= */
+{ yymsp[1].minor.yy502 = TK_BEFORE; }
break;
- case 233: /* trigger_event ::= DELETE|INSERT */
- case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234);
-{yymsp[0].minor.yy90.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy90.b = 0;}
+ case 241: /* trigger_event ::= DELETE|INSERT */
+ case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242);
+{yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;}
break;
- case 235: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy90.a = TK_UPDATE; yymsp[-2].minor.yy90.b = yymsp[0].minor.yy384;}
+ case 243: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
break;
- case 236: /* when_clause ::= */
- case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
-{ yymsp[1].minor.yy314 = 0; }
+ case 244: /* when_clause ::= */
+ case 263: /* key_opt ::= */ yytestcase(yyruleno==263);
+{ yymsp[1].minor.yy182 = 0; }
break;
- case 237: /* when_clause ::= WHEN expr */
- case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256);
-{ yymsp[-1].minor.yy314 = yymsp[0].minor.yy314; }
+ case 245: /* when_clause ::= WHEN expr */
+ case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264);
+{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
break;
- case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ case 246: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
- assert( yymsp[-2].minor.yy203!=0 );
- yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203;
- yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203;
+ assert( yymsp[-2].minor.yy47!=0 );
+ yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
+ yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
break;
- case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
+ case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
- assert( yymsp[-1].minor.yy203!=0 );
- yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
+ assert( yymsp[-1].minor.yy47!=0 );
+ yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
break;
- case 240: /* trnm ::= nm DOT nm */
+ case 248: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
@@ -143291,194 +144985,196 @@ static void yy_reduce(
"statements within triggers");
}
break;
- case 241: /* tridxby ::= INDEXED BY nm */
+ case 249: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 242: /* tridxby ::= NOT INDEXED */
+ case 250: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
-{yylhsminor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy314, yymsp[-6].minor.yy4, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy336);}
- yymsp[-7].minor.yy203 = yylhsminor.yy203;
+ case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+{yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
+ yymsp[-7].minor.yy47 = yylhsminor.yy47;
break;
- case 244: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
-{yylhsminor.yy203 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-3].minor.yy0,yymsp[-2].minor.yy384,yymsp[-1].minor.yy387,yymsp[-5].minor.yy4,yymsp[-6].minor.yy336,yymsp[0].minor.yy336);/*yylhsminor.yy203-overwrites-yymsp[-5].minor.yy4*/}
- yymsp[-6].minor.yy203 = yylhsminor.yy203;
+ case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+{
+ yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
+}
+ yymsp[-7].minor.yy47 = yylhsminor.yy47;
break;
- case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-{yylhsminor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy314, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy336);}
- yymsp[-5].minor.yy203 = yylhsminor.yy203;
+ case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+{yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
+ yymsp[-5].minor.yy47 = yylhsminor.yy47;
break;
- case 246: /* trigger_cmd ::= scanpt select scanpt */
-{yylhsminor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy387, yymsp[-2].minor.yy336, yymsp[0].minor.yy336); /*yylhsminor.yy203-overwrites-yymsp[-1].minor.yy387*/}
- yymsp[-2].minor.yy203 = yylhsminor.yy203;
+ case 254: /* trigger_cmd ::= scanpt select scanpt */
+{yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/}
+ yymsp[-2].minor.yy47 = yylhsminor.yy47;
break;
- case 247: /* expr ::= RAISE LP IGNORE RP */
+ case 255: /* expr ::= RAISE LP IGNORE RP */
{
- yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
- if( yymsp[-3].minor.yy314 ){
- yymsp[-3].minor.yy314->affinity = OE_Ignore;
+ yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+ if( yymsp[-3].minor.yy182 ){
+ yymsp[-3].minor.yy182->affinity = OE_Ignore;
}
}
break;
- case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
+ case 256: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
- yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
- if( yymsp[-5].minor.yy314 ) {
- yymsp[-5].minor.yy314->affinity = (char)yymsp[-3].minor.yy4;
+ yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
+ if( yymsp[-5].minor.yy182 ) {
+ yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502;
}
}
break;
- case 249: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy4 = OE_Rollback;}
+ case 257: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy502 = OE_Rollback;}
break;
- case 251: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy4 = OE_Fail;}
+ case 259: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy502 = OE_Fail;}
break;
- case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
+ case 260: /* cmd ::= DROP TRIGGER ifexists fullname */
{
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
}
break;
- case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ case 261: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
- sqlite3Attach(pParse, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, yymsp[0].minor.yy314);
+ sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
}
break;
- case 254: /* cmd ::= DETACH database_kw_opt expr */
+ case 262: /* cmd ::= DETACH database_kw_opt expr */
{
- sqlite3Detach(pParse, yymsp[0].minor.yy314);
+ sqlite3Detach(pParse, yymsp[0].minor.yy182);
}
break;
- case 257: /* cmd ::= REINDEX */
+ case 265: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
break;
- case 258: /* cmd ::= REINDEX nm dbnm */
+ case 266: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
- case 259: /* cmd ::= ANALYZE */
+ case 267: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
break;
- case 260: /* cmd ::= ANALYZE nm dbnm */
+ case 268: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
- case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+ case 269: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0);
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
}
break;
- case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ case 270: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
break;
- case 263: /* add_column_fullname ::= fullname */
+ case 271: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259);
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
}
break;
- case 264: /* cmd ::= create_vtab */
+ case 272: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
- case 265: /* cmd ::= create_vtab LP vtabarglist RP */
+ case 273: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
- case 266: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ case 274: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy4);
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
}
break;
- case 267: /* vtabarg ::= */
+ case 275: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
- case 268: /* vtabargtoken ::= ANY */
- case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269);
- case 270: /* lp ::= LP */ yytestcase(yyruleno==270);
+ case 276: /* vtabargtoken ::= ANY */
+ case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277);
+ case 278: /* lp ::= LP */ yytestcase(yyruleno==278);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
- case 271: /* with ::= WITH wqlist */
- case 272: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==272);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy451, 1); }
+ case 279: /* with ::= WITH wqlist */
+ case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
break;
- case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
+ case 281: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
- yymsp[-5].minor.yy451 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387); /*A-overwrites-X*/
+ yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
}
break;
- case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ case 282: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
- yymsp[-7].minor.yy451 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy451, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387);
+ yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
}
break;
default:
- /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
- /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
- /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
- /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
- /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
- /* (280) explain ::= */ yytestcase(yyruleno==280);
- /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
- /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
- /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
- /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
- /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
- /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
- /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
- /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
- /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
- /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
- /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
- /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
- /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
- /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
- /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
- /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
- /* (297) carglist ::= */ yytestcase(yyruleno==297);
- /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
- /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
- /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
- /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
- /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
- /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
- /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
- /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
- /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
- /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
- /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
- /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
- /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
- /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
- /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
- /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
- /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
- /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
- /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
- /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
- /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
- /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
- /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
- /* (321) tridxby ::= */ yytestcase(yyruleno==321);
- /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
- /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
- /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
- /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
- /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
- /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
- /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
- /* (329) anylist ::= */ yytestcase(yyruleno==329);
- /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
- /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
- /* (332) with ::= */ yytestcase(yyruleno==332);
+ /* (283) input ::= cmdlist */ yytestcase(yyruleno==283);
+ /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284);
+ /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285);
+ /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286);
+ /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287);
+ /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288);
+ /* (289) trans_opt ::= */ yytestcase(yyruleno==289);
+ /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290);
+ /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291);
+ /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292);
+ /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293);
+ /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294);
+ /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295);
+ /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296);
+ /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297);
+ /* (298) nm ::= STRING */ yytestcase(yyruleno==298);
+ /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299);
+ /* (300) typetoken ::= typename */ yytestcase(yyruleno==300);
+ /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301);
+ /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302);
+ /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303);
+ /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304);
+ /* (305) carglist ::= */ yytestcase(yyruleno==305);
+ /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306);
+ /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307);
+ /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308);
+ /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309);
+ /* (310) tconscomma ::= */ yytestcase(yyruleno==310);
+ /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311);
+ /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312);
+ /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313);
+ /* (314) oneselect ::= values */ yytestcase(yyruleno==314);
+ /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315);
+ /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316);
+ /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317);
+ /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318);
+ /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319);
+ /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
+ /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321);
+ /* (322) nmnum ::= ON */ yytestcase(yyruleno==322);
+ /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323);
+ /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324);
+ /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325);
+ /* (326) foreach_clause ::= */ yytestcase(yyruleno==326);
+ /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327);
+ /* (328) trnm ::= nm */ yytestcase(yyruleno==328);
+ /* (329) tridxby ::= */ yytestcase(yyruleno==329);
+ /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330);
+ /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331);
+ /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332);
+ /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333);
+ /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334);
+ /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335);
+ /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336);
+ /* (337) anylist ::= */ yytestcase(yyruleno==337);
+ /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338);
+ /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339);
+ /* (340) with ::= */ yytestcase(yyruleno==340);
break;
/********** End reduce actions ************************************************/
};
@@ -143499,6 +145195,7 @@ static void yy_reduce(
yymsp->stateno = (YYACTIONTYPE)yyact;
yymsp->major = (YYCODETYPE)yygoto;
yyTraceShift(yypParser, yyact, "... then shift");
+ return yyact;
}
/*
@@ -143508,7 +145205,8 @@ static void yy_reduce(
static void yy_parse_failed(
yyParser *yypParser /* The parser */
){
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
+ sqlite3ParserCTX_FETCH
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
@@ -143519,7 +145217,8 @@ static void yy_parse_failed(
** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
- sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserCTX_STORE
}
#endif /* YYNOERRORRECOVERY */
@@ -143531,7 +145230,8 @@ static void yy_syntax_error(
int yymajor, /* The major type of the error token */
sqlite3ParserTOKENTYPE yyminor /* The minor type of the error token */
){
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
+ sqlite3ParserCTX_FETCH
#define TOKEN yyminor
/************ Begin %syntax_error code ****************************************/
@@ -143542,7 +145242,8 @@ static void yy_syntax_error(
sqlite3ErrorMsg(pParse, "incomplete input");
}
/************ End %syntax_error code ******************************************/
- sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserCTX_STORE
}
/*
@@ -143551,7 +145252,8 @@ static void yy_syntax_error(
static void yy_accept(
yyParser *yypParser /* The parser */
){
- sqlite3ParserARG_FETCH;
+ sqlite3ParserARG_FETCH
+ sqlite3ParserCTX_FETCH
#ifndef NDEBUG
if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
@@ -143565,7 +145267,8 @@ static void yy_accept(
** parser accepts */
/*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/
- sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3ParserCTX_STORE
}
/* The main parser program.
@@ -143594,45 +145297,47 @@ SQLITE_PRIVATE void sqlite3Parser(
sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */
){
YYMINORTYPE yyminorunion;
- unsigned int yyact; /* The parser action. */
+ YYACTIONTYPE yyact; /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */
#endif
#ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */
#endif
- yyParser *yypParser; /* The parser */
+ yyParser *yypParser = (yyParser*)yyp; /* The parser */
+ sqlite3ParserCTX_FETCH
+ sqlite3ParserARG_STORE
- yypParser = (yyParser*)yyp;
assert( yypParser->yytos!=0 );
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor==0);
#endif
- sqlite3ParserARG_STORE;
+ yyact = yypParser->yytos->stateno;
#ifndef NDEBUG
if( yyTraceFILE ){
- int stateno = yypParser->yytos->stateno;
- if( stateno < YY_MIN_REDUCE ){
+ if( yyact < YY_MIN_REDUCE ){
fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
- yyTracePrompt,yyTokenName[yymajor],stateno);
+ yyTracePrompt,yyTokenName[yymajor],yyact);
}else{
fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
- yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
+ yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
}
}
#endif
do{
- yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
+ assert( yyact==yypParser->yytos->stateno );
+ yyact = yy_find_shift_action(yymajor,yyact);
if( yyact >= YY_MIN_REDUCE ){
- yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
+ yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
+ yyminor sqlite3ParserCTX_PARAM);
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,yymajor,yyminor);
#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--;
#endif
- yymajor = YYNOCODE;
+ break;
}else if( yyact==YY_ACCEPT_ACTION ){
yypParser->yytos--;
yy_accept(yypParser);
@@ -143703,6 +145408,8 @@ SQLITE_PRIVATE void sqlite3Parser(
}
yypParser->yyerrcnt = 3;
yyerrorhit = 1;
+ if( yymajor==YYNOCODE ) break;
+ yyact = yypParser->yytos->stateno;
#elif defined(YYNOERRORRECOVERY)
/* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
** do any kind of error recovery. Instead, simply invoke the syntax
@@ -143713,8 +145420,7 @@ SQLITE_PRIVATE void sqlite3Parser(
*/
yy_syntax_error(yypParser,yymajor, yyminor);
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
- yymajor = YYNOCODE;
-
+ break;
#else /* YYERRORSYMBOL is not defined */
/* This is what we do if the grammar does not define ERROR:
**
@@ -143736,10 +145442,10 @@ SQLITE_PRIVATE void sqlite3Parser(
yypParser->yyerrcnt = -1;
#endif
}
- yymajor = YYNOCODE;
+ break;
#endif
}
- }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
+ }while( yypParser->yytos>yypParser->yystack );
#ifndef NDEBUG
if( yyTraceFILE ){
yyStackEntry *i;
@@ -143916,19 +145622,19 @@ const unsigned char ebcdicToAscii[] = {
** is substantially reduced. This is important for embedded applications
** on platforms with limited memory.
*/
-/* Hash score: 182 */
-/* zKWText[] encodes 834 bytes of keyword text in 554 bytes */
+/* Hash score: 185 */
+/* zKWText[] encodes 845 bytes of keyword text in 561 bytes */
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
-/* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
-/* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
-/* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
-/* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
-/* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
-/* VACUUMVIEWINITIALLY */
-static const char zKWText[553] = {
+/* BETWEENOTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATE */
+/* DETACHIMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUES */
+/* VIRTUALIMITWHENOTNULLWHERENAMEAFTEREPLACEANDEFAULT */
+/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
+/* RIMARYDEFERREDISTINCTDORDERESTRICTDROPFAILFROMFULLIFISNULL */
+/* RIGHTROLLBACKROWUNIONUSINGVACUUMVIEWINITIALLY */
+static const char zKWText[560] = {
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
@@ -143942,82 +145648,83 @@ static const char zKWText[553] = {
'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
- 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
- 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
- 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
- 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
- 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
- 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
- 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
- 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
- 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
- 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
- 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
- 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
- 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
- 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
- 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
- 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
- 'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
- 'V','I','E','W','I','N','I','T','I','A','L','L','Y',
+ 'B','E','T','W','E','E','N','O','T','H','I','N','G','L','O','B','Y','C',
+ 'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
+ 'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
+ 'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
+ 'J','O','I','N','S','E','R','T','L','I','K','E','M','A','T','C','H','P',
+ 'L','A','N','A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T',
+ 'V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T','W',
+ 'H','E','N','O','T','N','U','L','L','W','H','E','R','E','N','A','M','E',
+ 'A','F','T','E','R','E','P','L','A','C','E','A','N','D','E','F','A','U',
+ 'L','T','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S',
+ 'T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L',
+ 'I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I',
+ 'M','E','S','T','A','M','P','R','I','M','A','R','Y','D','E','F','E','R',
+ 'R','E','D','I','S','T','I','N','C','T','D','O','R','D','E','R','E','S',
+ 'T','R','I','C','T','D','R','O','P','F','A','I','L','F','R','O','M','F',
+ 'U','L','L','I','F','I','S','N','U','L','L','R','I','G','H','T','R','O',
+ 'L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N',
+ 'G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L',
+ 'L','Y',
};
/* aKWHash[i] is the hash value for the i-th keyword */
static const unsigned char aKWHash[127] = {
- 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
- 42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
- 121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
- 0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
- 0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
- 96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
- 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
- 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
- 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
- 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
+ 74, 108, 119, 72, 0, 45, 0, 0, 81, 0, 76, 61, 0,
+ 42, 12, 77, 15, 0, 118, 84, 54, 116, 0, 19, 0, 0,
+ 123, 0, 121, 111, 0, 22, 96, 0, 9, 0, 0, 68, 69,
+ 0, 67, 6, 0, 48, 93, 105, 0, 120, 104, 0, 0, 44,
+ 0, 106, 24, 0, 17, 0, 124, 53, 23, 0, 5, 62, 25,
+ 99, 0, 0, 126, 112, 60, 125, 57, 28, 55, 0, 94, 0,
+ 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 91, 115, 14,
+ 39, 114, 0, 80, 0, 109, 92, 90, 32, 0, 122, 79, 117,
+ 86, 46, 83, 0, 0, 97, 40, 59, 110, 0, 36, 0, 0,
+ 29, 0, 89, 87, 88, 0, 20, 85, 0, 56,
};
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
** then the i-th keyword has no more hash collisions. Otherwise,
** the next keyword with the same hash is aKWHash[i]-1. */
-static const unsigned char aKWNext[124] = {
+static const unsigned char aKWNext[126] = {
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
- 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
- 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
- 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
- 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
- 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
- 73, 83, 0, 35, 68, 0, 0,
+ 0, 43, 3, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
+ 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 63, 31,
+ 52, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
+ 78, 0, 8, 0, 18, 51, 0, 107, 101, 0, 113, 0, 73,
+ 27, 37, 71, 82, 0, 35, 66, 0, 0,
};
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
-static const unsigned char aKWLen[124] = {
+static const unsigned char aKWLen[126] = {
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
- 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
- 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
- 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
- 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
- 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
- 3, 5, 5, 6, 4, 9, 3,
+ 6, 6, 5, 6, 5, 5, 9, 7, 7, 4, 2, 7, 3,
+ 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
+ 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 6, 5,
+ 7, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
+ 7, 8, 8, 2, 2, 5, 8, 4, 4, 4, 4, 2, 6,
+ 5, 8, 3, 5, 5, 6, 4, 9, 3,
};
/* aKWOffset[i] is the index into zKWText[] of the start of
** the text for the i-th keyword. */
-static const unsigned short int aKWOffset[124] = {
+static const unsigned short int aKWOffset[126] = {
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
- 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
- 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
- 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
- 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
- 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
- 521, 524, 529, 534, 540, 544, 549,
+ 199, 204, 209, 212, 218, 221, 225, 234, 240, 246, 249, 251, 252,
+ 256, 262, 266, 273, 279, 291, 297, 306, 308, 314, 318, 323, 325,
+ 332, 337, 342, 348, 354, 359, 362, 362, 362, 365, 369, 372, 378,
+ 382, 389, 391, 398, 400, 402, 411, 415, 421, 427, 435, 440, 440,
+ 456, 463, 470, 471, 478, 479, 483, 491, 495, 499, 503, 507, 509,
+ 515, 520, 528, 531, 536, 541, 547, 551, 556,
};
/* aKWCode[i] is the parser symbol code for the i-th keyword */
-static const unsigned char aKWCode[124] = {
+static const unsigned char aKWCode[126] = {
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
@@ -144030,19 +145737,20 @@ static const unsigned char aKWCode[124] = {
TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
- TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
- TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
- TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
- TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
- TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
- TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
- TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
- TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
- TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
- TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
- TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
- TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
- TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
+ TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
+ TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
+ TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
+ TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
+ TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
+ TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RENAME,
+ TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT, TK_AUTOINCR,
+ TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
+ TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY,
+ TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DO, TK_ORDER,
+ TK_RESTRICT, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
+ TK_IF, TK_ISNULL, TK_JOIN_KW, TK_ROLLBACK, TK_ROW,
+ TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY,
+ TK_ALL,
};
/* Check to see if z[0..n-1] is a keyword. If it is, write the
** parser symbol code for that keyword into *pType. Always
@@ -144123,70 +145831,72 @@ static int keywordCode(const char *z, int n, int *pType){
testcase( i==57 ); /* INNER */
testcase( i==58 ); /* RECURSIVE */
testcase( i==59 ); /* BETWEEN */
- testcase( i==60 ); /* NOTNULL */
- testcase( i==61 ); /* NOT */
- testcase( i==62 ); /* NO */
- testcase( i==63 ); /* NULL */
- testcase( i==64 ); /* LIKE */
- testcase( i==65 ); /* CASCADE */
- testcase( i==66 ); /* ASC */
- testcase( i==67 ); /* DELETE */
- testcase( i==68 ); /* CASE */
- testcase( i==69 ); /* COLLATE */
- testcase( i==70 ); /* CREATE */
- testcase( i==71 ); /* CURRENT_DATE */
- testcase( i==72 ); /* DETACH */
- testcase( i==73 ); /* IMMEDIATE */
- testcase( i==74 ); /* JOIN */
- testcase( i==75 ); /* INSERT */
- testcase( i==76 ); /* MATCH */
- testcase( i==77 ); /* PLAN */
- testcase( i==78 ); /* ANALYZE */
- testcase( i==79 ); /* PRAGMA */
- testcase( i==80 ); /* ABORT */
- testcase( i==81 ); /* VALUES */
- testcase( i==82 ); /* VIRTUAL */
- testcase( i==83 ); /* LIMIT */
- testcase( i==84 ); /* WHEN */
- testcase( i==85 ); /* WHERE */
- testcase( i==86 ); /* RENAME */
- testcase( i==87 ); /* AFTER */
- testcase( i==88 ); /* REPLACE */
- testcase( i==89 ); /* AND */
- testcase( i==90 ); /* DEFAULT */
- testcase( i==91 ); /* AUTOINCREMENT */
- testcase( i==92 ); /* TO */
- testcase( i==93 ); /* IN */
- testcase( i==94 ); /* CAST */
- testcase( i==95 ); /* COLUMN */
- testcase( i==96 ); /* COMMIT */
- testcase( i==97 ); /* CONFLICT */
- testcase( i==98 ); /* CROSS */
- testcase( i==99 ); /* CURRENT_TIMESTAMP */
- testcase( i==100 ); /* CURRENT_TIME */
- testcase( i==101 ); /* PRIMARY */
- testcase( i==102 ); /* DEFERRED */
- testcase( i==103 ); /* DISTINCT */
- testcase( i==104 ); /* IS */
- testcase( i==105 ); /* DROP */
- testcase( i==106 ); /* FAIL */
- testcase( i==107 ); /* FROM */
- testcase( i==108 ); /* FULL */
- testcase( i==109 ); /* GLOB */
- testcase( i==110 ); /* BY */
- testcase( i==111 ); /* IF */
- testcase( i==112 ); /* ISNULL */
- testcase( i==113 ); /* ORDER */
- testcase( i==114 ); /* RESTRICT */
- testcase( i==115 ); /* RIGHT */
- testcase( i==116 ); /* ROLLBACK */
- testcase( i==117 ); /* ROW */
- testcase( i==118 ); /* UNION */
- testcase( i==119 ); /* USING */
- testcase( i==120 ); /* VACUUM */
- testcase( i==121 ); /* VIEW */
- testcase( i==122 ); /* INITIALLY */
- testcase( i==123 ); /* ALL */
+ testcase( i==60 ); /* NOTHING */
+ testcase( i==61 ); /* GLOB */
+ testcase( i==62 ); /* BY */
+ testcase( i==63 ); /* CASCADE */
+ testcase( i==64 ); /* ASC */
+ testcase( i==65 ); /* DELETE */
+ testcase( i==66 ); /* CASE */
+ testcase( i==67 ); /* COLLATE */
+ testcase( i==68 ); /* CREATE */
+ testcase( i==69 ); /* CURRENT_DATE */
+ testcase( i==70 ); /* DETACH */
+ testcase( i==71 ); /* IMMEDIATE */
+ testcase( i==72 ); /* JOIN */
+ testcase( i==73 ); /* INSERT */
+ testcase( i==74 ); /* LIKE */
+ testcase( i==75 ); /* MATCH */
+ testcase( i==76 ); /* PLAN */
+ testcase( i==77 ); /* ANALYZE */
+ testcase( i==78 ); /* PRAGMA */
+ testcase( i==79 ); /* ABORT */
+ testcase( i==80 ); /* VALUES */
+ testcase( i==81 ); /* VIRTUAL */
+ testcase( i==82 ); /* LIMIT */
+ testcase( i==83 ); /* WHEN */
+ testcase( i==84 ); /* NOTNULL */
+ testcase( i==85 ); /* NOT */
+ testcase( i==86 ); /* NO */
+ testcase( i==87 ); /* NULL */
+ testcase( i==88 ); /* WHERE */
+ testcase( i==89 ); /* RENAME */
+ testcase( i==90 ); /* AFTER */
+ testcase( i==91 ); /* REPLACE */
+ testcase( i==92 ); /* AND */
+ testcase( i==93 ); /* DEFAULT */
+ testcase( i==94 ); /* AUTOINCREMENT */
+ testcase( i==95 ); /* TO */
+ testcase( i==96 ); /* IN */
+ testcase( i==97 ); /* CAST */
+ testcase( i==98 ); /* COLUMN */
+ testcase( i==99 ); /* COMMIT */
+ testcase( i==100 ); /* CONFLICT */
+ testcase( i==101 ); /* CROSS */
+ testcase( i==102 ); /* CURRENT_TIMESTAMP */
+ testcase( i==103 ); /* CURRENT_TIME */
+ testcase( i==104 ); /* PRIMARY */
+ testcase( i==105 ); /* DEFERRED */
+ testcase( i==106 ); /* DISTINCT */
+ testcase( i==107 ); /* IS */
+ testcase( i==108 ); /* DO */
+ testcase( i==109 ); /* ORDER */
+ testcase( i==110 ); /* RESTRICT */
+ testcase( i==111 ); /* DROP */
+ testcase( i==112 ); /* FAIL */
+ testcase( i==113 ); /* FROM */
+ testcase( i==114 ); /* FULL */
+ testcase( i==115 ); /* IF */
+ testcase( i==116 ); /* ISNULL */
+ testcase( i==117 ); /* RIGHT */
+ testcase( i==118 ); /* ROLLBACK */
+ testcase( i==119 ); /* ROW */
+ testcase( i==120 ); /* UNION */
+ testcase( i==121 ); /* USING */
+ testcase( i==122 ); /* VACUUM */
+ testcase( i==123 ); /* VIEW */
+ testcase( i==124 ); /* INITIALLY */
+ testcase( i==125 ); /* ALL */
*pType = aKWCode[i];
break;
}
@@ -144198,7 +145908,17 @@ SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
keywordCode((char*)z, n, &id);
return id;
}
-#define SQLITE_N_KEYWORD 124
+#define SQLITE_N_KEYWORD 126
+SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
+ if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
+ *pzName = zKWText + aKWOffset[i];
+ *pnName = aKWLen[i];
+ return SQLITE_OK;
+}
+SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }
+SQLITE_API int sqlite3_keyword_check(const char *zName, int nName){
+ return TK_ID!=sqlite3KeywordCode((const u8*)zName, nName);
+}
/************** End of keywordhash.h *****************************************/
/************** Continuing where we left off in tokenize.c *******************/
@@ -144555,9 +146275,9 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
/* sqlite3ParserTrace(stdout, "parser: "); */
#ifdef sqlite3Parser_ENGINEALWAYSONSTACK
pEngine = &sEngine;
- sqlite3ParserInit(pEngine);
+ sqlite3ParserInit(pEngine, pParse);
#else
- pEngine = sqlite3ParserAlloc(sqlite3Malloc);
+ pEngine = sqlite3ParserAlloc(sqlite3Malloc, pParse);
if( pEngine==0 ){
sqlite3OomFault(db);
return SQLITE_NOMEM_BKPT;
@@ -144601,7 +146321,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
}else{
pParse->sLastToken.z = zSql;
pParse->sLastToken.n = n;
- sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
+ sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
lastTokenParsed = tokenType;
zSql += n;
if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
@@ -145708,6 +147428,17 @@ SQLITE_API int sqlite3_config(int op, ...){
break;
}
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
+ case SQLITE_CONFIG_SORTERREF_SIZE: {
+ int iVal = va_arg(ap, int);
+ if( iVal<0 ){
+ iVal = SQLITE_DEFAULT_SORTERREF_SIZE;
+ }
+ sqlite3GlobalConfig.szSorterRef = (u32)iVal;
+ break;
+ }
+#endif /* SQLITE_ENABLE_SORTER_REFERENCES */
+
default: {
rc = SQLITE_ERROR;
break;
@@ -145889,6 +147620,7 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
{ SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
{ SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
+ { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
};
unsigned int i;
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
@@ -146862,11 +148594,13 @@ SQLITE_API int sqlite3_create_function_v2(
#endif
sqlite3_mutex_enter(db->mutex);
if( xDestroy ){
- pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));
+ pArg = (FuncDestructor *)sqlite3Malloc(sizeof(FuncDestructor));
if( !pArg ){
+ sqlite3OomFault(db);
xDestroy(p);
goto out;
}
+ pArg->nRef = 0;
pArg->xDestroy = xDestroy;
pArg->pUserData = p;
}
@@ -146874,7 +148608,7 @@ SQLITE_API int sqlite3_create_function_v2(
if( pArg && pArg->nRef==0 ){
assert( rc!=SQLITE_OK );
xDestroy(p);
- sqlite3DbFree(db, pArg);
+ sqlite3_free(pArg);
}
out:
@@ -146913,6 +148647,28 @@ SQLITE_API int sqlite3_create_function16(
/*
+** The following is the implementation of an SQL function that always
+** fails with an error message stating that the function is used in the
+** wrong context. The sqlite3_overload_function() API might construct
+** SQL function that use this routine so that the functions will exist
+** for name resolution but are actually overloaded by the xFindFunction
+** method of virtual tables.
+*/
+static void sqlite3InvalidFunction(
+ sqlite3_context *context, /* The function calling context */
+ int NotUsed, /* Number of arguments to the function */
+ sqlite3_value **NotUsed2 /* Value of each argument */
+){
+ const char *zName = (const char*)sqlite3_user_data(context);
+ char *zErr;
+ UNUSED_PARAMETER2(NotUsed, NotUsed2);
+ zErr = sqlite3_mprintf(
+ "unable to use function %s in the requested context", zName);
+ sqlite3_result_error(context, zErr, -1);
+ sqlite3_free(zErr);
+}
+
+/*
** Declare that a function has been overloaded by a virtual table.
**
** If the function already exists as a regular global function, then
@@ -146929,7 +148685,8 @@ SQLITE_API int sqlite3_overload_function(
const char *zName,
int nArg
){
- int rc = SQLITE_OK;
+ int rc;
+ char *zCopy;
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){
@@ -146937,13 +148694,13 @@ SQLITE_API int sqlite3_overload_function(
}
#endif
sqlite3_mutex_enter(db->mutex);
- if( sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)==0 ){
- rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,
- 0, sqlite3InvalidFunction, 0, 0, 0);
- }
- rc = sqlite3ApiExit(db, rc);
+ rc = sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)!=0;
sqlite3_mutex_leave(db->mutex);
- return rc;
+ if( rc ) return SQLITE_OK;
+ zCopy = sqlite3_mprintf(zName);
+ if( zCopy==0 ) return SQLITE_NOMEM;
+ return sqlite3_create_function_v2(db, zName, nArg, SQLITE_UTF8,
+ zCopy, sqlite3InvalidFunction, 0, 0, sqlite3_free);
}
#ifndef SQLITE_OMIT_TRACE
@@ -148916,24 +150673,6 @@ SQLITE_API int sqlite3_test_control(int op, ...){
break;
}
-#ifdef SQLITE_N_KEYWORD
- /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
- **
- ** If zWord is a keyword recognized by the parser, then return the
- ** number of keywords. Or if zWord is not a keyword, return 0.
- **
- ** This test feature is only available in the amalgamation since
- ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
- ** is built using separate source files.
- */
- case SQLITE_TESTCTRL_ISKEYWORD: {
- const char *zWord = va_arg(ap, const char*);
- int n = sqlite3Strlen30(zWord);
- rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;
- break;
- }
-#endif
-
/* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
**
** If parameter onoff is non-zero, configure the wrappers so that all
@@ -150800,7 +152539,7 @@ SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,
);
SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
#ifdef SQLITE_TEST
-SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash*);
SQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db);
#endif
@@ -154510,7 +156249,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
#ifdef SQLITE_TEST
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3ExprInitTestInterface(db);
+ rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
}
#endif
@@ -158171,34 +159910,6 @@ SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *pDel){
/* #include <stdio.h> */
/*
-** Function to query the hash-table of tokenizers (see README.tokenizers).
-*/
-static int queryTestTokenizer(
- sqlite3 *db,
- const char *zName,
- const sqlite3_tokenizer_module **pp
-){
- int rc;
- sqlite3_stmt *pStmt;
- const char zSql[] = "SELECT fts3_tokenizer(?)";
-
- *pp = 0;
- rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
- if( rc!=SQLITE_OK ){
- return rc;
- }
-
- sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
- if( SQLITE_ROW==sqlite3_step(pStmt) ){
- if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){
- memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));
- }
- }
-
- return sqlite3_finalize(pStmt);
-}
-
-/*
** Return a pointer to a buffer containing a text representation of the
** expression passed as the first argument. The buffer is obtained from
** sqlite3_malloc(). It is the responsibility of the caller to use
@@ -158265,12 +159976,12 @@ static char *exprToString(Fts3Expr *pExpr, char *zBuf){
**
** SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');
*/
-static void fts3ExprTest(
+static void fts3ExprTestCommon(
+ int bRebalance,
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
- sqlite3_tokenizer_module const *pModule = 0;
sqlite3_tokenizer *pTokenizer = 0;
int rc;
char **azCol = 0;
@@ -158280,7 +159991,9 @@ static void fts3ExprTest(
int ii;
Fts3Expr *pExpr;
char *zBuf = 0;
- sqlite3 *db = sqlite3_context_db_handle(context);
+ Fts3Hash *pHash = (Fts3Hash*)sqlite3_user_data(context);
+ const char *zTokenizer = 0;
+ char *zErr = 0;
if( argc<3 ){
sqlite3_result_error(context,
@@ -158289,23 +160002,17 @@ static void fts3ExprTest(
return;
}
- rc = queryTestTokenizer(db,
- (const char *)sqlite3_value_text(argv[0]), &pModule);
- if( rc==SQLITE_NOMEM ){
- sqlite3_result_error_nomem(context);
- goto exprtest_out;
- }else if( !pModule ){
- sqlite3_result_error(context, "No such tokenizer module", -1);
- goto exprtest_out;
- }
-
- rc = pModule->xCreate(0, 0, &pTokenizer);
- assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );
- if( rc==SQLITE_NOMEM ){
- sqlite3_result_error_nomem(context);
- goto exprtest_out;
+ zTokenizer = (const char*)sqlite3_value_text(argv[0]);
+ rc = sqlite3Fts3InitTokenizer(pHash, zTokenizer, &pTokenizer, &zErr);
+ if( rc!=SQLITE_OK ){
+ if( rc==SQLITE_NOMEM ){
+ sqlite3_result_error_nomem(context);
+ }else{
+ sqlite3_result_error(context, zErr, -1);
+ }
+ sqlite3_free(zErr);
+ return;
}
- pTokenizer->pModule = pModule;
zExpr = (const char *)sqlite3_value_text(argv[1]);
nExpr = sqlite3_value_bytes(argv[1]);
@@ -158319,7 +160026,7 @@ static void fts3ExprTest(
azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);
}
- if( sqlite3_user_data(context) ){
+ if( bRebalance ){
char *zDummy = 0;
rc = sqlite3Fts3ExprParse(
pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy
@@ -158345,23 +160052,38 @@ static void fts3ExprTest(
sqlite3Fts3ExprFree(pExpr);
exprtest_out:
- if( pModule && pTokenizer ){
- rc = pModule->xDestroy(pTokenizer);
+ if( pTokenizer ){
+ rc = pTokenizer->pModule->xDestroy(pTokenizer);
}
sqlite3_free(azCol);
}
+static void fts3ExprTest(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ fts3ExprTestCommon(0, context, argc, argv);
+}
+static void fts3ExprTestRebalance(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ fts3ExprTestCommon(1, context, argc, argv);
+}
+
/*
** Register the query expression parser test function fts3_exprtest()
** with database connection db.
*/
-SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash *pHash){
int rc = sqlite3_create_function(
- db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
+ db, "fts3_exprtest", -1, SQLITE_UTF8, (void*)pHash, fts3ExprTest, 0, 0
);
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "fts3_exprtest_rebalance",
- -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0
+ -1, SQLITE_UTF8, (void*)pHash, fts3ExprTestRebalance, 0, 0
);
}
return rc;
@@ -168822,14 +170544,15 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){
**
** CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
-** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
+** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)
**
** The data for each node of the r-tree structure is stored in the %_node
** table. For each node that is not the root node of the r-tree, there is
** an entry in the %_parent table associating the node with its parent.
** And for each row of data in the table, there is an entry in the %_rowid
** table that maps from the entries rowid to the id of the node that it
-** is stored on.
+** is stored on. If the r-tree contains auxiliary columns, those are stored
+** on the end of the %_rowid table.
**
** The root node of an r-tree always exists, even if the r-tree table is
** empty. The nodeno of the root node is always 1. All other nodes in the
@@ -168892,6 +170615,9 @@ typedef struct RtreeSearchPoint RtreeSearchPoint;
/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */
#define RTREE_MAX_DIMENSIONS 5
+/* Maximum number of auxiliary columns */
+#define RTREE_MAX_AUX_COLUMN 100
+
/* Size of hash table Rtree.aHash. This hash table is not expected to
** ever contain very many entries, so a fixed number of buckets is
** used.
@@ -168920,12 +170646,15 @@ struct Rtree {
u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */
u8 nBytesPerCell; /* Bytes consumed per cell */
u8 inWrTrans; /* True if inside write transaction */
+ u8 nAux; /* # of auxiliary columns in %_rowid */
int iDepth; /* Current depth of the r-tree structure */
char *zDb; /* Name of database containing r-tree table */
char *zName; /* Name of r-tree table */
u32 nBusy; /* Current number of users of this structure */
i64 nRowEst; /* Estimated number of rows in this table */
u32 nCursor; /* Number of open cursors */
+ u32 nNodeRef; /* Number RtreeNodes with positive nRef */
+ char *zReadAuxSql; /* SQL for statement to read aux data */
/* List of nodes removed during a CondenseTree operation. List is
** linked together via the pointer normally used for hash chains -
@@ -168952,6 +170681,9 @@ struct Rtree {
sqlite3_stmt *pWriteParent;
sqlite3_stmt *pDeleteParent;
+ /* Statement for writing to the "aux:" fields, if there are any */
+ sqlite3_stmt *pWriteAux;
+
RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */
};
@@ -169028,6 +170760,7 @@ struct RtreeCursor {
sqlite3_vtab_cursor base; /* Base class. Must be first */
u8 atEOF; /* True if at end of search */
u8 bPoint; /* True if sPoint is valid */
+ u8 bAuxValid; /* True if pReadAux is valid */
int iStrategy; /* Copy of idxNum search parameter */
int nConstraint; /* Number of entries in aConstraint */
RtreeConstraint *aConstraint; /* Search constraints. */
@@ -169035,6 +170768,7 @@ struct RtreeCursor {
int nPoint; /* Number of slots used in aPoint[] */
int mxLevel; /* iLevel value for root of the tree */
RtreeSearchPoint *aPoint; /* Priority queue for search points */
+ sqlite3_stmt *pReadAux; /* Statement to read aux-data */
RtreeSearchPoint sPoint; /* Cached next search point */
RtreeNode *aNode[RTREE_CACHE_SZ]; /* Rtree node cache */
u32 anQueue[RTREE_MAX_DEPTH+1]; /* Number of queued entries by iLevel */
@@ -169321,6 +171055,7 @@ static int writeInt64(u8 *p, i64 i){
*/
static void nodeReference(RtreeNode *p){
if( p ){
+ assert( p->nRef>0 );
p->nRef++;
}
}
@@ -169388,6 +171123,7 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
pNode->zData = (u8 *)&pNode[1];
pNode->nRef = 1;
+ pRtree->nNodeRef++;
pNode->pParent = pParent;
pNode->isDirty = 1;
nodeReference(pParent);
@@ -169421,10 +171157,10 @@ static int nodeAcquire(
/* Check if the requested node is already in the hash table. If so,
** increase its reference count and return it.
*/
- if( (pNode = nodeHashLookup(pRtree, iNode)) ){
+ if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
if( pParent && !pNode->pParent ){
- nodeReference(pParent);
+ pParent->nRef++;
pNode->pParent = pParent;
}
pNode->nRef++;
@@ -169463,6 +171199,7 @@ static int nodeAcquire(
pNode->pParent = pParent;
pNode->zData = (u8 *)&pNode[1];
pNode->nRef = 1;
+ pRtree->nNodeRef++;
pNode->iNode = iNode;
pNode->isDirty = 0;
pNode->pNext = 0;
@@ -169503,7 +171240,10 @@ static int nodeAcquire(
}
*ppNode = pNode;
}else{
- sqlite3_free(pNode);
+ if( pNode ){
+ pRtree->nNodeRef--;
+ sqlite3_free(pNode);
+ }
*ppNode = 0;
}
@@ -169600,8 +171340,10 @@ static int nodeRelease(Rtree *pRtree, RtreeNode *pNode){
int rc = SQLITE_OK;
if( pNode ){
assert( pNode->nRef>0 );
+ assert( pRtree->nNodeRef>0 );
pNode->nRef--;
if( pNode->nRef==0 ){
+ pRtree->nNodeRef--;
if( pNode->iNode==1 ){
pRtree->iDepth = -1;
}
@@ -169718,8 +171460,9 @@ static void rtreeRelease(Rtree *pRtree){
pRtree->nBusy--;
if( pRtree->nBusy==0 ){
pRtree->inWrTrans = 0;
- pRtree->nCursor = 0;
+ assert( pRtree->nCursor==0 );
nodeBlobReset(pRtree);
+ assert( pRtree->nNodeRef==0 );
sqlite3_finalize(pRtree->pWriteNode);
sqlite3_finalize(pRtree->pDeleteNode);
sqlite3_finalize(pRtree->pReadRowid);
@@ -169728,6 +171471,8 @@ static void rtreeRelease(Rtree *pRtree){
sqlite3_finalize(pRtree->pReadParent);
sqlite3_finalize(pRtree->pWriteParent);
sqlite3_finalize(pRtree->pDeleteParent);
+ sqlite3_finalize(pRtree->pWriteAux);
+ sqlite3_free(pRtree->zReadAuxSql);
sqlite3_free(pRtree);
}
}
@@ -169816,6 +171561,7 @@ static int rtreeClose(sqlite3_vtab_cursor *cur){
RtreeCursor *pCsr = (RtreeCursor *)cur;
assert( pRtree->nCursor>0 );
freeCursorConstraints(pCsr);
+ sqlite3_finalize(pCsr->pReadAux);
sqlite3_free(pCsr->aPoint);
for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
sqlite3_free(pCsr);
@@ -170187,7 +171933,7 @@ static RtreeSearchPoint *rtreeSearchPointNew(
if( ii<RTREE_CACHE_SZ ){
assert( pCur->aNode[ii]==0 );
pCur->aNode[ii] = pCur->aNode[0];
- }else{
+ }else{
nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]);
}
pCur->aNode[0] = 0;
@@ -170358,6 +172104,10 @@ static int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){
/* Move to the next entry that matches the configured constraints. */
RTREE_QUEUE_TRACE(pCsr, "POP-Nx:");
+ if( pCsr->bAuxValid ){
+ pCsr->bAuxValid = 0;
+ sqlite3_reset(pCsr->pReadAux);
+ }
rtreeSearchPointPop(pCsr);
rc = rtreeStepToLeaf(pCsr);
return rc;
@@ -170392,7 +172142,7 @@ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
if( p==0 ) return SQLITE_OK;
if( i==0 ){
sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));
- }else{
+ }else if( i<=pRtree->nDim2 ){
nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);
#ifndef SQLITE_RTREE_INT_ONLY
if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
@@ -170403,7 +172153,27 @@ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
assert( pRtree->eCoordType==RTREE_COORD_INT32 );
sqlite3_result_int(ctx, c.i);
}
- }
+ }else{
+ if( !pCsr->bAuxValid ){
+ if( pCsr->pReadAux==0 ){
+ rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,
+ &pCsr->pReadAux, 0);
+ if( rc ) return rc;
+ }
+ sqlite3_bind_int64(pCsr->pReadAux, 1,
+ nodeGetRowid(pRtree, pNode, p->iCell));
+ rc = sqlite3_step(pCsr->pReadAux);
+ if( rc==SQLITE_ROW ){
+ pCsr->bAuxValid = 1;
+ }else{
+ sqlite3_reset(pCsr->pReadAux);
+ if( rc==SQLITE_DONE ) rc = SQLITE_OK;
+ return rc;
+ }
+ }
+ sqlite3_result_value(ctx,
+ sqlite3_column_value(pCsr->pReadAux, i - pRtree->nDim2 + 1));
+ }
return SQLITE_OK;
}
@@ -170481,14 +172251,17 @@ static int rtreeFilter(
int ii;
int rc = SQLITE_OK;
int iCell = 0;
+ sqlite3_stmt *pStmt;
rtreeReference(pRtree);
/* Reset the cursor to the same state as rtreeOpen() leaves it in. */
freeCursorConstraints(pCsr);
sqlite3_free(pCsr->aPoint);
+ pStmt = pCsr->pReadAux;
memset(pCsr, 0, sizeof(RtreeCursor));
pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
+ pCsr->pReadAux = pStmt;
pCsr->iStrategy = idxNum;
if( idxNum==1 ){
@@ -170651,10 +172424,14 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
*/
pIdxInfo->estimatedCost = 30.0;
pIdxInfo->estimatedRows = 1;
+ pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;
return SQLITE_OK;
}
- if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){
+ if( p->usable
+ && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2)
+ || p->op==SQLITE_INDEX_CONSTRAINT_MATCH)
+ ){
u8 op;
switch( p->op ){
case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
@@ -171227,7 +173004,7 @@ static int SplitNode(
}else{
pLeft = pNode;
pRight = nodeNew(pRtree, pLeft->pParent);
- nodeReference(pLeft);
+ pLeft->nRef++;
}
if( !pLeft || !pRight ){
@@ -171717,6 +173494,7 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
rc = reinsertNodeContent(pRtree, pLeaf);
}
pRtree->pDeleted = pLeaf->pNext;
+ pRtree->nNodeRef--;
sqlite3_free(pLeaf);
}
@@ -171813,7 +173591,7 @@ static int rtreeConstraintError(Rtree *pRtree, int iCol){
static int rtreeUpdate(
sqlite3_vtab *pVtab,
int nData,
- sqlite3_value **azData,
+ sqlite3_value **aData,
sqlite_int64 *pRowid
){
Rtree *pRtree = (Rtree *)pVtab;
@@ -171821,6 +173599,12 @@ static int rtreeUpdate(
RtreeCell cell; /* New cell to insert if nData>1 */
int bHaveRowid = 0; /* Set to 1 after new rowid is determined */
+ if( pRtree->nNodeRef ){
+ /* Unable to write to the btree while another cursor is reading from it,
+ ** since the write might do a rebalance which would disrupt the read
+ ** cursor. */
+ return SQLITE_LOCKED_VTAB;
+ }
rtreeReference(pRtree);
assert(nData>=1);
@@ -171839,8 +173623,10 @@ static int rtreeUpdate(
*/
if( nData>1 ){
int ii;
+ int nn = nData - 4;
- /* Populate the cell.aCoord[] array. The first coordinate is azData[3].
+ if( nn > pRtree->nDim2 ) nn = pRtree->nDim2;
+ /* Populate the cell.aCoord[] array. The first coordinate is aData[3].
**
** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared
** with "column" that are interpreted as table constraints.
@@ -171848,13 +173634,12 @@ static int rtreeUpdate(
** This problem was discovered after years of use, so we silently ignore
** these kinds of misdeclared tables to avoid breaking any legacy.
*/
- assert( nData<=(pRtree->nDim2 + 3) );
#ifndef SQLITE_RTREE_INT_ONLY
if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
- for(ii=0; ii<nData-4; ii+=2){
- cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
- cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
+ for(ii=0; ii<nn; ii+=2){
+ cell.aCoord[ii].f = rtreeValueDown(aData[ii+3]);
+ cell.aCoord[ii+1].f = rtreeValueUp(aData[ii+4]);
if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
rc = rtreeConstraintError(pRtree, ii+1);
goto constraint;
@@ -171863,9 +173648,9 @@ static int rtreeUpdate(
}else
#endif
{
- for(ii=0; ii<nData-4; ii+=2){
- cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
- cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
+ for(ii=0; ii<nn; ii+=2){
+ cell.aCoord[ii].i = sqlite3_value_int(aData[ii+3]);
+ cell.aCoord[ii+1].i = sqlite3_value_int(aData[ii+4]);
if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
rc = rtreeConstraintError(pRtree, ii+1);
goto constraint;
@@ -171875,10 +173660,10 @@ static int rtreeUpdate(
/* If a rowid value was supplied, check if it is already present in
** the table. If so, the constraint has failed. */
- if( sqlite3_value_type(azData[2])!=SQLITE_NULL ){
- cell.iRowid = sqlite3_value_int64(azData[2]);
- if( sqlite3_value_type(azData[0])==SQLITE_NULL
- || sqlite3_value_int64(azData[0])!=cell.iRowid
+ if( sqlite3_value_type(aData[2])!=SQLITE_NULL ){
+ cell.iRowid = sqlite3_value_int64(aData[2]);
+ if( sqlite3_value_type(aData[0])==SQLITE_NULL
+ || sqlite3_value_int64(aData[0])!=cell.iRowid
){
int steprc;
sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);
@@ -171897,16 +173682,16 @@ static int rtreeUpdate(
}
}
- /* If azData[0] is not an SQL NULL value, it is the rowid of a
+ /* If aData[0] is not an SQL NULL value, it is the rowid of a
** record to delete from the r-tree table. The following block does
** just that.
*/
- if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){
- rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(azData[0]));
+ if( sqlite3_value_type(aData[0])!=SQLITE_NULL ){
+ rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(aData[0]));
}
- /* If the azData[] array contains more than one element, elements
- ** (azData[2]..azData[argc-1]) contain a new record to insert into
+ /* If the aData[] array contains more than one element, elements
+ ** (aData[2]..aData[argc-1]) contain a new record to insert into
** the r-tree structure.
*/
if( rc==SQLITE_OK && nData>1 ){
@@ -171931,6 +173716,16 @@ static int rtreeUpdate(
rc = rc2;
}
}
+ if( pRtree->nAux ){
+ sqlite3_stmt *pUp = pRtree->pWriteAux;
+ int jj;
+ sqlite3_bind_int64(pUp, 1, *pRowid);
+ for(jj=0; jj<pRtree->nAux; jj++){
+ sqlite3_bind_value(pUp, jj+2, aData[pRtree->nDim2+3+jj]);
+ }
+ sqlite3_step(pUp);
+ rc = sqlite3_reset(pUp);
+ }
}
constraint:
@@ -172087,18 +173882,18 @@ static int rtreeSqlInit(
#define N_STATEMENT 8
static const char *azSql[N_STATEMENT] = {
/* Write the xxx_node table */
- "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)",
- "DELETE FROM '%q'.'%q_node' WHERE nodeno = :1",
+ "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)",
+ "DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1",
/* Read and write the xxx_rowid table */
- "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1",
- "INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)",
- "DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1",
+ "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1",
+ "INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)",
+ "DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1",
/* Read and write the xxx_parent table */
- "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1",
- "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)",
- "DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1"
+ "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1",
+ "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)",
+ "DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1"
};
sqlite3_stmt **appStmt[N_STATEMENT];
int i;
@@ -172106,14 +173901,25 @@ static int rtreeSqlInit(
pRtree->db = db;
if( isCreate ){
- char *zCreate = sqlite3_mprintf(
-"CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB);"
-"CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);"
-"CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,"
- " parentnode INTEGER);"
-"INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))",
- zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize
- );
+ char *zCreate;
+ sqlite3_str *p = sqlite3_str_new(db);
+ int ii;
+ sqlite3_str_appendf(p,
+ "CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY,nodeno",
+ zDb, zPrefix);
+ for(ii=0; ii<pRtree->nAux; ii++){
+ sqlite3_str_appendf(p,",a%d",ii);
+ }
+ sqlite3_str_appendf(p,
+ ");CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY,data);",
+ zDb, zPrefix);
+ sqlite3_str_appendf(p,
+ "CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,parentnode);",
+ zDb, zPrefix);
+ sqlite3_str_appendf(p,
+ "INSERT INTO \"%w\".\"%w_node\"VALUES(1,zeroblob(%d))",
+ zDb, zPrefix, pRtree->iNodeSize);
+ zCreate = sqlite3_str_finish(p);
if( !zCreate ){
return SQLITE_NOMEM;
}
@@ -172135,7 +173941,17 @@ static int rtreeSqlInit(
rc = rtreeQueryStat1(db, pRtree);
for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
- char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
+ char *zSql;
+ const char *zFormat;
+ if( i!=3 || pRtree->nAux==0 ){
+ zFormat = azSql[i];
+ }else {
+ /* An UPSERT is very slightly slower than REPLACE, but it is needed
+ ** if there are auxiliary columns */
+ zFormat = "INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)"
+ "ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno";
+ }
+ zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);
if( zSql ){
rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
appStmt[i], 0);
@@ -172144,6 +173960,32 @@ static int rtreeSqlInit(
}
sqlite3_free(zSql);
}
+ if( pRtree->nAux ){
+ pRtree->zReadAuxSql = sqlite3_mprintf(
+ "SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1",
+ zDb, zPrefix);
+ if( pRtree->zReadAuxSql==0 ){
+ rc = SQLITE_NOMEM;
+ }else{
+ sqlite3_str *p = sqlite3_str_new(db);
+ int ii;
+ char *zSql;
+ sqlite3_str_appendf(p, "UPDATE \"%w\".\"%w_rowid\"SET ", zDb, zPrefix);
+ for(ii=0; ii<pRtree->nAux; ii++){
+ if( ii ) sqlite3_str_append(p, ",", 1);
+ sqlite3_str_appendf(p,"a%d=?%d",ii,ii+2);
+ }
+ sqlite3_str_appendf(p, " WHERE rowid=?1");
+ zSql = sqlite3_str_finish(p);
+ if( zSql==0 ){
+ rc = SQLITE_NOMEM;
+ }else{
+ rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
+ &pRtree->pWriteAux, 0);
+ sqlite3_free(zSql);
+ }
+ }
+ }
return rc;
}
@@ -172246,17 +174088,22 @@ static int rtreeInit(
int nDb; /* Length of string argv[1] */
int nName; /* Length of string argv[2] */
int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);
+ sqlite3_str *pSql;
+ char *zSql;
+ int ii = 4;
+ int iErr;
const char *aErrMsg[] = {
0, /* 0 */
"Wrong number of columns for an rtree table", /* 1 */
"Too few columns for an rtree table", /* 2 */
- "Too many columns for an rtree table" /* 3 */
+ "Too many columns for an rtree table", /* 3 */
+ "Auxiliary rtree columns must be last" /* 4 */
};
- int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2;
- if( aErrMsg[iErr] ){
- *pzErr = sqlite3_mprintf("%s", aErrMsg[iErr]);
+ assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
+ if( argc>RTREE_MAX_AUX_COLUMN+3 ){
+ *pzErr = sqlite3_mprintf("%s", aErrMsg[3]);
return SQLITE_ERROR;
}
@@ -172274,53 +174121,73 @@ static int rtreeInit(
pRtree->base.pModule = &rtreeModule;
pRtree->zDb = (char *)&pRtree[1];
pRtree->zName = &pRtree->zDb[nDb+1];
- pRtree->nDim = (u8)((argc-4)/2);
- pRtree->nDim2 = pRtree->nDim*2;
- pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;
pRtree->eCoordType = (u8)eCoordType;
memcpy(pRtree->zDb, argv[1], nDb);
memcpy(pRtree->zName, argv[2], nName);
- /* Figure out the node size to use. */
- rc = getNodeSize(db, pRtree, isCreate, pzErr);
/* Create/Connect to the underlying relational database schema. If
** that is successful, call sqlite3_declare_vtab() to configure
** the r-tree table schema.
*/
- if( rc==SQLITE_OK ){
- if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){
- *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ pSql = sqlite3_str_new(db);
+ sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]);
+ for(ii=4; ii<argc; ii++){
+ if( argv[ii][0]=='+' ){
+ pRtree->nAux++;
+ sqlite3_str_appendf(pSql, ",%s", argv[ii]+1);
+ }else if( pRtree->nAux>0 ){
+ break;
}else{
- char *zSql = sqlite3_mprintf("CREATE TABLE x(%s", argv[3]);
- char *zTmp;
- int ii;
- for(ii=4; zSql && ii<argc; ii++){
- zTmp = zSql;
- zSql = sqlite3_mprintf("%s, %s", zTmp, argv[ii]);
- sqlite3_free(zTmp);
- }
- if( zSql ){
- zTmp = zSql;
- zSql = sqlite3_mprintf("%s);", zTmp);
- sqlite3_free(zTmp);
- }
- if( !zSql ){
- rc = SQLITE_NOMEM;
- }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
- *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
- }
- sqlite3_free(zSql);
+ pRtree->nDim2++;
+ sqlite3_str_appendf(pSql, ",%s", argv[ii]);
}
}
+ sqlite3_str_appendf(pSql, ");");
+ zSql = sqlite3_str_finish(pSql);
+ if( !zSql ){
+ rc = SQLITE_NOMEM;
+ }else if( ii<argc ){
+ *pzErr = sqlite3_mprintf("%s", aErrMsg[4]);
+ rc = SQLITE_ERROR;
+ }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){
+ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ }
+ sqlite3_free(zSql);
+ if( rc ) goto rtreeInit_fail;
+ pRtree->nDim = pRtree->nDim2/2;
+ if( pRtree->nDim<1 ){
+ iErr = 2;
+ }else if( pRtree->nDim2>RTREE_MAX_DIMENSIONS*2 ){
+ iErr = 3;
+ }else if( pRtree->nDim2 % 2 ){
+ iErr = 1;
+ }else{
+ iErr = 0;
+ }
+ if( iErr ){
+ *pzErr = sqlite3_mprintf("%s", aErrMsg[iErr]);
+ goto rtreeInit_fail;
+ }
+ pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;
- if( rc==SQLITE_OK ){
- *ppVtab = (sqlite3_vtab *)pRtree;
- }else{
- assert( *ppVtab==0 );
- assert( pRtree->nBusy==1 );
- rtreeRelease(pRtree);
+ /* Figure out the node size to use. */
+ rc = getNodeSize(db, pRtree, isCreate, pzErr);
+ if( rc ) goto rtreeInit_fail;
+ rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);
+ if( rc ){
+ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
+ goto rtreeInit_fail;
}
+
+ *ppVtab = (sqlite3_vtab *)pRtree;
+ return SQLITE_OK;
+
+rtreeInit_fail:
+ if( rc==SQLITE_OK ) rc = SQLITE_ERROR;
+ assert( *ppVtab==0 );
+ assert( pRtree->nBusy==1 );
+ rtreeRelease(pRtree);
return rc;
}
@@ -172549,7 +174416,7 @@ static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
** two tables are:
**
** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
-** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
+** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)
**
** In both cases, this function checks that there exists an entry with
** IPK value iKey and the second column set to iVal.
@@ -172564,8 +174431,8 @@ static void rtreeCheckMapping(
int rc;
sqlite3_stmt *pStmt;
const char *azSql[2] = {
- "SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?",
- "SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?"
+ "SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1",
+ "SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1"
};
assert( bLeaf==0 || bLeaf==1 );
@@ -172749,6 +174616,7 @@ static int rtreeCheckTable(
RtreeCheck check; /* Common context for various routines */
sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */
int bEnd = 0; /* True if transaction should be closed */
+ int nAux = 0; /* Number of extra columns. */
/* Initialize the context object */
memset(&check, 0, sizeof(check));
@@ -172764,11 +174632,21 @@ static int rtreeCheckTable(
bEnd = 1;
}
+ /* Find the number of auxiliary columns */
+ if( check.rc==SQLITE_OK ){
+ pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
+ if( pStmt ){
+ nAux = sqlite3_column_count(pStmt) - 2;
+ sqlite3_finalize(pStmt);
+ }
+ check.rc = SQLITE_OK;
+ }
+
/* Find number of dimensions in the rtree table. */
pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab);
if( pStmt ){
int rc;
- check.nDim = (sqlite3_column_count(pStmt) - 1) / 2;
+ check.nDim = (sqlite3_column_count(pStmt) - 1 - nAux) / 2;
if( check.nDim<1 ){
rtreeCheckAppendMsg(&check, "Schema corrupt or not an rtree");
}else if( SQLITE_ROW==sqlite3_step(pStmt) ){
@@ -174618,6 +176496,10 @@ SQLITE_API void sqlite3rbu_destroy_vfs(const char *zName);
**
** RBU_STATE_OALSZ:
** Valid if STAGE==1. The size in bytes of the *-oal file.
+**
+** RBU_STATE_DATATBL:
+** Only valid if STAGE==1. The RBU database name of the table
+** currently being read.
*/
#define RBU_STATE_STAGE 1
#define RBU_STATE_TBL 2
@@ -174628,6 +176510,7 @@ SQLITE_API void sqlite3rbu_destroy_vfs(const char *zName);
#define RBU_STATE_COOKIE 7
#define RBU_STATE_OALSZ 8
#define RBU_STATE_PHASEONESTEP 9
+#define RBU_STATE_DATATBL 10
#define RBU_STAGE_OAL 1
#define RBU_STAGE_MOVE 2
@@ -174670,6 +176553,7 @@ typedef sqlite3_int64 i64;
struct RbuState {
int eStage;
char *zTbl;
+ char *zDataTbl;
char *zIdx;
i64 iWalCksum;
int nRow;
@@ -176733,6 +178617,7 @@ static sqlite3 *rbuOpenDbhandle(
static void rbuFreeState(RbuState *p){
if( p ){
sqlite3_free(p->zTbl);
+ sqlite3_free(p->zDataTbl);
sqlite3_free(p->zIdx);
sqlite3_free(p);
}
@@ -176803,6 +178688,10 @@ static RbuState *rbuLoadState(sqlite3rbu *p){
pRet->nPhaseOneStep = sqlite3_column_int64(pStmt, 1);
break;
+ case RBU_STATE_DATATBL:
+ pRet->zDataTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);
+ break;
+
default:
rc = SQLITE_CORRUPT;
break;
@@ -177577,7 +179466,8 @@ static void rbuSaveState(sqlite3rbu *p, int eStage){
"(%d, %lld), "
"(%d, %lld), "
"(%d, %lld), "
- "(%d, %lld) ",
+ "(%d, %lld), "
+ "(%d, %Q) ",
p->zStateDb,
RBU_STATE_STAGE, eStage,
RBU_STATE_TBL, p->objiter.zTbl,
@@ -177587,7 +179477,8 @@ static void rbuSaveState(sqlite3rbu *p, int eStage){
RBU_STATE_CKPT, p->iWalCksum,
RBU_STATE_COOKIE, (i64)pFd->iCookie,
RBU_STATE_OALSZ, p->iOalSz,
- RBU_STATE_PHASEONESTEP, p->nPhaseOneStep
+ RBU_STATE_PHASEONESTEP, p->nPhaseOneStep,
+ RBU_STATE_DATATBL, p->objiter.zDataTbl
)
);
assert( pInsert==0 || rc==SQLITE_OK );
@@ -177843,7 +179734,8 @@ static void rbuSetupOal(sqlite3rbu *p, RbuState *pState){
while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup
|| rbuStrCompare(pIter->zIdx, pState->zIdx)
- || rbuStrCompare(pIter->zTbl, pState->zTbl)
+ || (pState->zDataTbl==0 && rbuStrCompare(pIter->zTbl, pState->zTbl))
+ || (pState->zDataTbl && rbuStrCompare(pIter->zDataTbl, pState->zDataTbl))
)){
rc = rbuObjIterNext(p, pIter);
}
@@ -187962,7 +189854,7 @@ static int jsonEachColumn(
}
if( p->eType==JSON_ARRAY ){
jsonPrintf(30, &x, "[%d]", p->iRowid);
- }else{
+ }else if( p->eType==JSON_OBJECT ){
jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1);
}
}
@@ -189767,8 +191659,10 @@ static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
** zero the stack is dynamically sized using realloc()
** sqlite3Fts5ParserARG_SDECL A static variable declaration for the %extra_argument
** sqlite3Fts5ParserARG_PDECL A parameter declaration for the %extra_argument
+** sqlite3Fts5ParserARG_PARAM Code to pass %extra_argument as a subroutine parameter
** sqlite3Fts5ParserARG_STORE Code to store %extra_argument into fts5yypParser
** sqlite3Fts5ParserARG_FETCH Code to extract %extra_argument from fts5yypParser
+** sqlite3Fts5ParserCTX_* As sqlite3Fts5ParserARG_ except for %extra_context
** fts5YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing.
** fts5YYNSTATE the combined number of states.
@@ -189788,25 +191682,31 @@ static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
#endif
/************* Begin control #defines *****************************************/
#define fts5YYCODETYPE unsigned char
-#define fts5YYNOCODE 29
+#define fts5YYNOCODE 27
#define fts5YYACTIONTYPE unsigned char
#define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token
typedef union {
int fts5yyinit;
sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0;
int fts5yy4;
- Fts5ExprPhrase* fts5yy11;
- Fts5ExprNearset* fts5yy14;
- Fts5Colset* fts5yy43;
- Fts5ExprNode* fts5yy54;
+ Fts5Colset* fts5yy11;
+ Fts5ExprNode* fts5yy24;
+ Fts5ExprNearset* fts5yy46;
+ Fts5ExprPhrase* fts5yy53;
} fts5YYMINORTYPE;
#ifndef fts5YYSTACKDEPTH
#define fts5YYSTACKDEPTH 100
#endif
#define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse;
#define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse
-#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse
-#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse
+#define sqlite3Fts5ParserARG_PARAM ,pParse
+#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse;
+#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse;
+#define sqlite3Fts5ParserCTX_SDECL
+#define sqlite3Fts5ParserCTX_PDECL
+#define sqlite3Fts5ParserCTX_PARAM
+#define sqlite3Fts5ParserCTX_FETCH
+#define sqlite3Fts5ParserCTX_STORE
#define fts5YYNSTATE 35
#define fts5YYNRULE 28
#define fts5YYNFTS5TOKEN 16
@@ -189887,46 +191787,46 @@ typedef union {
static const fts5YYACTIONTYPE fts5yy_action[] = {
/* 0 */ 81, 20, 96, 6, 28, 99, 98, 26, 26, 18,
/* 10 */ 96, 6, 28, 17, 98, 56, 26, 19, 96, 6,
- /* 20 */ 28, 14, 98, 108, 26, 92, 96, 6, 28, 25,
- /* 30 */ 98, 78, 26, 21, 96, 6, 28, 107, 98, 58,
- /* 40 */ 26, 29, 96, 6, 28, 32, 98, 22, 26, 24,
- /* 50 */ 16, 23, 11, 1, 14, 13, 24, 16, 31, 11,
- /* 60 */ 3, 97, 13, 27, 8, 98, 82, 26, 7, 4,
- /* 70 */ 5, 3, 4, 5, 3, 83, 4, 5, 3, 63,
- /* 80 */ 33, 34, 62, 12, 2, 86, 13, 10, 12, 71,
- /* 90 */ 10, 13, 78, 5, 3, 78, 9, 30, 75, 82,
- /* 100 */ 54, 57, 53, 57, 15,
+ /* 20 */ 28, 14, 98, 14, 26, 31, 92, 96, 6, 28,
+ /* 30 */ 108, 98, 25, 26, 21, 96, 6, 28, 78, 98,
+ /* 40 */ 58, 26, 29, 96, 6, 28, 107, 98, 22, 26,
+ /* 50 */ 24, 16, 12, 11, 1, 13, 13, 24, 16, 23,
+ /* 60 */ 11, 33, 34, 13, 97, 8, 27, 32, 98, 7,
+ /* 70 */ 26, 3, 4, 5, 3, 4, 5, 3, 83, 4,
+ /* 80 */ 5, 3, 63, 5, 3, 62, 12, 2, 86, 13,
+ /* 90 */ 9, 30, 10, 10, 54, 57, 75, 78, 78, 53,
+ /* 100 */ 57, 15, 82, 82, 71,
};
static const fts5YYCODETYPE fts5yy_lookahead[] = {
- /* 0 */ 17, 18, 19, 20, 21, 23, 23, 25, 25, 18,
- /* 10 */ 19, 20, 21, 7, 23, 9, 25, 18, 19, 20,
- /* 20 */ 21, 9, 23, 27, 25, 18, 19, 20, 21, 25,
- /* 30 */ 23, 15, 25, 18, 19, 20, 21, 27, 23, 9,
- /* 40 */ 25, 18, 19, 20, 21, 14, 23, 22, 25, 6,
- /* 50 */ 7, 22, 9, 10, 9, 12, 6, 7, 13, 9,
- /* 60 */ 3, 19, 12, 21, 5, 23, 28, 25, 5, 1,
- /* 70 */ 2, 3, 1, 2, 3, 0, 1, 2, 3, 11,
- /* 80 */ 25, 26, 11, 9, 10, 5, 12, 10, 9, 11,
- /* 90 */ 10, 12, 15, 2, 3, 15, 24, 25, 9, 28,
- /* 100 */ 8, 9, 8, 9, 9, 28, 28, 28, 28, 28,
- /* 110 */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- /* 120 */ 28,
+ /* 0 */ 16, 17, 18, 19, 20, 22, 22, 24, 24, 17,
+ /* 10 */ 18, 19, 20, 7, 22, 9, 24, 17, 18, 19,
+ /* 20 */ 20, 9, 22, 9, 24, 13, 17, 18, 19, 20,
+ /* 30 */ 26, 22, 24, 24, 17, 18, 19, 20, 15, 22,
+ /* 40 */ 9, 24, 17, 18, 19, 20, 26, 22, 21, 24,
+ /* 50 */ 6, 7, 9, 9, 10, 12, 12, 6, 7, 21,
+ /* 60 */ 9, 24, 25, 12, 18, 5, 20, 14, 22, 5,
+ /* 70 */ 24, 3, 1, 2, 3, 1, 2, 3, 0, 1,
+ /* 80 */ 2, 3, 11, 2, 3, 11, 9, 10, 5, 12,
+ /* 90 */ 23, 24, 10, 10, 8, 9, 9, 15, 15, 8,
+ /* 100 */ 9, 9, 27, 27, 11, 27, 27, 27, 27, 27,
+ /* 110 */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ /* 120 */ 27,
};
#define fts5YY_SHIFT_COUNT (34)
#define fts5YY_SHIFT_MIN (0)
-#define fts5YY_SHIFT_MAX (95)
+#define fts5YY_SHIFT_MAX (93)
static const unsigned char fts5yy_shift_ofst[] = {
- /* 0 */ 43, 43, 43, 43, 43, 43, 50, 74, 79, 45,
- /* 10 */ 12, 80, 77, 12, 16, 16, 30, 30, 68, 71,
- /* 20 */ 75, 91, 92, 94, 6, 31, 31, 59, 63, 57,
- /* 30 */ 31, 89, 95, 31, 78,
+ /* 0 */ 44, 44, 44, 44, 44, 44, 51, 77, 43, 12,
+ /* 10 */ 14, 83, 82, 14, 23, 23, 31, 31, 71, 74,
+ /* 20 */ 78, 81, 86, 91, 6, 53, 53, 60, 64, 68,
+ /* 30 */ 53, 87, 92, 53, 93,
};
#define fts5YY_REDUCE_COUNT (17)
-#define fts5YY_REDUCE_MIN (-18)
-#define fts5YY_REDUCE_MAX (72)
+#define fts5YY_REDUCE_MIN (-17)
+#define fts5YY_REDUCE_MAX (67)
static const signed char fts5yy_reduce_ofst[] = {
- /* 0 */ -17, -9, -1, 7, 15, 23, 42, -18, -18, 55,
- /* 10 */ 72, -4, -4, 4, -4, 10, 25, 29,
+ /* 0 */ -16, -8, 0, 9, 17, 25, 46, -17, -17, 37,
+ /* 10 */ 67, 4, 4, 8, 4, 20, 27, 38,
};
static const fts5YYACTIONTYPE fts5yy_default[] = {
/* 0 */ 80, 80, 80, 80, 80, 80, 95, 80, 80, 105,
@@ -189991,6 +191891,7 @@ struct fts5yyParser {
int fts5yyerrcnt; /* Shifts left before out of the error */
#endif
sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
+ sqlite3Fts5ParserCTX_SDECL /* A place to hold %extra_context */
#if fts5YYSTACKDEPTH<=0
int fts5yystksz; /* Current side of the stack */
fts5yyStackEntry *fts5yystack; /* The parser's stack */
@@ -190054,18 +191955,17 @@ static const char *const fts5yyTokenName[] = {
/* 13 */ "COMMA",
/* 14 */ "PLUS",
/* 15 */ "STAR",
- /* 16 */ "error",
- /* 17 */ "input",
- /* 18 */ "expr",
- /* 19 */ "cnearset",
- /* 20 */ "exprlist",
- /* 21 */ "colset",
- /* 22 */ "colsetlist",
- /* 23 */ "nearset",
- /* 24 */ "nearphrases",
- /* 25 */ "phrase",
- /* 26 */ "neardist_opt",
- /* 27 */ "star_opt",
+ /* 16 */ "input",
+ /* 17 */ "expr",
+ /* 18 */ "cnearset",
+ /* 19 */ "exprlist",
+ /* 20 */ "colset",
+ /* 21 */ "colsetlist",
+ /* 22 */ "nearset",
+ /* 23 */ "nearphrases",
+ /* 24 */ "phrase",
+ /* 25 */ "neardist_opt",
+ /* 26 */ "star_opt",
};
#endif /* defined(fts5YYCOVERAGE) || !defined(NDEBUG) */
@@ -190149,28 +192049,29 @@ static int fts5yyGrowStack(fts5yyParser *p){
/* Initialize a new parser that has already been allocated.
*/
-static void sqlite3Fts5ParserInit(void *fts5yypParser){
- fts5yyParser *pParser = (fts5yyParser*)fts5yypParser;
+static void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PDECL){
+ fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yypRawParser;
+ sqlite3Fts5ParserCTX_STORE
#ifdef fts5YYTRACKMAXSTACKDEPTH
- pParser->fts5yyhwm = 0;
+ fts5yypParser->fts5yyhwm = 0;
#endif
#if fts5YYSTACKDEPTH<=0
- pParser->fts5yytos = NULL;
- pParser->fts5yystack = NULL;
- pParser->fts5yystksz = 0;
- if( fts5yyGrowStack(pParser) ){
- pParser->fts5yystack = &pParser->fts5yystk0;
- pParser->fts5yystksz = 1;
+ fts5yypParser->fts5yytos = NULL;
+ fts5yypParser->fts5yystack = NULL;
+ fts5yypParser->fts5yystksz = 0;
+ if( fts5yyGrowStack(fts5yypParser) ){
+ fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0;
+ fts5yypParser->fts5yystksz = 1;
}
#endif
#ifndef fts5YYNOERRORRECOVERY
- pParser->fts5yyerrcnt = -1;
+ fts5yypParser->fts5yyerrcnt = -1;
#endif
- pParser->fts5yytos = pParser->fts5yystack;
- pParser->fts5yystack[0].stateno = 0;
- pParser->fts5yystack[0].major = 0;
+ fts5yypParser->fts5yytos = fts5yypParser->fts5yystack;
+ fts5yypParser->fts5yystack[0].stateno = 0;
+ fts5yypParser->fts5yystack[0].major = 0;
#if fts5YYSTACKDEPTH>0
- pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
+ fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];
#endif
}
@@ -190187,11 +192088,14 @@ static void sqlite3Fts5ParserInit(void *fts5yypParser){
** A pointer to a parser. This pointer is used in subsequent calls
** to sqlite3Fts5Parser and sqlite3Fts5ParserFree.
*/
-static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
- fts5yyParser *pParser;
- pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
- if( pParser ) sqlite3Fts5ParserInit(pParser);
- return pParser;
+static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE) sqlite3Fts5ParserCTX_PDECL){
+ fts5yyParser *fts5yypParser;
+ fts5yypParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
+ if( fts5yypParser ){
+ sqlite3Fts5ParserCTX_STORE
+ sqlite3Fts5ParserInit(fts5yypParser sqlite3Fts5ParserCTX_PARAM);
+ }
+ return (void*)fts5yypParser;
}
#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */
@@ -190208,7 +192112,8 @@ static void fts5yy_destructor(
fts5YYCODETYPE fts5yymajor, /* Type code for object to destroy */
fts5YYMINORTYPE *fts5yypminor /* The object to be destroyed */
){
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
+ sqlite3Fts5ParserCTX_FETCH
switch( fts5yymajor ){
/* Here is inserted the actions which take place when a
** terminal or non-terminal is destroyed. This can happen
@@ -190221,33 +192126,33 @@ static void fts5yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 17: /* input */
+ case 16: /* input */
{
(void)pParse;
}
break;
- case 18: /* expr */
- case 19: /* cnearset */
- case 20: /* exprlist */
+ case 17: /* expr */
+ case 18: /* cnearset */
+ case 19: /* exprlist */
{
- sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy54));
+ sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24));
}
break;
- case 21: /* colset */
- case 22: /* colsetlist */
+ case 20: /* colset */
+ case 21: /* colsetlist */
{
- sqlite3_free((fts5yypminor->fts5yy43));
+ sqlite3_free((fts5yypminor->fts5yy11));
}
break;
- case 23: /* nearset */
- case 24: /* nearphrases */
+ case 22: /* nearset */
+ case 23: /* nearphrases */
{
- sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy14));
+ sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46));
}
break;
- case 25: /* phrase */
+ case 24: /* phrase */
{
- sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy11));
+ sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53));
}
break;
/********* End destructor definitions *****************************************/
@@ -190359,13 +192264,12 @@ static int sqlite3Fts5ParserCoverage(FILE *out){
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
-static unsigned int fts5yy_find_shift_action(
- fts5yyParser *pParser, /* The parser */
- fts5YYCODETYPE iLookAhead /* The look-ahead token */
+static fts5YYACTIONTYPE fts5yy_find_shift_action(
+ fts5YYCODETYPE iLookAhead, /* The look-ahead token */
+ fts5YYACTIONTYPE stateno /* Current state number */
){
int i;
- int stateno = pParser->fts5yytos->stateno;
-
+
if( stateno>fts5YY_MAX_SHIFT ) return stateno;
assert( stateno <= fts5YY_SHIFT_COUNT );
#if defined(fts5YYCOVERAGE)
@@ -190429,7 +192333,7 @@ static unsigned int fts5yy_find_shift_action(
** look-ahead token iLookAhead.
*/
static int fts5yy_find_reduce_action(
- int stateno, /* Current state number */
+ fts5YYACTIONTYPE stateno, /* Current state number */
fts5YYCODETYPE iLookAhead /* The look-ahead token */
){
int i;
@@ -190458,7 +192362,8 @@ static int fts5yy_find_reduce_action(
** The following routine is called if the stack overflows.
*/
static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
+ sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
if( fts5yyTraceFILE ){
fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
@@ -190471,7 +192376,8 @@ static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
/******** End %stack_overflow code ********************************************/
- sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
+ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */
+ sqlite3Fts5ParserCTX_STORE
}
/*
@@ -190500,8 +192406,8 @@ static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState, co
*/
static void fts5yy_shift(
fts5yyParser *fts5yypParser, /* The parser to be shifted */
- int fts5yyNewState, /* The new state to shift in */
- int fts5yyMajor, /* The major token to shift in */
+ fts5YYACTIONTYPE fts5yyNewState, /* The new state to shift in */
+ fts5YYCODETYPE fts5yyMajor, /* The major token to shift in */
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
){
fts5yyStackEntry *fts5yytos;
@@ -190531,8 +192437,8 @@ static void fts5yy_shift(
fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
}
fts5yytos = fts5yypParser->fts5yytos;
- fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
- fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
+ fts5yytos->stateno = fts5yyNewState;
+ fts5yytos->major = fts5yyMajor;
fts5yytos->minor.fts5yy0 = fts5yyMinor;
fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift");
}
@@ -190544,34 +192450,34 @@ static const struct {
fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} fts5yyRuleInfo[] = {
- { 17, -1 }, /* (0) input ::= expr */
- { 21, -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
- { 21, -3 }, /* (2) colset ::= LCP colsetlist RCP */
- { 21, -1 }, /* (3) colset ::= STRING */
- { 21, -2 }, /* (4) colset ::= MINUS STRING */
- { 22, -2 }, /* (5) colsetlist ::= colsetlist STRING */
- { 22, -1 }, /* (6) colsetlist ::= STRING */
- { 18, -3 }, /* (7) expr ::= expr AND expr */
- { 18, -3 }, /* (8) expr ::= expr OR expr */
- { 18, -3 }, /* (9) expr ::= expr NOT expr */
- { 18, -5 }, /* (10) expr ::= colset COLON LP expr RP */
- { 18, -3 }, /* (11) expr ::= LP expr RP */
- { 18, -1 }, /* (12) expr ::= exprlist */
- { 20, -1 }, /* (13) exprlist ::= cnearset */
- { 20, -2 }, /* (14) exprlist ::= exprlist cnearset */
- { 19, -1 }, /* (15) cnearset ::= nearset */
- { 19, -3 }, /* (16) cnearset ::= colset COLON nearset */
- { 23, -1 }, /* (17) nearset ::= phrase */
- { 23, -2 }, /* (18) nearset ::= CARET phrase */
- { 23, -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
- { 24, -1 }, /* (20) nearphrases ::= phrase */
- { 24, -2 }, /* (21) nearphrases ::= nearphrases phrase */
- { 26, 0 }, /* (22) neardist_opt ::= */
- { 26, -2 }, /* (23) neardist_opt ::= COMMA STRING */
- { 25, -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
- { 25, -2 }, /* (25) phrase ::= STRING star_opt */
- { 27, -1 }, /* (26) star_opt ::= STAR */
- { 27, 0 }, /* (27) star_opt ::= */
+ { 16, -1 }, /* (0) input ::= expr */
+ { 20, -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
+ { 20, -3 }, /* (2) colset ::= LCP colsetlist RCP */
+ { 20, -1 }, /* (3) colset ::= STRING */
+ { 20, -2 }, /* (4) colset ::= MINUS STRING */
+ { 21, -2 }, /* (5) colsetlist ::= colsetlist STRING */
+ { 21, -1 }, /* (6) colsetlist ::= STRING */
+ { 17, -3 }, /* (7) expr ::= expr AND expr */
+ { 17, -3 }, /* (8) expr ::= expr OR expr */
+ { 17, -3 }, /* (9) expr ::= expr NOT expr */
+ { 17, -5 }, /* (10) expr ::= colset COLON LP expr RP */
+ { 17, -3 }, /* (11) expr ::= LP expr RP */
+ { 17, -1 }, /* (12) expr ::= exprlist */
+ { 19, -1 }, /* (13) exprlist ::= cnearset */
+ { 19, -2 }, /* (14) exprlist ::= exprlist cnearset */
+ { 18, -1 }, /* (15) cnearset ::= nearset */
+ { 18, -3 }, /* (16) cnearset ::= colset COLON nearset */
+ { 22, -1 }, /* (17) nearset ::= phrase */
+ { 22, -2 }, /* (18) nearset ::= CARET phrase */
+ { 22, -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
+ { 23, -1 }, /* (20) nearphrases ::= phrase */
+ { 23, -2 }, /* (21) nearphrases ::= nearphrases phrase */
+ { 25, 0 }, /* (22) neardist_opt ::= */
+ { 25, -2 }, /* (23) neardist_opt ::= COMMA STRING */
+ { 24, -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
+ { 24, -2 }, /* (25) phrase ::= STRING star_opt */
+ { 26, -1 }, /* (26) star_opt ::= STAR */
+ { 26, 0 }, /* (27) star_opt ::= */
};
static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
@@ -190586,17 +192492,18 @@ static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact.
*/
-static void fts5yy_reduce(
+static fts5YYACTIONTYPE fts5yy_reduce(
fts5yyParser *fts5yypParser, /* The parser */
unsigned int fts5yyruleno, /* Number of the rule by which to reduce */
int fts5yyLookahead, /* Lookahead token, or fts5YYNOCODE if none */
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken /* Value of the lookahead token */
+ sqlite3Fts5ParserCTX_PDECL /* %extra_context */
){
int fts5yygoto; /* The next state */
int fts5yyact; /* The next action */
fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
int fts5yysize; /* Amount to pop the stack */
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
(void)fts5yyLookahead;
(void)fts5yyLookaheadToken;
fts5yymsp = fts5yypParser->fts5yytos;
@@ -190627,13 +192534,19 @@ static void fts5yy_reduce(
#if fts5YYSTACKDEPTH>0
if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
fts5yyStackOverflow(fts5yypParser);
- return;
+ /* The call to fts5yyStackOverflow() above pops the stack until it is
+ ** empty, causing the main parser loop to exit. So the return value
+ ** is never used and does not matter. */
+ return 0;
}
#else
if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
if( fts5yyGrowStack(fts5yypParser) ){
fts5yyStackOverflow(fts5yypParser);
- return;
+ /* The call to fts5yyStackOverflow() above pops the stack until it is
+ ** empty, causing the main parser loop to exit. So the return value
+ ** is never used and does not matter. */
+ return 0;
}
fts5yymsp = fts5yypParser->fts5yytos;
}
@@ -190652,120 +192565,120 @@ static void fts5yy_reduce(
/********** Begin reduce actions **********************************************/
fts5YYMINORTYPE fts5yylhsminor;
case 0: /* input ::= expr */
-{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy54); }
+{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); }
break;
case 1: /* colset ::= MINUS LCP colsetlist RCP */
{
- fts5yymsp[-3].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
+ fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
break;
case 2: /* colset ::= LCP colsetlist RCP */
-{ fts5yymsp[-2].minor.fts5yy43 = fts5yymsp[-1].minor.fts5yy43; }
+{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; }
break;
case 3: /* colset ::= STRING */
{
- fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
+ fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
}
- fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
+ fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
break;
case 4: /* colset ::= MINUS STRING */
{
- fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
- fts5yymsp[-1].minor.fts5yy43 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy43);
+ fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
+ fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);
}
break;
case 5: /* colsetlist ::= colsetlist STRING */
{
- fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy43, &fts5yymsp[0].minor.fts5yy0); }
- fts5yymsp[-1].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
+ fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); }
+ fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
break;
case 6: /* colsetlist ::= STRING */
{
- fts5yylhsminor.fts5yy43 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
+ fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);
}
- fts5yymsp[0].minor.fts5yy43 = fts5yylhsminor.fts5yy43;
+ fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
break;
case 7: /* expr ::= expr AND expr */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
- fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 8: /* expr ::= expr OR expr */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
- fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 9: /* expr ::= expr NOT expr */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54, 0);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);
}
- fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 10: /* expr ::= colset COLON LP expr RP */
{
- sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[-4].minor.fts5yy43);
- fts5yylhsminor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;
+ sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11);
+ fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;
}
- fts5yymsp[-4].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 11: /* expr ::= LP expr RP */
-{fts5yymsp[-2].minor.fts5yy54 = fts5yymsp[-1].minor.fts5yy54;}
+{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;}
break;
case 12: /* expr ::= exprlist */
case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13);
-{fts5yylhsminor.fts5yy54 = fts5yymsp[0].minor.fts5yy54;}
- fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;}
+ fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 14: /* exprlist ::= exprlist cnearset */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy54, fts5yymsp[0].minor.fts5yy54);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24);
}
- fts5yymsp[-1].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 15: /* cnearset ::= nearset */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46);
}
- fts5yymsp[0].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 16: /* cnearset ::= colset COLON nearset */
{
- fts5yylhsminor.fts5yy54 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy14);
- sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy54, fts5yymsp[-2].minor.fts5yy43);
+ fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46);
+ sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11);
}
- fts5yymsp[-2].minor.fts5yy54 = fts5yylhsminor.fts5yy54;
+ fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;
break;
case 17: /* nearset ::= phrase */
-{ fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11); }
- fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
+{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); }
+ fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
break;
case 18: /* nearset ::= CARET phrase */
{
- sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy11);
- fts5yymsp[-1].minor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11);
+ sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53);
+ fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53);
}
break;
case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */
{
sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0);
- sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy14, &fts5yymsp[-1].minor.fts5yy0);
- fts5yylhsminor.fts5yy14 = fts5yymsp[-2].minor.fts5yy14;
+ sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0);
+ fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46;
}
- fts5yymsp[-4].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
+ fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
break;
case 20: /* nearphrases ::= phrase */
{
- fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy11);
+ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53);
}
- fts5yymsp[0].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
+ fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
break;
case 21: /* nearphrases ::= nearphrases phrase */
{
- fts5yylhsminor.fts5yy14 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy14, fts5yymsp[0].minor.fts5yy11);
+ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53);
}
- fts5yymsp[-1].minor.fts5yy14 = fts5yylhsminor.fts5yy14;
+ fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46;
break;
case 22: /* neardist_opt ::= */
{ fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; }
@@ -190775,15 +192688,15 @@ static void fts5yy_reduce(
break;
case 24: /* phrase ::= phrase PLUS STRING star_opt */
{
- fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy11, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
+ fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
- fts5yymsp[-3].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
+ fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
break;
case 25: /* phrase ::= STRING star_opt */
{
- fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
+ fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);
}
- fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;
+ fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53;
break;
case 26: /* star_opt ::= STAR */
{ fts5yymsp[0].minor.fts5yy4 = 1; }
@@ -190812,6 +192725,7 @@ static void fts5yy_reduce(
fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
fts5yyTraceShift(fts5yypParser, fts5yyact, "... then shift");
+ return fts5yyact;
}
/*
@@ -190821,7 +192735,8 @@ static void fts5yy_reduce(
static void fts5yy_parse_failed(
fts5yyParser *fts5yypParser /* The parser */
){
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
+ sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
if( fts5yyTraceFILE ){
fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
@@ -190832,7 +192747,8 @@ static void fts5yy_parse_failed(
** parser fails */
/************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/
- sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserCTX_STORE
}
#endif /* fts5YYNOERRORRECOVERY */
@@ -190844,7 +192760,8 @@ static void fts5yy_syntax_error(
int fts5yymajor, /* The major type of the error token */
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor /* The minor type of the error token */
){
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
+ sqlite3Fts5ParserCTX_FETCH
#define FTS5TOKEN fts5yyminor
/************ Begin %syntax_error code ****************************************/
@@ -190853,7 +192770,8 @@ static void fts5yy_syntax_error(
pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p
);
/************ End %syntax_error code ******************************************/
- sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserCTX_STORE
}
/*
@@ -190862,7 +192780,8 @@ static void fts5yy_syntax_error(
static void fts5yy_accept(
fts5yyParser *fts5yypParser /* The parser */
){
- sqlite3Fts5ParserARG_FETCH;
+ sqlite3Fts5ParserARG_FETCH
+ sqlite3Fts5ParserCTX_FETCH
#ifndef NDEBUG
if( fts5yyTraceFILE ){
fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
@@ -190876,7 +192795,8 @@ static void fts5yy_accept(
** parser accepts */
/*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/
- sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */
+ sqlite3Fts5ParserCTX_STORE
}
/* The main parser program.
@@ -190905,45 +192825,47 @@ static void sqlite3Fts5Parser(
sqlite3Fts5ParserARG_PDECL /* Optional %extra_argument parameter */
){
fts5YYMINORTYPE fts5yyminorunion;
- unsigned int fts5yyact; /* The parser action. */
+ fts5YYACTIONTYPE fts5yyact; /* The parser action. */
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
int fts5yyendofinput; /* True if we are at the end of input */
#endif
#ifdef fts5YYERRORSYMBOL
int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
#endif
- fts5yyParser *fts5yypParser; /* The parser */
+ fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yyp; /* The parser */
+ sqlite3Fts5ParserCTX_FETCH
+ sqlite3Fts5ParserARG_STORE
- fts5yypParser = (fts5yyParser*)fts5yyp;
assert( fts5yypParser->fts5yytos!=0 );
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
fts5yyendofinput = (fts5yymajor==0);
#endif
- sqlite3Fts5ParserARG_STORE;
+ fts5yyact = fts5yypParser->fts5yytos->stateno;
#ifndef NDEBUG
if( fts5yyTraceFILE ){
- int stateno = fts5yypParser->fts5yytos->stateno;
- if( stateno < fts5YY_MIN_REDUCE ){
+ if( fts5yyact < fts5YY_MIN_REDUCE ){
fprintf(fts5yyTraceFILE,"%sInput '%s' in state %d\n",
- fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno);
+ fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact);
}else{
fprintf(fts5yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
- fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],stateno-fts5YY_MIN_REDUCE);
+ fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact-fts5YY_MIN_REDUCE);
}
}
#endif
do{
- fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
+ assert( fts5yyact==fts5yypParser->fts5yytos->stateno );
+ fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact);
if( fts5yyact >= fts5YY_MIN_REDUCE ){
- fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,fts5yyminor);
+ fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,
+ fts5yyminor sqlite3Fts5ParserCTX_PARAM);
}else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
#ifndef fts5YYNOERRORRECOVERY
fts5yypParser->fts5yyerrcnt--;
#endif
- fts5yymajor = fts5YYNOCODE;
+ break;
}else if( fts5yyact==fts5YY_ACCEPT_ACTION ){
fts5yypParser->fts5yytos--;
fts5yy_accept(fts5yypParser);
@@ -191014,6 +192936,8 @@ static void sqlite3Fts5Parser(
}
fts5yypParser->fts5yyerrcnt = 3;
fts5yyerrorhit = 1;
+ if( fts5yymajor==fts5YYNOCODE ) break;
+ fts5yyact = fts5yypParser->fts5yytos->stateno;
#elif defined(fts5YYNOERRORRECOVERY)
/* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to
** do any kind of error recovery. Instead, simply invoke the syntax
@@ -191024,8 +192948,7 @@ static void sqlite3Fts5Parser(
*/
fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);
fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
- fts5yymajor = fts5YYNOCODE;
-
+ break;
#else /* fts5YYERRORSYMBOL is not defined */
/* This is what we do if the grammar does not define ERROR:
**
@@ -191047,10 +192970,10 @@ static void sqlite3Fts5Parser(
fts5yypParser->fts5yyerrcnt = -1;
#endif
}
- fts5yymajor = fts5YYNOCODE;
+ break;
#endif
}
- }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
+ }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
#ifndef NDEBUG
if( fts5yyTraceFILE ){
fts5yyStackEntry *i;
@@ -205662,7 +207585,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
- sqlite3_result_text(pCtx, "fts5: 2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b", -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(pCtx, "fts5: 2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca", -1, SQLITE_TRANSIENT);
}
static int fts5Init(sqlite3 *db){
@@ -209932,9 +211855,9 @@ SQLITE_API int sqlite3_stmt_init(
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
/************** End of stmt.c ************************************************/
-#if __LINE__!=209935
+#if __LINE__!=211858
#undef SQLITE_SOURCE_ID
-#define SQLITE_SOURCE_ID "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd14alt2"
+#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199aalt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
diff --git a/ext/sqlite3/libsqlite/sqlite3.h b/ext/sqlite3/libsqlite/sqlite3.h
index 0ba2852d78..4427d2fa27 100644
--- a/ext/sqlite3/libsqlite/sqlite3.h
+++ b/ext/sqlite3/libsqlite/sqlite3.h
@@ -123,9 +123,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.23.1"
-#define SQLITE_VERSION_NUMBER 3023001
-#define SQLITE_SOURCE_ID "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"
+#define SQLITE_VERSION "3.24.0"
+#define SQLITE_VERSION_NUMBER 3024000
+#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -504,6 +504,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
+#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
@@ -511,6 +512,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
+#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
@@ -1930,6 +1932,22 @@ struct sqlite3_mem_methods {
** I/O required to support statement rollback.
** The default value for this setting is controlled by the
** [SQLITE_STMTJRNL_SPILL] compile-time option.
+**
+** [[SQLITE_CONFIG_SORTERREF_SIZE]]
+** <dt>SQLITE_CONFIG_SORTERREF_SIZE
+** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
+** of type (int) - the new value of the sorter-reference size threshold.
+** Usually, when SQLite uses an external sort to order records according
+** to an ORDER BY clause, all fields required by the caller are present in the
+** sorted records. However, if SQLite determines based on the declared type
+** of a table column that its values are likely to be very large - larger
+** than the configured sorter-reference size threshold - then a reference
+** is stored in each sorted record and the required column values loaded
+** from the database as records are returned in sorted order. The default
+** value for this option is to never use this optimization. Specifying a
+** negative value for this option restores the default behaviour.
+** This option is only available if SQLite is compiled with the
+** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -1959,6 +1977,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
+#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -2095,6 +2114,21 @@ struct sqlite3_mem_methods {
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
** it is not disabled, 1 if it is.
** </dd>
+**
+** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
+** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
+** [VACUUM] in order to reset a database back to an empty database
+** with no schema and no content. The following process works even for
+** a badly corrupted database file:
+** <ol>
+** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
+** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
+** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
+** </ol>
+** Because resetting a database is destructive and irreversible, the
+** process requires the use of this obscure API and multiple steps to help
+** ensure that it does not happen by accident.
+** </dd>
** </dl>
*/
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
@@ -2106,7 +2140,8 @@ struct sqlite3_mem_methods {
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
-#define SQLITE_DBCONFIG_MAX 1008 /* Largest DBCONFIG */
+#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
+#define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
/*
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -5493,6 +5528,41 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
/*
+** CAPI3REF: Win32 Specific Interface
+**
+** These interfaces are available only on Windows. The
+** [sqlite3_win32_set_directory] interface is used to set the value associated
+** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to
+** zValue, depending on the value of the type parameter. The zValue parameter
+** should be NULL to cause the previous value to be freed via [sqlite3_free];
+** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]
+** prior to being used. The [sqlite3_win32_set_directory] interface returns
+** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,
+** or [SQLITE_NOMEM] if memory could not be allocated. The value of the
+** [sqlite3_data_directory] variable is intended to act as a replacement for
+** the current directory on the sub-platforms of Win32 where that concept is
+** not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and
+** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the
+** sqlite3_win32_set_directory interface except the string parameter must be
+** UTF-8 or UTF-16, respectively.
+*/
+SQLITE_API int sqlite3_win32_set_directory(
+ unsigned long type, /* Identifier for directory being set or reset */
+ void *zValue /* New value for directory being set or reset */
+);
+SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);
+SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);
+
+/*
+** CAPI3REF: Win32 Directory Types
+**
+** These macros are only available on Windows. They define the allowed values
+** for the type argument to the [sqlite3_win32_set_directory] interface.
+*/
+#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
+#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
+
+/*
** CAPI3REF: Test For Auto-Commit Mode
** KEYWORDS: {autocommit mode}
** METHOD: sqlite3
@@ -6224,6 +6294,10 @@ struct sqlite3_index_info {
/*
** CAPI3REF: Virtual Table Scan Flags
+**
+** Virtual table implementations are allowed to set the
+** [sqlite3_index_info].idxFlags field to some combination of
+** these bits.
*/
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
@@ -6999,7 +7073,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
-#define SQLITE_TESTCTRL_ISKEYWORD 16
+#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
@@ -7014,6 +7088,189 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */
/*
+** CAPI3REF: SQL Keyword Checking
+**
+** These routines provide access to the set of SQL language keywords
+** recognized by SQLite. Applications can uses these routines to determine
+** whether or not a specific identifier needs to be escaped (for example,
+** by enclosing in double-quotes) so as not to confuse the parser.
+**
+** The sqlite3_keyword_count() interface returns the number of distinct
+** keywords understood by SQLite.
+**
+** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
+** makes *Z point to that keyword expressed as UTF8 and writes the number
+** of bytes in the keyword into *L. The string that *Z points to is not
+** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns
+** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
+** or L are NULL or invalid pointers then calls to
+** sqlite3_keyword_name(N,Z,L) result in undefined behavior.
+**
+** The sqlite3_keyword_check(Z,L) interface checks to see whether or not
+** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
+** if it is and zero if not.
+**
+** The parser used by SQLite is forgiving. It is often possible to use
+** a keyword as an identifier as long as such use does not result in a
+** parsing ambiguity. For example, the statement
+** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
+** creates a new table named "BEGIN" with three columns named
+** "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid
+** using keywords as identifiers. Common techniques used to avoid keyword
+** name collisions include:
+** <ul>
+** <li> Put all identifier names inside double-quotes. This is the official
+** SQL way to escape identifier names.
+** <li> Put identifier names inside &#91;...&#93;. This is not standard SQL,
+** but it is what SQL Server does and so lots of programmers use this
+** technique.
+** <li> Begin every identifier with the letter "Z" as no SQL keywords start
+** with "Z".
+** <li> Include a digit somewhere in every identifier name.
+** </ul>
+**
+** Note that the number of keywords understood by SQLite can depend on
+** compile-time options. For example, "VACUUM" is not a keyword if
+** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also,
+** new keywords may be added to future releases of SQLite.
+*/
+SQLITE_API int sqlite3_keyword_count(void);
+SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
+SQLITE_API int sqlite3_keyword_check(const char*,int);
+
+/*
+** CAPI3REF: Dynamic String Object
+** KEYWORDS: {dynamic string}
+**
+** An instance of the sqlite3_str object contains a dynamically-sized
+** string under construction.
+**
+** The lifecycle of an sqlite3_str object is as follows:
+** <ol>
+** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
+** <li> ^Text is appended to the sqlite3_str object using various
+** methods, such as [sqlite3_str_appendf()].
+** <li> ^The sqlite3_str object is destroyed and the string it created
+** is returned using the [sqlite3_str_finish()] interface.
+** </ol>
+*/
+typedef struct sqlite3_str sqlite3_str;
+
+/*
+** CAPI3REF: Create A New Dynamic String Object
+** CONSTRUCTOR: sqlite3_str
+**
+** ^The [sqlite3_str_new(D)] interface allocates and initializes
+** a new [sqlite3_str] object. To avoid memory leaks, the object returned by
+** [sqlite3_str_new()] must be freed by a subsequent call to
+** [sqlite3_str_finish(X)].
+**
+** ^The [sqlite3_str_new(D)] interface always returns a pointer to a
+** valid [sqlite3_str] object, though in the event of an out-of-memory
+** error the returned object might be a special singleton that will
+** silently reject new text, always return SQLITE_NOMEM from
+** [sqlite3_str_errcode()], always return 0 for
+** [sqlite3_str_length()], and always return NULL from
+** [sqlite3_str_finish(X)]. It is always safe to use the value
+** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter
+** to any of the other [sqlite3_str] methods.
+**
+** The D parameter to [sqlite3_str_new(D)] may be NULL. If the
+** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum
+** length of the string contained in the [sqlite3_str] object will be
+** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead
+** of [SQLITE_MAX_LENGTH].
+*/
+SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
+
+/*
+** CAPI3REF: Finalize A Dynamic String
+** DESTRUCTOR: sqlite3_str
+**
+** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X
+** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]
+** that contains the constructed string. The calling application should
+** pass the returned value to [sqlite3_free()] to avoid a memory leak.
+** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
+** errors were encountered during construction of the string. ^The
+** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
+** string in [sqlite3_str] object X is zero bytes long.
+*/
+SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
+
+/*
+** CAPI3REF: Add Content To A Dynamic String
+** METHOD: sqlite3_str
+**
+** These interfaces add content to an sqlite3_str object previously obtained
+** from [sqlite3_str_new()].
+**
+** ^The [sqlite3_str_appendf(X,F,...)] and
+** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
+** functionality of SQLite to append formatted text onto the end of
+** [sqlite3_str] object X.
+**
+** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S
+** onto the end of the [sqlite3_str] object X. N must be non-negative.
+** S must contain at least N non-zero bytes of content. To append a
+** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]
+** method instead.
+**
+** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of
+** zero-terminated string S onto the end of [sqlite3_str] object X.
+**
+** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the
+** single-byte character C onto the end of [sqlite3_str] object X.
+** ^This method can be used, for example, to add whitespace indentation.
+**
+** ^The [sqlite3_str_reset(X)] method resets the string under construction
+** inside [sqlite3_str] object X back to zero bytes in length.
+**
+** These methods do not return a result code. ^If an error occurs, that fact
+** is recorded in the [sqlite3_str] object and can be recovered by a
+** subsequent call to [sqlite3_str_errcode(X)].
+*/
+SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
+SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
+SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
+SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
+SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
+SQLITE_API void sqlite3_str_reset(sqlite3_str*);
+
+/*
+** CAPI3REF: Status Of A Dynamic String
+** METHOD: sqlite3_str
+**
+** These interfaces return the current status of an [sqlite3_str] object.
+**
+** ^If any prior errors have occurred while constructing the dynamic string
+** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return
+** an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns
+** [SQLITE_NOMEM] following any out-of-memory error, or
+** [SQLITE_TOOBIG] if the size of the dynamic string exceeds
+** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.
+**
+** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,
+** of the dynamic string under construction in [sqlite3_str] object X.
+** ^The length returned by [sqlite3_str_length(X)] does not include the
+** zero-termination byte.
+**
+** ^The [sqlite3_str_value(X)] method returns a pointer to the current
+** content of the dynamic string under construction in X. The value
+** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
+** and might be freed or altered by any subsequent method on the same
+** [sqlite3_str] object. Applications must not used the pointer returned
+** [sqlite3_str_value(X)] after any subsequent method call on the same
+** object. ^Applications may change the content of the string returned
+** by [sqlite3_str_value(X)] as long as they do not write into any bytes
+** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
+** write any byte after any subsequent sqlite3_str method call.
+*/
+SQLITE_API int sqlite3_str_errcode(sqlite3_str*);
+SQLITE_API int sqlite3_str_length(sqlite3_str*);
+SQLITE_API char *sqlite3_str_value(sqlite3_str*);
+
+/*
** CAPI3REF: SQLite Runtime Status
**
** ^These interfaces are used to retrieve runtime status information
@@ -8282,11 +8539,11 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
** method of a [virtual table], then it returns true if and only if the
** column is being fetched as part of an UPDATE operation during which the
** column value will not change. Applications might use this to substitute
-** a lighter-weight value to return that the corresponding [xUpdate] method
-** understands as a "no-change" value.
+** a return value that is less expensive to compute and that the corresponding
+** [xUpdate] method understands as a "no-change" value.
**
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
-** the column is not changed by the UPDATE statement, they the xColumn
+** the column is not changed by the UPDATE statement, then the xColumn
** method can optionally return without setting a result, without calling
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
** In that case, [sqlite3_value_nochange(X)] will return true for the
@@ -8781,7 +9038,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
** values of D and S.
** The size of the database is written into *P even if the
-** SQLITE_SERIALIZE_NOCOPY bit is set but no contigious copy
+** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
** of the database exists.
**
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
diff --git a/ext/sqlite3/libsqlite/sqlite3ext.h b/ext/sqlite3/libsqlite/sqlite3ext.h
index 1409370a6f..e0cd2f4d8d 100644
--- a/ext/sqlite3/libsqlite/sqlite3ext.h
+++ b/ext/sqlite3/libsqlite/sqlite3ext.h
@@ -295,6 +295,21 @@ struct sqlite3_api_routines {
int (*vtab_nochange)(sqlite3_context*);
int (*value_nochange)(sqlite3_value*);
const char *(*vtab_collation)(sqlite3_index_info*,int);
+ /* Version 3.24.0 and later */
+ int (*keyword_count)(void);
+ int (*keyword_name)(int,const char**,int*);
+ int (*keyword_check)(const char*,int);
+ sqlite3_str *(*str_new)(sqlite3*);
+ char *(*str_finish)(sqlite3_str*);
+ void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
+ void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
+ void (*str_append)(sqlite3_str*, const char *zIn, int N);
+ void (*str_appendall)(sqlite3_str*, const char *zIn);
+ void (*str_appendchar)(sqlite3_str*, int N, char C);
+ void (*str_reset)(sqlite3_str*);
+ int (*str_errcode)(sqlite3_str*);
+ int (*str_length)(sqlite3_str*);
+ char *(*str_value)(sqlite3_str*);
};
/*
@@ -565,6 +580,21 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
#define sqlite3_value_nochange sqlite3_api->value_nochange
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
+/* Version 3.24.0 and later */
+#define sqlite3_keyword_count sqlite3_api->keyword_count
+#define sqlite3_keyword_name sqlite3_api->keyword_name
+#define sqlite3_keyword_check sqlite3_api->keyword_check
+#define sqlite3_str_new sqlite3_api->str_new
+#define sqlite3_str_finish sqlite3_api->str_finish
+#define sqlite3_str_appendf sqlite3_api->str_appendf
+#define sqlite3_str_vappendf sqlite3_api->str_vappendf
+#define sqlite3_str_append sqlite3_api->str_append
+#define sqlite3_str_appendall sqlite3_api->str_appendall
+#define sqlite3_str_appendchar sqlite3_api->str_appendchar
+#define sqlite3_str_reset sqlite3_api->str_reset
+#define sqlite3_str_errcode sqlite3_api->str_errcode
+#define sqlite3_str_length sqlite3_api->str_length
+#define sqlite3_str_value sqlite3_api->str_value
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)