summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig.zon2
-rw-r--r--c/sqlite3.c6460
-rw-r--r--c/sqlite3.h199
-rw-r--r--c/sqlite3ext.h6
4 files changed, 4303 insertions, 2364 deletions
diff --git a/build.zig.zon b/build.zig.zon
index 77ec3d9..fcd6730 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -1,5 +1,5 @@
1.{ 1.{
2 .name = "sqlite", 2 .name = "sqlite",
3 .version = "3.43.2", 3 .version = "3.44.0",
4 .paths = .{"."}, 4 .paths = .{"."},
5} 5}
diff --git a/c/sqlite3.c b/c/sqlite3.c
index a1fbd60..8f9309a 100644
--- a/c/sqlite3.c
+++ b/c/sqlite3.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2** This file is an amalgamation of many separate C source files from SQLite 2** This file is an amalgamation of many separate C source files from SQLite
3** version 3.43.2. By combining all the individual C code files into this 3** version 3.44.0. By combining all the individual C code files into this
4** single large file, the entire code can be compiled as a single translation 4** single large file, the entire code can be compiled as a single translation
5** unit. This allows many compilers to do optimizations that would not be 5** unit. This allows many compilers to do optimizations that would not be
6** possible if the files were compiled separately. Performance improvements 6** possible if the files were compiled separately. Performance improvements
@@ -18,7 +18,7 @@
18** separate file. This file contains only code for the core SQLite library. 18** separate file. This file contains only code for the core SQLite library.
19** 19**
20** The content in this amalgamation comes from Fossil check-in 20** The content in this amalgamation comes from Fossil check-in
21** 310099cce5a487035fa535dd3002c59ac7f. 21** 17129ba1ff7f0daf37100ee82d507aef7827.
22*/ 22*/
23#define SQLITE_CORE 1 23#define SQLITE_CORE 1
24#define SQLITE_AMALGAMATION 1 24#define SQLITE_AMALGAMATION 1
@@ -459,9 +459,9 @@ extern "C" {
459** [sqlite3_libversion_number()], [sqlite3_sourceid()], 459** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460** [sqlite_version()] and [sqlite_source_id()]. 460** [sqlite_version()] and [sqlite_source_id()].
461*/ 461*/
462#define SQLITE_VERSION "3.43.2" 462#define SQLITE_VERSION "3.44.0"
463#define SQLITE_VERSION_NUMBER 3043002 463#define SQLITE_VERSION_NUMBER 3044000
464#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" 464#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301"
465 465
466/* 466/*
467** CAPI3REF: Run-Time Library Version Numbers 467** CAPI3REF: Run-Time Library Version Numbers
@@ -2440,7 +2440,7 @@ struct sqlite3_mem_methods {
2440** is stored in each sorted record and the required column values loaded 2440** is stored in each sorted record and the required column values loaded
2441** from the database as records are returned in sorted order. The default 2441** from the database as records are returned in sorted order. The default
2442** value for this option is to never use this optimization. Specifying a 2442** value for this option is to never use this optimization. Specifying a
2443** negative value for this option restores the default behaviour. 2443** negative value for this option restores the default behavior.
2444** This option is only available if SQLite is compiled with the 2444** This option is only available if SQLite is compiled with the
2445** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. 2445** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
2446** 2446**
@@ -2615,7 +2615,7 @@ struct sqlite3_mem_methods {
2615** database handle, SQLite checks if this will mean that there are now no 2615** database handle, SQLite checks if this will mean that there are now no
2616** connections at all to the database. If so, it performs a checkpoint 2616** connections at all to the database. If so, it performs a checkpoint
2617** operation before closing the connection. This option may be used to 2617** operation before closing the connection. This option may be used to
2618** override this behaviour. The first parameter passed to this operation 2618** override this behavior. The first parameter passed to this operation
2619** is an integer - positive to disable checkpoints-on-close, or zero (the 2619** is an integer - positive to disable checkpoints-on-close, or zero (the
2620** default) to enable them, and negative to leave the setting unchanged. 2620** default) to enable them, and negative to leave the setting unchanged.
2621** The second parameter is a pointer to an integer 2621** The second parameter is a pointer to an integer
@@ -4268,6 +4268,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4268** 4268**
4269** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 4269** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
4270** text that describes the error, as either UTF-8 or UTF-16 respectively. 4270** text that describes the error, as either UTF-8 or UTF-16 respectively.
4271** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
4271** ^(Memory to hold the error message string is managed internally. 4272** ^(Memory to hold the error message string is managed internally.
4272** The application does not need to worry about freeing the result. 4273** The application does not need to worry about freeing the result.
4273** However, the error string might be overwritten or deallocated by 4274** However, the error string might be overwritten or deallocated by
@@ -5638,6 +5639,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
5638*/ 5639*/
5639SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); 5640SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5640 5641
5642
5641/* 5643/*
5642** CAPI3REF: Create Or Redefine SQL Functions 5644** CAPI3REF: Create Or Redefine SQL Functions
5643** KEYWORDS: {function creation routines} 5645** KEYWORDS: {function creation routines}
@@ -6192,32 +6194,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6192** METHOD: sqlite3_context 6194** METHOD: sqlite3_context
6193** 6195**
6194** These functions may be used by (non-aggregate) SQL functions to 6196** These functions may be used by (non-aggregate) SQL functions to
6195** associate metadata with argument values. If the same value is passed to 6197** associate auxiliary data with argument values. If the same argument
6196** multiple invocations of the same SQL function during query execution, under 6198** value is passed to multiple invocations of the same SQL function during
6197** some circumstances the associated metadata may be preserved. An example 6199** query execution, under some circumstances the associated auxiliary data
6198** of where this might be useful is in a regular-expression matching 6200** might be preserved. An example of where this might be useful is in a
6199** function. The compiled version of the regular expression can be stored as 6201** regular-expression matching function. The compiled version of the regular
6200** metadata associated with the pattern string. 6202** expression can be stored as auxiliary data associated with the pattern string.
6201** Then as long as the pattern string remains the same, 6203** Then as long as the pattern string remains the same,
6202** the compiled regular expression can be reused on multiple 6204** the compiled regular expression can be reused on multiple
6203** invocations of the same function. 6205** invocations of the same function.
6204** 6206**
6205** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata 6207** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6206** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument 6208** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6207** value to the application-defined function. ^N is zero for the left-most 6209** value to the application-defined function. ^N is zero for the left-most
6208** function argument. ^If there is no metadata 6210** function argument. ^If there is no auxiliary data
6209** associated with the function argument, the sqlite3_get_auxdata(C,N) interface 6211** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6210** returns a NULL pointer. 6212** returns a NULL pointer.
6211** 6213**
6212** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th 6214** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6213** argument of the application-defined function. ^Subsequent 6215** N-th argument of the application-defined function. ^Subsequent
6214** calls to sqlite3_get_auxdata(C,N) return P from the most recent 6216** calls to sqlite3_get_auxdata(C,N) return P from the most recent
6215** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or 6217** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
6216** NULL if the metadata has been discarded. 6218** NULL if the auxiliary data has been discarded.
6217** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, 6219** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
6218** SQLite will invoke the destructor function X with parameter P exactly 6220** SQLite will invoke the destructor function X with parameter P exactly
6219** once, when the metadata is discarded. 6221** once, when the auxiliary data is discarded.
6220** SQLite is free to discard the metadata at any time, including: <ul> 6222** SQLite is free to discard the auxiliary data at any time, including: <ul>
6221** <li> ^(when the corresponding function parameter changes)^, or 6223** <li> ^(when the corresponding function parameter changes)^, or
6222** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the 6224** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
6223** SQL statement)^, or 6225** SQL statement)^, or
@@ -6233,7 +6235,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6233** function implementation should not make any use of P after 6235** function implementation should not make any use of P after
6234** sqlite3_set_auxdata() has been called. 6236** sqlite3_set_auxdata() has been called.
6235** 6237**
6236** ^(In practice, metadata is preserved between function calls for 6238** ^(In practice, auxiliary data is preserved between function calls for
6237** function parameters that are compile-time constants, including literal 6239** function parameters that are compile-time constants, including literal
6238** values and [parameters] and expressions composed from the same.)^ 6240** values and [parameters] and expressions composed from the same.)^
6239** 6241**
@@ -6243,10 +6245,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6243** 6245**
6244** These routines must be called from the same thread in which 6246** These routines must be called from the same thread in which
6245** the SQL function is running. 6247** the SQL function is running.
6248**
6249** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()].
6246*/ 6250*/
6247SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); 6251SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
6248SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); 6252SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
6249 6253
6254/*
6255** CAPI3REF: Database Connection Client Data
6256** METHOD: sqlite3
6257**
6258** These functions are used to associate one or more named pointers
6259** with a [database connection].
6260** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P
6261** to be attached to [database connection] D using name N. Subsequent
6262** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P
6263** or a NULL pointer if there were no prior calls to
6264** sqlite3_set_clientdata() with the same values of D and N.
6265** Names are compared using strcmp() and are thus case sensitive.
6266**
6267** If P and X are both non-NULL, then the destructor X is invoked with
6268** argument P on the first of the following occurrences:
6269** <ul>
6270** <li> An out-of-memory error occurs during the call to
6271** sqlite3_set_clientdata() which attempts to register pointer P.
6272** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made
6273** with the same D and N parameters.
6274** <li> The database connection closes. SQLite does not make any guarantees
6275** about the order in which destructors are called, only that all
6276** destructors will be called exactly once at some point during the
6277** database connection closing process.
6278** </ul>
6279**
6280** SQLite does not do anything with client data other than invoke
6281** destructors on the client data at the appropriate time. The intended
6282** use for client data is to provide a mechanism for wrapper libraries
6283** to store additional information about an SQLite database connection.
6284**
6285** There is no limit (other than available memory) on the number of different
6286** client data pointers (with different names) that can be attached to a
6287** single database connection. However, the implementation is optimized
6288** for the case of having only one or two different client data names.
6289** Applications and wrapper libraries are discouraged from using more than
6290** one client data name each.
6291**
6292** There is no way to enumerate the client data pointers
6293** associated with a database connection. The N parameter can be thought
6294** of as a secret key such that only code that knows the secret key is able
6295** to access the associated data.
6296**
6297** Security Warning: These interfaces should not be exposed in scripting
6298** languages or in other circumstances where it might be possible for an
6299** an attacker to invoke them. Any agent that can invoke these interfaces
6300** can probably also take control of the process.
6301**
6302** Database connection client data is only available for SQLite
6303** version 3.44.0 ([dateof:3.44.0]) and later.
6304**
6305** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()].
6306*/
6307SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*);
6308SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*));
6250 6309
6251/* 6310/*
6252** CAPI3REF: Constants Defining Special Destructor Behavior 6311** CAPI3REF: Constants Defining Special Destructor Behavior
@@ -6879,7 +6938,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
6879SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); 6938SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
6880 6939
6881/* 6940/*
6882** CAPI3REF: Allowed return values from [sqlite3_txn_state()] 6941** CAPI3REF: Allowed return values from sqlite3_txn_state()
6883** KEYWORDS: {transaction state} 6942** KEYWORDS: {transaction state}
6884** 6943**
6885** These constants define the current transaction state of a database file. 6944** These constants define the current transaction state of a database file.
@@ -7011,7 +7070,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
7011** ^Each call to the sqlite3_autovacuum_pages() interface overrides all 7070** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
7012** previous invocations for that database connection. ^If the callback 7071** previous invocations for that database connection. ^If the callback
7013** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, 7072** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
7014** then the autovacuum steps callback is cancelled. The return value 7073** then the autovacuum steps callback is canceled. The return value
7015** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might 7074** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
7016** be some other error code if something goes wrong. The current 7075** be some other error code if something goes wrong. The current
7017** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other 7076** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
@@ -7530,6 +7589,10 @@ struct sqlite3_module {
7530 /* The methods above are in versions 1 and 2 of the sqlite_module object. 7589 /* The methods above are in versions 1 and 2 of the sqlite_module object.
7531 ** Those below are for version 3 and greater. */ 7590 ** Those below are for version 3 and greater. */
7532 int (*xShadowName)(const char*); 7591 int (*xShadowName)(const char*);
7592 /* The methods above are in versions 1 through 3 of the sqlite_module object.
7593 ** Those below are for version 4 and greater. */
7594 int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema,
7595 const char *zTabName, int mFlags, char **pzErr);
7533}; 7596};
7534 7597
7535/* 7598/*
@@ -8017,7 +8080,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
8017** code is returned and the transaction rolled back. 8080** code is returned and the transaction rolled back.
8018** 8081**
8019** Calling this function with an argument that is not a NULL pointer or an 8082** Calling this function with an argument that is not a NULL pointer or an
8020** open blob handle results in undefined behaviour. ^Calling this routine 8083** open blob handle results in undefined behavior. ^Calling this routine
8021** with a null pointer (such as would be returned by a failed call to 8084** with a null pointer (such as would be returned by a failed call to
8022** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function 8085** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
8023** is passed a valid open blob handle, the values returned by the 8086** is passed a valid open blob handle, the values returned by the
@@ -8497,6 +8560,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8497#define SQLITE_TESTCTRL_PRNG_SAVE 5 8560#define SQLITE_TESTCTRL_PRNG_SAVE 5
8498#define SQLITE_TESTCTRL_PRNG_RESTORE 6 8561#define SQLITE_TESTCTRL_PRNG_RESTORE 6
8499#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ 8562#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
8563#define SQLITE_TESTCTRL_FK_NO_ACTION 7
8500#define SQLITE_TESTCTRL_BITVEC_TEST 8 8564#define SQLITE_TESTCTRL_BITVEC_TEST 8
8501#define SQLITE_TESTCTRL_FAULT_INSTALL 9 8565#define SQLITE_TESTCTRL_FAULT_INSTALL 9
8502#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 8566#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
@@ -9558,8 +9622,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
9558** blocked connection already has a registered unlock-notify callback, 9622** blocked connection already has a registered unlock-notify callback,
9559** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is 9623** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
9560** called with a NULL pointer as its second argument, then any existing 9624** called with a NULL pointer as its second argument, then any existing
9561** unlock-notify callback is cancelled. ^The blocked connections 9625** unlock-notify callback is canceled. ^The blocked connections
9562** unlock-notify callback may also be cancelled by closing the blocked 9626** unlock-notify callback may also be canceled by closing the blocked
9563** connection using [sqlite3_close()]. 9627** connection using [sqlite3_close()].
9564** 9628**
9565** The unlock-notify callback is not reentrant. If an application invokes 9629** The unlock-notify callback is not reentrant. If an application invokes
@@ -10862,6 +10926,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
10862** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy 10926** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
10863** of the database exists. 10927** of the database exists.
10864** 10928**
10929** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set,
10930** the returned buffer content will remain accessible and unchanged
10931** until either the next write operation on the connection or when
10932** the connection is closed, and applications must not modify the
10933** buffer. If the bit had been clear, the returned buffer will not
10934** be accessed by SQLite after the call.
10935**
10865** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the 10936** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
10866** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory 10937** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
10867** allocation error occurs. 10938** allocation error occurs.
@@ -10910,6 +10981,9 @@ SQLITE_API unsigned char *sqlite3_serialize(
10910** SQLite will try to increase the buffer size using sqlite3_realloc64() 10981** SQLite will try to increase the buffer size using sqlite3_realloc64()
10911** if writes on the database cause it to grow larger than M bytes. 10982** if writes on the database cause it to grow larger than M bytes.
10912** 10983**
10984** Applications must not modify the buffer P or invalidate it before
10985** the database connection D is closed.
10986**
10913** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the 10987** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
10914** database is currently in a read transaction or is involved in a backup 10988** database is currently in a read transaction or is involved in a backup
10915** operation. 10989** operation.
@@ -10918,6 +10992,13 @@ SQLITE_API unsigned char *sqlite3_serialize(
10918** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the 10992** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10919** function returns SQLITE_ERROR. 10993** function returns SQLITE_ERROR.
10920** 10994**
10995** The deserialized database should not be in [WAL mode]. If the database
10996** is in WAL mode, then any attempt to use the database file will result
10997** in an [SQLITE_CANTOPEN] error. The application can set the
10998** [file format version numbers] (bytes 18 and 19) of the input database P
10999** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the
11000** database file into rollback mode and work around this limitation.
11001**
10921** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the 11002** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10922** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then 11003** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10923** [sqlite3_free()] is invoked on argument P prior to returning. 11004** [sqlite3_free()] is invoked on argument P prior to returning.
@@ -11991,6 +12072,18 @@ SQLITE_API int sqlite3changeset_concat(
11991 12072
11992 12073
11993/* 12074/*
12075** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
12076*/
12077SQLITE_API int sqlite3changeset_upgrade(
12078 sqlite3 *db,
12079 const char *zDb,
12080 int nIn, const void *pIn, /* Input changeset */
12081 int *pnOut, void **ppOut /* OUT: Inverse of input */
12082);
12083
12084
12085
12086/*
11994** CAPI3REF: Changegroup Handle 12087** CAPI3REF: Changegroup Handle
11995** 12088**
11996** A changegroup is an object used to combine two or more 12089** A changegroup is an object used to combine two or more
@@ -12037,6 +12130,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
12037SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); 12130SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
12038 12131
12039/* 12132/*
12133** CAPI3REF: Add a Schema to a Changegroup
12134** METHOD: sqlite3_changegroup_schema
12135**
12136** This method may be used to optionally enforce the rule that the changesets
12137** added to the changegroup handle must match the schema of database zDb
12138** ("main", "temp", or the name of an attached database). If
12139** sqlite3changegroup_add() is called to add a changeset that is not compatible
12140** with the configured schema, SQLITE_SCHEMA is returned and the changegroup
12141** object is left in an undefined state.
12142**
12143** A changeset schema is considered compatible with the database schema in
12144** the same way as for sqlite3changeset_apply(). Specifically, for each
12145** table in the changeset, there exists a database table with:
12146**
12147** <ul>
12148** <li> The name identified by the changeset, and
12149** <li> at least as many columns as recorded in the changeset, and
12150** <li> the primary key columns in the same position as recorded in
12151** the changeset.
12152** </ul>
12153**
12154** The output of the changegroup object always has the same schema as the
12155** database nominated using this function. In cases where changesets passed
12156** to sqlite3changegroup_add() have fewer columns than the corresponding table
12157** in the database schema, these are filled in using the default column
12158** values from the database schema. This makes it possible to combined
12159** changesets that have different numbers of columns for a single table
12160** within a changegroup, provided that they are otherwise compatible.
12161*/
12162SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb);
12163
12164/*
12040** CAPI3REF: Add A Changeset To A Changegroup 12165** CAPI3REF: Add A Changeset To A Changegroup
12041** METHOD: sqlite3_changegroup 12166** METHOD: sqlite3_changegroup
12042** 12167**
@@ -12104,13 +12229,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
12104** If the new changeset contains changes to a table that is already present 12229** If the new changeset contains changes to a table that is already present
12105** in the changegroup, then the number of columns and the position of the 12230** in the changegroup, then the number of columns and the position of the
12106** primary key columns for the table must be consistent. If this is not the 12231** primary key columns for the table must be consistent. If this is not the
12107** case, this function fails with SQLITE_SCHEMA. If the input changeset 12232** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup
12108** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is 12233** object has been configured with a database schema using the
12109** returned. Or, if an out-of-memory condition occurs during processing, this 12234** sqlite3changegroup_schema() API, then it is possible to combine changesets
12110** function returns SQLITE_NOMEM. In all cases, if an error occurs the state 12235** with different numbers of columns for a single table, provided that
12111** of the final contents of the changegroup is undefined. 12236** they are otherwise compatible.
12112** 12237**
12113** If no error occurs, SQLITE_OK is returned. 12238** If the input changeset appears to be corrupt and the corruption is
12239** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition
12240** occurs during processing, this function returns SQLITE_NOMEM.
12241**
12242** In all cases, if an error occurs the state of the final contents of the
12243** changegroup is undefined. If no error occurs, SQLITE_OK is returned.
12114*/ 12244*/
12115SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); 12245SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
12116 12246
@@ -12375,10 +12505,17 @@ SQLITE_API int sqlite3changeset_apply_v2(
12375** <li>an insert change if all fields of the conflicting row match 12505** <li>an insert change if all fields of the conflicting row match
12376** the row being inserted. 12506** the row being inserted.
12377** </ul> 12507** </ul>
12508**
12509** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
12510** If this flag it set, then all foreign key constraints in the target
12511** database behave as if they were declared with "ON UPDATE NO ACTION ON
12512** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12513** or SET DEFAULT.
12378*/ 12514*/
12379#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 12515#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12380#define SQLITE_CHANGESETAPPLY_INVERT 0x0002 12516#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12381#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 12517#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12518#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12382 12519
12383/* 12520/*
12384** CAPI3REF: Constants Passed To The Conflict Handler 12521** CAPI3REF: Constants Passed To The Conflict Handler
@@ -13770,6 +13907,16 @@ struct fts5_api {
13770#endif 13907#endif
13771 13908
13772/* 13909/*
13910** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit
13911** SEH support if the -DSQLITE_OMIT_SEH option is given.
13912*/
13913#if defined(_MSC_VER) && !defined(SQLITE_OMIT_SEH)
13914# define SQLITE_USE_SEH 1
13915#else
13916# undef SQLITE_USE_SEH
13917#endif
13918
13919/*
13773** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. 13920** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
13774** 0 means mutexes are permanently disable and the library is never 13921** 0 means mutexes are permanently disable and the library is never
13775** threadsafe. 1 means the library is serialized which is the highest 13922** threadsafe. 1 means the library is serialized which is the highest
@@ -14662,16 +14809,33 @@ typedef INT16_TYPE LogEst;
14662** using C-preprocessor macros. If that is unsuccessful, or if 14809** using C-preprocessor macros. If that is unsuccessful, or if
14663** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined 14810** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined
14664** at run-time. 14811** at run-time.
14812**
14813** If you are building SQLite on some obscure platform for which the
14814** following ifdef magic does not work, you can always include either:
14815**
14816** -DSQLITE_BYTEORDER=1234
14817**
14818** or
14819**
14820** -DSQLITE_BYTEORDER=4321
14821**
14822** to cause the build to work for little-endian or big-endian processors,
14823** respectively.
14665*/ 14824*/
14666#ifndef SQLITE_BYTEORDER 14825#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */
14667# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ 14826# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
14827# define SQLITE_BYTEORDER 4321
14828# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
14829# define SQLITE_BYTEORDER 1234
14830# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1
14831# define SQLITE_BYTEORDER 4321
14832# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
14668 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ 14833 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
14669 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ 14834 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
14670 defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) 14835 defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
14671# define SQLITE_BYTEORDER 1234 14836# define SQLITE_BYTEORDER 1234
14672# elif defined(sparc) || defined(__ppc__) || \ 14837# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__)
14673 defined(__ARMEB__) || defined(__AARCH64EB__) 14838# define SQLITE_BYTEORDER 4321
14674# define SQLITE_BYTEORDER 4321
14675# else 14839# else
14676# define SQLITE_BYTEORDER 0 14840# define SQLITE_BYTEORDER 0
14677# endif 14841# endif
@@ -14995,6 +15159,7 @@ typedef struct Column Column;
14995typedef struct Cte Cte; 15159typedef struct Cte Cte;
14996typedef struct CteUse CteUse; 15160typedef struct CteUse CteUse;
14997typedef struct Db Db; 15161typedef struct Db Db;
15162typedef struct DbClientData DbClientData;
14998typedef struct DbFixer DbFixer; 15163typedef struct DbFixer DbFixer;
14999typedef struct Schema Schema; 15164typedef struct Schema Schema;
15000typedef struct Expr Expr; 15165typedef struct Expr Expr;
@@ -16435,19 +16600,20 @@ typedef struct VdbeOpList VdbeOpList;
16435#define OP_VCreate 171 16600#define OP_VCreate 171
16436#define OP_VDestroy 172 16601#define OP_VDestroy 172
16437#define OP_VOpen 173 16602#define OP_VOpen 173
16438#define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */ 16603#define OP_VCheck 174
16439#define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */ 16604#define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */
16440#define OP_VRename 176 16605#define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */
16441#define OP_Pagecount 177 16606#define OP_VRename 177
16442#define OP_MaxPgcnt 178 16607#define OP_Pagecount 178
16443#define OP_ClrSubtype 179 /* synopsis: r[P1].subtype = 0 */ 16608#define OP_MaxPgcnt 179
16444#define OP_FilterAdd 180 /* synopsis: filter(P1) += key(P3@P4) */ 16609#define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */
16445#define OP_Trace 181 16610#define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */
16446#define OP_CursorHint 182 16611#define OP_Trace 182
16447#define OP_ReleaseReg 183 /* synopsis: release r[P1@P2] mask P3 */ 16612#define OP_CursorHint 183
16448#define OP_Noop 184 16613#define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */
16449#define OP_Explain 185 16614#define OP_Noop 185
16450#define OP_Abortable 186 16615#define OP_Explain 186
16616#define OP_Abortable 187
16451 16617
16452/* Properties such as "out2" or "jump" that are specified in 16618/* Properties such as "out2" or "jump" that are specified in
16453** comments following the "case" for each opcode in the vdbe.c 16619** comments following the "case" for each opcode in the vdbe.c
@@ -16482,9 +16648,9 @@ typedef struct VdbeOpList VdbeOpList;
16482/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ 16648/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
16483/* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ 16649/* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
16484/* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ 16650/* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
16485/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x40,\ 16651/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\
16486/* 176 */ 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00,\ 16652/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\
16487/* 184 */ 0x00, 0x00, 0x00,} 16653/* 184 */ 0x00, 0x00, 0x00, 0x00,}
16488 16654
16489/* The resolve3P2Values() routine is able to run faster if it knows 16655/* The resolve3P2Values() routine is able to run faster if it knows
16490** the value of the largest JUMP opcode. The smaller the maximum 16656** the value of the largest JUMP opcode. The smaller the maximum
@@ -17393,6 +17559,7 @@ struct sqlite3 {
17393 i64 nDeferredCons; /* Net deferred constraints this transaction. */ 17559 i64 nDeferredCons; /* Net deferred constraints this transaction. */
17394 i64 nDeferredImmCons; /* Net deferred immediate constraints */ 17560 i64 nDeferredImmCons; /* Net deferred immediate constraints */
17395 int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ 17561 int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
17562 DbClientData *pDbData; /* sqlite3_set_clientdata() content */
17396#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY 17563#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
17397 /* The following variables are all protected by the STATIC_MAIN 17564 /* The following variables are all protected by the STATIC_MAIN
17398 ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 17565 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
@@ -17475,6 +17642,7 @@ struct sqlite3 {
17475 /* the count using a callback. */ 17642 /* the count using a callback. */
17476#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ 17643#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
17477#define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ 17644#define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */
17645#define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */
17478 17646
17479/* Flags used only if debugging */ 17647/* Flags used only if debugging */
17480#ifdef SQLITE_DEBUG 17648#ifdef SQLITE_DEBUG
@@ -18490,6 +18658,9 @@ struct AggInfo {
18490 FuncDef *pFunc; /* The aggregate function implementation */ 18658 FuncDef *pFunc; /* The aggregate function implementation */
18491 int iDistinct; /* Ephemeral table used to enforce DISTINCT */ 18659 int iDistinct; /* Ephemeral table used to enforce DISTINCT */
18492 int iDistAddr; /* Address of OP_OpenEphemeral */ 18660 int iDistAddr; /* Address of OP_OpenEphemeral */
18661 int iOBTab; /* Ephemeral table to implement ORDER BY */
18662 u8 bOBPayload; /* iOBTab has payload columns separate from key */
18663 u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */
18493 } *aFunc; 18664 } *aFunc;
18494 int nFunc; /* Number of entries in aFunc[] */ 18665 int nFunc; /* Number of entries in aFunc[] */
18495 u32 selId; /* Select to which this AggInfo belongs */ 18666 u32 selId; /* Select to which this AggInfo belongs */
@@ -18674,7 +18845,7 @@ struct Expr {
18674#define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ 18845#define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
18675#define EP_Win 0x008000 /* Contains window functions */ 18846#define EP_Win 0x008000 /* Contains window functions */
18676#define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ 18847#define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
18677 /* 0x020000 // Available for reuse */ 18848#define EP_FullSize 0x020000 /* Expr structure must remain full sized */
18678#define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ 18849#define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */
18679#define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ 18850#define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */
18680#define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ 18851#define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
@@ -18704,6 +18875,7 @@ struct Expr {
18704#define ExprClearProperty(E,P) (E)->flags&=~(P) 18875#define ExprClearProperty(E,P) (E)->flags&=~(P)
18705#define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) 18876#define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue)
18706#define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) 18877#define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse)
18878#define ExprIsFullSize(E) (((E)->flags&(EP_Reduced|EP_TokenOnly))==0)
18707 18879
18708/* Macros used to ensure that the correct members of unions are accessed 18880/* Macros used to ensure that the correct members of unions are accessed
18709** in Expr. 18881** in Expr.
@@ -18821,6 +18993,7 @@ struct ExprList {
18821#define ENAME_NAME 0 /* The AS clause of a result set */ 18993#define ENAME_NAME 0 /* The AS clause of a result set */
18822#define ENAME_SPAN 1 /* Complete text of the result set expression */ 18994#define ENAME_SPAN 1 /* Complete text of the result set expression */
18823#define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ 18995#define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */
18996#define ENAME_ROWID 3 /* "DB.TABLE._rowid_" for * expansion of rowid */
18824 18997
18825/* 18998/*
18826** An instance of this structure can hold a simple list of identifiers, 18999** An instance of this structure can hold a simple list of identifiers,
@@ -19429,6 +19602,7 @@ struct Parse {
19429 int *aLabel; /* Space to hold the labels */ 19602 int *aLabel; /* Space to hold the labels */
19430 ExprList *pConstExpr;/* Constant expressions */ 19603 ExprList *pConstExpr;/* Constant expressions */
19431 IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ 19604 IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */
19605 IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */
19432 Token constraintName;/* Name of the constraint currently being parsed */ 19606 Token constraintName;/* Name of the constraint currently being parsed */
19433 yDbMask writeMask; /* Start a write transaction on these databases */ 19607 yDbMask writeMask; /* Start a write transaction on these databases */
19434 yDbMask cookieMask; /* Bitmask of schema verified databases */ 19608 yDbMask cookieMask; /* Bitmask of schema verified databases */
@@ -19700,6 +19874,7 @@ struct Returning {
19700 int iRetCur; /* Transient table holding RETURNING results */ 19874 int iRetCur; /* Transient table holding RETURNING results */
19701 int nRetCol; /* Number of in pReturnEL after expansion */ 19875 int nRetCol; /* Number of in pReturnEL after expansion */
19702 int iRetReg; /* Register array for holding a row of RETURNING */ 19876 int iRetReg; /* Register array for holding a row of RETURNING */
19877 char zName[40]; /* Name of trigger: "sqlite_returning_%p" */
19703}; 19878};
19704 19879
19705/* 19880/*
@@ -20000,6 +20175,16 @@ struct CteUse {
20000}; 20175};
20001 20176
20002 20177
20178/* Client data associated with sqlite3_set_clientdata() and
20179** sqlite3_get_clientdata().
20180*/
20181struct DbClientData {
20182 DbClientData *pNext; /* Next in a linked list */
20183 void *pData; /* The data */
20184 void (*xDestructor)(void*); /* Destructor. Might be NULL */
20185 char zName[1]; /* Name of this client data. MUST BE LAST */
20186};
20187
20003#ifdef SQLITE_DEBUG 20188#ifdef SQLITE_DEBUG
20004/* 20189/*
20005** An instance of the TreeView object is used for printing the content of 20190** An instance of the TreeView object is used for printing the content of
@@ -20404,6 +20589,8 @@ SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);
20404SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); 20589SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*);
20405SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); 20590SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*);
20406SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); 20591SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int);
20592SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(Parse*,Expr*,ExprList*);
20593SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*);
20407SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); 20594SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
20408SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); 20595SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
20409SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); 20596SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
@@ -20640,6 +20827,7 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*);
20640SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); 20827SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
20641SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); 20828SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
20642SQLITE_PRIVATE int sqlite3IsRowid(const char*); 20829SQLITE_PRIVATE int sqlite3IsRowid(const char*);
20830SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab);
20643SQLITE_PRIVATE void sqlite3GenerateRowDelete( 20831SQLITE_PRIVATE void sqlite3GenerateRowDelete(
20644 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); 20832 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
20645SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); 20833SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
@@ -20911,7 +21099,8 @@ SQLITE_PRIVATE int sqlite3MatchEName(
20911 const struct ExprList_item*, 21099 const struct ExprList_item*,
20912 const char*, 21100 const char*,
20913 const char*, 21101 const char*,
20914 const char* 21102 const char*,
21103 int*
20915); 21104);
20916SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); 21105SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*);
20917SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); 21106SQLITE_PRIVATE u8 sqlite3StrIHash(const char*);
@@ -20968,7 +21157,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
20968SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); 21157SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
20969 21158
20970SQLITE_PRIVATE char *sqlite3RCStrRef(char*); 21159SQLITE_PRIVATE char *sqlite3RCStrRef(char*);
20971SQLITE_PRIVATE void sqlite3RCStrUnref(char*); 21160SQLITE_PRIVATE void sqlite3RCStrUnref(void*);
20972SQLITE_PRIVATE char *sqlite3RCStrNew(u64); 21161SQLITE_PRIVATE char *sqlite3RCStrNew(u64);
20973SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); 21162SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64);
20974 21163
@@ -21804,6 +21993,9 @@ static const char * const sqlite3azCompileOpt[] = {
21804#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS 21993#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
21805 "EXPLAIN_ESTIMATED_ROWS", 21994 "EXPLAIN_ESTIMATED_ROWS",
21806#endif 21995#endif
21996#ifdef SQLITE_EXTRA_AUTOEXT
21997 "EXTRA_AUTOEXT=" CTIMEOPT_VAL(SQLITE_EXTRA_AUTOEXT),
21998#endif
21807#ifdef SQLITE_EXTRA_IFNULLROW 21999#ifdef SQLITE_EXTRA_IFNULLROW
21808 "EXTRA_IFNULLROW", 22000 "EXTRA_IFNULLROW",
21809#endif 22001#endif
@@ -22085,6 +22277,9 @@ static const char * const sqlite3azCompileOpt[] = {
22085#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS 22277#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
22086 "OMIT_SCHEMA_VERSION_PRAGMAS", 22278 "OMIT_SCHEMA_VERSION_PRAGMAS",
22087#endif 22279#endif
22280#ifdef SQLITE_OMIT_SEH
22281 "OMIT_SEH",
22282#endif
22088#ifdef SQLITE_OMIT_SHARED_CACHE 22283#ifdef SQLITE_OMIT_SHARED_CACHE
22089 "OMIT_SHARED_CACHE", 22284 "OMIT_SHARED_CACHE",
22090#endif 22285#endif
@@ -25044,13 +25239,16 @@ static void strftimeFunc(
25044 computeJD(&x); 25239 computeJD(&x);
25045 computeYMD_HMS(&x); 25240 computeYMD_HMS(&x);
25046 for(i=j=0; zFmt[i]; i++){ 25241 for(i=j=0; zFmt[i]; i++){
25242 char cf;
25047 if( zFmt[i]!='%' ) continue; 25243 if( zFmt[i]!='%' ) continue;
25048 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); 25244 if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j));
25049 i++; 25245 i++;
25050 j = i + 1; 25246 j = i + 1;
25051 switch( zFmt[i] ){ 25247 cf = zFmt[i];
25052 case 'd': { 25248 switch( cf ){
25053 sqlite3_str_appendf(&sRes, "%02d", x.D); 25249 case 'd': /* Fall thru */
25250 case 'e': {
25251 sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D);
25054 break; 25252 break;
25055 } 25253 }
25056 case 'f': { 25254 case 'f': {
@@ -25059,8 +25257,21 @@ static void strftimeFunc(
25059 sqlite3_str_appendf(&sRes, "%06.3f", s); 25257 sqlite3_str_appendf(&sRes, "%06.3f", s);
25060 break; 25258 break;
25061 } 25259 }
25062 case 'H': { 25260 case 'F': {
25063 sqlite3_str_appendf(&sRes, "%02d", x.h); 25261 sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D);
25262 break;
25263 }
25264 case 'H':
25265 case 'k': {
25266 sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h);
25267 break;
25268 }
25269 case 'I': /* Fall thru */
25270 case 'l': {
25271 int h = x.h;
25272 if( h>12 ) h -= 12;
25273 if( h==0 ) h = 12;
25274 sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h);
25064 break; 25275 break;
25065 } 25276 }
25066 case 'W': /* Fall thru */ 25277 case 'W': /* Fall thru */
@@ -25072,7 +25283,7 @@ static void strftimeFunc(
25072 y.D = 1; 25283 y.D = 1;
25073 computeJD(&y); 25284 computeJD(&y);
25074 nDay = (int)((x.iJD-y.iJD+43200000)/86400000); 25285 nDay = (int)((x.iJD-y.iJD+43200000)/86400000);
25075 if( zFmt[i]=='W' ){ 25286 if( cf=='W' ){
25076 int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ 25287 int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
25077 wd = (int)(((x.iJD+43200000)/86400000)%7); 25288 wd = (int)(((x.iJD+43200000)/86400000)%7);
25078 sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); 25289 sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7);
@@ -25093,6 +25304,19 @@ static void strftimeFunc(
25093 sqlite3_str_appendf(&sRes,"%02d",x.m); 25304 sqlite3_str_appendf(&sRes,"%02d",x.m);
25094 break; 25305 break;
25095 } 25306 }
25307 case 'p': /* Fall thru */
25308 case 'P': {
25309 if( x.h>=12 ){
25310 sqlite3_str_append(&sRes, cf=='p' ? "PM" : "pm", 2);
25311 }else{
25312 sqlite3_str_append(&sRes, cf=='p' ? "AM" : "am", 2);
25313 }
25314 break;
25315 }
25316 case 'R': {
25317 sqlite3_str_appendf(&sRes, "%02d:%02d", x.h, x.m);
25318 break;
25319 }
25096 case 's': { 25320 case 's': {
25097 if( x.useSubsec ){ 25321 if( x.useSubsec ){
25098 sqlite3_str_appendf(&sRes,"%.3f", 25322 sqlite3_str_appendf(&sRes,"%.3f",
@@ -25107,9 +25331,15 @@ static void strftimeFunc(
25107 sqlite3_str_appendf(&sRes,"%02d",(int)x.s); 25331 sqlite3_str_appendf(&sRes,"%02d",(int)x.s);
25108 break; 25332 break;
25109 } 25333 }
25334 case 'T': {
25335 sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s);
25336 break;
25337 }
25338 case 'u': /* Fall thru */
25110 case 'w': { 25339 case 'w': {
25111 sqlite3_str_appendchar(&sRes, 1, 25340 char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0';
25112 (char)(((x.iJD+129600000)/86400000) % 7) + '0'); 25341 if( c=='0' && cf=='u' ) c = '7';
25342 sqlite3_str_appendchar(&sRes, 1, c);
25113 break; 25343 break;
25114 } 25344 }
25115 case 'Y': { 25345 case 'Y': {
@@ -28198,7 +28428,7 @@ static void checkMutexFree(sqlite3_mutex *p){
28198 assert( SQLITE_MUTEX_FAST<2 ); 28428 assert( SQLITE_MUTEX_FAST<2 );
28199 assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); 28429 assert( SQLITE_MUTEX_WARNONCONTENTION<2 );
28200 28430
28201#if SQLITE_ENABLE_API_ARMOR 28431#ifdef SQLITE_ENABLE_API_ARMOR
28202 if( ((CheckMutex*)p)->iType<2 ) 28432 if( ((CheckMutex*)p)->iType<2 )
28203#endif 28433#endif
28204 { 28434 {
@@ -28870,7 +29100,7 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
28870*/ 29100*/
28871static void pthreadMutexFree(sqlite3_mutex *p){ 29101static void pthreadMutexFree(sqlite3_mutex *p){
28872 assert( p->nRef==0 ); 29102 assert( p->nRef==0 );
28873#if SQLITE_ENABLE_API_ARMOR 29103#ifdef SQLITE_ENABLE_API_ARMOR
28874 if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) 29104 if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE )
28875#endif 29105#endif
28876 { 29106 {
@@ -30434,7 +30664,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){
30434 if( db->mallocFailed || rc ){ 30664 if( db->mallocFailed || rc ){
30435 return apiHandleError(db, rc); 30665 return apiHandleError(db, rc);
30436 } 30666 }
30437 return rc & db->errMask; 30667 return 0;
30438} 30668}
30439 30669
30440/************** End of malloc.c **********************************************/ 30670/************** End of malloc.c **********************************************/
@@ -31830,7 +32060,7 @@ SQLITE_PRIVATE char *sqlite3RCStrRef(char *z){
31830** Decrease the reference count by one. Free the string when the 32060** Decrease the reference count by one. Free the string when the
31831** reference count reaches zero. 32061** reference count reaches zero.
31832*/ 32062*/
31833SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ 32063SQLITE_PRIVATE void sqlite3RCStrUnref(void *z){
31834 RCStr *p = (RCStr*)z; 32064 RCStr *p = (RCStr*)z;
31835 assert( p!=0 ); 32065 assert( p!=0 );
31836 p--; 32066 p--;
@@ -32293,6 +32523,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u
32293 sqlite3TreeViewItem(pView, "FILTER", 1); 32523 sqlite3TreeViewItem(pView, "FILTER", 1);
32294 sqlite3TreeViewExpr(pView, pWin->pFilter, 0); 32524 sqlite3TreeViewExpr(pView, pWin->pFilter, 0);
32295 sqlite3TreeViewPop(&pView); 32525 sqlite3TreeViewPop(&pView);
32526 if( pWin->eFrmType==TK_FILTER ) return;
32296 } 32527 }
32297 sqlite3TreeViewPush(&pView, more); 32528 sqlite3TreeViewPush(&pView, more);
32298 if( pWin->zName ){ 32529 if( pWin->zName ){
@@ -32302,7 +32533,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u
32302 } 32533 }
32303 if( pWin->zBase ) nElement++; 32534 if( pWin->zBase ) nElement++;
32304 if( pWin->pOrderBy ) nElement++; 32535 if( pWin->pOrderBy ) nElement++;
32305 if( pWin->eFrmType ) nElement++; 32536 if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ) nElement++;
32306 if( pWin->eExclude ) nElement++; 32537 if( pWin->eExclude ) nElement++;
32307 if( pWin->zBase ){ 32538 if( pWin->zBase ){
32308 sqlite3TreeViewPush(&pView, (--nElement)>0); 32539 sqlite3TreeViewPush(&pView, (--nElement)>0);
@@ -32315,7 +32546,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u
32315 if( pWin->pOrderBy ){ 32546 if( pWin->pOrderBy ){
32316 sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); 32547 sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY");
32317 } 32548 }
32318 if( pWin->eFrmType ){ 32549 if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ){
32319 char zBuf[30]; 32550 char zBuf[30];
32320 const char *zFrmType = "ROWS"; 32551 const char *zFrmType = "ROWS";
32321 if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; 32552 if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE";
@@ -32563,7 +32794,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m
32563 assert( ExprUseXList(pExpr) ); 32794 assert( ExprUseXList(pExpr) );
32564 pFarg = pExpr->x.pList; 32795 pFarg = pExpr->x.pList;
32565#ifndef SQLITE_OMIT_WINDOWFUNC 32796#ifndef SQLITE_OMIT_WINDOWFUNC
32566 pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; 32797 pWin = IsWindowFunc(pExpr) ? pExpr->y.pWin : 0;
32567#else 32798#else
32568 pWin = 0; 32799 pWin = 0;
32569#endif 32800#endif
@@ -32589,7 +32820,13 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m
32589 sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); 32820 sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs);
32590 } 32821 }
32591 if( pFarg ){ 32822 if( pFarg ){
32592 sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); 32823 sqlite3TreeViewExprList(pView, pFarg, pWin!=0 || pExpr->pLeft, 0);
32824 if( pExpr->pLeft ){
32825 Expr *pOB = pExpr->pLeft;
32826 assert( pOB->op==TK_ORDER );
32827 assert( ExprUseXList(pOB) );
32828 sqlite3TreeViewExprList(pView, pOB->x.pList, pWin!=0, "ORDERBY");
32829 }
32593 } 32830 }
32594#ifndef SQLITE_OMIT_WINDOWFUNC 32831#ifndef SQLITE_OMIT_WINDOWFUNC
32595 if( pWin ){ 32832 if( pWin ){
@@ -32598,6 +32835,10 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m
32598#endif 32835#endif
32599 break; 32836 break;
32600 } 32837 }
32838 case TK_ORDER: {
32839 sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, "ORDERBY");
32840 break;
32841 }
32601#ifndef SQLITE_OMIT_SUBQUERY 32842#ifndef SQLITE_OMIT_SUBQUERY
32602 case TK_EXISTS: { 32843 case TK_EXISTS: {
32603 assert( ExprUseXSelect(pExpr) ); 32844 assert( ExprUseXSelect(pExpr) );
@@ -34362,12 +34603,16 @@ SQLITE_PRIVATE void sqlite3ProgressCheck(Parse *p){
34362 p->rc = SQLITE_INTERRUPT; 34603 p->rc = SQLITE_INTERRUPT;
34363 } 34604 }
34364#ifndef SQLITE_OMIT_PROGRESS_CALLBACK 34605#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
34365 if( db->xProgress && (++p->nProgressSteps)>=db->nProgressOps ){ 34606 if( db->xProgress ){
34366 if( db->xProgress(db->pProgressArg) ){ 34607 if( p->rc==SQLITE_INTERRUPT ){
34367 p->nErr++; 34608 p->nProgressSteps = 0;
34368 p->rc = SQLITE_INTERRUPT; 34609 }else if( (++p->nProgressSteps)>=db->nProgressOps ){
34610 if( db->xProgress(db->pProgressArg) ){
34611 p->nErr++;
34612 p->rc = SQLITE_INTERRUPT;
34613 }
34614 p->nProgressSteps = 0;
34369 } 34615 }
34370 p->nProgressSteps = 0;
34371 } 34616 }
34372#endif 34617#endif
34373} 34618}
@@ -35523,121 +35768,32 @@ SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){
35523** this function assumes the single-byte case has already been handled. 35768** this function assumes the single-byte case has already been handled.
35524*/ 35769*/
35525SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ 35770SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){
35526 u32 a,b; 35771 u64 v64;
35772 u8 n;
35527 35773
35528 /* The 1-byte case. Overwhelmingly the most common. Handled inline 35774 /* Assume that the single-byte case has already been handled by
35529 ** by the getVarin32() macro */ 35775 ** the getVarint32() macro */
35530 a = *p; 35776 assert( (p[0] & 0x80)!=0 );
35531 /* a: p0 (unmasked) */
35532#ifndef getVarint32
35533 if (!(a&0x80))
35534 {
35535 /* Values between 0 and 127 */
35536 *v = a;
35537 return 1;
35538 }
35539#endif
35540 35777
35541 /* The 2-byte case */ 35778 if( (p[1] & 0x80)==0 ){
35542 p++; 35779 /* This is the two-byte case */
35543 b = *p; 35780 *v = ((p[0]&0x7f)<<7) | p[1];
35544 /* b: p1 (unmasked) */
35545 if (!(b&0x80))
35546 {
35547 /* Values between 128 and 16383 */
35548 a &= 0x7f;
35549 a = a<<7;
35550 *v = a | b;
35551 return 2; 35781 return 2;
35552 } 35782 }
35553 35783 if( (p[2] & 0x80)==0 ){
35554 /* The 3-byte case */ 35784 /* This is the three-byte case */
35555 p++; 35785 *v = ((p[0]&0x7f)<<14) | ((p[1]&0x7f)<<7) | p[2];
35556 a = a<<14;
35557 a |= *p;
35558 /* a: p0<<14 | p2 (unmasked) */
35559 if (!(a&0x80))
35560 {
35561 /* Values between 16384 and 2097151 */
35562 a &= (0x7f<<14)|(0x7f);
35563 b &= 0x7f;
35564 b = b<<7;
35565 *v = a | b;
35566 return 3; 35786 return 3;
35567 } 35787 }
35568 35788 /* four or more bytes */
35569 /* A 32-bit varint is used to store size information in btrees. 35789 n = sqlite3GetVarint(p, &v64);
35570 ** Objects are rarely larger than 2MiB limit of a 3-byte varint. 35790 assert( n>3 && n<=9 );
35571 ** A 3-byte varint is sufficient, for example, to record the size 35791 if( (v64 & SQLITE_MAX_U32)!=v64 ){
35572 ** of a 1048569-byte BLOB or string. 35792 *v = 0xffffffff;
35573 ** 35793 }else{
35574 ** We only unroll the first 1-, 2-, and 3- byte cases. The very
35575 ** rare larger cases can be handled by the slower 64-bit varint
35576 ** routine.
35577 */
35578#if 1
35579 {
35580 u64 v64;
35581 u8 n;
35582
35583 n = sqlite3GetVarint(p-2, &v64);
35584 assert( n>3 && n<=9 );
35585 if( (v64 & SQLITE_MAX_U32)!=v64 ){
35586 *v = 0xffffffff;
35587 }else{
35588 *v = (u32)v64;
35589 }
35590 return n;
35591 }
35592
35593#else
35594 /* For following code (kept for historical record only) shows an
35595 ** unrolling for the 3- and 4-byte varint cases. This code is
35596 ** slightly faster, but it is also larger and much harder to test.
35597 */
35598 p++;
35599 b = b<<14;
35600 b |= *p;
35601 /* b: p1<<14 | p3 (unmasked) */
35602 if (!(b&0x80))
35603 {
35604 /* Values between 2097152 and 268435455 */
35605 b &= (0x7f<<14)|(0x7f);
35606 a &= (0x7f<<14)|(0x7f);
35607 a = a<<7;
35608 *v = a | b;
35609 return 4;
35610 }
35611
35612 p++;
35613 a = a<<14;
35614 a |= *p;
35615 /* a: p0<<28 | p2<<14 | p4 (unmasked) */
35616 if (!(a&0x80))
35617 {
35618 /* Values between 268435456 and 34359738367 */
35619 a &= SLOT_4_2_0;
35620 b &= SLOT_4_2_0;
35621 b = b<<7;
35622 *v = a | b;
35623 return 5;
35624 }
35625
35626 /* We can only reach this point when reading a corrupt database
35627 ** file. In that case we are not in any hurry. Use the (relatively
35628 ** slow) general-purpose sqlite3GetVarint() routine to extract the
35629 ** value. */
35630 {
35631 u64 v64;
35632 u8 n;
35633
35634 p -= 4;
35635 n = sqlite3GetVarint(p, &v64);
35636 assert( n>5 && n<=9 );
35637 *v = (u32)v64; 35794 *v = (u32)v64;
35638 return n;
35639 } 35795 }
35640#endif 35796 return n;
35641} 35797}
35642 35798
35643/* 35799/*
@@ -36633,19 +36789,20 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
36633 /* 171 */ "VCreate" OpHelp(""), 36789 /* 171 */ "VCreate" OpHelp(""),
36634 /* 172 */ "VDestroy" OpHelp(""), 36790 /* 172 */ "VDestroy" OpHelp(""),
36635 /* 173 */ "VOpen" OpHelp(""), 36791 /* 173 */ "VOpen" OpHelp(""),
36636 /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), 36792 /* 174 */ "VCheck" OpHelp(""),
36637 /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), 36793 /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
36638 /* 176 */ "VRename" OpHelp(""), 36794 /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
36639 /* 177 */ "Pagecount" OpHelp(""), 36795 /* 177 */ "VRename" OpHelp(""),
36640 /* 178 */ "MaxPgcnt" OpHelp(""), 36796 /* 178 */ "Pagecount" OpHelp(""),
36641 /* 179 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), 36797 /* 179 */ "MaxPgcnt" OpHelp(""),
36642 /* 180 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), 36798 /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
36643 /* 181 */ "Trace" OpHelp(""), 36799 /* 181 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
36644 /* 182 */ "CursorHint" OpHelp(""), 36800 /* 182 */ "Trace" OpHelp(""),
36645 /* 183 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), 36801 /* 183 */ "CursorHint" OpHelp(""),
36646 /* 184 */ "Noop" OpHelp(""), 36802 /* 184 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
36647 /* 185 */ "Explain" OpHelp(""), 36803 /* 185 */ "Noop" OpHelp(""),
36648 /* 186 */ "Abortable" OpHelp(""), 36804 /* 186 */ "Explain" OpHelp(""),
36805 /* 187 */ "Abortable" OpHelp(""),
36649 }; 36806 };
36650 return azName[i]; 36807 return azName[i];
36651} 36808}
@@ -40787,9 +40944,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) {
40787 unixInodeInfo *pInode; 40944 unixInodeInfo *pInode;
40788 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; 40945 afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
40789 int skipShared = 0; 40946 int skipShared = 0;
40790#ifdef SQLITE_TEST
40791 int h = pFile->h;
40792#endif
40793 40947
40794 assert( pFile ); 40948 assert( pFile );
40795 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, 40949 OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
@@ -40805,9 +40959,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) {
40805 assert( pInode->nShared!=0 ); 40959 assert( pInode->nShared!=0 );
40806 if( pFile->eFileLock>SHARED_LOCK ){ 40960 if( pFile->eFileLock>SHARED_LOCK ){
40807 assert( pInode->eFileLock==pFile->eFileLock ); 40961 assert( pInode->eFileLock==pFile->eFileLock );
40808 SimulateIOErrorBenign(1);
40809 SimulateIOError( h=(-1) )
40810 SimulateIOErrorBenign(0);
40811 40962
40812#ifdef SQLITE_DEBUG 40963#ifdef SQLITE_DEBUG
40813 /* When reducing a lock such that other processes can start 40964 /* When reducing a lock such that other processes can start
@@ -40856,9 +41007,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) {
40856 unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte; 41007 unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;
40857 pInode->nShared--; 41008 pInode->nShared--;
40858 if( pInode->nShared==0 ){ 41009 if( pInode->nShared==0 ){
40859 SimulateIOErrorBenign(1);
40860 SimulateIOError( h=(-1) )
40861 SimulateIOErrorBenign(0);
40862 if( !skipShared ){ 41010 if( !skipShared ){
40863 rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0); 41011 rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);
40864 } 41012 }
@@ -57729,9 +57877,32 @@ static int writeJournalHdr(Pager *pPager){
57729 memset(zHeader, 0, sizeof(aJournalMagic)+4); 57877 memset(zHeader, 0, sizeof(aJournalMagic)+4);
57730 } 57878 }
57731 57879
57880
57881
57732 /* The random check-hash initializer */ 57882 /* The random check-hash initializer */
57733 sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); 57883 if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){
57884 sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
57885 }
57886#ifdef SQLITE_DEBUG
57887 else{
57888 /* The Pager.cksumInit variable is usually randomized above to protect
57889 ** against there being existing records in the journal file. This is
57890 ** dangerous, as following a crash they may be mistaken for records
57891 ** written by the current transaction and rolled back into the database
57892 ** file, causing corruption. The following assert statements verify
57893 ** that this is not required in "journal_mode=memory" mode, as in that
57894 ** case the journal file is always 0 bytes in size at this point.
57895 ** It is advantageous to avoid the sqlite3_randomness() call if possible
57896 ** as it takes the global PRNG mutex. */
57897 i64 sz = 0;
57898 sqlite3OsFileSize(pPager->jfd, &sz);
57899 assert( sz==0 );
57900 assert( pPager->journalOff==journalHdrOffset(pPager) );
57901 assert( sqlite3JournalIsInMemory(pPager->jfd) );
57902 }
57903#endif
57734 put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); 57904 put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);
57905
57735 /* The initial database size */ 57906 /* The initial database size */
57736 put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); 57907 put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);
57737 /* The assumed sector size for this process */ 57908 /* The assumed sector size for this process */
@@ -58375,6 +58546,9 @@ static int pager_end_transaction(Pager *pPager, int hasSuper, int bCommit){
58375 return (rc==SQLITE_OK?rc2:rc); 58546 return (rc==SQLITE_OK?rc2:rc);
58376} 58547}
58377 58548
58549/* Forward reference */
58550static int pager_playback(Pager *pPager, int isHot);
58551
58378/* 58552/*
58379** Execute a rollback if a transaction is active and unlock the 58553** Execute a rollback if a transaction is active and unlock the
58380** database file. 58554** database file.
@@ -58403,6 +58577,21 @@ static void pagerUnlockAndRollback(Pager *pPager){
58403 assert( pPager->eState==PAGER_READER ); 58577 assert( pPager->eState==PAGER_READER );
58404 pager_end_transaction(pPager, 0, 0); 58578 pager_end_transaction(pPager, 0, 0);
58405 } 58579 }
58580 }else if( pPager->eState==PAGER_ERROR
58581 && pPager->journalMode==PAGER_JOURNALMODE_MEMORY
58582 && isOpen(pPager->jfd)
58583 ){
58584 /* Special case for a ROLLBACK due to I/O error with an in-memory
58585 ** journal: We have to rollback immediately, before the journal is
58586 ** closed, because once it is closed, all content is forgotten. */
58587 int errCode = pPager->errCode;
58588 u8 eLock = pPager->eLock;
58589 pPager->eState = PAGER_OPEN;
58590 pPager->errCode = SQLITE_OK;
58591 pPager->eLock = EXCLUSIVE_LOCK;
58592 pager_playback(pPager, 1);
58593 pPager->errCode = errCode;
58594 pPager->eLock = eLock;
58406 } 58595 }
58407 pager_unlock(pPager); 58596 pager_unlock(pPager);
58408} 58597}
@@ -61895,8 +62084,20 @@ SQLITE_PRIVATE int sqlite3PagerGet(
61895 DbPage **ppPage, /* Write a pointer to the page here */ 62084 DbPage **ppPage, /* Write a pointer to the page here */
61896 int flags /* PAGER_GET_XXX flags */ 62085 int flags /* PAGER_GET_XXX flags */
61897){ 62086){
61898 /* printf("PAGE %u\n", pgno); fflush(stdout); */ 62087#if 0 /* Trace page fetch by setting to 1 */
62088 int rc;
62089 printf("PAGE %u\n", pgno);
62090 fflush(stdout);
62091 rc = pPager->xGet(pPager, pgno, ppPage, flags);
62092 if( rc ){
62093 printf("PAGE %u failed with 0x%02x\n", pgno, rc);
62094 fflush(stdout);
62095 }
62096 return rc;
62097#else
62098 /* Normal, high-speed version of sqlite3PagerGet() */
61899 return pPager->xGet(pPager, pgno, ppPage, flags); 62099 return pPager->xGet(pPager, pgno, ppPage, flags);
62100#endif
61900} 62101}
61901 62102
61902/* 62103/*
@@ -62772,6 +62973,13 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(
62772 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); 62973 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);
62773 if( rc==SQLITE_OK ){ 62974 if( rc==SQLITE_OK ){
62774 rc = pager_write_pagelist(pPager, pList); 62975 rc = pager_write_pagelist(pPager, pList);
62976 if( rc==SQLITE_OK && pPager->dbSize>pPager->dbFileSize ){
62977 char *pTmp = pPager->pTmpSpace;
62978 int szPage = (int)pPager->pageSize;
62979 memset(pTmp, 0, szPage);
62980 rc = sqlite3OsWrite(pPager->fd, pTmp, szPage,
62981 ((i64)pPager->dbSize*pPager->pageSize)-szPage);
62982 }
62775 if( rc==SQLITE_OK ){ 62983 if( rc==SQLITE_OK ){
62776 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); 62984 rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);
62777 } 62985 }
@@ -63583,7 +63791,7 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
63583 } 63791 }
63584 assert( state==pPager->eState ); 63792 assert( state==pPager->eState );
63585 } 63793 }
63586 }else if( eMode==PAGER_JOURNALMODE_OFF ){ 63794 }else if( eMode==PAGER_JOURNALMODE_OFF || eMode==PAGER_JOURNALMODE_MEMORY ){
63587 sqlite3OsClose(pPager->jfd); 63795 sqlite3OsClose(pPager->jfd);
63588 } 63796 }
63589 } 63797 }
@@ -69196,7 +69404,7 @@ struct IntegrityCk {
69196 BtShared *pBt; /* The tree being checked out */ 69404 BtShared *pBt; /* The tree being checked out */
69197 Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ 69405 Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */
69198 u8 *aPgRef; /* 1 bit per page in the db (see above) */ 69406 u8 *aPgRef; /* 1 bit per page in the db (see above) */
69199 Pgno nPage; /* Number of pages in the database */ 69407 Pgno nCkPage; /* Pages in the database. 0 for partial check */
69200 int mxErr; /* Stop accumulating errors when this reaches zero */ 69408 int mxErr; /* Stop accumulating errors when this reaches zero */
69201 int nErr; /* Number of messages written to zErrMsg so far */ 69409 int nErr; /* Number of messages written to zErrMsg so far */
69202 int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ 69410 int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */
@@ -69529,7 +69737,6 @@ SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){
69529 69737
69530/************** End of btmutex.c *********************************************/ 69738/************** End of btmutex.c *********************************************/
69531/************** Begin file btree.c *******************************************/ 69739/************** Begin file btree.c *******************************************/
69532
69533/* 69740/*
69534** 2004 April 6 69741** 2004 April 6
69535** 69742**
@@ -77027,7 +77234,7 @@ static int rebuildPage(
77027 assert( nCell>0 ); 77234 assert( nCell>0 );
77028 assert( i<iEnd ); 77235 assert( i<iEnd );
77029 j = get2byte(&aData[hdr+5]); 77236 j = get2byte(&aData[hdr+5]);
77030 if( NEVER(j>(u32)usableSize) ){ j = 0; } 77237 if( j>(u32)usableSize ){ j = 0; }
77031 memcpy(&pTmp[j], &aData[j], usableSize - j); 77238 memcpy(&pTmp[j], &aData[j], usableSize - j);
77032 77239
77033 for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){} 77240 for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){}
@@ -79991,7 +80198,8 @@ static void checkAppendMsg(
79991** corresponds to page iPg is already set. 80198** corresponds to page iPg is already set.
79992*/ 80199*/
79993static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ 80200static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){
79994 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); 80201 assert( pCheck->aPgRef!=0 );
80202 assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 );
79995 return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); 80203 return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));
79996} 80204}
79997 80205
@@ -79999,7 +80207,8 @@ static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){
79999** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. 80207** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.
80000*/ 80208*/
80001static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ 80209static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
80002 assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); 80210 assert( pCheck->aPgRef!=0 );
80211 assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 );
80003 pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); 80212 pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));
80004} 80213}
80005 80214
@@ -80013,7 +80222,7 @@ static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
80013** Also check that the page number is in bounds. 80222** Also check that the page number is in bounds.
80014*/ 80223*/
80015static int checkRef(IntegrityCk *pCheck, Pgno iPage){ 80224static int checkRef(IntegrityCk *pCheck, Pgno iPage){
80016 if( iPage>pCheck->nPage || iPage==0 ){ 80225 if( iPage>pCheck->nCkPage || iPage==0 ){
80017 checkAppendMsg(pCheck, "invalid page number %u", iPage); 80226 checkAppendMsg(pCheck, "invalid page number %u", iPage);
80018 return 1; 80227 return 1;
80019 } 80228 }
@@ -80240,6 +80449,7 @@ static int checkTreePage(
80240 if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ 80449 if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){
80241 checkAppendMsg(pCheck, 80450 checkAppendMsg(pCheck,
80242 "unable to get the page. error code=%d", rc); 80451 "unable to get the page. error code=%d", rc);
80452 if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM;
80243 goto end_of_check; 80453 goto end_of_check;
80244 } 80454 }
80245 80455
@@ -80510,15 +80720,15 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
80510 sCheck.db = db; 80720 sCheck.db = db;
80511 sCheck.pBt = pBt; 80721 sCheck.pBt = pBt;
80512 sCheck.pPager = pBt->pPager; 80722 sCheck.pPager = pBt->pPager;
80513 sCheck.nPage = btreePagecount(sCheck.pBt); 80723 sCheck.nCkPage = btreePagecount(sCheck.pBt);
80514 sCheck.mxErr = mxErr; 80724 sCheck.mxErr = mxErr;
80515 sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); 80725 sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
80516 sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; 80726 sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL;
80517 if( sCheck.nPage==0 ){ 80727 if( sCheck.nCkPage==0 ){
80518 goto integrity_ck_cleanup; 80728 goto integrity_ck_cleanup;
80519 } 80729 }
80520 80730
80521 sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1); 80731 sCheck.aPgRef = sqlite3MallocZero((sCheck.nCkPage / 8)+ 1);
80522 if( !sCheck.aPgRef ){ 80732 if( !sCheck.aPgRef ){
80523 checkOom(&sCheck); 80733 checkOom(&sCheck);
80524 goto integrity_ck_cleanup; 80734 goto integrity_ck_cleanup;
@@ -80530,7 +80740,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
80530 } 80740 }
80531 80741
80532 i = PENDING_BYTE_PAGE(pBt); 80742 i = PENDING_BYTE_PAGE(pBt);
80533 if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i); 80743 if( i<=sCheck.nCkPage ) setPageReferenced(&sCheck, i);
80534 80744
80535 /* Check the integrity of the freelist 80745 /* Check the integrity of the freelist
80536 */ 80746 */
@@ -80581,7 +80791,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
80581 /* Make sure every page in the file is referenced 80791 /* Make sure every page in the file is referenced
80582 */ 80792 */
80583 if( !bPartial ){ 80793 if( !bPartial ){
80584 for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){ 80794 for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){
80585#ifdef SQLITE_OMIT_AUTOVACUUM 80795#ifdef SQLITE_OMIT_AUTOVACUUM
80586 if( getPageReferenced(&sCheck, i)==0 ){ 80796 if( getPageReferenced(&sCheck, i)==0 ){
80587 checkAppendMsg(&sCheck, "Page %u: never used", i); 80797 checkAppendMsg(&sCheck, "Page %u: never used", i);
@@ -82022,7 +82232,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){
82022 pMem->flags |= MEM_Term; 82232 pMem->flags |= MEM_Term;
82023 return; 82233 return;
82024 } 82234 }
82025 if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ 82235 if( pMem->xDel==sqlite3RCStrUnref ){
82026 /* Blindly assume that all RCStr objects are zero-terminated */ 82236 /* Blindly assume that all RCStr objects are zero-terminated */
82027 pMem->flags |= MEM_Term; 82237 pMem->flags |= MEM_Term;
82028 return; 82238 return;
@@ -83402,6 +83612,7 @@ static int valueFromExpr(
83402 if( pVal ){ 83612 if( pVal ){
83403 pVal->flags = MEM_Int; 83613 pVal->flags = MEM_Int;
83404 pVal->u.i = pExpr->u.zToken[4]==0; 83614 pVal->u.i = pExpr->u.zToken[4]==0;
83615 sqlite3ValueApplyAffinity(pVal, affinity, enc);
83405 } 83616 }
83406 } 83617 }
83407 83618
@@ -84715,6 +84926,10 @@ SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn(
84715 int iDest = pOp->p2; /* Jump destination */ 84926 int iDest = pOp->p2; /* Jump destination */
84716 if( iDest==0 ) continue; 84927 if( iDest==0 ) continue;
84717 if( pOp->opcode==OP_Gosub ) continue; 84928 if( pOp->opcode==OP_Gosub ) continue;
84929 if( pOp->p3==20230325 && pOp->opcode==OP_NotNull ){
84930 /* This is a deliberately taken illegal branch. tag-20230325-2 */
84931 continue;
84932 }
84718 if( iDest<0 ){ 84933 if( iDest<0 ){
84719 int j = ADDR(iDest); 84934 int j = ADDR(iDest);
84720 assert( j>=0 ); 84935 assert( j>=0 );
@@ -88174,20 +88389,33 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem
88174 return n1 - n2; 88389 return n1 - n2;
88175} 88390}
88176 88391
88392/* The following two functions are used only within testcase() to prove
88393** test coverage. These functions do no exist for production builds.
88394** We must use separate SQLITE_NOINLINE functions here, since otherwise
88395** optimizer code movement causes gcov to become very confused.
88396*/
88397#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
88398static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; }
88399static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; }
88400#endif
88401
88177/* 88402/*
88178** Do a comparison between a 64-bit signed integer and a 64-bit floating-point 88403** Do a comparison between a 64-bit signed integer and a 64-bit floating-point
88179** number. Return negative, zero, or positive if the first (i64) is less than, 88404** number. Return negative, zero, or positive if the first (i64) is less than,
88180** equal to, or greater than the second (double). 88405** equal to, or greater than the second (double).
88181*/ 88406*/
88182SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ 88407SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
88183 if( sizeof(LONGDOUBLE_TYPE)>8 ){ 88408 if( sqlite3IsNaN(r) ){
88409 /* SQLite considers NaN to be a NULL. And all integer values are greater
88410 ** than NULL */
88411 return 1;
88412 }
88413 if( sqlite3Config.bUseLongDouble ){
88184 LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; 88414 LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
88185 testcase( x<r ); 88415 testcase( x<r );
88186 testcase( x>r ); 88416 testcase( x>r );
88187 testcase( x==r ); 88417 testcase( x==r );
88188 if( x<r ) return -1; 88418 return (x<r) ? -1 : (x>r);
88189 if( x>r ) return +1; /*NO_TEST*/ /* work around bugs in gcov */
88190 return 0; /*NO_TEST*/ /* work around bugs in gcov */
88191 }else{ 88419 }else{
88192 i64 y; 88420 i64 y;
88193 double s; 88421 double s;
@@ -88197,9 +88425,10 @@ SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
88197 if( i<y ) return -1; 88425 if( i<y ) return -1;
88198 if( i>y ) return +1; 88426 if( i>y ) return +1;
88199 s = (double)i; 88427 s = (double)i;
88200 if( s<r ) return -1; 88428 testcase( doubleLt(s,r) );
88201 if( s>r ) return +1; 88429 testcase( doubleLt(r,s) );
88202 return 0; 88430 testcase( doubleEq(r,s) );
88431 return (s<r) ? -1 : (s>r);
88203 } 88432 }
88204} 88433}
88205 88434
@@ -89567,7 +89796,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value *pOld){
89567** is too big or if an OOM occurs. 89796** is too big or if an OOM occurs.
89568** 89797**
89569** The invokeValueDestructor(P,X) routine invokes destructor function X() 89798** The invokeValueDestructor(P,X) routine invokes destructor function X()
89570** on value P is not going to be used and need to be destroyed. 89799** on value P if P is not going to be used and need to be destroyed.
89571*/ 89800*/
89572static void setResultStrOrError( 89801static void setResultStrOrError(
89573 sqlite3_context *pCtx, /* Function context */ 89802 sqlite3_context *pCtx, /* Function context */
@@ -89597,7 +89826,7 @@ static void setResultStrOrError(
89597static int invokeValueDestructor( 89826static int invokeValueDestructor(
89598 const void *p, /* Value to destroy */ 89827 const void *p, /* Value to destroy */
89599 void (*xDel)(void*), /* The destructor */ 89828 void (*xDel)(void*), /* The destructor */
89600 sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */ 89829 sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */
89601){ 89830){
89602 assert( xDel!=SQLITE_DYNAMIC ); 89831 assert( xDel!=SQLITE_DYNAMIC );
89603 if( xDel==0 ){ 89832 if( xDel==0 ){
@@ -89607,7 +89836,14 @@ static int invokeValueDestructor(
89607 }else{ 89836 }else{
89608 xDel((void*)p); 89837 xDel((void*)p);
89609 } 89838 }
89839#ifdef SQLITE_ENABLE_API_ARMOR
89840 if( pCtx!=0 ){
89841 sqlite3_result_error_toobig(pCtx);
89842 }
89843#else
89844 assert( pCtx!=0 );
89610 sqlite3_result_error_toobig(pCtx); 89845 sqlite3_result_error_toobig(pCtx);
89846#endif
89611 return SQLITE_TOOBIG; 89847 return SQLITE_TOOBIG;
89612} 89848}
89613SQLITE_API void sqlite3_result_blob( 89849SQLITE_API void sqlite3_result_blob(
@@ -89616,6 +89852,12 @@ SQLITE_API void sqlite3_result_blob(
89616 int n, 89852 int n,
89617 void (*xDel)(void *) 89853 void (*xDel)(void *)
89618){ 89854){
89855#ifdef SQLITE_ENABLE_API_ARMOR
89856 if( pCtx==0 || n<0 ){
89857 invokeValueDestructor(z, xDel, pCtx);
89858 return;
89859 }
89860#endif
89619 assert( n>=0 ); 89861 assert( n>=0 );
89620 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89862 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89621 setResultStrOrError(pCtx, z, n, 0, xDel); 89863 setResultStrOrError(pCtx, z, n, 0, xDel);
@@ -89626,8 +89868,14 @@ SQLITE_API void sqlite3_result_blob64(
89626 sqlite3_uint64 n, 89868 sqlite3_uint64 n,
89627 void (*xDel)(void *) 89869 void (*xDel)(void *)
89628){ 89870){
89629 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89630 assert( xDel!=SQLITE_DYNAMIC ); 89871 assert( xDel!=SQLITE_DYNAMIC );
89872#ifdef SQLITE_ENABLE_API_ARMOR
89873 if( pCtx==0 ){
89874 invokeValueDestructor(z, xDel, 0);
89875 return;
89876 }
89877#endif
89878 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89631 if( n>0x7fffffff ){ 89879 if( n>0x7fffffff ){
89632 (void)invokeValueDestructor(z, xDel, pCtx); 89880 (void)invokeValueDestructor(z, xDel, pCtx);
89633 }else{ 89881 }else{
@@ -89635,30 +89883,48 @@ SQLITE_API void sqlite3_result_blob64(
89635 } 89883 }
89636} 89884}
89637SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ 89885SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
89886#ifdef SQLITE_ENABLE_API_ARMOR
89887 if( pCtx==0 ) return;
89888#endif
89638 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89889 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89639 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); 89890 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
89640} 89891}
89641SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ 89892SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
89893#ifdef SQLITE_ENABLE_API_ARMOR
89894 if( pCtx==0 ) return;
89895#endif
89642 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89896 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89643 pCtx->isError = SQLITE_ERROR; 89897 pCtx->isError = SQLITE_ERROR;
89644 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); 89898 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
89645} 89899}
89646#ifndef SQLITE_OMIT_UTF16 89900#ifndef SQLITE_OMIT_UTF16
89647SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ 89901SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
89902#ifdef SQLITE_ENABLE_API_ARMOR
89903 if( pCtx==0 ) return;
89904#endif
89648 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89905 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89649 pCtx->isError = SQLITE_ERROR; 89906 pCtx->isError = SQLITE_ERROR;
89650 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); 89907 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
89651} 89908}
89652#endif 89909#endif
89653SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ 89910SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
89911#ifdef SQLITE_ENABLE_API_ARMOR
89912 if( pCtx==0 ) return;
89913#endif
89654 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89914 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89655 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); 89915 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
89656} 89916}
89657SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ 89917SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
89918#ifdef SQLITE_ENABLE_API_ARMOR
89919 if( pCtx==0 ) return;
89920#endif
89658 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89921 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89659 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); 89922 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
89660} 89923}
89661SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ 89924SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
89925#ifdef SQLITE_ENABLE_API_ARMOR
89926 if( pCtx==0 ) return;
89927#endif
89662 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89928 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89663 sqlite3VdbeMemSetNull(pCtx->pOut); 89929 sqlite3VdbeMemSetNull(pCtx->pOut);
89664} 89930}
@@ -89668,14 +89934,25 @@ SQLITE_API void sqlite3_result_pointer(
89668 const char *zPType, 89934 const char *zPType,
89669 void (*xDestructor)(void*) 89935 void (*xDestructor)(void*)
89670){ 89936){
89671 Mem *pOut = pCtx->pOut; 89937 Mem *pOut;
89938#ifdef SQLITE_ENABLE_API_ARMOR
89939 if( pCtx==0 ){
89940 invokeValueDestructor(pPtr, xDestructor, 0);
89941 return;
89942 }
89943#endif
89944 pOut = pCtx->pOut;
89672 assert( sqlite3_mutex_held(pOut->db->mutex) ); 89945 assert( sqlite3_mutex_held(pOut->db->mutex) );
89673 sqlite3VdbeMemRelease(pOut); 89946 sqlite3VdbeMemRelease(pOut);
89674 pOut->flags = MEM_Null; 89947 pOut->flags = MEM_Null;
89675 sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); 89948 sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor);
89676} 89949}
89677SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ 89950SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
89678 Mem *pOut = pCtx->pOut; 89951 Mem *pOut;
89952#ifdef SQLITE_ENABLE_API_ARMOR
89953 if( pCtx==0 ) return;
89954#endif
89955 pOut = pCtx->pOut;
89679 assert( sqlite3_mutex_held(pOut->db->mutex) ); 89956 assert( sqlite3_mutex_held(pOut->db->mutex) );
89680 pOut->eSubtype = eSubtype & 0xff; 89957 pOut->eSubtype = eSubtype & 0xff;
89681 pOut->flags |= MEM_Subtype; 89958 pOut->flags |= MEM_Subtype;
@@ -89686,6 +89963,12 @@ SQLITE_API void sqlite3_result_text(
89686 int n, 89963 int n,
89687 void (*xDel)(void *) 89964 void (*xDel)(void *)
89688){ 89965){
89966#ifdef SQLITE_ENABLE_API_ARMOR
89967 if( pCtx==0 ){
89968 invokeValueDestructor(z, xDel, 0);
89969 return;
89970 }
89971#endif
89689 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89972 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89690 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); 89973 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
89691} 89974}
@@ -89696,6 +89979,12 @@ SQLITE_API void sqlite3_result_text64(
89696 void (*xDel)(void *), 89979 void (*xDel)(void *),
89697 unsigned char enc 89980 unsigned char enc
89698){ 89981){
89982#ifdef SQLITE_ENABLE_API_ARMOR
89983 if( pCtx==0 ){
89984 invokeValueDestructor(z, xDel, 0);
89985 return;
89986 }
89987#endif
89699 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 89988 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89700 assert( xDel!=SQLITE_DYNAMIC ); 89989 assert( xDel!=SQLITE_DYNAMIC );
89701 if( enc!=SQLITE_UTF8 ){ 89990 if( enc!=SQLITE_UTF8 ){
@@ -89739,7 +90028,16 @@ SQLITE_API void sqlite3_result_text16le(
89739} 90028}
89740#endif /* SQLITE_OMIT_UTF16 */ 90029#endif /* SQLITE_OMIT_UTF16 */
89741SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ 90030SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
89742 Mem *pOut = pCtx->pOut; 90031 Mem *pOut;
90032
90033#ifdef SQLITE_ENABLE_API_ARMOR
90034 if( pCtx==0 ) return;
90035 if( pValue==0 ){
90036 sqlite3_result_null(pCtx);
90037 return;
90038 }
90039#endif
90040 pOut = pCtx->pOut;
89743 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 90041 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89744 sqlite3VdbeMemCopy(pOut, pValue); 90042 sqlite3VdbeMemCopy(pOut, pValue);
89745 sqlite3VdbeChangeEncoding(pOut, pCtx->enc); 90043 sqlite3VdbeChangeEncoding(pOut, pCtx->enc);
@@ -89751,7 +90049,12 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
89751 sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); 90049 sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0);
89752} 90050}
89753SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ 90051SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){
89754 Mem *pOut = pCtx->pOut; 90052 Mem *pOut;
90053
90054#ifdef SQLITE_ENABLE_API_ARMOR
90055 if( pCtx==0 ) return SQLITE_MISUSE_BKPT;
90056#endif
90057 pOut = pCtx->pOut;
89755 assert( sqlite3_mutex_held(pOut->db->mutex) ); 90058 assert( sqlite3_mutex_held(pOut->db->mutex) );
89756 if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ 90059 if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){
89757 sqlite3_result_error_toobig(pCtx); 90060 sqlite3_result_error_toobig(pCtx);
@@ -89765,6 +90068,9 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){
89765#endif 90068#endif
89766} 90069}
89767SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ 90070SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
90071#ifdef SQLITE_ENABLE_API_ARMOR
90072 if( pCtx==0 ) return;
90073#endif
89768 pCtx->isError = errCode ? errCode : -1; 90074 pCtx->isError = errCode ? errCode : -1;
89769#ifdef SQLITE_DEBUG 90075#ifdef SQLITE_DEBUG
89770 if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; 90076 if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
@@ -89777,6 +90083,9 @@ SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
89777 90083
89778/* Force an SQLITE_TOOBIG error. */ 90084/* Force an SQLITE_TOOBIG error. */
89779SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ 90085SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
90086#ifdef SQLITE_ENABLE_API_ARMOR
90087 if( pCtx==0 ) return;
90088#endif
89780 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 90089 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89781 pCtx->isError = SQLITE_TOOBIG; 90090 pCtx->isError = SQLITE_TOOBIG;
89782 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, 90091 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
@@ -89785,6 +90094,9 @@ SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
89785 90094
89786/* An SQLITE_NOMEM error. */ 90095/* An SQLITE_NOMEM error. */
89787SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ 90096SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
90097#ifdef SQLITE_ENABLE_API_ARMOR
90098 if( pCtx==0 ) return;
90099#endif
89788 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 90100 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
89789 sqlite3VdbeMemSetNull(pCtx->pOut); 90101 sqlite3VdbeMemSetNull(pCtx->pOut);
89790 pCtx->isError = SQLITE_NOMEM_BKPT; 90102 pCtx->isError = SQLITE_NOMEM_BKPT;
@@ -90037,7 +90349,11 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
90037** pointer to it. 90349** pointer to it.
90038*/ 90350*/
90039SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ 90351SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
90352#ifdef SQLITE_ENABLE_API_ARMOR
90353 if( p==0 ) return 0;
90354#else
90040 assert( p && p->pFunc ); 90355 assert( p && p->pFunc );
90356#endif
90041 return p->pFunc->pUserData; 90357 return p->pFunc->pUserData;
90042} 90358}
90043 90359
@@ -90052,7 +90368,11 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
90052** application defined function. 90368** application defined function.
90053*/ 90369*/
90054SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ 90370SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
90371#ifdef SQLITE_ENABLE_API_ARMOR
90372 if( p==0 ) return 0;
90373#else
90055 assert( p && p->pOut ); 90374 assert( p && p->pOut );
90375#endif
90056 return p->pOut->db; 90376 return p->pOut->db;
90057} 90377}
90058 90378
@@ -90071,7 +90391,11 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
90071** value, as a signal to the xUpdate routine that the column is unchanged. 90391** value, as a signal to the xUpdate routine that the column is unchanged.
90072*/ 90392*/
90073SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ 90393SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
90394#ifdef SQLITE_ENABLE_API_ARMOR
90395 if( p==0 ) return 0;
90396#else
90074 assert( p ); 90397 assert( p );
90398#endif
90075 return sqlite3_value_nochange(p->pOut); 90399 return sqlite3_value_nochange(p->pOut);
90076} 90400}
90077 90401
@@ -90099,7 +90423,7 @@ static int valueFromValueList(
90099 ValueList *pRhs; 90423 ValueList *pRhs;
90100 90424
90101 *ppOut = 0; 90425 *ppOut = 0;
90102 if( pVal==0 ) return SQLITE_MISUSE; 90426 if( pVal==0 ) return SQLITE_MISUSE_BKPT;
90103 if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ 90427 if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){
90104 return SQLITE_ERROR; 90428 return SQLITE_ERROR;
90105 }else{ 90429 }else{
@@ -90230,6 +90554,9 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
90230SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ 90554SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
90231 AuxData *pAuxData; 90555 AuxData *pAuxData;
90232 90556
90557#ifdef SQLITE_ENABLE_API_ARMOR
90558 if( pCtx==0 ) return 0;
90559#endif
90233 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 90560 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
90234#if SQLITE_ENABLE_STAT4 90561#if SQLITE_ENABLE_STAT4
90235 if( pCtx->pVdbe==0 ) return 0; 90562 if( pCtx->pVdbe==0 ) return 0;
@@ -90262,8 +90589,12 @@ SQLITE_API void sqlite3_set_auxdata(
90262 void (*xDelete)(void*) 90589 void (*xDelete)(void*)
90263){ 90590){
90264 AuxData *pAuxData; 90591 AuxData *pAuxData;
90265 Vdbe *pVdbe = pCtx->pVdbe; 90592 Vdbe *pVdbe;
90266 90593
90594#ifdef SQLITE_ENABLE_API_ARMOR
90595 if( pCtx==0 ) return;
90596#endif
90597 pVdbe= pCtx->pVdbe;
90267 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); 90598 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
90268#ifdef SQLITE_ENABLE_STAT4 90599#ifdef SQLITE_ENABLE_STAT4
90269 if( pVdbe==0 ) goto failed; 90600 if( pVdbe==0 ) goto failed;
@@ -90700,7 +91031,7 @@ static int vdbeUnbind(Vdbe *p, unsigned int i){
90700 } 91031 }
90701 sqlite3_mutex_enter(p->db->mutex); 91032 sqlite3_mutex_enter(p->db->mutex);
90702 if( p->eVdbeState!=VDBE_READY_STATE ){ 91033 if( p->eVdbeState!=VDBE_READY_STATE ){
90703 sqlite3Error(p->db, SQLITE_MISUSE); 91034 sqlite3Error(p->db, SQLITE_MISUSE_BKPT);
90704 sqlite3_mutex_leave(p->db->mutex); 91035 sqlite3_mutex_leave(p->db->mutex);
90705 sqlite3_log(SQLITE_MISUSE, 91036 sqlite3_log(SQLITE_MISUSE,
90706 "bind on a busy prepared statement: [%s]", p->zSql); 91037 "bind on a busy prepared statement: [%s]", p->zSql);
@@ -90929,6 +91260,9 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
90929SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ 91260SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){
90930 int rc; 91261 int rc;
90931 Vdbe *p = (Vdbe *)pStmt; 91262 Vdbe *p = (Vdbe *)pStmt;
91263#ifdef SQLITE_ENABLE_API_ARMOR
91264 if( p==0 ) return SQLITE_MISUSE_BKPT;
91265#endif
90932 sqlite3_mutex_enter(p->db->mutex); 91266 sqlite3_mutex_enter(p->db->mutex);
90933 if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ 91267 if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){
90934 rc = SQLITE_TOOBIG; 91268 rc = SQLITE_TOOBIG;
@@ -91055,6 +91389,9 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt){
91055SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ 91389SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){
91056 Vdbe *v = (Vdbe*)pStmt; 91390 Vdbe *v = (Vdbe*)pStmt;
91057 int rc; 91391 int rc;
91392#ifdef SQLITE_ENABLE_API_ARMOR
91393 if( pStmt==0 ) return SQLITE_MISUSE_BKPT;
91394#endif
91058 sqlite3_mutex_enter(v->db->mutex); 91395 sqlite3_mutex_enter(v->db->mutex);
91059 if( ((int)v->explain)==eMode ){ 91396 if( ((int)v->explain)==eMode ){
91060 rc = SQLITE_OK; 91397 rc = SQLITE_OK;
@@ -91221,10 +91558,16 @@ static UnpackedRecord *vdbeUnpackRecord(
91221** a field of the row currently being updated or deleted. 91558** a field of the row currently being updated or deleted.
91222*/ 91559*/
91223SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ 91560SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
91224 PreUpdate *p = db->pPreUpdate; 91561 PreUpdate *p;
91225 Mem *pMem; 91562 Mem *pMem;
91226 int rc = SQLITE_OK; 91563 int rc = SQLITE_OK;
91227 91564
91565#ifdef SQLITE_ENABLE_API_ARMOR
91566 if( db==0 || ppValue==0 ){
91567 return SQLITE_MISUSE_BKPT;
91568 }
91569#endif
91570 p = db->pPreUpdate;
91228 /* Test that this call is being made from within an SQLITE_DELETE or 91571 /* Test that this call is being made from within an SQLITE_DELETE or
91229 ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ 91572 ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */
91230 if( !p || p->op==SQLITE_INSERT ){ 91573 if( !p || p->op==SQLITE_INSERT ){
@@ -91285,7 +91628,12 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa
91285** the number of columns in the row being updated, deleted or inserted. 91628** the number of columns in the row being updated, deleted or inserted.
91286*/ 91629*/
91287SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ 91630SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){
91288 PreUpdate *p = db->pPreUpdate; 91631 PreUpdate *p;
91632#ifdef SQLITE_ENABLE_API_ARMOR
91633 p = db!=0 ? db->pPreUpdate : 0;
91634#else
91635 p = db->pPreUpdate;
91636#endif
91289 return (p ? p->keyinfo.nKeyField : 0); 91637 return (p ? p->keyinfo.nKeyField : 0);
91290} 91638}
91291#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ 91639#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
@@ -91303,7 +91651,12 @@ SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){
91303** or SET DEFAULT action is considered a trigger. 91651** or SET DEFAULT action is considered a trigger.
91304*/ 91652*/
91305SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ 91653SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){
91306 PreUpdate *p = db->pPreUpdate; 91654 PreUpdate *p;
91655#ifdef SQLITE_ENABLE_API_ARMOR
91656 p = db!=0 ? db->pPreUpdate : 0;
91657#else
91658 p = db->pPreUpdate;
91659#endif
91307 return (p ? p->v->nFrame : 0); 91660 return (p ? p->v->nFrame : 0);
91308} 91661}
91309#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ 91662#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
@@ -91314,7 +91667,12 @@ SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){
91314** only. 91667** only.
91315*/ 91668*/
91316SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ 91669SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){
91317 PreUpdate *p = db->pPreUpdate; 91670 PreUpdate *p;
91671#ifdef SQLITE_ENABLE_API_ARMOR
91672 p = db!=0 ? db->pPreUpdate : 0;
91673#else
91674 p = db->pPreUpdate;
91675#endif
91318 return (p ? p->iBlobWrite : -1); 91676 return (p ? p->iBlobWrite : -1);
91319} 91677}
91320#endif 91678#endif
@@ -91325,10 +91683,16 @@ SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){
91325** a field of the row currently being updated or inserted. 91683** a field of the row currently being updated or inserted.
91326*/ 91684*/
91327SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ 91685SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
91328 PreUpdate *p = db->pPreUpdate; 91686 PreUpdate *p;
91329 int rc = SQLITE_OK; 91687 int rc = SQLITE_OK;
91330 Mem *pMem; 91688 Mem *pMem;
91331 91689
91690#ifdef SQLITE_ENABLE_API_ARMOR
91691 if( db==0 || ppValue==0 ){
91692 return SQLITE_MISUSE_BKPT;
91693 }
91694#endif
91695 p = db->pPreUpdate;
91332 if( !p || p->op==SQLITE_DELETE ){ 91696 if( !p || p->op==SQLITE_DELETE ){
91333 rc = SQLITE_MISUSE_BKPT; 91697 rc = SQLITE_MISUSE_BKPT;
91334 goto preupdate_new_out; 91698 goto preupdate_new_out;
@@ -91407,11 +91771,20 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
91407 void *pOut /* OUT: Write the answer here */ 91771 void *pOut /* OUT: Write the answer here */
91408){ 91772){
91409 Vdbe *p = (Vdbe*)pStmt; 91773 Vdbe *p = (Vdbe*)pStmt;
91410 VdbeOp *aOp = p->aOp; 91774 VdbeOp *aOp;
91411 int nOp = p->nOp; 91775 int nOp;
91412 ScanStatus *pScan = 0; 91776 ScanStatus *pScan = 0;
91413 int idx; 91777 int idx;
91414 91778
91779#ifdef SQLITE_ENABLE_API_ARMOR
91780 if( p==0 || pOut==0
91781 || iScanStatusOp<SQLITE_SCANSTAT_NLOOP
91782 || iScanStatusOp>SQLITE_SCANSTAT_NCYCLE ){
91783 return 1;
91784 }
91785#endif
91786 aOp = p->aOp;
91787 nOp = p->nOp;
91415 if( p->pFrame ){ 91788 if( p->pFrame ){
91416 VdbeFrame *pFrame; 91789 VdbeFrame *pFrame;
91417 for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); 91790 for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);
@@ -91558,7 +91931,7 @@ SQLITE_API int sqlite3_stmt_scanstatus(
91558SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ 91931SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
91559 Vdbe *p = (Vdbe*)pStmt; 91932 Vdbe *p = (Vdbe*)pStmt;
91560 int ii; 91933 int ii;
91561 for(ii=0; ii<p->nOp; ii++){ 91934 for(ii=0; p!=0 && ii<p->nOp; ii++){
91562 Op *pOp = &p->aOp[ii]; 91935 Op *pOp = &p->aOp[ii];
91563 pOp->nExec = 0; 91936 pOp->nExec = 0;
91564 pOp->nCycle = 0; 91937 pOp->nCycle = 0;
@@ -92527,11 +92900,11 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow(
92527 sqlite3RCStrRef(pBuf); 92900 sqlite3RCStrRef(pBuf);
92528 if( t&1 ){ 92901 if( t&1 ){
92529 rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, 92902 rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding,
92530 (void(*)(void*))sqlite3RCStrUnref); 92903 sqlite3RCStrUnref);
92531 pDest->flags |= MEM_Term; 92904 pDest->flags |= MEM_Term;
92532 }else{ 92905 }else{
92533 rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, 92906 rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0,
92534 (void(*)(void*))sqlite3RCStrUnref); 92907 sqlite3RCStrUnref);
92535 } 92908 }
92536 }else{ 92909 }else{
92537 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); 92910 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest);
@@ -95406,7 +95779,6 @@ case OP_MakeRecord: {
95406 /* NULL value. No change in zPayload */ 95779 /* NULL value. No change in zPayload */
95407 }else{ 95780 }else{
95408 u64 v; 95781 u64 v;
95409 u32 i;
95410 if( serial_type==7 ){ 95782 if( serial_type==7 ){
95411 assert( sizeof(v)==sizeof(pRec->u.r) ); 95783 assert( sizeof(v)==sizeof(pRec->u.r) );
95412 memcpy(&v, &pRec->u.r, sizeof(v)); 95784 memcpy(&v, &pRec->u.r, sizeof(v));
@@ -95414,12 +95786,17 @@ case OP_MakeRecord: {
95414 }else{ 95786 }else{
95415 v = pRec->u.i; 95787 v = pRec->u.i;
95416 } 95788 }
95417 len = i = sqlite3SmallTypeSizes[serial_type]; 95789 len = sqlite3SmallTypeSizes[serial_type];
95418 assert( i>0 ); 95790 assert( len>=1 && len<=8 && len!=5 && len!=7 );
95419 while( 1 /*exit-by-break*/ ){ 95791 switch( len ){
95420 zPayload[--i] = (u8)(v&0xFF); 95792 default: zPayload[7] = (u8)(v&0xff); v >>= 8;
95421 if( i==0 ) break; 95793 zPayload[6] = (u8)(v&0xff); v >>= 8;
95422 v >>= 8; 95794 case 6: zPayload[5] = (u8)(v&0xff); v >>= 8;
95795 zPayload[4] = (u8)(v&0xff); v >>= 8;
95796 case 4: zPayload[3] = (u8)(v&0xff); v >>= 8;
95797 case 3: zPayload[2] = (u8)(v&0xff); v >>= 8;
95798 case 2: zPayload[1] = (u8)(v&0xff); v >>= 8;
95799 case 1: zPayload[0] = (u8)(v&0xff);
95423 } 95800 }
95424 zPayload += len; 95801 zPayload += len;
95425 } 95802 }
@@ -97536,8 +97913,13 @@ case OP_RowCell: {
97536** the "primary" delete. The others are all on OPFLAG_FORDELETE 97913** the "primary" delete. The others are all on OPFLAG_FORDELETE
97537** cursors or else are marked with the AUXDELETE flag. 97914** cursors or else are marked with the AUXDELETE flag.
97538** 97915**
97539** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row 97916** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then
97540** change count is incremented (otherwise not). 97917** the row change count is incremented (otherwise not).
97918**
97919** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the
97920** pre-update-hook for deletes is run, but the btree is otherwise unchanged.
97921** This happens when the OP_Delete is to be shortly followed by an OP_Insert
97922** with the same key, causing the btree entry to be overwritten.
97541** 97923**
97542** P1 must not be pseudo-table. It has to be a real table with 97924** P1 must not be pseudo-table. It has to be a real table with
97543** multiple rows. 97925** multiple rows.
@@ -98662,13 +99044,41 @@ case OP_CreateBtree: { /* out2 */
98662/* Opcode: SqlExec * * * P4 * 99044/* Opcode: SqlExec * * * P4 *
98663** 99045**
98664** Run the SQL statement or statements specified in the P4 string. 99046** Run the SQL statement or statements specified in the P4 string.
99047** Disable Auth and Trace callbacks while those statements are running if
99048** P1 is true.
98665*/ 99049*/
98666case OP_SqlExec: { 99050case OP_SqlExec: {
99051 char *zErr;
99052#ifndef SQLITE_OMIT_AUTHORIZATION
99053 sqlite3_xauth xAuth;
99054#endif
99055 u8 mTrace;
99056
98667 sqlite3VdbeIncrWriteCounter(p, 0); 99057 sqlite3VdbeIncrWriteCounter(p, 0);
98668 db->nSqlExec++; 99058 db->nSqlExec++;
98669 rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); 99059 zErr = 0;
99060#ifndef SQLITE_OMIT_AUTHORIZATION
99061 xAuth = db->xAuth;
99062#endif
99063 mTrace = db->mTrace;
99064 if( pOp->p1 ){
99065#ifndef SQLITE_OMIT_AUTHORIZATION
99066 db->xAuth = 0;
99067#endif
99068 db->mTrace = 0;
99069 }
99070 rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr);
98670 db->nSqlExec--; 99071 db->nSqlExec--;
98671 if( rc ) goto abort_due_to_error; 99072#ifndef SQLITE_OMIT_AUTHORIZATION
99073 db->xAuth = xAuth;
99074#endif
99075 db->mTrace = mTrace;
99076 if( zErr || rc ){
99077 sqlite3VdbeError(p, "%s", zErr);
99078 sqlite3_free(zErr);
99079 if( rc==SQLITE_NOMEM ) goto no_mem;
99080 goto abort_due_to_error;
99081 }
98672 break; 99082 break;
98673} 99083}
98674 99084
@@ -99890,6 +100300,53 @@ case OP_VOpen: { /* ncycle */
99890#endif /* SQLITE_OMIT_VIRTUALTABLE */ 100300#endif /* SQLITE_OMIT_VIRTUALTABLE */
99891 100301
99892#ifndef SQLITE_OMIT_VIRTUALTABLE 100302#ifndef SQLITE_OMIT_VIRTUALTABLE
100303/* Opcode: VCheck P1 P2 P3 P4 *
100304**
100305** P4 is a pointer to a Table object that is a virtual table in schema P1
100306** that supports the xIntegrity() method. This opcode runs the xIntegrity()
100307** method for that virtual table, using P3 as the integer argument. If
100308** an error is reported back, the table name is prepended to the error
100309** message and that message is stored in P2. If no errors are seen,
100310** register P2 is set to NULL.
100311*/
100312case OP_VCheck: { /* out2 */
100313 Table *pTab;
100314 sqlite3_vtab *pVtab;
100315 const sqlite3_module *pModule;
100316 char *zErr = 0;
100317
100318 pOut = &aMem[pOp->p2];
100319 sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */
100320 assert( pOp->p4type==P4_TABLE );
100321 pTab = pOp->p4.pTab;
100322 assert( pTab!=0 );
100323 assert( IsVirtual(pTab) );
100324 assert( pTab->u.vtab.p!=0 );
100325 pVtab = pTab->u.vtab.p->pVtab;
100326 assert( pVtab!=0 );
100327 pModule = pVtab->pModule;
100328 assert( pModule!=0 );
100329 assert( pModule->iVersion>=4 );
100330 assert( pModule->xIntegrity!=0 );
100331 pTab->nTabRef++;
100332 sqlite3VtabLock(pTab->u.vtab.p);
100333 assert( pOp->p1>=0 && pOp->p1<db->nDb );
100334 rc = pModule->xIntegrity(pVtab, db->aDb[pOp->p1].zDbSName, pTab->zName,
100335 pOp->p3, &zErr);
100336 sqlite3VtabUnlock(pTab->u.vtab.p);
100337 sqlite3DeleteTable(db, pTab);
100338 if( rc ){
100339 sqlite3_free(zErr);
100340 goto abort_due_to_error;
100341 }
100342 if( zErr ){
100343 sqlite3VdbeMemSetStr(pOut, zErr, -1, SQLITE_UTF8, sqlite3_free);
100344 }
100345 break;
100346}
100347#endif /* SQLITE_OMIT_VIRTUALTABLE */
100348
100349#ifndef SQLITE_OMIT_VIRTUALTABLE
99893/* Opcode: VInitIn P1 P2 P3 * * 100350/* Opcode: VInitIn P1 P2 P3 * *
99894** Synopsis: r[P2]=ValueList(P1,P3) 100351** Synopsis: r[P2]=ValueList(P1,P3)
99895** 100352**
@@ -100918,7 +101375,7 @@ SQLITE_API int sqlite3_blob_open(
100918#endif 101375#endif
100919 *ppBlob = 0; 101376 *ppBlob = 0;
100920#ifdef SQLITE_ENABLE_API_ARMOR 101377#ifdef SQLITE_ENABLE_API_ARMOR
100921 if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ 101378 if( !sqlite3SafetyCheckOk(db) || zTable==0 || zColumn==0 ){
100922 return SQLITE_MISUSE_BKPT; 101379 return SQLITE_MISUSE_BKPT;
100923 } 101380 }
100924#endif 101381#endif
@@ -101480,7 +101937,7 @@ struct SorterFile {
101480struct SorterList { 101937struct SorterList {
101481 SorterRecord *pList; /* Linked list of records */ 101938 SorterRecord *pList; /* Linked list of records */
101482 u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ 101939 u8 *aMemory; /* If non-NULL, bulk memory to hold pList */
101483 int szPMA; /* Size of pList as PMA in bytes */ 101940 i64 szPMA; /* Size of pList as PMA in bytes */
101484}; 101941};
101485 101942
101486/* 101943/*
@@ -101589,10 +102046,10 @@ typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);
101589struct SortSubtask { 102046struct SortSubtask {
101590 SQLiteThread *pThread; /* Background thread, if any */ 102047 SQLiteThread *pThread; /* Background thread, if any */
101591 int bDone; /* Set if thread is finished but not joined */ 102048 int bDone; /* Set if thread is finished but not joined */
102049 int nPMA; /* Number of PMAs currently in file */
101592 VdbeSorter *pSorter; /* Sorter that owns this sub-task */ 102050 VdbeSorter *pSorter; /* Sorter that owns this sub-task */
101593 UnpackedRecord *pUnpacked; /* Space to unpack a record */ 102051 UnpackedRecord *pUnpacked; /* Space to unpack a record */
101594 SorterList list; /* List for thread to write to a PMA */ 102052 SorterList list; /* List for thread to write to a PMA */
101595 int nPMA; /* Number of PMAs currently in file */
101596 SorterCompare xCompare; /* Compare function to use */ 102053 SorterCompare xCompare; /* Compare function to use */
101597 SorterFile file; /* Temp file for level-0 PMAs */ 102054 SorterFile file; /* Temp file for level-0 PMAs */
101598 SorterFile file2; /* Space for other PMAs */ 102055 SorterFile file2; /* Space for other PMAs */
@@ -103066,8 +103523,8 @@ SQLITE_PRIVATE int sqlite3VdbeSorterWrite(
103066 int rc = SQLITE_OK; /* Return Code */ 103523 int rc = SQLITE_OK; /* Return Code */
103067 SorterRecord *pNew; /* New list element */ 103524 SorterRecord *pNew; /* New list element */
103068 int bFlush; /* True to flush contents of memory to PMA */ 103525 int bFlush; /* True to flush contents of memory to PMA */
103069 int nReq; /* Bytes of memory required */ 103526 i64 nReq; /* Bytes of memory required */
103070 int nPMA; /* Bytes of PMA space required */ 103527 i64 nPMA; /* Bytes of PMA space required */
103071 int t; /* serial type of first record field */ 103528 int t; /* serial type of first record field */
103072 103529
103073 assert( pCsr->eCurType==CURTYPE_SORTER ); 103530 assert( pCsr->eCurType==CURTYPE_SORTER );
@@ -104491,7 +104948,8 @@ static sqlite3_module bytecodevtabModule = {
104491 /* xSavepoint */ 0, 104948 /* xSavepoint */ 0,
104492 /* xRelease */ 0, 104949 /* xRelease */ 0,
104493 /* xRollbackTo */ 0, 104950 /* xRollbackTo */ 0,
104494 /* xShadowName */ 0 104951 /* xShadowName */ 0,
104952 /* xIntegrity */ 0
104495}; 104953};
104496 104954
104497 104955
@@ -105320,21 +105778,36 @@ static void resolveAlias(
105320} 105778}
105321 105779
105322/* 105780/*
105323** Subqueries stores the original database, table and column names for their 105781** Subqueries store the original database, table and column names for their
105324** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN". 105782** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN",
105325** Check to see if the zSpan given to this routine matches the zDb, zTab, 105783** and mark the expression-list item by setting ExprList.a[].fg.eEName
105326** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will 105784** to ENAME_TAB.
105327** match anything. 105785**
105786** Check to see if the zSpan/eEName of the expression-list item passed to this
105787** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are
105788** NULL then those fields will match anything. Return true if there is a match,
105789** or false otherwise.
105790**
105791** SF_NestedFrom subqueries also store an entry for the implicit rowid (or
105792** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID,
105793** and setting zSpan to "DATABASE.TABLE.<rowid-alias>". This type of pItem
105794** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid)
105795** is set to 1 if there is this kind of match.
105328*/ 105796*/
105329SQLITE_PRIVATE int sqlite3MatchEName( 105797SQLITE_PRIVATE int sqlite3MatchEName(
105330 const struct ExprList_item *pItem, 105798 const struct ExprList_item *pItem,
105331 const char *zCol, 105799 const char *zCol,
105332 const char *zTab, 105800 const char *zTab,
105333 const char *zDb 105801 const char *zDb,
105802 int *pbRowid
105334){ 105803){
105335 int n; 105804 int n;
105336 const char *zSpan; 105805 const char *zSpan;
105337 if( pItem->fg.eEName!=ENAME_TAB ) return 0; 105806 int eEName = pItem->fg.eEName;
105807 if( eEName!=ENAME_TAB && (eEName!=ENAME_ROWID || NEVER(pbRowid==0)) ){
105808 return 0;
105809 }
105810 assert( pbRowid==0 || *pbRowid==0 );
105338 zSpan = pItem->zEName; 105811 zSpan = pItem->zEName;
105339 for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} 105812 for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}
105340 if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ 105813 if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){
@@ -105346,9 +105819,11 @@ SQLITE_PRIVATE int sqlite3MatchEName(
105346 return 0; 105819 return 0;
105347 } 105820 }
105348 zSpan += n+1; 105821 zSpan += n+1;
105349 if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){ 105822 if( zCol ){
105350 return 0; 105823 if( eEName==ENAME_TAB && sqlite3StrICmp(zSpan, zCol)!=0 ) return 0;
105824 if( eEName==ENAME_ROWID && sqlite3IsRowid(zCol)==0 ) return 0;
105351 } 105825 }
105826 if( eEName==ENAME_ROWID ) *pbRowid = 1;
105352 return 1; 105827 return 1;
105353} 105828}
105354 105829
@@ -105481,7 +105956,7 @@ static int lookupName(
105481){ 105956){
105482 int i, j; /* Loop counters */ 105957 int i, j; /* Loop counters */
105483 int cnt = 0; /* Number of matching column names */ 105958 int cnt = 0; /* Number of matching column names */
105484 int cntTab = 0; /* Number of matching table names */ 105959 int cntTab = 0; /* Number of potential "rowid" matches */
105485 int nSubquery = 0; /* How many levels of subquery */ 105960 int nSubquery = 0; /* How many levels of subquery */
105486 sqlite3 *db = pParse->db; /* The database connection */ 105961 sqlite3 *db = pParse->db; /* The database connection */
105487 SrcItem *pItem; /* Use for looping over pSrcList items */ 105962 SrcItem *pItem; /* Use for looping over pSrcList items */
@@ -105558,39 +106033,49 @@ static int lookupName(
105558 assert( pEList!=0 ); 106033 assert( pEList!=0 );
105559 assert( pEList->nExpr==pTab->nCol ); 106034 assert( pEList->nExpr==pTab->nCol );
105560 for(j=0; j<pEList->nExpr; j++){ 106035 for(j=0; j<pEList->nExpr; j++){
105561 if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ 106036 int bRowid = 0; /* True if possible rowid match */
106037 if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb, &bRowid) ){
105562 continue; 106038 continue;
105563 } 106039 }
105564 if( cnt>0 ){ 106040 if( bRowid==0 ){
105565 if( pItem->fg.isUsing==0 106041 if( cnt>0 ){
105566 || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 106042 if( pItem->fg.isUsing==0
105567 ){ 106043 || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0
105568 /* Two or more tables have the same column name which is 106044 ){
105569 ** not joined by USING. This is an error. Signal as much 106045 /* Two or more tables have the same column name which is
105570 ** by clearing pFJMatch and letting cnt go above 1. */ 106046 ** not joined by USING. This is an error. Signal as much
105571 sqlite3ExprListDelete(db, pFJMatch); 106047 ** by clearing pFJMatch and letting cnt go above 1. */
105572 pFJMatch = 0; 106048 sqlite3ExprListDelete(db, pFJMatch);
105573 }else 106049 pFJMatch = 0;
105574 if( (pItem->fg.jointype & JT_RIGHT)==0 ){ 106050 }else
105575 /* An INNER or LEFT JOIN. Use the left-most table */ 106051 if( (pItem->fg.jointype & JT_RIGHT)==0 ){
105576 continue; 106052 /* An INNER or LEFT JOIN. Use the left-most table */
105577 }else 106053 continue;
105578 if( (pItem->fg.jointype & JT_LEFT)==0 ){ 106054 }else
105579 /* A RIGHT JOIN. Use the right-most table */ 106055 if( (pItem->fg.jointype & JT_LEFT)==0 ){
105580 cnt = 0; 106056 /* A RIGHT JOIN. Use the right-most table */
105581 sqlite3ExprListDelete(db, pFJMatch); 106057 cnt = 0;
105582 pFJMatch = 0; 106058 sqlite3ExprListDelete(db, pFJMatch);
105583 }else{ 106059 pFJMatch = 0;
105584 /* For a FULL JOIN, we must construct a coalesce() func */ 106060 }else{
105585 extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); 106061 /* For a FULL JOIN, we must construct a coalesce() func */
106062 extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn);
106063 }
105586 } 106064 }
106065 cnt++;
106066 hit = 1;
106067 }else if( cnt>0 ){
106068 /* This is a potential rowid match, but there has already been
106069 ** a real match found. So this can be ignored. */
106070 continue;
105587 } 106071 }
105588 cnt++; 106072 cntTab++;
105589 cntTab = 2;
105590 pMatch = pItem; 106073 pMatch = pItem;
105591 pExpr->iColumn = j; 106074 pExpr->iColumn = j;
105592 pEList->a[j].fg.bUsed = 1; 106075 pEList->a[j].fg.bUsed = 1;
105593 hit = 1; 106076
106077 /* rowid cannot be part of a USING clause - assert() this. */
106078 assert( bRowid==0 || pEList->a[j].fg.bUsingTerm==0 );
105594 if( pEList->a[j].fg.bUsingTerm ) break; 106079 if( pEList->a[j].fg.bUsingTerm ) break;
105595 } 106080 }
105596 if( hit || zTab==0 ) continue; 106081 if( hit || zTab==0 ) continue;
@@ -105785,10 +106270,10 @@ static int lookupName(
105785 && pMatch 106270 && pMatch
105786 && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 106271 && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
105787 && sqlite3IsRowid(zCol) 106272 && sqlite3IsRowid(zCol)
105788 && ALWAYS(VisibleRowid(pMatch->pTab)) 106273 && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom)
105789 ){ 106274 ){
105790 cnt = 1; 106275 cnt = 1;
105791 pExpr->iColumn = -1; 106276 if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1;
105792 pExpr->affExpr = SQLITE_AFF_INTEGER; 106277 pExpr->affExpr = SQLITE_AFF_INTEGER;
105793 } 106278 }
105794 106279
@@ -106241,6 +106726,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
106241 Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); 106726 Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0);
106242#endif 106727#endif
106243 assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); 106728 assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) );
106729 assert( pExpr->pLeft==0 || pExpr->pLeft->op==TK_ORDER );
106244 zId = pExpr->u.zToken; 106730 zId = pExpr->u.zToken;
106245 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); 106731 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
106246 if( pDef==0 ){ 106732 if( pDef==0 ){
@@ -106382,6 +106868,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
106382 pNC->nNcErr++; 106868 pNC->nNcErr++;
106383 } 106869 }
106384#endif 106870#endif
106871 else if( is_agg==0 && pExpr->pLeft ){
106872 sqlite3ExprOrderByAggregateError(pParse, pExpr);
106873 pNC->nNcErr++;
106874 }
106385 if( is_agg ){ 106875 if( is_agg ){
106386 /* Window functions may not be arguments of aggregate functions. 106876 /* Window functions may not be arguments of aggregate functions.
106387 ** Or arguments of other window functions. But aggregate functions 106877 ** Or arguments of other window functions. But aggregate functions
@@ -106400,6 +106890,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
106400#endif 106890#endif
106401 sqlite3WalkExprList(pWalker, pList); 106891 sqlite3WalkExprList(pWalker, pList);
106402 if( is_agg ){ 106892 if( is_agg ){
106893 if( pExpr->pLeft ){
106894 assert( pExpr->pLeft->op==TK_ORDER );
106895 assert( ExprUseXList(pExpr->pLeft) );
106896 sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList);
106897 }
106403#ifndef SQLITE_OMIT_WINDOWFUNC 106898#ifndef SQLITE_OMIT_WINDOWFUNC
106404 if( pWin ){ 106899 if( pWin ){
106405 Select *pSel = pNC->pWinSelect; 106900 Select *pSel = pNC->pWinSelect;
@@ -106963,10 +107458,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
106963 while( p ){ 107458 while( p ){
106964 assert( (p->selFlags & SF_Expanded)!=0 ); 107459 assert( (p->selFlags & SF_Expanded)!=0 );
106965 assert( (p->selFlags & SF_Resolved)==0 ); 107460 assert( (p->selFlags & SF_Resolved)==0 );
106966 assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */
106967 p->selFlags |= SF_Resolved; 107461 p->selFlags |= SF_Resolved;
106968 107462
106969
106970 /* Resolve the expressions in the LIMIT and OFFSET clauses. These 107463 /* Resolve the expressions in the LIMIT and OFFSET clauses. These
106971 ** are not allowed to refer to any names, so pass an empty NameContext. 107464 ** are not allowed to refer to any names, so pass an empty NameContext.
106972 */ 107465 */
@@ -107972,6 +108465,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
107972 */ 108465 */
107973 pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); 108466 pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);
107974 if( pRet ){ 108467 if( pRet ){
108468 ExprSetProperty(pRet, EP_FullSize);
107975 pRet->iTable = nField; 108469 pRet->iTable = nField;
107976 pRet->iColumn = iField; 108470 pRet->iColumn = iField;
107977 pRet->pLeft = pVector; 108471 pRet->pLeft = pVector;
@@ -108563,6 +109057,69 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction(
108563} 109057}
108564 109058
108565/* 109059/*
109060** Report an error when attempting to use an ORDER BY clause within
109061** the arguments of a non-aggregate function.
109062*/
109063SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){
109064 sqlite3ErrorMsg(pParse,
109065 "ORDER BY may not be used with non-aggregate %#T()", p
109066 );
109067}
109068
109069/*
109070** Attach an ORDER BY clause to a function call.
109071**
109072** functionname( arguments ORDER BY sortlist )
109073** \_____________________/ \______/
109074** pExpr pOrderBy
109075**
109076** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER
109077** and added to the Expr.pLeft field of the parent TK_FUNCTION node.
109078*/
109079SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(
109080 Parse *pParse, /* Parsing context */
109081 Expr *pExpr, /* The function call to which ORDER BY is to be added */
109082 ExprList *pOrderBy /* The ORDER BY clause to add */
109083){
109084 Expr *pOB;
109085 sqlite3 *db = pParse->db;
109086 if( NEVER(pOrderBy==0) ){
109087 assert( db->mallocFailed );
109088 return;
109089 }
109090 if( pExpr==0 ){
109091 assert( db->mallocFailed );
109092 sqlite3ExprListDelete(db, pOrderBy);
109093 return;
109094 }
109095 assert( pExpr->op==TK_FUNCTION );
109096 assert( pExpr->pLeft==0 );
109097 assert( ExprUseXList(pExpr) );
109098 if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){
109099 /* Ignore ORDER BY on zero-argument aggregates */
109100 sqlite3ParserAddCleanup(pParse,
109101 (void(*)(sqlite3*,void*))sqlite3ExprListDelete,
109102 pOrderBy);
109103 return;
109104 }
109105 if( IsWindowFunc(pExpr) ){
109106 sqlite3ExprOrderByAggregateError(pParse, pExpr);
109107 sqlite3ExprListDelete(db, pOrderBy);
109108 return;
109109 }
109110
109111 pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0);
109112 if( pOB==0 ){
109113 sqlite3ExprListDelete(db, pOrderBy);
109114 return;
109115 }
109116 pOB->x.pList = pOrderBy;
109117 assert( ExprUseXList(pOB) );
109118 pExpr->pLeft = pOB;
109119 ExprSetProperty(pOB, EP_FullSize);
109120}
109121
109122/*
108566** Check to see if a function is usable according to current access 109123** Check to see if a function is usable according to current access
108567** rules: 109124** rules:
108568** 109125**
@@ -108815,11 +109372,7 @@ static int dupedExprStructSize(const Expr *p, int flags){
108815 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ 109372 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
108816 assert( EXPR_FULLSIZE<=0xfff ); 109373 assert( EXPR_FULLSIZE<=0xfff );
108817 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); 109374 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
108818 if( 0==flags || p->op==TK_SELECT_COLUMN 109375 if( 0==flags || ExprHasProperty(p, EP_FullSize) ){
108819#ifndef SQLITE_OMIT_WINDOWFUNC
108820 || ExprHasProperty(p, EP_WinFunc)
108821#endif
108822 ){
108823 nSize = EXPR_FULLSIZE; 109376 nSize = EXPR_FULLSIZE;
108824 }else{ 109377 }else{
108825 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); 109378 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
@@ -108850,56 +109403,93 @@ static int dupedExprNodeSize(const Expr *p, int flags){
108850 109403
108851/* 109404/*
108852** Return the number of bytes required to create a duplicate of the 109405** Return the number of bytes required to create a duplicate of the
108853** expression passed as the first argument. The second argument is a 109406** expression passed as the first argument.
108854** mask containing EXPRDUP_XXX flags.
108855** 109407**
108856** The value returned includes space to create a copy of the Expr struct 109408** The value returned includes space to create a copy of the Expr struct
108857** itself and the buffer referred to by Expr.u.zToken, if any. 109409** itself and the buffer referred to by Expr.u.zToken, if any.
108858** 109410**
108859** If the EXPRDUP_REDUCE flag is set, then the return value includes 109411** The return value includes space to duplicate all Expr nodes in the
108860** space to duplicate all Expr nodes in the tree formed by Expr.pLeft 109412** tree formed by Expr.pLeft and Expr.pRight, but not any other
108861** and Expr.pRight variables (but not for any structures pointed to or 109413** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin.
108862** descended from the Expr.x.pList or Expr.x.pSelect variables).
108863*/ 109414*/
108864static int dupedExprSize(const Expr *p, int flags){ 109415static int dupedExprSize(const Expr *p){
108865 int nByte = 0; 109416 int nByte;
108866 if( p ){ 109417 assert( p!=0 );
108867 nByte = dupedExprNodeSize(p, flags); 109418 nByte = dupedExprNodeSize(p, EXPRDUP_REDUCE);
108868 if( flags&EXPRDUP_REDUCE ){ 109419 if( p->pLeft ) nByte += dupedExprSize(p->pLeft);
108869 nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags); 109420 if( p->pRight ) nByte += dupedExprSize(p->pRight);
108870 } 109421 assert( nByte==ROUND8(nByte) );
108871 }
108872 return nByte; 109422 return nByte;
108873} 109423}
108874 109424
108875/* 109425/*
108876** This function is similar to sqlite3ExprDup(), except that if pzBuffer 109426** An EdupBuf is a memory allocation used to stored multiple Expr objects
108877** is not NULL then *pzBuffer is assumed to point to a buffer large enough 109427** together with their Expr.zToken content. This is used to help implement
108878** to store the copy of expression p, the copies of p->u.zToken 109428** compression while doing sqlite3ExprDup(). The top-level Expr does the
108879** (if applicable), and the copies of the p->pLeft and p->pRight expressions, 109429** allocation for itself and many of its decendents, then passes an instance
108880** if any. Before returning, *pzBuffer is set to the first byte past the 109430** of the structure down into exprDup() so that they decendents can have
108881** portion of the buffer copied into by this function. 109431** access to that memory.
108882*/ 109432*/
108883static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ 109433typedef struct EdupBuf EdupBuf;
109434struct EdupBuf {
109435 u8 *zAlloc; /* Memory space available for storage */
109436#ifdef SQLITE_DEBUG
109437 u8 *zEnd; /* First byte past the end of memory */
109438#endif
109439};
109440
109441/*
109442** This function is similar to sqlite3ExprDup(), except that if pEdupBuf
109443** is not NULL then it points to memory that can be used to store a copy
109444** of the input Expr p together with its p->u.zToken (if any). pEdupBuf
109445** is updated with the new buffer tail prior to returning.
109446*/
109447static Expr *exprDup(
109448 sqlite3 *db, /* Database connection (for memory allocation) */
109449 const Expr *p, /* Expr tree to be duplicated */
109450 int dupFlags, /* EXPRDUP_REDUCE for compression. 0 if not */
109451 EdupBuf *pEdupBuf /* Preallocated storage space, or NULL */
109452){
108884 Expr *pNew; /* Value to return */ 109453 Expr *pNew; /* Value to return */
108885 u8 *zAlloc; /* Memory space from which to build Expr object */ 109454 EdupBuf sEdupBuf; /* Memory space from which to build Expr object */
108886 u32 staticFlag; /* EP_Static if space not obtained from malloc */ 109455 u32 staticFlag; /* EP_Static if space not obtained from malloc */
109456 int nToken = -1; /* Space needed for p->u.zToken. -1 means unknown */
108887 109457
108888 assert( db!=0 ); 109458 assert( db!=0 );
108889 assert( p ); 109459 assert( p );
108890 assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); 109460 assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE );
108891 assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE ); 109461 assert( pEdupBuf==0 || dupFlags==EXPRDUP_REDUCE );
108892 109462
108893 /* Figure out where to write the new Expr structure. */ 109463 /* Figure out where to write the new Expr structure. */
108894 if( pzBuffer ){ 109464 if( pEdupBuf ){
108895 zAlloc = *pzBuffer; 109465 sEdupBuf.zAlloc = pEdupBuf->zAlloc;
109466#ifdef SQLITE_DEBUG
109467 sEdupBuf.zEnd = pEdupBuf->zEnd;
109468#endif
108896 staticFlag = EP_Static; 109469 staticFlag = EP_Static;
108897 assert( zAlloc!=0 ); 109470 assert( sEdupBuf.zAlloc!=0 );
109471 assert( dupFlags==EXPRDUP_REDUCE );
108898 }else{ 109472 }else{
108899 zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); 109473 int nAlloc;
109474 if( dupFlags ){
109475 nAlloc = dupedExprSize(p);
109476 }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
109477 nToken = sqlite3Strlen30NN(p->u.zToken)+1;
109478 nAlloc = ROUND8(EXPR_FULLSIZE + nToken);
109479 }else{
109480 nToken = 0;
109481 nAlloc = ROUND8(EXPR_FULLSIZE);
109482 }
109483 assert( nAlloc==ROUND8(nAlloc) );
109484 sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc);
109485#ifdef SQLITE_DEBUG
109486 sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0;
109487#endif
109488
108900 staticFlag = 0; 109489 staticFlag = 0;
108901 } 109490 }
108902 pNew = (Expr *)zAlloc; 109491 pNew = (Expr *)sEdupBuf.zAlloc;
109492 assert( EIGHT_BYTE_ALIGNMENT(pNew) );
108903 109493
108904 if( pNew ){ 109494 if( pNew ){
108905 /* Set nNewSize to the size allocated for the structure pointed to 109495 /* Set nNewSize to the size allocated for the structure pointed to
@@ -108908,22 +109498,27 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){
108908 ** by the copy of the p->u.zToken string (if any). 109498 ** by the copy of the p->u.zToken string (if any).
108909 */ 109499 */
108910 const unsigned nStructSize = dupedExprStructSize(p, dupFlags); 109500 const unsigned nStructSize = dupedExprStructSize(p, dupFlags);
108911 const int nNewSize = nStructSize & 0xfff; 109501 int nNewSize = nStructSize & 0xfff;
108912 int nToken; 109502 if( nToken<0 ){
108913 if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ 109503 if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
108914 nToken = sqlite3Strlen30(p->u.zToken) + 1; 109504 nToken = sqlite3Strlen30(p->u.zToken) + 1;
108915 }else{ 109505 }else{
108916 nToken = 0; 109506 nToken = 0;
109507 }
108917 } 109508 }
108918 if( dupFlags ){ 109509 if( dupFlags ){
109510 assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= nNewSize+nToken );
108919 assert( ExprHasProperty(p, EP_Reduced)==0 ); 109511 assert( ExprHasProperty(p, EP_Reduced)==0 );
108920 memcpy(zAlloc, p, nNewSize); 109512 memcpy(sEdupBuf.zAlloc, p, nNewSize);
108921 }else{ 109513 }else{
108922 u32 nSize = (u32)exprStructSize(p); 109514 u32 nSize = (u32)exprStructSize(p);
108923 memcpy(zAlloc, p, nSize); 109515 assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >=
109516 (int)EXPR_FULLSIZE+nToken );
109517 memcpy(sEdupBuf.zAlloc, p, nSize);
108924 if( nSize<EXPR_FULLSIZE ){ 109518 if( nSize<EXPR_FULLSIZE ){
108925 memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); 109519 memset(&sEdupBuf.zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
108926 } 109520 }
109521 nNewSize = EXPR_FULLSIZE;
108927 } 109522 }
108928 109523
108929 /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ 109524 /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */
@@ -108936,44 +109531,50 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){
108936 } 109531 }
108937 109532
108938 /* Copy the p->u.zToken string, if any. */ 109533 /* Copy the p->u.zToken string, if any. */
108939 if( nToken ){ 109534 assert( nToken>=0 );
108940 char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; 109535 if( nToken>0 ){
109536 char *zToken = pNew->u.zToken = (char*)&sEdupBuf.zAlloc[nNewSize];
108941 memcpy(zToken, p->u.zToken, nToken); 109537 memcpy(zToken, p->u.zToken, nToken);
109538 nNewSize += nToken;
108942 } 109539 }
109540 sEdupBuf.zAlloc += ROUND8(nNewSize);
109541
109542 if( ((p->flags|pNew->flags)&(EP_TokenOnly|EP_Leaf))==0 ){
108943 109543
108944 if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){
108945 /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ 109544 /* Fill in the pNew->x.pSelect or pNew->x.pList member. */
108946 if( ExprUseXSelect(p) ){ 109545 if( ExprUseXSelect(p) ){
108947 pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); 109546 pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);
108948 }else{ 109547 }else{
108949 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); 109548 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList,
109549 p->op!=TK_ORDER ? dupFlags : 0);
108950 } 109550 }
108951 }
108952 109551
108953 /* Fill in pNew->pLeft and pNew->pRight. */
108954 if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){
108955 zAlloc += dupedExprNodeSize(p, dupFlags);
108956 if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
108957 pNew->pLeft = p->pLeft ?
108958 exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
108959 pNew->pRight = p->pRight ?
108960 exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
108961 }
108962#ifndef SQLITE_OMIT_WINDOWFUNC 109552#ifndef SQLITE_OMIT_WINDOWFUNC
108963 if( ExprHasProperty(p, EP_WinFunc) ){ 109553 if( ExprHasProperty(p, EP_WinFunc) ){
108964 pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); 109554 pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);
108965 assert( ExprHasProperty(pNew, EP_WinFunc) ); 109555 assert( ExprHasProperty(pNew, EP_WinFunc) );
108966 } 109556 }
108967#endif /* SQLITE_OMIT_WINDOWFUNC */ 109557#endif /* SQLITE_OMIT_WINDOWFUNC */
108968 if( pzBuffer ){ 109558
108969 *pzBuffer = zAlloc; 109559 /* Fill in pNew->pLeft and pNew->pRight. */
108970 } 109560 if( dupFlags ){
108971 }else{ 109561 if( p->op==TK_SELECT_COLUMN ){
108972 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
108973 if( pNew->op==TK_SELECT_COLUMN ){
108974 pNew->pLeft = p->pLeft; 109562 pNew->pLeft = p->pLeft;
108975 assert( p->pRight==0 || p->pRight==p->pLeft 109563 assert( p->pRight==0
108976 || ExprHasProperty(p->pLeft, EP_Subquery) ); 109564 || p->pRight==p->pLeft
109565 || ExprHasProperty(p->pLeft, EP_Subquery) );
109566 }else{
109567 pNew->pLeft = p->pLeft ?
109568 exprDup(db, p->pLeft, EXPRDUP_REDUCE, &sEdupBuf) : 0;
109569 }
109570 pNew->pRight = p->pRight ?
109571 exprDup(db, p->pRight, EXPRDUP_REDUCE, &sEdupBuf) : 0;
109572 }else{
109573 if( p->op==TK_SELECT_COLUMN ){
109574 pNew->pLeft = p->pLeft;
109575 assert( p->pRight==0
109576 || p->pRight==p->pLeft
109577 || ExprHasProperty(p->pLeft, EP_Subquery) );
108977 }else{ 109578 }else{
108978 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); 109579 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
108979 } 109580 }
@@ -108981,6 +109582,8 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){
108981 } 109582 }
108982 } 109583 }
108983 } 109584 }
109585 if( pEdupBuf ) memcpy(pEdupBuf, &sEdupBuf, sizeof(sEdupBuf));
109586 assert( sEdupBuf.zAlloc <= sEdupBuf.zEnd );
108984 return pNew; 109587 return pNew;
108985} 109588}
108986 109589
@@ -109245,11 +109848,7 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *p, int flags)
109245** initially NULL, then create a new expression list. 109848** initially NULL, then create a new expression list.
109246** 109849**
109247** The pList argument must be either NULL or a pointer to an ExprList 109850** The pList argument must be either NULL or a pointer to an ExprList
109248** obtained from a prior call to sqlite3ExprListAppend(). This routine 109851** obtained from a prior call to sqlite3ExprListAppend().
109249** may not be used with an ExprList obtained from sqlite3ExprListDup().
109250** Reason: This routine assumes that the number of slots in pList->a[]
109251** is a power of two. That is true for sqlite3ExprListAppend() returns
109252** but is not necessarily true from the return value of sqlite3ExprListDup().
109253** 109852**
109254** If a memory allocation error occurs, the entire list is freed and 109853** If a memory allocation error occurs, the entire list is freed and
109255** NULL is returned. If non-NULL is returned, then it is guaranteed 109854** NULL is returned. If non-NULL is returned, then it is guaranteed
@@ -110076,6 +110675,27 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){
110076} 110675}
110077 110676
110078/* 110677/*
110678** Return a pointer to a buffer containing a usable rowid alias for table
110679** pTab. An alias is usable if there is not an explicit user-defined column
110680** of the same name.
110681*/
110682SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){
110683 const char *azOpt[] = {"_ROWID_", "ROWID", "OID"};
110684 int ii;
110685 assert( VisibleRowid(pTab) );
110686 for(ii=0; ii<ArraySize(azOpt); ii++){
110687 int iCol;
110688 for(iCol=0; iCol<pTab->nCol; iCol++){
110689 if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break;
110690 }
110691 if( iCol==pTab->nCol ){
110692 return azOpt[ii];
110693 }
110694 }
110695 return 0;
110696}
110697
110698/*
110079** pX is the RHS of an IN operator. If pX is a SELECT statement 110699** pX is the RHS of an IN operator. If pX is a SELECT statement
110080** that can be simplified to a direct table access, then return 110700** that can be simplified to a direct table access, then return
110081** a pointer to the SELECT statement. If pX is not a SELECT statement, 110701** a pointer to the SELECT statement. If pX is not a SELECT statement,
@@ -111613,6 +112233,41 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
111613 112233
111614 112234
111615/* 112235/*
112236** Expresion pExpr is guaranteed to be a TK_COLUMN or equivalent. This
112237** function checks the Parse.pIdxPartExpr list to see if this column
112238** can be replaced with a constant value. If so, it generates code to
112239** put the constant value in a register (ideally, but not necessarily,
112240** register iTarget) and returns the register number.
112241**
112242** Or, if the TK_COLUMN cannot be replaced by a constant, zero is
112243** returned.
112244*/
112245static int exprPartidxExprLookup(Parse *pParse, Expr *pExpr, int iTarget){
112246 IndexedExpr *p;
112247 for(p=pParse->pIdxPartExpr; p; p=p->pIENext){
112248 if( pExpr->iColumn==p->iIdxCol && pExpr->iTable==p->iDataCur ){
112249 Vdbe *v = pParse->pVdbe;
112250 int addr = 0;
112251 int ret;
112252
112253 if( p->bMaybeNullRow ){
112254 addr = sqlite3VdbeAddOp1(v, OP_IfNullRow, p->iIdxCur);
112255 }
112256 ret = sqlite3ExprCodeTarget(pParse, p->pExpr, iTarget);
112257 sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, ret, 1, 0,
112258 (const char*)&p->aff, 1);
112259 if( addr ){
112260 sqlite3VdbeJumpHere(v, addr);
112261 sqlite3VdbeChangeP3(v, addr, ret);
112262 }
112263 return ret;
112264 }
112265 }
112266 return 0;
112267}
112268
112269
112270/*
111616** Generate code into the current Vdbe to evaluate the given 112271** Generate code into the current Vdbe to evaluate the given
111617** expression. Attempt to store the results in register "target". 112272** expression. Attempt to store the results in register "target".
111618** Return the register where results are stored. 112273** Return the register where results are stored.
@@ -111648,6 +112303,7 @@ expr_code_doover:
111648 assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); 112303 assert( !ExprHasVVAProperty(pExpr,EP_Immutable) );
111649 op = pExpr->op; 112304 op = pExpr->op;
111650 } 112305 }
112306 assert( op!=TK_ORDER );
111651 switch( op ){ 112307 switch( op ){
111652 case TK_AGG_COLUMN: { 112308 case TK_AGG_COLUMN: {
111653 AggInfo *pAggInfo = pExpr->pAggInfo; 112309 AggInfo *pAggInfo = pExpr->pAggInfo;
@@ -111661,7 +112317,7 @@ expr_code_doover:
111661#ifdef SQLITE_VDBE_COVERAGE 112317#ifdef SQLITE_VDBE_COVERAGE
111662 /* Verify that the OP_Null above is exercised by tests 112318 /* Verify that the OP_Null above is exercised by tests
111663 ** tag-20230325-2 */ 112319 ** tag-20230325-2 */
111664 sqlite3VdbeAddOp2(v, OP_NotNull, target, 1); 112320 sqlite3VdbeAddOp3(v, OP_NotNull, target, 1, 20230325);
111665 VdbeCoverageNeverTaken(v); 112321 VdbeCoverageNeverTaken(v);
111666#endif 112322#endif
111667 break; 112323 break;
@@ -111769,6 +112425,11 @@ expr_code_doover:
111769 iTab = pParse->iSelfTab - 1; 112425 iTab = pParse->iSelfTab - 1;
111770 } 112426 }
111771 } 112427 }
112428 else if( pParse->pIdxPartExpr
112429 && 0!=(r1 = exprPartidxExprLookup(pParse, pExpr, target))
112430 ){
112431 return r1;
112432 }
111772 assert( ExprUseYTab(pExpr) ); 112433 assert( ExprUseYTab(pExpr) );
111773 assert( pExpr->y.pTab!=0 ); 112434 assert( pExpr->y.pTab!=0 );
111774 iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, 112435 iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
@@ -112429,7 +113090,7 @@ expr_code_doover:
112429** once. If no functions are involved, then factor the code out and put it at 113090** once. If no functions are involved, then factor the code out and put it at
112430** the end of the prepared statement in the initialization section. 113091** the end of the prepared statement in the initialization section.
112431** 113092**
112432** If regDest>=0 then the result is always stored in that register and the 113093** If regDest>0 then the result is always stored in that register and the
112433** result is not reusable. If regDest<0 then this routine is free to 113094** result is not reusable. If regDest<0 then this routine is free to
112434** store the value wherever it wants. The register where the expression 113095** store the value wherever it wants. The register where the expression
112435** is stored is returned. When regDest<0, two identical expressions might 113096** is stored is returned. When regDest<0, two identical expressions might
@@ -112444,6 +113105,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(
112444){ 113105){
112445 ExprList *p; 113106 ExprList *p;
112446 assert( ConstFactorOk(pParse) ); 113107 assert( ConstFactorOk(pParse) );
113108 assert( regDest!=0 );
112447 p = pParse->pConstExpr; 113109 p = pParse->pConstExpr;
112448 if( regDest<0 && p ){ 113110 if( regDest<0 && p ){
112449 struct ExprList_item *pItem; 113111 struct ExprList_item *pItem;
@@ -113728,6 +114390,12 @@ SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList
113728 assert( pExpr->op==TK_AGG_FUNCTION ); 114390 assert( pExpr->op==TK_AGG_FUNCTION );
113729 assert( ExprUseXList(pExpr) ); 114391 assert( ExprUseXList(pExpr) );
113730 sqlite3WalkExprList(&w, pExpr->x.pList); 114392 sqlite3WalkExprList(&w, pExpr->x.pList);
114393 if( pExpr->pLeft ){
114394 assert( pExpr->pLeft->op==TK_ORDER );
114395 assert( ExprUseXList(pExpr->pLeft) );
114396 assert( pExpr->pLeft->x.pList!=0 );
114397 sqlite3WalkExprList(&w, pExpr->pLeft->x.pList);
114398 }
113731#ifndef SQLITE_OMIT_WINDOWFUNC 114399#ifndef SQLITE_OMIT_WINDOWFUNC
113732 if( ExprHasProperty(pExpr, EP_WinFunc) ){ 114400 if( ExprHasProperty(pExpr, EP_WinFunc) ){
113733 sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); 114401 sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter);
@@ -113992,14 +114660,42 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
113992 u8 enc = ENC(pParse->db); 114660 u8 enc = ENC(pParse->db);
113993 i = addAggInfoFunc(pParse->db, pAggInfo); 114661 i = addAggInfoFunc(pParse->db, pAggInfo);
113994 if( i>=0 ){ 114662 if( i>=0 ){
114663 int nArg;
113995 assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); 114664 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
113996 pItem = &pAggInfo->aFunc[i]; 114665 pItem = &pAggInfo->aFunc[i];
113997 pItem->pFExpr = pExpr; 114666 pItem->pFExpr = pExpr;
113998 assert( ExprUseUToken(pExpr) ); 114667 assert( ExprUseUToken(pExpr) );
114668 nArg = pExpr->x.pList ? pExpr->x.pList->nExpr : 0;
113999 pItem->pFunc = sqlite3FindFunction(pParse->db, 114669 pItem->pFunc = sqlite3FindFunction(pParse->db,
114000 pExpr->u.zToken, 114670 pExpr->u.zToken, nArg, enc, 0);
114001 pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); 114671 assert( pItem->bOBUnique==0 );
114002 if( pExpr->flags & EP_Distinct ){ 114672 if( pExpr->pLeft
114673 && (pItem->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)==0
114674 ){
114675 /* The NEEDCOLL test above causes any ORDER BY clause on
114676 ** aggregate min() or max() to be ignored. */
114677 ExprList *pOBList;
114678 assert( nArg>0 );
114679 assert( pExpr->pLeft->op==TK_ORDER );
114680 assert( ExprUseXList(pExpr->pLeft) );
114681 pItem->iOBTab = pParse->nTab++;
114682 pOBList = pExpr->pLeft->x.pList;
114683 assert( pOBList->nExpr>0 );
114684 assert( pItem->bOBUnique==0 );
114685 if( pOBList->nExpr==1
114686 && nArg==1
114687 && sqlite3ExprCompare(0,pOBList->a[0].pExpr,
114688 pExpr->x.pList->a[0].pExpr,0)==0
114689 ){
114690 pItem->bOBPayload = 0;
114691 pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct);
114692 }else{
114693 pItem->bOBPayload = 1;
114694 }
114695 }else{
114696 pItem->iOBTab = -1;
114697 }
114698 if( ExprHasProperty(pExpr, EP_Distinct) && !pItem->bOBUnique ){
114003 pItem->iDistinct = pParse->nTab++; 114699 pItem->iDistinct = pParse->nTab++;
114004 }else{ 114700 }else{
114005 pItem->iDistinct = -1; 114701 pItem->iDistinct = -1;
@@ -114635,14 +115331,19 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
114635 /* Verify that constraints are still satisfied */ 115331 /* Verify that constraints are still satisfied */
114636 if( pNew->pCheck!=0 115332 if( pNew->pCheck!=0
114637 || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) 115333 || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0)
115334 || (pTab->tabFlags & TF_Strict)!=0
114638 ){ 115335 ){
114639 sqlite3NestedParse(pParse, 115336 sqlite3NestedParse(pParse,
114640 "SELECT CASE WHEN quick_check GLOB 'CHECK*'" 115337 "SELECT CASE WHEN quick_check GLOB 'CHECK*'"
114641 " THEN raise(ABORT,'CHECK constraint failed')" 115338 " THEN raise(ABORT,'CHECK constraint failed')"
115339 " WHEN quick_check GLOB 'non-* value in*'"
115340 " THEN raise(ABORT,'type mismatch on DEFAULT')"
114642 " ELSE raise(ABORT,'NOT NULL constraint failed')" 115341 " ELSE raise(ABORT,'NOT NULL constraint failed')"
114643 " END" 115342 " END"
114644 " FROM pragma_quick_check(%Q,%Q)" 115343 " FROM pragma_quick_check(%Q,%Q)"
114645 " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", 115344 " WHERE quick_check GLOB 'CHECK*'"
115345 " OR quick_check GLOB 'NULL*'"
115346 " OR quick_check GLOB 'non-* value in*'",
114646 zTab, zDb 115347 zTab, zDb
114647 ); 115348 );
114648 } 115349 }
@@ -119621,19 +120322,14 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
119621 */ 120322 */
119622 if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); 120323 if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse);
119623 120324
119624 /* Code constant expressions that where factored out of inner loops. 120325 /* Code constant expressions that were factored out of inner loops.
119625 **
119626 ** The pConstExpr list might also contain expressions that we simply
119627 ** want to keep around until the Parse object is deleted. Such
119628 ** expressions have iConstExprReg==0. Do not generate code for
119629 ** those expressions, of course.
119630 */ 120326 */
119631 if( pParse->pConstExpr ){ 120327 if( pParse->pConstExpr ){
119632 ExprList *pEL = pParse->pConstExpr; 120328 ExprList *pEL = pParse->pConstExpr;
119633 pParse->okConstFactor = 0; 120329 pParse->okConstFactor = 0;
119634 for(i=0; i<pEL->nExpr; i++){ 120330 for(i=0; i<pEL->nExpr; i++){
119635 int iReg = pEL->a[i].u.iConstExprReg; 120331 assert( pEL->a[i].u.iConstExprReg>0 );
119636 sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg); 120332 sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
119637 } 120333 }
119638 } 120334 }
119639 120335
@@ -120788,19 +121484,12 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
120788#endif 121484#endif
120789 121485
120790/* 121486/*
120791** Name of the special TEMP trigger used to implement RETURNING. The
120792** name begins with "sqlite_" so that it is guaranteed not to collide
120793** with any application-generated triggers.
120794*/
120795#define RETURNING_TRIGGER_NAME "sqlite_returning"
120796
120797/*
120798** Clean up the data structures associated with the RETURNING clause. 121487** Clean up the data structures associated with the RETURNING clause.
120799*/ 121488*/
120800static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ 121489static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){
120801 Hash *pHash; 121490 Hash *pHash;
120802 pHash = &(db->aDb[1].pSchema->trigHash); 121491 pHash = &(db->aDb[1].pSchema->trigHash);
120803 sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, 0); 121492 sqlite3HashInsert(pHash, pRet->zName, 0);
120804 sqlite3ExprListDelete(db, pRet->pReturnEL); 121493 sqlite3ExprListDelete(db, pRet->pReturnEL);
120805 sqlite3DbFree(db, pRet); 121494 sqlite3DbFree(db, pRet);
120806} 121495}
@@ -120843,7 +121532,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){
120843 (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); 121532 (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet);
120844 testcase( pParse->earlyCleanup ); 121533 testcase( pParse->earlyCleanup );
120845 if( db->mallocFailed ) return; 121534 if( db->mallocFailed ) return;
120846 pRet->retTrig.zName = RETURNING_TRIGGER_NAME; 121535 sqlite3_snprintf(sizeof(pRet->zName), pRet->zName,
121536 "sqlite_returning_%p", pParse);
121537 pRet->retTrig.zName = pRet->zName;
120847 pRet->retTrig.op = TK_RETURNING; 121538 pRet->retTrig.op = TK_RETURNING;
120848 pRet->retTrig.tr_tm = TRIGGER_AFTER; 121539 pRet->retTrig.tr_tm = TRIGGER_AFTER;
120849 pRet->retTrig.bReturning = 1; 121540 pRet->retTrig.bReturning = 1;
@@ -120854,9 +121545,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){
120854 pRet->retTStep.pTrig = &pRet->retTrig; 121545 pRet->retTStep.pTrig = &pRet->retTrig;
120855 pRet->retTStep.pExprList = pList; 121546 pRet->retTStep.pExprList = pList;
120856 pHash = &(db->aDb[1].pSchema->trigHash); 121547 pHash = &(db->aDb[1].pSchema->trigHash);
120857 assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0 121548 assert( sqlite3HashFind(pHash, pRet->zName)==0
120858 || pParse->nErr || pParse->ifNotExists ); 121549 || pParse->nErr || pParse->ifNotExists );
120859 if( sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, &pRet->retTrig) 121550 if( sqlite3HashInsert(pHash, pRet->zName, &pRet->retTrig)
120860 ==&pRet->retTrig ){ 121551 ==&pRet->retTrig ){
120861 sqlite3OomFault(db); 121552 sqlite3OomFault(db);
120862 } 121553 }
@@ -122300,6 +122991,17 @@ SQLITE_PRIVATE void sqlite3EndTable(
122300 /* Reparse everything to update our internal data structures */ 122991 /* Reparse everything to update our internal data structures */
122301 sqlite3VdbeAddParseSchemaOp(v, iDb, 122992 sqlite3VdbeAddParseSchemaOp(v, iDb,
122302 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); 122993 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0);
122994
122995 /* Test for cycles in generated columns and illegal expressions
122996 ** in CHECK constraints and in DEFAULT clauses. */
122997 if( p->tabFlags & TF_HasGenerated ){
122998 sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0,
122999 sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"",
123000 db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
123001 }
123002 sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0,
123003 sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)",
123004 db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
122303 } 123005 }
122304 123006
122305 /* Add the table to the in-memory representation of the database. 123007 /* Add the table to the in-memory representation of the database.
@@ -127902,7 +128604,8 @@ static void hexFunc(
127902 *(z++) = hexdigits[c&0xf]; 128604 *(z++) = hexdigits[c&0xf];
127903 } 128605 }
127904 *z = 0; 128606 *z = 0;
127905 sqlite3_result_text(context, zHex, n*2, sqlite3_free); 128607 sqlite3_result_text64(context, zHex, (u64)(z-zHex),
128608 sqlite3_free, SQLITE_UTF8);
127906 } 128609 }
127907} 128610}
127908 128611
@@ -128196,6 +128899,81 @@ static void trimFunc(
128196 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); 128899 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
128197} 128900}
128198 128901
128902/* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...)
128903** functions.
128904**
128905** Return a string value that is the concatenation of all non-null
128906** entries in argv[]. Use zSep as the separator.
128907*/
128908static void concatFuncCore(
128909 sqlite3_context *context,
128910 int argc,
128911 sqlite3_value **argv,
128912 int nSep,
128913 const char *zSep
128914){
128915 i64 j, k, n = 0;
128916 int i;
128917 char *z;
128918 for(i=0; i<argc; i++){
128919 n += sqlite3_value_bytes(argv[i]);
128920 }
128921 n += (argc-1)*nSep;
128922 z = sqlite3_malloc64(n+1);
128923 if( z==0 ){
128924 sqlite3_result_error_nomem(context);
128925 return;
128926 }
128927 j = 0;
128928 for(i=0; i<argc; i++){
128929 k = sqlite3_value_bytes(argv[i]);
128930 if( k>0 ){
128931 const char *v = (const char*)sqlite3_value_text(argv[i]);
128932 if( v!=0 ){
128933 if( j>0 && nSep>0 ){
128934 memcpy(&z[j], zSep, nSep);
128935 j += nSep;
128936 }
128937 memcpy(&z[j], v, k);
128938 j += k;
128939 }
128940 }
128941 }
128942 z[j] = 0;
128943 assert( j<=n );
128944 sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8);
128945}
128946
128947/*
128948** The CONCAT(...) function. Generate a string result that is the
128949** concatentation of all non-null arguments.
128950*/
128951static void concatFunc(
128952 sqlite3_context *context,
128953 int argc,
128954 sqlite3_value **argv
128955){
128956 concatFuncCore(context, argc, argv, 0, "");
128957}
128958
128959/*
128960** The CONCAT_WS(separator, ...) function.
128961**
128962** Generate a string that is the concatenation of 2nd through the Nth
128963** argument. Use the first argument (which must be non-NULL) as the
128964** separator.
128965*/
128966static void concatwsFunc(
128967 sqlite3_context *context,
128968 int argc,
128969 sqlite3_value **argv
128970){
128971 int nSep = sqlite3_value_bytes(argv[0]);
128972 const char *zSep = (const char*)sqlite3_value_text(argv[0]);
128973 if( zSep==0 ) return;
128974 concatFuncCore(context, argc-1, argv+1, nSep, zSep);
128975}
128976
128199 128977
128200#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION 128978#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
128201/* 128979/*
@@ -128617,6 +129395,7 @@ static void minMaxFinalize(sqlite3_context *context){
128617 129395
128618/* 129396/*
128619** group_concat(EXPR, ?SEPARATOR?) 129397** group_concat(EXPR, ?SEPARATOR?)
129398** string_agg(EXPR, SEPARATOR)
128620** 129399**
128621** The SEPARATOR goes before the EXPR string. This is tragic. The 129400** The SEPARATOR goes before the EXPR string. This is tragic. The
128622** groupConcatInverse() implementation would have been easier if the 129401** groupConcatInverse() implementation would have been easier if the
@@ -129207,6 +129986,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
129207 FUNCTION(hex, 1, 0, 0, hexFunc ), 129986 FUNCTION(hex, 1, 0, 0, hexFunc ),
129208 FUNCTION(unhex, 1, 0, 0, unhexFunc ), 129987 FUNCTION(unhex, 1, 0, 0, unhexFunc ),
129209 FUNCTION(unhex, 2, 0, 0, unhexFunc ), 129988 FUNCTION(unhex, 2, 0, 0, unhexFunc ),
129989 FUNCTION(concat, -1, 0, 0, concatFunc ),
129990 FUNCTION(concat, 0, 0, 0, 0 ),
129991 FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ),
129992 FUNCTION(concat_ws, 0, 0, 0, 0 ),
129993 FUNCTION(concat_ws, 1, 0, 0, 0 ),
129210 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), 129994 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
129211 VFUNCTION(random, 0, 0, 0, randomFunc ), 129995 VFUNCTION(random, 0, 0, 0, randomFunc ),
129212 VFUNCTION(randomblob, 1, 0, 0, randomBlob ), 129996 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
@@ -129236,6 +130020,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
129236 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), 130020 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
129237 WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, 130021 WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
129238 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), 130022 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
130023 WAGGREGATE(string_agg, 2, 0, 0, groupConcatStep,
130024 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
129239 130025
129240 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), 130026 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
129241#ifdef SQLITE_CASE_SENSITIVE_LIKE 130027#ifdef SQLITE_CASE_SENSITIVE_LIKE
@@ -130178,6 +130964,7 @@ static int isSetNullAction(Parse *pParse, FKey *pFKey){
130178 if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) 130964 if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull)
130179 || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) 130965 || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull)
130180 ){ 130966 ){
130967 assert( (pTop->db->flags & SQLITE_FkNoAction)==0 );
130181 return 1; 130968 return 1;
130182 } 130969 }
130183 } 130970 }
@@ -130372,6 +131159,8 @@ SQLITE_PRIVATE void sqlite3FkCheck(
130372 } 131159 }
130373 if( regOld!=0 ){ 131160 if( regOld!=0 ){
130374 int eAction = pFKey->aAction[aChange!=0]; 131161 int eAction = pFKey->aAction[aChange!=0];
131162 if( (db->flags & SQLITE_FkNoAction) ) eAction = OE_None;
131163
130375 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); 131164 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
130376 /* If this is a deferred FK constraint, or a CASCADE or SET NULL 131165 /* If this is a deferred FK constraint, or a CASCADE or SET NULL
130377 ** action applies, then any foreign key violations caused by 131166 ** action applies, then any foreign key violations caused by
@@ -130487,7 +131276,11 @@ SQLITE_PRIVATE int sqlite3FkRequired(
130487 /* Check if any parent key columns are being modified. */ 131276 /* Check if any parent key columns are being modified. */
130488 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ 131277 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
130489 if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ 131278 if( fkParentIsModified(pTab, p, aChange, chngRowid) ){
130490 if( p->aAction[1]!=OE_None ) return 2; 131279 if( (pParse->db->flags & SQLITE_FkNoAction)==0
131280 && p->aAction[1]!=OE_None
131281 ){
131282 return 2;
131283 }
130491 bHaveFK = 1; 131284 bHaveFK = 1;
130492 } 131285 }
130493 } 131286 }
@@ -130537,6 +131330,7 @@ static Trigger *fkActionTrigger(
130537 int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ 131330 int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */
130538 131331
130539 action = pFKey->aAction[iAction]; 131332 action = pFKey->aAction[iAction];
131333 if( (db->flags & SQLITE_FkNoAction) ) action = OE_None;
130540 if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ 131334 if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){
130541 return 0; 131335 return 0;
130542 } 131336 }
@@ -134492,6 +135286,9 @@ struct sqlite3_api_routines {
134492 int (*is_interrupted)(sqlite3*); 135286 int (*is_interrupted)(sqlite3*);
134493 /* Version 3.43.0 and later */ 135287 /* Version 3.43.0 and later */
134494 int (*stmt_explain)(sqlite3_stmt*,int); 135288 int (*stmt_explain)(sqlite3_stmt*,int);
135289 /* Version 3.44.0 and later */
135290 void *(*get_clientdata)(sqlite3*,const char*);
135291 int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
134495}; 135292};
134496 135293
134497/* 135294/*
@@ -134822,6 +135619,9 @@ typedef int (*sqlite3_loadext_entry)(
134822#define sqlite3_is_interrupted sqlite3_api->is_interrupted 135619#define sqlite3_is_interrupted sqlite3_api->is_interrupted
134823/* Version 3.43.0 and later */ 135620/* Version 3.43.0 and later */
134824#define sqlite3_stmt_explain sqlite3_api->stmt_explain 135621#define sqlite3_stmt_explain sqlite3_api->stmt_explain
135622/* Version 3.44.0 and later */
135623#define sqlite3_get_clientdata sqlite3_api->get_clientdata
135624#define sqlite3_set_clientdata sqlite3_api->set_clientdata
134825#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ 135625#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
134826 135626
134827#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) 135627#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
@@ -135340,7 +136140,10 @@ static const sqlite3_api_routines sqlite3Apis = {
135340 /* Version 3.41.0 and later */ 136140 /* Version 3.41.0 and later */
135341 sqlite3_is_interrupted, 136141 sqlite3_is_interrupted,
135342 /* Version 3.43.0 and later */ 136142 /* Version 3.43.0 and later */
135343 sqlite3_stmt_explain 136143 sqlite3_stmt_explain,
136144 /* Version 3.44.0 and later */
136145 sqlite3_get_clientdata,
136146 sqlite3_set_clientdata
135344}; 136147};
135345 136148
135346/* True if x is the directory separator character 136149/* True if x is the directory separator character
@@ -135556,6 +136359,9 @@ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){
135556** default so as not to open security holes in older applications. 136359** default so as not to open security holes in older applications.
135557*/ 136360*/
135558SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ 136361SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
136362#ifdef SQLITE_ENABLE_API_ARMOR
136363 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
136364#endif
135559 sqlite3_mutex_enter(db->mutex); 136365 sqlite3_mutex_enter(db->mutex);
135560 if( onoff ){ 136366 if( onoff ){
135561 db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; 136367 db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;
@@ -135605,6 +136411,9 @@ SQLITE_API int sqlite3_auto_extension(
135605 void (*xInit)(void) 136411 void (*xInit)(void)
135606){ 136412){
135607 int rc = SQLITE_OK; 136413 int rc = SQLITE_OK;
136414#ifdef SQLITE_ENABLE_API_ARMOR
136415 if( xInit==0 ) return SQLITE_MISUSE_BKPT;
136416#endif
135608#ifndef SQLITE_OMIT_AUTOINIT 136417#ifndef SQLITE_OMIT_AUTOINIT
135609 rc = sqlite3_initialize(); 136418 rc = sqlite3_initialize();
135610 if( rc ){ 136419 if( rc ){
@@ -135657,6 +136466,9 @@ SQLITE_API int sqlite3_cancel_auto_extension(
135657 int i; 136466 int i;
135658 int n = 0; 136467 int n = 0;
135659 wsdAutoextInit; 136468 wsdAutoextInit;
136469#ifdef SQLITE_ENABLE_API_ARMOR
136470 if( xInit==0 ) return 0;
136471#endif
135660 sqlite3_mutex_enter(mutex); 136472 sqlite3_mutex_enter(mutex);
135661 for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ 136473 for(i=(int)wsdAutoext.nExt-1; i>=0; i--){
135662 if( wsdAutoext.aExt[i]==xInit ){ 136474 if( wsdAutoext.aExt[i]==xInit ){
@@ -137526,7 +138338,11 @@ SQLITE_PRIVATE void sqlite3Pragma(
137526#endif 138338#endif
137527 138339
137528 if( sqlite3GetBoolean(zRight, 0) ){ 138340 if( sqlite3GetBoolean(zRight, 0) ){
137529 db->flags |= mask; 138341 if( (mask & SQLITE_WriteSchema)==0
138342 || (db->flags & SQLITE_Defensive)==0
138343 ){
138344 db->flags |= mask;
138345 }
137530 }else{ 138346 }else{
137531 db->flags &= ~mask; 138347 db->flags &= ~mask;
137532 if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; 138348 if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;
@@ -138159,8 +138975,31 @@ SQLITE_PRIVATE void sqlite3Pragma(
138159 int r2; /* Previous key for WITHOUT ROWID tables */ 138975 int r2; /* Previous key for WITHOUT ROWID tables */
138160 int mxCol; /* Maximum non-virtual column number */ 138976 int mxCol; /* Maximum non-virtual column number */
138161 138977
138162 if( !IsOrdinaryTable(pTab) ) continue;
138163 if( pObjTab && pObjTab!=pTab ) continue; 138978 if( pObjTab && pObjTab!=pTab ) continue;
138979 if( !IsOrdinaryTable(pTab) ){
138980#ifndef SQLITE_OMIT_VIRTUALTABLE
138981 sqlite3_vtab *pVTab;
138982 int a1;
138983 if( !IsVirtual(pTab) ) continue;
138984 if( pTab->nCol<=0 ){
138985 const char *zMod = pTab->u.vtab.azArg[0];
138986 if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue;
138987 }
138988 sqlite3ViewGetColumnNames(pParse, pTab);
138989 if( pTab->u.vtab.p==0 ) continue;
138990 pVTab = pTab->u.vtab.p->pVtab;
138991 if( NEVER(pVTab==0) ) continue;
138992 if( NEVER(pVTab->pModule==0) ) continue;
138993 if( pVTab->pModule->iVersion<4 ) continue;
138994 if( pVTab->pModule->xIntegrity==0 ) continue;
138995 sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick);
138996 sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
138997 a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v);
138998 integrityCheckResultRow(v);
138999 sqlite3VdbeJumpHere(v, a1);
139000#endif
139001 continue;
139002 }
138164 if( isQuick || HasRowid(pTab) ){ 139003 if( isQuick || HasRowid(pTab) ){
138165 pPk = 0; 139004 pPk = 0;
138166 r2 = 0; 139005 r2 = 0;
@@ -139286,7 +140125,8 @@ static const sqlite3_module pragmaVtabModule = {
139286 0, /* xSavepoint */ 140125 0, /* xSavepoint */
139287 0, /* xRelease */ 140126 0, /* xRelease */
139288 0, /* xRollbackTo */ 140127 0, /* xRollbackTo */
139289 0 /* xShadowName */ 140128 0, /* xShadowName */
140129 0 /* xIntegrity */
139290}; 140130};
139291 140131
139292/* 140132/*
@@ -139910,8 +140750,6 @@ SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){
139910 db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; 140750 db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
139911 assert( pParse->db->pParse==pParse ); 140751 assert( pParse->db->pParse==pParse );
139912 db->pParse = pParse->pOuterParse; 140752 db->pParse = pParse->pOuterParse;
139913 pParse->db = 0;
139914 pParse->disableLookaside = 0;
139915} 140753}
139916 140754
139917/* 140755/*
@@ -140849,6 +141687,7 @@ static void unsetJoinExpr(Expr *p, int iTable, int nullable){
140849 } 141687 }
140850 if( p->op==TK_FUNCTION ){ 141688 if( p->op==TK_FUNCTION ){
140851 assert( ExprUseXList(p) ); 141689 assert( ExprUseXList(p) );
141690 assert( p->pLeft==0 );
140852 if( p->x.pList ){ 141691 if( p->x.pList ){
140853 int i; 141692 int i;
140854 for(i=0; i<p->x.pList->nExpr; i++){ 141693 for(i=0; i<p->x.pList->nExpr; i++){
@@ -146509,6 +147348,7 @@ static int selectExpander(Walker *pWalker, Select *p){
146509 char *zTName = 0; /* text of name of TABLE */ 147348 char *zTName = 0; /* text of name of TABLE */
146510 int iErrOfst; 147349 int iErrOfst;
146511 if( pE->op==TK_DOT ){ 147350 if( pE->op==TK_DOT ){
147351 assert( (selFlags & SF_NestedFrom)==0 );
146512 assert( pE->pLeft!=0 ); 147352 assert( pE->pLeft!=0 );
146513 assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); 147353 assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );
146514 zTName = pE->pLeft->u.zToken; 147354 zTName = pE->pLeft->u.zToken;
@@ -146519,6 +147359,7 @@ static int selectExpander(Walker *pWalker, Select *p){
146519 iErrOfst = pE->w.iOfst; 147359 iErrOfst = pE->w.iOfst;
146520 } 147360 }
146521 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ 147361 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
147362 int nAdd; /* Number of cols including rowid */
146522 Table *pTab = pFrom->pTab; /* Table for this data source */ 147363 Table *pTab = pFrom->pTab; /* Table for this data source */
146523 ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ 147364 ExprList *pNestedFrom; /* Result-set of a nested FROM clause */
146524 char *zTabName; /* AS name for this data source */ 147365 char *zTabName; /* AS name for this data source */
@@ -146536,6 +147377,7 @@ static int selectExpander(Walker *pWalker, Select *p){
146536 pNestedFrom = pFrom->pSelect->pEList; 147377 pNestedFrom = pFrom->pSelect->pEList;
146537 assert( pNestedFrom!=0 ); 147378 assert( pNestedFrom!=0 );
146538 assert( pNestedFrom->nExpr==pTab->nCol ); 147379 assert( pNestedFrom->nExpr==pTab->nCol );
147380 assert( VisibleRowid(pTab)==0 );
146539 }else{ 147381 }else{
146540 if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ 147382 if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){
146541 continue; 147383 continue;
@@ -146566,33 +147408,48 @@ static int selectExpander(Walker *pWalker, Select *p){
146566 }else{ 147408 }else{
146567 pUsing = 0; 147409 pUsing = 0;
146568 } 147410 }
146569 for(j=0; j<pTab->nCol; j++){ 147411
146570 char *zName = pTab->aCol[j].zCnName; 147412 nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom));
147413 for(j=0; j<nAdd; j++){
147414 const char *zName;
146571 struct ExprList_item *pX; /* Newly added ExprList term */ 147415 struct ExprList_item *pX; /* Newly added ExprList term */
146572 147416
146573 assert( zName ); 147417 if( j==pTab->nCol ){
146574 if( zTName 147418 zName = sqlite3RowidAlias(pTab);
146575 && pNestedFrom 147419 if( zName==0 ) continue;
146576 && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0)==0 147420 }else{
146577 ){ 147421 zName = pTab->aCol[j].zCnName;
146578 continue;
146579 }
146580 147422
146581 /* If a column is marked as 'hidden', omit it from the expanded 147423 /* If pTab is actually an SF_NestedFrom sub-select, do not
146582 ** result-set list unless the SELECT has the SF_IncludeHidden 147424 ** expand any ENAME_ROWID columns. */
146583 ** bit set. 147425 if( pNestedFrom && pNestedFrom->a[j].fg.eEName==ENAME_ROWID ){
146584 */ 147426 continue;
146585 if( (p->selFlags & SF_IncludeHidden)==0 147427 }
146586 && IsHiddenColumn(&pTab->aCol[j]) 147428
146587 ){ 147429 if( zTName
146588 continue; 147430 && pNestedFrom
146589 } 147431 && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0, 0)==0
146590 if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 147432 ){
146591 && zTName==0 147433 continue;
146592 && (selFlags & (SF_NestedFrom))==0 147434 }
146593 ){ 147435
146594 continue; 147436 /* If a column is marked as 'hidden', omit it from the expanded
147437 ** result-set list unless the SELECT has the SF_IncludeHidden
147438 ** bit set.
147439 */
147440 if( (p->selFlags & SF_IncludeHidden)==0
147441 && IsHiddenColumn(&pTab->aCol[j])
147442 ){
147443 continue;
147444 }
147445 if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0
147446 && zTName==0
147447 && (selFlags & (SF_NestedFrom))==0
147448 ){
147449 continue;
147450 }
146595 } 147451 }
147452 assert( zName );
146596 tableSeen = 1; 147453 tableSeen = 1;
146597 147454
146598 if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ 147455 if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){
@@ -146642,11 +147499,11 @@ static int selectExpander(Walker *pWalker, Select *p){
146642 zSchemaName, zTabName, zName); 147499 zSchemaName, zTabName, zName);
146643 testcase( pX->zEName==0 ); 147500 testcase( pX->zEName==0 );
146644 } 147501 }
146645 pX->fg.eEName = ENAME_TAB; 147502 pX->fg.eEName = (j==pTab->nCol ? ENAME_ROWID : ENAME_TAB);
146646 if( (pFrom->fg.isUsing 147503 if( (pFrom->fg.isUsing
146647 && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) 147504 && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0)
146648 || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) 147505 || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0)
146649 || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 147506 || (j<pTab->nCol && (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND))
146650 ){ 147507 ){
146651 pX->fg.bNoExpand = 1; 147508 pX->fg.bNoExpand = 1;
146652 } 147509 }
@@ -146867,8 +147724,14 @@ static void analyzeAggFuncArgs(
146867 pNC->ncFlags |= NC_InAggFunc; 147724 pNC->ncFlags |= NC_InAggFunc;
146868 for(i=0; i<pAggInfo->nFunc; i++){ 147725 for(i=0; i<pAggInfo->nFunc; i++){
146869 Expr *pExpr = pAggInfo->aFunc[i].pFExpr; 147726 Expr *pExpr = pAggInfo->aFunc[i].pFExpr;
147727 assert( pExpr->op==TK_FUNCTION || pExpr->op==TK_AGG_FUNCTION );
146870 assert( ExprUseXList(pExpr) ); 147728 assert( ExprUseXList(pExpr) );
146871 sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); 147729 sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList);
147730 if( pExpr->pLeft ){
147731 assert( pExpr->pLeft->op==TK_ORDER );
147732 assert( ExprUseXList(pExpr->pLeft) );
147733 sqlite3ExprAnalyzeAggList(pNC, pExpr->pLeft->x.pList);
147734 }
146872#ifndef SQLITE_OMIT_WINDOWFUNC 147735#ifndef SQLITE_OMIT_WINDOWFUNC
146873 assert( !IsWindowFunc(pExpr) ); 147736 assert( !IsWindowFunc(pExpr) );
146874 if( ExprHasProperty(pExpr, EP_WinFunc) ){ 147737 if( ExprHasProperty(pExpr, EP_WinFunc) ){
@@ -147023,6 +147886,32 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
147023 pFunc->pFunc->zName)); 147886 pFunc->pFunc->zName));
147024 } 147887 }
147025 } 147888 }
147889 if( pFunc->iOBTab>=0 ){
147890 ExprList *pOBList;
147891 KeyInfo *pKeyInfo;
147892 int nExtra = 0;
147893 assert( pFunc->pFExpr->pLeft!=0 );
147894 assert( pFunc->pFExpr->pLeft->op==TK_ORDER );
147895 assert( ExprUseXList(pFunc->pFExpr->pLeft) );
147896 pOBList = pFunc->pFExpr->pLeft->x.pList;
147897 if( !pFunc->bOBUnique ){
147898 nExtra++; /* One extra column for the OP_Sequence */
147899 }
147900 if( pFunc->bOBPayload ){
147901 /* extra columns for the function arguments */
147902 assert( ExprUseXList(pFunc->pFExpr) );
147903 nExtra += pFunc->pFExpr->x.pList->nExpr;
147904 }
147905 pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra);
147906 if( !pFunc->bOBUnique && pParse->nErr==0 ){
147907 pKeyInfo->nKeyField++;
147908 }
147909 sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
147910 pFunc->iOBTab, pOBList->nExpr+nExtra, 0,
147911 (char*)pKeyInfo, P4_KEYINFO);
147912 ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(ORDER BY)",
147913 pFunc->pFunc->zName));
147914 }
147026 } 147915 }
147027} 147916}
147028 147917
@@ -147038,13 +147927,46 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){
147038 ExprList *pList; 147927 ExprList *pList;
147039 assert( ExprUseXList(pF->pFExpr) ); 147928 assert( ExprUseXList(pF->pFExpr) );
147040 pList = pF->pFExpr->x.pList; 147929 pList = pF->pFExpr->x.pList;
147930 if( pF->iOBTab>=0 ){
147931 /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and
147932 ** all content was stored in emphermal table pF->iOBTab. Extract that
147933 ** content now (in ORDER BY order) and make all calls to OP_AggStep
147934 ** before doing the OP_AggFinal call. */
147935 int iTop; /* Start of loop for extracting columns */
147936 int nArg; /* Number of columns to extract */
147937 int nKey; /* Key columns to be skipped */
147938 int regAgg; /* Extract into this array */
147939 int j; /* Loop counter */
147940
147941 nArg = pList->nExpr;
147942 regAgg = sqlite3GetTempRange(pParse, nArg);
147943
147944 if( pF->bOBPayload==0 ){
147945 nKey = 0;
147946 }else{
147947 assert( pF->pFExpr->pLeft!=0 );
147948 assert( ExprUseXList(pF->pFExpr->pLeft) );
147949 assert( pF->pFExpr->pLeft->x.pList!=0 );
147950 nKey = pF->pFExpr->pLeft->x.pList->nExpr;
147951 if( ALWAYS(!pF->bOBUnique) ) nKey++;
147952 }
147953 iTop = sqlite3VdbeAddOp1(v, OP_Rewind, pF->iOBTab); VdbeCoverage(v);
147954 for(j=nArg-1; j>=0; j--){
147955 sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j);
147956 }
147957 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
147958 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
147959 sqlite3VdbeChangeP5(v, (u8)nArg);
147960 sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v);
147961 sqlite3VdbeJumpHere(v, iTop);
147962 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
147963 }
147041 sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), 147964 sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i),
147042 pList ? pList->nExpr : 0); 147965 pList ? pList->nExpr : 0);
147043 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); 147966 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
147044 } 147967 }
147045} 147968}
147046 147969
147047
147048/* 147970/*
147049** Generate code that will update the accumulator memory cells for an 147971** Generate code that will update the accumulator memory cells for an
147050** aggregate based on the current cursor position. 147972** aggregate based on the current cursor position.
@@ -147053,6 +147975,13 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){
147053** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator 147975** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator
147054** registers if register regAcc contains 0. The caller will take care 147976** registers if register regAcc contains 0. The caller will take care
147055** of setting and clearing regAcc. 147977** of setting and clearing regAcc.
147978**
147979** For an ORDER BY aggregate, the actual accumulator memory cell update
147980** is deferred until after all input rows have been received, so that they
147981** can be run in the requested order. In that case, instead of invoking
147982** OP_AggStep to update the accumulator, just add the arguments that would
147983** have been passed into OP_AggStep into the sorting ephemeral table
147984** (along with the appropriate sort key).
147056*/ 147985*/
147057static void updateAccumulator( 147986static void updateAccumulator(
147058 Parse *pParse, 147987 Parse *pParse,
@@ -147074,6 +148003,8 @@ static void updateAccumulator(
147074 int nArg; 148003 int nArg;
147075 int addrNext = 0; 148004 int addrNext = 0;
147076 int regAgg; 148005 int regAgg;
148006 int regAggSz = 0;
148007 int regDistinct = 0;
147077 ExprList *pList; 148008 ExprList *pList;
147078 assert( ExprUseXList(pF->pFExpr) ); 148009 assert( ExprUseXList(pF->pFExpr) );
147079 assert( !IsWindowFunc(pF->pFExpr) ); 148010 assert( !IsWindowFunc(pF->pFExpr) );
@@ -147100,9 +148031,44 @@ static void updateAccumulator(
147100 addrNext = sqlite3VdbeMakeLabel(pParse); 148031 addrNext = sqlite3VdbeMakeLabel(pParse);
147101 sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); 148032 sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL);
147102 } 148033 }
147103 if( pList ){ 148034 if( pF->iOBTab>=0 ){
148035 /* Instead of invoking AggStep, we must push the arguments that would
148036 ** have been passed to AggStep onto the sorting table. */
148037 int jj; /* Registered used so far in building the record */
148038 ExprList *pOBList; /* The ORDER BY clause */
148039 assert( pList!=0 );
148040 nArg = pList->nExpr;
148041 assert( nArg>0 );
148042 assert( pF->pFExpr->pLeft!=0 );
148043 assert( pF->pFExpr->pLeft->op==TK_ORDER );
148044 assert( ExprUseXList(pF->pFExpr->pLeft) );
148045 pOBList = pF->pFExpr->pLeft->x.pList;
148046 assert( pOBList!=0 );
148047 assert( pOBList->nExpr>0 );
148048 regAggSz = pOBList->nExpr;
148049 if( !pF->bOBUnique ){
148050 regAggSz++; /* One register for OP_Sequence */
148051 }
148052 if( pF->bOBPayload ){
148053 regAggSz += nArg;
148054 }
148055 regAggSz++; /* One extra register to hold result of MakeRecord */
148056 regAgg = sqlite3GetTempRange(pParse, regAggSz);
148057 regDistinct = regAgg;
148058 sqlite3ExprCodeExprList(pParse, pOBList, regAgg, 0, SQLITE_ECEL_DUP);
148059 jj = pOBList->nExpr;
148060 if( !pF->bOBUnique ){
148061 sqlite3VdbeAddOp2(v, OP_Sequence, pF->iOBTab, regAgg+jj);
148062 jj++;
148063 }
148064 if( pF->bOBPayload ){
148065 regDistinct = regAgg+jj;
148066 sqlite3ExprCodeExprList(pParse, pList, regDistinct, 0, SQLITE_ECEL_DUP);
148067 }
148068 }else if( pList ){
147104 nArg = pList->nExpr; 148069 nArg = pList->nExpr;
147105 regAgg = sqlite3GetTempRange(pParse, nArg); 148070 regAgg = sqlite3GetTempRange(pParse, nArg);
148071 regDistinct = regAgg;
147106 sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); 148072 sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);
147107 }else{ 148073 }else{
147108 nArg = 0; 148074 nArg = 0;
@@ -147113,26 +148079,37 @@ static void updateAccumulator(
147113 addrNext = sqlite3VdbeMakeLabel(pParse); 148079 addrNext = sqlite3VdbeMakeLabel(pParse);
147114 } 148080 }
147115 pF->iDistinct = codeDistinct(pParse, eDistinctType, 148081 pF->iDistinct = codeDistinct(pParse, eDistinctType,
147116 pF->iDistinct, addrNext, pList, regAgg); 148082 pF->iDistinct, addrNext, pList, regDistinct);
147117 } 148083 }
147118 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ 148084 if( pF->iOBTab>=0 ){
147119 CollSeq *pColl = 0; 148085 /* Insert a new record into the ORDER BY table */
147120 struct ExprList_item *pItem; 148086 sqlite3VdbeAddOp3(v, OP_MakeRecord, regAgg, regAggSz-1,
147121 int j; 148087 regAgg+regAggSz-1);
147122 assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ 148088 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pF->iOBTab, regAgg+regAggSz-1,
147123 for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){ 148089 regAgg, regAggSz-1);
147124 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); 148090 sqlite3ReleaseTempRange(pParse, regAgg, regAggSz);
147125 } 148091 }else{
147126 if( !pColl ){ 148092 /* Invoke the AggStep function */
147127 pColl = pParse->db->pDfltColl; 148093 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
148094 CollSeq *pColl = 0;
148095 struct ExprList_item *pItem;
148096 int j;
148097 assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */
148098 for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){
148099 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
148100 }
148101 if( !pColl ){
148102 pColl = pParse->db->pDfltColl;
148103 }
148104 if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;
148105 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0,
148106 (char *)pColl, P4_COLLSEQ);
147128 } 148107 }
147129 if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; 148108 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
147130 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); 148109 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
148110 sqlite3VdbeChangeP5(v, (u8)nArg);
148111 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
147131 } 148112 }
147132 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
147133 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
147134 sqlite3VdbeChangeP5(v, (u8)nArg);
147135 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
147136 if( addrNext ){ 148113 if( addrNext ){
147137 sqlite3VdbeResolveLabel(v, addrNext); 148114 sqlite3VdbeResolveLabel(v, addrNext);
147138 } 148115 }
@@ -149193,6 +150170,10 @@ SQLITE_PRIVATE void sqlite3BeginTrigger(
149193 sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); 150170 sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");
149194 goto trigger_orphan_error; 150171 goto trigger_orphan_error;
149195 } 150172 }
150173 if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){
150174 sqlite3ErrorMsg(pParse, "cannot create triggers on shadow tables");
150175 goto trigger_orphan_error;
150176 }
149196 150177
149197 /* Check that the trigger name is not reserved and that no trigger of the 150178 /* Check that the trigger name is not reserved and that no trigger of the
149198 ** specified name exists */ 150179 ** specified name exists */
@@ -149976,10 +150957,17 @@ static void codeReturningTrigger(
149976 SrcList sFrom; 150957 SrcList sFrom;
149977 150958
149978 assert( v!=0 ); 150959 assert( v!=0 );
149979 assert( pParse->bReturning ); 150960 if( !pParse->bReturning ){
150961 /* This RETURNING trigger must be for a different statement as
150962 ** this statement lacks a RETURNING clause. */
150963 return;
150964 }
149980 assert( db->pParse==pParse ); 150965 assert( db->pParse==pParse );
149981 pReturning = pParse->u1.pReturning; 150966 pReturning = pParse->u1.pReturning;
149982 assert( pTrigger == &(pReturning->retTrig) ); 150967 if( pTrigger != &(pReturning->retTrig) ){
150968 /* This RETURNING trigger is for a different statement */
150969 return;
150970 }
149983 memset(&sSelect, 0, sizeof(sSelect)); 150971 memset(&sSelect, 0, sizeof(sSelect));
149984 memset(&sFrom, 0, sizeof(sFrom)); 150972 memset(&sFrom, 0, sizeof(sFrom));
149985 sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); 150973 sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
@@ -153416,7 +154404,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
153416 sqlite3_mutex_enter(db->mutex); 154404 sqlite3_mutex_enter(db->mutex);
153417 pCtx = db->pVtabCtx; 154405 pCtx = db->pVtabCtx;
153418 if( !pCtx || pCtx->bDeclared ){ 154406 if( !pCtx || pCtx->bDeclared ){
153419 sqlite3Error(db, SQLITE_MISUSE); 154407 sqlite3Error(db, SQLITE_MISUSE_BKPT);
153420 sqlite3_mutex_leave(db->mutex); 154408 sqlite3_mutex_leave(db->mutex);
153421 return SQLITE_MISUSE_BKPT; 154409 return SQLITE_MISUSE_BKPT;
153422 } 154410 }
@@ -154607,7 +155595,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
154607#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ 155595#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */
154608#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ 155596#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */
154609#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ 155597#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */
154610#define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ 155598 /* 0x02000000 -- available for reuse */
154611#define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ 155599#define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */
154612 155600
154613#endif /* !defined(SQLITE_WHEREINT_H) */ 155601#endif /* !defined(SQLITE_WHEREINT_H) */
@@ -160402,13 +161390,17 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
160402 WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ 161390 WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
160403 int iCur; /* Cursor for table getting the filter */ 161391 int iCur; /* Cursor for table getting the filter */
160404 IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ 161392 IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */
161393 IndexedExpr *saved_pIdxPartExpr; /* saved copy of Parse.pIdxPartExpr */
160405 161394
160406 saved_pIdxEpr = pParse->pIdxEpr; 161395 saved_pIdxEpr = pParse->pIdxEpr;
161396 saved_pIdxPartExpr = pParse->pIdxPartExpr;
160407 pParse->pIdxEpr = 0; 161397 pParse->pIdxEpr = 0;
161398 pParse->pIdxPartExpr = 0;
160408 161399
160409 assert( pLoop!=0 ); 161400 assert( pLoop!=0 );
160410 assert( v!=0 ); 161401 assert( v!=0 );
160411 assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); 161402 assert( pLoop->wsFlags & WHERE_BLOOMFILTER );
161403 assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 );
160412 161404
160413 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); 161405 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
160414 do{ 161406 do{
@@ -160498,6 +161490,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
160498 }while( iLevel < pWInfo->nLevel ); 161490 }while( iLevel < pWInfo->nLevel );
160499 sqlite3VdbeJumpHere(v, addrOnce); 161491 sqlite3VdbeJumpHere(v, addrOnce);
160500 pParse->pIdxEpr = saved_pIdxEpr; 161492 pParse->pIdxEpr = saved_pIdxEpr;
161493 pParse->pIdxPartExpr = saved_pIdxPartExpr;
160501} 161494}
160502 161495
160503 161496
@@ -162758,6 +163751,100 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex(
162758} 163751}
162759 163752
162760/* 163753/*
163754** This is an sqlite3ParserAddCleanup() callback that is invoked to
163755** free the Parse->pIdxEpr list when the Parse object is destroyed.
163756*/
163757static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){
163758 IndexedExpr **pp = (IndexedExpr**)pObject;
163759 while( *pp!=0 ){
163760 IndexedExpr *p = *pp;
163761 *pp = p->pIENext;
163762 sqlite3ExprDelete(db, p->pExpr);
163763 sqlite3DbFreeNN(db, p);
163764 }
163765}
163766
163767/*
163768** This function is called for a partial index - one with a WHERE clause - in
163769** two scenarios. In both cases, it determines whether or not the WHERE
163770** clause on the index implies that a column of the table may be safely
163771** replaced by a constant expression. For example, in the following
163772** SELECT:
163773**
163774** CREATE INDEX i1 ON t1(b, c) WHERE a=<expr>;
163775** SELECT a, b, c FROM t1 WHERE a=<expr> AND b=?;
163776**
163777** The "a" in the select-list may be replaced by <expr>, iff:
163778**
163779** (a) <expr> is a constant expression, and
163780** (b) The (a=<expr>) comparison uses the BINARY collation sequence, and
163781** (c) Column "a" has an affinity other than NONE or BLOB.
163782**
163783** If argument pItem is NULL, then pMask must not be NULL. In this case this
163784** function is being called as part of determining whether or not pIdx
163785** is a covering index. This function clears any bits in (*pMask)
163786** corresponding to columns that may be replaced by constants as described
163787** above.
163788**
163789** Otherwise, if pItem is not NULL, then this function is being called
163790** as part of coding a loop that uses index pIdx. In this case, add entries
163791** to the Parse.pIdxPartExpr list for each column that can be replaced
163792** by a constant.
163793*/
163794static void wherePartIdxExpr(
163795 Parse *pParse, /* Parse context */
163796 Index *pIdx, /* Partial index being processed */
163797 Expr *pPart, /* WHERE clause being processed */
163798 Bitmask *pMask, /* Mask to clear bits in */
163799 int iIdxCur, /* Cursor number for index */
163800 SrcItem *pItem /* The FROM clause entry for the table */
163801){
163802 assert( pItem==0 || (pItem->fg.jointype & JT_RIGHT)==0 );
163803 assert( (pItem==0 || pMask==0) && (pMask!=0 || pItem!=0) );
163804
163805 if( pPart->op==TK_AND ){
163806 wherePartIdxExpr(pParse, pIdx, pPart->pRight, pMask, iIdxCur, pItem);
163807 pPart = pPart->pLeft;
163808 }
163809
163810 if( (pPart->op==TK_EQ || pPart->op==TK_IS) ){
163811 Expr *pLeft = pPart->pLeft;
163812 Expr *pRight = pPart->pRight;
163813 u8 aff;
163814
163815 if( pLeft->op!=TK_COLUMN ) return;
163816 if( !sqlite3ExprIsConstant(pRight) ) return;
163817 if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return;
163818 if( pLeft->iColumn<0 ) return;
163819 aff = pIdx->pTable->aCol[pLeft->iColumn].affinity;
163820 if( aff>=SQLITE_AFF_TEXT ){
163821 if( pItem ){
163822 sqlite3 *db = pParse->db;
163823 IndexedExpr *p = (IndexedExpr*)sqlite3DbMallocRaw(db, sizeof(*p));
163824 if( p ){
163825 int bNullRow = (pItem->fg.jointype&(JT_LEFT|JT_LTORJ))!=0;
163826 p->pExpr = sqlite3ExprDup(db, pRight, 0);
163827 p->iDataCur = pItem->iCursor;
163828 p->iIdxCur = iIdxCur;
163829 p->iIdxCol = pLeft->iColumn;
163830 p->bMaybeNullRow = bNullRow;
163831 p->pIENext = pParse->pIdxPartExpr;
163832 p->aff = aff;
163833 pParse->pIdxPartExpr = p;
163834 if( p->pIENext==0 ){
163835 void *pArg = (void*)&pParse->pIdxPartExpr;
163836 sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg);
163837 }
163838 }
163839 }else if( pLeft->iColumn<(BMS-1) ){
163840 *pMask &= ~((Bitmask)1 << pLeft->iColumn);
163841 }
163842 }
163843 }
163844}
163845
163846
163847/*
162761** Add all WhereLoop objects for a single table of the join where the table 163848** Add all WhereLoop objects for a single table of the join where the table
162762** is identified by pBuilder->pNew->iTab. That table is guaranteed to be 163849** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
162763** a b-tree table, not a virtual table. 163850** a b-tree table, not a virtual table.
@@ -162960,9 +164047,6 @@ static int whereLoopAddBtree(
162960#else 164047#else
162961 pNew->rRun = rSize + 16; 164048 pNew->rRun = rSize + 16;
162962#endif 164049#endif
162963 if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){
162964 pNew->wsFlags |= WHERE_VIEWSCAN;
162965 }
162966 ApplyCostMultiplier(pNew->rRun, pTab->costMult); 164050 ApplyCostMultiplier(pNew->rRun, pTab->costMult);
162967 whereLoopOutputAdjust(pWC, pNew, rSize); 164051 whereLoopOutputAdjust(pWC, pNew, rSize);
162968 rc = whereLoopInsert(pBuilder, pNew); 164052 rc = whereLoopInsert(pBuilder, pNew);
@@ -162975,6 +164059,11 @@ static int whereLoopAddBtree(
162975 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; 164059 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
162976 }else{ 164060 }else{
162977 m = pSrc->colUsed & pProbe->colNotIdxed; 164061 m = pSrc->colUsed & pProbe->colNotIdxed;
164062 if( pProbe->pPartIdxWhere ){
164063 wherePartIdxExpr(
164064 pWInfo->pParse, pProbe, pProbe->pPartIdxWhere, &m, 0, 0
164065 );
164066 }
162978 pNew->wsFlags = WHERE_INDEXED; 164067 pNew->wsFlags = WHERE_INDEXED;
162979 if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ 164068 if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){
162980 u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); 164069 u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor);
@@ -163357,7 +164446,7 @@ SQLITE_API int sqlite3_vtab_rhs_value(
163357 sqlite3_value *pVal = 0; 164446 sqlite3_value *pVal = 0;
163358 int rc = SQLITE_OK; 164447 int rc = SQLITE_OK;
163359 if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ 164448 if( iCons<0 || iCons>=pIdxInfo->nConstraint ){
163360 rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ 164449 rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */
163361 }else{ 164450 }else{
163362 if( pH->aRhs[iCons]==0 ){ 164451 if( pH->aRhs[iCons]==0 ){
163363 WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; 164452 WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset];
@@ -164381,14 +165470,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
164381 rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ 165470 rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
164382 } 165471 }
164383 165472
164384 /* TUNING: A full-scan of a VIEW or subquery in the outer loop
164385 ** is not so bad. */
164386 if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 && nLoop>1 ){
164387 rCost += -10;
164388 nOut += -30;
164389 WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId));
164390 }
164391
164392 /* Check to see if pWLoop should be added to the set of 165473 /* Check to see if pWLoop should be added to the set of
164393 ** mxChoice best-so-far paths. 165474 ** mxChoice best-so-far paths.
164394 ** 165475 **
@@ -164939,20 +166020,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
164939} 166020}
164940 166021
164941/* 166022/*
164942** This is an sqlite3ParserAddCleanup() callback that is invoked to
164943** free the Parse->pIdxEpr list when the Parse object is destroyed.
164944*/
164945static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){
164946 Parse *pParse = (Parse*)pObject;
164947 while( pParse->pIdxEpr!=0 ){
164948 IndexedExpr *p = pParse->pIdxEpr;
164949 pParse->pIdxEpr = p->pIENext;
164950 sqlite3ExprDelete(db, p->pExpr);
164951 sqlite3DbFreeNN(db, p);
164952 }
164953}
164954
164955/*
164956** The index pIdx is used by a query and contains one or more expressions. 166023** The index pIdx is used by a query and contains one or more expressions.
164957** In other words pIdx is an index on an expression. iIdxCur is the cursor 166024** In other words pIdx is an index on an expression. iIdxCur is the cursor
164958** number for the index and iDataCur is the cursor number for the corresponding 166025** number for the index and iDataCur is the cursor number for the corresponding
@@ -165013,7 +166080,8 @@ static SQLITE_NOINLINE void whereAddIndexedExpr(
165013#endif 166080#endif
165014 pParse->pIdxEpr = p; 166081 pParse->pIdxEpr = p;
165015 if( p->pIENext==0 ){ 166082 if( p->pIENext==0 ){
165016 sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); 166083 void *pArg = (void*)&pParse->pIdxEpr;
166084 sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg);
165017 } 166085 }
165018 } 166086 }
165019} 166087}
@@ -165403,6 +166471,16 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
165403 wherePathSolver(pWInfo, pWInfo->nRowOut+1); 166471 wherePathSolver(pWInfo, pWInfo->nRowOut+1);
165404 if( db->mallocFailed ) goto whereBeginError; 166472 if( db->mallocFailed ) goto whereBeginError;
165405 } 166473 }
166474
166475 /* TUNING: Assume that a DISTINCT clause on a subquery reduces
166476 ** the output size by a factor of 8 (LogEst -30).
166477 */
166478 if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){
166479 WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n",
166480 pWInfo->nRowOut, pWInfo->nRowOut-30));
166481 pWInfo->nRowOut -= 30;
166482 }
166483
165406 } 166484 }
165407 assert( pWInfo->pTabList!=0 ); 166485 assert( pWInfo->pTabList!=0 );
165408 if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ 166486 if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){
@@ -165615,6 +166693,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
165615 if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ 166693 if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){
165616 whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); 166694 whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem);
165617 } 166695 }
166696 if( pIx->pPartIdxWhere && (pTabItem->fg.jointype & JT_RIGHT)==0 ){
166697 wherePartIdxExpr(
166698 pParse, pIx, pIx->pPartIdxWhere, 0, iIndexCur, pTabItem
166699 );
166700 }
165618 } 166701 }
165619 pLevel->iIdxCur = iIndexCur; 166702 pLevel->iIdxCur = iIndexCur;
165620 assert( pIx!=0 ); 166703 assert( pIx!=0 );
@@ -167431,8 +168514,9 @@ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
167431 if( p ){ 168514 if( p ){
167432 assert( p->op==TK_FUNCTION ); 168515 assert( p->op==TK_FUNCTION );
167433 assert( pWin ); 168516 assert( pWin );
168517 assert( ExprIsFullSize(p) );
167434 p->y.pWin = pWin; 168518 p->y.pWin = pWin;
167435 ExprSetProperty(p, EP_WinFunc); 168519 ExprSetProperty(p, EP_WinFunc|EP_FullSize);
167436 pWin->pOwner = p; 168520 pWin->pOwner = p;
167437 if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ 168521 if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){
167438 sqlite3ErrorMsg(pParse, 168522 sqlite3ErrorMsg(pParse,
@@ -169734,18 +170818,18 @@ typedef union {
169734#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; 170818#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
169735#define sqlite3ParserCTX_STORE yypParser->pParse=pParse; 170819#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
169736#define YYFALLBACK 1 170820#define YYFALLBACK 1
169737#define YYNSTATE 575 170821#define YYNSTATE 579
169738#define YYNRULE 403 170822#define YYNRULE 405
169739#define YYNRULE_WITH_ACTION 338 170823#define YYNRULE_WITH_ACTION 340
169740#define YYNTOKEN 185 170824#define YYNTOKEN 185
169741#define YY_MAX_SHIFT 574 170825#define YY_MAX_SHIFT 578
169742#define YY_MIN_SHIFTREDUCE 833 170826#define YY_MIN_SHIFTREDUCE 838
169743#define YY_MAX_SHIFTREDUCE 1235 170827#define YY_MAX_SHIFTREDUCE 1242
169744#define YY_ERROR_ACTION 1236 170828#define YY_ERROR_ACTION 1243
169745#define YY_ACCEPT_ACTION 1237 170829#define YY_ACCEPT_ACTION 1244
169746#define YY_NO_ACTION 1238 170830#define YY_NO_ACTION 1245
169747#define YY_MIN_REDUCE 1239 170831#define YY_MIN_REDUCE 1246
169748#define YY_MAX_REDUCE 1641 170832#define YY_MAX_REDUCE 1650
169749/************* End control #defines *******************************************/ 170833/************* End control #defines *******************************************/
169750#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) 170834#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
169751 170835
@@ -169812,218 +170896,218 @@ typedef union {
169812** yy_default[] Default action for each state. 170896** yy_default[] Default action for each state.
169813** 170897**
169814*********** Begin parsing tables **********************************************/ 170898*********** Begin parsing tables **********************************************/
169815#define YY_ACTTAB_COUNT (2096) 170899#define YY_ACTTAB_COUNT (2100)
169816static const YYACTIONTYPE yy_action[] = { 170900static const YYACTIONTYPE yy_action[] = {
169817 /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, 170901 /* 0 */ 572, 210, 572, 119, 116, 231, 572, 119, 116, 231,
169818 /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, 170902 /* 10 */ 572, 1317, 379, 1296, 410, 566, 566, 566, 572, 411,
169819 /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, 170903 /* 20 */ 380, 1317, 1279, 42, 42, 42, 42, 210, 1529, 72,
169820 /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, 170904 /* 30 */ 72, 974, 421, 42, 42, 495, 305, 281, 305, 975,
169821 /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, 170905 /* 40 */ 399, 72, 72, 126, 127, 81, 1217, 1217, 1054, 1057,
169822 /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, 170906 /* 50 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 480, 411,
169823 /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, 170907 /* 60 */ 1244, 1, 1, 578, 2, 1248, 554, 119, 116, 231,
169824 /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, 170908 /* 70 */ 319, 484, 147, 484, 528, 119, 116, 231, 533, 1330,
169825 /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, 170909 /* 80 */ 419, 527, 143, 126, 127, 81, 1217, 1217, 1054, 1057,
169826 /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, 170910 /* 90 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 119, 116,
169827 /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, 170911 /* 100 */ 231, 329, 123, 123, 123, 123, 122, 122, 121, 121,
169828 /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, 170912 /* 110 */ 121, 120, 117, 448, 286, 286, 286, 286, 446, 446,
169829 /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, 170913 /* 120 */ 446, 1568, 378, 1570, 1193, 377, 1164, 569, 1164, 569,
169830 /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, 170914 /* 130 */ 411, 1568, 541, 261, 228, 448, 102, 146, 453, 318,
169831 /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, 170915 /* 140 */ 563, 242, 123, 123, 123, 123, 122, 122, 121, 121,
169832 /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, 170916 /* 150 */ 121, 120, 117, 448, 126, 127, 81, 1217, 1217, 1054,
169833 /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, 170917 /* 160 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 143,
169834 /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, 170918 /* 170 */ 296, 1193, 341, 452, 121, 121, 121, 120, 117, 448,
169835 /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, 170919 /* 180 */ 128, 1193, 1194, 1193, 149, 445, 444, 572, 120, 117,
169836 /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, 170920 /* 190 */ 448, 125, 125, 125, 125, 118, 123, 123, 123, 123,
169837 /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, 170921 /* 200 */ 122, 122, 121, 121, 121, 120, 117, 448, 458, 114,
169838 /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, 170922 /* 210 */ 13, 13, 550, 123, 123, 123, 123, 122, 122, 121,
169839 /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, 170923 /* 220 */ 121, 121, 120, 117, 448, 424, 318, 563, 1193, 1194,
169840 /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, 170924 /* 230 */ 1193, 150, 1225, 411, 1225, 125, 125, 125, 125, 123,
169841 /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, 170925 /* 240 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117,
169842 /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, 170926 /* 250 */ 448, 469, 344, 1041, 1041, 1055, 1058, 126, 127, 81,
169843 /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 170927 /* 260 */ 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125,
169844 /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, 170928 /* 270 */ 125, 125, 1282, 526, 224, 1193, 572, 411, 226, 519,
169845 /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, 170929 /* 280 */ 177, 83, 84, 123, 123, 123, 123, 122, 122, 121,
169846 /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, 170930 /* 290 */ 121, 121, 120, 117, 448, 1010, 16, 16, 1193, 134,
169847 /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 170931 /* 300 */ 134, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, 1044,
169848 /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, 170932 /* 310 */ 124, 124, 125, 125, 125, 125, 123, 123, 123, 123,
169849 /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, 170933 /* 320 */ 122, 122, 121, 121, 121, 120, 117, 448, 1045, 550,
169850 /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, 170934 /* 330 */ 1193, 375, 1193, 1194, 1193, 254, 1438, 401, 508, 505,
169851 /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, 170935 /* 340 */ 504, 112, 564, 570, 4, 929, 929, 435, 503, 342,
169852 /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, 170936 /* 350 */ 464, 330, 362, 396, 1238, 1193, 1194, 1193, 567, 572,
169853 /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, 170937 /* 360 */ 123, 123, 123, 123, 122, 122, 121, 121, 121, 120,
169854 /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, 170938 /* 370 */ 117, 448, 286, 286, 371, 1581, 1607, 445, 444, 155,
169855 /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, 170939 /* 380 */ 411, 449, 72, 72, 1289, 569, 1222, 1193, 1194, 1193,
169856 /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, 170940 /* 390 */ 86, 1224, 273, 561, 547, 520, 520, 572, 99, 1223,
169857 /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, 170941 /* 400 */ 6, 1281, 476, 143, 126, 127, 81, 1217, 1217, 1054,
169858 /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, 170942 /* 410 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 554,
169859 /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, 170943 /* 420 */ 13, 13, 1031, 511, 1225, 1193, 1225, 553, 110, 110,
169860 /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, 170944 /* 430 */ 224, 572, 1239, 177, 572, 429, 111, 199, 449, 573,
169861 /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, 170945 /* 440 */ 449, 432, 1555, 1019, 327, 555, 1193, 272, 289, 370,
169862 /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, 170946 /* 450 */ 514, 365, 513, 259, 72, 72, 547, 72, 72, 361,
169863 /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, 170947 /* 460 */ 318, 563, 1613, 123, 123, 123, 123, 122, 122, 121,
169864 /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, 170948 /* 470 */ 121, 121, 120, 117, 448, 1019, 1019, 1021, 1022, 28,
169865 /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, 170949 /* 480 */ 286, 286, 1193, 1194, 1193, 1159, 572, 1612, 411, 904,
169866 /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, 170950 /* 490 */ 192, 554, 358, 569, 554, 940, 537, 521, 1159, 437,
169867 /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, 170951 /* 500 */ 415, 1159, 556, 1193, 1194, 1193, 572, 548, 548, 52,
169868 /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 170952 /* 510 */ 52, 216, 126, 127, 81, 1217, 1217, 1054, 1057, 1044,
169869 /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, 170953 /* 520 */ 1044, 124, 124, 125, 125, 125, 125, 1193, 478, 136,
169870 /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, 170954 /* 530 */ 136, 411, 286, 286, 1493, 509, 122, 122, 121, 121,
169871 /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, 170955 /* 540 */ 121, 120, 117, 448, 1010, 569, 522, 219, 545, 545,
169872 /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, 170956 /* 550 */ 318, 563, 143, 6, 536, 126, 127, 81, 1217, 1217,
169873 /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 170957 /* 560 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125,
169874 /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, 170958 /* 570 */ 1557, 123, 123, 123, 123, 122, 122, 121, 121, 121,
169875 /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, 170959 /* 580 */ 120, 117, 448, 489, 1193, 1194, 1193, 486, 283, 1270,
169876 /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, 170960 /* 590 */ 960, 254, 1193, 375, 508, 505, 504, 1193, 342, 574,
169877 /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, 170961 /* 600 */ 1193, 574, 411, 294, 503, 960, 879, 193, 484, 318,
169878 /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, 170962 /* 610 */ 563, 386, 292, 382, 123, 123, 123, 123, 122, 122,
169879 /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, 170963 /* 620 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217,
169880 /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 170964 /* 630 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169881 /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, 170965 /* 640 */ 125, 411, 396, 1139, 1193, 872, 101, 286, 286, 1193,
169882 /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, 170966 /* 650 */ 1194, 1193, 375, 1096, 1193, 1194, 1193, 1193, 1194, 1193,
169883 /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, 170967 /* 660 */ 569, 459, 33, 375, 235, 126, 127, 81, 1217, 1217,
169884 /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 170968 /* 670 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125,
169885 /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, 170969 /* 680 */ 1437, 962, 572, 230, 961, 123, 123, 123, 123, 122,
169886 /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, 170970 /* 690 */ 122, 121, 121, 121, 120, 117, 448, 1159, 230, 1193,
169887 /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, 170971 /* 700 */ 158, 1193, 1194, 1193, 1556, 13, 13, 303, 960, 1233,
169888 /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, 170972 /* 710 */ 1159, 154, 411, 1159, 375, 1584, 1177, 5, 371, 1581,
169889 /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, 170973 /* 720 */ 431, 1239, 3, 960, 123, 123, 123, 123, 122, 122,
169890 /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, 170974 /* 730 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217,
169891 /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 170975 /* 740 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169892 /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, 170976 /* 750 */ 125, 411, 210, 571, 1193, 1032, 1193, 1194, 1193, 1193,
169893 /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, 170977 /* 760 */ 390, 855, 156, 1555, 376, 404, 1101, 1101, 492, 572,
169894 /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, 170978 /* 770 */ 469, 344, 1322, 1322, 1555, 126, 127, 81, 1217, 1217,
169895 /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 170979 /* 780 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125,
169896 /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, 170980 /* 790 */ 130, 572, 13, 13, 532, 123, 123, 123, 123, 122,
169897 /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, 170981 /* 800 */ 122, 121, 121, 121, 120, 117, 448, 304, 572, 457,
169898 /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, 170982 /* 810 */ 229, 1193, 1194, 1193, 13, 13, 1193, 1194, 1193, 1300,
169899 /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, 170983 /* 820 */ 467, 1270, 411, 1320, 1320, 1555, 1015, 457, 456, 436,
169900 /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, 170984 /* 830 */ 301, 72, 72, 1268, 123, 123, 123, 123, 122, 122,
169901 /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, 170985 /* 840 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217,
169902 /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 170986 /* 850 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169903 /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, 170987 /* 860 */ 125, 411, 384, 1076, 1159, 286, 286, 421, 314, 280,
169904 /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, 170988 /* 870 */ 280, 287, 287, 461, 408, 407, 1539, 1159, 569, 572,
169905 /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, 170989 /* 880 */ 1159, 1196, 569, 409, 569, 126, 127, 81, 1217, 1217,
169906 /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 170990 /* 890 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125,
169907 /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, 170991 /* 900 */ 457, 1485, 13, 13, 1541, 123, 123, 123, 123, 122,
169908 /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, 170992 /* 910 */ 122, 121, 121, 121, 120, 117, 448, 202, 572, 462,
169909 /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, 170993 /* 920 */ 1587, 578, 2, 1248, 843, 844, 845, 1563, 319, 409,
169910 /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, 170994 /* 930 */ 147, 6, 411, 257, 256, 255, 208, 1330, 9, 1196,
169911 /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, 170995 /* 940 */ 264, 72, 72, 1436, 123, 123, 123, 123, 122, 122,
169912 /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, 170996 /* 950 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217,
169913 /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 170997 /* 960 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169914 /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, 170998 /* 970 */ 125, 572, 286, 286, 572, 1213, 411, 577, 315, 1248,
169915 /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, 170999 /* 980 */ 421, 371, 1581, 356, 319, 569, 147, 495, 529, 1644,
169916 /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, 171000 /* 990 */ 397, 935, 495, 1330, 71, 71, 934, 72, 72, 242,
169917 /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 171001 /* 1000 */ 1328, 105, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124,
169918 /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, 171002 /* 1010 */ 124, 125, 125, 125, 125, 123, 123, 123, 123, 122,
169919 /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, 171003 /* 1020 */ 122, 121, 121, 121, 120, 117, 448, 1117, 286, 286,
169920 /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, 171004 /* 1030 */ 1422, 452, 1528, 1213, 443, 286, 286, 1492, 1355, 313,
169921 /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, 171005 /* 1040 */ 478, 569, 1118, 454, 351, 495, 354, 1266, 569, 209,
169922 /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, 171006 /* 1050 */ 572, 418, 179, 572, 1031, 242, 385, 1119, 523, 123,
169923 /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, 171007 /* 1060 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117,
169924 /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, 171008 /* 1070 */ 448, 1020, 108, 72, 72, 1019, 13, 13, 915, 572,
169925 /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, 171009 /* 1080 */ 1498, 572, 286, 286, 98, 530, 1537, 452, 916, 1334,
169926 /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, 171010 /* 1090 */ 1329, 203, 411, 286, 286, 569, 152, 211, 1498, 1500,
169927 /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, 171011 /* 1100 */ 426, 569, 56, 56, 57, 57, 569, 1019, 1019, 1021,
169928 /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, 171012 /* 1110 */ 447, 572, 411, 531, 12, 297, 126, 127, 81, 1217,
169929 /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 171013 /* 1120 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169930 /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, 171014 /* 1130 */ 125, 572, 411, 867, 15, 15, 126, 127, 81, 1217,
169931 /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 171015 /* 1140 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169932 /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, 171016 /* 1150 */ 125, 373, 529, 264, 44, 44, 126, 115, 81, 1217,
169933 /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 171017 /* 1160 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125,
169934 /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, 171018 /* 1170 */ 125, 1498, 478, 1271, 417, 123, 123, 123, 123, 122,
169935 /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, 171019 /* 1180 */ 122, 121, 121, 121, 120, 117, 448, 205, 1213, 495,
169936 /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, 171020 /* 1190 */ 430, 867, 468, 322, 495, 123, 123, 123, 123, 122,
169937 /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, 171021 /* 1200 */ 122, 121, 121, 121, 120, 117, 448, 572, 557, 1140,
169938 /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, 171022 /* 1210 */ 1642, 1422, 1642, 543, 572, 123, 123, 123, 123, 122,
169939 /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, 171023 /* 1220 */ 122, 121, 121, 121, 120, 117, 448, 572, 1422, 572,
169940 /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, 171024 /* 1230 */ 13, 13, 542, 323, 1325, 411, 334, 58, 58, 349,
169941 /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, 171025 /* 1240 */ 1422, 1170, 326, 286, 286, 549, 1213, 300, 895, 530,
169942 /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, 171026 /* 1250 */ 45, 45, 59, 59, 1140, 1643, 569, 1643, 565, 417,
169943 /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 171027 /* 1260 */ 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, 124,
169944 /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, 171028 /* 1270 */ 125, 125, 125, 125, 1367, 373, 500, 290, 1193, 512,
169945 /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, 171029 /* 1280 */ 1366, 427, 394, 394, 393, 275, 391, 896, 1138, 852,
169946 /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, 171030 /* 1290 */ 478, 258, 1422, 1170, 463, 1159, 12, 331, 428, 333,
169947 /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, 171031 /* 1300 */ 1117, 460, 236, 258, 325, 460, 544, 1544, 1159, 1098,
169948 /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, 171032 /* 1310 */ 491, 1159, 324, 1098, 440, 1118, 335, 516, 123, 123,
169949 /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, 171033 /* 1320 */ 123, 123, 122, 122, 121, 121, 121, 120, 117, 448,
169950 /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, 171034 /* 1330 */ 1119, 318, 563, 1138, 572, 1193, 1194, 1193, 112, 564,
169951 /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, 171035 /* 1340 */ 201, 4, 238, 433, 935, 490, 285, 228, 1517, 934,
169952 /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, 171036 /* 1350 */ 170, 560, 572, 142, 1516, 567, 572, 60, 60, 572,
169953 /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, 171037 /* 1360 */ 416, 572, 441, 572, 535, 302, 875, 8, 487, 572,
169954 /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, 171038 /* 1370 */ 237, 572, 416, 572, 485, 61, 61, 572, 449, 62,
169955 /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, 171039 /* 1380 */ 62, 332, 63, 63, 46, 46, 47, 47, 361, 572,
169956 /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, 171040 /* 1390 */ 561, 572, 48, 48, 50, 50, 51, 51, 572, 295,
169957 /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, 171041 /* 1400 */ 64, 64, 482, 295, 539, 412, 471, 1031, 572, 538,
169958 /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, 171042 /* 1410 */ 318, 563, 65, 65, 66, 66, 409, 475, 572, 1031,
169959 /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, 171043 /* 1420 */ 572, 14, 14, 875, 1020, 110, 110, 409, 1019, 572,
169960 /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, 171044 /* 1430 */ 474, 67, 67, 111, 455, 449, 573, 449, 98, 317,
169961 /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, 171045 /* 1440 */ 1019, 132, 132, 133, 133, 572, 1561, 572, 974, 409,
169962 /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, 171046 /* 1450 */ 6, 1562, 68, 68, 1560, 6, 975, 572, 6, 1559,
169963 /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, 171047 /* 1460 */ 1019, 1019, 1021, 6, 346, 218, 101, 531, 53, 53,
169964 /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, 171048 /* 1470 */ 69, 69, 1019, 1019, 1021, 1022, 28, 1586, 1181, 451,
169965 /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, 171049 /* 1480 */ 70, 70, 290, 87, 215, 31, 1363, 394, 394, 393,
169966 /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, 171050 /* 1490 */ 275, 391, 350, 109, 852, 107, 572, 112, 564, 483,
169967 /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, 171051 /* 1500 */ 4, 1212, 572, 239, 153, 572, 39, 236, 1299, 325,
169968 /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, 171052 /* 1510 */ 112, 564, 1298, 4, 567, 572, 32, 324, 572, 54,
169969 /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, 171053 /* 1520 */ 54, 572, 1135, 353, 398, 165, 165, 567, 166, 166,
169970 /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, 171054 /* 1530 */ 572, 291, 355, 572, 17, 357, 572, 449, 77, 77,
169971 /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, 171055 /* 1540 */ 1313, 55, 55, 1297, 73, 73, 572, 238, 470, 561,
169972 /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, 171056 /* 1550 */ 449, 472, 364, 135, 135, 170, 74, 74, 142, 163,
169973 /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, 171057 /* 1560 */ 163, 374, 561, 539, 572, 321, 572, 886, 540, 137,
169974 /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, 171058 /* 1570 */ 137, 339, 1353, 422, 298, 237, 539, 572, 1031, 572,
169975 /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, 171059 /* 1580 */ 340, 538, 101, 369, 110, 110, 162, 131, 131, 164,
169976 /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, 171060 /* 1590 */ 164, 1031, 111, 368, 449, 573, 449, 110, 110, 1019,
169977 /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, 171061 /* 1600 */ 157, 157, 141, 141, 572, 111, 572, 449, 573, 449,
169978 /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, 171062 /* 1610 */ 412, 288, 1019, 572, 882, 318, 563, 572, 219, 572,
169979 /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, 171063 /* 1620 */ 241, 1012, 477, 263, 263, 894, 893, 140, 140, 138,
169980 /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, 171064 /* 1630 */ 138, 1019, 1019, 1021, 1022, 28, 139, 139, 525, 455,
169981 /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, 171065 /* 1640 */ 76, 76, 78, 78, 1019, 1019, 1021, 1022, 28, 1181,
169982 /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, 171066 /* 1650 */ 451, 572, 1083, 290, 112, 564, 1575, 4, 394, 394,
169983 /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, 171067 /* 1660 */ 393, 275, 391, 572, 1023, 852, 572, 479, 345, 263,
169984 /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, 171068 /* 1670 */ 101, 567, 882, 1376, 75, 75, 1421, 501, 236, 260,
169985 /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, 171069 /* 1680 */ 325, 112, 564, 359, 4, 101, 43, 43, 324, 49,
169986 /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, 171070 /* 1690 */ 49, 901, 902, 161, 449, 101, 977, 978, 567, 1079,
169987 /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, 171071 /* 1700 */ 1349, 260, 965, 932, 263, 114, 561, 1095, 517, 1095,
169988 /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, 171072 /* 1710 */ 1083, 1094, 865, 1094, 151, 933, 1144, 114, 238, 1361,
169989 /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, 171073 /* 1720 */ 558, 449, 1023, 559, 1426, 1278, 170, 1269, 1257, 142,
169990 /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, 171074 /* 1730 */ 1601, 1256, 1258, 561, 1594, 1031, 496, 278, 213, 1346,
169991 /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, 171075 /* 1740 */ 310, 110, 110, 939, 311, 312, 237, 11, 234, 111,
169992 /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, 171076 /* 1750 */ 221, 449, 573, 449, 293, 395, 1019, 1408, 337, 1403,
169993 /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, 171077 /* 1760 */ 1396, 338, 1031, 299, 343, 1413, 1412, 481, 110, 110,
169994 /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, 171078 /* 1770 */ 506, 402, 225, 1296, 206, 367, 111, 1358, 449, 573,
169995 /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, 171079 /* 1780 */ 449, 412, 1359, 1019, 1489, 1488, 318, 563, 1019, 1019,
169996 /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, 171080 /* 1790 */ 1021, 1022, 28, 562, 207, 220, 80, 564, 389, 4,
169997 /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, 171081 /* 1800 */ 1597, 1357, 552, 1356, 1233, 181, 267, 232, 1536, 1534,
169998 /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, 171082 /* 1810 */ 455, 1230, 420, 567, 82, 1019, 1019, 1021, 1022, 28,
169999 /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, 171083 /* 1820 */ 86, 217, 85, 1494, 190, 175, 183, 465, 185, 466,
170000 /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, 171084 /* 1830 */ 36, 1409, 186, 187, 188, 499, 449, 244, 37, 99,
170001 /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, 171085 /* 1840 */ 400, 1415, 1414, 488, 1417, 194, 473, 403, 561, 1483,
170002 /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, 171086 /* 1850 */ 248, 92, 1505, 494, 198, 279, 112, 564, 250, 4,
170003 /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, 171087 /* 1860 */ 348, 497, 405, 352, 1259, 251, 252, 515, 1316, 434,
170004 /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, 171088 /* 1870 */ 1315, 1314, 94, 567, 1307, 886, 1306, 1031, 226, 406,
170005 /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, 171089 /* 1880 */ 1611, 1610, 438, 110, 110, 1580, 1286, 524, 439, 308,
170006 /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, 171090 /* 1890 */ 266, 111, 1285, 449, 573, 449, 449, 309, 1019, 366,
170007 /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, 171091 /* 1900 */ 1284, 1609, 265, 1566, 1565, 442, 372, 1381, 561, 129,
170008 /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, 171092 /* 1910 */ 550, 1380, 10, 1470, 383, 106, 316, 551, 100, 35,
170009 /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, 171093 /* 1920 */ 534, 575, 212, 1339, 381, 387, 1187, 1338, 274, 276,
170010 /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, 171094 /* 1930 */ 1019, 1019, 1021, 1022, 28, 277, 413, 1031, 576, 1254,
170011 /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, 171095 /* 1940 */ 388, 1521, 1249, 110, 110, 167, 1522, 168, 148, 1520,
170012 /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, 171096 /* 1950 */ 1519, 111, 306, 449, 573, 449, 222, 223, 1019, 839,
170013 /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, 171097 /* 1960 */ 169, 79, 450, 214, 414, 233, 320, 145, 1093, 1091,
170014 /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, 171098 /* 1970 */ 328, 182, 171, 1212, 918, 184, 240, 336, 243, 1107,
170015 /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, 171099 /* 1980 */ 189, 172, 173, 423, 425, 88, 180, 191, 89, 90,
170016 /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, 171100 /* 1990 */ 1019, 1019, 1021, 1022, 28, 91, 174, 1110, 245, 1106,
170017 /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, 171101 /* 2000 */ 246, 159, 18, 247, 347, 1099, 263, 195, 1227, 493,
170018 /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, 171102 /* 2010 */ 249, 196, 38, 854, 498, 368, 253, 360, 897, 197,
170019 /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, 171103 /* 2020 */ 502, 93, 19, 20, 507, 884, 363, 510, 95, 307,
170020 /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, 171104 /* 2030 */ 160, 96, 518, 97, 1175, 1060, 1146, 40, 21, 227,
170021 /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, 171105 /* 2040 */ 176, 1145, 282, 284, 969, 200, 963, 114, 262, 1165,
170022 /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, 171106 /* 2050 */ 22, 23, 24, 1161, 1169, 25, 1163, 1150, 34, 26,
170023 /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, 171107 /* 2060 */ 1168, 546, 27, 204, 101, 103, 104, 1074, 7, 1061,
170024 /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, 171108 /* 2070 */ 1059, 1063, 1116, 1064, 1115, 268, 269, 29, 41, 270,
170025 /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 171109 /* 2080 */ 1024, 866, 113, 30, 568, 392, 1183, 144, 178, 1182,
170026 /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, 171110 /* 2090 */ 271, 928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602,
170027}; 171111};
170028static const YYCODETYPE yy_lookahead[] = { 171112static const YYCODETYPE yy_lookahead[] = {
170029 /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, 171113 /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276,
@@ -170102,7 +171186,7 @@ static const YYCODETYPE yy_lookahead[] = {
170102 /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, 171186 /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
170103 /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171187 /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170104 /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, 171188 /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59,
170105 /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, 171189 /* 760 */ 201, 21, 241, 304, 193, 206, 127, 128, 129, 193,
170106 /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, 171190 /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47,
170107 /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 171191 /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
170108 /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, 171192 /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106,
@@ -170113,129 +171197,129 @@ static const YYCODETYPE yy_lookahead[] = {
170113 /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, 171197 /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
170114 /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171198 /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170115 /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, 171199 /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239,
170116 /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, 171200 /* 870 */ 240, 239, 240, 244, 106, 107, 193, 89, 252, 193,
170117 /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, 171201 /* 880 */ 92, 59, 252, 254, 252, 43, 44, 45, 46, 47,
170118 /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 171202 /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
170119 /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, 171203 /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106,
170120 /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, 171204 /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 244,
170121 /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, 171205 /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 254,
170122 /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, 171206 /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117,
170123 /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, 171207 /* 940 */ 24, 216, 217, 273, 102, 103, 104, 105, 106, 107,
170124 /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, 171208 /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
170125 /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171209 /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170126 /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, 171210 /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190,
170127 /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, 171211 /* 980 */ 193, 311, 312, 16, 195, 252, 197, 193, 19, 301,
170128 /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, 171212 /* 990 */ 302, 135, 193, 204, 216, 217, 140, 216, 217, 266,
170129 /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, 171213 /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52,
170130 /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, 171214 /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106,
170131 /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, 171215 /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240,
170132 /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, 171216 /* 1030 */ 193, 298, 238, 117, 253, 239, 240, 238, 259, 260,
170133 /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, 171217 /* 1040 */ 193, 252, 27, 193, 77, 193, 79, 204, 252, 262,
170134 /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, 171218 /* 1050 */ 193, 299, 300, 193, 100, 266, 278, 42, 204, 102,
170135 /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 171219 /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
170136 /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, 171220 /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193,
170137 /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, 171221 /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 240,
170138 /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, 171222 /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212,
170139 /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, 171223 /* 1100 */ 263, 252, 216, 217, 216, 217, 252, 153, 154, 155,
170140 /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, 171224 /* 1110 */ 253, 193, 19, 144, 213, 268, 43, 44, 45, 46,
170141 /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171225 /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170142 /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, 171226 /* 1130 */ 57, 193, 19, 59, 216, 217, 43, 44, 45, 46,
170143 /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171227 /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170144 /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, 171228 /* 1150 */ 57, 193, 19, 24, 216, 217, 43, 44, 45, 46,
170145 /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 171229 /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
170146 /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, 171230 /* 1170 */ 57, 284, 193, 208, 209, 102, 103, 104, 105, 106,
170147 /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, 171231 /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 59, 193,
170148 /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, 171232 /* 1190 */ 232, 117, 291, 193, 193, 102, 103, 104, 105, 106,
170149 /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, 171233 /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 193, 204, 22,
170150 /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, 171234 /* 1210 */ 23, 193, 25, 66, 193, 102, 103, 104, 105, 106,
170151 /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, 171235 /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 193, 193,
170152 /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, 171236 /* 1230 */ 216, 217, 85, 193, 238, 19, 16, 216, 217, 238,
170153 /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, 171237 /* 1240 */ 193, 94, 193, 239, 240, 231, 117, 268, 35, 116,
170154 /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, 171238 /* 1250 */ 216, 217, 216, 217, 22, 23, 252, 25, 208, 209,
170155 /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 171239 /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
170156 /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, 171240 /* 1270 */ 54, 55, 56, 57, 193, 193, 19, 5, 59, 66,
170157 /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, 171241 /* 1280 */ 193, 263, 10, 11, 12, 13, 14, 74, 101, 17,
170158 /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, 171242 /* 1290 */ 193, 46, 193, 146, 193, 76, 213, 77, 263, 79,
170159 /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, 171243 /* 1300 */ 12, 260, 30, 46, 32, 264, 87, 193, 89, 29,
170160 /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, 171244 /* 1310 */ 263, 92, 40, 33, 232, 27, 193, 108, 102, 103,
170161 /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 171245 /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
170162 /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, 171246 /* 1330 */ 42, 138, 139, 101, 193, 116, 117, 118, 19, 20,
170163 /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, 171247 /* 1340 */ 255, 22, 70, 130, 135, 65, 256, 257, 193, 140,
170164 /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, 171248 /* 1350 */ 78, 63, 193, 81, 193, 36, 193, 216, 217, 193,
170165 /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, 171249 /* 1360 */ 115, 193, 263, 193, 145, 268, 59, 48, 193, 193,
170166 /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, 171250 /* 1370 */ 98, 193, 115, 193, 291, 216, 217, 193, 59, 216,
170167 /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, 171251 /* 1380 */ 217, 161, 216, 217, 216, 217, 216, 217, 131, 193,
170168 /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, 171252 /* 1390 */ 71, 193, 216, 217, 216, 217, 216, 217, 193, 260,
170169 /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, 171253 /* 1400 */ 216, 217, 19, 264, 85, 133, 244, 100, 193, 90,
170170 /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, 171254 /* 1410 */ 138, 139, 216, 217, 216, 217, 254, 244, 193, 100,
170171 /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, 171255 /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 254, 121, 193,
170172 /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, 171256 /* 1430 */ 115, 216, 217, 114, 162, 116, 117, 118, 115, 244,
170173 /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, 171257 /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 193, 31, 254,
170174 /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, 171258 /* 1450 */ 313, 309, 216, 217, 309, 313, 39, 193, 313, 309,
170175 /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, 171259 /* 1460 */ 153, 154, 155, 313, 193, 150, 25, 144, 216, 217,
170176 /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, 171260 /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2,
170177 /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, 171261 /* 1480 */ 216, 217, 5, 149, 150, 22, 193, 10, 11, 12,
170178 /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, 171262 /* 1490 */ 13, 14, 193, 158, 17, 160, 193, 19, 20, 116,
170179 /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, 171263 /* 1500 */ 22, 25, 193, 24, 22, 193, 24, 30, 226, 32,
170180 /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, 171264 /* 1510 */ 19, 20, 226, 22, 36, 193, 53, 40, 193, 216,
170181 /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, 171265 /* 1520 */ 217, 193, 23, 193, 25, 216, 217, 36, 216, 217,
170182 /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, 171266 /* 1530 */ 193, 99, 193, 193, 22, 193, 193, 59, 216, 217,
170183 /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, 171267 /* 1540 */ 193, 216, 217, 193, 216, 217, 193, 70, 129, 71,
170184 /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, 171268 /* 1550 */ 59, 129, 193, 216, 217, 78, 216, 217, 81, 216,
170185 /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, 171269 /* 1560 */ 217, 193, 71, 85, 193, 133, 193, 126, 90, 216,
170186 /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, 171270 /* 1570 */ 217, 152, 258, 61, 152, 98, 85, 193, 100, 193,
170187 /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, 171271 /* 1580 */ 23, 90, 25, 121, 106, 107, 23, 216, 217, 216,
170188 /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, 171272 /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121,
170189 /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, 171273 /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118,
170190 /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, 171274 /* 1610 */ 133, 22, 121, 193, 59, 138, 139, 193, 142, 193,
170191 /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, 171275 /* 1620 */ 141, 23, 23, 25, 25, 120, 121, 216, 217, 216,
170192 /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 193, 162, 171276 /* 1630 */ 217, 153, 154, 155, 156, 157, 216, 217, 19, 162,
170193 /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, 171277 /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1,
170194 /* 1650 */ 2, 193, 193, 5, 19, 20, 59, 22, 10, 11, 171278 /* 1650 */ 2, 193, 59, 5, 19, 20, 318, 22, 10, 11,
170195 /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 193, 25, 171279 /* 1660 */ 12, 13, 14, 193, 59, 17, 193, 23, 23, 25,
170196 /* 1670 */ 288, 36, 193, 242, 216, 217, 236, 23, 30, 25, 171280 /* 1670 */ 25, 36, 117, 193, 216, 217, 193, 23, 30, 25,
170197 /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, 171281 /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216,
170198 /* 1690 */ 217, 216, 217, 193, 59, 216, 217, 193, 36, 83, 171282 /* 1690 */ 217, 7, 8, 23, 59, 25, 83, 84, 36, 23,
170199 /* 1700 */ 84, 153, 153, 155, 155, 23, 71, 25, 23, 193, 171283 /* 1700 */ 193, 25, 23, 23, 25, 25, 71, 153, 145, 155,
170200 /* 1710 */ 25, 193, 193, 193, 117, 193, 193, 193, 70, 193, 171284 /* 1710 */ 117, 153, 23, 155, 25, 23, 97, 25, 70, 193,
170201 /* 1720 */ 193, 59, 193, 255, 255, 287, 78, 255, 243, 81, 171285 /* 1720 */ 193, 59, 117, 236, 193, 193, 78, 193, 193, 81,
170202 /* 1730 */ 191, 255, 297, 71, 271, 100, 293, 245, 267, 214, 171286 /* 1730 */ 141, 193, 193, 71, 193, 100, 288, 287, 242, 255,
170203 /* 1740 */ 246, 106, 107, 108, 246, 271, 98, 245, 293, 114, 171287 /* 1740 */ 255, 106, 107, 108, 255, 255, 98, 243, 297, 114,
170204 /* 1750 */ 220, 116, 117, 118, 267, 271, 121, 271, 225, 219, 171288 /* 1750 */ 214, 116, 117, 118, 245, 191, 121, 271, 293, 267,
170205 /* 1760 */ 229, 219, 100, 219, 259, 259, 259, 259, 106, 107, 171289 /* 1760 */ 267, 246, 100, 246, 245, 271, 271, 293, 106, 107,
170206 /* 1770 */ 249, 196, 60, 280, 141, 243, 114, 249, 116, 117, 171290 /* 1770 */ 220, 271, 229, 225, 249, 219, 114, 259, 116, 117,
170207 /* 1780 */ 118, 133, 245, 121, 200, 297, 138, 139, 153, 154, 171291 /* 1780 */ 118, 133, 259, 121, 219, 219, 138, 139, 153, 154,
170208 /* 1790 */ 155, 156, 157, 297, 200, 38, 19, 20, 151, 22, 171292 /* 1790 */ 155, 156, 157, 280, 249, 243, 19, 20, 245, 22,
170209 /* 1800 */ 200, 150, 140, 294, 294, 22, 272, 43, 234, 18, 171293 /* 1800 */ 196, 259, 140, 259, 60, 297, 141, 297, 200, 200,
170210 /* 1810 */ 162, 270, 200, 36, 237, 153, 154, 155, 156, 157, 171294 /* 1810 */ 162, 38, 200, 36, 294, 153, 154, 155, 156, 157,
170211 /* 1820 */ 237, 283, 237, 237, 18, 199, 149, 246, 272, 270, 171295 /* 1820 */ 151, 150, 294, 283, 22, 43, 234, 18, 237, 200,
170212 /* 1830 */ 272, 200, 158, 246, 246, 234, 59, 234, 246, 199, 171296 /* 1830 */ 270, 272, 237, 237, 237, 18, 59, 199, 270, 149,
170213 /* 1840 */ 290, 62, 289, 200, 199, 22, 221, 115, 71, 200, 171297 /* 1840 */ 246, 272, 272, 200, 234, 234, 246, 246, 71, 246,
170214 /* 1850 */ 200, 199, 199, 221, 218, 218, 19, 20, 64, 22, 171298 /* 1850 */ 199, 158, 290, 62, 22, 200, 19, 20, 199, 22,
170215 /* 1860 */ 218, 227, 22, 224, 126, 224, 165, 221, 24, 305, 171299 /* 1860 */ 289, 221, 221, 200, 200, 199, 199, 115, 218, 64,
170216 /* 1870 */ 200, 113, 312, 36, 218, 220, 218, 100, 282, 218, 171300 /* 1870 */ 218, 218, 22, 36, 227, 126, 227, 100, 165, 221,
170217 /* 1880 */ 91, 218, 317, 106, 107, 221, 227, 282, 317, 82, 171301 /* 1880 */ 224, 224, 24, 106, 107, 312, 218, 305, 113, 282,
170218 /* 1890 */ 148, 114, 265, 116, 117, 118, 59, 145, 121, 22, 171302 /* 1890 */ 91, 114, 220, 116, 117, 118, 59, 282, 121, 218,
170219 /* 1900 */ 277, 158, 200, 265, 25, 202, 147, 250, 71, 279, 171303 /* 1900 */ 218, 218, 200, 317, 317, 82, 221, 265, 71, 148,
170220 /* 1910 */ 13, 146, 194, 194, 249, 248, 250, 140, 247, 246, 171304 /* 1910 */ 145, 265, 22, 277, 200, 158, 279, 140, 147, 25,
170221 /* 1920 */ 6, 192, 192, 192, 303, 303, 213, 207, 300, 213, 171305 /* 1920 */ 146, 202, 248, 250, 249, 247, 13, 250, 194, 194,
170222 /* 1930 */ 153, 154, 155, 156, 157, 213, 213, 100, 213, 222, 171306 /* 1930 */ 153, 154, 155, 156, 157, 6, 303, 100, 192, 192,
170223 /* 1940 */ 207, 214, 214, 106, 107, 4, 222, 207, 3, 22, 171307 /* 1940 */ 246, 213, 192, 106, 107, 207, 213, 207, 222, 213,
170224 /* 1950 */ 163, 114, 15, 116, 117, 118, 16, 23, 121, 23, 171308 /* 1950 */ 213, 114, 222, 116, 117, 118, 214, 214, 121, 4,
170225 /* 1960 */ 139, 151, 130, 25, 142, 16, 24, 20, 144, 1, 171309 /* 1960 */ 207, 213, 3, 22, 303, 15, 163, 16, 23, 23,
170226 /* 1970 */ 142, 130, 130, 61, 53, 53, 37, 151, 53, 53, 171310 /* 1970 */ 139, 151, 130, 25, 20, 142, 24, 16, 144, 1,
170227 /* 1980 */ 130, 116, 34, 1, 141, 5, 22, 115, 161, 141, 171311 /* 1980 */ 142, 130, 130, 61, 37, 53, 300, 151, 53, 53,
170228 /* 1990 */ 153, 154, 155, 156, 157, 25, 68, 68, 75, 41, 171312 /* 1990 */ 153, 154, 155, 156, 157, 53, 130, 116, 34, 1,
170229 /* 2000 */ 115, 24, 131, 20, 19, 125, 22, 96, 22, 22, 171313 /* 2000 */ 141, 5, 22, 115, 161, 68, 25, 68, 75, 41,
170230 /* 2010 */ 67, 23, 22, 67, 59, 24, 22, 28, 67, 23, 171314 /* 2010 */ 141, 115, 24, 20, 19, 131, 125, 23, 28, 22,
170231 /* 2020 */ 22, 22, 149, 23, 23, 23, 116, 23, 25, 37, 171315 /* 2020 */ 67, 22, 22, 22, 67, 59, 24, 96, 22, 67,
170232 /* 2030 */ 97, 141, 23, 23, 22, 143, 25, 75, 88, 34, 171316 /* 2030 */ 23, 149, 22, 25, 23, 23, 23, 22, 34, 141,
170233 /* 2040 */ 34, 34, 34, 86, 75, 93, 23, 34, 22, 34, 171317 /* 2040 */ 37, 97, 23, 23, 116, 22, 143, 25, 34, 75,
170234 /* 2050 */ 25, 24, 34, 25, 23, 142, 23, 142, 44, 23, 171318 /* 2050 */ 34, 34, 34, 88, 75, 34, 86, 23, 22, 34,
170235 /* 2060 */ 23, 23, 11, 23, 25, 22, 22, 22, 15, 23, 171319 /* 2060 */ 93, 24, 34, 25, 25, 142, 142, 23, 44, 23,
170236 /* 2070 */ 23, 22, 22, 25, 1, 1, 141, 25, 23, 135, 171320 /* 2070 */ 23, 23, 23, 11, 23, 25, 22, 22, 22, 141,
170237 /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171321 /* 2080 */ 23, 23, 22, 22, 25, 15, 1, 23, 25, 1,
170238 /* 2090 */ 319, 319, 319, 319, 141, 141, 319, 319, 319, 319, 171322 /* 2090 */ 141, 135, 319, 319, 319, 319, 319, 319, 319, 141,
170239 /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171323 /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
170240 /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171324 /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
170241 /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171325 /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
@@ -170254,176 +171338,177 @@ static const YYCODETYPE yy_lookahead[] = {
170254 /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171338 /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
170255 /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171339 /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
170256 /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 171340 /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
170257 /* 2280 */ 319, 171341 /* 2280 */ 319, 319, 319, 319, 319,
170258}; 171342};
170259#define YY_SHIFT_COUNT (574) 171343#define YY_SHIFT_COUNT (578)
170260#define YY_SHIFT_MIN (0) 171344#define YY_SHIFT_MIN (0)
170261#define YY_SHIFT_MAX (2074) 171345#define YY_SHIFT_MAX (2088)
170262static const unsigned short int yy_shift_ofst[] = { 171346static const unsigned short int yy_shift_ofst[] = {
170263 /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, 171347 /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837,
170264 /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, 171348 /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837,
170265 /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171349 /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170266 /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, 171350 /* 30 */ 1837, 271, 271, 1219, 1219, 216, 88, 1, 1, 1,
170267 /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, 171351 /* 40 */ 1, 1, 40, 111, 258, 361, 469, 512, 583, 622,
170268 /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, 171352 /* 50 */ 693, 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093,
170269 /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 171353 /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
170270 /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, 171354 /* 70 */ 1093, 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635,
170271 /* 80 */ 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171355 /* 80 */ 1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170272 /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171356 /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170273 /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171357 /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170274 /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171358 /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170275 /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 171359 /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
170276 /* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430, 171360 /* 130 */ 1837, 137, 181, 181, 181, 181, 181, 181, 181, 94,
170277 /* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533, 171361 /* 140 */ 430, 66, 65, 112, 366, 533, 533, 740, 1257, 533,
170278 /* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113, 171362 /* 150 */ 533, 79, 79, 533, 412, 412, 412, 77, 412, 123,
170279 /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468, 171363 /* 160 */ 113, 113, 113, 22, 22, 2100, 2100, 328, 328, 328,
170280 /* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533, 171364 /* 170 */ 239, 468, 468, 468, 468, 1015, 1015, 409, 366, 1187,
170281 /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 171365 /* 180 */ 1232, 533, 533, 533, 533, 533, 533, 533, 533, 533,
170282 /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969, 171366 /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533,
170283 /* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822, 171367 /* 200 */ 533, 969, 621, 621, 533, 642, 788, 788, 1133, 1133,
170284 /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307, 171368 /* 210 */ 822, 822, 67, 1193, 2100, 2100, 2100, 2100, 2100, 2100,
170285 /* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700, 171369 /* 220 */ 2100, 1307, 954, 954, 585, 472, 640, 387, 695, 538,
170286 /* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 171370 /* 230 */ 541, 700, 533, 533, 533, 533, 533, 533, 533, 533,
170287 /* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533, 171371 /* 240 */ 533, 533, 222, 533, 533, 533, 533, 533, 533, 533,
170288 /* 250 */ 533, 533, 533, 1179, 1179, 1179, 533, 533, 533, 565, 171372 /* 250 */ 533, 533, 533, 533, 533, 1213, 1213, 1213, 533, 533,
170289 /* 260 */ 533, 533, 533, 916, 1144, 533, 533, 1288, 533, 533, 171373 /* 260 */ 533, 565, 533, 533, 533, 916, 1147, 533, 533, 1288,
170290 /* 270 */ 533, 533, 533, 533, 533, 533, 639, 1330, 209, 1076, 171374 /* 270 */ 533, 533, 533, 533, 533, 533, 533, 533, 639, 1280,
170291 /* 280 */ 1076, 1076, 1076, 580, 209, 209, 1313, 768, 917, 649, 171375 /* 280 */ 209, 1129, 1129, 1129, 1129, 580, 209, 209, 1209, 768,
170292 /* 290 */ 1181, 1316, 405, 1316, 1238, 249, 1181, 1181, 249, 1181, 171376 /* 290 */ 917, 649, 1315, 1334, 405, 1334, 1383, 249, 1315, 1315,
170293 /* 300 */ 405, 1238, 1369, 464, 1259, 1012, 1012, 1012, 1368, 1368, 171377 /* 300 */ 249, 1315, 405, 1383, 1441, 464, 1245, 1417, 1417, 1417,
170294 /* 310 */ 1368, 1368, 184, 184, 1326, 904, 1287, 1480, 1712, 1712, 171378 /* 310 */ 1323, 1323, 1323, 1323, 184, 184, 1335, 1476, 856, 1482,
170295 /* 320 */ 1633, 1633, 1757, 1757, 1633, 1647, 1651, 1783, 1764, 1791, 171379 /* 320 */ 1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802,
170296 /* 330 */ 1791, 1791, 1791, 1633, 1806, 1677, 1651, 1651, 1677, 1783, 171380 /* 330 */ 1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671,
170297 /* 340 */ 1764, 1677, 1764, 1677, 1633, 1806, 1674, 1779, 1633, 1806, 171381 /* 340 */ 1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791,
170298 /* 350 */ 1823, 1633, 1806, 1633, 1806, 1823, 1732, 1732, 1732, 1794, 171382 /* 350 */ 1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752,
170299 /* 360 */ 1840, 1840, 1823, 1732, 1738, 1732, 1794, 1732, 1732, 1701, 171383 /* 360 */ 1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752,
170300 /* 370 */ 1844, 1758, 1758, 1823, 1633, 1789, 1789, 1807, 1807, 1742, 171384 /* 370 */ 1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823,
170301 /* 380 */ 1752, 1877, 1633, 1743, 1742, 1759, 1765, 1677, 1879, 1897, 171385 /* 380 */ 1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690,
170302 /* 390 */ 1897, 1914, 1914, 1914, 2096, 2096, 2096, 2096, 2096, 2096, 171386 /* 390 */ 1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100,
170303 /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 207, 171387 /* 400 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100,
170304 /* 410 */ 1095, 331, 620, 903, 806, 1074, 1483, 1432, 1481, 1322, 171388 /* 410 */ 2100, 207, 1220, 331, 620, 967, 806, 1074, 1499, 1432,
170305 /* 420 */ 1370, 1394, 1515, 1291, 1546, 1547, 1557, 1595, 1598, 1599, 171389 /* 420 */ 1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645,
170306 /* 430 */ 1434, 1453, 1618, 1462, 1567, 1489, 1644, 1654, 1616, 1660, 171390 /* 430 */ 1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593,
170307 /* 440 */ 1548, 1549, 1682, 1685, 1597, 742, 1941, 1945, 1927, 1787, 171391 /* 440 */ 1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589,
170308 /* 450 */ 1937, 1940, 1934, 1936, 1821, 1810, 1832, 1938, 1938, 1942, 171392 /* 450 */ 1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820,
170309 /* 460 */ 1822, 1947, 1824, 1949, 1968, 1828, 1841, 1938, 1842, 1912, 171393 /* 460 */ 1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838,
170310 /* 470 */ 1939, 1938, 1826, 1921, 1922, 1925, 1926, 1850, 1865, 1948, 171394 /* 470 */ 1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936,
170311 /* 480 */ 1843, 1982, 1980, 1964, 1872, 1827, 1928, 1970, 1929, 1923, 171395 /* 480 */ 1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843,
170312 /* 490 */ 1958, 1848, 1885, 1977, 1983, 1985, 1871, 1880, 1984, 1943, 171396 /* 490 */ 1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995,
170313 /* 500 */ 1986, 1987, 1988, 1990, 1946, 1955, 1991, 1911, 1989, 1994, 171397 /* 500 */ 1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966,
170314 /* 510 */ 1951, 1992, 1996, 1873, 1998, 2000, 2001, 2002, 2003, 2004, 171398 /* 510 */ 2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010,
170315 /* 520 */ 1999, 1933, 1890, 2009, 2010, 1910, 2005, 2012, 1892, 2011, 171399 /* 520 */ 2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928,
170316 /* 530 */ 2006, 2007, 2008, 2013, 1950, 1962, 1957, 2014, 1969, 1952, 171400 /* 530 */ 2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974,
170317 /* 540 */ 2015, 2023, 2026, 2027, 2025, 2028, 2018, 1913, 1915, 2031, 171401 /* 540 */ 1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039,
170318 /* 550 */ 2011, 2033, 2036, 2037, 2038, 2039, 2040, 2043, 2051, 2044, 171402 /* 550 */ 2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050,
170319 /* 560 */ 2045, 2046, 2047, 2049, 2050, 2048, 1944, 1935, 1953, 1954, 171403 /* 560 */ 2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059,
170320 /* 570 */ 2052, 2055, 2053, 2073, 2074, 171404 /* 570 */ 1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088,
170321}; 171405};
170322#define YY_REDUCE_COUNT (408) 171406#define YY_REDUCE_COUNT (410)
170323#define YY_REDUCE_MIN (-271) 171407#define YY_REDUCE_MIN (-271)
170324#define YY_REDUCE_MAX (1740) 171408#define YY_REDUCE_MAX (1753)
170325static const short yy_reduce_ofst[] = { 171409static const short yy_reduce_ofst[] = {
170326 /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, 171410 /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187,
170327 /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, 171411 /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489,
170328 /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, 171412 /* 20 */ 576, 598, -175, 686, 860, 615, 725, 1014, 778, 781,
170329 /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, 171413 /* 30 */ 857, 616, 887, 87, 240, -192, 408, 626, 796, 843,
170330 /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, 171414 /* 40 */ 854, 1004, -271, -271, -271, -271, -271, -271, -271, -271,
170331 /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, 171415 /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
170332 /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, 171416 /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
170333 /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, 171417 /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, 80,
170334 /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, 171418 /* 80 */ 83, 313, 886, 888, 918, 938, 1021, 1034, 1036, 1141,
170335 /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, 171419 /* 90 */ 1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196,
170336 /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, 171420 /* 100 */ 1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303,
170337 /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, 171421 /* 110 */ 1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371,
170338 /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, 1475, 1479, 171422 /* 120 */ 1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470,
170339 /* 130 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, 171423 /* 130 */ 1473, -271, -271, -271, -271, -271, -271, -271, -271, -271,
170340 /* 140 */ -271, 138, 459, 396, -158, 470, 302, -212, 521, 201, 171424 /* 140 */ -271, -271, 138, 459, 396, -158, 470, 302, -212, 521,
170341 /* 150 */ -195, -92, 559, 630, 632, 630, -271, 632, 901, 63, 171425 /* 150 */ 201, -195, -92, 559, 630, 632, 630, -271, 632, 901,
170342 /* 160 */ 407, -271, -271, -271, -271, 161, 161, 161, 251, 335, 171426 /* 160 */ 63, 407, 670, -271, -271, -271, -271, 161, 161, 161,
170343 /* 170 */ 847, 960, 980, 537, 588, 618, 628, 688, 688, -166, 171427 /* 170 */ 251, 335, 847, 979, 1097, 537, 588, 618, 628, 688,
170344 /* 180 */ -161, 674, 790, 794, 799, 851, 852, -122, 680, -120, 171428 /* 180 */ 688, -166, -161, 674, 787, 794, 799, 852, 996, -122,
170345 /* 190 */ 995, 1038, 415, 1051, 893, 798, 962, 400, 1086, 779, 171429 /* 190 */ 837, -120, 1018, 1035, 415, 1047, 1001, 958, 1082, 400,
170346 /* 200 */ 923, 924, 263, 1041, 979, 990, 1083, 1097, 1031, 1194, 171430 /* 200 */ 1099, 779, 1137, 1142, 263, 1083, 1145, 1150, 1041, 1139,
170347 /* 210 */ 362, 994, 1139, 1005, 1037, 1202, 1205, 1195, 1210, -194, 171431 /* 210 */ 965, 1050, 362, 849, 752, 629, 675, 1162, 1173, 1090,
170348 /* 220 */ 56, 185, -135, 232, 522, 560, 601, 617, 669, 683, 171432 /* 220 */ 1195, -194, 56, 185, -135, 232, 522, 560, 571, 601,
170349 /* 230 */ 711, 856, 908, 941, 1048, 1101, 1147, 1257, 1262, 1265, 171433 /* 230 */ 617, 669, 683, 711, 850, 893, 1000, 1040, 1049, 1081,
170350 /* 240 */ 392, 1292, 1333, 1339, 1342, 1346, 1350, 1359, 1374, 1418, 171434 /* 240 */ 1087, 1101, 392, 1114, 1123, 1155, 1161, 1175, 1271, 1293,
170351 /* 250 */ 1421, 1436, 1437, 593, 755, 770, 997, 1445, 1459, 1209, 171435 /* 250 */ 1299, 1330, 1339, 1342, 1347, 593, 1282, 1286, 1350, 1359,
170352 /* 260 */ 1500, 1504, 1516, 1132, 1243, 1518, 1519, 1440, 1520, 560, 171436 /* 260 */ 1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487,
170353 /* 270 */ 1522, 1523, 1524, 1526, 1527, 1529, 1382, 1438, 1431, 1468, 171437 /* 270 */ 1531, 560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450,
170354 /* 280 */ 1469, 1472, 1476, 1209, 1431, 1431, 1485, 1525, 1539, 1435, 171438 /* 280 */ 1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536,
170355 /* 290 */ 1463, 1471, 1492, 1487, 1443, 1494, 1474, 1484, 1498, 1486, 171439 /* 290 */ 1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495,
170356 /* 300 */ 1502, 1455, 1530, 1531, 1533, 1540, 1542, 1544, 1505, 1506, 171440 /* 300 */ 1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566,
170357 /* 310 */ 1507, 1508, 1521, 1528, 1493, 1537, 1532, 1575, 1488, 1496, 171441 /* 310 */ 1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604,
170358 /* 320 */ 1584, 1594, 1509, 1510, 1600, 1538, 1534, 1541, 1574, 1577, 171442 /* 320 */ 1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560,
170359 /* 330 */ 1583, 1585, 1586, 1612, 1626, 1581, 1556, 1558, 1587, 1559, 171443 /* 330 */ 1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570,
170360 /* 340 */ 1601, 1588, 1603, 1592, 1631, 1640, 1550, 1553, 1643, 1645, 171444 /* 340 */ 1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571,
170361 /* 350 */ 1625, 1649, 1652, 1650, 1653, 1632, 1636, 1637, 1642, 1634, 171445 /* 350 */ 1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652,
170362 /* 360 */ 1639, 1641, 1646, 1656, 1655, 1658, 1659, 1661, 1663, 1560, 171446 /* 360 */ 1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682,
170363 /* 370 */ 1564, 1596, 1605, 1664, 1670, 1565, 1571, 1627, 1638, 1657, 171447 /* 370 */ 1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642,
170364 /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, 171448 /* 380 */ 1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694,
170365 /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, 171449 /* 390 */ 1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738,
170366 /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, 171450 /* 400 */ 1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748,
171451 /* 410 */ 1753,
170367}; 171452};
170368static const YYACTIONTYPE yy_default[] = { 171453static const YYACTIONTYPE yy_default[] = {
170369 /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, 171454 /* 0 */ 1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478,
170370 /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, 171455 /* 10 */ 1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243,
170371 /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, 171456 /* 20 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243,
170372 /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, 171457 /* 30 */ 1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243,
170373 /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, 171458 /* 40 */ 1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243,
170374 /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, 171459 /* 50 */ 1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407,
170375 /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, 171460 /* 60 */ 1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475,
170376 /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, 171461 /* 70 */ 1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243,
170377 /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171462 /* 80 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170378 /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171463 /* 90 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170379 /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171464 /* 100 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170380 /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171465 /* 110 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170381 /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171466 /* 120 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170382 /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, 171467 /* 130 */ 1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443,
170383 /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, 171468 /* 140 */ 1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243,
170384 /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, 171469 /* 150 */ 1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276,
170385 /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, 171470 /* 160 */ 1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599,
170386 /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, 171471 /* 170 */ 1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243,
170387 /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171472 /* 180 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170388 /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, 171473 /* 190 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170389 /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, 171474 /* 200 */ 1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375,
170390 /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, 171475 /* 210 */ 1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354,
170391 /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171476 /* 220 */ 1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170392 /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, 171477 /* 230 */ 1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243,
170393 /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171478 /* 240 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170394 /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171479 /* 250 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170395 /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, 171480 /* 260 */ 1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243,
170396 /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, 171481 /* 270 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508,
170397 /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, 171482 /* 280 */ 1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277,
170398 /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, 171483 /* 290 */ 1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410,
170399 /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, 171484 /* 300 */ 1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384,
170400 /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, 171485 /* 310 */ 1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243,
170401 /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, 171486 /* 320 */ 1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419,
170402 /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, 171487 /* 330 */ 1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623,
170403 /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, 171488 /* 340 */ 1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634,
170404 /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, 171489 /* 350 */ 1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319,
170405 /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, 171490 /* 360 */ 1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319,
170406 /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, 171491 /* 370 */ 1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387,
170407 /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, 171492 /* 380 */ 1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397,
170408 /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, 171493 /* 390 */ 1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608,
170409 /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, 171494 /* 400 */ 1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276,
170410 /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, 171495 /* 410 */ 1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540,
170411 /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171496 /* 420 */ 1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170412 /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, 171497 /* 430 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243,
170413 /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, 171498 /* 440 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424,
170414 /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, 171499 /* 450 */ 1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170415 /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, 171500 /* 460 */ 1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243,
170416 /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171501 /* 470 */ 1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243,
170417 /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, 171502 /* 480 */ 1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243,
170418 /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171503 /* 490 */ 1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243,
170419 /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, 171504 /* 500 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291,
170420 /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171505 /* 510 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170421 /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, 171506 /* 520 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
170422 /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171507 /* 530 */ 1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243,
170423 /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, 171508 /* 540 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379,
170424 /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 171509 /* 550 */ 1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243,
170425 /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, 171510 /* 560 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619,
170426 /* 570 */ 1258, 1236, 1248, 1236, 1236, 171511 /* 570 */ 1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243,
170427}; 171512};
170428/********** End of lemon-generated parsing tables *****************************/ 171513/********** End of lemon-generated parsing tables *****************************/
170429 171514
@@ -171230,221 +172315,223 @@ static const char *const yyRuleName[] = {
171230 /* 185 */ "expr ::= expr COLLATE ID|STRING", 172315 /* 185 */ "expr ::= expr COLLATE ID|STRING",
171231 /* 186 */ "expr ::= CAST LP expr AS typetoken RP", 172316 /* 186 */ "expr ::= CAST LP expr AS typetoken RP",
171232 /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", 172317 /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP",
171233 /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", 172318 /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP",
171234 /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", 172319 /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP",
171235 /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", 172320 /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over",
171236 /* 191 */ "term ::= CTIME_KW", 172321 /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over",
171237 /* 192 */ "expr ::= LP nexprlist COMMA expr RP", 172322 /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over",
171238 /* 193 */ "expr ::= expr AND expr", 172323 /* 193 */ "term ::= CTIME_KW",
171239 /* 194 */ "expr ::= expr OR expr", 172324 /* 194 */ "expr ::= LP nexprlist COMMA expr RP",
171240 /* 195 */ "expr ::= expr LT|GT|GE|LE expr", 172325 /* 195 */ "expr ::= expr AND expr",
171241 /* 196 */ "expr ::= expr EQ|NE expr", 172326 /* 196 */ "expr ::= expr OR expr",
171242 /* 197 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", 172327 /* 197 */ "expr ::= expr LT|GT|GE|LE expr",
171243 /* 198 */ "expr ::= expr PLUS|MINUS expr", 172328 /* 198 */ "expr ::= expr EQ|NE expr",
171244 /* 199 */ "expr ::= expr STAR|SLASH|REM expr", 172329 /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
171245 /* 200 */ "expr ::= expr CONCAT expr", 172330 /* 200 */ "expr ::= expr PLUS|MINUS expr",
171246 /* 201 */ "likeop ::= NOT LIKE_KW|MATCH", 172331 /* 201 */ "expr ::= expr STAR|SLASH|REM expr",
171247 /* 202 */ "expr ::= expr likeop expr", 172332 /* 202 */ "expr ::= expr CONCAT expr",
171248 /* 203 */ "expr ::= expr likeop expr ESCAPE expr", 172333 /* 203 */ "likeop ::= NOT LIKE_KW|MATCH",
171249 /* 204 */ "expr ::= expr ISNULL|NOTNULL", 172334 /* 204 */ "expr ::= expr likeop expr",
171250 /* 205 */ "expr ::= expr NOT NULL", 172335 /* 205 */ "expr ::= expr likeop expr ESCAPE expr",
171251 /* 206 */ "expr ::= expr IS expr", 172336 /* 206 */ "expr ::= expr ISNULL|NOTNULL",
171252 /* 207 */ "expr ::= expr IS NOT expr", 172337 /* 207 */ "expr ::= expr NOT NULL",
171253 /* 208 */ "expr ::= expr IS NOT DISTINCT FROM expr", 172338 /* 208 */ "expr ::= expr IS expr",
171254 /* 209 */ "expr ::= expr IS DISTINCT FROM expr", 172339 /* 209 */ "expr ::= expr IS NOT expr",
171255 /* 210 */ "expr ::= NOT expr", 172340 /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr",
171256 /* 211 */ "expr ::= BITNOT expr", 172341 /* 211 */ "expr ::= expr IS DISTINCT FROM expr",
171257 /* 212 */ "expr ::= PLUS|MINUS expr", 172342 /* 212 */ "expr ::= NOT expr",
171258 /* 213 */ "expr ::= expr PTR expr", 172343 /* 213 */ "expr ::= BITNOT expr",
171259 /* 214 */ "between_op ::= BETWEEN", 172344 /* 214 */ "expr ::= PLUS|MINUS expr",
171260 /* 215 */ "between_op ::= NOT BETWEEN", 172345 /* 215 */ "expr ::= expr PTR expr",
171261 /* 216 */ "expr ::= expr between_op expr AND expr", 172346 /* 216 */ "between_op ::= BETWEEN",
171262 /* 217 */ "in_op ::= IN", 172347 /* 217 */ "between_op ::= NOT BETWEEN",
171263 /* 218 */ "in_op ::= NOT IN", 172348 /* 218 */ "expr ::= expr between_op expr AND expr",
171264 /* 219 */ "expr ::= expr in_op LP exprlist RP", 172349 /* 219 */ "in_op ::= IN",
171265 /* 220 */ "expr ::= LP select RP", 172350 /* 220 */ "in_op ::= NOT IN",
171266 /* 221 */ "expr ::= expr in_op LP select RP", 172351 /* 221 */ "expr ::= expr in_op LP exprlist RP",
171267 /* 222 */ "expr ::= expr in_op nm dbnm paren_exprlist", 172352 /* 222 */ "expr ::= LP select RP",
171268 /* 223 */ "expr ::= EXISTS LP select RP", 172353 /* 223 */ "expr ::= expr in_op LP select RP",
171269 /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", 172354 /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist",
171270 /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", 172355 /* 225 */ "expr ::= EXISTS LP select RP",
171271 /* 226 */ "case_exprlist ::= WHEN expr THEN expr", 172356 /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END",
171272 /* 227 */ "case_else ::= ELSE expr", 172357 /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
171273 /* 228 */ "case_else ::=", 172358 /* 228 */ "case_exprlist ::= WHEN expr THEN expr",
171274 /* 229 */ "case_operand ::=", 172359 /* 229 */ "case_else ::= ELSE expr",
171275 /* 230 */ "exprlist ::=", 172360 /* 230 */ "case_else ::=",
171276 /* 231 */ "nexprlist ::= nexprlist COMMA expr", 172361 /* 231 */ "case_operand ::=",
171277 /* 232 */ "nexprlist ::= expr", 172362 /* 232 */ "exprlist ::=",
171278 /* 233 */ "paren_exprlist ::=", 172363 /* 233 */ "nexprlist ::= nexprlist COMMA expr",
171279 /* 234 */ "paren_exprlist ::= LP exprlist RP", 172364 /* 234 */ "nexprlist ::= expr",
171280 /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", 172365 /* 235 */ "paren_exprlist ::=",
171281 /* 236 */ "uniqueflag ::= UNIQUE", 172366 /* 236 */ "paren_exprlist ::= LP exprlist RP",
171282 /* 237 */ "uniqueflag ::=", 172367 /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
171283 /* 238 */ "eidlist_opt ::=", 172368 /* 238 */ "uniqueflag ::= UNIQUE",
171284 /* 239 */ "eidlist_opt ::= LP eidlist RP", 172369 /* 239 */ "uniqueflag ::=",
171285 /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", 172370 /* 240 */ "eidlist_opt ::=",
171286 /* 241 */ "eidlist ::= nm collate sortorder", 172371 /* 241 */ "eidlist_opt ::= LP eidlist RP",
171287 /* 242 */ "collate ::=", 172372 /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder",
171288 /* 243 */ "collate ::= COLLATE ID|STRING", 172373 /* 243 */ "eidlist ::= nm collate sortorder",
171289 /* 244 */ "cmd ::= DROP INDEX ifexists fullname", 172374 /* 244 */ "collate ::=",
171290 /* 245 */ "cmd ::= VACUUM vinto", 172375 /* 245 */ "collate ::= COLLATE ID|STRING",
171291 /* 246 */ "cmd ::= VACUUM nm vinto", 172376 /* 246 */ "cmd ::= DROP INDEX ifexists fullname",
171292 /* 247 */ "vinto ::= INTO expr", 172377 /* 247 */ "cmd ::= VACUUM vinto",
171293 /* 248 */ "vinto ::=", 172378 /* 248 */ "cmd ::= VACUUM nm vinto",
171294 /* 249 */ "cmd ::= PRAGMA nm dbnm", 172379 /* 249 */ "vinto ::= INTO expr",
171295 /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", 172380 /* 250 */ "vinto ::=",
171296 /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", 172381 /* 251 */ "cmd ::= PRAGMA nm dbnm",
171297 /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", 172382 /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
171298 /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", 172383 /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
171299 /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", 172384 /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
171300 /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", 172385 /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
171301 /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", 172386 /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT",
171302 /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", 172387 /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT",
171303 /* 258 */ "trigger_time ::= BEFORE|AFTER", 172388 /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
171304 /* 259 */ "trigger_time ::= INSTEAD OF", 172389 /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
171305 /* 260 */ "trigger_time ::=", 172390 /* 260 */ "trigger_time ::= BEFORE|AFTER",
171306 /* 261 */ "trigger_event ::= DELETE|INSERT", 172391 /* 261 */ "trigger_time ::= INSTEAD OF",
171307 /* 262 */ "trigger_event ::= UPDATE", 172392 /* 262 */ "trigger_time ::=",
171308 /* 263 */ "trigger_event ::= UPDATE OF idlist", 172393 /* 263 */ "trigger_event ::= DELETE|INSERT",
171309 /* 264 */ "when_clause ::=", 172394 /* 264 */ "trigger_event ::= UPDATE",
171310 /* 265 */ "when_clause ::= WHEN expr", 172395 /* 265 */ "trigger_event ::= UPDATE OF idlist",
171311 /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", 172396 /* 266 */ "when_clause ::=",
171312 /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", 172397 /* 267 */ "when_clause ::= WHEN expr",
171313 /* 268 */ "trnm ::= nm DOT nm", 172398 /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
171314 /* 269 */ "tridxby ::= INDEXED BY nm", 172399 /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI",
171315 /* 270 */ "tridxby ::= NOT INDEXED", 172400 /* 270 */ "trnm ::= nm DOT nm",
171316 /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", 172401 /* 271 */ "tridxby ::= INDEXED BY nm",
171317 /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", 172402 /* 272 */ "tridxby ::= NOT INDEXED",
171318 /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", 172403 /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
171319 /* 274 */ "trigger_cmd ::= scanpt select scanpt", 172404 /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
171320 /* 275 */ "expr ::= RAISE LP IGNORE RP", 172405 /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
171321 /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", 172406 /* 276 */ "trigger_cmd ::= scanpt select scanpt",
171322 /* 277 */ "raisetype ::= ROLLBACK", 172407 /* 277 */ "expr ::= RAISE LP IGNORE RP",
171323 /* 278 */ "raisetype ::= ABORT", 172408 /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP",
171324 /* 279 */ "raisetype ::= FAIL", 172409 /* 279 */ "raisetype ::= ROLLBACK",
171325 /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", 172410 /* 280 */ "raisetype ::= ABORT",
171326 /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", 172411 /* 281 */ "raisetype ::= FAIL",
171327 /* 282 */ "cmd ::= DETACH database_kw_opt expr", 172412 /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname",
171328 /* 283 */ "key_opt ::=", 172413 /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
171329 /* 284 */ "key_opt ::= KEY expr", 172414 /* 284 */ "cmd ::= DETACH database_kw_opt expr",
171330 /* 285 */ "cmd ::= REINDEX", 172415 /* 285 */ "key_opt ::=",
171331 /* 286 */ "cmd ::= REINDEX nm dbnm", 172416 /* 286 */ "key_opt ::= KEY expr",
171332 /* 287 */ "cmd ::= ANALYZE", 172417 /* 287 */ "cmd ::= REINDEX",
171333 /* 288 */ "cmd ::= ANALYZE nm dbnm", 172418 /* 288 */ "cmd ::= REINDEX nm dbnm",
171334 /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", 172419 /* 289 */ "cmd ::= ANALYZE",
171335 /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", 172420 /* 290 */ "cmd ::= ANALYZE nm dbnm",
171336 /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", 172421 /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
171337 /* 292 */ "add_column_fullname ::= fullname", 172422 /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
171338 /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", 172423 /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
171339 /* 294 */ "cmd ::= create_vtab", 172424 /* 294 */ "add_column_fullname ::= fullname",
171340 /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", 172425 /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
171341 /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", 172426 /* 296 */ "cmd ::= create_vtab",
171342 /* 297 */ "vtabarg ::=", 172427 /* 297 */ "cmd ::= create_vtab LP vtabarglist RP",
171343 /* 298 */ "vtabargtoken ::= ANY", 172428 /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
171344 /* 299 */ "vtabargtoken ::= lp anylist RP", 172429 /* 299 */ "vtabarg ::=",
171345 /* 300 */ "lp ::= LP", 172430 /* 300 */ "vtabargtoken ::= ANY",
171346 /* 301 */ "with ::= WITH wqlist", 172431 /* 301 */ "vtabargtoken ::= lp anylist RP",
171347 /* 302 */ "with ::= WITH RECURSIVE wqlist", 172432 /* 302 */ "lp ::= LP",
171348 /* 303 */ "wqas ::= AS", 172433 /* 303 */ "with ::= WITH wqlist",
171349 /* 304 */ "wqas ::= AS MATERIALIZED", 172434 /* 304 */ "with ::= WITH RECURSIVE wqlist",
171350 /* 305 */ "wqas ::= AS NOT MATERIALIZED", 172435 /* 305 */ "wqas ::= AS",
171351 /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", 172436 /* 306 */ "wqas ::= AS MATERIALIZED",
171352 /* 307 */ "wqlist ::= wqitem", 172437 /* 307 */ "wqas ::= AS NOT MATERIALIZED",
171353 /* 308 */ "wqlist ::= wqlist COMMA wqitem", 172438 /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
171354 /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", 172439 /* 309 */ "wqlist ::= wqitem",
171355 /* 310 */ "windowdefn ::= nm AS LP window RP", 172440 /* 310 */ "wqlist ::= wqlist COMMA wqitem",
171356 /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", 172441 /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
171357 /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", 172442 /* 312 */ "windowdefn ::= nm AS LP window RP",
171358 /* 313 */ "window ::= ORDER BY sortlist frame_opt", 172443 /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
171359 /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", 172444 /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
171360 /* 315 */ "window ::= nm frame_opt", 172445 /* 315 */ "window ::= ORDER BY sortlist frame_opt",
171361 /* 316 */ "frame_opt ::=", 172446 /* 316 */ "window ::= nm ORDER BY sortlist frame_opt",
171362 /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", 172447 /* 317 */ "window ::= nm frame_opt",
171363 /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", 172448 /* 318 */ "frame_opt ::=",
171364 /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", 172449 /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
171365 /* 320 */ "frame_bound_s ::= frame_bound", 172450 /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
171366 /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", 172451 /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
171367 /* 322 */ "frame_bound_e ::= frame_bound", 172452 /* 322 */ "frame_bound_s ::= frame_bound",
171368 /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", 172453 /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
171369 /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", 172454 /* 324 */ "frame_bound_e ::= frame_bound",
171370 /* 325 */ "frame_bound ::= CURRENT ROW", 172455 /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
171371 /* 326 */ "frame_exclude_opt ::=", 172456 /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
171372 /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", 172457 /* 327 */ "frame_bound ::= CURRENT ROW",
171373 /* 328 */ "frame_exclude ::= NO OTHERS", 172458 /* 328 */ "frame_exclude_opt ::=",
171374 /* 329 */ "frame_exclude ::= CURRENT ROW", 172459 /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
171375 /* 330 */ "frame_exclude ::= GROUP|TIES", 172460 /* 330 */ "frame_exclude ::= NO OTHERS",
171376 /* 331 */ "window_clause ::= WINDOW windowdefn_list", 172461 /* 331 */ "frame_exclude ::= CURRENT ROW",
171377 /* 332 */ "filter_over ::= filter_clause over_clause", 172462 /* 332 */ "frame_exclude ::= GROUP|TIES",
171378 /* 333 */ "filter_over ::= over_clause", 172463 /* 333 */ "window_clause ::= WINDOW windowdefn_list",
171379 /* 334 */ "filter_over ::= filter_clause", 172464 /* 334 */ "filter_over ::= filter_clause over_clause",
171380 /* 335 */ "over_clause ::= OVER LP window RP", 172465 /* 335 */ "filter_over ::= over_clause",
171381 /* 336 */ "over_clause ::= OVER nm", 172466 /* 336 */ "filter_over ::= filter_clause",
171382 /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", 172467 /* 337 */ "over_clause ::= OVER LP window RP",
171383 /* 338 */ "input ::= cmdlist", 172468 /* 338 */ "over_clause ::= OVER nm",
171384 /* 339 */ "cmdlist ::= cmdlist ecmd", 172469 /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP",
171385 /* 340 */ "cmdlist ::= ecmd", 172470 /* 340 */ "input ::= cmdlist",
171386 /* 341 */ "ecmd ::= SEMI", 172471 /* 341 */ "cmdlist ::= cmdlist ecmd",
171387 /* 342 */ "ecmd ::= cmdx SEMI", 172472 /* 342 */ "cmdlist ::= ecmd",
171388 /* 343 */ "ecmd ::= explain cmdx SEMI", 172473 /* 343 */ "ecmd ::= SEMI",
171389 /* 344 */ "trans_opt ::=", 172474 /* 344 */ "ecmd ::= cmdx SEMI",
171390 /* 345 */ "trans_opt ::= TRANSACTION", 172475 /* 345 */ "ecmd ::= explain cmdx SEMI",
171391 /* 346 */ "trans_opt ::= TRANSACTION nm", 172476 /* 346 */ "trans_opt ::=",
171392 /* 347 */ "savepoint_opt ::= SAVEPOINT", 172477 /* 347 */ "trans_opt ::= TRANSACTION",
171393 /* 348 */ "savepoint_opt ::=", 172478 /* 348 */ "trans_opt ::= TRANSACTION nm",
171394 /* 349 */ "cmd ::= create_table create_table_args", 172479 /* 349 */ "savepoint_opt ::= SAVEPOINT",
171395 /* 350 */ "table_option_set ::= table_option", 172480 /* 350 */ "savepoint_opt ::=",
171396 /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", 172481 /* 351 */ "cmd ::= create_table create_table_args",
171397 /* 352 */ "columnlist ::= columnname carglist", 172482 /* 352 */ "table_option_set ::= table_option",
171398 /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", 172483 /* 353 */ "columnlist ::= columnlist COMMA columnname carglist",
171399 /* 354 */ "nm ::= STRING", 172484 /* 354 */ "columnlist ::= columnname carglist",
171400 /* 355 */ "typetoken ::= typename", 172485 /* 355 */ "nm ::= ID|INDEXED|JOIN_KW",
171401 /* 356 */ "typename ::= ID|STRING", 172486 /* 356 */ "nm ::= STRING",
171402 /* 357 */ "signed ::= plus_num", 172487 /* 357 */ "typetoken ::= typename",
171403 /* 358 */ "signed ::= minus_num", 172488 /* 358 */ "typename ::= ID|STRING",
171404 /* 359 */ "carglist ::= carglist ccons", 172489 /* 359 */ "signed ::= plus_num",
171405 /* 360 */ "carglist ::=", 172490 /* 360 */ "signed ::= minus_num",
171406 /* 361 */ "ccons ::= NULL onconf", 172491 /* 361 */ "carglist ::= carglist ccons",
171407 /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", 172492 /* 362 */ "carglist ::=",
171408 /* 363 */ "ccons ::= AS generated", 172493 /* 363 */ "ccons ::= NULL onconf",
171409 /* 364 */ "conslist_opt ::= COMMA conslist", 172494 /* 364 */ "ccons ::= GENERATED ALWAYS AS generated",
171410 /* 365 */ "conslist ::= conslist tconscomma tcons", 172495 /* 365 */ "ccons ::= AS generated",
171411 /* 366 */ "conslist ::= tcons", 172496 /* 366 */ "conslist_opt ::= COMMA conslist",
171412 /* 367 */ "tconscomma ::=", 172497 /* 367 */ "conslist ::= conslist tconscomma tcons",
171413 /* 368 */ "defer_subclause_opt ::= defer_subclause", 172498 /* 368 */ "conslist ::= tcons",
171414 /* 369 */ "resolvetype ::= raisetype", 172499 /* 369 */ "tconscomma ::=",
171415 /* 370 */ "selectnowith ::= oneselect", 172500 /* 370 */ "defer_subclause_opt ::= defer_subclause",
171416 /* 371 */ "oneselect ::= values", 172501 /* 371 */ "resolvetype ::= raisetype",
171417 /* 372 */ "sclp ::= selcollist COMMA", 172502 /* 372 */ "selectnowith ::= oneselect",
171418 /* 373 */ "as ::= ID|STRING", 172503 /* 373 */ "oneselect ::= values",
171419 /* 374 */ "indexed_opt ::= indexed_by", 172504 /* 374 */ "sclp ::= selcollist COMMA",
171420 /* 375 */ "returning ::=", 172505 /* 375 */ "as ::= ID|STRING",
171421 /* 376 */ "expr ::= term", 172506 /* 376 */ "indexed_opt ::= indexed_by",
171422 /* 377 */ "likeop ::= LIKE_KW|MATCH", 172507 /* 377 */ "returning ::=",
171423 /* 378 */ "case_operand ::= expr", 172508 /* 378 */ "expr ::= term",
171424 /* 379 */ "exprlist ::= nexprlist", 172509 /* 379 */ "likeop ::= LIKE_KW|MATCH",
171425 /* 380 */ "nmnum ::= plus_num", 172510 /* 380 */ "case_operand ::= expr",
171426 /* 381 */ "nmnum ::= nm", 172511 /* 381 */ "exprlist ::= nexprlist",
171427 /* 382 */ "nmnum ::= ON", 172512 /* 382 */ "nmnum ::= plus_num",
171428 /* 383 */ "nmnum ::= DELETE", 172513 /* 383 */ "nmnum ::= nm",
171429 /* 384 */ "nmnum ::= DEFAULT", 172514 /* 384 */ "nmnum ::= ON",
171430 /* 385 */ "plus_num ::= INTEGER|FLOAT", 172515 /* 385 */ "nmnum ::= DELETE",
171431 /* 386 */ "foreach_clause ::=", 172516 /* 386 */ "nmnum ::= DEFAULT",
171432 /* 387 */ "foreach_clause ::= FOR EACH ROW", 172517 /* 387 */ "plus_num ::= INTEGER|FLOAT",
171433 /* 388 */ "trnm ::= nm", 172518 /* 388 */ "foreach_clause ::=",
171434 /* 389 */ "tridxby ::=", 172519 /* 389 */ "foreach_clause ::= FOR EACH ROW",
171435 /* 390 */ "database_kw_opt ::= DATABASE", 172520 /* 390 */ "trnm ::= nm",
171436 /* 391 */ "database_kw_opt ::=", 172521 /* 391 */ "tridxby ::=",
171437 /* 392 */ "kwcolumn_opt ::=", 172522 /* 392 */ "database_kw_opt ::= DATABASE",
171438 /* 393 */ "kwcolumn_opt ::= COLUMNKW", 172523 /* 393 */ "database_kw_opt ::=",
171439 /* 394 */ "vtabarglist ::= vtabarg", 172524 /* 394 */ "kwcolumn_opt ::=",
171440 /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", 172525 /* 395 */ "kwcolumn_opt ::= COLUMNKW",
171441 /* 396 */ "vtabarg ::= vtabarg vtabargtoken", 172526 /* 396 */ "vtabarglist ::= vtabarg",
171442 /* 397 */ "anylist ::=", 172527 /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
171443 /* 398 */ "anylist ::= anylist LP anylist RP", 172528 /* 398 */ "vtabarg ::= vtabarg vtabargtoken",
171444 /* 399 */ "anylist ::= anylist ANY", 172529 /* 399 */ "anylist ::=",
171445 /* 400 */ "with ::=", 172530 /* 400 */ "anylist ::= anylist LP anylist RP",
171446 /* 401 */ "windowdefn_list ::= windowdefn", 172531 /* 401 */ "anylist ::= anylist ANY",
171447 /* 402 */ "window ::= frame_opt", 172532 /* 402 */ "with ::=",
172533 /* 403 */ "windowdefn_list ::= windowdefn",
172534 /* 404 */ "window ::= frame_opt",
171448}; 172535};
171449#endif /* NDEBUG */ 172536#endif /* NDEBUG */
171450 172537
@@ -172139,221 +173226,223 @@ static const YYCODETYPE yyRuleInfoLhs[] = {
172139 217, /* (185) expr ::= expr COLLATE ID|STRING */ 173226 217, /* (185) expr ::= expr COLLATE ID|STRING */
172140 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ 173227 217, /* (186) expr ::= CAST LP expr AS typetoken RP */
172141 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ 173228 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
172142 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ 173229 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
172143 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ 173230 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
172144 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ 173231 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
172145 216, /* (191) term ::= CTIME_KW */ 173232 217, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
172146 217, /* (192) expr ::= LP nexprlist COMMA expr RP */ 173233 217, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
172147 217, /* (193) expr ::= expr AND expr */ 173234 216, /* (193) term ::= CTIME_KW */
172148 217, /* (194) expr ::= expr OR expr */ 173235 217, /* (194) expr ::= LP nexprlist COMMA expr RP */
172149 217, /* (195) expr ::= expr LT|GT|GE|LE expr */ 173236 217, /* (195) expr ::= expr AND expr */
172150 217, /* (196) expr ::= expr EQ|NE expr */ 173237 217, /* (196) expr ::= expr OR expr */
172151 217, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ 173238 217, /* (197) expr ::= expr LT|GT|GE|LE expr */
172152 217, /* (198) expr ::= expr PLUS|MINUS expr */ 173239 217, /* (198) expr ::= expr EQ|NE expr */
172153 217, /* (199) expr ::= expr STAR|SLASH|REM expr */ 173240 217, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
172154 217, /* (200) expr ::= expr CONCAT expr */ 173241 217, /* (200) expr ::= expr PLUS|MINUS expr */
172155 274, /* (201) likeop ::= NOT LIKE_KW|MATCH */ 173242 217, /* (201) expr ::= expr STAR|SLASH|REM expr */
172156 217, /* (202) expr ::= expr likeop expr */ 173243 217, /* (202) expr ::= expr CONCAT expr */
172157 217, /* (203) expr ::= expr likeop expr ESCAPE expr */ 173244 274, /* (203) likeop ::= NOT LIKE_KW|MATCH */
172158 217, /* (204) expr ::= expr ISNULL|NOTNULL */ 173245 217, /* (204) expr ::= expr likeop expr */
172159 217, /* (205) expr ::= expr NOT NULL */ 173246 217, /* (205) expr ::= expr likeop expr ESCAPE expr */
172160 217, /* (206) expr ::= expr IS expr */ 173247 217, /* (206) expr ::= expr ISNULL|NOTNULL */
172161 217, /* (207) expr ::= expr IS NOT expr */ 173248 217, /* (207) expr ::= expr NOT NULL */
172162 217, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ 173249 217, /* (208) expr ::= expr IS expr */
172163 217, /* (209) expr ::= expr IS DISTINCT FROM expr */ 173250 217, /* (209) expr ::= expr IS NOT expr */
172164 217, /* (210) expr ::= NOT expr */ 173251 217, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
172165 217, /* (211) expr ::= BITNOT expr */ 173252 217, /* (211) expr ::= expr IS DISTINCT FROM expr */
172166 217, /* (212) expr ::= PLUS|MINUS expr */ 173253 217, /* (212) expr ::= NOT expr */
172167 217, /* (213) expr ::= expr PTR expr */ 173254 217, /* (213) expr ::= BITNOT expr */
172168 275, /* (214) between_op ::= BETWEEN */ 173255 217, /* (214) expr ::= PLUS|MINUS expr */
172169 275, /* (215) between_op ::= NOT BETWEEN */ 173256 217, /* (215) expr ::= expr PTR expr */
172170 217, /* (216) expr ::= expr between_op expr AND expr */ 173257 275, /* (216) between_op ::= BETWEEN */
172171 276, /* (217) in_op ::= IN */ 173258 275, /* (217) between_op ::= NOT BETWEEN */
172172 276, /* (218) in_op ::= NOT IN */ 173259 217, /* (218) expr ::= expr between_op expr AND expr */
172173 217, /* (219) expr ::= expr in_op LP exprlist RP */ 173260 276, /* (219) in_op ::= IN */
172174 217, /* (220) expr ::= LP select RP */ 173261 276, /* (220) in_op ::= NOT IN */
172175 217, /* (221) expr ::= expr in_op LP select RP */ 173262 217, /* (221) expr ::= expr in_op LP exprlist RP */
172176 217, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ 173263 217, /* (222) expr ::= LP select RP */
172177 217, /* (223) expr ::= EXISTS LP select RP */ 173264 217, /* (223) expr ::= expr in_op LP select RP */
172178 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ 173265 217, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
172179 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ 173266 217, /* (225) expr ::= EXISTS LP select RP */
172180 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ 173267 217, /* (226) expr ::= CASE case_operand case_exprlist case_else END */
172181 280, /* (227) case_else ::= ELSE expr */ 173268 279, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
172182 280, /* (228) case_else ::= */ 173269 279, /* (228) case_exprlist ::= WHEN expr THEN expr */
172183 278, /* (229) case_operand ::= */ 173270 280, /* (229) case_else ::= ELSE expr */
172184 261, /* (230) exprlist ::= */ 173271 280, /* (230) case_else ::= */
172185 253, /* (231) nexprlist ::= nexprlist COMMA expr */ 173272 278, /* (231) case_operand ::= */
172186 253, /* (232) nexprlist ::= expr */ 173273 261, /* (232) exprlist ::= */
172187 277, /* (233) paren_exprlist ::= */ 173274 253, /* (233) nexprlist ::= nexprlist COMMA expr */
172188 277, /* (234) paren_exprlist ::= LP exprlist RP */ 173275 253, /* (234) nexprlist ::= expr */
172189 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ 173276 277, /* (235) paren_exprlist ::= */
172190 281, /* (236) uniqueflag ::= UNIQUE */ 173277 277, /* (236) paren_exprlist ::= LP exprlist RP */
172191 281, /* (237) uniqueflag ::= */ 173278 190, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
172192 221, /* (238) eidlist_opt ::= */ 173279 281, /* (238) uniqueflag ::= UNIQUE */
172193 221, /* (239) eidlist_opt ::= LP eidlist RP */ 173280 281, /* (239) uniqueflag ::= */
172194 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ 173281 221, /* (240) eidlist_opt ::= */
172195 232, /* (241) eidlist ::= nm collate sortorder */ 173282 221, /* (241) eidlist_opt ::= LP eidlist RP */
172196 282, /* (242) collate ::= */ 173283 232, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
172197 282, /* (243) collate ::= COLLATE ID|STRING */ 173284 232, /* (243) eidlist ::= nm collate sortorder */
172198 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ 173285 282, /* (244) collate ::= */
172199 190, /* (245) cmd ::= VACUUM vinto */ 173286 282, /* (245) collate ::= COLLATE ID|STRING */
172200 190, /* (246) cmd ::= VACUUM nm vinto */ 173287 190, /* (246) cmd ::= DROP INDEX ifexists fullname */
172201 283, /* (247) vinto ::= INTO expr */ 173288 190, /* (247) cmd ::= VACUUM vinto */
172202 283, /* (248) vinto ::= */ 173289 190, /* (248) cmd ::= VACUUM nm vinto */
172203 190, /* (249) cmd ::= PRAGMA nm dbnm */ 173290 283, /* (249) vinto ::= INTO expr */
172204 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ 173291 283, /* (250) vinto ::= */
172205 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ 173292 190, /* (251) cmd ::= PRAGMA nm dbnm */
172206 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ 173293 190, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
172207 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ 173294 190, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
172208 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ 173295 190, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
172209 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ 173296 190, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
172210 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ 173297 211, /* (256) plus_num ::= PLUS INTEGER|FLOAT */
172211 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ 173298 212, /* (257) minus_num ::= MINUS INTEGER|FLOAT */
172212 287, /* (258) trigger_time ::= BEFORE|AFTER */ 173299 190, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
172213 287, /* (259) trigger_time ::= INSTEAD OF */ 173300 285, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
172214 287, /* (260) trigger_time ::= */ 173301 287, /* (260) trigger_time ::= BEFORE|AFTER */
172215 288, /* (261) trigger_event ::= DELETE|INSERT */ 173302 287, /* (261) trigger_time ::= INSTEAD OF */
172216 288, /* (262) trigger_event ::= UPDATE */ 173303 287, /* (262) trigger_time ::= */
172217 288, /* (263) trigger_event ::= UPDATE OF idlist */ 173304 288, /* (263) trigger_event ::= DELETE|INSERT */
172218 290, /* (264) when_clause ::= */ 173305 288, /* (264) trigger_event ::= UPDATE */
172219 290, /* (265) when_clause ::= WHEN expr */ 173306 288, /* (265) trigger_event ::= UPDATE OF idlist */
172220 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ 173307 290, /* (266) when_clause ::= */
172221 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ 173308 290, /* (267) when_clause ::= WHEN expr */
172222 292, /* (268) trnm ::= nm DOT nm */ 173309 286, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
172223 293, /* (269) tridxby ::= INDEXED BY nm */ 173310 286, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
172224 293, /* (270) tridxby ::= NOT INDEXED */ 173311 292, /* (270) trnm ::= nm DOT nm */
172225 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ 173312 293, /* (271) tridxby ::= INDEXED BY nm */
172226 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ 173313 293, /* (272) tridxby ::= NOT INDEXED */
172227 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ 173314 291, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
172228 291, /* (274) trigger_cmd ::= scanpt select scanpt */ 173315 291, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
172229 217, /* (275) expr ::= RAISE LP IGNORE RP */ 173316 291, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
172230 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ 173317 291, /* (276) trigger_cmd ::= scanpt select scanpt */
172231 236, /* (277) raisetype ::= ROLLBACK */ 173318 217, /* (277) expr ::= RAISE LP IGNORE RP */
172232 236, /* (278) raisetype ::= ABORT */ 173319 217, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
172233 236, /* (279) raisetype ::= FAIL */ 173320 236, /* (279) raisetype ::= ROLLBACK */
172234 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ 173321 236, /* (280) raisetype ::= ABORT */
172235 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ 173322 236, /* (281) raisetype ::= FAIL */
172236 190, /* (282) cmd ::= DETACH database_kw_opt expr */ 173323 190, /* (282) cmd ::= DROP TRIGGER ifexists fullname */
172237 295, /* (283) key_opt ::= */ 173324 190, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
172238 295, /* (284) key_opt ::= KEY expr */ 173325 190, /* (284) cmd ::= DETACH database_kw_opt expr */
172239 190, /* (285) cmd ::= REINDEX */ 173326 295, /* (285) key_opt ::= */
172240 190, /* (286) cmd ::= REINDEX nm dbnm */ 173327 295, /* (286) key_opt ::= KEY expr */
172241 190, /* (287) cmd ::= ANALYZE */ 173328 190, /* (287) cmd ::= REINDEX */
172242 190, /* (288) cmd ::= ANALYZE nm dbnm */ 173329 190, /* (288) cmd ::= REINDEX nm dbnm */
172243 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ 173330 190, /* (289) cmd ::= ANALYZE */
172244 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ 173331 190, /* (290) cmd ::= ANALYZE nm dbnm */
172245 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ 173332 190, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
172246 296, /* (292) add_column_fullname ::= fullname */ 173333 190, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
172247 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ 173334 190, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
172248 190, /* (294) cmd ::= create_vtab */ 173335 296, /* (294) add_column_fullname ::= fullname */
172249 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ 173336 190, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
172250 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ 173337 190, /* (296) cmd ::= create_vtab */
172251 300, /* (297) vtabarg ::= */ 173338 190, /* (297) cmd ::= create_vtab LP vtabarglist RP */
172252 301, /* (298) vtabargtoken ::= ANY */ 173339 298, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
172253 301, /* (299) vtabargtoken ::= lp anylist RP */ 173340 300, /* (299) vtabarg ::= */
172254 302, /* (300) lp ::= LP */ 173341 301, /* (300) vtabargtoken ::= ANY */
172255 266, /* (301) with ::= WITH wqlist */ 173342 301, /* (301) vtabargtoken ::= lp anylist RP */
172256 266, /* (302) with ::= WITH RECURSIVE wqlist */ 173343 302, /* (302) lp ::= LP */
172257 305, /* (303) wqas ::= AS */ 173344 266, /* (303) with ::= WITH wqlist */
172258 305, /* (304) wqas ::= AS MATERIALIZED */ 173345 266, /* (304) with ::= WITH RECURSIVE wqlist */
172259 305, /* (305) wqas ::= AS NOT MATERIALIZED */ 173346 305, /* (305) wqas ::= AS */
172260 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ 173347 305, /* (306) wqas ::= AS MATERIALIZED */
172261 241, /* (307) wqlist ::= wqitem */ 173348 305, /* (307) wqas ::= AS NOT MATERIALIZED */
172262 241, /* (308) wqlist ::= wqlist COMMA wqitem */ 173349 304, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
172263 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ 173350 241, /* (309) wqlist ::= wqitem */
172264 307, /* (310) windowdefn ::= nm AS LP window RP */ 173351 241, /* (310) wqlist ::= wqlist COMMA wqitem */
172265 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ 173352 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
172266 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ 173353 307, /* (312) windowdefn ::= nm AS LP window RP */
172267 308, /* (313) window ::= ORDER BY sortlist frame_opt */ 173354 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
172268 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ 173355 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
172269 308, /* (315) window ::= nm frame_opt */ 173356 308, /* (315) window ::= ORDER BY sortlist frame_opt */
172270 309, /* (316) frame_opt ::= */ 173357 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */
172271 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ 173358 308, /* (317) window ::= nm frame_opt */
172272 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ 173359 309, /* (318) frame_opt ::= */
172273 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ 173360 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
172274 315, /* (320) frame_bound_s ::= frame_bound */ 173361 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
172275 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ 173362 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
172276 316, /* (322) frame_bound_e ::= frame_bound */ 173363 315, /* (322) frame_bound_s ::= frame_bound */
172277 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ 173364 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
172278 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ 173365 316, /* (324) frame_bound_e ::= frame_bound */
172279 314, /* (325) frame_bound ::= CURRENT ROW */ 173366 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
172280 317, /* (326) frame_exclude_opt ::= */ 173367 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
172281 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ 173368 314, /* (327) frame_bound ::= CURRENT ROW */
172282 318, /* (328) frame_exclude ::= NO OTHERS */ 173369 317, /* (328) frame_exclude_opt ::= */
172283 318, /* (329) frame_exclude ::= CURRENT ROW */ 173370 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
172284 318, /* (330) frame_exclude ::= GROUP|TIES */ 173371 318, /* (330) frame_exclude ::= NO OTHERS */
172285 251, /* (331) window_clause ::= WINDOW windowdefn_list */ 173372 318, /* (331) frame_exclude ::= CURRENT ROW */
172286 273, /* (332) filter_over ::= filter_clause over_clause */ 173373 318, /* (332) frame_exclude ::= GROUP|TIES */
172287 273, /* (333) filter_over ::= over_clause */ 173374 251, /* (333) window_clause ::= WINDOW windowdefn_list */
172288 273, /* (334) filter_over ::= filter_clause */ 173375 273, /* (334) filter_over ::= filter_clause over_clause */
172289 312, /* (335) over_clause ::= OVER LP window RP */ 173376 273, /* (335) filter_over ::= over_clause */
172290 312, /* (336) over_clause ::= OVER nm */ 173377 273, /* (336) filter_over ::= filter_clause */
172291 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ 173378 312, /* (337) over_clause ::= OVER LP window RP */
172292 185, /* (338) input ::= cmdlist */ 173379 312, /* (338) over_clause ::= OVER nm */
172293 186, /* (339) cmdlist ::= cmdlist ecmd */ 173380 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */
172294 186, /* (340) cmdlist ::= ecmd */ 173381 185, /* (340) input ::= cmdlist */
172295 187, /* (341) ecmd ::= SEMI */ 173382 186, /* (341) cmdlist ::= cmdlist ecmd */
172296 187, /* (342) ecmd ::= cmdx SEMI */ 173383 186, /* (342) cmdlist ::= ecmd */
172297 187, /* (343) ecmd ::= explain cmdx SEMI */ 173384 187, /* (343) ecmd ::= SEMI */
172298 192, /* (344) trans_opt ::= */ 173385 187, /* (344) ecmd ::= cmdx SEMI */
172299 192, /* (345) trans_opt ::= TRANSACTION */ 173386 187, /* (345) ecmd ::= explain cmdx SEMI */
172300 192, /* (346) trans_opt ::= TRANSACTION nm */ 173387 192, /* (346) trans_opt ::= */
172301 194, /* (347) savepoint_opt ::= SAVEPOINT */ 173388 192, /* (347) trans_opt ::= TRANSACTION */
172302 194, /* (348) savepoint_opt ::= */ 173389 192, /* (348) trans_opt ::= TRANSACTION nm */
172303 190, /* (349) cmd ::= create_table create_table_args */ 173390 194, /* (349) savepoint_opt ::= SAVEPOINT */
172304 203, /* (350) table_option_set ::= table_option */ 173391 194, /* (350) savepoint_opt ::= */
172305 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ 173392 190, /* (351) cmd ::= create_table create_table_args */
172306 201, /* (352) columnlist ::= columnname carglist */ 173393 203, /* (352) table_option_set ::= table_option */
172307 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ 173394 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */
172308 193, /* (354) nm ::= STRING */ 173395 201, /* (354) columnlist ::= columnname carglist */
172309 208, /* (355) typetoken ::= typename */ 173396 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */
172310 209, /* (356) typename ::= ID|STRING */ 173397 193, /* (356) nm ::= STRING */
172311 210, /* (357) signed ::= plus_num */ 173398 208, /* (357) typetoken ::= typename */
172312 210, /* (358) signed ::= minus_num */ 173399 209, /* (358) typename ::= ID|STRING */
172313 207, /* (359) carglist ::= carglist ccons */ 173400 210, /* (359) signed ::= plus_num */
172314 207, /* (360) carglist ::= */ 173401 210, /* (360) signed ::= minus_num */
172315 215, /* (361) ccons ::= NULL onconf */ 173402 207, /* (361) carglist ::= carglist ccons */
172316 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ 173403 207, /* (362) carglist ::= */
172317 215, /* (363) ccons ::= AS generated */ 173404 215, /* (363) ccons ::= NULL onconf */
172318 202, /* (364) conslist_opt ::= COMMA conslist */ 173405 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */
172319 228, /* (365) conslist ::= conslist tconscomma tcons */ 173406 215, /* (365) ccons ::= AS generated */
172320 228, /* (366) conslist ::= tcons */ 173407 202, /* (366) conslist_opt ::= COMMA conslist */
172321 229, /* (367) tconscomma ::= */ 173408 228, /* (367) conslist ::= conslist tconscomma tcons */
172322 233, /* (368) defer_subclause_opt ::= defer_subclause */ 173409 228, /* (368) conslist ::= tcons */
172323 235, /* (369) resolvetype ::= raisetype */ 173410 229, /* (369) tconscomma ::= */
172324 239, /* (370) selectnowith ::= oneselect */ 173411 233, /* (370) defer_subclause_opt ::= defer_subclause */
172325 240, /* (371) oneselect ::= values */ 173412 235, /* (371) resolvetype ::= raisetype */
172326 254, /* (372) sclp ::= selcollist COMMA */ 173413 239, /* (372) selectnowith ::= oneselect */
172327 255, /* (373) as ::= ID|STRING */ 173414 240, /* (373) oneselect ::= values */
172328 264, /* (374) indexed_opt ::= indexed_by */ 173415 254, /* (374) sclp ::= selcollist COMMA */
172329 272, /* (375) returning ::= */ 173416 255, /* (375) as ::= ID|STRING */
172330 217, /* (376) expr ::= term */ 173417 264, /* (376) indexed_opt ::= indexed_by */
172331 274, /* (377) likeop ::= LIKE_KW|MATCH */ 173418 272, /* (377) returning ::= */
172332 278, /* (378) case_operand ::= expr */ 173419 217, /* (378) expr ::= term */
172333 261, /* (379) exprlist ::= nexprlist */ 173420 274, /* (379) likeop ::= LIKE_KW|MATCH */
172334 284, /* (380) nmnum ::= plus_num */ 173421 278, /* (380) case_operand ::= expr */
172335 284, /* (381) nmnum ::= nm */ 173422 261, /* (381) exprlist ::= nexprlist */
172336 284, /* (382) nmnum ::= ON */ 173423 284, /* (382) nmnum ::= plus_num */
172337 284, /* (383) nmnum ::= DELETE */ 173424 284, /* (383) nmnum ::= nm */
172338 284, /* (384) nmnum ::= DEFAULT */ 173425 284, /* (384) nmnum ::= ON */
172339 211, /* (385) plus_num ::= INTEGER|FLOAT */ 173426 284, /* (385) nmnum ::= DELETE */
172340 289, /* (386) foreach_clause ::= */ 173427 284, /* (386) nmnum ::= DEFAULT */
172341 289, /* (387) foreach_clause ::= FOR EACH ROW */ 173428 211, /* (387) plus_num ::= INTEGER|FLOAT */
172342 292, /* (388) trnm ::= nm */ 173429 289, /* (388) foreach_clause ::= */
172343 293, /* (389) tridxby ::= */ 173430 289, /* (389) foreach_clause ::= FOR EACH ROW */
172344 294, /* (390) database_kw_opt ::= DATABASE */ 173431 292, /* (390) trnm ::= nm */
172345 294, /* (391) database_kw_opt ::= */ 173432 293, /* (391) tridxby ::= */
172346 297, /* (392) kwcolumn_opt ::= */ 173433 294, /* (392) database_kw_opt ::= DATABASE */
172347 297, /* (393) kwcolumn_opt ::= COLUMNKW */ 173434 294, /* (393) database_kw_opt ::= */
172348 299, /* (394) vtabarglist ::= vtabarg */ 173435 297, /* (394) kwcolumn_opt ::= */
172349 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ 173436 297, /* (395) kwcolumn_opt ::= COLUMNKW */
172350 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ 173437 299, /* (396) vtabarglist ::= vtabarg */
172351 303, /* (397) anylist ::= */ 173438 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
172352 303, /* (398) anylist ::= anylist LP anylist RP */ 173439 300, /* (398) vtabarg ::= vtabarg vtabargtoken */
172353 303, /* (399) anylist ::= anylist ANY */ 173440 303, /* (399) anylist ::= */
172354 266, /* (400) with ::= */ 173441 303, /* (400) anylist ::= anylist LP anylist RP */
172355 306, /* (401) windowdefn_list ::= windowdefn */ 173442 303, /* (401) anylist ::= anylist ANY */
172356 308, /* (402) window ::= frame_opt */ 173443 266, /* (402) with ::= */
173444 306, /* (403) windowdefn_list ::= windowdefn */
173445 308, /* (404) window ::= frame_opt */
172357}; 173446};
172358 173447
172359/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number 173448/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
@@ -172547,221 +173636,223 @@ static const signed char yyRuleInfoNRhs[] = {
172547 -3, /* (185) expr ::= expr COLLATE ID|STRING */ 173636 -3, /* (185) expr ::= expr COLLATE ID|STRING */
172548 -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ 173637 -6, /* (186) expr ::= CAST LP expr AS typetoken RP */
172549 -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ 173638 -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
172550 -4, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ 173639 -8, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
172551 -6, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ 173640 -4, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
172552 -5, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ 173641 -6, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
172553 -1, /* (191) term ::= CTIME_KW */ 173642 -9, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
172554 -5, /* (192) expr ::= LP nexprlist COMMA expr RP */ 173643 -5, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
172555 -3, /* (193) expr ::= expr AND expr */ 173644 -1, /* (193) term ::= CTIME_KW */
172556 -3, /* (194) expr ::= expr OR expr */ 173645 -5, /* (194) expr ::= LP nexprlist COMMA expr RP */
172557 -3, /* (195) expr ::= expr LT|GT|GE|LE expr */ 173646 -3, /* (195) expr ::= expr AND expr */
172558 -3, /* (196) expr ::= expr EQ|NE expr */ 173647 -3, /* (196) expr ::= expr OR expr */
172559 -3, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ 173648 -3, /* (197) expr ::= expr LT|GT|GE|LE expr */
172560 -3, /* (198) expr ::= expr PLUS|MINUS expr */ 173649 -3, /* (198) expr ::= expr EQ|NE expr */
172561 -3, /* (199) expr ::= expr STAR|SLASH|REM expr */ 173650 -3, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
172562 -3, /* (200) expr ::= expr CONCAT expr */ 173651 -3, /* (200) expr ::= expr PLUS|MINUS expr */
172563 -2, /* (201) likeop ::= NOT LIKE_KW|MATCH */ 173652 -3, /* (201) expr ::= expr STAR|SLASH|REM expr */
172564 -3, /* (202) expr ::= expr likeop expr */ 173653 -3, /* (202) expr ::= expr CONCAT expr */
172565 -5, /* (203) expr ::= expr likeop expr ESCAPE expr */ 173654 -2, /* (203) likeop ::= NOT LIKE_KW|MATCH */
172566 -2, /* (204) expr ::= expr ISNULL|NOTNULL */ 173655 -3, /* (204) expr ::= expr likeop expr */
172567 -3, /* (205) expr ::= expr NOT NULL */ 173656 -5, /* (205) expr ::= expr likeop expr ESCAPE expr */
172568 -3, /* (206) expr ::= expr IS expr */ 173657 -2, /* (206) expr ::= expr ISNULL|NOTNULL */
172569 -4, /* (207) expr ::= expr IS NOT expr */ 173658 -3, /* (207) expr ::= expr NOT NULL */
172570 -6, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ 173659 -3, /* (208) expr ::= expr IS expr */
172571 -5, /* (209) expr ::= expr IS DISTINCT FROM expr */ 173660 -4, /* (209) expr ::= expr IS NOT expr */
172572 -2, /* (210) expr ::= NOT expr */ 173661 -6, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
172573 -2, /* (211) expr ::= BITNOT expr */ 173662 -5, /* (211) expr ::= expr IS DISTINCT FROM expr */
172574 -2, /* (212) expr ::= PLUS|MINUS expr */ 173663 -2, /* (212) expr ::= NOT expr */
172575 -3, /* (213) expr ::= expr PTR expr */ 173664 -2, /* (213) expr ::= BITNOT expr */
172576 -1, /* (214) between_op ::= BETWEEN */ 173665 -2, /* (214) expr ::= PLUS|MINUS expr */
172577 -2, /* (215) between_op ::= NOT BETWEEN */ 173666 -3, /* (215) expr ::= expr PTR expr */
172578 -5, /* (216) expr ::= expr between_op expr AND expr */ 173667 -1, /* (216) between_op ::= BETWEEN */
172579 -1, /* (217) in_op ::= IN */ 173668 -2, /* (217) between_op ::= NOT BETWEEN */
172580 -2, /* (218) in_op ::= NOT IN */ 173669 -5, /* (218) expr ::= expr between_op expr AND expr */
172581 -5, /* (219) expr ::= expr in_op LP exprlist RP */ 173670 -1, /* (219) in_op ::= IN */
172582 -3, /* (220) expr ::= LP select RP */ 173671 -2, /* (220) in_op ::= NOT IN */
172583 -5, /* (221) expr ::= expr in_op LP select RP */ 173672 -5, /* (221) expr ::= expr in_op LP exprlist RP */
172584 -5, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ 173673 -3, /* (222) expr ::= LP select RP */
172585 -4, /* (223) expr ::= EXISTS LP select RP */ 173674 -5, /* (223) expr ::= expr in_op LP select RP */
172586 -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ 173675 -5, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
172587 -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ 173676 -4, /* (225) expr ::= EXISTS LP select RP */
172588 -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ 173677 -5, /* (226) expr ::= CASE case_operand case_exprlist case_else END */
172589 -2, /* (227) case_else ::= ELSE expr */ 173678 -5, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
172590 0, /* (228) case_else ::= */ 173679 -4, /* (228) case_exprlist ::= WHEN expr THEN expr */
172591 0, /* (229) case_operand ::= */ 173680 -2, /* (229) case_else ::= ELSE expr */
172592 0, /* (230) exprlist ::= */ 173681 0, /* (230) case_else ::= */
172593 -3, /* (231) nexprlist ::= nexprlist COMMA expr */ 173682 0, /* (231) case_operand ::= */
172594 -1, /* (232) nexprlist ::= expr */ 173683 0, /* (232) exprlist ::= */
172595 0, /* (233) paren_exprlist ::= */ 173684 -3, /* (233) nexprlist ::= nexprlist COMMA expr */
172596 -3, /* (234) paren_exprlist ::= LP exprlist RP */ 173685 -1, /* (234) nexprlist ::= expr */
172597 -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ 173686 0, /* (235) paren_exprlist ::= */
172598 -1, /* (236) uniqueflag ::= UNIQUE */ 173687 -3, /* (236) paren_exprlist ::= LP exprlist RP */
172599 0, /* (237) uniqueflag ::= */ 173688 -12, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
172600 0, /* (238) eidlist_opt ::= */ 173689 -1, /* (238) uniqueflag ::= UNIQUE */
172601 -3, /* (239) eidlist_opt ::= LP eidlist RP */ 173690 0, /* (239) uniqueflag ::= */
172602 -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ 173691 0, /* (240) eidlist_opt ::= */
172603 -3, /* (241) eidlist ::= nm collate sortorder */ 173692 -3, /* (241) eidlist_opt ::= LP eidlist RP */
172604 0, /* (242) collate ::= */ 173693 -5, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
172605 -2, /* (243) collate ::= COLLATE ID|STRING */ 173694 -3, /* (243) eidlist ::= nm collate sortorder */
172606 -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ 173695 0, /* (244) collate ::= */
172607 -2, /* (245) cmd ::= VACUUM vinto */ 173696 -2, /* (245) collate ::= COLLATE ID|STRING */
172608 -3, /* (246) cmd ::= VACUUM nm vinto */ 173697 -4, /* (246) cmd ::= DROP INDEX ifexists fullname */
172609 -2, /* (247) vinto ::= INTO expr */ 173698 -2, /* (247) cmd ::= VACUUM vinto */
172610 0, /* (248) vinto ::= */ 173699 -3, /* (248) cmd ::= VACUUM nm vinto */
172611 -3, /* (249) cmd ::= PRAGMA nm dbnm */ 173700 -2, /* (249) vinto ::= INTO expr */
172612 -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ 173701 0, /* (250) vinto ::= */
172613 -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ 173702 -3, /* (251) cmd ::= PRAGMA nm dbnm */
172614 -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ 173703 -5, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
172615 -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ 173704 -6, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
172616 -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ 173705 -5, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
172617 -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ 173706 -6, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
172618 -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ 173707 -2, /* (256) plus_num ::= PLUS INTEGER|FLOAT */
172619 -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ 173708 -2, /* (257) minus_num ::= MINUS INTEGER|FLOAT */
172620 -1, /* (258) trigger_time ::= BEFORE|AFTER */ 173709 -5, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
172621 -2, /* (259) trigger_time ::= INSTEAD OF */ 173710 -11, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
172622 0, /* (260) trigger_time ::= */ 173711 -1, /* (260) trigger_time ::= BEFORE|AFTER */
172623 -1, /* (261) trigger_event ::= DELETE|INSERT */ 173712 -2, /* (261) trigger_time ::= INSTEAD OF */
172624 -1, /* (262) trigger_event ::= UPDATE */ 173713 0, /* (262) trigger_time ::= */
172625 -3, /* (263) trigger_event ::= UPDATE OF idlist */ 173714 -1, /* (263) trigger_event ::= DELETE|INSERT */
172626 0, /* (264) when_clause ::= */ 173715 -1, /* (264) trigger_event ::= UPDATE */
172627 -2, /* (265) when_clause ::= WHEN expr */ 173716 -3, /* (265) trigger_event ::= UPDATE OF idlist */
172628 -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ 173717 0, /* (266) when_clause ::= */
172629 -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ 173718 -2, /* (267) when_clause ::= WHEN expr */
172630 -3, /* (268) trnm ::= nm DOT nm */ 173719 -3, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
172631 -3, /* (269) tridxby ::= INDEXED BY nm */ 173720 -2, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
172632 -2, /* (270) tridxby ::= NOT INDEXED */ 173721 -3, /* (270) trnm ::= nm DOT nm */
172633 -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ 173722 -3, /* (271) tridxby ::= INDEXED BY nm */
172634 -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ 173723 -2, /* (272) tridxby ::= NOT INDEXED */
172635 -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ 173724 -9, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
172636 -3, /* (274) trigger_cmd ::= scanpt select scanpt */ 173725 -8, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
172637 -4, /* (275) expr ::= RAISE LP IGNORE RP */ 173726 -6, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
172638 -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ 173727 -3, /* (276) trigger_cmd ::= scanpt select scanpt */
172639 -1, /* (277) raisetype ::= ROLLBACK */ 173728 -4, /* (277) expr ::= RAISE LP IGNORE RP */
172640 -1, /* (278) raisetype ::= ABORT */ 173729 -6, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
172641 -1, /* (279) raisetype ::= FAIL */ 173730 -1, /* (279) raisetype ::= ROLLBACK */
172642 -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ 173731 -1, /* (280) raisetype ::= ABORT */
172643 -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ 173732 -1, /* (281) raisetype ::= FAIL */
172644 -3, /* (282) cmd ::= DETACH database_kw_opt expr */ 173733 -4, /* (282) cmd ::= DROP TRIGGER ifexists fullname */
172645 0, /* (283) key_opt ::= */ 173734 -6, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
172646 -2, /* (284) key_opt ::= KEY expr */ 173735 -3, /* (284) cmd ::= DETACH database_kw_opt expr */
172647 -1, /* (285) cmd ::= REINDEX */ 173736 0, /* (285) key_opt ::= */
172648 -3, /* (286) cmd ::= REINDEX nm dbnm */ 173737 -2, /* (286) key_opt ::= KEY expr */
172649 -1, /* (287) cmd ::= ANALYZE */ 173738 -1, /* (287) cmd ::= REINDEX */
172650 -3, /* (288) cmd ::= ANALYZE nm dbnm */ 173739 -3, /* (288) cmd ::= REINDEX nm dbnm */
172651 -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ 173740 -1, /* (289) cmd ::= ANALYZE */
172652 -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ 173741 -3, /* (290) cmd ::= ANALYZE nm dbnm */
172653 -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ 173742 -6, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
172654 -1, /* (292) add_column_fullname ::= fullname */ 173743 -7, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
172655 -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ 173744 -6, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
172656 -1, /* (294) cmd ::= create_vtab */ 173745 -1, /* (294) add_column_fullname ::= fullname */
172657 -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ 173746 -8, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
172658 -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ 173747 -1, /* (296) cmd ::= create_vtab */
172659 0, /* (297) vtabarg ::= */ 173748 -4, /* (297) cmd ::= create_vtab LP vtabarglist RP */
172660 -1, /* (298) vtabargtoken ::= ANY */ 173749 -8, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
172661 -3, /* (299) vtabargtoken ::= lp anylist RP */ 173750 0, /* (299) vtabarg ::= */
172662 -1, /* (300) lp ::= LP */ 173751 -1, /* (300) vtabargtoken ::= ANY */
172663 -2, /* (301) with ::= WITH wqlist */ 173752 -3, /* (301) vtabargtoken ::= lp anylist RP */
172664 -3, /* (302) with ::= WITH RECURSIVE wqlist */ 173753 -1, /* (302) lp ::= LP */
172665 -1, /* (303) wqas ::= AS */ 173754 -2, /* (303) with ::= WITH wqlist */
172666 -2, /* (304) wqas ::= AS MATERIALIZED */ 173755 -3, /* (304) with ::= WITH RECURSIVE wqlist */
172667 -3, /* (305) wqas ::= AS NOT MATERIALIZED */ 173756 -1, /* (305) wqas ::= AS */
172668 -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ 173757 -2, /* (306) wqas ::= AS MATERIALIZED */
172669 -1, /* (307) wqlist ::= wqitem */ 173758 -3, /* (307) wqas ::= AS NOT MATERIALIZED */
172670 -3, /* (308) wqlist ::= wqlist COMMA wqitem */ 173759 -6, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
172671 -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ 173760 -1, /* (309) wqlist ::= wqitem */
172672 -5, /* (310) windowdefn ::= nm AS LP window RP */ 173761 -3, /* (310) wqlist ::= wqlist COMMA wqitem */
172673 -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ 173762 -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
172674 -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ 173763 -5, /* (312) windowdefn ::= nm AS LP window RP */
172675 -4, /* (313) window ::= ORDER BY sortlist frame_opt */ 173764 -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
172676 -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ 173765 -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
172677 -2, /* (315) window ::= nm frame_opt */ 173766 -4, /* (315) window ::= ORDER BY sortlist frame_opt */
172678 0, /* (316) frame_opt ::= */ 173767 -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */
172679 -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ 173768 -2, /* (317) window ::= nm frame_opt */
172680 -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ 173769 0, /* (318) frame_opt ::= */
172681 -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ 173770 -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
172682 -1, /* (320) frame_bound_s ::= frame_bound */ 173771 -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
172683 -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ 173772 -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
172684 -1, /* (322) frame_bound_e ::= frame_bound */ 173773 -1, /* (322) frame_bound_s ::= frame_bound */
172685 -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ 173774 -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
172686 -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ 173775 -1, /* (324) frame_bound_e ::= frame_bound */
172687 -2, /* (325) frame_bound ::= CURRENT ROW */ 173776 -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
172688 0, /* (326) frame_exclude_opt ::= */ 173777 -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
172689 -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ 173778 -2, /* (327) frame_bound ::= CURRENT ROW */
172690 -2, /* (328) frame_exclude ::= NO OTHERS */ 173779 0, /* (328) frame_exclude_opt ::= */
172691 -2, /* (329) frame_exclude ::= CURRENT ROW */ 173780 -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
172692 -1, /* (330) frame_exclude ::= GROUP|TIES */ 173781 -2, /* (330) frame_exclude ::= NO OTHERS */
172693 -2, /* (331) window_clause ::= WINDOW windowdefn_list */ 173782 -2, /* (331) frame_exclude ::= CURRENT ROW */
172694 -2, /* (332) filter_over ::= filter_clause over_clause */ 173783 -1, /* (332) frame_exclude ::= GROUP|TIES */
172695 -1, /* (333) filter_over ::= over_clause */ 173784 -2, /* (333) window_clause ::= WINDOW windowdefn_list */
172696 -1, /* (334) filter_over ::= filter_clause */ 173785 -2, /* (334) filter_over ::= filter_clause over_clause */
172697 -4, /* (335) over_clause ::= OVER LP window RP */ 173786 -1, /* (335) filter_over ::= over_clause */
172698 -2, /* (336) over_clause ::= OVER nm */ 173787 -1, /* (336) filter_over ::= filter_clause */
172699 -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ 173788 -4, /* (337) over_clause ::= OVER LP window RP */
172700 -1, /* (338) input ::= cmdlist */ 173789 -2, /* (338) over_clause ::= OVER nm */
172701 -2, /* (339) cmdlist ::= cmdlist ecmd */ 173790 -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */
172702 -1, /* (340) cmdlist ::= ecmd */ 173791 -1, /* (340) input ::= cmdlist */
172703 -1, /* (341) ecmd ::= SEMI */ 173792 -2, /* (341) cmdlist ::= cmdlist ecmd */
172704 -2, /* (342) ecmd ::= cmdx SEMI */ 173793 -1, /* (342) cmdlist ::= ecmd */
172705 -3, /* (343) ecmd ::= explain cmdx SEMI */ 173794 -1, /* (343) ecmd ::= SEMI */
172706 0, /* (344) trans_opt ::= */ 173795 -2, /* (344) ecmd ::= cmdx SEMI */
172707 -1, /* (345) trans_opt ::= TRANSACTION */ 173796 -3, /* (345) ecmd ::= explain cmdx SEMI */
172708 -2, /* (346) trans_opt ::= TRANSACTION nm */ 173797 0, /* (346) trans_opt ::= */
172709 -1, /* (347) savepoint_opt ::= SAVEPOINT */ 173798 -1, /* (347) trans_opt ::= TRANSACTION */
172710 0, /* (348) savepoint_opt ::= */ 173799 -2, /* (348) trans_opt ::= TRANSACTION nm */
172711 -2, /* (349) cmd ::= create_table create_table_args */ 173800 -1, /* (349) savepoint_opt ::= SAVEPOINT */
172712 -1, /* (350) table_option_set ::= table_option */ 173801 0, /* (350) savepoint_opt ::= */
172713 -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ 173802 -2, /* (351) cmd ::= create_table create_table_args */
172714 -2, /* (352) columnlist ::= columnname carglist */ 173803 -1, /* (352) table_option_set ::= table_option */
172715 -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ 173804 -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */
172716 -1, /* (354) nm ::= STRING */ 173805 -2, /* (354) columnlist ::= columnname carglist */
172717 -1, /* (355) typetoken ::= typename */ 173806 -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */
172718 -1, /* (356) typename ::= ID|STRING */ 173807 -1, /* (356) nm ::= STRING */
172719 -1, /* (357) signed ::= plus_num */ 173808 -1, /* (357) typetoken ::= typename */
172720 -1, /* (358) signed ::= minus_num */ 173809 -1, /* (358) typename ::= ID|STRING */
172721 -2, /* (359) carglist ::= carglist ccons */ 173810 -1, /* (359) signed ::= plus_num */
172722 0, /* (360) carglist ::= */ 173811 -1, /* (360) signed ::= minus_num */
172723 -2, /* (361) ccons ::= NULL onconf */ 173812 -2, /* (361) carglist ::= carglist ccons */
172724 -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ 173813 0, /* (362) carglist ::= */
172725 -2, /* (363) ccons ::= AS generated */ 173814 -2, /* (363) ccons ::= NULL onconf */
172726 -2, /* (364) conslist_opt ::= COMMA conslist */ 173815 -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */
172727 -3, /* (365) conslist ::= conslist tconscomma tcons */ 173816 -2, /* (365) ccons ::= AS generated */
172728 -1, /* (366) conslist ::= tcons */ 173817 -2, /* (366) conslist_opt ::= COMMA conslist */
172729 0, /* (367) tconscomma ::= */ 173818 -3, /* (367) conslist ::= conslist tconscomma tcons */
172730 -1, /* (368) defer_subclause_opt ::= defer_subclause */ 173819 -1, /* (368) conslist ::= tcons */
172731 -1, /* (369) resolvetype ::= raisetype */ 173820 0, /* (369) tconscomma ::= */
172732 -1, /* (370) selectnowith ::= oneselect */ 173821 -1, /* (370) defer_subclause_opt ::= defer_subclause */
172733 -1, /* (371) oneselect ::= values */ 173822 -1, /* (371) resolvetype ::= raisetype */
172734 -2, /* (372) sclp ::= selcollist COMMA */ 173823 -1, /* (372) selectnowith ::= oneselect */
172735 -1, /* (373) as ::= ID|STRING */ 173824 -1, /* (373) oneselect ::= values */
172736 -1, /* (374) indexed_opt ::= indexed_by */ 173825 -2, /* (374) sclp ::= selcollist COMMA */
172737 0, /* (375) returning ::= */ 173826 -1, /* (375) as ::= ID|STRING */
172738 -1, /* (376) expr ::= term */ 173827 -1, /* (376) indexed_opt ::= indexed_by */
172739 -1, /* (377) likeop ::= LIKE_KW|MATCH */ 173828 0, /* (377) returning ::= */
172740 -1, /* (378) case_operand ::= expr */ 173829 -1, /* (378) expr ::= term */
172741 -1, /* (379) exprlist ::= nexprlist */ 173830 -1, /* (379) likeop ::= LIKE_KW|MATCH */
172742 -1, /* (380) nmnum ::= plus_num */ 173831 -1, /* (380) case_operand ::= expr */
172743 -1, /* (381) nmnum ::= nm */ 173832 -1, /* (381) exprlist ::= nexprlist */
172744 -1, /* (382) nmnum ::= ON */ 173833 -1, /* (382) nmnum ::= plus_num */
172745 -1, /* (383) nmnum ::= DELETE */ 173834 -1, /* (383) nmnum ::= nm */
172746 -1, /* (384) nmnum ::= DEFAULT */ 173835 -1, /* (384) nmnum ::= ON */
172747 -1, /* (385) plus_num ::= INTEGER|FLOAT */ 173836 -1, /* (385) nmnum ::= DELETE */
172748 0, /* (386) foreach_clause ::= */ 173837 -1, /* (386) nmnum ::= DEFAULT */
172749 -3, /* (387) foreach_clause ::= FOR EACH ROW */ 173838 -1, /* (387) plus_num ::= INTEGER|FLOAT */
172750 -1, /* (388) trnm ::= nm */ 173839 0, /* (388) foreach_clause ::= */
172751 0, /* (389) tridxby ::= */ 173840 -3, /* (389) foreach_clause ::= FOR EACH ROW */
172752 -1, /* (390) database_kw_opt ::= DATABASE */ 173841 -1, /* (390) trnm ::= nm */
172753 0, /* (391) database_kw_opt ::= */ 173842 0, /* (391) tridxby ::= */
172754 0, /* (392) kwcolumn_opt ::= */ 173843 -1, /* (392) database_kw_opt ::= DATABASE */
172755 -1, /* (393) kwcolumn_opt ::= COLUMNKW */ 173844 0, /* (393) database_kw_opt ::= */
172756 -1, /* (394) vtabarglist ::= vtabarg */ 173845 0, /* (394) kwcolumn_opt ::= */
172757 -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ 173846 -1, /* (395) kwcolumn_opt ::= COLUMNKW */
172758 -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ 173847 -1, /* (396) vtabarglist ::= vtabarg */
172759 0, /* (397) anylist ::= */ 173848 -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
172760 -4, /* (398) anylist ::= anylist LP anylist RP */ 173849 -2, /* (398) vtabarg ::= vtabarg vtabargtoken */
172761 -2, /* (399) anylist ::= anylist ANY */ 173850 0, /* (399) anylist ::= */
172762 0, /* (400) with ::= */ 173851 -4, /* (400) anylist ::= anylist LP anylist RP */
172763 -1, /* (401) windowdefn_list ::= windowdefn */ 173852 -2, /* (401) anylist ::= anylist ANY */
172764 -1, /* (402) window ::= frame_opt */ 173853 0, /* (402) with ::= */
173854 -1, /* (403) windowdefn_list ::= windowdefn */
173855 -1, /* (404) window ::= frame_opt */
172765}; 173856};
172766 173857
172767static void yy_accept(yyParser*); /* Forward Declaration */ 173858static void yy_accept(yyParser*); /* Forward Declaration */
@@ -172821,7 +173912,7 @@ static YYACTIONTYPE yy_reduce(
172821 case 5: /* transtype ::= DEFERRED */ 173912 case 5: /* transtype ::= DEFERRED */
172822 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); 173913 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
172823 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); 173914 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
172824 case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); 173915 case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321);
172825{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} 173916{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/}
172826 break; 173917 break;
172827 case 8: /* cmd ::= COMMIT|END trans_opt */ 173918 case 8: /* cmd ::= COMMIT|END trans_opt */
@@ -172858,7 +173949,7 @@ static YYACTIONTYPE yy_reduce(
172858 case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); 173949 case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
172859 case 81: /* ifexists ::= */ yytestcase(yyruleno==81); 173950 case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
172860 case 98: /* distinct ::= */ yytestcase(yyruleno==98); 173951 case 98: /* distinct ::= */ yytestcase(yyruleno==98);
172861 case 242: /* collate ::= */ yytestcase(yyruleno==242); 173952 case 244: /* collate ::= */ yytestcase(yyruleno==244);
172862{yymsp[1].minor.yy394 = 0;} 173953{yymsp[1].minor.yy394 = 0;}
172863 break; 173954 break;
172864 case 16: /* ifnotexists ::= IF NOT EXISTS */ 173955 case 16: /* ifnotexists ::= IF NOT EXISTS */
@@ -173042,9 +174133,9 @@ static YYACTIONTYPE yy_reduce(
173042 break; 174133 break;
173043 case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ 174134 case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
173044 case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); 174135 case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
173045 case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); 174136 case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217);
173046 case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); 174137 case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220);
173047 case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); 174138 case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245);
173048{yymsp[-1].minor.yy394 = 1;} 174139{yymsp[-1].minor.yy394 = 1;}
173049 break; 174140 break;
173050 case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ 174141 case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
@@ -173193,9 +174284,9 @@ static YYACTIONTYPE yy_reduce(
173193 case 99: /* sclp ::= */ 174284 case 99: /* sclp ::= */
173194 case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); 174285 case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132);
173195 case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); 174286 case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142);
173196 case 230: /* exprlist ::= */ yytestcase(yyruleno==230); 174287 case 232: /* exprlist ::= */ yytestcase(yyruleno==232);
173197 case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); 174288 case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235);
173198 case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); 174289 case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240);
173199{yymsp[1].minor.yy322 = 0;} 174290{yymsp[1].minor.yy322 = 0;}
173200 break; 174291 break;
173201 case 100: /* selcollist ::= sclp scanpt expr scanpt as */ 174292 case 100: /* selcollist ::= sclp scanpt expr scanpt as */
@@ -173224,8 +174315,8 @@ static YYACTIONTYPE yy_reduce(
173224 break; 174315 break;
173225 case 103: /* as ::= AS nm */ 174316 case 103: /* as ::= AS nm */
173226 case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); 174317 case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115);
173227 case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); 174318 case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256);
173228 case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); 174319 case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257);
173229{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} 174320{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
173230 break; 174321 break;
173231 case 105: /* from ::= */ 174322 case 105: /* from ::= */
@@ -173397,16 +174488,16 @@ static YYACTIONTYPE yy_reduce(
173397 case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); 174488 case 146: /* limit_opt ::= */ yytestcase(yyruleno==146);
173398 case 151: /* where_opt ::= */ yytestcase(yyruleno==151); 174489 case 151: /* where_opt ::= */ yytestcase(yyruleno==151);
173399 case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); 174490 case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153);
173400 case 228: /* case_else ::= */ yytestcase(yyruleno==228); 174491 case 230: /* case_else ::= */ yytestcase(yyruleno==230);
173401 case 229: /* case_operand ::= */ yytestcase(yyruleno==229); 174492 case 231: /* case_operand ::= */ yytestcase(yyruleno==231);
173402 case 248: /* vinto ::= */ yytestcase(yyruleno==248); 174493 case 250: /* vinto ::= */ yytestcase(yyruleno==250);
173403{yymsp[1].minor.yy528 = 0;} 174494{yymsp[1].minor.yy528 = 0;}
173404 break; 174495 break;
173405 case 145: /* having_opt ::= HAVING expr */ 174496 case 145: /* having_opt ::= HAVING expr */
173406 case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); 174497 case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152);
173407 case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); 174498 case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154);
173408 case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); 174499 case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229);
173409 case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); 174500 case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249);
173410{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} 174501{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;}
173411 break; 174502 break;
173412 case 147: /* limit_opt ::= LIMIT expr */ 174503 case 147: /* limit_opt ::= LIMIT expr */
@@ -173592,33 +174683,48 @@ static YYACTIONTYPE yy_reduce(
173592} 174683}
173593 yymsp[-4].minor.yy528 = yylhsminor.yy528; 174684 yymsp[-4].minor.yy528 = yylhsminor.yy528;
173594 break; 174685 break;
173595 case 188: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ 174686 case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
174687{
174688 yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394);
174689 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322);
174690}
174691 yymsp[-7].minor.yy528 = yylhsminor.yy528;
174692 break;
174693 case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
173596{ 174694{
173597 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); 174695 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
173598} 174696}
173599 yymsp[-3].minor.yy528 = yylhsminor.yy528; 174697 yymsp[-3].minor.yy528 = yylhsminor.yy528;
173600 break; 174698 break;
173601 case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ 174699 case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
173602{ 174700{
173603 yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); 174701 yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394);
173604 sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); 174702 sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
173605} 174703}
173606 yymsp[-5].minor.yy528 = yylhsminor.yy528; 174704 yymsp[-5].minor.yy528 = yylhsminor.yy528;
173607 break; 174705 break;
173608 case 190: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ 174706 case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
174707{
174708 yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394);
174709 sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
174710 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322);
174711}
174712 yymsp[-8].minor.yy528 = yylhsminor.yy528;
174713 break;
174714 case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
173609{ 174715{
173610 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); 174716 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
173611 sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); 174717 sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
173612} 174718}
173613 yymsp[-4].minor.yy528 = yylhsminor.yy528; 174719 yymsp[-4].minor.yy528 = yylhsminor.yy528;
173614 break; 174720 break;
173615 case 191: /* term ::= CTIME_KW */ 174721 case 193: /* term ::= CTIME_KW */
173616{ 174722{
173617 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); 174723 yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
173618} 174724}
173619 yymsp[0].minor.yy528 = yylhsminor.yy528; 174725 yymsp[0].minor.yy528 = yylhsminor.yy528;
173620 break; 174726 break;
173621 case 192: /* expr ::= LP nexprlist COMMA expr RP */ 174727 case 194: /* expr ::= LP nexprlist COMMA expr RP */
173622{ 174728{
173623 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); 174729 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528);
173624 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); 174730 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
@@ -173632,22 +174738,22 @@ static YYACTIONTYPE yy_reduce(
173632 } 174738 }
173633} 174739}
173634 break; 174740 break;
173635 case 193: /* expr ::= expr AND expr */ 174741 case 195: /* expr ::= expr AND expr */
173636{yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} 174742{yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
173637 break; 174743 break;
173638 case 194: /* expr ::= expr OR expr */ 174744 case 196: /* expr ::= expr OR expr */
173639 case 195: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==195); 174745 case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197);
173640 case 196: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==196); 174746 case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198);
173641 case 197: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==197); 174747 case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199);
173642 case 198: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==198); 174748 case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200);
173643 case 199: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==199); 174749 case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201);
173644 case 200: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==200); 174750 case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202);
173645{yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} 174751{yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
173646 break; 174752 break;
173647 case 201: /* likeop ::= NOT LIKE_KW|MATCH */ 174753 case 203: /* likeop ::= NOT LIKE_KW|MATCH */
173648{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} 174754{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
173649 break; 174755 break;
173650 case 202: /* expr ::= expr likeop expr */ 174756 case 204: /* expr ::= expr likeop expr */
173651{ 174757{
173652 ExprList *pList; 174758 ExprList *pList;
173653 int bNot = yymsp[-1].minor.yy0.n & 0x80000000; 174759 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
@@ -173659,7 +174765,7 @@ static YYACTIONTYPE yy_reduce(
173659 if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; 174765 if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc;
173660} 174766}
173661 break; 174767 break;
173662 case 203: /* expr ::= expr likeop expr ESCAPE expr */ 174768 case 205: /* expr ::= expr likeop expr ESCAPE expr */
173663{ 174769{
173664 ExprList *pList; 174770 ExprList *pList;
173665 int bNot = yymsp[-3].minor.yy0.n & 0x80000000; 174771 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
@@ -173672,47 +174778,47 @@ static YYACTIONTYPE yy_reduce(
173672 if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; 174778 if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc;
173673} 174779}
173674 break; 174780 break;
173675 case 204: /* expr ::= expr ISNULL|NOTNULL */ 174781 case 206: /* expr ::= expr ISNULL|NOTNULL */
173676{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} 174782{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);}
173677 break; 174783 break;
173678 case 205: /* expr ::= expr NOT NULL */ 174784 case 207: /* expr ::= expr NOT NULL */
173679{yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} 174785{yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);}
173680 break; 174786 break;
173681 case 206: /* expr ::= expr IS expr */ 174787 case 208: /* expr ::= expr IS expr */
173682{ 174788{
173683 yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); 174789 yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);
173684 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); 174790 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL);
173685} 174791}
173686 break; 174792 break;
173687 case 207: /* expr ::= expr IS NOT expr */ 174793 case 209: /* expr ::= expr IS NOT expr */
173688{ 174794{
173689 yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); 174795 yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528);
173690 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); 174796 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL);
173691} 174797}
173692 break; 174798 break;
173693 case 208: /* expr ::= expr IS NOT DISTINCT FROM expr */ 174799 case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */
173694{ 174800{
173695 yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); 174801 yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528);
173696 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); 174802 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL);
173697} 174803}
173698 break; 174804 break;
173699 case 209: /* expr ::= expr IS DISTINCT FROM expr */ 174805 case 211: /* expr ::= expr IS DISTINCT FROM expr */
173700{ 174806{
173701 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); 174807 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528);
173702 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); 174808 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL);
173703} 174809}
173704 break; 174810 break;
173705 case 210: /* expr ::= NOT expr */ 174811 case 212: /* expr ::= NOT expr */
173706 case 211: /* expr ::= BITNOT expr */ yytestcase(yyruleno==211); 174812 case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213);
173707{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} 174813{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/}
173708 break; 174814 break;
173709 case 212: /* expr ::= PLUS|MINUS expr */ 174815 case 214: /* expr ::= PLUS|MINUS expr */
173710{ 174816{
173711 yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); 174817 yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0);
173712 /*A-overwrites-B*/ 174818 /*A-overwrites-B*/
173713} 174819}
173714 break; 174820 break;
173715 case 213: /* expr ::= expr PTR expr */ 174821 case 215: /* expr ::= expr PTR expr */
173716{ 174822{
173717 ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); 174823 ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528);
173718 pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); 174824 pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528);
@@ -173720,11 +174826,11 @@ static YYACTIONTYPE yy_reduce(
173720} 174826}
173721 yymsp[-2].minor.yy528 = yylhsminor.yy528; 174827 yymsp[-2].minor.yy528 = yylhsminor.yy528;
173722 break; 174828 break;
173723 case 214: /* between_op ::= BETWEEN */ 174829 case 216: /* between_op ::= BETWEEN */
173724 case 217: /* in_op ::= IN */ yytestcase(yyruleno==217); 174830 case 219: /* in_op ::= IN */ yytestcase(yyruleno==219);
173725{yymsp[0].minor.yy394 = 0;} 174831{yymsp[0].minor.yy394 = 0;}
173726 break; 174832 break;
173727 case 216: /* expr ::= expr between_op expr AND expr */ 174833 case 218: /* expr ::= expr between_op expr AND expr */
173728{ 174834{
173729 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); 174835 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
173730 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); 174836 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
@@ -173737,7 +174843,7 @@ static YYACTIONTYPE yy_reduce(
173737 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); 174843 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
173738} 174844}
173739 break; 174845 break;
173740 case 219: /* expr ::= expr in_op LP exprlist RP */ 174846 case 221: /* expr ::= expr in_op LP exprlist RP */
173741{ 174847{
173742 if( yymsp[-1].minor.yy322==0 ){ 174848 if( yymsp[-1].minor.yy322==0 ){
173743 /* Expressions of the form 174849 /* Expressions of the form
@@ -173783,20 +174889,20 @@ static YYACTIONTYPE yy_reduce(
173783 } 174889 }
173784 } 174890 }
173785 break; 174891 break;
173786 case 220: /* expr ::= LP select RP */ 174892 case 222: /* expr ::= LP select RP */
173787{ 174893{
173788 yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); 174894 yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
173789 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); 174895 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47);
173790 } 174896 }
173791 break; 174897 break;
173792 case 221: /* expr ::= expr in_op LP select RP */ 174898 case 223: /* expr ::= expr in_op LP select RP */
173793{ 174899{
173794 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); 174900 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
173795 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); 174901 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47);
173796 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); 174902 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
173797 } 174903 }
173798 break; 174904 break;
173799 case 222: /* expr ::= expr in_op nm dbnm paren_exprlist */ 174905 case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */
173800{ 174906{
173801 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); 174907 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
173802 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); 174908 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
@@ -173806,14 +174912,14 @@ static YYACTIONTYPE yy_reduce(
173806 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); 174912 if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
173807 } 174913 }
173808 break; 174914 break;
173809 case 223: /* expr ::= EXISTS LP select RP */ 174915 case 225: /* expr ::= EXISTS LP select RP */
173810{ 174916{
173811 Expr *p; 174917 Expr *p;
173812 p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); 174918 p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
173813 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); 174919 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47);
173814 } 174920 }
173815 break; 174921 break;
173816 case 224: /* expr ::= CASE case_operand case_exprlist case_else END */ 174922 case 226: /* expr ::= CASE case_operand case_exprlist case_else END */
173817{ 174923{
173818 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); 174924 yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0);
173819 if( yymsp[-4].minor.yy528 ){ 174925 if( yymsp[-4].minor.yy528 ){
@@ -173825,29 +174931,29 @@ static YYACTIONTYPE yy_reduce(
173825 } 174931 }
173826} 174932}
173827 break; 174933 break;
173828 case 225: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ 174934 case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
173829{ 174935{
173830 yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); 174936 yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
173831 yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); 174937 yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
173832} 174938}
173833 break; 174939 break;
173834 case 226: /* case_exprlist ::= WHEN expr THEN expr */ 174940 case 228: /* case_exprlist ::= WHEN expr THEN expr */
173835{ 174941{
173836 yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); 174942 yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
173837 yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); 174943 yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528);
173838} 174944}
173839 break; 174945 break;
173840 case 231: /* nexprlist ::= nexprlist COMMA expr */ 174946 case 233: /* nexprlist ::= nexprlist COMMA expr */
173841{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} 174947{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);}
173842 break; 174948 break;
173843 case 232: /* nexprlist ::= expr */ 174949 case 234: /* nexprlist ::= expr */
173844{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} 174950{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/}
173845 break; 174951 break;
173846 case 234: /* paren_exprlist ::= LP exprlist RP */ 174952 case 236: /* paren_exprlist ::= LP exprlist RP */
173847 case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); 174953 case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241);
173848{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} 174954{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
173849 break; 174955 break;
173850 case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ 174956 case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
173851{ 174957{
173852 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 174958 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
173853 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, 174959 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394,
@@ -173857,48 +174963,48 @@ static YYACTIONTYPE yy_reduce(
173857 } 174963 }
173858} 174964}
173859 break; 174965 break;
173860 case 236: /* uniqueflag ::= UNIQUE */ 174966 case 238: /* uniqueflag ::= UNIQUE */
173861 case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); 174967 case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280);
173862{yymsp[0].minor.yy394 = OE_Abort;} 174968{yymsp[0].minor.yy394 = OE_Abort;}
173863 break; 174969 break;
173864 case 237: /* uniqueflag ::= */ 174970 case 239: /* uniqueflag ::= */
173865{yymsp[1].minor.yy394 = OE_None;} 174971{yymsp[1].minor.yy394 = OE_None;}
173866 break; 174972 break;
173867 case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ 174973 case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */
173868{ 174974{
173869 yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); 174975 yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394);
173870} 174976}
173871 break; 174977 break;
173872 case 241: /* eidlist ::= nm collate sortorder */ 174978 case 243: /* eidlist ::= nm collate sortorder */
173873{ 174979{
173874 yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ 174980 yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/
173875} 174981}
173876 break; 174982 break;
173877 case 244: /* cmd ::= DROP INDEX ifexists fullname */ 174983 case 246: /* cmd ::= DROP INDEX ifexists fullname */
173878{sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} 174984{sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);}
173879 break; 174985 break;
173880 case 245: /* cmd ::= VACUUM vinto */ 174986 case 247: /* cmd ::= VACUUM vinto */
173881{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} 174987{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);}
173882 break; 174988 break;
173883 case 246: /* cmd ::= VACUUM nm vinto */ 174989 case 248: /* cmd ::= VACUUM nm vinto */
173884{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} 174990{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);}
173885 break; 174991 break;
173886 case 249: /* cmd ::= PRAGMA nm dbnm */ 174992 case 251: /* cmd ::= PRAGMA nm dbnm */
173887{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} 174993{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
173888 break; 174994 break;
173889 case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ 174995 case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
173890{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} 174996{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
173891 break; 174997 break;
173892 case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ 174998 case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
173893{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} 174999{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
173894 break; 175000 break;
173895 case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ 175001 case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
173896{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} 175002{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
173897 break; 175003 break;
173898 case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ 175004 case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
173899{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} 175005{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
173900 break; 175006 break;
173901 case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ 175007 case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
173902{ 175008{
173903 Token all; 175009 Token all;
173904 all.z = yymsp[-3].minor.yy0.z; 175010 all.z = yymsp[-3].minor.yy0.z;
@@ -173906,50 +175012,50 @@ static YYACTIONTYPE yy_reduce(
173906 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); 175012 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all);
173907} 175013}
173908 break; 175014 break;
173909 case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ 175015 case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
173910{ 175016{
173911 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394); 175017 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394);
173912 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ 175018 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
173913} 175019}
173914 break; 175020 break;
173915 case 258: /* trigger_time ::= BEFORE|AFTER */ 175021 case 260: /* trigger_time ::= BEFORE|AFTER */
173916{ yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } 175022{ yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ }
173917 break; 175023 break;
173918 case 259: /* trigger_time ::= INSTEAD OF */ 175024 case 261: /* trigger_time ::= INSTEAD OF */
173919{ yymsp[-1].minor.yy394 = TK_INSTEAD;} 175025{ yymsp[-1].minor.yy394 = TK_INSTEAD;}
173920 break; 175026 break;
173921 case 260: /* trigger_time ::= */ 175027 case 262: /* trigger_time ::= */
173922{ yymsp[1].minor.yy394 = TK_BEFORE; } 175028{ yymsp[1].minor.yy394 = TK_BEFORE; }
173923 break; 175029 break;
173924 case 261: /* trigger_event ::= DELETE|INSERT */ 175030 case 263: /* trigger_event ::= DELETE|INSERT */
173925 case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); 175031 case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264);
173926{yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} 175032{yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;}
173927 break; 175033 break;
173928 case 263: /* trigger_event ::= UPDATE OF idlist */ 175034 case 265: /* trigger_event ::= UPDATE OF idlist */
173929{yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} 175035{yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;}
173930 break; 175036 break;
173931 case 264: /* when_clause ::= */ 175037 case 266: /* when_clause ::= */
173932 case 283: /* key_opt ::= */ yytestcase(yyruleno==283); 175038 case 285: /* key_opt ::= */ yytestcase(yyruleno==285);
173933{ yymsp[1].minor.yy528 = 0; } 175039{ yymsp[1].minor.yy528 = 0; }
173934 break; 175040 break;
173935 case 265: /* when_clause ::= WHEN expr */ 175041 case 267: /* when_clause ::= WHEN expr */
173936 case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); 175042 case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286);
173937{ yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } 175043{ yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; }
173938 break; 175044 break;
173939 case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ 175045 case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
173940{ 175046{
173941 assert( yymsp[-2].minor.yy33!=0 ); 175047 assert( yymsp[-2].minor.yy33!=0 );
173942 yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; 175048 yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33;
173943 yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; 175049 yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33;
173944} 175050}
173945 break; 175051 break;
173946 case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ 175052 case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */
173947{ 175053{
173948 assert( yymsp[-1].minor.yy33!=0 ); 175054 assert( yymsp[-1].minor.yy33!=0 );
173949 yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; 175055 yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33;
173950} 175056}
173951 break; 175057 break;
173952 case 268: /* trnm ::= nm DOT nm */ 175058 case 270: /* trnm ::= nm DOT nm */
173953{ 175059{
173954 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; 175060 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
173955 sqlite3ErrorMsg(pParse, 175061 sqlite3ErrorMsg(pParse,
@@ -173957,39 +175063,39 @@ static YYACTIONTYPE yy_reduce(
173957 "statements within triggers"); 175063 "statements within triggers");
173958} 175064}
173959 break; 175065 break;
173960 case 269: /* tridxby ::= INDEXED BY nm */ 175066 case 271: /* tridxby ::= INDEXED BY nm */
173961{ 175067{
173962 sqlite3ErrorMsg(pParse, 175068 sqlite3ErrorMsg(pParse,
173963 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " 175069 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
173964 "within triggers"); 175070 "within triggers");
173965} 175071}
173966 break; 175072 break;
173967 case 270: /* tridxby ::= NOT INDEXED */ 175073 case 272: /* tridxby ::= NOT INDEXED */
173968{ 175074{
173969 sqlite3ErrorMsg(pParse, 175075 sqlite3ErrorMsg(pParse,
173970 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " 175076 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
173971 "within triggers"); 175077 "within triggers");
173972} 175078}
173973 break; 175079 break;
173974 case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ 175080 case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
173975{yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);} 175081{yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);}
173976 yymsp[-8].minor.yy33 = yylhsminor.yy33; 175082 yymsp[-8].minor.yy33 = yylhsminor.yy33;
173977 break; 175083 break;
173978 case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ 175084 case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
173979{ 175085{
173980 yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/ 175086 yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/
173981} 175087}
173982 yymsp[-7].minor.yy33 = yylhsminor.yy33; 175088 yymsp[-7].minor.yy33 = yylhsminor.yy33;
173983 break; 175089 break;
173984 case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ 175090 case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
173985{yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} 175091{yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);}
173986 yymsp[-5].minor.yy33 = yylhsminor.yy33; 175092 yymsp[-5].minor.yy33 = yylhsminor.yy33;
173987 break; 175093 break;
173988 case 274: /* trigger_cmd ::= scanpt select scanpt */ 175094 case 276: /* trigger_cmd ::= scanpt select scanpt */
173989{yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} 175095{yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/}
173990 yymsp[-2].minor.yy33 = yylhsminor.yy33; 175096 yymsp[-2].minor.yy33 = yylhsminor.yy33;
173991 break; 175097 break;
173992 case 275: /* expr ::= RAISE LP IGNORE RP */ 175098 case 277: /* expr ::= RAISE LP IGNORE RP */
173993{ 175099{
173994 yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 175100 yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
173995 if( yymsp[-3].minor.yy528 ){ 175101 if( yymsp[-3].minor.yy528 ){
@@ -173997,7 +175103,7 @@ static YYACTIONTYPE yy_reduce(
173997 } 175103 }
173998} 175104}
173999 break; 175105 break;
174000 case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ 175106 case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */
174001{ 175107{
174002 yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 175108 yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
174003 if( yymsp[-5].minor.yy528 ) { 175109 if( yymsp[-5].minor.yy528 ) {
@@ -174005,114 +175111,114 @@ static YYACTIONTYPE yy_reduce(
174005 } 175111 }
174006} 175112}
174007 break; 175113 break;
174008 case 277: /* raisetype ::= ROLLBACK */ 175114 case 279: /* raisetype ::= ROLLBACK */
174009{yymsp[0].minor.yy394 = OE_Rollback;} 175115{yymsp[0].minor.yy394 = OE_Rollback;}
174010 break; 175116 break;
174011 case 279: /* raisetype ::= FAIL */ 175117 case 281: /* raisetype ::= FAIL */
174012{yymsp[0].minor.yy394 = OE_Fail;} 175118{yymsp[0].minor.yy394 = OE_Fail;}
174013 break; 175119 break;
174014 case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ 175120 case 282: /* cmd ::= DROP TRIGGER ifexists fullname */
174015{ 175121{
174016 sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); 175122 sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394);
174017} 175123}
174018 break; 175124 break;
174019 case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ 175125 case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
174020{ 175126{
174021 sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); 175127 sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528);
174022} 175128}
174023 break; 175129 break;
174024 case 282: /* cmd ::= DETACH database_kw_opt expr */ 175130 case 284: /* cmd ::= DETACH database_kw_opt expr */
174025{ 175131{
174026 sqlite3Detach(pParse, yymsp[0].minor.yy528); 175132 sqlite3Detach(pParse, yymsp[0].minor.yy528);
174027} 175133}
174028 break; 175134 break;
174029 case 285: /* cmd ::= REINDEX */ 175135 case 287: /* cmd ::= REINDEX */
174030{sqlite3Reindex(pParse, 0, 0);} 175136{sqlite3Reindex(pParse, 0, 0);}
174031 break; 175137 break;
174032 case 286: /* cmd ::= REINDEX nm dbnm */ 175138 case 288: /* cmd ::= REINDEX nm dbnm */
174033{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} 175139{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
174034 break; 175140 break;
174035 case 287: /* cmd ::= ANALYZE */ 175141 case 289: /* cmd ::= ANALYZE */
174036{sqlite3Analyze(pParse, 0, 0);} 175142{sqlite3Analyze(pParse, 0, 0);}
174037 break; 175143 break;
174038 case 288: /* cmd ::= ANALYZE nm dbnm */ 175144 case 290: /* cmd ::= ANALYZE nm dbnm */
174039{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} 175145{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
174040 break; 175146 break;
174041 case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ 175147 case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
174042{ 175148{
174043 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); 175149 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0);
174044} 175150}
174045 break; 175151 break;
174046 case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ 175152 case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
174047{ 175153{
174048 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; 175154 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
174049 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); 175155 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
174050} 175156}
174051 break; 175157 break;
174052 case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ 175158 case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
174053{ 175159{
174054 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); 175160 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0);
174055} 175161}
174056 break; 175162 break;
174057 case 292: /* add_column_fullname ::= fullname */ 175163 case 294: /* add_column_fullname ::= fullname */
174058{ 175164{
174059 disableLookaside(pParse); 175165 disableLookaside(pParse);
174060 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); 175166 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131);
174061} 175167}
174062 break; 175168 break;
174063 case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ 175169 case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
174064{ 175170{
174065 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); 175171 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
174066} 175172}
174067 break; 175173 break;
174068 case 294: /* cmd ::= create_vtab */ 175174 case 296: /* cmd ::= create_vtab */
174069{sqlite3VtabFinishParse(pParse,0);} 175175{sqlite3VtabFinishParse(pParse,0);}
174070 break; 175176 break;
174071 case 295: /* cmd ::= create_vtab LP vtabarglist RP */ 175177 case 297: /* cmd ::= create_vtab LP vtabarglist RP */
174072{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} 175178{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
174073 break; 175179 break;
174074 case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ 175180 case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
174075{ 175181{
174076 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); 175182 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394);
174077} 175183}
174078 break; 175184 break;
174079 case 297: /* vtabarg ::= */ 175185 case 299: /* vtabarg ::= */
174080{sqlite3VtabArgInit(pParse);} 175186{sqlite3VtabArgInit(pParse);}
174081 break; 175187 break;
174082 case 298: /* vtabargtoken ::= ANY */ 175188 case 300: /* vtabargtoken ::= ANY */
174083 case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); 175189 case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301);
174084 case 300: /* lp ::= LP */ yytestcase(yyruleno==300); 175190 case 302: /* lp ::= LP */ yytestcase(yyruleno==302);
174085{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} 175191{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
174086 break; 175192 break;
174087 case 301: /* with ::= WITH wqlist */ 175193 case 303: /* with ::= WITH wqlist */
174088 case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); 175194 case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304);
174089{ sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } 175195{ sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); }
174090 break; 175196 break;
174091 case 303: /* wqas ::= AS */ 175197 case 305: /* wqas ::= AS */
174092{yymsp[0].minor.yy516 = M10d_Any;} 175198{yymsp[0].minor.yy516 = M10d_Any;}
174093 break; 175199 break;
174094 case 304: /* wqas ::= AS MATERIALIZED */ 175200 case 306: /* wqas ::= AS MATERIALIZED */
174095{yymsp[-1].minor.yy516 = M10d_Yes;} 175201{yymsp[-1].minor.yy516 = M10d_Yes;}
174096 break; 175202 break;
174097 case 305: /* wqas ::= AS NOT MATERIALIZED */ 175203 case 307: /* wqas ::= AS NOT MATERIALIZED */
174098{yymsp[-2].minor.yy516 = M10d_No;} 175204{yymsp[-2].minor.yy516 = M10d_No;}
174099 break; 175205 break;
174100 case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ 175206 case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */
174101{ 175207{
174102 yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/ 175208 yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/
174103} 175209}
174104 break; 175210 break;
174105 case 307: /* wqlist ::= wqitem */ 175211 case 309: /* wqlist ::= wqitem */
174106{ 175212{
174107 yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ 175213 yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/
174108} 175214}
174109 break; 175215 break;
174110 case 308: /* wqlist ::= wqlist COMMA wqitem */ 175216 case 310: /* wqlist ::= wqlist COMMA wqitem */
174111{ 175217{
174112 yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); 175218 yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385);
174113} 175219}
174114 break; 175220 break;
174115 case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ 175221 case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
174116{ 175222{
174117 assert( yymsp[0].minor.yy41!=0 ); 175223 assert( yymsp[0].minor.yy41!=0 );
174118 sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); 175224 sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41);
@@ -174121,7 +175227,7 @@ static YYACTIONTYPE yy_reduce(
174121} 175227}
174122 yymsp[-2].minor.yy41 = yylhsminor.yy41; 175228 yymsp[-2].minor.yy41 = yylhsminor.yy41;
174123 break; 175229 break;
174124 case 310: /* windowdefn ::= nm AS LP window RP */ 175230 case 312: /* windowdefn ::= nm AS LP window RP */
174125{ 175231{
174126 if( ALWAYS(yymsp[-1].minor.yy41) ){ 175232 if( ALWAYS(yymsp[-1].minor.yy41) ){
174127 yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); 175233 yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
@@ -174130,83 +175236,83 @@ static YYACTIONTYPE yy_reduce(
174130} 175236}
174131 yymsp[-4].minor.yy41 = yylhsminor.yy41; 175237 yymsp[-4].minor.yy41 = yylhsminor.yy41;
174132 break; 175238 break;
174133 case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ 175239 case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
174134{ 175240{
174135 yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); 175241 yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0);
174136} 175242}
174137 break; 175243 break;
174138 case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ 175244 case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
174139{ 175245{
174140 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); 175246 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0);
174141} 175247}
174142 yymsp[-5].minor.yy41 = yylhsminor.yy41; 175248 yymsp[-5].minor.yy41 = yylhsminor.yy41;
174143 break; 175249 break;
174144 case 313: /* window ::= ORDER BY sortlist frame_opt */ 175250 case 315: /* window ::= ORDER BY sortlist frame_opt */
174145{ 175251{
174146 yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); 175252 yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0);
174147} 175253}
174148 break; 175254 break;
174149 case 314: /* window ::= nm ORDER BY sortlist frame_opt */ 175255 case 316: /* window ::= nm ORDER BY sortlist frame_opt */
174150{ 175256{
174151 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); 175257 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
174152} 175258}
174153 yymsp[-4].minor.yy41 = yylhsminor.yy41; 175259 yymsp[-4].minor.yy41 = yylhsminor.yy41;
174154 break; 175260 break;
174155 case 315: /* window ::= nm frame_opt */ 175261 case 317: /* window ::= nm frame_opt */
174156{ 175262{
174157 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); 175263 yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0);
174158} 175264}
174159 yymsp[-1].minor.yy41 = yylhsminor.yy41; 175265 yymsp[-1].minor.yy41 = yylhsminor.yy41;
174160 break; 175266 break;
174161 case 316: /* frame_opt ::= */ 175267 case 318: /* frame_opt ::= */
174162{ 175268{
174163 yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); 175269 yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
174164} 175270}
174165 break; 175271 break;
174166 case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ 175272 case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
174167{ 175273{
174168 yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); 175274 yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516);
174169} 175275}
174170 yymsp[-2].minor.yy41 = yylhsminor.yy41; 175276 yymsp[-2].minor.yy41 = yylhsminor.yy41;
174171 break; 175277 break;
174172 case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ 175278 case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
174173{ 175279{
174174 yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); 175280 yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516);
174175} 175281}
174176 yymsp[-5].minor.yy41 = yylhsminor.yy41; 175282 yymsp[-5].minor.yy41 = yylhsminor.yy41;
174177 break; 175283 break;
174178 case 320: /* frame_bound_s ::= frame_bound */ 175284 case 322: /* frame_bound_s ::= frame_bound */
174179 case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); 175285 case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324);
174180{yylhsminor.yy595 = yymsp[0].minor.yy595;} 175286{yylhsminor.yy595 = yymsp[0].minor.yy595;}
174181 yymsp[0].minor.yy595 = yylhsminor.yy595; 175287 yymsp[0].minor.yy595 = yylhsminor.yy595;
174182 break; 175288 break;
174183 case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ 175289 case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */
174184 case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); 175290 case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325);
174185 case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); 175291 case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327);
174186{yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} 175292{yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;}
174187 yymsp[-1].minor.yy595 = yylhsminor.yy595; 175293 yymsp[-1].minor.yy595 = yylhsminor.yy595;
174188 break; 175294 break;
174189 case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ 175295 case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */
174190{yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} 175296{yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;}
174191 yymsp[-1].minor.yy595 = yylhsminor.yy595; 175297 yymsp[-1].minor.yy595 = yylhsminor.yy595;
174192 break; 175298 break;
174193 case 326: /* frame_exclude_opt ::= */ 175299 case 328: /* frame_exclude_opt ::= */
174194{yymsp[1].minor.yy516 = 0;} 175300{yymsp[1].minor.yy516 = 0;}
174195 break; 175301 break;
174196 case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ 175302 case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
174197{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} 175303{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;}
174198 break; 175304 break;
174199 case 328: /* frame_exclude ::= NO OTHERS */ 175305 case 330: /* frame_exclude ::= NO OTHERS */
174200 case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); 175306 case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331);
174201{yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} 175307{yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/}
174202 break; 175308 break;
174203 case 330: /* frame_exclude ::= GROUP|TIES */ 175309 case 332: /* frame_exclude ::= GROUP|TIES */
174204{yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} 175310{yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/}
174205 break; 175311 break;
174206 case 331: /* window_clause ::= WINDOW windowdefn_list */ 175312 case 333: /* window_clause ::= WINDOW windowdefn_list */
174207{ yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } 175313{ yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; }
174208 break; 175314 break;
174209 case 332: /* filter_over ::= filter_clause over_clause */ 175315 case 334: /* filter_over ::= filter_clause over_clause */
174210{ 175316{
174211 if( yymsp[0].minor.yy41 ){ 175317 if( yymsp[0].minor.yy41 ){
174212 yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; 175318 yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528;
@@ -174217,13 +175323,13 @@ static YYACTIONTYPE yy_reduce(
174217} 175323}
174218 yymsp[-1].minor.yy41 = yylhsminor.yy41; 175324 yymsp[-1].minor.yy41 = yylhsminor.yy41;
174219 break; 175325 break;
174220 case 333: /* filter_over ::= over_clause */ 175326 case 335: /* filter_over ::= over_clause */
174221{ 175327{
174222 yylhsminor.yy41 = yymsp[0].minor.yy41; 175328 yylhsminor.yy41 = yymsp[0].minor.yy41;
174223} 175329}
174224 yymsp[0].minor.yy41 = yylhsminor.yy41; 175330 yymsp[0].minor.yy41 = yylhsminor.yy41;
174225 break; 175331 break;
174226 case 334: /* filter_over ::= filter_clause */ 175332 case 336: /* filter_over ::= filter_clause */
174227{ 175333{
174228 yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); 175334 yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
174229 if( yylhsminor.yy41 ){ 175335 if( yylhsminor.yy41 ){
@@ -174235,13 +175341,13 @@ static YYACTIONTYPE yy_reduce(
174235} 175341}
174236 yymsp[0].minor.yy41 = yylhsminor.yy41; 175342 yymsp[0].minor.yy41 = yylhsminor.yy41;
174237 break; 175343 break;
174238 case 335: /* over_clause ::= OVER LP window RP */ 175344 case 337: /* over_clause ::= OVER LP window RP */
174239{ 175345{
174240 yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; 175346 yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41;
174241 assert( yymsp[-3].minor.yy41!=0 ); 175347 assert( yymsp[-3].minor.yy41!=0 );
174242} 175348}
174243 break; 175349 break;
174244 case 336: /* over_clause ::= OVER nm */ 175350 case 338: /* over_clause ::= OVER nm */
174245{ 175351{
174246 yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); 175352 yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
174247 if( yymsp[-1].minor.yy41 ){ 175353 if( yymsp[-1].minor.yy41 ){
@@ -174249,75 +175355,75 @@ static YYACTIONTYPE yy_reduce(
174249 } 175355 }
174250} 175356}
174251 break; 175357 break;
174252 case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ 175358 case 339: /* filter_clause ::= FILTER LP WHERE expr RP */
174253{ yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } 175359{ yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; }
174254 break; 175360 break;
174255 default: 175361 default:
174256 /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); 175362 /* (340) input ::= cmdlist */ yytestcase(yyruleno==340);
174257 /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); 175363 /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341);
174258 /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); 175364 /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342);
174259 /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); 175365 /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343);
174260 /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); 175366 /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344);
174261 /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); 175367 /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345);
174262 /* (344) trans_opt ::= */ yytestcase(yyruleno==344); 175368 /* (346) trans_opt ::= */ yytestcase(yyruleno==346);
174263 /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); 175369 /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347);
174264 /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); 175370 /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348);
174265 /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); 175371 /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349);
174266 /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); 175372 /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350);
174267 /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); 175373 /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351);
174268 /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); 175374 /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352);
174269 /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); 175375 /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353);
174270 /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); 175376 /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354);
174271 /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); 175377 /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355);
174272 /* (354) nm ::= STRING */ yytestcase(yyruleno==354); 175378 /* (356) nm ::= STRING */ yytestcase(yyruleno==356);
174273 /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); 175379 /* (357) typetoken ::= typename */ yytestcase(yyruleno==357);
174274 /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); 175380 /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358);
174275 /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); 175381 /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359);
174276 /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); 175382 /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
174277 /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); 175383 /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361);
174278 /* (360) carglist ::= */ yytestcase(yyruleno==360); 175384 /* (362) carglist ::= */ yytestcase(yyruleno==362);
174279 /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); 175385 /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363);
174280 /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); 175386 /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364);
174281 /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); 175387 /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365);
174282 /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); 175388 /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366);
174283 /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); 175389 /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367);
174284 /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); 175390 /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368);
174285 /* (367) tconscomma ::= */ yytestcase(yyruleno==367); 175391 /* (369) tconscomma ::= */ yytestcase(yyruleno==369);
174286 /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); 175392 /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370);
174287 /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); 175393 /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371);
174288 /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); 175394 /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372);
174289 /* (371) oneselect ::= values */ yytestcase(yyruleno==371); 175395 /* (373) oneselect ::= values */ yytestcase(yyruleno==373);
174290 /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); 175396 /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374);
174291 /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); 175397 /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375);
174292 /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); 175398 /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376);
174293 /* (375) returning ::= */ yytestcase(yyruleno==375); 175399 /* (377) returning ::= */ yytestcase(yyruleno==377);
174294 /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); 175400 /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378);
174295 /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); 175401 /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379);
174296 /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); 175402 /* (380) case_operand ::= expr */ yytestcase(yyruleno==380);
174297 /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); 175403 /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381);
174298 /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); 175404 /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382);
174299 /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); 175405 /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383);
174300 /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); 175406 /* (384) nmnum ::= ON */ yytestcase(yyruleno==384);
174301 /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); 175407 /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385);
174302 /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); 175408 /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386);
174303 /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); 175409 /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387);
174304 /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); 175410 /* (388) foreach_clause ::= */ yytestcase(yyruleno==388);
174305 /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); 175411 /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389);
174306 /* (388) trnm ::= nm */ yytestcase(yyruleno==388); 175412 /* (390) trnm ::= nm */ yytestcase(yyruleno==390);
174307 /* (389) tridxby ::= */ yytestcase(yyruleno==389); 175413 /* (391) tridxby ::= */ yytestcase(yyruleno==391);
174308 /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); 175414 /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392);
174309 /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); 175415 /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393);
174310 /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); 175416 /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394);
174311 /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); 175417 /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395);
174312 /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); 175418 /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396);
174313 /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); 175419 /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397);
174314 /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); 175420 /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398);
174315 /* (397) anylist ::= */ yytestcase(yyruleno==397); 175421 /* (399) anylist ::= */ yytestcase(yyruleno==399);
174316 /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); 175422 /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400);
174317 /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); 175423 /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401);
174318 /* (400) with ::= */ yytestcase(yyruleno==400); 175424 /* (402) with ::= */ yytestcase(yyruleno==402);
174319 /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); 175425 /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403);
174320 /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); 175426 /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404);
174321 break; 175427 break;
174322/********** End reduce actions ************************************************/ 175428/********** End reduce actions ************************************************/
174323 }; 175429 };
@@ -176441,7 +177547,9 @@ SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
176441#ifdef SQLITE_ENABLE_STMTVTAB 177547#ifdef SQLITE_ENABLE_STMTVTAB
176442SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); 177548SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
176443#endif 177549#endif
176444 177550#ifdef SQLITE_EXTRA_AUTOEXT
177551int SQLITE_EXTRA_AUTOEXT(sqlite3*);
177552#endif
176445/* 177553/*
176446** An array of pointers to extension initializer functions for 177554** An array of pointers to extension initializer functions for
176447** built-in extensions. 177555** built-in extensions.
@@ -176475,6 +177583,9 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = {
176475#ifdef SQLITE_ENABLE_BYTECODE_VTAB 177583#ifdef SQLITE_ENABLE_BYTECODE_VTAB
176476 sqlite3VdbeBytecodeVtabInit, 177584 sqlite3VdbeBytecodeVtabInit,
176477#endif 177585#endif
177586#ifdef SQLITE_EXTRA_AUTOEXT
177587 SQLITE_EXTRA_AUTOEXT,
177588#endif
176478}; 177589};
176479 177590
176480#ifndef SQLITE_AMALGAMATION 177591#ifndef SQLITE_AMALGAMATION
@@ -176549,6 +177660,32 @@ SQLITE_API char *sqlite3_temp_directory = 0;
176549SQLITE_API char *sqlite3_data_directory = 0; 177660SQLITE_API char *sqlite3_data_directory = 0;
176550 177661
176551/* 177662/*
177663** Determine whether or not high-precision (long double) floating point
177664** math works correctly on CPU currently running.
177665*/
177666static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){
177667 if( sizeof(LONGDOUBLE_TYPE)<=8 ){
177668 /* If the size of "long double" is not more than 8, then
177669 ** high-precision math is not possible. */
177670 return 0;
177671 }else{
177672 /* Just because sizeof(long double)>8 does not mean that the underlying
177673 ** hardware actually supports high-precision floating point. For example,
177674 ** clearing the 0x100 bit in the floating-point control word on Intel
177675 ** processors will make long double work like double, even though long
177676 ** double takes up more space. The only way to determine if long double
177677 ** actually works is to run an experiment. */
177678 LONGDOUBLE_TYPE a, b, c;
177679 rc++;
177680 a = 1.0+rc*0.1;
177681 b = 1.0e+18+rc*25.0;
177682 c = a+b;
177683 return b!=c;
177684 }
177685}
177686
177687
177688/*
176552** Initialize SQLite. 177689** Initialize SQLite.
176553** 177690**
176554** This routine must be called to initialize the memory allocation, 177691** This routine must be called to initialize the memory allocation,
@@ -176743,6 +177880,12 @@ SQLITE_API int sqlite3_initialize(void){
176743 } 177880 }
176744#endif 177881#endif
176745 177882
177883 /* Experimentally determine if high-precision floating point is
177884 ** available. */
177885#ifndef SQLITE_OMIT_WSD
177886 sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc);
177887#endif
177888
176746 return rc; 177889 return rc;
176747} 177890}
176748 177891
@@ -177313,6 +178456,10 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3 *db){
177313SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ 178456SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
177314 va_list ap; 178457 va_list ap;
177315 int rc; 178458 int rc;
178459
178460#ifdef SQLITE_ENABLE_API_ARMOR
178461 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
178462#endif
177316 sqlite3_mutex_enter(db->mutex); 178463 sqlite3_mutex_enter(db->mutex);
177317 va_start(ap, op); 178464 va_start(ap, op);
177318 switch( op ){ 178465 switch( op ){
@@ -177642,6 +178789,14 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){
177642 } 178789 }
177643#endif 178790#endif
177644 178791
178792 while( db->pDbData ){
178793 DbClientData *p = db->pDbData;
178794 db->pDbData = p->pNext;
178795 assert( p->pData!=0 );
178796 if( p->xDestructor ) p->xDestructor(p->pData);
178797 sqlite3_free(p);
178798 }
178799
177645 /* Convert the connection into a zombie and then close it. 178800 /* Convert the connection into a zombie and then close it.
177646 */ 178801 */
177647 db->eOpenState = SQLITE_STATE_ZOMBIE; 178802 db->eOpenState = SQLITE_STATE_ZOMBIE;
@@ -178716,6 +179871,12 @@ SQLITE_API void *sqlite3_preupdate_hook(
178716 void *pArg /* First callback argument */ 179871 void *pArg /* First callback argument */
178717){ 179872){
178718 void *pRet; 179873 void *pRet;
179874
179875#ifdef SQLITE_ENABLE_API_ARMOR
179876 if( db==0 ){
179877 return 0;
179878 }
179879#endif
178719 sqlite3_mutex_enter(db->mutex); 179880 sqlite3_mutex_enter(db->mutex);
178720 pRet = db->pPreUpdateArg; 179881 pRet = db->pPreUpdateArg;
178721 db->xPreUpdateCallback = xCallback; 179882 db->xPreUpdateCallback = xCallback;
@@ -178862,7 +180023,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
178862 if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){ 180023 if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
178863 /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint 180024 /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
178864 ** mode: */ 180025 ** mode: */
178865 return SQLITE_MISUSE; 180026 return SQLITE_MISUSE_BKPT;
178866 } 180027 }
178867 180028
178868 sqlite3_mutex_enter(db->mutex); 180029 sqlite3_mutex_enter(db->mutex);
@@ -180099,6 +181260,69 @@ SQLITE_API int sqlite3_collation_needed16(
180099} 181260}
180100#endif /* SQLITE_OMIT_UTF16 */ 181261#endif /* SQLITE_OMIT_UTF16 */
180101 181262
181263/*
181264** Find existing client data.
181265*/
181266SQLITE_API void *sqlite3_get_clientdata(sqlite3 *db, const char *zName){
181267 DbClientData *p;
181268 sqlite3_mutex_enter(db->mutex);
181269 for(p=db->pDbData; p; p=p->pNext){
181270 if( strcmp(p->zName, zName)==0 ){
181271 void *pResult = p->pData;
181272 sqlite3_mutex_leave(db->mutex);
181273 return pResult;
181274 }
181275 }
181276 sqlite3_mutex_leave(db->mutex);
181277 return 0;
181278}
181279
181280/*
181281** Add new client data to a database connection.
181282*/
181283SQLITE_API int sqlite3_set_clientdata(
181284 sqlite3 *db, /* Attach client data to this connection */
181285 const char *zName, /* Name of the client data */
181286 void *pData, /* The client data itself */
181287 void (*xDestructor)(void*) /* Destructor */
181288){
181289 DbClientData *p, **pp;
181290 sqlite3_mutex_enter(db->mutex);
181291 pp = &db->pDbData;
181292 for(p=db->pDbData; p && strcmp(p->zName,zName); p=p->pNext){
181293 pp = &p->pNext;
181294 }
181295 if( p ){
181296 assert( p->pData!=0 );
181297 if( p->xDestructor ) p->xDestructor(p->pData);
181298 if( pData==0 ){
181299 *pp = p->pNext;
181300 sqlite3_free(p);
181301 sqlite3_mutex_leave(db->mutex);
181302 return SQLITE_OK;
181303 }
181304 }else if( pData==0 ){
181305 sqlite3_mutex_leave(db->mutex);
181306 return SQLITE_OK;
181307 }else{
181308 size_t n = strlen(zName);
181309 p = sqlite3_malloc64( sizeof(DbClientData)+n+1 );
181310 if( p==0 ){
181311 if( xDestructor ) xDestructor(pData);
181312 sqlite3_mutex_leave(db->mutex);
181313 return SQLITE_NOMEM;
181314 }
181315 memcpy(p->zName, zName, n+1);
181316 p->pNext = db->pDbData;
181317 db->pDbData = p;
181318 }
181319 p->pData = pData;
181320 p->xDestructor = xDestructor;
181321 sqlite3_mutex_leave(db->mutex);
181322 return SQLITE_OK;
181323}
181324
181325
180102#ifndef SQLITE_OMIT_DEPRECATED 181326#ifndef SQLITE_OMIT_DEPRECATED
180103/* 181327/*
180104** This function is now an anachronism. It used to be used to recover from a 181328** This function is now an anachronism. It used to be used to recover from a
@@ -180448,6 +181672,28 @@ SQLITE_API int sqlite3_test_control(int op, ...){
180448 } 181672 }
180449#endif 181673#endif
180450 181674
181675 /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b);
181676 **
181677 ** If b is true, then activate the SQLITE_FkNoAction setting. If b is
181678 ** false then clearn that setting. If the SQLITE_FkNoAction setting is
181679 ** abled, all foreign key ON DELETE and ON UPDATE actions behave as if
181680 ** they were NO ACTION, regardless of how they are defined.
181681 **
181682 ** NB: One must usually run "PRAGMA writable_schema=RESET" after
181683 ** using this test-control, before it will take full effect. failing
181684 ** to reset the schema can result in some unexpected behavior.
181685 */
181686 case SQLITE_TESTCTRL_FK_NO_ACTION: {
181687 sqlite3 *db = va_arg(ap, sqlite3*);
181688 int b = va_arg(ap, int);
181689 if( b ){
181690 db->flags |= SQLITE_FkNoAction;
181691 }else{
181692 db->flags &= ~SQLITE_FkNoAction;
181693 }
181694 break;
181695 }
181696
180451 /* 181697 /*
180452 ** sqlite3_test_control(BITVEC_TEST, size, program) 181698 ** sqlite3_test_control(BITVEC_TEST, size, program)
180453 ** 181699 **
@@ -180872,11 +182118,11 @@ SQLITE_API int sqlite3_test_control(int op, ...){
180872 ** X<0 Make no changes to the bUseLongDouble. Just report value. 182118 ** X<0 Make no changes to the bUseLongDouble. Just report value.
180873 ** X==0 Disable bUseLongDouble 182119 ** X==0 Disable bUseLongDouble
180874 ** X==1 Enable bUseLongDouble 182120 ** X==1 Enable bUseLongDouble
180875 ** X==2 Set bUseLongDouble to its default value for this platform 182121 ** X>=2 Set bUseLongDouble to its default value for this platform
180876 */ 182122 */
180877 case SQLITE_TESTCTRL_USELONGDOUBLE: { 182123 case SQLITE_TESTCTRL_USELONGDOUBLE: {
180878 int b = va_arg(ap, int); 182124 int b = va_arg(ap, int);
180879 if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; 182125 if( b>=2 ) b = hasHighPrecisionDouble(b);
180880 if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; 182126 if( b>=0 ) sqlite3Config.bUseLongDouble = b>0;
180881 rc = sqlite3Config.bUseLongDouble!=0; 182127 rc = sqlite3Config.bUseLongDouble!=0;
180882 break; 182128 break;
@@ -181290,7 +182536,7 @@ SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
181290 int nOpt; 182536 int nOpt;
181291 const char **azCompileOpt; 182537 const char **azCompileOpt;
181292 182538
181293#if SQLITE_ENABLE_API_ARMOR 182539#ifdef SQLITE_ENABLE_API_ARMOR
181294 if( zOptName==0 ){ 182540 if( zOptName==0 ){
181295 (void)SQLITE_MISUSE_BKPT; 182541 (void)SQLITE_MISUSE_BKPT;
181296 return 0; 182542 return 0;
@@ -181485,6 +182731,9 @@ SQLITE_API int sqlite3_unlock_notify(
181485){ 182731){
181486 int rc = SQLITE_OK; 182732 int rc = SQLITE_OK;
181487 182733
182734#ifdef SQLITE_ENABLE_API_ARMOR
182735 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
182736#endif
181488 sqlite3_mutex_enter(db->mutex); 182737 sqlite3_mutex_enter(db->mutex);
181489 enterMutex(); 182738 enterMutex();
181490 182739
@@ -182506,6 +183755,7 @@ struct Fts3Table {
182506 int nPgsz; /* Page size for host database */ 183755 int nPgsz; /* Page size for host database */
182507 char *zSegmentsTbl; /* Name of %_segments table */ 183756 char *zSegmentsTbl; /* Name of %_segments table */
182508 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ 183757 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
183758 int iSavepoint;
182509 183759
182510 /* 183760 /*
182511 ** The following array of hash tables is used to buffer pending index 183761 ** The following array of hash tables is used to buffer pending index
@@ -183249,6 +184499,7 @@ static void fts3DeclareVtab(int *pRc, Fts3Table *p){
183249 184499
183250 zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); 184500 zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid");
183251 sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); 184501 sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
184502 sqlite3_vtab_config(p->db, SQLITE_VTAB_INNOCUOUS);
183252 184503
183253 /* Create a list of user columns for the virtual table */ 184504 /* Create a list of user columns for the virtual table */
183254 zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); 184505 zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]);
@@ -186498,6 +187749,8 @@ static int fts3RenameMethod(
186498 rc = sqlite3Fts3PendingTermsFlush(p); 187749 rc = sqlite3Fts3PendingTermsFlush(p);
186499 } 187750 }
186500 187751
187752 p->bIgnoreSavepoint = 1;
187753
186501 if( p->zContentTbl==0 ){ 187754 if( p->zContentTbl==0 ){
186502 fts3DbExec(&rc, db, 187755 fts3DbExec(&rc, db,
186503 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", 187756 "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';",
@@ -186525,6 +187778,8 @@ static int fts3RenameMethod(
186525 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", 187778 "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';",
186526 p->zDb, p->zName, zName 187779 p->zDb, p->zName, zName
186527 ); 187780 );
187781
187782 p->bIgnoreSavepoint = 0;
186528 return rc; 187783 return rc;
186529} 187784}
186530 187785
@@ -186535,12 +187790,28 @@ static int fts3RenameMethod(
186535*/ 187790*/
186536static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ 187791static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
186537 int rc = SQLITE_OK; 187792 int rc = SQLITE_OK;
186538 UNUSED_PARAMETER(iSavepoint); 187793 Fts3Table *pTab = (Fts3Table*)pVtab;
186539 assert( ((Fts3Table *)pVtab)->inTransaction ); 187794 assert( pTab->inTransaction );
186540 assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint ); 187795 assert( pTab->mxSavepoint<=iSavepoint );
186541 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); 187796 TESTONLY( pTab->mxSavepoint = iSavepoint );
186542 if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ 187797
186543 rc = fts3SyncMethod(pVtab); 187798 if( pTab->bIgnoreSavepoint==0 ){
187799 if( fts3HashCount(&pTab->aIndex[0].hPending)>0 ){
187800 char *zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')",
187801 pTab->zDb, pTab->zName, pTab->zName
187802 );
187803 if( zSql ){
187804 pTab->bIgnoreSavepoint = 1;
187805 rc = sqlite3_exec(pTab->db, zSql, 0, 0, 0);
187806 pTab->bIgnoreSavepoint = 0;
187807 sqlite3_free(zSql);
187808 }else{
187809 rc = SQLITE_NOMEM;
187810 }
187811 }
187812 if( rc==SQLITE_OK ){
187813 pTab->iSavepoint = iSavepoint+1;
187814 }
186544 } 187815 }
186545 return rc; 187816 return rc;
186546} 187817}
@@ -186551,12 +187822,11 @@ static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
186551** This is a no-op. 187822** This is a no-op.
186552*/ 187823*/
186553static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ 187824static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
186554 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); 187825 Fts3Table *pTab = (Fts3Table*)pVtab;
186555 UNUSED_PARAMETER(iSavepoint); 187826 assert( pTab->inTransaction );
186556 UNUSED_PARAMETER(pVtab); 187827 assert( pTab->mxSavepoint >= iSavepoint );
186557 assert( p->inTransaction ); 187828 TESTONLY( pTab->mxSavepoint = iSavepoint-1 );
186558 assert( p->mxSavepoint >= iSavepoint ); 187829 pTab->iSavepoint = iSavepoint;
186559 TESTONLY( p->mxSavepoint = iSavepoint-1 );
186560 return SQLITE_OK; 187830 return SQLITE_OK;
186561} 187831}
186562 187832
@@ -186566,11 +187836,13 @@ static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
186566** Discard the contents of the pending terms table. 187836** Discard the contents of the pending terms table.
186567*/ 187837*/
186568static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ 187838static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
186569 Fts3Table *p = (Fts3Table*)pVtab; 187839 Fts3Table *pTab = (Fts3Table*)pVtab;
186570 UNUSED_PARAMETER(iSavepoint); 187840 UNUSED_PARAMETER(iSavepoint);
186571 assert( p->inTransaction ); 187841 assert( pTab->inTransaction );
186572 TESTONLY( p->mxSavepoint = iSavepoint ); 187842 TESTONLY( pTab->mxSavepoint = iSavepoint );
186573 sqlite3Fts3PendingTermsClear(p); 187843 if( (iSavepoint+1)<=pTab->iSavepoint ){
187844 sqlite3Fts3PendingTermsClear(pTab);
187845 }
186574 return SQLITE_OK; 187846 return SQLITE_OK;
186575} 187847}
186576 187848
@@ -186589,8 +187861,49 @@ static int fts3ShadowName(const char *zName){
186589 return 0; 187861 return 0;
186590} 187862}
186591 187863
187864/*
187865** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual
187866** table.
187867*/
187868static int fts3Integrity(
187869 sqlite3_vtab *pVtab, /* The virtual table to be checked */
187870 const char *zSchema, /* Name of schema in which pVtab lives */
187871 const char *zTabname, /* Name of the pVTab table */
187872 int isQuick, /* True if this is a quick_check */
187873 char **pzErr /* Write error message here */
187874){
187875 Fts3Table *p = (Fts3Table*)pVtab;
187876 char *zSql;
187877 int rc;
187878 char *zErr = 0;
187879
187880 assert( pzErr!=0 );
187881 assert( *pzErr==0 );
187882 UNUSED_PARAMETER(isQuick);
187883 zSql = sqlite3_mprintf(
187884 "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');",
187885 zSchema, zTabname, zTabname);
187886 if( zSql==0 ){
187887 return SQLITE_NOMEM;
187888 }
187889 rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr);
187890 sqlite3_free(zSql);
187891 if( (rc&0xff)==SQLITE_CORRUPT ){
187892 *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s",
187893 p->bFts4 ? 4 : 3, zSchema, zTabname);
187894 }else if( rc!=SQLITE_OK ){
187895 *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
187896 " FTS%d table %s.%s: %s",
187897 p->bFts4 ? 4 : 3, zSchema, zTabname, zErr);
187898 }
187899 sqlite3_free(zErr);
187900 return SQLITE_OK;
187901}
187902
187903
187904
186592static const sqlite3_module fts3Module = { 187905static const sqlite3_module fts3Module = {
186593 /* iVersion */ 3, 187906 /* iVersion */ 4,
186594 /* xCreate */ fts3CreateMethod, 187907 /* xCreate */ fts3CreateMethod,
186595 /* xConnect */ fts3ConnectMethod, 187908 /* xConnect */ fts3ConnectMethod,
186596 /* xBestIndex */ fts3BestIndexMethod, 187909 /* xBestIndex */ fts3BestIndexMethod,
@@ -186614,6 +187927,7 @@ static const sqlite3_module fts3Module = {
186614 /* xRelease */ fts3ReleaseMethod, 187927 /* xRelease */ fts3ReleaseMethod,
186615 /* xRollbackTo */ fts3RollbackToMethod, 187928 /* xRollbackTo */ fts3RollbackToMethod,
186616 /* xShadowName */ fts3ShadowName, 187929 /* xShadowName */ fts3ShadowName,
187930 /* xIntegrity */ fts3Integrity,
186617}; 187931};
186618 187932
186619/* 187933/*
@@ -189289,7 +190603,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){
189289 0, /* xSavepoint */ 190603 0, /* xSavepoint */
189290 0, /* xRelease */ 190604 0, /* xRelease */
189291 0, /* xRollbackTo */ 190605 0, /* xRollbackTo */
189292 0 /* xShadowName */ 190606 0, /* xShadowName */
190607 0 /* xIntegrity */
189293 }; 190608 };
189294 int rc; /* Return code */ 190609 int rc; /* Return code */
189295 190610
@@ -192855,7 +194170,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestr
192855 0, /* xSavepoint */ 194170 0, /* xSavepoint */
192856 0, /* xRelease */ 194171 0, /* xRelease */
192857 0, /* xRollbackTo */ 194172 0, /* xRollbackTo */
192858 0 /* xShadowName */ 194173 0, /* xShadowName */
194174 0 /* xIntegrity */
192859 }; 194175 };
192860 int rc; /* Return code */ 194176 int rc; /* Return code */
192861 194177
@@ -196196,7 +197512,6 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
196196 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); 197512 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
196197 if( rc==SQLITE_DONE ) rc = SQLITE_OK; 197513 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
196198 } 197514 }
196199 sqlite3Fts3PendingTermsClear(p);
196200 197515
196201 /* Determine the auto-incr-merge setting if unknown. If enabled, 197516 /* Determine the auto-incr-merge setting if unknown. If enabled,
196202 ** estimate the number of leaf blocks of content to be written 197517 ** estimate the number of leaf blocks of content to be written
@@ -196218,6 +197533,10 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
196218 rc = sqlite3_reset(pStmt); 197533 rc = sqlite3_reset(pStmt);
196219 } 197534 }
196220 } 197535 }
197536
197537 if( rc==SQLITE_OK ){
197538 sqlite3Fts3PendingTermsClear(p);
197539 }
196221 return rc; 197540 return rc;
196222} 197541}
196223 197542
@@ -196849,6 +198168,8 @@ static int fts3AppendToNode(
196849 198168
196850 blobGrowBuffer(pPrev, nTerm, &rc); 198169 blobGrowBuffer(pPrev, nTerm, &rc);
196851 if( rc!=SQLITE_OK ) return rc; 198170 if( rc!=SQLITE_OK ) return rc;
198171 assert( pPrev!=0 );
198172 assert( pPrev->a!=0 );
196852 198173
196853 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); 198174 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
196854 nSuffix = nTerm - nPrefix; 198175 nSuffix = nTerm - nPrefix;
@@ -196905,9 +198226,13 @@ static int fts3IncrmergeAppend(
196905 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; 198226 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
196906 198227
196907 /* If the current block is not empty, and if adding this term/doclist 198228 /* If the current block is not empty, and if adding this term/doclist
196908 ** to the current block would make it larger than Fts3Table.nNodeSize 198229 ** to the current block would make it larger than Fts3Table.nNodeSize bytes,
196909 ** bytes, write this block out to the database. */ 198230 ** and if there is still room for another leaf page, write this block out to
196910 if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ 198231 ** the database. */
198232 if( pLeaf->block.n>0
198233 && (pLeaf->block.n + nSpace)>p->nNodeSize
198234 && pLeaf->iBlock < (pWriter->iStart + pWriter->nLeafEst)
198235 ){
196911 rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); 198236 rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
196912 pWriter->nWork++; 198237 pWriter->nWork++;
196913 198238
@@ -197239,7 +198564,7 @@ static int fts3IncrmergeLoad(
197239 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); 198564 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0);
197240 blobGrowBuffer(&pNode->block, 198565 blobGrowBuffer(&pNode->block,
197241 MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc 198566 MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc
197242 ); 198567 );
197243 if( rc==SQLITE_OK ){ 198568 if( rc==SQLITE_OK ){
197244 memcpy(pNode->block.a, aBlock, nBlock); 198569 memcpy(pNode->block.a, aBlock, nBlock);
197245 pNode->block.n = nBlock; 198570 pNode->block.n = nBlock;
@@ -198304,8 +199629,11 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
198304 rc = fts3DoIncrmerge(p, &zVal[6]); 199629 rc = fts3DoIncrmerge(p, &zVal[6]);
198305 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ 199630 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
198306 rc = fts3DoAutoincrmerge(p, &zVal[10]); 199631 rc = fts3DoAutoincrmerge(p, &zVal[10]);
199632 }else if( nVal==5 && 0==sqlite3_strnicmp(zVal, "flush", 5) ){
199633 rc = sqlite3Fts3PendingTermsFlush(p);
199634 }
198307#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) 199635#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
198308 }else{ 199636 else{
198309 int v; 199637 int v;
198310 if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ 199638 if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
198311 v = atoi(&zVal[9]); 199639 v = atoi(&zVal[9]);
@@ -198323,8 +199651,8 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
198323 if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; 199651 if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v;
198324 rc = SQLITE_OK; 199652 rc = SQLITE_OK;
198325 } 199653 }
198326#endif
198327 } 199654 }
199655#endif
198328 return rc; 199656 return rc;
198329} 199657}
198330 199658
@@ -201837,7 +203165,7 @@ static void jsonResult(JsonString *p){
201837 }else if( jsonForceRCStr(p) ){ 203165 }else if( jsonForceRCStr(p) ){
201838 sqlite3RCStrRef(p->zBuf); 203166 sqlite3RCStrRef(p->zBuf);
201839 sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, 203167 sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed,
201840 (void(*)(void*))sqlite3RCStrUnref, 203168 sqlite3RCStrUnref,
201841 SQLITE_UTF8); 203169 SQLITE_UTF8);
201842 } 203170 }
201843 } 203171 }
@@ -203177,7 +204505,7 @@ static JsonParse *jsonParseCached(
203177 /* The input JSON was not found anywhere in the cache. We will need 204505 /* The input JSON was not found anywhere in the cache. We will need
203178 ** to parse it ourselves and generate a new JsonParse object. 204506 ** to parse it ourselves and generate a new JsonParse object.
203179 */ 204507 */
203180 bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); 204508 bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref);
203181 p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); 204509 p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) );
203182 if( p==0 ){ 204510 if( p==0 ){
203183 sqlite3_result_error_nomem(pCtx); 204511 sqlite3_result_error_nomem(pCtx);
@@ -203391,6 +204719,7 @@ static JsonNode *jsonLookupStep(
203391 if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; 204719 if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--;
203392 j += jsonNodeSize(&pRoot[j]); 204720 j += jsonNodeSize(&pRoot[j]);
203393 } 204721 }
204722 if( i==0 && j<=pRoot->n ) break;
203394 if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; 204723 if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;
203395 if( pParse->useMod==0 ) break; 204724 if( pParse->useMod==0 ) break;
203396 assert( pRoot->eU==2 ); 204725 assert( pRoot->eU==2 );
@@ -204078,11 +205407,13 @@ static void jsonReplaceNode(
204078 break; 205407 break;
204079 } 205408 }
204080 if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ 205409 if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){
204081 char *zCopy = sqlite3DbStrDup(0, z); 205410 char *zCopy = sqlite3_malloc64( n+1 );
204082 int k; 205411 int k;
204083 if( zCopy ){ 205412 if( zCopy ){
205413 memcpy(zCopy, z, n);
205414 zCopy[n] = 0;
204084 jsonParseAddCleanup(p, sqlite3_free, zCopy); 205415 jsonParseAddCleanup(p, sqlite3_free, zCopy);
204085 }else{ 205416 }else{
204086 p->oom = 1; 205417 p->oom = 1;
204087 sqlite3_result_error_nomem(pCtx); 205418 sqlite3_result_error_nomem(pCtx);
204088 } 205419 }
@@ -204359,7 +205690,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
204359 }else if( isFinal ){ 205690 }else if( isFinal ){
204360 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, 205691 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed,
204361 pStr->bStatic ? SQLITE_TRANSIENT : 205692 pStr->bStatic ? SQLITE_TRANSIENT :
204362 (void(*)(void*))sqlite3RCStrUnref); 205693 sqlite3RCStrUnref);
204363 pStr->bStatic = 1; 205694 pStr->bStatic = 1;
204364 }else{ 205695 }else{
204365 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); 205696 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
@@ -204468,7 +205799,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
204468 }else if( isFinal ){ 205799 }else if( isFinal ){
204469 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, 205800 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed,
204470 pStr->bStatic ? SQLITE_TRANSIENT : 205801 pStr->bStatic ? SQLITE_TRANSIENT :
204471 (void(*)(void*))sqlite3RCStrUnref); 205802 sqlite3RCStrUnref);
204472 pStr->bStatic = 1; 205803 pStr->bStatic = 1;
204473 }else{ 205804 }else{
204474 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); 205805 sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
@@ -204900,7 +206231,7 @@ static int jsonEachFilter(
204900 if( z==0 ) return SQLITE_OK; 206231 if( z==0 ) return SQLITE_OK;
204901 memset(&p->sParse, 0, sizeof(p->sParse)); 206232 memset(&p->sParse, 0, sizeof(p->sParse));
204902 p->sParse.nJPRef = 1; 206233 p->sParse.nJPRef = 1;
204903 if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ 206234 if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){
204904 p->sParse.zJson = sqlite3RCStrRef((char*)z); 206235 p->sParse.zJson = sqlite3RCStrRef((char*)z);
204905 }else{ 206236 }else{
204906 n = sqlite3_value_bytes(argv[0]); 206237 n = sqlite3_value_bytes(argv[0]);
@@ -204995,7 +206326,8 @@ static sqlite3_module jsonEachModule = {
204995 0, /* xSavepoint */ 206326 0, /* xSavepoint */
204996 0, /* xRelease */ 206327 0, /* xRelease */
204997 0, /* xRollbackTo */ 206328 0, /* xRollbackTo */
204998 0 /* xShadowName */ 206329 0, /* xShadowName */
206330 0 /* xIntegrity */
204999}; 206331};
205000 206332
205001/* The methods of the json_tree virtual table. */ 206333/* The methods of the json_tree virtual table. */
@@ -205023,7 +206355,8 @@ static sqlite3_module jsonTreeModule = {
205023 0, /* xSavepoint */ 206355 0, /* xSavepoint */
205024 0, /* xRelease */ 206356 0, /* xRelease */
205025 0, /* xRollbackTo */ 206357 0, /* xRollbackTo */
205026 0 /* xShadowName */ 206358 0, /* xShadowName */
206359 0 /* xIntegrity */
205027}; 206360};
205028#endif /* SQLITE_OMIT_VIRTUALTABLE */ 206361#endif /* SQLITE_OMIT_VIRTUALTABLE */
205029#endif /* !defined(SQLITE_OMIT_JSON) */ 206362#endif /* !defined(SQLITE_OMIT_JSON) */
@@ -205258,6 +206591,7 @@ struct Rtree {
205258 int iDepth; /* Current depth of the r-tree structure */ 206591 int iDepth; /* Current depth of the r-tree structure */
205259 char *zDb; /* Name of database containing r-tree table */ 206592 char *zDb; /* Name of database containing r-tree table */
205260 char *zName; /* Name of r-tree table */ 206593 char *zName; /* Name of r-tree table */
206594 char *zNodeName; /* Name of the %_node table */
205261 u32 nBusy; /* Current number of users of this structure */ 206595 u32 nBusy; /* Current number of users of this structure */
205262 i64 nRowEst; /* Estimated number of rows in this table */ 206596 i64 nRowEst; /* Estimated number of rows in this table */
205263 u32 nCursor; /* Number of open cursors */ 206597 u32 nCursor; /* Number of open cursors */
@@ -205270,7 +206604,6 @@ struct Rtree {
205270 ** headed by the node (leaf nodes have RtreeNode.iNode==0). 206604 ** headed by the node (leaf nodes have RtreeNode.iNode==0).
205271 */ 206605 */
205272 RtreeNode *pDeleted; 206606 RtreeNode *pDeleted;
205273 int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */
205274 206607
205275 /* Blob I/O on xxx_node */ 206608 /* Blob I/O on xxx_node */
205276 sqlite3_blob *pNodeBlob; 206609 sqlite3_blob *pNodeBlob;
@@ -205567,15 +206900,20 @@ struct RtreeMatchArg {
205567** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined 206900** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
205568** at run-time. 206901** at run-time.
205569*/ 206902*/
205570#ifndef SQLITE_BYTEORDER 206903#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */
205571# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ 206904# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
206905# define SQLITE_BYTEORDER 4321
206906# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
206907# define SQLITE_BYTEORDER 1234
206908# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1
206909# define SQLITE_BYTEORDER 4321
206910# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
205572 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ 206911 defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
205573 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ 206912 defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
205574 defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) 206913 defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
205575# define SQLITE_BYTEORDER 1234 206914# define SQLITE_BYTEORDER 1234
205576# elif defined(sparc) || defined(__ppc__) || \ 206915# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__)
205577 defined(__ARMEB__) || defined(__AARCH64EB__) 206916# define SQLITE_BYTEORDER 4321
205578# define SQLITE_BYTEORDER 4321
205579# else 206917# else
205580# define SQLITE_BYTEORDER 0 206918# define SQLITE_BYTEORDER 0
205581# endif 206919# endif
@@ -205824,11 +207162,9 @@ static int nodeAcquire(
205824 } 207162 }
205825 } 207163 }
205826 if( pRtree->pNodeBlob==0 ){ 207164 if( pRtree->pNodeBlob==0 ){
205827 char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); 207165 rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, pRtree->zNodeName,
205828 if( zTab==0 ) return SQLITE_NOMEM; 207166 "data", iNode, 0,
205829 rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0,
205830 &pRtree->pNodeBlob); 207167 &pRtree->pNodeBlob);
205831 sqlite3_free(zTab);
205832 } 207168 }
205833 if( rc ){ 207169 if( rc ){
205834 nodeBlobReset(pRtree); 207170 nodeBlobReset(pRtree);
@@ -207169,8 +208505,12 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
207169 208505
207170 pIdxInfo->idxNum = 2; 208506 pIdxInfo->idxNum = 2;
207171 pIdxInfo->needToFreeIdxStr = 1; 208507 pIdxInfo->needToFreeIdxStr = 1;
207172 if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ 208508 if( iIdx>0 ){
207173 return SQLITE_NOMEM; 208509 pIdxInfo->idxStr = sqlite3_malloc( iIdx+1 );
208510 if( pIdxInfo->idxStr==0 ){
208511 return SQLITE_NOMEM;
208512 }
208513 memcpy(pIdxInfo->idxStr, zIdxStr, iIdx+1);
207174 } 208514 }
207175 208515
207176 nRow = pRtree->nRowEst >> (iIdx/2); 208516 nRow = pRtree->nRowEst >> (iIdx/2);
@@ -207249,31 +208589,22 @@ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){
207249*/ 208589*/
207250static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ 208590static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){
207251 int ii; 208591 int ii;
207252 int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); 208592 if( pRtree->eCoordType==RTREE_COORD_INT32 ){
207253 for(ii=0; ii<pRtree->nDim2; ii+=2){ 208593 for(ii=0; ii<pRtree->nDim2; ii+=2){
207254 RtreeCoord *a1 = &p1->aCoord[ii]; 208594 RtreeCoord *a1 = &p1->aCoord[ii];
207255 RtreeCoord *a2 = &p2->aCoord[ii]; 208595 RtreeCoord *a2 = &p2->aCoord[ii];
207256 if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) 208596 if( a2[0].i<a1[0].i || a2[1].i>a1[1].i ) return 0;
207257 || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) 208597 }
207258 ){ 208598 }else{
207259 return 0; 208599 for(ii=0; ii<pRtree->nDim2; ii+=2){
208600 RtreeCoord *a1 = &p1->aCoord[ii];
208601 RtreeCoord *a2 = &p2->aCoord[ii];
208602 if( a2[0].f<a1[0].f || a2[1].f>a1[1].f ) return 0;
207260 } 208603 }
207261 } 208604 }
207262 return 1; 208605 return 1;
207263} 208606}
207264 208607
207265/*
207266** Return the amount cell p would grow by if it were unioned with pCell.
207267*/
207268static RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){
207269 RtreeDValue area;
207270 RtreeCell cell;
207271 memcpy(&cell, p, sizeof(RtreeCell));
207272 area = cellArea(pRtree, &cell);
207273 cellUnion(pRtree, &cell, pCell);
207274 return (cellArea(pRtree, &cell)-area);
207275}
207276
207277static RtreeDValue cellOverlap( 208608static RtreeDValue cellOverlap(
207278 Rtree *pRtree, 208609 Rtree *pRtree,
207279 RtreeCell *p, 208610 RtreeCell *p,
@@ -207320,38 +208651,52 @@ static int ChooseLeaf(
207320 for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ 208651 for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
207321 int iCell; 208652 int iCell;
207322 sqlite3_int64 iBest = 0; 208653 sqlite3_int64 iBest = 0;
207323 208654 int bFound = 0;
207324 RtreeDValue fMinGrowth = RTREE_ZERO; 208655 RtreeDValue fMinGrowth = RTREE_ZERO;
207325 RtreeDValue fMinArea = RTREE_ZERO; 208656 RtreeDValue fMinArea = RTREE_ZERO;
207326
207327 int nCell = NCELL(pNode); 208657 int nCell = NCELL(pNode);
207328 RtreeCell cell;
207329 RtreeNode *pChild = 0; 208658 RtreeNode *pChild = 0;
207330 208659
207331 RtreeCell *aCell = 0; 208660 /* First check to see if there is are any cells in pNode that completely
207332 208661 ** contains pCell. If two or more cells in pNode completely contain pCell
207333 /* Select the child node which will be enlarged the least if pCell 208662 ** then pick the smallest.
207334 ** is inserted into it. Resolve ties by choosing the entry with
207335 ** the smallest area.
207336 */ 208663 */
207337 for(iCell=0; iCell<nCell; iCell++){ 208664 for(iCell=0; iCell<nCell; iCell++){
207338 int bBest = 0; 208665 RtreeCell cell;
207339 RtreeDValue growth;
207340 RtreeDValue area;
207341 nodeGetCell(pRtree, pNode, iCell, &cell); 208666 nodeGetCell(pRtree, pNode, iCell, &cell);
207342 growth = cellGrowth(pRtree, &cell, pCell); 208667 if( cellContains(pRtree, &cell, pCell) ){
207343 area = cellArea(pRtree, &cell); 208668 RtreeDValue area = cellArea(pRtree, &cell);
207344 if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){ 208669 if( bFound==0 || area<fMinArea ){
207345 bBest = 1; 208670 iBest = cell.iRowid;
208671 fMinArea = area;
208672 bFound = 1;
208673 }
207346 } 208674 }
207347 if( bBest ){ 208675 }
207348 fMinGrowth = growth; 208676 if( !bFound ){
207349 fMinArea = area; 208677 /* No cells of pNode will completely contain pCell. So pick the
207350 iBest = cell.iRowid; 208678 ** cell of pNode that grows by the least amount when pCell is added.
208679 ** Break ties by selecting the smaller cell.
208680 */
208681 for(iCell=0; iCell<nCell; iCell++){
208682 RtreeCell cell;
208683 RtreeDValue growth;
208684 RtreeDValue area;
208685 nodeGetCell(pRtree, pNode, iCell, &cell);
208686 area = cellArea(pRtree, &cell);
208687 cellUnion(pRtree, &cell, pCell);
208688 growth = cellArea(pRtree, &cell)-area;
208689 if( iCell==0
208690 || growth<fMinGrowth
208691 || (growth==fMinGrowth && area<fMinArea)
208692 ){
208693 fMinGrowth = growth;
208694 fMinArea = area;
208695 iBest = cell.iRowid;
208696 }
207351 } 208697 }
207352 } 208698 }
207353 208699
207354 sqlite3_free(aCell);
207355 rc = nodeAcquire(pRtree, iBest, pNode, &pChild); 208700 rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
207356 nodeRelease(pRtree, pNode); 208701 nodeRelease(pRtree, pNode);
207357 pNode = pChild; 208702 pNode = pChild;
@@ -207424,77 +208769,6 @@ static int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){
207424static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int); 208769static int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int);
207425 208770
207426 208771
207427/*
207428** Arguments aIdx, aDistance and aSpare all point to arrays of size
207429** nIdx. The aIdx array contains the set of integers from 0 to
207430** (nIdx-1) in no particular order. This function sorts the values
207431** in aIdx according to the indexed values in aDistance. For
207432** example, assuming the inputs:
207433**
207434** aIdx = { 0, 1, 2, 3 }
207435** aDistance = { 5.0, 2.0, 7.0, 6.0 }
207436**
207437** this function sets the aIdx array to contain:
207438**
207439** aIdx = { 0, 1, 2, 3 }
207440**
207441** The aSpare array is used as temporary working space by the
207442** sorting algorithm.
207443*/
207444static void SortByDistance(
207445 int *aIdx,
207446 int nIdx,
207447 RtreeDValue *aDistance,
207448 int *aSpare
207449){
207450 if( nIdx>1 ){
207451 int iLeft = 0;
207452 int iRight = 0;
207453
207454 int nLeft = nIdx/2;
207455 int nRight = nIdx-nLeft;
207456 int *aLeft = aIdx;
207457 int *aRight = &aIdx[nLeft];
207458
207459 SortByDistance(aLeft, nLeft, aDistance, aSpare);
207460 SortByDistance(aRight, nRight, aDistance, aSpare);
207461
207462 memcpy(aSpare, aLeft, sizeof(int)*nLeft);
207463 aLeft = aSpare;
207464
207465 while( iLeft<nLeft || iRight<nRight ){
207466 if( iLeft==nLeft ){
207467 aIdx[iLeft+iRight] = aRight[iRight];
207468 iRight++;
207469 }else if( iRight==nRight ){
207470 aIdx[iLeft+iRight] = aLeft[iLeft];
207471 iLeft++;
207472 }else{
207473 RtreeDValue fLeft = aDistance[aLeft[iLeft]];
207474 RtreeDValue fRight = aDistance[aRight[iRight]];
207475 if( fLeft<fRight ){
207476 aIdx[iLeft+iRight] = aLeft[iLeft];
207477 iLeft++;
207478 }else{
207479 aIdx[iLeft+iRight] = aRight[iRight];
207480 iRight++;
207481 }
207482 }
207483 }
207484
207485#if 0
207486 /* Check that the sort worked */
207487 {
207488 int jj;
207489 for(jj=1; jj<nIdx; jj++){
207490 RtreeDValue left = aDistance[aIdx[jj-1]];
207491 RtreeDValue right = aDistance[aIdx[jj]];
207492 assert( left<=right );
207493 }
207494 }
207495#endif
207496 }
207497}
207498 208772
207499/* 208773/*
207500** Arguments aIdx, aCell and aSpare all point to arrays of size 208774** Arguments aIdx, aCell and aSpare all point to arrays of size
@@ -207979,107 +209253,6 @@ static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
207979 return rc; 209253 return rc;
207980} 209254}
207981 209255
207982static int Reinsert(
207983 Rtree *pRtree,
207984 RtreeNode *pNode,
207985 RtreeCell *pCell,
207986 int iHeight
207987){
207988 int *aOrder;
207989 int *aSpare;
207990 RtreeCell *aCell;
207991 RtreeDValue *aDistance;
207992 int nCell;
207993 RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS];
207994 int iDim;
207995 int ii;
207996 int rc = SQLITE_OK;
207997 int n;
207998
207999 memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS);
208000
208001 nCell = NCELL(pNode)+1;
208002 n = (nCell+1)&(~1);
208003
208004 /* Allocate the buffers used by this operation. The allocation is
208005 ** relinquished before this function returns.
208006 */
208007 aCell = (RtreeCell *)sqlite3_malloc64(n * (
208008 sizeof(RtreeCell) + /* aCell array */
208009 sizeof(int) + /* aOrder array */
208010 sizeof(int) + /* aSpare array */
208011 sizeof(RtreeDValue) /* aDistance array */
208012 ));
208013 if( !aCell ){
208014 return SQLITE_NOMEM;
208015 }
208016 aOrder = (int *)&aCell[n];
208017 aSpare = (int *)&aOrder[n];
208018 aDistance = (RtreeDValue *)&aSpare[n];
208019
208020 for(ii=0; ii<nCell; ii++){
208021 if( ii==(nCell-1) ){
208022 memcpy(&aCell[ii], pCell, sizeof(RtreeCell));
208023 }else{
208024 nodeGetCell(pRtree, pNode, ii, &aCell[ii]);
208025 }
208026 aOrder[ii] = ii;
208027 for(iDim=0; iDim<pRtree->nDim; iDim++){
208028 aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);
208029 aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);
208030 }
208031 }
208032 for(iDim=0; iDim<pRtree->nDim; iDim++){
208033 aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2));
208034 }
208035
208036 for(ii=0; ii<nCell; ii++){
208037 aDistance[ii] = RTREE_ZERO;
208038 for(iDim=0; iDim<pRtree->nDim; iDim++){
208039 RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) -
208040 DCOORD(aCell[ii].aCoord[iDim*2]));
208041 aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);
208042 }
208043 }
208044
208045 SortByDistance(aOrder, nCell, aDistance, aSpare);
208046 nodeZero(pRtree, pNode);
208047
208048 for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){
208049 RtreeCell *p = &aCell[aOrder[ii]];
208050 nodeInsertCell(pRtree, pNode, p);
208051 if( p->iRowid==pCell->iRowid ){
208052 if( iHeight==0 ){
208053 rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);
208054 }else{
208055 rc = parentWrite(pRtree, p->iRowid, pNode->iNode);
208056 }
208057 }
208058 }
208059 if( rc==SQLITE_OK ){
208060 rc = fixBoundingBox(pRtree, pNode);
208061 }
208062 for(; rc==SQLITE_OK && ii<nCell; ii++){
208063 /* Find a node to store this cell in. pNode->iNode currently contains
208064 ** the height of the sub-tree headed by the cell.
208065 */
208066 RtreeNode *pInsert;
208067 RtreeCell *p = &aCell[aOrder[ii]];
208068 rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);
208069 if( rc==SQLITE_OK ){
208070 int rc2;
208071 rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);
208072 rc2 = nodeRelease(pRtree, pInsert);
208073 if( rc==SQLITE_OK ){
208074 rc = rc2;
208075 }
208076 }
208077 }
208078
208079 sqlite3_free(aCell);
208080 return rc;
208081}
208082
208083/* 209256/*
208084** Insert cell pCell into node pNode. Node pNode is the head of a 209257** Insert cell pCell into node pNode. Node pNode is the head of a
208085** subtree iHeight high (leaf nodes have iHeight==0). 209258** subtree iHeight high (leaf nodes have iHeight==0).
@@ -208100,12 +209273,7 @@ static int rtreeInsertCell(
208100 } 209273 }
208101 } 209274 }
208102 if( nodeInsertCell(pRtree, pNode, pCell) ){ 209275 if( nodeInsertCell(pRtree, pNode, pCell) ){
208103 if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ 209276 rc = SplitNode(pRtree, pNode, pCell, iHeight);
208104 rc = SplitNode(pRtree, pNode, pCell, iHeight);
208105 }else{
208106 pRtree->iReinsertHeight = iHeight;
208107 rc = Reinsert(pRtree, pNode, pCell, iHeight);
208108 }
208109 }else{ 209277 }else{
208110 rc = AdjustTree(pRtree, pNode, pCell); 209278 rc = AdjustTree(pRtree, pNode, pCell);
208111 if( ALWAYS(rc==SQLITE_OK) ){ 209279 if( ALWAYS(rc==SQLITE_OK) ){
@@ -208448,7 +209616,6 @@ static int rtreeUpdate(
208448 } 209616 }
208449 if( rc==SQLITE_OK ){ 209617 if( rc==SQLITE_OK ){
208450 int rc2; 209618 int rc2;
208451 pRtree->iReinsertHeight = -1;
208452 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); 209619 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);
208453 rc2 = nodeRelease(pRtree, pLeaf); 209620 rc2 = nodeRelease(pRtree, pLeaf);
208454 if( rc==SQLITE_OK ){ 209621 if( rc==SQLITE_OK ){
@@ -208589,8 +209756,11 @@ static int rtreeShadowName(const char *zName){
208589 return 0; 209756 return 0;
208590} 209757}
208591 209758
209759/* Forward declaration */
209760static int rtreeIntegrity(sqlite3_vtab*, const char*, const char*, int, char**);
209761
208592static sqlite3_module rtreeModule = { 209762static sqlite3_module rtreeModule = {
208593 3, /* iVersion */ 209763 4, /* iVersion */
208594 rtreeCreate, /* xCreate - create a table */ 209764 rtreeCreate, /* xCreate - create a table */
208595 rtreeConnect, /* xConnect - connect to an existing table */ 209765 rtreeConnect, /* xConnect - connect to an existing table */
208596 rtreeBestIndex, /* xBestIndex - Determine search strategy */ 209766 rtreeBestIndex, /* xBestIndex - Determine search strategy */
@@ -208613,7 +209783,8 @@ static sqlite3_module rtreeModule = {
208613 rtreeSavepoint, /* xSavepoint */ 209783 rtreeSavepoint, /* xSavepoint */
208614 0, /* xRelease */ 209784 0, /* xRelease */
208615 0, /* xRollbackTo */ 209785 0, /* xRollbackTo */
208616 rtreeShadowName /* xShadowName */ 209786 rtreeShadowName, /* xShadowName */
209787 rtreeIntegrity /* xIntegrity */
208617}; 209788};
208618 209789
208619static int rtreeSqlInit( 209790static int rtreeSqlInit(
@@ -208869,22 +210040,27 @@ static int rtreeInit(
208869 } 210040 }
208870 210041
208871 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); 210042 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
210043 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
210044
208872 210045
208873 /* Allocate the sqlite3_vtab structure */ 210046 /* Allocate the sqlite3_vtab structure */
208874 nDb = (int)strlen(argv[1]); 210047 nDb = (int)strlen(argv[1]);
208875 nName = (int)strlen(argv[2]); 210048 nName = (int)strlen(argv[2]);
208876 pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); 210049 pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8);
208877 if( !pRtree ){ 210050 if( !pRtree ){
208878 return SQLITE_NOMEM; 210051 return SQLITE_NOMEM;
208879 } 210052 }
208880 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); 210053 memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8);
208881 pRtree->nBusy = 1; 210054 pRtree->nBusy = 1;
208882 pRtree->base.pModule = &rtreeModule; 210055 pRtree->base.pModule = &rtreeModule;
208883 pRtree->zDb = (char *)&pRtree[1]; 210056 pRtree->zDb = (char *)&pRtree[1];
208884 pRtree->zName = &pRtree->zDb[nDb+1]; 210057 pRtree->zName = &pRtree->zDb[nDb+1];
210058 pRtree->zNodeName = &pRtree->zName[nName+1];
208885 pRtree->eCoordType = (u8)eCoordType; 210059 pRtree->eCoordType = (u8)eCoordType;
208886 memcpy(pRtree->zDb, argv[1], nDb); 210060 memcpy(pRtree->zDb, argv[1], nDb);
208887 memcpy(pRtree->zName, argv[2], nName); 210061 memcpy(pRtree->zName, argv[2], nName);
210062 memcpy(pRtree->zNodeName, argv[2], nName);
210063 memcpy(&pRtree->zNodeName[nName], "_node", 6);
208888 210064
208889 210065
208890 /* Create/Connect to the underlying relational database schema. If 210066 /* Create/Connect to the underlying relational database schema. If
@@ -209381,7 +210557,6 @@ static int rtreeCheckTable(
209381){ 210557){
209382 RtreeCheck check; /* Common context for various routines */ 210558 RtreeCheck check; /* Common context for various routines */
209383 sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ 210559 sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */
209384 int bEnd = 0; /* True if transaction should be closed */
209385 int nAux = 0; /* Number of extra columns. */ 210560 int nAux = 0; /* Number of extra columns. */
209386 210561
209387 /* Initialize the context object */ 210562 /* Initialize the context object */
@@ -209390,14 +210565,6 @@ static int rtreeCheckTable(
209390 check.zDb = zDb; 210565 check.zDb = zDb;
209391 check.zTab = zTab; 210566 check.zTab = zTab;
209392 210567
209393 /* If there is not already an open transaction, open one now. This is
209394 ** to ensure that the queries run as part of this integrity-check operate
209395 ** on a consistent snapshot. */
209396 if( sqlite3_get_autocommit(db) ){
209397 check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0);
209398 bEnd = 1;
209399 }
209400
209401 /* Find the number of auxiliary columns */ 210568 /* Find the number of auxiliary columns */
209402 if( check.rc==SQLITE_OK ){ 210569 if( check.rc==SQLITE_OK ){
209403 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); 210570 pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab);
@@ -209438,16 +210605,35 @@ static int rtreeCheckTable(
209438 sqlite3_finalize(check.aCheckMapping[0]); 210605 sqlite3_finalize(check.aCheckMapping[0]);
209439 sqlite3_finalize(check.aCheckMapping[1]); 210606 sqlite3_finalize(check.aCheckMapping[1]);
209440 210607
209441 /* If one was opened, close the transaction */
209442 if( bEnd ){
209443 int rc = sqlite3_exec(db, "END", 0, 0, 0);
209444 if( check.rc==SQLITE_OK ) check.rc = rc;
209445 }
209446 *pzReport = check.zReport; 210608 *pzReport = check.zReport;
209447 return check.rc; 210609 return check.rc;
209448} 210610}
209449 210611
209450/* 210612/*
210613** Implementation of the xIntegrity method for Rtree.
210614*/
210615static int rtreeIntegrity(
210616 sqlite3_vtab *pVtab, /* The virtual table to check */
210617 const char *zSchema, /* Schema in which the virtual table lives */
210618 const char *zName, /* Name of the virtual table */
210619 int isQuick, /* True for a quick_check */
210620 char **pzErr /* Write results here */
210621){
210622 Rtree *pRtree = (Rtree*)pVtab;
210623 int rc;
210624 assert( pzErr!=0 && *pzErr==0 );
210625 UNUSED_PARAMETER(zSchema);
210626 UNUSED_PARAMETER(zName);
210627 UNUSED_PARAMETER(isQuick);
210628 rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr);
210629 if( rc==SQLITE_OK && *pzErr ){
210630 *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z",
210631 pRtree->zDb, pRtree->zName, *pzErr);
210632 }
210633 return rc;
210634}
210635
210636/*
209451** Usage: 210637** Usage:
209452** 210638**
209453** rtreecheck(<rtree-table>); 210639** rtreecheck(<rtree-table>);
@@ -210768,24 +211954,28 @@ static int geopolyInit(
210768 (void)pAux; 211954 (void)pAux;
210769 211955
210770 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); 211956 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
211957 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
210771 211958
210772 /* Allocate the sqlite3_vtab structure */ 211959 /* Allocate the sqlite3_vtab structure */
210773 nDb = strlen(argv[1]); 211960 nDb = strlen(argv[1]);
210774 nName = strlen(argv[2]); 211961 nName = strlen(argv[2]);
210775 pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); 211962 pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8);
210776 if( !pRtree ){ 211963 if( !pRtree ){
210777 return SQLITE_NOMEM; 211964 return SQLITE_NOMEM;
210778 } 211965 }
210779 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); 211966 memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8);
210780 pRtree->nBusy = 1; 211967 pRtree->nBusy = 1;
210781 pRtree->base.pModule = &rtreeModule; 211968 pRtree->base.pModule = &rtreeModule;
210782 pRtree->zDb = (char *)&pRtree[1]; 211969 pRtree->zDb = (char *)&pRtree[1];
210783 pRtree->zName = &pRtree->zDb[nDb+1]; 211970 pRtree->zName = &pRtree->zDb[nDb+1];
211971 pRtree->zNodeName = &pRtree->zName[nName+1];
210784 pRtree->eCoordType = RTREE_COORD_REAL32; 211972 pRtree->eCoordType = RTREE_COORD_REAL32;
210785 pRtree->nDim = 2; 211973 pRtree->nDim = 2;
210786 pRtree->nDim2 = 4; 211974 pRtree->nDim2 = 4;
210787 memcpy(pRtree->zDb, argv[1], nDb); 211975 memcpy(pRtree->zDb, argv[1], nDb);
210788 memcpy(pRtree->zName, argv[2], nName); 211976 memcpy(pRtree->zName, argv[2], nName);
211977 memcpy(pRtree->zNodeName, argv[2], nName);
211978 memcpy(&pRtree->zNodeName[nName], "_node", 6);
210789 211979
210790 211980
210791 /* Create/Connect to the underlying relational database schema. If 211981 /* Create/Connect to the underlying relational database schema. If
@@ -211199,7 +212389,6 @@ static int geopolyUpdate(
211199 } 212389 }
211200 if( rc==SQLITE_OK ){ 212390 if( rc==SQLITE_OK ){
211201 int rc2; 212391 int rc2;
211202 pRtree->iReinsertHeight = -1;
211203 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); 212392 rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);
211204 rc2 = nodeRelease(pRtree, pLeaf); 212393 rc2 = nodeRelease(pRtree, pLeaf);
211205 if( rc==SQLITE_OK ){ 212394 if( rc==SQLITE_OK ){
@@ -211296,7 +212485,8 @@ static sqlite3_module geopolyModule = {
211296 rtreeSavepoint, /* xSavepoint */ 212485 rtreeSavepoint, /* xSavepoint */
211297 0, /* xRelease */ 212486 0, /* xRelease */
211298 0, /* xRollbackTo */ 212487 0, /* xRollbackTo */
211299 rtreeShadowName /* xShadowName */ 212488 rtreeShadowName, /* xShadowName */
212489 rtreeIntegrity /* xIntegrity */
211300}; 212490};
211301 212491
211302static int sqlite3_geopoly_init(sqlite3 *db){ 212492static int sqlite3_geopoly_init(sqlite3 *db){
@@ -219310,7 +220500,8 @@ SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){
219310 0, /* xSavepoint */ 220500 0, /* xSavepoint */
219311 0, /* xRelease */ 220501 0, /* xRelease */
219312 0, /* xRollbackTo */ 220502 0, /* xRollbackTo */
219313 0 /* xShadowName */ 220503 0, /* xShadowName */
220504 0 /* xIntegrity */
219314 }; 220505 };
219315 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); 220506 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
219316} 220507}
@@ -219747,7 +220938,8 @@ SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
219747 0, /* xSavepoint */ 220938 0, /* xSavepoint */
219748 0, /* xRelease */ 220939 0, /* xRelease */
219749 0, /* xRollbackTo */ 220940 0, /* xRollbackTo */
219750 0 /* xShadowName */ 220941 0, /* xShadowName */
220942 0 /* xIntegrity */
219751 }; 220943 };
219752 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); 220944 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
219753} 220945}
@@ -219878,6 +221070,18 @@ struct sqlite3_changeset_iter {
219878** The data associated with each hash-table entry is a structure containing 221070** The data associated with each hash-table entry is a structure containing
219879** a subset of the initial values that the modified row contained at the 221071** a subset of the initial values that the modified row contained at the
219880** start of the session. Or no initial values if the row was inserted. 221072** start of the session. Or no initial values if the row was inserted.
221073**
221074** pDfltStmt:
221075** This is only used by the sqlite3changegroup_xxx() APIs, not by
221076** regular sqlite3_session objects. It is a SELECT statement that
221077** selects the default value for each table column. For example,
221078** if the table is
221079**
221080** CREATE TABLE xx(a DEFAULT 1, b, c DEFAULT 'abc')
221081**
221082** then this variable is the compiled version of:
221083**
221084** SELECT 1, NULL, 'abc'
219881*/ 221085*/
219882struct SessionTable { 221086struct SessionTable {
219883 SessionTable *pNext; 221087 SessionTable *pNext;
@@ -219886,10 +221090,12 @@ struct SessionTable {
219886 int bStat1; /* True if this is sqlite_stat1 */ 221090 int bStat1; /* True if this is sqlite_stat1 */
219887 int bRowid; /* True if this table uses rowid for PK */ 221091 int bRowid; /* True if this table uses rowid for PK */
219888 const char **azCol; /* Column names */ 221092 const char **azCol; /* Column names */
221093 const char **azDflt; /* Default value expressions */
219889 u8 *abPK; /* Array of primary key flags */ 221094 u8 *abPK; /* Array of primary key flags */
219890 int nEntry; /* Total number of entries in hash table */ 221095 int nEntry; /* Total number of entries in hash table */
219891 int nChange; /* Size of apChange[] array */ 221096 int nChange; /* Size of apChange[] array */
219892 SessionChange **apChange; /* Hash table buckets */ 221097 SessionChange **apChange; /* Hash table buckets */
221098 sqlite3_stmt *pDfltStmt;
219893}; 221099};
219894 221100
219895/* 221101/*
@@ -220058,6 +221264,7 @@ struct SessionTable {
220058struct SessionChange { 221264struct SessionChange {
220059 u8 op; /* One of UPDATE, DELETE, INSERT */ 221265 u8 op; /* One of UPDATE, DELETE, INSERT */
220060 u8 bIndirect; /* True if this change is "indirect" */ 221266 u8 bIndirect; /* True if this change is "indirect" */
221267 u16 nRecordField; /* Number of fields in aRecord[] */
220061 int nMaxSize; /* Max size of eventual changeset record */ 221268 int nMaxSize; /* Max size of eventual changeset record */
220062 int nRecord; /* Number of bytes in buffer aRecord[] */ 221269 int nRecord; /* Number of bytes in buffer aRecord[] */
220063 u8 *aRecord; /* Buffer containing old.* record */ 221270 u8 *aRecord; /* Buffer containing old.* record */
@@ -220083,7 +221290,7 @@ static int sessionVarintLen(int iVal){
220083** Read a varint value from aBuf[] into *piVal. Return the number of 221290** Read a varint value from aBuf[] into *piVal. Return the number of
220084** bytes read. 221291** bytes read.
220085*/ 221292*/
220086static int sessionVarintGet(u8 *aBuf, int *piVal){ 221293static int sessionVarintGet(const u8 *aBuf, int *piVal){
220087 return getVarint32(aBuf, *piVal); 221294 return getVarint32(aBuf, *piVal);
220088} 221295}
220089 221296
@@ -220346,9 +221553,11 @@ static int sessionPreupdateHash(
220346** Return the number of bytes of space occupied by the value (including 221553** Return the number of bytes of space occupied by the value (including
220347** the type byte). 221554** the type byte).
220348*/ 221555*/
220349static int sessionSerialLen(u8 *a){ 221556static int sessionSerialLen(const u8 *a){
220350 int e = *a; 221557 int e;
220351 int n; 221558 int n;
221559 assert( a!=0 );
221560 e = *a;
220352 if( e==0 || e==0xFF ) return 1; 221561 if( e==0 || e==0xFF ) return 1;
220353 if( e==SQLITE_NULL ) return 1; 221562 if( e==SQLITE_NULL ) return 1;
220354 if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; 221563 if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
@@ -220753,13 +221962,14 @@ static int sessionGrowHash(
220753** 221962**
220754** For example, if the table is declared as: 221963** For example, if the table is declared as:
220755** 221964**
220756** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z)); 221965** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z));
220757** 221966**
220758** Then the four output variables are populated as follows: 221967** Then the five output variables are populated as follows:
220759** 221968**
220760** *pnCol = 4 221969** *pnCol = 4
220761** *pzTab = "tbl1" 221970** *pzTab = "tbl1"
220762** *pazCol = {"w", "x", "y", "z"} 221971** *pazCol = {"w", "x", "y", "z"}
221972** *pazDflt = {NULL, 'abc', NULL, NULL}
220763** *pabPK = {1, 0, 0, 1} 221973** *pabPK = {1, 0, 0, 1}
220764** 221974**
220765** All returned buffers are part of the same single allocation, which must 221975** All returned buffers are part of the same single allocation, which must
@@ -220773,6 +221983,7 @@ static int sessionTableInfo(
220773 int *pnCol, /* OUT: number of columns */ 221983 int *pnCol, /* OUT: number of columns */
220774 const char **pzTab, /* OUT: Copy of zThis */ 221984 const char **pzTab, /* OUT: Copy of zThis */
220775 const char ***pazCol, /* OUT: Array of column names for table */ 221985 const char ***pazCol, /* OUT: Array of column names for table */
221986 const char ***pazDflt, /* OUT: Array of default value expressions */
220776 u8 **pabPK, /* OUT: Array of booleans - true for PK col */ 221987 u8 **pabPK, /* OUT: Array of booleans - true for PK col */
220777 int *pbRowid /* OUT: True if only PK is a rowid */ 221988 int *pbRowid /* OUT: True if only PK is a rowid */
220778){ 221989){
@@ -220785,11 +221996,18 @@ static int sessionTableInfo(
220785 int i; 221996 int i;
220786 u8 *pAlloc = 0; 221997 u8 *pAlloc = 0;
220787 char **azCol = 0; 221998 char **azCol = 0;
221999 char **azDflt = 0;
220788 u8 *abPK = 0; 222000 u8 *abPK = 0;
220789 int bRowid = 0; /* Set to true to use rowid as PK */ 222001 int bRowid = 0; /* Set to true to use rowid as PK */
220790 222002
220791 assert( pazCol && pabPK ); 222003 assert( pazCol && pabPK );
220792 222004
222005 *pazCol = 0;
222006 *pabPK = 0;
222007 *pnCol = 0;
222008 if( pzTab ) *pzTab = 0;
222009 if( pazDflt ) *pazDflt = 0;
222010
220793 nThis = sqlite3Strlen30(zThis); 222011 nThis = sqlite3Strlen30(zThis);
220794 if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ 222012 if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){
220795 rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); 222013 rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
@@ -220803,39 +222021,28 @@ static int sessionTableInfo(
220803 }else if( rc==SQLITE_ERROR ){ 222021 }else if( rc==SQLITE_ERROR ){
220804 zPragma = sqlite3_mprintf(""); 222022 zPragma = sqlite3_mprintf("");
220805 }else{ 222023 }else{
220806 *pazCol = 0;
220807 *pabPK = 0;
220808 *pnCol = 0;
220809 if( pzTab ) *pzTab = 0;
220810 return rc; 222024 return rc;
220811 } 222025 }
220812 }else{ 222026 }else{
220813 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); 222027 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
220814 } 222028 }
220815 if( !zPragma ){ 222029 if( !zPragma ){
220816 *pazCol = 0;
220817 *pabPK = 0;
220818 *pnCol = 0;
220819 if( pzTab ) *pzTab = 0;
220820 return SQLITE_NOMEM; 222030 return SQLITE_NOMEM;
220821 } 222031 }
220822 222032
220823 rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); 222033 rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
220824 sqlite3_free(zPragma); 222034 sqlite3_free(zPragma);
220825 if( rc!=SQLITE_OK ){ 222035 if( rc!=SQLITE_OK ){
220826 *pazCol = 0;
220827 *pabPK = 0;
220828 *pnCol = 0;
220829 if( pzTab ) *pzTab = 0;
220830 return rc; 222036 return rc;
220831 } 222037 }
220832 222038
220833 nByte = nThis + 1; 222039 nByte = nThis + 1;
220834 bRowid = (pbRowid!=0); 222040 bRowid = (pbRowid!=0);
220835 while( SQLITE_ROW==sqlite3_step(pStmt) ){ 222041 while( SQLITE_ROW==sqlite3_step(pStmt) ){
220836 nByte += sqlite3_column_bytes(pStmt, 1); 222042 nByte += sqlite3_column_bytes(pStmt, 1); /* name */
222043 nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */
220837 nDbCol++; 222044 nDbCol++;
220838 if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; 222045 if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */
220839 } 222046 }
220840 if( nDbCol==0 ) bRowid = 0; 222047 if( nDbCol==0 ) bRowid = 0;
220841 nDbCol += bRowid; 222048 nDbCol += bRowid;
@@ -220843,15 +222050,18 @@ static int sessionTableInfo(
220843 rc = sqlite3_reset(pStmt); 222050 rc = sqlite3_reset(pStmt);
220844 222051
220845 if( rc==SQLITE_OK ){ 222052 if( rc==SQLITE_OK ){
220846 nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); 222053 nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1);
220847 pAlloc = sessionMalloc64(pSession, nByte); 222054 pAlloc = sessionMalloc64(pSession, nByte);
220848 if( pAlloc==0 ){ 222055 if( pAlloc==0 ){
220849 rc = SQLITE_NOMEM; 222056 rc = SQLITE_NOMEM;
222057 }else{
222058 memset(pAlloc, 0, nByte);
220850 } 222059 }
220851 } 222060 }
220852 if( rc==SQLITE_OK ){ 222061 if( rc==SQLITE_OK ){
220853 azCol = (char **)pAlloc; 222062 azCol = (char **)pAlloc;
220854 pAlloc = (u8 *)&azCol[nDbCol]; 222063 azDflt = (char**)&azCol[nDbCol];
222064 pAlloc = (u8 *)&azDflt[nDbCol];
220855 abPK = (u8 *)pAlloc; 222065 abPK = (u8 *)pAlloc;
220856 pAlloc = &abPK[nDbCol]; 222066 pAlloc = &abPK[nDbCol];
220857 if( pzTab ){ 222067 if( pzTab ){
@@ -220871,11 +222081,21 @@ static int sessionTableInfo(
220871 } 222081 }
220872 while( SQLITE_ROW==sqlite3_step(pStmt) ){ 222082 while( SQLITE_ROW==sqlite3_step(pStmt) ){
220873 int nName = sqlite3_column_bytes(pStmt, 1); 222083 int nName = sqlite3_column_bytes(pStmt, 1);
222084 int nDflt = sqlite3_column_bytes(pStmt, 4);
220874 const unsigned char *zName = sqlite3_column_text(pStmt, 1); 222085 const unsigned char *zName = sqlite3_column_text(pStmt, 1);
222086 const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
222087
220875 if( zName==0 ) break; 222088 if( zName==0 ) break;
220876 memcpy(pAlloc, zName, nName+1); 222089 memcpy(pAlloc, zName, nName+1);
220877 azCol[i] = (char *)pAlloc; 222090 azCol[i] = (char *)pAlloc;
220878 pAlloc += nName+1; 222091 pAlloc += nName+1;
222092 if( zDflt ){
222093 memcpy(pAlloc, zDflt, nDflt+1);
222094 azDflt[i] = (char *)pAlloc;
222095 pAlloc += nDflt+1;
222096 }else{
222097 azDflt[i] = 0;
222098 }
220879 abPK[i] = sqlite3_column_int(pStmt, 5); 222099 abPK[i] = sqlite3_column_int(pStmt, 5);
220880 i++; 222100 i++;
220881 } 222101 }
@@ -220886,14 +222106,11 @@ static int sessionTableInfo(
220886 ** free any allocation made. An error code will be returned in this case. 222106 ** free any allocation made. An error code will be returned in this case.
220887 */ 222107 */
220888 if( rc==SQLITE_OK ){ 222108 if( rc==SQLITE_OK ){
220889 *pazCol = (const char **)azCol; 222109 *pazCol = (const char**)azCol;
222110 if( pazDflt ) *pazDflt = (const char**)azDflt;
220890 *pabPK = abPK; 222111 *pabPK = abPK;
220891 *pnCol = nDbCol; 222112 *pnCol = nDbCol;
220892 }else{ 222113 }else{
220893 *pazCol = 0;
220894 *pabPK = 0;
220895 *pnCol = 0;
220896 if( pzTab ) *pzTab = 0;
220897 sessionFree(pSession, azCol); 222114 sessionFree(pSession, azCol);
220898 } 222115 }
220899 if( pbRowid ) *pbRowid = bRowid; 222116 if( pbRowid ) *pbRowid = bRowid;
@@ -220902,10 +222119,9 @@ static int sessionTableInfo(
220902} 222119}
220903 222120
220904/* 222121/*
220905** This function is only called from within a pre-update handler for a 222122** This function is called to initialize the SessionTable.nCol, azCol[]
220906** write to table pTab, part of session pSession. If this is the first 222123** abPK[] and azDflt[] members of SessionTable object pTab. If these
220907** write to this table, initalize the SessionTable.nCol, azCol[] and 222124** fields are already initilialized, this function is a no-op.
220908** abPK[] arrays accordingly.
220909** 222125**
220910** If an error occurs, an error code is stored in sqlite3_session.rc and 222126** If an error occurs, an error code is stored in sqlite3_session.rc and
220911** non-zero returned. Or, if no error occurs but the table has no primary 222127** non-zero returned. Or, if no error occurs but the table has no primary
@@ -220913,15 +222129,22 @@ static int sessionTableInfo(
220913** indicate that updates on this table should be ignored. SessionTable.abPK 222129** indicate that updates on this table should be ignored. SessionTable.abPK
220914** is set to NULL in this case. 222130** is set to NULL in this case.
220915*/ 222131*/
220916static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ 222132static int sessionInitTable(
222133 sqlite3_session *pSession, /* Optional session handle */
222134 SessionTable *pTab, /* Table object to initialize */
222135 sqlite3 *db, /* Database handle to read schema from */
222136 const char *zDb /* Name of db - "main", "temp" etc. */
222137){
222138 int rc = SQLITE_OK;
222139
220917 if( pTab->nCol==0 ){ 222140 if( pTab->nCol==0 ){
220918 u8 *abPK; 222141 u8 *abPK;
220919 assert( pTab->azCol==0 || pTab->abPK==0 ); 222142 assert( pTab->azCol==0 || pTab->abPK==0 );
220920 pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, 222143 rc = sessionTableInfo(pSession, db, zDb,
220921 pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, 222144 pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK,
220922 (pSession->bImplicitPK ? &pTab->bRowid : 0) 222145 ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0)
220923 ); 222146 );
220924 if( pSession->rc==SQLITE_OK ){ 222147 if( rc==SQLITE_OK ){
220925 int i; 222148 int i;
220926 for(i=0; i<pTab->nCol; i++){ 222149 for(i=0; i<pTab->nCol; i++){
220927 if( abPK[i] ){ 222150 if( abPK[i] ){
@@ -220933,14 +222156,321 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){
220933 pTab->bStat1 = 1; 222156 pTab->bStat1 = 1;
220934 } 222157 }
220935 222158
220936 if( pSession->bEnableSize ){ 222159 if( pSession && pSession->bEnableSize ){
220937 pSession->nMaxChangesetSize += ( 222160 pSession->nMaxChangesetSize += (
220938 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 222161 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1
220939 ); 222162 );
220940 } 222163 }
220941 } 222164 }
220942 } 222165 }
220943 return (pSession->rc || pTab->abPK==0); 222166
222167 if( pSession ){
222168 pSession->rc = rc;
222169 return (rc || pTab->abPK==0);
222170 }
222171 return rc;
222172}
222173
222174/*
222175** Re-initialize table object pTab.
222176*/
222177static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
222178 int nCol = 0;
222179 const char **azCol = 0;
222180 const char **azDflt = 0;
222181 u8 *abPK = 0;
222182 int bRowid = 0;
222183
222184 assert( pSession->rc==SQLITE_OK );
222185
222186 pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb,
222187 pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK,
222188 (pSession->bImplicitPK ? &bRowid : 0)
222189 );
222190 if( pSession->rc==SQLITE_OK ){
222191 if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){
222192 pSession->rc = SQLITE_SCHEMA;
222193 }else{
222194 int ii;
222195 int nOldCol = pTab->nCol;
222196 for(ii=0; ii<nCol; ii++){
222197 if( ii<pTab->nCol ){
222198 if( pTab->abPK[ii]!=abPK[ii] ){
222199 pSession->rc = SQLITE_SCHEMA;
222200 }
222201 }else if( abPK[ii] ){
222202 pSession->rc = SQLITE_SCHEMA;
222203 }
222204 }
222205
222206 if( pSession->rc==SQLITE_OK ){
222207 const char **a = pTab->azCol;
222208 pTab->azCol = azCol;
222209 pTab->nCol = nCol;
222210 pTab->azDflt = azDflt;
222211 pTab->abPK = abPK;
222212 azCol = a;
222213 }
222214 if( pSession->bEnableSize ){
222215 pSession->nMaxChangesetSize += (nCol - nOldCol);
222216 pSession->nMaxChangesetSize += sessionVarintLen(nCol);
222217 pSession->nMaxChangesetSize -= sessionVarintLen(nOldCol);
222218 }
222219 }
222220 }
222221
222222 sqlite3_free((char*)azCol);
222223 return pSession->rc;
222224}
222225
222226/*
222227** Session-change object (*pp) contains an old.* record with fewer than
222228** nCol fields. This function updates it with the default values for
222229** the missing fields.
222230*/
222231static void sessionUpdateOneChange(
222232 sqlite3_session *pSession, /* For memory accounting */
222233 int *pRc, /* IN/OUT: Error code */
222234 SessionChange **pp, /* IN/OUT: Change object to update */
222235 int nCol, /* Number of columns now in table */
222236 sqlite3_stmt *pDflt /* SELECT <default-values...> */
222237){
222238 SessionChange *pOld = *pp;
222239
222240 while( pOld->nRecordField<nCol ){
222241 SessionChange *pNew = 0;
222242 int nByte = 0;
222243 int nIncr = 0;
222244 int iField = pOld->nRecordField;
222245 int eType = sqlite3_column_type(pDflt, iField);
222246 switch( eType ){
222247 case SQLITE_NULL:
222248 nIncr = 1;
222249 break;
222250 case SQLITE_INTEGER:
222251 case SQLITE_FLOAT:
222252 nIncr = 9;
222253 break;
222254 default: {
222255 int n = sqlite3_column_bytes(pDflt, iField);
222256 nIncr = 1 + sessionVarintLen(n) + n;
222257 assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
222258 break;
222259 }
222260 }
222261
222262 nByte = nIncr + (sizeof(SessionChange) + pOld->nRecord);
222263 pNew = sessionMalloc64(pSession, nByte);
222264 if( pNew==0 ){
222265 *pRc = SQLITE_NOMEM;
222266 return;
222267 }else{
222268 memcpy(pNew, pOld, sizeof(SessionChange));
222269 pNew->aRecord = (u8*)&pNew[1];
222270 memcpy(pNew->aRecord, pOld->aRecord, pOld->nRecord);
222271 pNew->aRecord[pNew->nRecord++] = (u8)eType;
222272 switch( eType ){
222273 case SQLITE_INTEGER: {
222274 i64 iVal = sqlite3_column_int64(pDflt, iField);
222275 sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal);
222276 pNew->nRecord += 8;
222277 break;
222278 }
222279
222280 case SQLITE_FLOAT: {
222281 double rVal = sqlite3_column_double(pDflt, iField);
222282 i64 iVal = 0;
222283 memcpy(&iVal, &rVal, sizeof(rVal));
222284 sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal);
222285 pNew->nRecord += 8;
222286 break;
222287 }
222288
222289 case SQLITE_TEXT: {
222290 int n = sqlite3_column_bytes(pDflt, iField);
222291 const char *z = (const char*)sqlite3_column_text(pDflt, iField);
222292 pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n);
222293 memcpy(&pNew->aRecord[pNew->nRecord], z, n);
222294 pNew->nRecord += n;
222295 break;
222296 }
222297
222298 case SQLITE_BLOB: {
222299 int n = sqlite3_column_bytes(pDflt, iField);
222300 const u8 *z = (const u8*)sqlite3_column_blob(pDflt, iField);
222301 pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n);
222302 memcpy(&pNew->aRecord[pNew->nRecord], z, n);
222303 pNew->nRecord += n;
222304 break;
222305 }
222306
222307 default:
222308 assert( eType==SQLITE_NULL );
222309 break;
222310 }
222311
222312 sessionFree(pSession, pOld);
222313 *pp = pOld = pNew;
222314 pNew->nRecordField++;
222315 pNew->nMaxSize += nIncr;
222316 if( pSession ){
222317 pSession->nMaxChangesetSize += nIncr;
222318 }
222319 }
222320 }
222321}
222322
222323/*
222324** Ensure that there is room in the buffer to append nByte bytes of data.
222325** If not, use sqlite3_realloc() to grow the buffer so that there is.
222326**
222327** If successful, return zero. Otherwise, if an OOM condition is encountered,
222328** set *pRc to SQLITE_NOMEM and return non-zero.
222329*/
222330static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){
222331#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1)
222332 i64 nReq = p->nBuf + nByte;
222333 if( *pRc==SQLITE_OK && nReq>p->nAlloc ){
222334 u8 *aNew;
222335 i64 nNew = p->nAlloc ? p->nAlloc : 128;
222336
222337 do {
222338 nNew = nNew*2;
222339 }while( nNew<nReq );
222340
222341 /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation
222342 ** of sqlite3_realloc64(). Allocations greater than this size in bytes
222343 ** always fail. It is used here to ensure that this routine can always
222344 ** allocate up to this limit - instead of up to the largest power of
222345 ** two smaller than the limit. */
222346 if( nNew>SESSION_MAX_BUFFER_SZ ){
222347 nNew = SESSION_MAX_BUFFER_SZ;
222348 if( nNew<nReq ){
222349 *pRc = SQLITE_NOMEM;
222350 return 1;
222351 }
222352 }
222353
222354 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
222355 if( 0==aNew ){
222356 *pRc = SQLITE_NOMEM;
222357 }else{
222358 p->aBuf = aNew;
222359 p->nAlloc = nNew;
222360 }
222361 }
222362 return (*pRc!=SQLITE_OK);
222363}
222364
222365
222366/*
222367** This function is a no-op if *pRc is other than SQLITE_OK when it is
222368** called. Otherwise, append a string to the buffer. All bytes in the string
222369** up to (but not including) the nul-terminator are written to the buffer.
222370**
222371** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before
222372** returning.
222373*/
222374static void sessionAppendStr(
222375 SessionBuffer *p,
222376 const char *zStr,
222377 int *pRc
222378){
222379 int nStr = sqlite3Strlen30(zStr);
222380 if( 0==sessionBufferGrow(p, nStr+1, pRc) ){
222381 memcpy(&p->aBuf[p->nBuf], zStr, nStr);
222382 p->nBuf += nStr;
222383 p->aBuf[p->nBuf] = 0x00;
222384 }
222385}
222386
222387/*
222388** Format a string using printf() style formatting and then append it to the
222389** buffer using sessionAppendString().
222390*/
222391static void sessionAppendPrintf(
222392 SessionBuffer *p, /* Buffer to append to */
222393 int *pRc,
222394 const char *zFmt,
222395 ...
222396){
222397 if( *pRc==SQLITE_OK ){
222398 char *zApp = 0;
222399 va_list ap;
222400 va_start(ap, zFmt);
222401 zApp = sqlite3_vmprintf(zFmt, ap);
222402 if( zApp==0 ){
222403 *pRc = SQLITE_NOMEM;
222404 }else{
222405 sessionAppendStr(p, zApp, pRc);
222406 }
222407 va_end(ap);
222408 sqlite3_free(zApp);
222409 }
222410}
222411
222412/*
222413** Prepare a statement against database handle db that SELECTs a single
222414** row containing the default values for each column in table pTab. For
222415** example, if pTab is declared as:
222416**
222417** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd');
222418**
222419** Then this function prepares and returns the SQL statement:
222420**
222421** SELECT NULL, 123, 'abcd';
222422*/
222423static int sessionPrepareDfltStmt(
222424 sqlite3 *db, /* Database handle */
222425 SessionTable *pTab, /* Table to prepare statement for */
222426 sqlite3_stmt **ppStmt /* OUT: Statement handle */
222427){
222428 SessionBuffer sql = {0,0,0};
222429 int rc = SQLITE_OK;
222430 const char *zSep = " ";
222431 int ii = 0;
222432
222433 *ppStmt = 0;
222434 sessionAppendPrintf(&sql, &rc, "SELECT");
222435 for(ii=0; ii<pTab->nCol; ii++){
222436 const char *zDflt = pTab->azDflt[ii] ? pTab->azDflt[ii] : "NULL";
222437 sessionAppendPrintf(&sql, &rc, "%s%s", zSep, zDflt);
222438 zSep = ", ";
222439 }
222440 if( rc==SQLITE_OK ){
222441 rc = sqlite3_prepare_v2(db, (const char*)sql.aBuf, -1, ppStmt, 0);
222442 }
222443 sqlite3_free(sql.aBuf);
222444
222445 return rc;
222446}
222447
222448/*
222449** Table pTab has one or more existing change-records with old.* records
222450** with fewer than pTab->nCol columns. This function updates all such
222451** change-records with the default values for the missing columns.
222452*/
222453static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){
222454 sqlite3_stmt *pStmt = 0;
222455 int rc = pSession->rc;
222456
222457 rc = sessionPrepareDfltStmt(pSession->db, pTab, &pStmt);
222458 if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
222459 int ii = 0;
222460 SessionChange **pp = 0;
222461 for(ii=0; ii<pTab->nChange; ii++){
222462 for(pp=&pTab->apChange[ii]; *pp; pp=&((*pp)->pNext)){
222463 if( (*pp)->nRecordField!=pTab->nCol ){
222464 sessionUpdateOneChange(pSession, &rc, pp, pTab->nCol, pStmt);
222465 }
222466 }
222467 }
222468 }
222469
222470 pSession->rc = rc;
222471 rc = sqlite3_finalize(pStmt);
222472 if( pSession->rc==SQLITE_OK ) pSession->rc = rc;
222473 return pSession->rc;
220944} 222474}
220945 222475
220946/* 222476/*
@@ -221103,16 +222633,22 @@ static void sessionPreupdateOneChange(
221103 int iHash; 222633 int iHash;
221104 int bNull = 0; 222634 int bNull = 0;
221105 int rc = SQLITE_OK; 222635 int rc = SQLITE_OK;
222636 int nExpect = 0;
221106 SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; 222637 SessionStat1Ctx stat1 = {{0,0,0,0,0},0};
221107 222638
221108 if( pSession->rc ) return; 222639 if( pSession->rc ) return;
221109 222640
221110 /* Load table details if required */ 222641 /* Load table details if required */
221111 if( sessionInitTable(pSession, pTab) ) return; 222642 if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return;
221112 222643
221113 /* Check the number of columns in this xPreUpdate call matches the 222644 /* Check the number of columns in this xPreUpdate call matches the
221114 ** number of columns in the table. */ 222645 ** number of columns in the table. */
221115 if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ 222646 nExpect = pSession->hook.xCount(pSession->hook.pCtx);
222647 if( (pTab->nCol-pTab->bRowid)<nExpect ){
222648 if( sessionReinitTable(pSession, pTab) ) return;
222649 if( sessionUpdateChanges(pSession, pTab) ) return;
222650 }
222651 if( (pTab->nCol-pTab->bRowid)!=nExpect ){
221116 pSession->rc = SQLITE_SCHEMA; 222652 pSession->rc = SQLITE_SCHEMA;
221117 return; 222653 return;
221118 } 222654 }
@@ -221189,7 +222725,7 @@ static void sessionPreupdateOneChange(
221189 } 222725 }
221190 222726
221191 /* Allocate the change object */ 222727 /* Allocate the change object */
221192 pC = (SessionChange *)sessionMalloc64(pSession, nByte); 222728 pC = (SessionChange*)sessionMalloc64(pSession, nByte);
221193 if( !pC ){ 222729 if( !pC ){
221194 rc = SQLITE_NOMEM; 222730 rc = SQLITE_NOMEM;
221195 goto error_out; 222731 goto error_out;
@@ -221222,6 +222758,7 @@ static void sessionPreupdateOneChange(
221222 if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ 222758 if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){
221223 pC->bIndirect = 1; 222759 pC->bIndirect = 1;
221224 } 222760 }
222761 pC->nRecordField = pTab->nCol;
221225 pC->nRecord = nByte; 222762 pC->nRecord = nByte;
221226 pC->op = op; 222763 pC->op = op;
221227 pC->pNext = pTab->apChange[iHash]; 222764 pC->pNext = pTab->apChange[iHash];
@@ -221601,7 +223138,7 @@ SQLITE_API int sqlite3session_diff(
221601 /* Locate and if necessary initialize the target table object */ 223138 /* Locate and if necessary initialize the target table object */
221602 rc = sessionFindTable(pSession, zTbl, &pTo); 223139 rc = sessionFindTable(pSession, zTbl, &pTo);
221603 if( pTo==0 ) goto diff_out; 223140 if( pTo==0 ) goto diff_out;
221604 if( sessionInitTable(pSession, pTo) ){ 223141 if( sessionInitTable(pSession, pTo, pSession->db, pSession->zDb) ){
221605 rc = pSession->rc; 223142 rc = pSession->rc;
221606 goto diff_out; 223143 goto diff_out;
221607 } 223144 }
@@ -221614,7 +223151,7 @@ SQLITE_API int sqlite3session_diff(
221614 int bRowid = 0; 223151 int bRowid = 0;
221615 u8 *abPK; 223152 u8 *abPK;
221616 const char **azCol = 0; 223153 const char **azCol = 0;
221617 rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, 223154 rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK,
221618 pSession->bImplicitPK ? &bRowid : 0 223155 pSession->bImplicitPK ? &bRowid : 0
221619 ); 223156 );
221620 if( rc==SQLITE_OK ){ 223157 if( rc==SQLITE_OK ){
@@ -221729,6 +223266,7 @@ static void sessionDeleteTable(sqlite3_session *pSession, SessionTable *pList){
221729 sessionFree(pSession, p); 223266 sessionFree(pSession, p);
221730 } 223267 }
221731 } 223268 }
223269 sqlite3_finalize(pTab->pDfltStmt);
221732 sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ 223270 sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */
221733 sessionFree(pSession, pTab->apChange); 223271 sessionFree(pSession, pTab->apChange);
221734 sessionFree(pSession, pTab); 223272 sessionFree(pSession, pTab);
@@ -221763,7 +223301,7 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession){
221763 223301
221764 /* Assert that all allocations have been freed and then free the 223302 /* Assert that all allocations have been freed and then free the
221765 ** session object itself. */ 223303 ** session object itself. */
221766 assert( pSession->nMalloc==0 ); 223304 // assert( pSession->nMalloc==0 );
221767 sqlite3_free(pSession); 223305 sqlite3_free(pSession);
221768} 223306}
221769 223307
@@ -221835,48 +223373,6 @@ SQLITE_API int sqlite3session_attach(
221835} 223373}
221836 223374
221837/* 223375/*
221838** Ensure that there is room in the buffer to append nByte bytes of data.
221839** If not, use sqlite3_realloc() to grow the buffer so that there is.
221840**
221841** If successful, return zero. Otherwise, if an OOM condition is encountered,
221842** set *pRc to SQLITE_NOMEM and return non-zero.
221843*/
221844static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){
221845#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1)
221846 i64 nReq = p->nBuf + nByte;
221847 if( *pRc==SQLITE_OK && nReq>p->nAlloc ){
221848 u8 *aNew;
221849 i64 nNew = p->nAlloc ? p->nAlloc : 128;
221850
221851 do {
221852 nNew = nNew*2;
221853 }while( nNew<nReq );
221854
221855 /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation
221856 ** of sqlite3_realloc64(). Allocations greater than this size in bytes
221857 ** always fail. It is used here to ensure that this routine can always
221858 ** allocate up to this limit - instead of up to the largest power of
221859 ** two smaller than the limit. */
221860 if( nNew>SESSION_MAX_BUFFER_SZ ){
221861 nNew = SESSION_MAX_BUFFER_SZ;
221862 if( nNew<nReq ){
221863 *pRc = SQLITE_NOMEM;
221864 return 1;
221865 }
221866 }
221867
221868 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
221869 if( 0==aNew ){
221870 *pRc = SQLITE_NOMEM;
221871 }else{
221872 p->aBuf = aNew;
221873 p->nAlloc = nNew;
221874 }
221875 }
221876 return (*pRc!=SQLITE_OK);
221877}
221878
221879/*
221880** Append the value passed as the second argument to the buffer passed 223376** Append the value passed as the second argument to the buffer passed
221881** as the first. 223377** as the first.
221882** 223378**
@@ -221946,27 +223442,6 @@ static void sessionAppendBlob(
221946 223442
221947/* 223443/*
221948** This function is a no-op if *pRc is other than SQLITE_OK when it is 223444** This function is a no-op if *pRc is other than SQLITE_OK when it is
221949** called. Otherwise, append a string to the buffer. All bytes in the string
221950** up to (but not including) the nul-terminator are written to the buffer.
221951**
221952** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before
221953** returning.
221954*/
221955static void sessionAppendStr(
221956 SessionBuffer *p,
221957 const char *zStr,
221958 int *pRc
221959){
221960 int nStr = sqlite3Strlen30(zStr);
221961 if( 0==sessionBufferGrow(p, nStr+1, pRc) ){
221962 memcpy(&p->aBuf[p->nBuf], zStr, nStr);
221963 p->nBuf += nStr;
221964 p->aBuf[p->nBuf] = 0x00;
221965 }
221966}
221967
221968/*
221969** This function is a no-op if *pRc is other than SQLITE_OK when it is
221970** called. Otherwise, append the string representation of integer iVal 223445** called. Otherwise, append the string representation of integer iVal
221971** to the buffer. No nul-terminator is written. 223446** to the buffer. No nul-terminator is written.
221972** 223447**
@@ -221983,27 +223458,6 @@ static void sessionAppendInteger(
221983 sessionAppendStr(p, aBuf, pRc); 223458 sessionAppendStr(p, aBuf, pRc);
221984} 223459}
221985 223460
221986static void sessionAppendPrintf(
221987 SessionBuffer *p, /* Buffer to append to */
221988 int *pRc,
221989 const char *zFmt,
221990 ...
221991){
221992 if( *pRc==SQLITE_OK ){
221993 char *zApp = 0;
221994 va_list ap;
221995 va_start(ap, zFmt);
221996 zApp = sqlite3_vmprintf(zFmt, ap);
221997 if( zApp==0 ){
221998 *pRc = SQLITE_NOMEM;
221999 }else{
222000 sessionAppendStr(p, zApp, pRc);
222001 }
222002 va_end(ap);
222003 sqlite3_free(zApp);
222004 }
222005}
222006
222007/* 223461/*
222008** This function is a no-op if *pRc is other than SQLITE_OK when it is 223462** This function is a no-op if *pRc is other than SQLITE_OK when it is
222009** called. Otherwise, append the string zStr enclosed in quotes (") and 223463** called. Otherwise, append the string zStr enclosed in quotes (") and
@@ -222494,26 +223948,16 @@ static int sessionGenerateChangeset(
222494 for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ 223948 for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
222495 if( pTab->nEntry ){ 223949 if( pTab->nEntry ){
222496 const char *zName = pTab->zName; 223950 const char *zName = pTab->zName;
222497 int nCol = 0; /* Number of columns in table */
222498 u8 *abPK = 0; /* Primary key array */
222499 const char **azCol = 0; /* Table columns */
222500 int i; /* Used to iterate through hash buckets */ 223951 int i; /* Used to iterate through hash buckets */
222501 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ 223952 sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
222502 int nRewind = buf.nBuf; /* Initial size of write buffer */ 223953 int nRewind = buf.nBuf; /* Initial size of write buffer */
222503 int nNoop; /* Size of buffer after writing tbl header */ 223954 int nNoop; /* Size of buffer after writing tbl header */
222504 int bRowid = 0; 223955 int nOldCol = pTab->nCol;
222505 223956
222506 /* Check the table schema is still Ok. */ 223957 /* Check the table schema is still Ok. */
222507 rc = sessionTableInfo( 223958 rc = sessionReinitTable(pSession, pTab);
222508 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, 223959 if( rc==SQLITE_OK && pTab->nCol!=nOldCol ){
222509 (pSession->bImplicitPK ? &bRowid : 0) 223960 rc = sessionUpdateChanges(pSession, pTab);
222510 );
222511 if( rc==SQLITE_OK && (
222512 pTab->nCol!=nCol
222513 || pTab->bRowid!=bRowid
222514 || memcmp(abPK, pTab->abPK, nCol)
222515 )){
222516 rc = SQLITE_SCHEMA;
222517 } 223961 }
222518 223962
222519 /* Write a table header */ 223963 /* Write a table header */
@@ -222521,8 +223965,8 @@ static int sessionGenerateChangeset(
222521 223965
222522 /* Build and compile a statement to execute: */ 223966 /* Build and compile a statement to execute: */
222523 if( rc==SQLITE_OK ){ 223967 if( rc==SQLITE_OK ){
222524 rc = sessionSelectStmt( 223968 rc = sessionSelectStmt(db, 0, pSession->zDb,
222525 db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel 223969 zName, pTab->bRowid, pTab->nCol, pTab->azCol, pTab->abPK, &pSel
222526 ); 223970 );
222527 } 223971 }
222528 223972
@@ -222531,22 +223975,22 @@ static int sessionGenerateChangeset(
222531 SessionChange *p; /* Used to iterate through changes */ 223975 SessionChange *p; /* Used to iterate through changes */
222532 223976
222533 for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ 223977 for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){
222534 rc = sessionSelectBind(pSel, nCol, abPK, p); 223978 rc = sessionSelectBind(pSel, pTab->nCol, pTab->abPK, p);
222535 if( rc!=SQLITE_OK ) continue; 223979 if( rc!=SQLITE_OK ) continue;
222536 if( sqlite3_step(pSel)==SQLITE_ROW ){ 223980 if( sqlite3_step(pSel)==SQLITE_ROW ){
222537 if( p->op==SQLITE_INSERT ){ 223981 if( p->op==SQLITE_INSERT ){
222538 int iCol; 223982 int iCol;
222539 sessionAppendByte(&buf, SQLITE_INSERT, &rc); 223983 sessionAppendByte(&buf, SQLITE_INSERT, &rc);
222540 sessionAppendByte(&buf, p->bIndirect, &rc); 223984 sessionAppendByte(&buf, p->bIndirect, &rc);
222541 for(iCol=0; iCol<nCol; iCol++){ 223985 for(iCol=0; iCol<pTab->nCol; iCol++){
222542 sessionAppendCol(&buf, pSel, iCol, &rc); 223986 sessionAppendCol(&buf, pSel, iCol, &rc);
222543 } 223987 }
222544 }else{ 223988 }else{
222545 assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ 223989 assert( pTab->abPK!=0 );
222546 rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); 223990 rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, pTab->abPK);
222547 } 223991 }
222548 }else if( p->op!=SQLITE_INSERT ){ 223992 }else if( p->op!=SQLITE_INSERT ){
222549 rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK); 223993 rc = sessionAppendDelete(&buf, bPatchset, p, pTab->nCol,pTab->abPK);
222550 } 223994 }
222551 if( rc==SQLITE_OK ){ 223995 if( rc==SQLITE_OK ){
222552 rc = sqlite3_reset(pSel); 223996 rc = sqlite3_reset(pSel);
@@ -222571,7 +224015,6 @@ static int sessionGenerateChangeset(
222571 if( buf.nBuf==nNoop ){ 224015 if( buf.nBuf==nNoop ){
222572 buf.nBuf = nRewind; 224016 buf.nBuf = nRewind;
222573 } 224017 }
222574 sqlite3_free((char*)azCol); /* cast works around VC++ bug */
222575 } 224018 }
222576 } 224019 }
222577 224020
@@ -224700,7 +226143,7 @@ static int sessionChangesetApply(
224700 226143
224701 sqlite3changeset_pk(pIter, &abPK, 0); 226144 sqlite3changeset_pk(pIter, &abPK, 0);
224702 rc = sessionTableInfo(0, db, "main", zNew, 226145 rc = sessionTableInfo(0, db, "main", zNew,
224703 &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid 226146 &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid
224704 ); 226147 );
224705 if( rc!=SQLITE_OK ) break; 226148 if( rc!=SQLITE_OK ) break;
224706 for(i=0; i<sApply.nCol; i++){ 226149 for(i=0; i<sApply.nCol; i++){
@@ -224832,11 +226275,24 @@ SQLITE_API int sqlite3changeset_apply_v2(
224832 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ 226275 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
224833 int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); 226276 int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
224834 int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); 226277 int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1);
226278 u64 savedFlag = db->flags & SQLITE_FkNoAction;
226279
226280 if( flags & SQLITE_CHANGESETAPPLY_FKNOACTION ){
226281 db->flags |= ((u64)SQLITE_FkNoAction);
226282 db->aDb[0].pSchema->schema_cookie -= 32;
226283 }
226284
224835 if( rc==SQLITE_OK ){ 226285 if( rc==SQLITE_OK ){
224836 rc = sessionChangesetApply( 226286 rc = sessionChangesetApply(
224837 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags 226287 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
224838 ); 226288 );
224839 } 226289 }
226290
226291 if( (flags & SQLITE_CHANGESETAPPLY_FKNOACTION) && savedFlag==0 ){
226292 assert( db->flags & SQLITE_FkNoAction );
226293 db->flags &= ~((u64)SQLITE_FkNoAction);
226294 db->aDb[0].pSchema->schema_cookie -= 32;
226295 }
224840 return rc; 226296 return rc;
224841} 226297}
224842 226298
@@ -224924,6 +226380,9 @@ struct sqlite3_changegroup {
224924 int rc; /* Error code */ 226380 int rc; /* Error code */
224925 int bPatch; /* True to accumulate patchsets */ 226381 int bPatch; /* True to accumulate patchsets */
224926 SessionTable *pList; /* List of tables in current patch */ 226382 SessionTable *pList; /* List of tables in current patch */
226383
226384 sqlite3 *db; /* Configured by changegroup_schema() */
226385 char *zDb; /* Configured by changegroup_schema() */
224927}; 226386};
224928 226387
224929/* 226388/*
@@ -224944,6 +226403,7 @@ static int sessionChangeMerge(
224944){ 226403){
224945 SessionChange *pNew = 0; 226404 SessionChange *pNew = 0;
224946 int rc = SQLITE_OK; 226405 int rc = SQLITE_OK;
226406 assert( aRec!=0 );
224947 226407
224948 if( !pExist ){ 226408 if( !pExist ){
224949 pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec); 226409 pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec);
@@ -225110,6 +226570,114 @@ static int sessionChangeMerge(
225110} 226570}
225111 226571
225112/* 226572/*
226573** Check if a changeset entry with nCol columns and the PK array passed
226574** as the final argument to this function is compatible with SessionTable
226575** pTab. If so, return 1. Otherwise, if they are incompatible in some way,
226576** return 0.
226577*/
226578static int sessionChangesetCheckCompat(
226579 SessionTable *pTab,
226580 int nCol,
226581 u8 *abPK
226582){
226583 if( pTab->azCol && nCol<pTab->nCol ){
226584 int ii;
226585 for(ii=0; ii<pTab->nCol; ii++){
226586 u8 bPK = (ii < nCol) ? abPK[ii] : 0;
226587 if( pTab->abPK[ii]!=bPK ) return 0;
226588 }
226589 return 1;
226590 }
226591 return (pTab->nCol==nCol && 0==memcmp(abPK, pTab->abPK, nCol));
226592}
226593
226594static int sessionChangesetExtendRecord(
226595 sqlite3_changegroup *pGrp,
226596 SessionTable *pTab,
226597 int nCol,
226598 int op,
226599 const u8 *aRec,
226600 int nRec,
226601 SessionBuffer *pOut
226602){
226603 int rc = SQLITE_OK;
226604 int ii = 0;
226605
226606 assert( pTab->azCol );
226607 assert( nCol<pTab->nCol );
226608
226609 pOut->nBuf = 0;
226610 if( op==SQLITE_INSERT || (op==SQLITE_DELETE && pGrp->bPatch==0) ){
226611 /* Append the missing default column values to the record. */
226612 sessionAppendBlob(pOut, aRec, nRec, &rc);
226613 if( rc==SQLITE_OK && pTab->pDfltStmt==0 ){
226614 rc = sessionPrepareDfltStmt(pGrp->db, pTab, &pTab->pDfltStmt);
226615 }
226616 for(ii=nCol; rc==SQLITE_OK && ii<pTab->nCol; ii++){
226617 int eType = sqlite3_column_type(pTab->pDfltStmt, ii);
226618 sessionAppendByte(pOut, eType, &rc);
226619 switch( eType ){
226620 case SQLITE_FLOAT:
226621 case SQLITE_INTEGER: {
226622 i64 iVal;
226623 if( eType==SQLITE_INTEGER ){
226624 iVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
226625 }else{
226626 double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
226627 memcpy(&iVal, &rVal, sizeof(i64));
226628 }
226629 if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){
226630 sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal);
226631 }
226632 break;
226633 }
226634
226635 case SQLITE_BLOB:
226636 case SQLITE_TEXT: {
226637 int n = sqlite3_column_bytes(pTab->pDfltStmt, ii);
226638 sessionAppendVarint(pOut, n, &rc);
226639 if( eType==SQLITE_TEXT ){
226640 const u8 *z = (const u8*)sqlite3_column_text(pTab->pDfltStmt, ii);
226641 sessionAppendBlob(pOut, z, n, &rc);
226642 }else{
226643 const u8 *z = (const u8*)sqlite3_column_blob(pTab->pDfltStmt, ii);
226644 sessionAppendBlob(pOut, z, n, &rc);
226645 }
226646 break;
226647 }
226648
226649 default:
226650 assert( eType==SQLITE_NULL );
226651 break;
226652 }
226653 }
226654 }else if( op==SQLITE_UPDATE ){
226655 /* Append missing "undefined" entries to the old.* record. And, if this
226656 ** is an UPDATE, to the new.* record as well. */
226657 int iOff = 0;
226658 if( pGrp->bPatch==0 ){
226659 for(ii=0; ii<nCol; ii++){
226660 iOff += sessionSerialLen(&aRec[iOff]);
226661 }
226662 sessionAppendBlob(pOut, aRec, iOff, &rc);
226663 for(ii=0; ii<(pTab->nCol-nCol); ii++){
226664 sessionAppendByte(pOut, 0x00, &rc);
226665 }
226666 }
226667
226668 sessionAppendBlob(pOut, &aRec[iOff], nRec-iOff, &rc);
226669 for(ii=0; ii<(pTab->nCol-nCol); ii++){
226670 sessionAppendByte(pOut, 0x00, &rc);
226671 }
226672 }else{
226673 assert( op==SQLITE_DELETE && pGrp->bPatch );
226674 sessionAppendBlob(pOut, aRec, nRec, &rc);
226675 }
226676
226677 return rc;
226678}
226679
226680/*
225113** Add all changes in the changeset traversed by the iterator passed as 226681** Add all changes in the changeset traversed by the iterator passed as
225114** the first argument to the changegroup hash tables. 226682** the first argument to the changegroup hash tables.
225115*/ 226683*/
@@ -225122,6 +226690,7 @@ static int sessionChangesetToHash(
225122 int nRec; 226690 int nRec;
225123 int rc = SQLITE_OK; 226691 int rc = SQLITE_OK;
225124 SessionTable *pTab = 0; 226692 SessionTable *pTab = 0;
226693 SessionBuffer rec = {0, 0, 0};
225125 226694
225126 while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ 226695 while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){
225127 const char *zNew; 226696 const char *zNew;
@@ -225133,6 +226702,9 @@ static int sessionChangesetToHash(
225133 SessionChange *pExist = 0; 226702 SessionChange *pExist = 0;
225134 SessionChange **pp; 226703 SessionChange **pp;
225135 226704
226705 /* Ensure that only changesets, or only patchsets, but not a mixture
226706 ** of both, are being combined. It is an error to try to combine a
226707 ** changeset and a patchset. */
225136 if( pGrp->pList==0 ){ 226708 if( pGrp->pList==0 ){
225137 pGrp->bPatch = pIter->bPatchset; 226709 pGrp->bPatch = pIter->bPatchset;
225138 }else if( pIter->bPatchset!=pGrp->bPatch ){ 226710 }else if( pIter->bPatchset!=pGrp->bPatch ){
@@ -225165,18 +226737,38 @@ static int sessionChangesetToHash(
225165 pTab->zName = (char*)&pTab->abPK[nCol]; 226737 pTab->zName = (char*)&pTab->abPK[nCol];
225166 memcpy(pTab->zName, zNew, nNew+1); 226738 memcpy(pTab->zName, zNew, nNew+1);
225167 226739
226740 if( pGrp->db ){
226741 pTab->nCol = 0;
226742 rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
226743 if( rc ){
226744 assert( pTab->azCol==0 );
226745 sqlite3_free(pTab);
226746 break;
226747 }
226748 }
226749
225168 /* The new object must be linked on to the end of the list, not 226750 /* The new object must be linked on to the end of the list, not
225169 ** simply added to the start of it. This is to ensure that the 226751 ** simply added to the start of it. This is to ensure that the
225170 ** tables within the output of sqlite3changegroup_output() are in 226752 ** tables within the output of sqlite3changegroup_output() are in
225171 ** the right order. */ 226753 ** the right order. */
225172 for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); 226754 for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext);
225173 *ppTab = pTab; 226755 *ppTab = pTab;
225174 }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){ 226756 }
226757
226758 if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
225175 rc = SQLITE_SCHEMA; 226759 rc = SQLITE_SCHEMA;
225176 break; 226760 break;
225177 } 226761 }
225178 } 226762 }
225179 226763
226764 if( nCol<pTab->nCol ){
226765 assert( pGrp->db );
226766 rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec);
226767 if( rc ) break;
226768 aRec = rec.aBuf;
226769 nRec = rec.nBuf;
226770 }
226771
225180 if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ 226772 if( sessionGrowHash(0, pIter->bPatchset, pTab) ){
225181 rc = SQLITE_NOMEM; 226773 rc = SQLITE_NOMEM;
225182 break; 226774 break;
@@ -225214,6 +226806,7 @@ static int sessionChangesetToHash(
225214 } 226806 }
225215 } 226807 }
225216 226808
226809 sqlite3_free(rec.aBuf);
225217 if( rc==SQLITE_OK ) rc = pIter->rc; 226810 if( rc==SQLITE_OK ) rc = pIter->rc;
225218 return rc; 226811 return rc;
225219} 226812}
@@ -225301,6 +226894,31 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp){
225301} 226894}
225302 226895
225303/* 226896/*
226897** Provide a database schema to the changegroup object.
226898*/
226899SQLITE_API int sqlite3changegroup_schema(
226900 sqlite3_changegroup *pGrp,
226901 sqlite3 *db,
226902 const char *zDb
226903){
226904 int rc = SQLITE_OK;
226905
226906 if( pGrp->pList || pGrp->db ){
226907 /* Cannot add a schema after one or more calls to sqlite3changegroup_add(),
226908 ** or after sqlite3changegroup_schema() has already been called. */
226909 rc = SQLITE_MISUSE;
226910 }else{
226911 pGrp->zDb = sqlite3_mprintf("%s", zDb);
226912 if( pGrp->zDb==0 ){
226913 rc = SQLITE_NOMEM;
226914 }else{
226915 pGrp->db = db;
226916 }
226917 }
226918 return rc;
226919}
226920
226921/*
225304** Add the changeset currently stored in buffer pData, size nData bytes, 226922** Add the changeset currently stored in buffer pData, size nData bytes,
225305** to changeset-group p. 226923** to changeset-group p.
225306*/ 226924*/
@@ -225363,6 +226981,7 @@ SQLITE_API int sqlite3changegroup_output_strm(
225363*/ 226981*/
225364SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ 226982SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){
225365 if( pGrp ){ 226983 if( pGrp ){
226984 sqlite3_free(pGrp->zDb);
225366 sessionDeleteTable(0, pGrp->pList); 226985 sessionDeleteTable(0, pGrp->pList);
225367 sqlite3_free(pGrp); 226986 sqlite3_free(pGrp);
225368 } 226987 }
@@ -228868,15 +230487,19 @@ static int fts5CInstIterInit(
228868*/ 230487*/
228869typedef struct HighlightContext HighlightContext; 230488typedef struct HighlightContext HighlightContext;
228870struct HighlightContext { 230489struct HighlightContext {
228871 CInstIter iter; /* Coalesced Instance Iterator */ 230490 /* Constant parameters to fts5HighlightCb() */
228872 int iPos; /* Current token offset in zIn[] */
228873 int iRangeStart; /* First token to include */ 230491 int iRangeStart; /* First token to include */
228874 int iRangeEnd; /* If non-zero, last token to include */ 230492 int iRangeEnd; /* If non-zero, last token to include */
228875 const char *zOpen; /* Opening highlight */ 230493 const char *zOpen; /* Opening highlight */
228876 const char *zClose; /* Closing highlight */ 230494 const char *zClose; /* Closing highlight */
228877 const char *zIn; /* Input text */ 230495 const char *zIn; /* Input text */
228878 int nIn; /* Size of input text in bytes */ 230496 int nIn; /* Size of input text in bytes */
228879 int iOff; /* Current offset within zIn[] */ 230497
230498 /* Variables modified by fts5HighlightCb() */
230499 CInstIter iter; /* Coalesced Instance Iterator */
230500 int iPos; /* Current token offset in zIn[] */
230501 int iOff; /* Have copied up to this offset in zIn[] */
230502 int bOpen; /* True if highlight is open */
228880 char *zOut; /* Output value */ 230503 char *zOut; /* Output value */
228881}; 230504};
228882 230505
@@ -228909,8 +230532,8 @@ static int fts5HighlightCb(
228909 int tflags, /* Mask of FTS5_TOKEN_* flags */ 230532 int tflags, /* Mask of FTS5_TOKEN_* flags */
228910 const char *pToken, /* Buffer containing token */ 230533 const char *pToken, /* Buffer containing token */
228911 int nToken, /* Size of token in bytes */ 230534 int nToken, /* Size of token in bytes */
228912 int iStartOff, /* Start offset of token */ 230535 int iStartOff, /* Start byte offset of token */
228913 int iEndOff /* End offset of token */ 230536 int iEndOff /* End byte offset of token */
228914){ 230537){
228915 HighlightContext *p = (HighlightContext*)pContext; 230538 HighlightContext *p = (HighlightContext*)pContext;
228916 int rc = SQLITE_OK; 230539 int rc = SQLITE_OK;
@@ -228926,30 +230549,47 @@ static int fts5HighlightCb(
228926 if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff; 230549 if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff;
228927 } 230550 }
228928 230551
228929 if( iPos==p->iter.iStart ){ 230552 /* If the parenthesis is open, and this token is not part of the current
230553 ** phrase, and the starting byte offset of this token is past the point
230554 ** that has currently been copied into the output buffer, close the
230555 ** parenthesis. */
230556 if( p->bOpen
230557 && (iPos<=p->iter.iStart || p->iter.iStart<0)
230558 && iStartOff>p->iOff
230559 ){
230560 fts5HighlightAppend(&rc, p, p->zClose, -1);
230561 p->bOpen = 0;
230562 }
230563
230564 /* If this is the start of a new phrase, and the highlight is not open:
230565 **
230566 ** * copy text from the input up to the start of the phrase, and
230567 ** * open the highlight.
230568 */
230569 if( iPos==p->iter.iStart && p->bOpen==0 ){
228930 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff); 230570 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff);
228931 fts5HighlightAppend(&rc, p, p->zOpen, -1); 230571 fts5HighlightAppend(&rc, p, p->zOpen, -1);
228932 p->iOff = iStartOff; 230572 p->iOff = iStartOff;
230573 p->bOpen = 1;
228933 } 230574 }
228934 230575
228935 if( iPos==p->iter.iEnd ){ 230576 if( iPos==p->iter.iEnd ){
228936 if( p->iRangeEnd>=0 && p->iter.iStart<p->iRangeStart ){ 230577 if( p->bOpen==0 ){
230578 assert( p->iRangeEnd>=0 );
228937 fts5HighlightAppend(&rc, p, p->zOpen, -1); 230579 fts5HighlightAppend(&rc, p, p->zOpen, -1);
230580 p->bOpen = 1;
228938 } 230581 }
228939 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); 230582 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);
228940 fts5HighlightAppend(&rc, p, p->zClose, -1);
228941 p->iOff = iEndOff; 230583 p->iOff = iEndOff;
230584
228942 if( rc==SQLITE_OK ){ 230585 if( rc==SQLITE_OK ){
228943 rc = fts5CInstIterNext(&p->iter); 230586 rc = fts5CInstIterNext(&p->iter);
228944 } 230587 }
228945 } 230588 }
228946 230589
228947 if( p->iRangeEnd>=0 && iPos==p->iRangeEnd ){ 230590 if( iPos==p->iRangeEnd ){
228948 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); 230591 fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);
228949 p->iOff = iEndOff; 230592 p->iOff = iEndOff;
228950 if( iPos>=p->iter.iStart && iPos<p->iter.iEnd ){
228951 fts5HighlightAppend(&rc, p, p->zClose, -1);
228952 }
228953 } 230593 }
228954 230594
228955 return rc; 230595 return rc;
@@ -228990,6 +230630,9 @@ static void fts5HighlightFunction(
228990 if( rc==SQLITE_OK ){ 230630 if( rc==SQLITE_OK ){
228991 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); 230631 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);
228992 } 230632 }
230633 if( ctx.bOpen ){
230634 fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1);
230635 }
228993 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); 230636 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
228994 230637
228995 if( rc==SQLITE_OK ){ 230638 if( rc==SQLITE_OK ){
@@ -229268,6 +230911,9 @@ static void fts5SnippetFunction(
229268 if( rc==SQLITE_OK ){ 230911 if( rc==SQLITE_OK ){
229269 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); 230912 rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);
229270 } 230913 }
230914 if( ctx.bOpen ){
230915 fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1);
230916 }
229271 if( ctx.iRangeEnd>=(nColSize-1) ){ 230917 if( ctx.iRangeEnd>=(nColSize-1) ){
229272 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); 230918 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
229273 }else{ 230919 }else{
@@ -237539,7 +239185,6 @@ static int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){
237539 assert_nc( i2!=0 ); 239185 assert_nc( i2!=0 );
237540 pRes->bTermEq = 1; 239186 pRes->bTermEq = 1;
237541 if( p1->iRowid==p2->iRowid ){ 239187 if( p1->iRowid==p2->iRowid ){
237542 p1->bDel = p2->bDel;
237543 return i2; 239188 return i2;
237544 } 239189 }
237545 res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; 239190 res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1;
@@ -237907,7 +239552,7 @@ static Fts5Iter *fts5MultiIterAlloc(
237907 int nSeg 239552 int nSeg
237908){ 239553){
237909 Fts5Iter *pNew; 239554 Fts5Iter *pNew;
237910 int nSlot; /* Power of two >= nSeg */ 239555 i64 nSlot; /* Power of two >= nSeg */
237911 239556
237912 for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2); 239557 for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2);
237913 pNew = fts5IdxMalloc(p, 239558 pNew = fts5IdxMalloc(p,
@@ -239683,7 +241328,6 @@ static void fts5DoSecureDelete(
239683 int iPgIdx = pSeg->pLeaf->szLeaf; 241328 int iPgIdx = pSeg->pLeaf->szLeaf;
239684 241329
239685 u64 iDelta = 0; 241330 u64 iDelta = 0;
239686 u64 iNextDelta = 0;
239687 int iNextOff = 0; 241331 int iNextOff = 0;
239688 int iOff = 0; 241332 int iOff = 0;
239689 int nIdx = 0; 241333 int nIdx = 0;
@@ -239691,7 +241335,6 @@ static void fts5DoSecureDelete(
239691 int bLastInDoclist = 0; 241335 int bLastInDoclist = 0;
239692 int iIdx = 0; 241336 int iIdx = 0;
239693 int iStart = 0; 241337 int iStart = 0;
239694 int iKeyOff = 0;
239695 int iDelKeyOff = 0; /* Offset of deleted key, if any */ 241338 int iDelKeyOff = 0; /* Offset of deleted key, if any */
239696 241339
239697 nIdx = nPg-iPgIdx; 241340 nIdx = nPg-iPgIdx;
@@ -239716,10 +241359,21 @@ static void fts5DoSecureDelete(
239716 ** This block sets the following variables: 241359 ** This block sets the following variables:
239717 ** 241360 **
239718 ** iStart: 241361 ** iStart:
241362 ** The offset of the first byte of the rowid or delta-rowid
241363 ** value for the doclist entry being removed.
241364 **
239719 ** iDelta: 241365 ** iDelta:
241366 ** The value of the rowid or delta-rowid value for the doclist
241367 ** entry being removed.
241368 **
241369 ** iNextOff:
241370 ** The offset of the next entry following the position list
241371 ** for the one being removed. If the position list for this
241372 ** entry overflows onto the next leaf page, this value will be
241373 ** greater than pLeaf->szLeaf.
239720 */ 241374 */
239721 { 241375 {
239722 int iSOP; 241376 int iSOP; /* Start-Of-Position-list */
239723 if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ 241377 if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){
239724 iStart = pSeg->iTermLeafOffset; 241378 iStart = pSeg->iTermLeafOffset;
239725 }else{ 241379 }else{
@@ -239755,47 +241409,75 @@ static void fts5DoSecureDelete(
239755 } 241409 }
239756 241410
239757 iOff = iStart; 241411 iOff = iStart;
239758 if( iNextOff>=iPgIdx ){ 241412
239759 int pgno = pSeg->iLeafPgno+1; 241413 /* Set variable bLastInDoclist to true if this entry happens to be
239760 fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); 241414 ** the last rowid in the doclist for its term. */
239761 iNextOff = iPgIdx; 241415 if( pSeg->bDel==0 ){
239762 }else{ 241416 if( iNextOff>=iPgIdx ){
239763 /* Set bLastInDoclist to true if the entry being removed is the last 241417 int pgno = pSeg->iLeafPgno+1;
239764 ** in its doclist. */ 241418 fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist);
239765 for(iIdx=0, iKeyOff=0; iIdx<nIdx; /* no-op */){ 241419 iNextOff = iPgIdx;
239766 u32 iVal = 0; 241420 }else{
239767 iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); 241421 /* Loop through the page-footer. If iNextOff (offset of the
239768 iKeyOff += iVal; 241422 ** entry following the one we are removing) is equal to the
239769 if( iKeyOff==iNextOff ){ 241423 ** offset of a key on this page, then the entry is the last
239770 bLastInDoclist = 1; 241424 ** in its doclist. */
241425 int iKeyOff = 0;
241426 for(iIdx=0; iIdx<nIdx; /* no-op */){
241427 u32 iVal = 0;
241428 iIdx += fts5GetVarint32(&aIdx[iIdx], iVal);
241429 iKeyOff += iVal;
241430 if( iKeyOff==iNextOff ){
241431 bLastInDoclist = 1;
241432 }
239771 } 241433 }
239772 } 241434 }
239773 }
239774 241435
239775 if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist||iNextOff==iPgIdx) ){ 241436 /* If this is (a) the first rowid on a page and (b) is not followed by
239776 fts5PutU16(&aPg[0], 0); 241437 ** another position list on the same page, set the "first-rowid" field
241438 ** of the header to 0. */
241439 if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist || iNextOff==iPgIdx) ){
241440 fts5PutU16(&aPg[0], 0);
241441 }
239777 } 241442 }
239778 241443
239779 if( bLastInDoclist==0 ){ 241444 if( pSeg->bDel ){
241445 iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta);
241446 aPg[iOff++] = 0x01;
241447 }else if( bLastInDoclist==0 ){
239780 if( iNextOff!=iPgIdx ){ 241448 if( iNextOff!=iPgIdx ){
241449 u64 iNextDelta = 0;
239781 iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); 241450 iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta);
239782 iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); 241451 iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta);
239783 } 241452 }
239784 }else if( 241453 }else if(
239785 iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno 241454 pSeg->iLeafPgno==pSeg->iTermLeafPgno
241455 && iStart==pSeg->iTermLeafOffset
239786 ){ 241456 ){
239787 /* The entry being removed was the only position list in its 241457 /* The entry being removed was the only position list in its
239788 ** doclist. Therefore the term needs to be removed as well. */ 241458 ** doclist. Therefore the term needs to be removed as well. */
239789 int iKey = 0; 241459 int iKey = 0;
239790 for(iIdx=0, iKeyOff=0; iIdx<nIdx; iKey++){ 241460 int iKeyOff = 0;
241461
241462 /* Set iKeyOff to the offset of the term that will be removed - the
241463 ** last offset in the footer that is not greater than iStart. */
241464 for(iIdx=0; iIdx<nIdx; iKey++){
239791 u32 iVal = 0; 241465 u32 iVal = 0;
239792 iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); 241466 iIdx += fts5GetVarint32(&aIdx[iIdx], iVal);
239793 if( (iKeyOff+iVal)>(u32)iStart ) break; 241467 if( (iKeyOff+iVal)>(u32)iStart ) break;
239794 iKeyOff += iVal; 241468 iKeyOff += iVal;
239795 } 241469 }
241470 assert_nc( iKey>=1 );
239796 241471
241472 /* Set iDelKeyOff to the value of the footer entry to remove from
241473 ** the page. */
239797 iDelKeyOff = iOff = iKeyOff; 241474 iDelKeyOff = iOff = iKeyOff;
241475
239798 if( iNextOff!=iPgIdx ){ 241476 if( iNextOff!=iPgIdx ){
241477 /* This is the only position-list associated with the term, and there
241478 ** is another term following it on this page. So the subsequent term
241479 ** needs to be moved to replace the term associated with the entry
241480 ** being removed. */
239799 int nPrefix = 0; 241481 int nPrefix = 0;
239800 int nSuffix = 0; 241482 int nSuffix = 0;
239801 int nPrefix2 = 0; 241483 int nPrefix2 = 0;
@@ -239874,6 +241556,15 @@ static void fts5DoSecureDelete(
239874 } 241556 }
239875 } 241557 }
239876 241558
241559 /* Assuming no error has occurred, this block does final edits to the
241560 ** leaf page before writing it back to disk. Input variables are:
241561 **
241562 ** nPg: Total initial size of leaf page.
241563 ** iPgIdx: Initial offset of page footer.
241564 **
241565 ** iOff: Offset to move data to
241566 ** iNextOff: Offset to move data from
241567 */
239877 if( p->rc==SQLITE_OK ){ 241568 if( p->rc==SQLITE_OK ){
239878 const int nMove = nPg - iNextOff; /* Number of bytes to move */ 241569 const int nMove = nPg - iNextOff; /* Number of bytes to move */
239879 int nShift = iNextOff - iOff; /* Distance to move them */ 241570 int nShift = iNextOff - iOff; /* Distance to move them */
@@ -240074,10 +241765,16 @@ static void fts5FlushOneHash(Fts5Index *p){
240074 fts5WriteFlushLeaf(p, &writer); 241765 fts5WriteFlushLeaf(p, &writer);
240075 } 241766 }
240076 }else{ 241767 }else{
240077 int bDummy; 241768 int bDel = 0;
240078 int nPos; 241769 int nPos = 0;
240079 int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); 241770 int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDel);
240080 nCopy += nPos; 241771 if( bDel && bSecureDelete ){
241772 fts5BufferAppendVarint(&p->rc, pBuf, nPos*2);
241773 iOff += nCopy;
241774 nCopy = nPos;
241775 }else{
241776 nCopy += nPos;
241777 }
240081 if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ 241778 if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){
240082 /* The entire poslist will fit on the current leaf. So copy 241779 /* The entire poslist will fit on the current leaf. So copy
240083 ** it in one go. */ 241780 ** it in one go. */
@@ -240115,7 +241812,6 @@ static void fts5FlushOneHash(Fts5Index *p){
240115 assert( pBuf->n<=pBuf->nSpace ); 241812 assert( pBuf->n<=pBuf->nSpace );
240116 if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); 241813 if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
240117 } 241814 }
240118 sqlite3Fts5HashClear(pHash);
240119 fts5WriteFinish(p, &writer, &pgnoLast); 241815 fts5WriteFinish(p, &writer, &pgnoLast);
240120 241816
240121 assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); 241817 assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 );
@@ -240148,7 +241844,6 @@ static void fts5FlushOneHash(Fts5Index *p){
240148 fts5IndexCrisismerge(p, &pStruct); 241844 fts5IndexCrisismerge(p, &pStruct);
240149 fts5StructureWrite(p, pStruct); 241845 fts5StructureWrite(p, pStruct);
240150 fts5StructureRelease(pStruct); 241846 fts5StructureRelease(pStruct);
240151 p->nContentlessDelete = 0;
240152} 241847}
240153 241848
240154/* 241849/*
@@ -240159,8 +241854,12 @@ static void fts5IndexFlush(Fts5Index *p){
240159 if( p->nPendingData || p->nContentlessDelete ){ 241854 if( p->nPendingData || p->nContentlessDelete ){
240160 assert( p->pHash ); 241855 assert( p->pHash );
240161 fts5FlushOneHash(p); 241856 fts5FlushOneHash(p);
240162 p->nPendingData = 0; 241857 if( p->rc==SQLITE_OK ){
240163 p->nPendingRow = 0; 241858 sqlite3Fts5HashClear(p->pHash);
241859 p->nPendingData = 0;
241860 p->nPendingRow = 0;
241861 p->nContentlessDelete = 0;
241862 }
240164 } 241863 }
240165} 241864}
240166 241865
@@ -242902,7 +244601,8 @@ static int sqlite3Fts5IndexInit(sqlite3 *db){
242902 0, /* xSavepoint */ 244601 0, /* xSavepoint */
242903 0, /* xRelease */ 244602 0, /* xRelease */
242904 0, /* xRollbackTo */ 244603 0, /* xRollbackTo */
242905 0 /* xShadowName */ 244604 0, /* xShadowName */
244605 0 /* xIntegrity */
242906 }; 244606 };
242907 rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); 244607 rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0);
242908 } 244608 }
@@ -243041,6 +244741,8 @@ struct Fts5FullTable {
243041 Fts5Storage *pStorage; /* Document store */ 244741 Fts5Storage *pStorage; /* Document store */
243042 Fts5Global *pGlobal; /* Global (connection wide) data */ 244742 Fts5Global *pGlobal; /* Global (connection wide) data */
243043 Fts5Cursor *pSortCsr; /* Sort data from this cursor */ 244743 Fts5Cursor *pSortCsr; /* Sort data from this cursor */
244744 int iSavepoint; /* Successful xSavepoint()+1 */
244745 int bInSavepoint;
243044#ifdef SQLITE_DEBUG 244746#ifdef SQLITE_DEBUG
243045 struct Fts5TransactionState ts; 244747 struct Fts5TransactionState ts;
243046#endif 244748#endif
@@ -243329,6 +245031,13 @@ static int fts5InitVtab(
243329 pConfig->pzErrmsg = 0; 245031 pConfig->pzErrmsg = 0;
243330 } 245032 }
243331 245033
245034 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
245035 rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1);
245036 }
245037 if( rc==SQLITE_OK ){
245038 rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
245039 }
245040
243332 if( rc!=SQLITE_OK ){ 245041 if( rc!=SQLITE_OK ){
243333 fts5FreeVtab(pTab); 245042 fts5FreeVtab(pTab);
243334 pTab = 0; 245043 pTab = 0;
@@ -244278,9 +245987,8 @@ static int fts5FilterMethod(
244278 pCsr->pExpr = pTab->pSortCsr->pExpr; 245987 pCsr->pExpr = pTab->pSortCsr->pExpr;
244279 rc = fts5CursorFirst(pTab, pCsr, bDesc); 245988 rc = fts5CursorFirst(pTab, pCsr, bDesc);
244280 }else if( pCsr->pExpr ){ 245989 }else if( pCsr->pExpr ){
244281 if( rc==SQLITE_OK ){ 245990 assert( rc==SQLITE_OK );
244282 rc = fts5CursorParseRank(pConfig, pCsr, pRank); 245991 rc = fts5CursorParseRank(pConfig, pCsr, pRank);
244283 }
244284 if( rc==SQLITE_OK ){ 245992 if( rc==SQLITE_OK ){
244285 if( bOrderByRank ){ 245993 if( bOrderByRank ){
244286 pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; 245994 pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;
@@ -244451,6 +246159,7 @@ static int fts5SpecialInsert(
244451 Fts5Config *pConfig = pTab->p.pConfig; 246159 Fts5Config *pConfig = pTab->p.pConfig;
244452 int rc = SQLITE_OK; 246160 int rc = SQLITE_OK;
244453 int bError = 0; 246161 int bError = 0;
246162 int bLoadConfig = 0;
244454 246163
244455 if( 0==sqlite3_stricmp("delete-all", zCmd) ){ 246164 if( 0==sqlite3_stricmp("delete-all", zCmd) ){
244456 if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ 246165 if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
@@ -244462,6 +246171,7 @@ static int fts5SpecialInsert(
244462 }else{ 246171 }else{
244463 rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); 246172 rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);
244464 } 246173 }
246174 bLoadConfig = 1;
244465 }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ 246175 }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){
244466 if( pConfig->eContent==FTS5_CONTENT_NONE ){ 246176 if( pConfig->eContent==FTS5_CONTENT_NONE ){
244467 fts5SetVtabError(pTab, 246177 fts5SetVtabError(pTab,
@@ -244471,6 +246181,7 @@ static int fts5SpecialInsert(
244471 }else{ 246181 }else{
244472 rc = sqlite3Fts5StorageRebuild(pTab->pStorage); 246182 rc = sqlite3Fts5StorageRebuild(pTab->pStorage);
244473 } 246183 }
246184 bLoadConfig = 1;
244474 }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ 246185 }else if( 0==sqlite3_stricmp("optimize", zCmd) ){
244475 rc = sqlite3Fts5StorageOptimize(pTab->pStorage); 246186 rc = sqlite3Fts5StorageOptimize(pTab->pStorage);
244476 }else if( 0==sqlite3_stricmp("merge", zCmd) ){ 246187 }else if( 0==sqlite3_stricmp("merge", zCmd) ){
@@ -244483,6 +246194,8 @@ static int fts5SpecialInsert(
244483 }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ 246194 }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
244484 pConfig->bPrefixIndex = sqlite3_value_int(pVal); 246195 pConfig->bPrefixIndex = sqlite3_value_int(pVal);
244485#endif 246196#endif
246197 }else if( 0==sqlite3_stricmp("flush", zCmd) ){
246198 rc = sqlite3Fts5FlushToDisk(&pTab->p);
244486 }else{ 246199 }else{
244487 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); 246200 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
244488 if( rc==SQLITE_OK ){ 246201 if( rc==SQLITE_OK ){
@@ -244496,6 +246209,12 @@ static int fts5SpecialInsert(
244496 } 246209 }
244497 } 246210 }
244498 } 246211 }
246212
246213 if( rc==SQLITE_OK && bLoadConfig ){
246214 pTab->p.pConfig->iCookie--;
246215 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
246216 }
246217
244499 return rc; 246218 return rc;
244500} 246219}
244501 246220
@@ -244614,7 +246333,7 @@ static int fts5UpdateMethod(
244614 assert( nArg!=1 || eType0==SQLITE_INTEGER ); 246333 assert( nArg!=1 || eType0==SQLITE_INTEGER );
244615 246334
244616 /* Filter out attempts to run UPDATE or DELETE on contentless tables. 246335 /* Filter out attempts to run UPDATE or DELETE on contentless tables.
244617 ** This is not suported. Except - DELETE is supported if the CREATE 246336 ** This is not suported. Except - they are both supported if the CREATE
244618 ** VIRTUAL TABLE statement contained "contentless_delete=1". */ 246337 ** VIRTUAL TABLE statement contained "contentless_delete=1". */
244619 if( eType0==SQLITE_INTEGER 246338 if( eType0==SQLITE_INTEGER
244620 && pConfig->eContent==FTS5_CONTENT_NONE 246339 && pConfig->eContent==FTS5_CONTENT_NONE
@@ -244643,7 +246362,8 @@ static int fts5UpdateMethod(
244643 } 246362 }
244644 246363
244645 else if( eType0!=SQLITE_INTEGER ){ 246364 else if( eType0!=SQLITE_INTEGER ){
244646 /* If this is a REPLACE, first remove the current entry (if any) */ 246365 /* An INSERT statement. If the conflict-mode is REPLACE, first remove
246366 ** the current entry (if any). */
244647 if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ 246367 if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
244648 i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ 246368 i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
244649 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); 246369 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
@@ -245517,8 +247237,12 @@ static int fts5RenameMethod(
245517 sqlite3_vtab *pVtab, /* Virtual table handle */ 247237 sqlite3_vtab *pVtab, /* Virtual table handle */
245518 const char *zName /* New name of table */ 247238 const char *zName /* New name of table */
245519){ 247239){
247240 int rc;
245520 Fts5FullTable *pTab = (Fts5FullTable*)pVtab; 247241 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
245521 return sqlite3Fts5StorageRename(pTab->pStorage, zName); 247242 pTab->bInSavepoint = 1;
247243 rc = sqlite3Fts5StorageRename(pTab->pStorage, zName);
247244 pTab->bInSavepoint = 0;
247245 return rc;
245522} 247246}
245523 247247
245524static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ 247248static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
@@ -245532,9 +247256,29 @@ static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
245532** Flush the contents of the pending-terms table to disk. 247256** Flush the contents of the pending-terms table to disk.
245533*/ 247257*/
245534static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ 247258static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
245535 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ 247259 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
245536 fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint); 247260 int rc = SQLITE_OK;
245537 return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); 247261 char *zSql = 0;
247262 fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
247263
247264 if( pTab->bInSavepoint==0 ){
247265 zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')",
247266 pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName
247267 );
247268 if( zSql ){
247269 pTab->bInSavepoint = 1;
247270 rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0);
247271 pTab->bInSavepoint = 0;
247272 sqlite3_free(zSql);
247273 }else{
247274 rc = SQLITE_NOMEM;
247275 }
247276 if( rc==SQLITE_OK ){
247277 pTab->iSavepoint = iSavepoint+1;
247278 }
247279 }
247280
247281 return rc;
245538} 247282}
245539 247283
245540/* 247284/*
@@ -245543,9 +247287,16 @@ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
245543** This is a no-op. 247287** This is a no-op.
245544*/ 247288*/
245545static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ 247289static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
245546 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ 247290 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
245547 fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint); 247291 int rc = SQLITE_OK;
245548 return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); 247292 fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
247293 if( (iSavepoint+1)<pTab->iSavepoint ){
247294 rc = sqlite3Fts5FlushToDisk(&pTab->p);
247295 if( rc==SQLITE_OK ){
247296 pTab->iSavepoint = iSavepoint;
247297 }
247298 }
247299 return rc;
245549} 247300}
245550 247301
245551/* 247302/*
@@ -245555,11 +247306,14 @@ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
245555*/ 247306*/
245556static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ 247307static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
245557 Fts5FullTable *pTab = (Fts5FullTable*)pVtab; 247308 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
245558 UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ 247309 int rc = SQLITE_OK;
245559 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); 247310 fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
245560 fts5TripCursors(pTab); 247311 fts5TripCursors(pTab);
245561 pTab->p.pConfig->pgsz = 0; 247312 pTab->p.pConfig->pgsz = 0;
245562 return sqlite3Fts5StorageRollback(pTab->pStorage); 247313 if( (iSavepoint+1)<=pTab->iSavepoint ){
247314 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
247315 }
247316 return rc;
245563} 247317}
245564 247318
245565/* 247319/*
@@ -245761,7 +247515,7 @@ static void fts5SourceIdFunc(
245761){ 247515){
245762 assert( nArg==0 ); 247516 assert( nArg==0 );
245763 UNUSED_PARAM2(nArg, apUnused); 247517 UNUSED_PARAM2(nArg, apUnused);
245764 sqlite3_result_text(pCtx, "fts5: 2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790", -1, SQLITE_TRANSIENT); 247518 sqlite3_result_text(pCtx, "fts5: 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301", -1, SQLITE_TRANSIENT);
245765} 247519}
245766 247520
245767/* 247521/*
@@ -245779,9 +247533,46 @@ static int fts5ShadowName(const char *zName){
245779 return 0; 247533 return 0;
245780} 247534}
245781 247535
247536/*
247537** Run an integrity check on the FTS5 data structures. Return a string
247538** if anything is found amiss. Return a NULL pointer if everything is
247539** OK.
247540*/
247541static int fts5Integrity(
247542 sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */
247543 const char *zSchema, /* Name of schema in which this table lives */
247544 const char *zTabname, /* Name of the table itself */
247545 int isQuick, /* True if this is a quick-check */
247546 char **pzErr /* Write error message here */
247547){
247548 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
247549 Fts5Config *pConfig = pTab->p.pConfig;
247550 char *zSql;
247551 char *zErr = 0;
247552 int rc;
247553 assert( pzErr!=0 && *pzErr==0 );
247554 UNUSED_PARAM(isQuick);
247555 zSql = sqlite3_mprintf(
247556 "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');",
247557 zSchema, zTabname, pConfig->zName);
247558 if( zSql==0 ) return SQLITE_NOMEM;
247559 rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr);
247560 sqlite3_free(zSql);
247561 if( (rc&0xff)==SQLITE_CORRUPT ){
247562 *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
247563 zSchema, zTabname);
247564 }else if( rc!=SQLITE_OK ){
247565 *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
247566 " FTS5 table %s.%s: %s",
247567 zSchema, zTabname, zErr);
247568 }
247569 sqlite3_free(zErr);
247570 return SQLITE_OK;
247571}
247572
245782static int fts5Init(sqlite3 *db){ 247573static int fts5Init(sqlite3 *db){
245783 static const sqlite3_module fts5Mod = { 247574 static const sqlite3_module fts5Mod = {
245784 /* iVersion */ 3, 247575 /* iVersion */ 4,
245785 /* xCreate */ fts5CreateMethod, 247576 /* xCreate */ fts5CreateMethod,
245786 /* xConnect */ fts5ConnectMethod, 247577 /* xConnect */ fts5ConnectMethod,
245787 /* xBestIndex */ fts5BestIndexMethod, 247578 /* xBestIndex */ fts5BestIndexMethod,
@@ -245804,7 +247595,8 @@ static int fts5Init(sqlite3 *db){
245804 /* xSavepoint */ fts5SavepointMethod, 247595 /* xSavepoint */ fts5SavepointMethod,
245805 /* xRelease */ fts5ReleaseMethod, 247596 /* xRelease */ fts5ReleaseMethod,
245806 /* xRollbackTo */ fts5RollbackToMethod, 247597 /* xRollbackTo */ fts5RollbackToMethod,
245807 /* xShadowName */ fts5ShadowName 247598 /* xShadowName */ fts5ShadowName,
247599 /* xIntegrity */ fts5Integrity
245808 }; 247600 };
245809 247601
245810 int rc; 247602 int rc;
@@ -247081,7 +248873,9 @@ static int sqlite3Fts5StorageSync(Fts5Storage *p){
247081 i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); 248873 i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);
247082 if( p->bTotalsValid ){ 248874 if( p->bTotalsValid ){
247083 rc = fts5StorageSaveTotals(p); 248875 rc = fts5StorageSaveTotals(p);
247084 p->bTotalsValid = 0; 248876 if( rc==SQLITE_OK ){
248877 p->bTotalsValid = 0;
248878 }
247085 } 248879 }
247086 if( rc==SQLITE_OK ){ 248880 if( rc==SQLITE_OK ){
247087 rc = sqlite3Fts5IndexSync(p->pIndex); 248881 rc = sqlite3Fts5IndexSync(p->pIndex);
@@ -250449,7 +252243,8 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
250449 /* xSavepoint */ 0, 252243 /* xSavepoint */ 0,
250450 /* xRelease */ 0, 252244 /* xRelease */ 0,
250451 /* xRollbackTo */ 0, 252245 /* xRollbackTo */ 0,
250452 /* xShadowName */ 0 252246 /* xShadowName */ 0,
252247 /* xIntegrity */ 0
250453 }; 252248 };
250454 void *p = (void*)pGlobal; 252249 void *p = (void*)pGlobal;
250455 252250
@@ -250778,6 +252573,7 @@ static sqlite3_module stmtModule = {
250778 0, /* xRelease */ 252573 0, /* xRelease */
250779 0, /* xRollbackTo */ 252574 0, /* xRollbackTo */
250780 0, /* xShadowName */ 252575 0, /* xShadowName */
252576 0 /* xIntegrity */
250781}; 252577};
250782 252578
250783#endif /* SQLITE_OMIT_VIRTUALTABLE */ 252579#endif /* SQLITE_OMIT_VIRTUALTABLE */
diff --git a/c/sqlite3.h b/c/sqlite3.h
index 0376113..d4f1c81 100644
--- a/c/sqlite3.h
+++ b/c/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
146** [sqlite3_libversion_number()], [sqlite3_sourceid()], 146** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147** [sqlite_version()] and [sqlite_source_id()]. 147** [sqlite_version()] and [sqlite_source_id()].
148*/ 148*/
149#define SQLITE_VERSION "3.43.2" 149#define SQLITE_VERSION "3.44.0"
150#define SQLITE_VERSION_NUMBER 3043002 150#define SQLITE_VERSION_NUMBER 3044000
151#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" 151#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301"
152 152
153/* 153/*
154** CAPI3REF: Run-Time Library Version Numbers 154** CAPI3REF: Run-Time Library Version Numbers
@@ -2127,7 +2127,7 @@ struct sqlite3_mem_methods {
2127** is stored in each sorted record and the required column values loaded 2127** is stored in each sorted record and the required column values loaded
2128** from the database as records are returned in sorted order. The default 2128** from the database as records are returned in sorted order. The default
2129** value for this option is to never use this optimization. Specifying a 2129** value for this option is to never use this optimization. Specifying a
2130** negative value for this option restores the default behaviour. 2130** negative value for this option restores the default behavior.
2131** This option is only available if SQLite is compiled with the 2131** This option is only available if SQLite is compiled with the
2132** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. 2132** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
2133** 2133**
@@ -2302,7 +2302,7 @@ struct sqlite3_mem_methods {
2302** database handle, SQLite checks if this will mean that there are now no 2302** database handle, SQLite checks if this will mean that there are now no
2303** connections at all to the database. If so, it performs a checkpoint 2303** connections at all to the database. If so, it performs a checkpoint
2304** operation before closing the connection. This option may be used to 2304** operation before closing the connection. This option may be used to
2305** override this behaviour. The first parameter passed to this operation 2305** override this behavior. The first parameter passed to this operation
2306** is an integer - positive to disable checkpoints-on-close, or zero (the 2306** is an integer - positive to disable checkpoints-on-close, or zero (the
2307** default) to enable them, and negative to leave the setting unchanged. 2307** default) to enable them, and negative to leave the setting unchanged.
2308** The second parameter is a pointer to an integer 2308** The second parameter is a pointer to an integer
@@ -3955,6 +3955,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
3955** 3955**
3956** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 3956** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3957** text that describes the error, as either UTF-8 or UTF-16 respectively. 3957** text that describes the error, as either UTF-8 or UTF-16 respectively.
3958** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
3958** ^(Memory to hold the error message string is managed internally. 3959** ^(Memory to hold the error message string is managed internally.
3959** The application does not need to worry about freeing the result. 3960** The application does not need to worry about freeing the result.
3960** However, the error string might be overwritten or deallocated by 3961** However, the error string might be overwritten or deallocated by
@@ -5325,6 +5326,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
5325*/ 5326*/
5326SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); 5327SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5327 5328
5329
5328/* 5330/*
5329** CAPI3REF: Create Or Redefine SQL Functions 5331** CAPI3REF: Create Or Redefine SQL Functions
5330** KEYWORDS: {function creation routines} 5332** KEYWORDS: {function creation routines}
@@ -5879,32 +5881,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5879** METHOD: sqlite3_context 5881** METHOD: sqlite3_context
5880** 5882**
5881** These functions may be used by (non-aggregate) SQL functions to 5883** These functions may be used by (non-aggregate) SQL functions to
5882** associate metadata with argument values. If the same value is passed to 5884** associate auxiliary data with argument values. If the same argument
5883** multiple invocations of the same SQL function during query execution, under 5885** value is passed to multiple invocations of the same SQL function during
5884** some circumstances the associated metadata may be preserved. An example 5886** query execution, under some circumstances the associated auxiliary data
5885** of where this might be useful is in a regular-expression matching 5887** might be preserved. An example of where this might be useful is in a
5886** function. The compiled version of the regular expression can be stored as 5888** regular-expression matching function. The compiled version of the regular
5887** metadata associated with the pattern string. 5889** expression can be stored as auxiliary data associated with the pattern string.
5888** Then as long as the pattern string remains the same, 5890** Then as long as the pattern string remains the same,
5889** the compiled regular expression can be reused on multiple 5891** the compiled regular expression can be reused on multiple
5890** invocations of the same function. 5892** invocations of the same function.
5891** 5893**
5892** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata 5894** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
5893** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument 5895** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
5894** value to the application-defined function. ^N is zero for the left-most 5896** value to the application-defined function. ^N is zero for the left-most
5895** function argument. ^If there is no metadata 5897** function argument. ^If there is no auxiliary data
5896** associated with the function argument, the sqlite3_get_auxdata(C,N) interface 5898** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
5897** returns a NULL pointer. 5899** returns a NULL pointer.
5898** 5900**
5899** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th 5901** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
5900** argument of the application-defined function. ^Subsequent 5902** N-th argument of the application-defined function. ^Subsequent
5901** calls to sqlite3_get_auxdata(C,N) return P from the most recent 5903** calls to sqlite3_get_auxdata(C,N) return P from the most recent
5902** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or 5904** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
5903** NULL if the metadata has been discarded. 5905** NULL if the auxiliary data has been discarded.
5904** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, 5906** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
5905** SQLite will invoke the destructor function X with parameter P exactly 5907** SQLite will invoke the destructor function X with parameter P exactly
5906** once, when the metadata is discarded. 5908** once, when the auxiliary data is discarded.
5907** SQLite is free to discard the metadata at any time, including: <ul> 5909** SQLite is free to discard the auxiliary data at any time, including: <ul>
5908** <li> ^(when the corresponding function parameter changes)^, or 5910** <li> ^(when the corresponding function parameter changes)^, or
5909** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the 5911** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
5910** SQL statement)^, or 5912** SQL statement)^, or
@@ -5920,7 +5922,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5920** function implementation should not make any use of P after 5922** function implementation should not make any use of P after
5921** sqlite3_set_auxdata() has been called. 5923** sqlite3_set_auxdata() has been called.
5922** 5924**
5923** ^(In practice, metadata is preserved between function calls for 5925** ^(In practice, auxiliary data is preserved between function calls for
5924** function parameters that are compile-time constants, including literal 5926** function parameters that are compile-time constants, including literal
5925** values and [parameters] and expressions composed from the same.)^ 5927** values and [parameters] and expressions composed from the same.)^
5926** 5928**
@@ -5930,10 +5932,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5930** 5932**
5931** These routines must be called from the same thread in which 5933** These routines must be called from the same thread in which
5932** the SQL function is running. 5934** the SQL function is running.
5935**
5936** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()].
5933*/ 5937*/
5934SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); 5938SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
5935SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); 5939SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
5936 5940
5941/*
5942** CAPI3REF: Database Connection Client Data
5943** METHOD: sqlite3
5944**
5945** These functions are used to associate one or more named pointers
5946** with a [database connection].
5947** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P
5948** to be attached to [database connection] D using name N. Subsequent
5949** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P
5950** or a NULL pointer if there were no prior calls to
5951** sqlite3_set_clientdata() with the same values of D and N.
5952** Names are compared using strcmp() and are thus case sensitive.
5953**
5954** If P and X are both non-NULL, then the destructor X is invoked with
5955** argument P on the first of the following occurrences:
5956** <ul>
5957** <li> An out-of-memory error occurs during the call to
5958** sqlite3_set_clientdata() which attempts to register pointer P.
5959** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made
5960** with the same D and N parameters.
5961** <li> The database connection closes. SQLite does not make any guarantees
5962** about the order in which destructors are called, only that all
5963** destructors will be called exactly once at some point during the
5964** database connection closing process.
5965** </ul>
5966**
5967** SQLite does not do anything with client data other than invoke
5968** destructors on the client data at the appropriate time. The intended
5969** use for client data is to provide a mechanism for wrapper libraries
5970** to store additional information about an SQLite database connection.
5971**
5972** There is no limit (other than available memory) on the number of different
5973** client data pointers (with different names) that can be attached to a
5974** single database connection. However, the implementation is optimized
5975** for the case of having only one or two different client data names.
5976** Applications and wrapper libraries are discouraged from using more than
5977** one client data name each.
5978**
5979** There is no way to enumerate the client data pointers
5980** associated with a database connection. The N parameter can be thought
5981** of as a secret key such that only code that knows the secret key is able
5982** to access the associated data.
5983**
5984** Security Warning: These interfaces should not be exposed in scripting
5985** languages or in other circumstances where it might be possible for an
5986** an attacker to invoke them. Any agent that can invoke these interfaces
5987** can probably also take control of the process.
5988**
5989** Database connection client data is only available for SQLite
5990** version 3.44.0 ([dateof:3.44.0]) and later.
5991**
5992** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()].
5993*/
5994SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*);
5995SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*));
5937 5996
5938/* 5997/*
5939** CAPI3REF: Constants Defining Special Destructor Behavior 5998** CAPI3REF: Constants Defining Special Destructor Behavior
@@ -6566,7 +6625,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
6566SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); 6625SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
6567 6626
6568/* 6627/*
6569** CAPI3REF: Allowed return values from [sqlite3_txn_state()] 6628** CAPI3REF: Allowed return values from sqlite3_txn_state()
6570** KEYWORDS: {transaction state} 6629** KEYWORDS: {transaction state}
6571** 6630**
6572** These constants define the current transaction state of a database file. 6631** These constants define the current transaction state of a database file.
@@ -6698,7 +6757,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6698** ^Each call to the sqlite3_autovacuum_pages() interface overrides all 6757** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
6699** previous invocations for that database connection. ^If the callback 6758** previous invocations for that database connection. ^If the callback
6700** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, 6759** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
6701** then the autovacuum steps callback is cancelled. The return value 6760** then the autovacuum steps callback is canceled. The return value
6702** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might 6761** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
6703** be some other error code if something goes wrong. The current 6762** be some other error code if something goes wrong. The current
6704** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other 6763** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
@@ -7217,6 +7276,10 @@ struct sqlite3_module {
7217 /* The methods above are in versions 1 and 2 of the sqlite_module object. 7276 /* The methods above are in versions 1 and 2 of the sqlite_module object.
7218 ** Those below are for version 3 and greater. */ 7277 ** Those below are for version 3 and greater. */
7219 int (*xShadowName)(const char*); 7278 int (*xShadowName)(const char*);
7279 /* The methods above are in versions 1 through 3 of the sqlite_module object.
7280 ** Those below are for version 4 and greater. */
7281 int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema,
7282 const char *zTabName, int mFlags, char **pzErr);
7220}; 7283};
7221 7284
7222/* 7285/*
@@ -7704,7 +7767,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
7704** code is returned and the transaction rolled back. 7767** code is returned and the transaction rolled back.
7705** 7768**
7706** Calling this function with an argument that is not a NULL pointer or an 7769** Calling this function with an argument that is not a NULL pointer or an
7707** open blob handle results in undefined behaviour. ^Calling this routine 7770** open blob handle results in undefined behavior. ^Calling this routine
7708** with a null pointer (such as would be returned by a failed call to 7771** with a null pointer (such as would be returned by a failed call to
7709** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function 7772** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
7710** is passed a valid open blob handle, the values returned by the 7773** is passed a valid open blob handle, the values returned by the
@@ -8184,6 +8247,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8184#define SQLITE_TESTCTRL_PRNG_SAVE 5 8247#define SQLITE_TESTCTRL_PRNG_SAVE 5
8185#define SQLITE_TESTCTRL_PRNG_RESTORE 6 8248#define SQLITE_TESTCTRL_PRNG_RESTORE 6
8186#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ 8249#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
8250#define SQLITE_TESTCTRL_FK_NO_ACTION 7
8187#define SQLITE_TESTCTRL_BITVEC_TEST 8 8251#define SQLITE_TESTCTRL_BITVEC_TEST 8
8188#define SQLITE_TESTCTRL_FAULT_INSTALL 9 8252#define SQLITE_TESTCTRL_FAULT_INSTALL 9
8189#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 8253#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
@@ -9245,8 +9309,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
9245** blocked connection already has a registered unlock-notify callback, 9309** blocked connection already has a registered unlock-notify callback,
9246** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is 9310** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
9247** called with a NULL pointer as its second argument, then any existing 9311** called with a NULL pointer as its second argument, then any existing
9248** unlock-notify callback is cancelled. ^The blocked connections 9312** unlock-notify callback is canceled. ^The blocked connections
9249** unlock-notify callback may also be cancelled by closing the blocked 9313** unlock-notify callback may also be canceled by closing the blocked
9250** connection using [sqlite3_close()]. 9314** connection using [sqlite3_close()].
9251** 9315**
9252** The unlock-notify callback is not reentrant. If an application invokes 9316** The unlock-notify callback is not reentrant. If an application invokes
@@ -10549,6 +10613,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
10549** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy 10613** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
10550** of the database exists. 10614** of the database exists.
10551** 10615**
10616** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set,
10617** the returned buffer content will remain accessible and unchanged
10618** until either the next write operation on the connection or when
10619** the connection is closed, and applications must not modify the
10620** buffer. If the bit had been clear, the returned buffer will not
10621** be accessed by SQLite after the call.
10622**
10552** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the 10623** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
10553** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory 10624** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
10554** allocation error occurs. 10625** allocation error occurs.
@@ -10597,6 +10668,9 @@ SQLITE_API unsigned char *sqlite3_serialize(
10597** SQLite will try to increase the buffer size using sqlite3_realloc64() 10668** SQLite will try to increase the buffer size using sqlite3_realloc64()
10598** if writes on the database cause it to grow larger than M bytes. 10669** if writes on the database cause it to grow larger than M bytes.
10599** 10670**
10671** Applications must not modify the buffer P or invalidate it before
10672** the database connection D is closed.
10673**
10600** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the 10674** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
10601** database is currently in a read transaction or is involved in a backup 10675** database is currently in a read transaction or is involved in a backup
10602** operation. 10676** operation.
@@ -10605,6 +10679,13 @@ SQLITE_API unsigned char *sqlite3_serialize(
10605** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the 10679** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10606** function returns SQLITE_ERROR. 10680** function returns SQLITE_ERROR.
10607** 10681**
10682** The deserialized database should not be in [WAL mode]. If the database
10683** is in WAL mode, then any attempt to use the database file will result
10684** in an [SQLITE_CANTOPEN] error. The application can set the
10685** [file format version numbers] (bytes 18 and 19) of the input database P
10686** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the
10687** database file into rollback mode and work around this limitation.
10688**
10608** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the 10689** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10609** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then 10690** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10610** [sqlite3_free()] is invoked on argument P prior to returning. 10691** [sqlite3_free()] is invoked on argument P prior to returning.
@@ -11678,6 +11759,18 @@ SQLITE_API int sqlite3changeset_concat(
11678 11759
11679 11760
11680/* 11761/*
11762** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
11763*/
11764SQLITE_API int sqlite3changeset_upgrade(
11765 sqlite3 *db,
11766 const char *zDb,
11767 int nIn, const void *pIn, /* Input changeset */
11768 int *pnOut, void **ppOut /* OUT: Inverse of input */
11769);
11770
11771
11772
11773/*
11681** CAPI3REF: Changegroup Handle 11774** CAPI3REF: Changegroup Handle
11682** 11775**
11683** A changegroup is an object used to combine two or more 11776** A changegroup is an object used to combine two or more
@@ -11724,6 +11817,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
11724SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); 11817SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
11725 11818
11726/* 11819/*
11820** CAPI3REF: Add a Schema to a Changegroup
11821** METHOD: sqlite3_changegroup_schema
11822**
11823** This method may be used to optionally enforce the rule that the changesets
11824** added to the changegroup handle must match the schema of database zDb
11825** ("main", "temp", or the name of an attached database). If
11826** sqlite3changegroup_add() is called to add a changeset that is not compatible
11827** with the configured schema, SQLITE_SCHEMA is returned and the changegroup
11828** object is left in an undefined state.
11829**
11830** A changeset schema is considered compatible with the database schema in
11831** the same way as for sqlite3changeset_apply(). Specifically, for each
11832** table in the changeset, there exists a database table with:
11833**
11834** <ul>
11835** <li> The name identified by the changeset, and
11836** <li> at least as many columns as recorded in the changeset, and
11837** <li> the primary key columns in the same position as recorded in
11838** the changeset.
11839** </ul>
11840**
11841** The output of the changegroup object always has the same schema as the
11842** database nominated using this function. In cases where changesets passed
11843** to sqlite3changegroup_add() have fewer columns than the corresponding table
11844** in the database schema, these are filled in using the default column
11845** values from the database schema. This makes it possible to combined
11846** changesets that have different numbers of columns for a single table
11847** within a changegroup, provided that they are otherwise compatible.
11848*/
11849SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb);
11850
11851/*
11727** CAPI3REF: Add A Changeset To A Changegroup 11852** CAPI3REF: Add A Changeset To A Changegroup
11728** METHOD: sqlite3_changegroup 11853** METHOD: sqlite3_changegroup
11729** 11854**
@@ -11791,13 +11916,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
11791** If the new changeset contains changes to a table that is already present 11916** If the new changeset contains changes to a table that is already present
11792** in the changegroup, then the number of columns and the position of the 11917** in the changegroup, then the number of columns and the position of the
11793** primary key columns for the table must be consistent. If this is not the 11918** primary key columns for the table must be consistent. If this is not the
11794** case, this function fails with SQLITE_SCHEMA. If the input changeset 11919** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup
11795** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is 11920** object has been configured with a database schema using the
11796** returned. Or, if an out-of-memory condition occurs during processing, this 11921** sqlite3changegroup_schema() API, then it is possible to combine changesets
11797** function returns SQLITE_NOMEM. In all cases, if an error occurs the state 11922** with different numbers of columns for a single table, provided that
11798** of the final contents of the changegroup is undefined. 11923** they are otherwise compatible.
11799** 11924**
11800** If no error occurs, SQLITE_OK is returned. 11925** If the input changeset appears to be corrupt and the corruption is
11926** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition
11927** occurs during processing, this function returns SQLITE_NOMEM.
11928**
11929** In all cases, if an error occurs the state of the final contents of the
11930** changegroup is undefined. If no error occurs, SQLITE_OK is returned.
11801*/ 11931*/
11802SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); 11932SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
11803 11933
@@ -12062,10 +12192,17 @@ SQLITE_API int sqlite3changeset_apply_v2(
12062** <li>an insert change if all fields of the conflicting row match 12192** <li>an insert change if all fields of the conflicting row match
12063** the row being inserted. 12193** the row being inserted.
12064** </ul> 12194** </ul>
12195**
12196** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
12197** If this flag it set, then all foreign key constraints in the target
12198** database behave as if they were declared with "ON UPDATE NO ACTION ON
12199** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12200** or SET DEFAULT.
12065*/ 12201*/
12066#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 12202#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12067#define SQLITE_CHANGESETAPPLY_INVERT 0x0002 12203#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12068#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 12204#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12205#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12069 12206
12070/* 12207/*
12071** CAPI3REF: Constants Passed To The Conflict Handler 12208** CAPI3REF: Constants Passed To The Conflict Handler
diff --git a/c/sqlite3ext.h b/c/sqlite3ext.h
index 7116380..ae0949b 100644
--- a/c/sqlite3ext.h
+++ b/c/sqlite3ext.h
@@ -363,6 +363,9 @@ struct sqlite3_api_routines {
363 int (*is_interrupted)(sqlite3*); 363 int (*is_interrupted)(sqlite3*);
364 /* Version 3.43.0 and later */ 364 /* Version 3.43.0 and later */
365 int (*stmt_explain)(sqlite3_stmt*,int); 365 int (*stmt_explain)(sqlite3_stmt*,int);
366 /* Version 3.44.0 and later */
367 void *(*get_clientdata)(sqlite3*,const char*);
368 int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
366}; 369};
367 370
368/* 371/*
@@ -693,6 +696,9 @@ typedef int (*sqlite3_loadext_entry)(
693#define sqlite3_is_interrupted sqlite3_api->is_interrupted 696#define sqlite3_is_interrupted sqlite3_api->is_interrupted
694/* Version 3.43.0 and later */ 697/* Version 3.43.0 and later */
695#define sqlite3_stmt_explain sqlite3_api->stmt_explain 698#define sqlite3_stmt_explain sqlite3_api->stmt_explain
699/* Version 3.44.0 and later */
700#define sqlite3_get_clientdata sqlite3_api->get_clientdata
701#define sqlite3_set_clientdata sqlite3_api->set_clientdata
696#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ 702#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
697 703
698#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) 704#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)