Fossil SCM

Update the built-in SQLite to the latest from upstream.

drh 2017-06-29 18:54 trunk
Commit ee71f347eece2522c83c474edc591543df75a8e9ae85ddce5797955890fc42b3
3 files changed +17 +1474 -904 +129 -41
+17
--- src/shell.c
+++ src/shell.c
@@ -3820,10 +3820,11 @@
38203820
FILE *in; /* Read the CSV text from this input stream */
38213821
char *z; /* Accumulated text for a field */
38223822
int n; /* Number of bytes in z */
38233823
int nAlloc; /* Space allocated for z[] */
38243824
int nLine; /* Current line number */
3825
+ int bNotFirst; /* True if one or more bytes already read */
38253826
int cTerm; /* Character that terminated the most recent field */
38263827
int cColSep; /* The column separator character. (Usually ",") */
38273828
int cRowSep; /* The row separator character. (Usually "\n") */
38283829
};
38293830
@@ -3899,10 +3900,25 @@
38993900
import_append_char(p, c);
39003901
ppc = pc;
39013902
pc = c;
39023903
}
39033904
}else{
3905
+ /* If this is the first field being parsed and it begins with the
3906
+ ** UTF-8 BOM (0xEF BB BF) then skip the BOM */
3907
+ if( (c&0xff)==0xef && p->bNotFirst==0 ){
3908
+ import_append_char(p, c);
3909
+ c = fgetc(p->in);
3910
+ if( (c&0xff)==0xbb ){
3911
+ import_append_char(p, c);
3912
+ c = fgetc(p->in);
3913
+ if( (c&0xff)==0xbf ){
3914
+ p->bNotFirst = 1;
3915
+ p->n = 0;
3916
+ return csv_read_one_field(p);
3917
+ }
3918
+ }
3919
+ }
39043920
while( c!=EOF && c!=cSep && c!=rSep ){
39053921
import_append_char(p, c);
39063922
c = fgetc(p->in);
39073923
}
39083924
if( c==rSep ){
@@ -3910,10 +3926,11 @@
39103926
if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
39113927
}
39123928
p->cTerm = c;
39133929
}
39143930
if( p->z ) p->z[p->n] = 0;
3931
+ p->bNotFirst = 1;
39153932
return p->z;
39163933
}
39173934
39183935
/* Read a single field of ASCII delimited text.
39193936
**
39203937
--- src/shell.c
+++ src/shell.c
@@ -3820,10 +3820,11 @@
3820 FILE *in; /* Read the CSV text from this input stream */
3821 char *z; /* Accumulated text for a field */
3822 int n; /* Number of bytes in z */
3823 int nAlloc; /* Space allocated for z[] */
3824 int nLine; /* Current line number */
 
3825 int cTerm; /* Character that terminated the most recent field */
3826 int cColSep; /* The column separator character. (Usually ",") */
3827 int cRowSep; /* The row separator character. (Usually "\n") */
3828 };
3829
@@ -3899,10 +3900,25 @@
3899 import_append_char(p, c);
3900 ppc = pc;
3901 pc = c;
3902 }
3903 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3904 while( c!=EOF && c!=cSep && c!=rSep ){
3905 import_append_char(p, c);
3906 c = fgetc(p->in);
3907 }
3908 if( c==rSep ){
@@ -3910,10 +3926,11 @@
3910 if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
3911 }
3912 p->cTerm = c;
3913 }
3914 if( p->z ) p->z[p->n] = 0;
 
3915 return p->z;
3916 }
3917
3918 /* Read a single field of ASCII delimited text.
3919 **
3920
--- src/shell.c
+++ src/shell.c
@@ -3820,10 +3820,11 @@
3820 FILE *in; /* Read the CSV text from this input stream */
3821 char *z; /* Accumulated text for a field */
3822 int n; /* Number of bytes in z */
3823 int nAlloc; /* Space allocated for z[] */
3824 int nLine; /* Current line number */
3825 int bNotFirst; /* True if one or more bytes already read */
3826 int cTerm; /* Character that terminated the most recent field */
3827 int cColSep; /* The column separator character. (Usually ",") */
3828 int cRowSep; /* The row separator character. (Usually "\n") */
3829 };
3830
@@ -3899,10 +3900,25 @@
3900 import_append_char(p, c);
3901 ppc = pc;
3902 pc = c;
3903 }
3904 }else{
3905 /* If this is the first field being parsed and it begins with the
3906 ** UTF-8 BOM (0xEF BB BF) then skip the BOM */
3907 if( (c&0xff)==0xef && p->bNotFirst==0 ){
3908 import_append_char(p, c);
3909 c = fgetc(p->in);
3910 if( (c&0xff)==0xbb ){
3911 import_append_char(p, c);
3912 c = fgetc(p->in);
3913 if( (c&0xff)==0xbf ){
3914 p->bNotFirst = 1;
3915 p->n = 0;
3916 return csv_read_one_field(p);
3917 }
3918 }
3919 }
3920 while( c!=EOF && c!=cSep && c!=rSep ){
3921 import_append_char(p, c);
3922 c = fgetc(p->in);
3923 }
3924 if( c==rSep ){
@@ -3910,10 +3926,11 @@
3926 if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
3927 }
3928 p->cTerm = c;
3929 }
3930 if( p->z ) p->z[p->n] = 0;
3931 p->bNotFirst = 1;
3932 return p->z;
3933 }
3934
3935 /* Read a single field of ASCII delimited text.
3936 **
3937
+1474 -904
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -39,10 +39,18 @@
3939
** SQLite was built with.
4040
*/
4141
4242
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
4343
44
+/*
45
+** Include the configuration header output by 'configure' if we're using the
46
+** autoconf-based build
47
+*/
48
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49
+#include "config.h"
50
+#define SQLITECONFIG_H 1
51
+#endif
4452
4553
/* These macros are provided to "stringify" the value of the define
4654
** for those options in which the value is meaningful. */
4755
#define CTIMEOPT_VAL_(opt) #opt
4856
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
@@ -279,10 +287,13 @@
279287
#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
280288
"ENABLE_OVERSIZE_CELL_CHECK",
281289
#endif
282290
#if SQLITE_ENABLE_PREUPDATE_HOOK
283291
"ENABLE_PREUPDATE_HOOK",
292
+#endif
293
+#if SQLITE_ENABLE_QPSG
294
+ "ENABLE_QPSG",
284295
#endif
285296
#if SQLITE_ENABLE_RBU
286297
"ENABLE_RBU",
287298
#endif
288299
#if SQLITE_ENABLE_RTREE
@@ -302,10 +313,13 @@
302313
#endif
303314
#if defined(SQLITE_ENABLE_STAT4)
304315
"ENABLE_STAT4",
305316
#elif defined(SQLITE_ENABLE_STAT3)
306317
"ENABLE_STAT3",
318
+#endif
319
+#if SQLITE_ENABLE_STMTVTAB
320
+ "ENABLE_STMTVTAB",
307321
#endif
308322
#if SQLITE_ENABLE_STMT_SCANSTATUS
309323
"ENABLE_STMT_SCANSTATUS",
310324
#endif
311325
#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
@@ -1012,11 +1026,11 @@
10121026
** MinGW.
10131027
*/
10141028
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
10151029
/************** Begin file sqlite3.h *****************************************/
10161030
/*
1017
-** 2001 September 15
1031
+** 2001-09-15
10181032
**
10191033
** The author disclaims copyright to this source code. In place of
10201034
** a legal notice, here is a blessing:
10211035
**
10221036
** May you do good and not evil.
@@ -1136,11 +1150,11 @@
11361150
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11371151
** [sqlite_version()] and [sqlite_source_id()].
11381152
*/
11391153
#define SQLITE_VERSION "3.20.0"
11401154
#define SQLITE_VERSION_NUMBER 3020000
1141
-#define SQLITE_SOURCE_ID "2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a"
1155
+#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
11421156
11431157
/*
11441158
** CAPI3REF: Run-Time Library Version Numbers
11451159
** KEYWORDS: sqlite3_version sqlite3_sourceid
11461160
**
@@ -1248,11 +1262,11 @@
12481262
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
12491263
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
12501264
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
12511265
** and [sqlite3_close_v2()] are its destructors. There are many other
12521266
** interfaces (such as
1253
-** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
1267
+** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
12541268
** [sqlite3_busy_timeout()] to name but three) that are methods on an
12551269
** sqlite3 object.
12561270
*/
12571271
typedef struct sqlite3 sqlite3;
12581272
@@ -1352,11 +1366,11 @@
13521366
/*
13531367
** CAPI3REF: One-Step Query Execution Interface
13541368
** METHOD: sqlite3
13551369
**
13561370
** The sqlite3_exec() interface is a convenience wrapper around
1357
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
1371
+** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
13581372
** that allows an application to run multiple statements of SQL
13591373
** without having to use a lot of C code.
13601374
**
13611375
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
13621376
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3020,19 +3034,31 @@
30203034
** default) to enable them. The second parameter is a pointer to an integer
30213035
** into which is written 0 or 1 to indicate whether checkpoints-on-close
30223036
** have been disabled - 0 if they are not disabled, 1 if they are.
30233037
** </dd>
30243038
**
3039
+** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040
+** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041
+** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042
+** a single SQL query statement will always use the same algorithm regardless
3043
+** of values of [bound parameters]. The QPSG disables some query optimizations
3044
+** that look at the values of bound parameters, which can make some queries
3045
+** slower. But the QPSG has the advantage of more predictable behavior. With
3046
+** the QPSG active, SQLite will always use the same query plan in the field as
3047
+** was used during testing in the lab.
3048
+** </dd>
3049
+**
30253050
** </dl>
30263051
*/
30273052
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
30283053
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
30293054
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
30303055
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
30313056
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
30323057
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
30333058
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3059
+#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
30343060
30353061
30363062
/*
30373063
** CAPI3REF: Enable Or Disable Extended Result Codes
30383064
** METHOD: sqlite3
@@ -3692,25 +3718,26 @@
36923718
**
36933719
** ^This routine registers an authorizer callback with a particular
36943720
** [database connection], supplied in the first argument.
36953721
** ^The authorizer callback is invoked as SQL statements are being compiled
36963722
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
3697
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
3723
+** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
3724
+** and [sqlite3_prepare16_v3()]. ^At various
36983725
** points during the compilation process, as logic is being created
36993726
** to perform various actions, the authorizer callback is invoked to
37003727
** see if those actions are allowed. ^The authorizer callback should
37013728
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
37023729
** specific action but allow the SQL statement to continue to be
37033730
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
37043731
** rejected with an error. ^If the authorizer callback returns
37053732
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3706
-** then the [sqlite3_prepare_v2()] or equivalent call that triggered
3733
+** then the [sqlite3_prepare_v3()] or equivalent call that triggered
37073734
** the authorizer will fail with an error message.
37083735
**
37093736
** When the callback returns [SQLITE_OK], that means the operation
37103737
** requested is ok. ^When the callback returns [SQLITE_DENY], the
3711
-** [sqlite3_prepare_v2()] or equivalent call that triggered the
3738
+** [sqlite3_prepare_v3()] or equivalent call that triggered the
37123739
** authorizer will fail with an error message explaining that
37133740
** access is denied.
37143741
**
37153742
** ^The first parameter to the authorizer callback is a copy of the third
37163743
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3757,23 +3784,23 @@
37573784
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
37583785
** The authorizer is disabled by default.
37593786
**
37603787
** The authorizer callback must not do anything that will modify
37613788
** the database connection that invoked the authorizer callback.
3762
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3789
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
37633790
** database connections for the meaning of "modify" in this paragraph.
37643791
**
3765
-** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3792
+** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
37663793
** statement might be re-prepared during [sqlite3_step()] due to a
37673794
** schema change. Hence, the application should ensure that the
37683795
** correct authorizer callback remains in place during the [sqlite3_step()].
37693796
**
37703797
** ^Note that the authorizer callback is invoked only during
37713798
** [sqlite3_prepare()] or its variants. Authorization is not
37723799
** performed during statement evaluation in [sqlite3_step()], unless
37733800
** as stated in the previous paragraph, sqlite3_step() invokes
3774
-** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3801
+** sqlite3_prepare_v3() to reprepare a statement after a schema change.
37753802
*/
37763803
SQLITE_API int sqlite3_set_authorizer(
37773804
sqlite3*,
37783805
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
37793806
void *pUserData
@@ -4005,11 +4032,11 @@
40054032
** interrupted. This feature can be used to implement a
40064033
** "Cancel" button on a GUI progress dialog box.
40074034
**
40084035
** The progress handler callback must not do anything that will modify
40094036
** the database connection that invoked the progress handler.
4010
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4037
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
40114038
** database connections for the meaning of "modify" in this paragraph.
40124039
**
40134040
*/
40144041
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
40154042
@@ -4359,11 +4386,11 @@
43594386
** prepared statement before it can be run.
43604387
**
43614388
** The life-cycle of a prepared statement object usually goes like this:
43624389
**
43634390
** <ol>
4364
-** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
4391
+** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
43654392
** <li> Bind values to [parameters] using the sqlite3_bind_*()
43664393
** interfaces.
43674394
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
43684395
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
43694396
** to step 2. Do this zero or more times.
@@ -4441,11 +4468,11 @@
44414468
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
44424469
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
44434470
**
44444471
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
44454472
** <dd>The maximum number of instructions in a virtual machine program
4446
-** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
4473
+** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
44474474
** the equivalent tries to allocate space for more than this many opcodes
44484475
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
44494476
**
44504477
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
44514478
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4481,28 +4508,61 @@
44814508
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
44824509
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
44834510
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
44844511
#define SQLITE_LIMIT_WORKER_THREADS 11
44854512
4513
+/*
4514
+** CAPI3REF: Prepare Flags
4515
+**
4516
+** These constants define various flags that can be passed into
4517
+** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
4518
+** [sqlite3_prepare16_v3()] interfaces.
4519
+**
4520
+** New flags may be added in future releases of SQLite.
4521
+**
4522
+** <dl>
4523
+** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524
+** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525
+** and [sqlite3_prepare16_v3()]
4526
+** to optimize the resulting prepared statement to be retained for a
4527
+** relatively long amount of time.)^ ^Without this flag,
4528
+** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529
+** the prepared statement will be used just once or at most a few times
4530
+** and then destroyed using [sqlite3_finalize()] relatively soon.
4531
+** </dl>
4532
+*/
4533
+#define SQLITE_PREPARE_PERSISTENT 0x01
44864534
44874535
/*
44884536
** CAPI3REF: Compiling An SQL Statement
44894537
** KEYWORDS: {SQL statement compiler}
44904538
** METHOD: sqlite3
44914539
** CONSTRUCTOR: sqlite3_stmt
44924540
**
4493
-** To execute an SQL query, it must first be compiled into a byte-code
4494
-** program using one of these routines.
4541
+** To execute an SQL statement, it must first be compiled into a byte-code
4542
+** program using one of these routines. Or, in other words, these routines
4543
+** are constructors for the [prepared statement] object.
4544
+**
4545
+** The preferred routine to use is [sqlite3_prepare_v2()]. The
4546
+** [sqlite3_prepare()] interface is legacy and should be avoided.
4547
+** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4548
+** for special purposes.
4549
+**
4550
+** The use of the UTF-8 interfaces is preferred, as SQLite currently
4551
+** does all parsing using UTF-8. The UTF-16 interfaces are provided
4552
+** as a convenience. The UTF-16 interfaces work by converting the
4553
+** input text into UTF-8, then invoking the corresponding UTF-8 interface.
44954554
**
44964555
** The first argument, "db", is a [database connection] obtained from a
44974556
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
44984557
** [sqlite3_open16()]. The database connection must not have been closed.
44994558
**
45004559
** The second argument, "zSql", is the statement to be compiled, encoded
4501
-** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
4502
-** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
4503
-** use UTF-16.
4560
+** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
4561
+** and sqlite3_prepare_v3()
4562
+** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
4563
+** and sqlite3_prepare16_v3() use UTF-16.
45044564
**
45054565
** ^If the nByte argument is negative, then zSql is read up to the
45064566
** first zero terminator. ^If nByte is positive, then it is the
45074567
** number of bytes read from zSql. ^If nByte is zero, then no prepared
45084568
** statement is generated.
@@ -4525,14 +4585,15 @@
45254585
** ppStmt may not be NULL.
45264586
**
45274587
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
45284588
** otherwise an [error code] is returned.
45294589
**
4530
-** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
4531
-** recommended for all new programs. The two older interfaces are retained
4532
-** for backwards compatibility, but their use is discouraged.
4533
-** ^In the "v2" interfaces, the prepared statement
4590
+** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
4591
+** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
4592
+** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
4593
+** are retained for backwards compatibility, but their use is discouraged.
4594
+** ^In the "vX" interfaces, the prepared statement
45344595
** that is returned (the [sqlite3_stmt] object) contains a copy of the
45354596
** original SQL text. This causes the [sqlite3_step()] interface to
45364597
** behave differently in three ways:
45374598
**
45384599
** <ol>
@@ -4561,10 +4622,16 @@
45614622
** ^The specific value of WHERE-clause [parameter] might influence the
45624623
** choice of query plan if the parameter is the left-hand side of a [LIKE]
45634624
** or [GLOB] operator or if the parameter is compared to an indexed column
45644625
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
45654626
** </li>
4627
+**
4628
+** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4629
+** the extra prepFlags parameter, which is a bit array consisting of zero or
4630
+** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
4631
+** sqlite3_prepare_v2() interface works exactly the same as
4632
+** sqlite3_prepare_v3() with a zero prepFlags parameter.
45664633
** </ol>
45674634
*/
45684635
SQLITE_API int sqlite3_prepare(
45694636
sqlite3 *db, /* Database handle */
45704637
const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4574,10 +4641,18 @@
45744641
);
45754642
SQLITE_API int sqlite3_prepare_v2(
45764643
sqlite3 *db, /* Database handle */
45774644
const char *zSql, /* SQL statement, UTF-8 encoded */
45784645
int nByte, /* Maximum length of zSql in bytes. */
4646
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4647
+ const char **pzTail /* OUT: Pointer to unused portion of zSql */
4648
+);
4649
+SQLITE_API int sqlite3_prepare_v3(
4650
+ sqlite3 *db, /* Database handle */
4651
+ const char *zSql, /* SQL statement, UTF-8 encoded */
4652
+ int nByte, /* Maximum length of zSql in bytes. */
4653
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
45794654
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
45804655
const char **pzTail /* OUT: Pointer to unused portion of zSql */
45814656
);
45824657
SQLITE_API int sqlite3_prepare16(
45834658
sqlite3 *db, /* Database handle */
@@ -4591,18 +4666,27 @@
45914666
const void *zSql, /* SQL statement, UTF-16 encoded */
45924667
int nByte, /* Maximum length of zSql in bytes. */
45934668
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
45944669
const void **pzTail /* OUT: Pointer to unused portion of zSql */
45954670
);
4671
+SQLITE_API int sqlite3_prepare16_v3(
4672
+ sqlite3 *db, /* Database handle */
4673
+ const void *zSql, /* SQL statement, UTF-16 encoded */
4674
+ int nByte, /* Maximum length of zSql in bytes. */
4675
+ unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
4676
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4677
+ const void **pzTail /* OUT: Pointer to unused portion of zSql */
4678
+);
45964679
45974680
/*
45984681
** CAPI3REF: Retrieving Statement SQL
45994682
** METHOD: sqlite3_stmt
46004683
**
46014684
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
46024685
** SQL text used to create [prepared statement] P if P was
4603
-** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
4686
+** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4687
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
46044688
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
46054689
** string containing the SQL text of prepared statement P with
46064690
** [bound parameters] expanded.
46074691
**
46084692
** ^(For example, if a prepared statement is created using the SQL
@@ -4744,11 +4828,11 @@
47444828
** CAPI3REF: Binding Values To Prepared Statements
47454829
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
47464830
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
47474831
** METHOD: sqlite3_stmt
47484832
**
4749
-** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
4833
+** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
47504834
** literals may be replaced by a [parameter] that matches one of following
47514835
** templates:
47524836
**
47534837
** <ul>
47544838
** <li> ?
@@ -4763,11 +4847,11 @@
47634847
** parameters (also called "host parameter names" or "SQL parameters")
47644848
** can be set using the sqlite3_bind_*() routines defined here.
47654849
**
47664850
** ^The first argument to the sqlite3_bind_*() routines is always
47674851
** a pointer to the [sqlite3_stmt] object returned from
4768
-** [sqlite3_prepare_v2()] or its variants.
4852
+** [sqlite3_prepare_v3()] or its variants.
47694853
**
47704854
** ^The second argument is the index of the SQL parameter to be set.
47714855
** ^The leftmost SQL parameter has an index of 1. ^When the same named
47724856
** SQL parameter is used more than once, second and subsequent
47734857
** occurrences have the same index as the first occurrence.
@@ -4900,12 +4984,12 @@
49004984
** ^The first host parameter has an index of 1, not 0.
49014985
**
49024986
** ^If the value N is out of range or if the N-th parameter is
49034987
** nameless, then NULL is returned. ^The returned string is
49044988
** always in UTF-8 encoding even if the named parameter was
4905
-** originally specified as UTF-16 in [sqlite3_prepare16()] or
4906
-** [sqlite3_prepare16_v2()].
4989
+** originally specified as UTF-16 in [sqlite3_prepare16()],
4990
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
49074991
**
49084992
** See also: [sqlite3_bind_blob|sqlite3_bind()],
49094993
** [sqlite3_bind_parameter_count()], and
49104994
** [sqlite3_bind_parameter_index()].
49114995
*/
@@ -4918,11 +5002,12 @@
49185002
** ^Return the index of an SQL parameter given its name. ^The
49195003
** index value returned is suitable for use as the second
49205004
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
49215005
** is returned if no matching parameter is found. ^The parameter
49225006
** name must be given in UTF-8 even if the original statement
4923
-** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
5007
+** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
5008
+** [sqlite3_prepare16_v3()].
49245009
**
49255010
** See also: [sqlite3_bind_blob|sqlite3_bind()],
49265011
** [sqlite3_bind_parameter_count()], and
49275012
** [sqlite3_bind_parameter_name()].
49285013
*/
@@ -5072,20 +5157,22 @@
50725157
50735158
/*
50745159
** CAPI3REF: Evaluate An SQL Statement
50755160
** METHOD: sqlite3_stmt
50765161
**
5077
-** After a [prepared statement] has been prepared using either
5078
-** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
5162
+** After a [prepared statement] has been prepared using any of
5163
+** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
5164
+** or [sqlite3_prepare16_v3()] or one of the legacy
50795165
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
50805166
** must be called one or more times to evaluate the statement.
50815167
**
50825168
** The details of the behavior of the sqlite3_step() interface depend
5083
-** on whether the statement was prepared using the newer "v2" interface
5084
-** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
5085
-** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5086
-** new "v2" interface is recommended for new applications but the legacy
5169
+** on whether the statement was prepared using the newer "vX" interfaces
5170
+** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
5171
+** [sqlite3_prepare16_v2()] or the older legacy
5172
+** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5173
+** new "vX" interface is recommended for new applications but the legacy
50875174
** interface will continue to be supported.
50885175
**
50895176
** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
50905177
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
50915178
** ^With the "v2" interface, any of the other [result codes] or
@@ -5142,14 +5229,15 @@
51425229
** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
51435230
** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
51445231
** specific [error codes] that better describes the error.
51455232
** We admit that this is a goofy design. The problem has been fixed
51465233
** with the "v2" interface. If you prepare all of your SQL statements
5147
-** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
5234
+** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
5235
+** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
51485236
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
51495237
** then the more specific [error codes] are returned directly
5150
-** by sqlite3_step(). The use of the "v2" interface is recommended.
5238
+** by sqlite3_step(). The use of the "vX" interfaces is recommended.
51515239
*/
51525240
SQLITE_API int sqlite3_step(sqlite3_stmt*);
51535241
51545242
/*
51555243
** CAPI3REF: Number of columns in a result set
@@ -5210,11 +5298,11 @@
52105298
** METHOD: sqlite3_stmt
52115299
**
52125300
** ^These routines return information about a single column of the current
52135301
** result row of a query. ^In every case the first argument is a pointer
52145302
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5215
-** that was returned from [sqlite3_prepare_v2()] or one of its variants)
5303
+** that was returned from [sqlite3_prepare_v3()] or one of its variants)
52165304
** and the second argument is the index of the column for which information
52175305
** should be returned. ^The leftmost column of the result set has the index 0.
52185306
** ^The number of columns in the result can be determined using
52195307
** [sqlite3_column_count()].
52205308
**
@@ -6334,11 +6422,11 @@
63346422
**
63356423
** ^The sqlite3_db_handle interface returns the [database connection] handle
63366424
** to which a [prepared statement] belongs. ^The [database connection]
63376425
** returned by sqlite3_db_handle is the same [database connection]
63386426
** that was the first argument
6339
-** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
6427
+** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
63406428
** create the statement in the first place.
63416429
*/
63426430
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
63436431
63446432
/*
@@ -6410,11 +6498,11 @@
64106498
** the database connection that invoked the callback. Any actions
64116499
** to modify the database connection must be deferred until after the
64126500
** completion of the [sqlite3_step()] call that triggered the commit
64136501
** or rollback hook in the first place.
64146502
** Note that running any other SQL statements, including SELECT statements,
6415
-** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
6503
+** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
64166504
** the database connections for the meaning of "modify" in this paragraph.
64176505
**
64186506
** ^Registering a NULL function disables the callback.
64196507
**
64206508
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6470,11 +6558,11 @@
64706558
**
64716559
** The update hook implementation must not do anything that will modify
64726560
** the database connection that invoked the update hook. Any actions
64736561
** to modify the database connection must be deferred until after the
64746562
** completion of the [sqlite3_step()] call that triggered the update hook.
6475
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
6563
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
64766564
** database connections for the meaning of "modify" in this paragraph.
64776565
**
64786566
** ^The sqlite3_update_hook(D,C,P) function
64796567
** returns the P argument from the previous call
64806568
** on the same [database connection] D, or NULL for
@@ -8148,10 +8236,22 @@
81488236
** by the prepared statement if that number is less than or equal
81498237
** to 2147483647. The number of virtual machine operations can be
81508238
** used as a proxy for the total work done by the prepared statement.
81518239
** If the number of virtual machine operations exceeds 2147483647
81528240
** then the value returned by this statement status code is undefined.
8241
+**
8242
+** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
8243
+** <dd>^This is the number of times that the prepare statement has been
8244
+** automatically regenerated due to schema changes or change to
8245
+** [bound parameters] that might affect the query plan.
8246
+**
8247
+** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
8248
+** <dd>^This is the number of times that the prepared statement has
8249
+** been run. A single "run" for the purposes of this counter is one
8250
+** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
8251
+** The counter is incremented on the first [sqlite3_step()] call of each
8252
+** cycle.
81538253
**
81548254
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
81558255
** <dd>^This is the approximate number of bytes of heap memory
81568256
** used to store the prepared statement. ^This value is not actually
81578257
** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -8161,11 +8261,13 @@
81618261
*/
81628262
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
81638263
#define SQLITE_STMTSTATUS_SORT 2
81648264
#define SQLITE_STMTSTATUS_AUTOINDEX 3
81658265
#define SQLITE_STMTSTATUS_VM_STEP 4
8166
-#define SQLITE_STMTSTATUS_MEMUSED 5
8266
+#define SQLITE_STMTSTATUS_REPREPARE 5
8267
+#define SQLITE_STMTSTATUS_RUN 6
8268
+#define SQLITE_STMTSTATUS_MEMUSED 99
81678269
81688270
/*
81698271
** CAPI3REF: Custom Page Cache Object
81708272
**
81718273
** The sqlite3_pcache type is opaque. It is implemented by
@@ -11528,12 +11630,13 @@
1152811630
1152911631
/*
1153011632
** Include the configuration header output by 'configure' if we're using the
1153111633
** autoconf-based build
1153211634
*/
11533
-#ifdef _HAVE_SQLITE_CONFIG_H
11534
-#include "config.h"
11635
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
11636
+/* #include "config.h" */
11637
+#define SQLITECONFIG_H 1
1153511638
#endif
1153611639
1153711640
/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
1153811641
/************** Begin file sqliteLimit.h *************************************/
1153911642
/*
@@ -13695,10 +13798,16 @@
1369513798
#define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
1369613799
1369713800
/************** End of opcodes.h *********************************************/
1369813801
/************** Continuing where we left off in vdbe.h ***********************/
1369913802
13803
+/*
13804
+** Additional non-public SQLITE_PREPARE_* flags
13805
+*/
13806
+#define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
13807
+#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
13808
+
1370013809
/*
1370113810
** Prototypes for the VDBE interface. See comments on the implementation
1370213811
** for a description of what each of these routines does.
1370313812
*/
1370413813
SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13752,11 +13861,12 @@
1375213861
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
1375313862
SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
1375413863
SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
1375513864
SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
1375613865
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13757
-SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
13866
+SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);
13867
+SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
1375813868
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
1375913869
SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
1376013870
SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
1376113871
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
1376213872
#ifndef SQLITE_OMIT_TRACE
@@ -14974,12 +15084,12 @@
1497415084
** Value constraints (enforced via assert()):
1497515085
** SQLITE_FullFSync == PAGER_FULLFSYNC
1497615086
** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
1497715087
** SQLITE_CacheSpill == PAGER_CACHE_SPILL
1497815088
*/
14979
-#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
14980
-#define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
15089
+#define SQLITE_WriteSchema 0x00000001 /* OK to update SQLITE_MASTER */
15090
+#define SQLITE_LegacyFileFmt 0x00000002 /* Create new databases in format 1 */
1498115091
#define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
1498215092
#define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
1498315093
#define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
1498415094
#define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
1498515095
#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -14986,33 +15096,38 @@
1498615096
#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
1498715097
/* DELETE, or UPDATE and return */
1498815098
/* the count using a callback. */
1498915099
#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
1499015100
/* result set is empty */
14991
-#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
14992
-#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
14993
-#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
14994
-#define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
14995
-#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
14996
-#define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
14997
-#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
14998
-#define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
14999
-#define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
15000
-#define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
15001
-#define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
15002
-#define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
15003
-#define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
15004
-#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
15005
-#define SQLITE_LoadExtFunc 0x00800000 /* Enable load_extension() SQL func */
15006
-#define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */
15007
-#define SQLITE_DeferFKs 0x02000000 /* Defer all FK constraints */
15008
-#define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
15009
-#define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
15010
-#define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
15011
-#define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
15012
-#define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
15013
-#define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
15101
+#define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */
15102
+#define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */
15103
+#define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */
15104
+#define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */
15105
+#define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */
15106
+#define SQLITE_ForeignKeys 0x00004000 /* Enforce foreign key constraints */
15107
+#define SQLITE_AutoIndex 0x00008000 /* Enable automatic indexes */
15108
+#define SQLITE_LoadExtension 0x00010000 /* Enable load_extension */
15109
+#define SQLITE_EnableTrigger 0x00020000 /* True to enable triggers */
15110
+#define SQLITE_DeferFKs 0x00040000 /* Defer all FK constraints */
15111
+#define SQLITE_QueryOnly 0x00080000 /* Disable database changes */
15112
+#define SQLITE_CellSizeCk 0x00100000 /* Check btree cell sizes on load */
15113
+#define SQLITE_Fts3Tokenizer 0x00200000 /* Enable fts3_tokenizer(2) */
15114
+#define SQLITE_EnableQPSG 0x00400000 /* Query Planner Stability Guarantee */
15115
+/* The next four values are not used by PRAGMAs or by sqlite3_dbconfig() and
15116
+** could be factored out into a separate bit vector of the sqlite3 object. */
15117
+#define SQLITE_InternChanges 0x00800000 /* Uncommitted Hash table changes */
15118
+#define SQLITE_LoadExtFunc 0x01000000 /* Enable load_extension() SQL func */
15119
+#define SQLITE_PreferBuiltin 0x02000000 /* Preference to built-in funcs */
15120
+#define SQLITE_Vacuum 0x04000000 /* Currently in a VACUUM */
15121
+/* Flags used only if debugging */
15122
+#ifdef SQLITE_DEBUG
15123
+#define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
15124
+#define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
15125
+#define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
15126
+#define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
15127
+#define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
15128
+#endif
1501415129
1501515130
1501615131
/*
1501715132
** Bits of the sqlite3.dbOptFlags field that are used by the
1501815133
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17305,14 +17420,14 @@
1730517420
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1730617421
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1730717422
SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
1730817423
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
1730917424
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
17310
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
17425
+SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
1731117426
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
1731217427
SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
17313
-SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
17428
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);
1731417429
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1731517430
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1731617431
SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
1731717432
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1731817433
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18606,22 +18721,22 @@
1860618721
int rcApp; /* errcode set by sqlite3_result_error_code() */
1860718722
#endif
1860818723
u16 nResColumn; /* Number of columns in one row of the result set */
1860918724
u8 errorAction; /* Recovery action to do in case of an error */
1861018725
u8 minWriteFileFormat; /* Minimum file format for writable database files */
18726
+ u8 prepFlags; /* SQLITE_PREPARE_* flags */
1861118727
bft expired:1; /* True if the VM needs to be recompiled */
1861218728
bft doingRerun:1; /* True if rerunning after an auto-reprepare */
1861318729
bft explain:2; /* True if EXPLAIN present on SQL command */
1861418730
bft changeCntOn:1; /* True to update the change-counter */
1861518731
bft runOnlyOnce:1; /* Automatically expire on reset */
1861618732
bft usesStmtJournal:1; /* True if uses a statement journal */
1861718733
bft readOnly:1; /* True for statements that do not write */
1861818734
bft bIsReader:1; /* True for statements that read */
18619
- bft isPrepareV2:1; /* True if prepared with prepare_v2() */
1862018735
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
1862118736
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18622
- u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
18737
+ u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
1862318738
char *zSql; /* Text of the SQL statement that generated this */
1862418739
void *pFree; /* Free this when deleting the vdbe */
1862518740
VdbeFrame *pFrame; /* Parent frame */
1862618741
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
1862718742
int nFrame; /* Number of frames in pFrame list */
@@ -59469,11 +59584,11 @@
5946959584
/* If this database is not shareable, or if the client is reading
5947059585
** and has the read-uncommitted flag set, then no lock is required.
5947159586
** Return true immediately.
5947259587
*/
5947359588
if( (pBtree->sharable==0)
59474
- || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))
59589
+ || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))
5947559590
){
5947659591
return 1;
5947759592
}
5947859593
5947959594
/* If the client is reading or writing an index and the schema is
@@ -59546,11 +59661,11 @@
5954659661
static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
5954759662
BtCursor *p;
5954859663
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
5954959664
if( p->pgnoRoot==iRoot
5955059665
&& p->pBtree!=pBtree
59551
- && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted)
59666
+ && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)
5955259667
){
5955359668
return 1;
5955459669
}
5955559670
}
5955659671
return 0;
@@ -59568,11 +59683,11 @@
5956859683
BtLock *pIter;
5956959684
5957059685
assert( sqlite3BtreeHoldsMutex(p) );
5957159686
assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
5957259687
assert( p->db!=0 );
59573
- assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 );
59688
+ assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );
5957459689
5957559690
/* If requesting a write-lock, then the Btree must have an open write
5957659691
** transaction on this file. And, obviously, for this to be so there
5957759692
** must be an open write transaction on the file itself.
5957859693
*/
@@ -59646,11 +59761,11 @@
5964659761
5964759762
/* A connection with the read-uncommitted flag set will never try to
5964859763
** obtain a read-lock using this function. The only read-lock obtained
5964959764
** by a connection in read-uncommitted mode is on the sqlite_master
5965059765
** table, and that lock is obtained in BtreeBeginTrans(). */
59651
- assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );
59766
+ assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );
5965259767
5965359768
/* This function should only be called on a sharable b-tree after it
5965459769
** has been determined that no other b-tree holds a conflicting lock. */
5965559770
assert( p->sharable );
5965659771
assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -62338,11 +62453,11 @@
6233862453
freeTempSpace(pBt);
6233962454
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
6234062455
pageSize-usableSize);
6234162456
return rc;
6234262457
}
62343
- if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
62458
+ if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
6234462459
rc = SQLITE_CORRUPT_BKPT;
6234562460
goto page1_init_failed;
6234662461
}
6234762462
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
6234862463
** be less than 480. In other words, if the page size is 512, then the
@@ -71465,28 +71580,25 @@
7146571580
sqlite3 *db = pParse->db;
7146671581
7146771582
/* Skip over any TK_COLLATE nodes */
7146871583
pExpr = sqlite3ExprSkipCollate(pExpr);
7146971584
71585
+ assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );
7147071586
if( !pExpr ){
7147171587
pVal = valueNew(db, pAlloc);
7147271588
if( pVal ){
7147371589
sqlite3VdbeMemSetNull((Mem*)pVal);
7147471590
}
71475
- }else if( pExpr->op==TK_VARIABLE
71476
- || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
71477
- ){
71591
+ }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
7147871592
Vdbe *v;
7147971593
int iBindVar = pExpr->iColumn;
7148071594
sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
7148171595
if( (v = pParse->pReprepare)!=0 ){
7148271596
pVal = valueNew(db, pAlloc);
7148371597
if( pVal ){
7148471598
rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71485
- if( rc==SQLITE_OK ){
71486
- sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
71487
- }
71599
+ sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
7148871600
pVal->db = pParse->db;
7148971601
}
7149071602
}
7149171603
}else{
7149271604
rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71756,20 +71868,18 @@
7175671868
}
7175771869
7175871870
/*
7175971871
** Remember the SQL string for a prepared statement.
7176071872
*/
71761
-SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71762
- assert( isPrepareV2==1 || isPrepareV2==0 );
71873
+SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
7176371874
if( p==0 ) return;
71764
- if( !isPrepareV2 ) p->expmask = 0;
71765
-#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71766
- if( !isPrepareV2 ) return;
71767
-#endif
71875
+ p->prepFlags = prepFlags;
71876
+ if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
71877
+ p->expmask = 0;
71878
+ }
7176871879
assert( p->zSql==0 );
7176971880
p->zSql = sqlite3DbStrNDup(p->db, z, n);
71770
- p->isPrepareV2 = (u8)isPrepareV2;
7177171881
}
7177271882
7177371883
/*
7177471884
** Swap all content between two VDBE structures.
7177571885
*/
@@ -71787,12 +71897,14 @@
7178771897
pA->pPrev = pB->pPrev;
7178871898
pB->pPrev = pTmp;
7178971899
zTmp = pA->zSql;
7179071900
pA->zSql = pB->zSql;
7179171901
pB->zSql = zTmp;
71792
- pB->isPrepareV2 = pA->isPrepareV2;
7179371902
pB->expmask = pA->expmask;
71903
+ pB->prepFlags = pA->prepFlags;
71904
+ memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
71905
+ pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
7179471906
}
7179571907
7179671908
/*
7179771909
** Resize the Vdbe.aOp array so that it is at least nOp elements larger
7179871910
** than its current size. nOp is guaranteed to be less than or equal
@@ -76231,10 +76343,17 @@
7623176343
** Return the database associated with the Vdbe.
7623276344
*/
7623376345
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
7623476346
return v->db;
7623576347
}
76348
+
76349
+/*
76350
+** Return the SQLITE_PREPARE flags for a Vdbe.
76351
+*/
76352
+SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){
76353
+ return v->prepFlags;
76354
+}
7623676355
7623776356
/*
7623876357
** Return a pointer to an sqlite3_value structure containing the value bound
7623976358
** parameter iVar of VM v. Except, if the value is an SQL NULL, return
7624076359
** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
@@ -76244,10 +76363,11 @@
7624476363
*/
7624576364
SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
7624676365
assert( iVar>0 );
7624776366
if( v ){
7624876367
Mem *pMem = &v->aVar[iVar-1];
76368
+ assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
7624976369
if( 0==(pMem->flags & MEM_Null) ){
7625076370
sqlite3_value *pRet = sqlite3ValueNew(v->db);
7625176371
if( pRet ){
7625276372
sqlite3VdbeMemCopy((Mem *)pRet, pMem);
7625376373
sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76263,10 +76383,11 @@
7626376383
** to sqlite3_reoptimize() that re-preparing the statement may result
7626476384
** in a better query plan.
7626576385
*/
7626676386
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
7626776387
assert( iVar>0 );
76388
+ assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
7626876389
if( iVar>=32 ){
7626976390
v->expmask |= 0x80000000;
7627076391
}else{
7627176392
v->expmask |= ((u32)1 << (iVar-1));
7627276393
}
@@ -76534,11 +76655,11 @@
7653476655
sqlite3_mutex_enter(mutex);
7653576656
for(i=0; i<p->nVar; i++){
7653676657
sqlite3VdbeMemRelease(&p->aVar[i]);
7653776658
p->aVar[i].flags = MEM_Null;
7653876659
}
76539
- assert( p->isPrepareV2 || p->expmask==0 );
76660
+ assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
7654076661
if( p->expmask ){
7654176662
p->expired = 1;
7654276663
}
7654376664
sqlite3_mutex_leave(mutex);
7654476665
return rc;
@@ -77013,12 +77134,15 @@
7701377134
*/
7701477135
assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
7701577136
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
7701677137
);
7701777138
assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
77018
- if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
77019
- /* If this statement was prepared using sqlite3_prepare_v2(), and an
77139
+ if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
77140
+ && rc!=SQLITE_ROW
77141
+ && rc!=SQLITE_DONE
77142
+ ){
77143
+ /* If this statement was prepared using saved SQL and an
7702077144
** error has occurred, then return the error code in p->rc to the
7702177145
** caller. Set the error code in the database handle to the same value.
7702277146
*/
7702377147
rc = sqlite3VdbeTransferError(p);
7702477148
}
@@ -77653,11 +77777,11 @@
7765377777
** parameter in the WHERE clause might influence the choice of query plan
7765477778
** for a statement, then the statement will be automatically recompiled,
7765577779
** as if there had been a schema change, on the first sqlite3_step() call
7765677780
** following any change to the bindings of that parameter.
7765777781
*/
77658
- assert( p->isPrepareV2 || p->expmask==0 );
77782
+ assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
7765977783
if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
7766077784
p->expired = 1;
7766177785
}
7766277786
return SQLITE_OK;
7766377787
}
@@ -77919,15 +78043,15 @@
7791978043
Vdbe *pFrom = (Vdbe*)pFromStmt;
7792078044
Vdbe *pTo = (Vdbe*)pToStmt;
7792178045
if( pFrom->nVar!=pTo->nVar ){
7792278046
return SQLITE_ERROR;
7792378047
}
77924
- assert( pTo->isPrepareV2 || pTo->expmask==0 );
78048
+ assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );
7792578049
if( pTo->expmask ){
7792678050
pTo->expired = 1;
7792778051
}
77928
- assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
78052
+ assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );
7792978053
if( pFrom->expmask ){
7793078054
pFrom->expired = 1;
7793178055
}
7793278056
return sqlite3TransferBindings(pFromStmt, pToStmt);
7793378057
}
@@ -85158,11 +85282,11 @@
8515885282
** P4 contains a pointer to the name of the table being locked. This is only
8515985283
** used to generate an error message if the lock cannot be obtained.
8516085284
*/
8516185285
case OP_TableLock: {
8516285286
u8 isWriteLock = (u8)pOp->p3;
85163
- if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){
85287
+ if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){
8516485288
int p1 = pOp->p1;
8516585289
assert( p1>=0 && p1<db->nDb );
8516685290
assert( DbMaskTest(p->btreeMask, p1) );
8516785291
assert( isWriteLock==0 || isWriteLock==1 );
8516885292
rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85666,10 +85790,11 @@
8566685790
if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
8566785791
}
8566885792
pOp->p1 = 0;
8566985793
}
8567085794
pOp->p1++;
85795
+ p->aCounter[SQLITE_STMTSTATUS_RUN]++;
8567185796
goto jump_to_p2;
8567285797
}
8567385798
8567485799
#ifdef SQLITE_ENABLE_CURSOR_HINTS
8567585800
/* Opcode: CursorHint P1 * * P4 *
@@ -90568,11 +90693,11 @@
9056890693
/* Try to match the ORDER BY expression against an expression
9056990694
** in the result set. Return an 1-based index of the matching
9057090695
** result-set entry.
9057190696
*/
9057290697
for(i=0; i<pEList->nExpr; i++){
90573
- if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
90698
+ if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){
9057490699
return i+1;
9057590700
}
9057690701
}
9057790702
9057890703
/* If no match, return 0. */
@@ -90802,11 +90927,11 @@
9080290927
pItem->u.x.iOrderByCol = 0;
9080390928
if( sqlite3ResolveExprNames(pNC, pE) ){
9080490929
return 1;
9080590930
}
9080690931
for(j=0; j<pSelect->pEList->nExpr; j++){
90807
- if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90932
+ if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
9080890933
pItem->u.x.iOrderByCol = j+1;
9080990934
}
9081090935
}
9081190936
}
9081290937
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -93027,11 +93152,11 @@
9302793152
9302893153
/* Check if pExpr is identical to any GROUP BY term. If so, consider
9302993154
** it constant. */
9303093155
for(i=0; i<pGroupBy->nExpr; i++){
9303193156
Expr *p = pGroupBy->a[i].pExpr;
93032
- if( sqlite3ExprCompare(pExpr, p, -1)<2 ){
93157
+ if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
9303393158
CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
9303493159
if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
9303593160
return WRC_Prune;
9303693161
}
9303793162
}
@@ -95303,11 +95428,11 @@
9530395428
p = pParse->pConstExpr;
9530495429
if( regDest<0 && p ){
9530595430
struct ExprList_item *pItem;
9530695431
int i;
9530795432
for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95308
- if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
95433
+ if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){
9530995434
return pItem->u.iConstExprReg;
9531095435
}
9531195436
}
9531295437
}
9531395438
pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95858,10 +95983,45 @@
9585895983
sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
9585995984
}
9586095985
sqlite3ExprDelete(db, pCopy);
9586195986
}
9586295987
95988
+/*
95989
+** Expression pVar is guaranteed to be an SQL variable. pExpr may be any
95990
+** type of expression.
95991
+**
95992
+** If pExpr is a simple SQL value - an integer, real, string, blob
95993
+** or NULL value - then the VDBE currently being prepared is configured
95994
+** to re-prepare each time a new value is bound to variable pVar.
95995
+**
95996
+** Additionally, if pExpr is a simple SQL value and the value is the
95997
+** same as that currently bound to variable pVar, non-zero is returned.
95998
+** Otherwise, if the values are not the same or if pExpr is not a simple
95999
+** SQL value, zero is returned.
96000
+*/
96001
+static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){
96002
+ int res = 0;
96003
+ int iVar;
96004
+ sqlite3_value *pL, *pR = 0;
96005
+
96006
+ sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
96007
+ if( pR ){
96008
+ iVar = pVar->iColumn;
96009
+ sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
96010
+ pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
96011
+ if( pL ){
96012
+ if( sqlite3_value_type(pL)==SQLITE_TEXT ){
96013
+ sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
96014
+ }
96015
+ res = 0==sqlite3MemCompare(pL, pR, 0);
96016
+ }
96017
+ sqlite3ValueFree(pR);
96018
+ sqlite3ValueFree(pL);
96019
+ }
96020
+
96021
+ return res;
96022
+}
9586396023
9586496024
/*
9586596025
** Do a deep comparison of two expression trees. Return 0 if the two
9586696026
** expressions are completely identical. Return 1 if they differ only
9586796027
** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -95880,28 +96040,38 @@
9588096040
** expressions are the same. But if you get a 0 or 1 return, then you
9588196041
** can be sure the expressions are the same. In the places where
9588296042
** this routine is used, it does not hurt to get an extra 2 - that
9588396043
** just might result in some slightly slower code. But returning
9588496044
** an incorrect 0 or 1 could lead to a malfunction.
96045
+**
96046
+** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
96047
+** pParse->pReprepare can be matched against literals in pB. The
96048
+** pParse->pVdbe->expmask bitmask is updated for each variable referenced.
96049
+** If pParse is NULL (the normal case) then any TK_VARIABLE term in
96050
+** Argument pParse should normally be NULL. If it is not NULL and pA or
96051
+** pB causes a return value of 2.
9588596052
*/
95886
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
96053
+SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
9588796054
u32 combinedFlags;
9588896055
if( pA==0 || pB==0 ){
9588996056
return pB==pA ? 0 : 2;
96057
+ }
96058
+ if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){
96059
+ return 0;
9589096060
}
9589196061
combinedFlags = pA->flags | pB->flags;
9589296062
if( combinedFlags & EP_IntValue ){
9589396063
if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
9589496064
return 0;
9589596065
}
9589696066
return 2;
9589796067
}
9589896068
if( pA->op!=pB->op ){
95899
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
96069
+ if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){
9590096070
return 1;
9590196071
}
95902
- if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
96072
+ if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){
9590396073
return 1;
9590496074
}
9590596075
return 2;
9590696076
}
9590796077
if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -95912,12 +96082,12 @@
9591296082
}
9591396083
}
9591496084
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
9591596085
if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
9591696086
if( combinedFlags & EP_xIsSelect ) return 2;
95917
- if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
95918
- if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
96087
+ if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
96088
+ if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
9591996089
if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
9592096090
if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
9592196091
if( pA->iColumn!=pB->iColumn ) return 2;
9592296092
if( pA->iTable!=pB->iTable
9592396093
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -95948,21 +96118,21 @@
9594896118
if( pA->nExpr!=pB->nExpr ) return 1;
9594996119
for(i=0; i<pA->nExpr; i++){
9595096120
Expr *pExprA = pA->a[i].pExpr;
9595196121
Expr *pExprB = pB->a[i].pExpr;
9595296122
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
95953
- if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
96123
+ if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
9595496124
}
9595596125
return 0;
9595696126
}
9595796127
9595896128
/*
9595996129
** Like sqlite3ExprCompare() except COLLATE operators at the top-level
9596096130
** are ignored.
9596196131
*/
9596296132
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
95963
- return sqlite3ExprCompare(
96133
+ return sqlite3ExprCompare(0,
9596496134
sqlite3ExprSkipCollate(pA),
9596596135
sqlite3ExprSkipCollate(pB),
9596696136
iTab);
9596796137
}
9596896138
@@ -95980,28 +96150,33 @@
9598096150
** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
9598196151
**
9598296152
** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
9598396153
** Expr.iTable<0 then assume a table number given by iTab.
9598496154
**
96155
+** If pParse is not NULL, then the values of bound variables in pE1 are
96156
+** compared against literal values in pE2 and pParse->pVdbe->expmask is
96157
+** modified to record which bound variables are referenced. If pParse
96158
+** is NULL, then false will be returned if pE1 contains any bound variables.
96159
+**
9598596160
** When in doubt, return false. Returning true might give a performance
9598696161
** improvement. Returning false might cause a performance reduction, but
9598796162
** it will always give the correct answer and is hence always safe.
9598896163
*/
95989
-SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
95990
- if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
96164
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
96165
+ if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){
9599196166
return 1;
9599296167
}
9599396168
if( pE2->op==TK_OR
95994
- && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
95995
- || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
96169
+ && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)
96170
+ || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )
9599696171
){
9599796172
return 1;
9599896173
}
9599996174
if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
9600096175
Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
9600196176
testcase( pX!=pE1->pLeft );
96002
- if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
96177
+ if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
9600396178
}
9600496179
return 0;
9600596180
}
9600696181
9600796182
/*
@@ -96238,11 +96413,11 @@
9623896413
/* Check to see if pExpr is a duplicate of another aggregate
9623996414
** function that is already in the pAggInfo structure
9624096415
*/
9624196416
struct AggInfo_func *pItem = pAggInfo->aFunc;
9624296417
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
96243
- if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
96418
+ if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){
9624496419
break;
9624596420
}
9624696421
}
9624796422
if( i>=pAggInfo->nFunc ){
9624896423
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96795,11 +96970,11 @@
9679596970
** in pParse->zErr (system tables may not be altered) and returns non-zero.
9679696971
**
9679796972
** Or, if zName is not a system table, zero is returned.
9679896973
*/
9679996974
static int isSystemTable(Parse *pParse, const char *zName){
96800
- if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96975
+ if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
9680196976
sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
9680296977
return 1;
9680396978
}
9680496979
return 0;
9680596980
}
@@ -104193,11 +104368,13 @@
104193104368
for(j=0; j<pIdx->nKeyCol; j++){
104194104369
char *zCol;
104195104370
assert( pIdx->aiColumn[j]>=0 );
104196104371
zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
104197104372
if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
104198
- sqlite3XPrintf(&errMsg, "%s.%s", pTab->zName, zCol);
104373
+ sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
104374
+ sqlite3StrAccumAppend(&errMsg, ".", 1);
104375
+ sqlite3StrAccumAppendAll(&errMsg, zCol);
104199104376
}
104200104377
}
104201104378
zErr = sqlite3StrAccumFinish(&errMsg);
104202104379
sqlite3HaltConstraint(pParse,
104203104380
IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -111051,11 +111228,11 @@
111051111228
if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
111052111229
return 0; /* Different columns indexed */
111053111230
}
111054111231
if( pSrc->aiColumn[i]==XN_EXPR ){
111055111232
assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
111056
- if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr,
111233
+ if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,
111057111234
pDest->aColExpr->a[i].pExpr, -1)!=0 ){
111058111235
return 0; /* Different expressions in the index */
111059111236
}
111060111237
}
111061111238
if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111063,11 +111240,11 @@
111063111240
}
111064111241
if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
111065111242
return 0; /* Different collating sequences */
111066111243
}
111067111244
}
111068
- if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111245
+ if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111069111246
return 0; /* Different WHERE clauses */
111070111247
}
111071111248
111072111249
/* If no test above fails then the indices must be compatible */
111073111250
return 1;
@@ -111543,15 +111720,12 @@
111543111720
if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111544111721
sqlite3DbFree(db, azCols);
111545111722
111546111723
rc = sqlite3ApiExit(db, rc);
111547111724
if( rc!=SQLITE_OK && pzErrMsg ){
111548
- int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
111549
- *pzErrMsg = sqlite3Malloc(nErrMsg);
111550
- if( *pzErrMsg ){
111551
- memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
111552
- }else{
111725
+ *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));
111726
+ if( *pzErrMsg==0 ){
111553111727
rc = SQLITE_NOMEM_BKPT;
111554111728
sqlite3Error(db, SQLITE_NOMEM);
111555111729
}
111556111730
}else if( pzErrMsg ){
111557111731
*pzErrMsg = 0;
@@ -113415,11 +113589,11 @@
113415113589
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113416113590
{/* zName: */ "read_uncommitted",
113417113591
/* ePragTyp: */ PragTyp_FLAG,
113418113592
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113419113593
/* ColNames: */ 0, 0,
113420
- /* iArg: */ SQLITE_ReadUncommitted },
113594
+ /* iArg: */ SQLITE_ReadUncommit },
113421113595
{/* zName: */ "recursive_triggers",
113422113596
/* ePragTyp: */ PragTyp_FLAG,
113423113597
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113424113598
/* ColNames: */ 0, 0,
113425113599
/* iArg: */ SQLITE_RecTriggers },
@@ -113567,11 +113741,11 @@
113567113741
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113568113742
{/* zName: */ "writable_schema",
113569113743
/* ePragTyp: */ PragTyp_FLAG,
113570113744
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113571113745
/* ColNames: */ 0, 0,
113572
- /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
113746
+ /* iArg: */ SQLITE_WriteSchema },
113573113747
#endif
113574113748
};
113575113749
/* Number of pragmas: 60 on by default, 74 total. */
113576113750
113577113751
/************** End of pragma.h **********************************************/
@@ -116009,11 +116183,11 @@
116009116183
InitData *pData, /* Initialization context */
116010116184
const char *zObj, /* Object being parsed at the point of error */
116011116185
const char *zExtra /* Error information */
116012116186
){
116013116187
sqlite3 *db = pData->db;
116014
- if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
116188
+ if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
116015116189
char *z;
116016116190
if( zObj==0 ) zObj = "?";
116017116191
z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
116018116192
if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
116019116193
sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116296,12 +116470,12 @@
116296116470
}
116297116471
if( db->mallocFailed ){
116298116472
rc = SQLITE_NOMEM_BKPT;
116299116473
sqlite3ResetAllSchemasOfConnection(db);
116300116474
}
116301
- if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){
116302
- /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider
116475
+ if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
116476
+ /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
116303116477
** the schema loaded, even if errors occurred. In this situation the
116304116478
** current sqlite3_prepare() operation will fail, but the following one
116305116479
** will attempt to compile the supplied statement against whatever subset
116306116480
** of the schema was loaded before the error occurred. The primary
116307116481
** purpose of this is to allow access to the sqlite_master table
@@ -116497,11 +116671,11 @@
116497116671
*/
116498116672
static int sqlite3Prepare(
116499116673
sqlite3 *db, /* Database handle. */
116500116674
const char *zSql, /* UTF-8 encoded SQL statement. */
116501116675
int nBytes, /* Length of zSql in bytes. */
116502
- int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116676
+ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116503116677
Vdbe *pReprepare, /* VM being reprepared */
116504116678
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116505116679
const char **pzTail /* OUT: End of parsed string */
116506116680
){
116507116681
char *zErrMsg = 0; /* Error message */
@@ -116513,10 +116687,18 @@
116513116687
memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
116514116688
sParse.pReprepare = pReprepare;
116515116689
assert( ppStmt && *ppStmt==0 );
116516116690
/* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116517116691
assert( sqlite3_mutex_held(db->mutex) );
116692
+
116693
+ /* For a long-term use prepared statement avoid the use of
116694
+ ** lookaside memory.
116695
+ */
116696
+ if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
116697
+ sParse.disableLookaside++;
116698
+ db->lookaside.bDisable++;
116699
+ }
116518116700
116519116701
/* Check to verify that it is possible to get a read lock on all
116520116702
** database schemas. The inability to get a read lock indicates that
116521116703
** some other database connection is holding a write-lock, which in
116522116704
** turn means that the other connection has made uncommitted changes
@@ -116545,11 +116727,11 @@
116545116727
assert( sqlite3BtreeHoldsMutex(pBt) );
116546116728
rc = sqlite3BtreeSchemaLocked(pBt);
116547116729
if( rc ){
116548116730
const char *zDb = db->aDb[i].zDbSName;
116549116731
sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116550
- testcase( db->flags & SQLITE_ReadUncommitted );
116732
+ testcase( db->flags & SQLITE_ReadUncommit );
116551116733
goto end_prepare;
116552116734
}
116553116735
}
116554116736
}
116555116737
@@ -116613,12 +116795,11 @@
116613116795
}
116614116796
}
116615116797
#endif
116616116798
116617116799
if( db->init.busy==0 ){
116618
- Vdbe *pVdbe = sParse.pVdbe;
116619
- sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag);
116800
+ sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
116620116801
}
116621116802
if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116622116803
sqlite3VdbeFinalize(sParse.pVdbe);
116623116804
assert(!(*ppStmt));
116624116805
}else{
@@ -116648,11 +116829,11 @@
116648116829
}
116649116830
static int sqlite3LockAndPrepare(
116650116831
sqlite3 *db, /* Database handle. */
116651116832
const char *zSql, /* UTF-8 encoded SQL statement. */
116652116833
int nBytes, /* Length of zSql in bytes. */
116653
- int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116834
+ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116654116835
Vdbe *pOld, /* VM being reprepared */
116655116836
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116656116837
const char **pzTail /* OUT: End of parsed string */
116657116838
){
116658116839
int rc;
@@ -116664,14 +116845,14 @@
116664116845
if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116665116846
return SQLITE_MISUSE_BKPT;
116666116847
}
116667116848
sqlite3_mutex_enter(db->mutex);
116668116849
sqlite3BtreeEnterAll(db);
116669
- rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116850
+ rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116670116851
if( rc==SQLITE_SCHEMA ){
116671116852
sqlite3_finalize(*ppStmt);
116672
- rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116853
+ rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116673116854
}
116674116855
sqlite3BtreeLeaveAll(db);
116675116856
sqlite3_mutex_leave(db->mutex);
116676116857
assert( rc==SQLITE_OK || *ppStmt==0 );
116677116858
return rc;
@@ -116688,17 +116869,19 @@
116688116869
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116689116870
int rc;
116690116871
sqlite3_stmt *pNew;
116691116872
const char *zSql;
116692116873
sqlite3 *db;
116874
+ u8 prepFlags;
116693116875
116694116876
assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116695116877
zSql = sqlite3_sql((sqlite3_stmt *)p);
116696116878
assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116697116879
db = sqlite3VdbeDb(p);
116698116880
assert( sqlite3_mutex_held(db->mutex) );
116699
- rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);
116881
+ prepFlags = sqlite3VdbePrepareFlags(p);
116882
+ rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
116700116883
if( rc ){
116701116884
if( rc==SQLITE_NOMEM ){
116702116885
sqlite3OomFault(db);
116703116886
}
116704116887
assert( pNew==0 );
@@ -116740,11 +116923,27 @@
116740116923
int nBytes, /* Length of zSql in bytes. */
116741116924
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116742116925
const char **pzTail /* OUT: End of parsed string */
116743116926
){
116744116927
int rc;
116745
- rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
116928
+ rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
116929
+ ppStmt,pzTail);
116930
+ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116931
+ return rc;
116932
+}
116933
+SQLITE_API int sqlite3_prepare_v3(
116934
+ sqlite3 *db, /* Database handle. */
116935
+ const char *zSql, /* UTF-8 encoded SQL statement. */
116936
+ int nBytes, /* Length of zSql in bytes. */
116937
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116938
+ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116939
+ const char **pzTail /* OUT: End of parsed string */
116940
+){
116941
+ int rc;
116942
+ rc = sqlite3LockAndPrepare(db,zSql,nBytes,
116943
+ SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
116944
+ 0,ppStmt,pzTail);
116746116945
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116747116946
return rc;
116748116947
}
116749116948
116750116949
@@ -116754,11 +116953,11 @@
116754116953
*/
116755116954
static int sqlite3Prepare16(
116756116955
sqlite3 *db, /* Database handle. */
116757116956
const void *zSql, /* UTF-16 encoded SQL statement. */
116758116957
int nBytes, /* Length of zSql in bytes. */
116759
- int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */
116958
+ u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116760116959
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116761116960
const void **pzTail /* OUT: End of parsed string */
116762116961
){
116763116962
/* This function currently works by first transforming the UTF-16
116764116963
** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116782,11 +116981,11 @@
116782116981
nBytes = sz;
116783116982
}
116784116983
sqlite3_mutex_enter(db->mutex);
116785116984
zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116786116985
if( zSql8 ){
116787
- rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
116986
+ rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
116788116987
}
116789116988
116790116989
if( zTail8 && pzTail ){
116791116990
/* If sqlite3_prepare returns a tail pointer, we calculate the
116792116991
** equivalent pointer into the UTF-16 string by counting the unicode
@@ -116828,11 +117027,26 @@
116828117027
int nBytes, /* Length of zSql in bytes. */
116829117028
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116830117029
const void **pzTail /* OUT: End of parsed string */
116831117030
){
116832117031
int rc;
116833
- rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
117032
+ rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
117033
+ assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117034
+ return rc;
117035
+}
117036
+SQLITE_API int sqlite3_prepare16_v3(
117037
+ sqlite3 *db, /* Database handle. */
117038
+ const void *zSql, /* UTF-16 encoded SQL statement. */
117039
+ int nBytes, /* Length of zSql in bytes. */
117040
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117041
+ sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117042
+ const void **pzTail /* OUT: End of parsed string */
117043
+){
117044
+ int rc;
117045
+ rc = sqlite3Prepare16(db,zSql,nBytes,
117046
+ SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117047
+ ppStmt,pzTail);
116834117048
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116835117049
return rc;
116836117050
}
116837117051
116838117052
#endif /* SQLITE_OMIT_UTF16 */
@@ -121844,11 +122058,13 @@
121844122058
if( pItem->pSelect==0 ) continue;
121845122059
if( pItem->fg.viaCoroutine ) continue;
121846122060
if( pItem->zName==0 ) continue;
121847122061
if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
121848122062
if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
121849
- if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){
122063
+ if( sqlite3ExprCompare(0,
122064
+ pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
122065
+ ){
121850122066
/* The view was modified by some other optimization such as
121851122067
** pushDownWhereTerms() */
121852122068
continue;
121853122069
}
121854122070
return pItem;
@@ -128193,11 +128409,11 @@
128193128409
** If pExpr matches, then transform it into a reference to the index column
128194128410
** that contains the value of pExpr.
128195128411
*/
128196128412
static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
128197128413
IdxExprTrans *pX = p->u.pIdxTrans;
128198
- if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128414
+ if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128199128415
pExpr->op = TK_COLUMN;
128200128416
pExpr->iTable = pX->iIdxCur;
128201128417
pExpr->iColumn = pX->iIdxCol;
128202128418
pExpr->pTab = 0;
128203128419
return WRC_Prune;
@@ -129487,11 +129703,11 @@
129487129703
pList = pExpr->x.pList;
129488129704
pLeft = pList->a[1].pExpr;
129489129705
129490129706
pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129491129707
op = pRight->op;
129492
- if( op==TK_VARIABLE ){
129708
+ if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
129493129709
Vdbe *pReprepare = pParse->pReprepare;
129494129710
int iCol = pRight->iColumn;
129495129711
pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129496129712
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129497129713
z = (char *)sqlite3_value_text(pVal);
@@ -129677,12 +129893,12 @@
129677129893
if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129678129894
if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129679129895
&& (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129680129896
assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129681129897
assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129682
- if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129683
- if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
129898
+ if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129899
+ if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;
129684129900
/* If we reach this point, it means the two subterms can be combined */
129685129901
if( (eOp & (eOp-1))!=0 ){
129686129902
if( eOp & (WO_LT|WO_LE) ){
129687129903
eOp = WO_LE;
129688129904
}else{
@@ -130449,10 +130665,13 @@
130449130665
prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130450130666
if( (prereqExpr & prereqColumn)==0 ){
130451130667
Expr *pNewExpr;
130452130668
pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130453130669
0, sqlite3ExprDup(db, pRight, 0));
130670
+ if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
130671
+ ExprSetProperty(pNewExpr, EP_FromJoin);
130672
+ }
130454130673
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130455130674
testcase( idxNew==0 );
130456130675
pNewTerm = &pWC->a[idxNew];
130457130676
pNewTerm->prereqRight = prereqExpr;
130458130677
pNewTerm->leftCursor = pLeft->iTable;
@@ -133387,11 +133606,11 @@
133387133606
if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133388133607
}
133389133608
}else if( (aColExpr = pIndex->aColExpr)!=0 ){
133390133609
for(jj=0; jj<pIndex->nKeyCol; jj++){
133391133610
if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133392
- if( sqlite3ExprCompare(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133611
+ if( sqlite3ExprCompare(0, pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133393133612
return 1;
133394133613
}
133395133614
}
133396133615
}
133397133616
}
@@ -133420,18 +133639,20 @@
133420133639
** in the current query. Return true if it can be and false if not.
133421133640
*/
133422133641
static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133423133642
int i;
133424133643
WhereTerm *pTerm;
133644
+ Parse *pParse = pWC->pWInfo->pParse;
133425133645
while( pWhere->op==TK_AND ){
133426133646
if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133427133647
pWhere = pWhere->pRight;
133428133648
}
133649
+ if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
133429133650
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133430133651
Expr *pExpr = pTerm->pExpr;
133431
- if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
133432
- && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133652
+ if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133653
+ && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
133433133654
){
133434133655
return 1;
133435133656
}
133436133657
}
133437133658
return 0;
@@ -134406,11 +134627,12 @@
134406134627
if( iColumn>=(-1) ){
134407134628
if( pOBExpr->op!=TK_COLUMN ) continue;
134408134629
if( pOBExpr->iTable!=iCur ) continue;
134409134630
if( pOBExpr->iColumn!=iColumn ) continue;
134410134631
}else{
134411
- if( sqlite3ExprCompare(pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134632
+ if( sqlite3ExprCompare(0,
134633
+ pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134412134634
continue;
134413134635
}
134414134636
}
134415134637
if( iColumn>=0 ){
134416134638
pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134705,10 +134927,11 @@
134705134927
("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134706134928
aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134707134929
rUnsorted, rCost));
134708134930
}else{
134709134931
rCost = rUnsorted;
134932
+ rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
134710134933
}
134711134934
134712134935
/* Check to see if pWLoop should be added to the set of
134713134936
** mxChoice best-so-far paths.
134714134937
**
@@ -136126,19 +136349,19 @@
136126136349
#define sqlite3ParserARG_PDECL ,Parse *pParse
136127136350
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136128136351
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
136129136352
#define YYFALLBACK 1
136130136353
#define YYNSTATE 456
136131
-#define YYNRULE 332
136354
+#define YYNRULE 331
136132136355
#define YY_MAX_SHIFT 455
136133
-#define YY_MIN_SHIFTREDUCE 668
136134
-#define YY_MAX_SHIFTREDUCE 999
136135
-#define YY_MIN_REDUCE 1000
136136
-#define YY_MAX_REDUCE 1331
136137
-#define YY_ERROR_ACTION 1332
136138
-#define YY_ACCEPT_ACTION 1333
136139
-#define YY_NO_ACTION 1334
136356
+#define YY_MIN_SHIFTREDUCE 667
136357
+#define YY_MAX_SHIFTREDUCE 997
136358
+#define YY_MIN_REDUCE 998
136359
+#define YY_MAX_REDUCE 1328
136360
+#define YY_ERROR_ACTION 1329
136361
+#define YY_ACCEPT_ACTION 1330
136362
+#define YY_NO_ACTION 1331
136140136363
/************* End control #defines *******************************************/
136141136364
136142136365
/* Define the yytestcase() macro to be a no-op if is not already defined
136143136366
** otherwise.
136144136367
**
@@ -136208,167 +136431,167 @@
136208136431
** yy_default[] Default action for each state.
136209136432
**
136210136433
*********** Begin parsing tables **********************************************/
136211136434
#define YY_ACTTAB_COUNT (1566)
136212136435
static const YYACTIONTYPE yy_action[] = {
136213
- /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98,
136436
+ /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
136214136437
/* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136215
- /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813,
136216
- /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96,
136438
+ /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439
+ /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
136217136440
/* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136218
- /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136441
+ /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136219136442
/* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136220
- /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262,
136221
- /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791,
136222
- /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95,
136223
- /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96,
136224
- /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813,
136225
- /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90,
136226
- /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136443
+ /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444
+ /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445
+ /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446
+ /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447
+ /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448
+ /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449
+ /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136227136450
/* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136228
- /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75,
136229
- /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262,
136230
- /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371,
136231
- /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824,
136232
- /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380,
136233
- /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845,
136451
+ /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452
+ /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453
+ /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454
+ /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455
+ /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456
+ /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
136234136457
/* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136235
- /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132,
136236
- /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93,
136237
- /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334,
136238
- /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845,
136239
- /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96,
136458
+ /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459
+ /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460
+ /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461
+ /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462
+ /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
136240136463
/* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136241
- /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888,
136242
- /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959,
136243
- /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978,
136244
- /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702,
136245
- /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99,
136246
- /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136247
- /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94,
136248
- /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231,
136249
- /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25,
136250
- /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74,
136251
- /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813,
136252
- /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415,
136253
- /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856,
136254
- /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96,
136464
+ /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465
+ /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466
+ /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467
+ /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468
+ /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469
+ /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470
+ /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471
+ /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472
+ /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473
+ /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474
+ /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475
+ /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476
+ /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477
+ /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
136255136478
/* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136256
- /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262,
136257
- /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959,
136258
- /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711,
136259
- /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447,
136260
- /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178,
136261
- /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136479
+ /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480
+ /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481
+ /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482
+ /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483
+ /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484
+ /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136262136485
/* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136263
- /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916,
136264
- /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157,
136265
- /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415,
136266
- /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777,
136267
- /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52,
136268
- /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90,
136269
- /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136486
+ /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487
+ /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488
+ /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489
+ /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490
+ /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491
+ /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492
+ /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136270136493
/* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136271
- /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450,
136272
- /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420,
136273
- /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36,
136274
- /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425,
136275
- /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326,
136276
- /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845,
136494
+ /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495
+ /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496
+ /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497
+ /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498
+ /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499
+ /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
136277136500
/* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136278
- /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846,
136279
- /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350,
136280
- /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327,
136281
- /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978,
136282
- /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776,
136283
- /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99,
136284
- /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136285
- /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94,
136286
- /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978,
136287
- /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675,
136288
- /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99,
136289
- /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136501
+ /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502
+ /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503
+ /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504
+ /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505
+ /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506
+ /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507
+ /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508
+ /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509
+ /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510
+ /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511
+ /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512
+ /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136290136513
/* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136291
- /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450,
136292
- /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228,
136293
- /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31,
136294
- /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44,
136295
- /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268,
136296
- /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856,
136297
- /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96,
136514
+ /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515
+ /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516
+ /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517
+ /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518
+ /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519
+ /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520
+ /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
136298136521
/* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136299
- /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48,
136300
- /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245,
136301
- /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817,
136302
- /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124,
136522
+ /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523
+ /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524
+ /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525
+ /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
136303136526
/* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136304
- /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136527
+ /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136305136528
/* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136306
- /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817,
136307
- /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944,
136308
- /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107,
136309
- /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136529
+ /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530
+ /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531
+ /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532
+ /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136310136533
/* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136311
- /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742,
136312
- /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133,
136313
- /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121,
136314
- /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97,
136315
- /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95,
136534
+ /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535
+ /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536
+ /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537
+ /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538
+ /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
136316136539
/* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136317
- /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263,
136318
- /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112,
136319
- /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97,
136540
+ /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541
+ /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542
+ /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
136320136543
/* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136321
- /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345,
136322
- /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709,
136323
- /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110,
136324
- /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97,
136325
- /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95,
136544
+ /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545
+ /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546
+ /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547
+ /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548
+ /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
136326136549
/* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136327
- /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785,
136328
- /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55,
136329
- /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709,
136330
- /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120,
136331
- /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26,
136332
- /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390,
136550
+ /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551
+ /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552
+ /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553
+ /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554
+ /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555
+ /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
136333136556
/* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136334
- /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730,
136335
- /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819,
136336
- /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3,
136337
- /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824,
136338
- /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951,
136339
- /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7,
136340
- /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713,
136341
- /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205,
136342
- /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144,
136343
- /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366,
136344
- /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140,
136345
- /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683,
136346
- /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383,
136347
- /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824,
136348
- /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271,
136349
- /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85,
136350
- /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711,
136351
- /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724,
136352
- /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290,
136353
- /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827,
136354
- /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434,
136557
+ /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558
+ /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559
+ /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560
+ /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561
+ /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562
+ /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563
+ /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564
+ /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565
+ /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566
+ /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567
+ /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568
+ /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569
+ /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570
+ /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571
+ /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572
+ /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573
+ /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574
+ /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575
+ /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576
+ /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577
+ /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
136355136578
/* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136356
- /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217,
136357
- /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669,
136579
+ /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580
+ /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
136358136581
/* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136359
- /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889,
136360
- /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63,
136361
- /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13,
136362
- /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19,
136363
- /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722,
136364
- /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830,
136365
- /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220,
136366
- /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18,
136367
- /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163,
136368
- /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695,
136369
- /* 1560 */ 87, 312, 309, 947, 1291, 1290,
136582
+ /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583
+ /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584
+ /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585
+ /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586
+ /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587
+ /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588
+ /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589
+ /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590
+ /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591
+ /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592
+ /* 1560 */ 87, 312, 309, 945, 1288, 1287,
136370136593
};
136371136594
static const YYCODETYPE yy_lookahead[] = {
136372136595
/* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136373136596
/* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136374136597
/* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136617,56 +136840,56 @@
136617136840
/* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136618136841
/* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136619136842
/* 320 */ 1280, 1281, 1264, 1269, 1283,
136620136843
};
136621136844
static const YYACTIONTYPE yy_default[] = {
136622
- /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
136623
- /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
136624
- /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
136625
- /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
136626
- /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
136627
- /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
136628
- /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136629
- /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136630
- /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136631
- /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136632
- /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
136633
- /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
136634
- /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
136635
- /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136636
- /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136637
- /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
136638
- /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
136639
- /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136640
- /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
136641
- /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136642
- /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
136643
- /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
136644
- /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
136645
- /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
136646
- /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
136647
- /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
136648
- /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
136649
- /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
136650
- /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
136651
- /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
136652
- /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
136653
- /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
136654
- /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
136655
- /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
136656
- /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136657
- /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
136658
- /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136659
- /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
136660
- /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
136661
- /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136662
- /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136663
- /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
136664
- /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
136665
- /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
136666
- /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
136667
- /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
136845
+ /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846
+ /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847
+ /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848
+ /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849
+ /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850
+ /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851
+ /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852
+ /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853
+ /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854
+ /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855
+ /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856
+ /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857
+ /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858
+ /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859
+ /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860
+ /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861
+ /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862
+ /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863
+ /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864
+ /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865
+ /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866
+ /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867
+ /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868
+ /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869
+ /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870
+ /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871
+ /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872
+ /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873
+ /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874
+ /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875
+ /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876
+ /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877
+ /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878
+ /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879
+ /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880
+ /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881
+ /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882
+ /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883
+ /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884
+ /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885
+ /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886
+ /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887
+ /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888
+ /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889
+ /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890
+ /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
136668136891
};
136669136892
/********** End of lemon-generated parsing tables *****************************/
136670136893
136671136894
/* The next table maps tokens (terminal symbols) into fallback tokens.
136672136895
** If a construct like the following:
@@ -136796,10 +137019,11 @@
136796137019
int yystksz; /* Current side of the stack */
136797137020
yyStackEntry *yystack; /* The parser's stack */
136798137021
yyStackEntry yystk0; /* First stack entry */
136799137022
#else
136800137023
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
137024
+ yyStackEntry *yystackEnd; /* Last entry in the stack */
136801137025
#endif
136802137026
};
136803137027
typedef struct yyParser yyParser;
136804137028
136805137029
#ifndef NDEBUG
@@ -137134,114 +137358,113 @@
137134137358
/* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137135137359
/* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137136137360
/* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137137137361
/* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137138137362
/* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137139
- /* 228 */ "trigger_time ::= BEFORE",
137140
- /* 229 */ "trigger_time ::= AFTER",
137141
- /* 230 */ "trigger_time ::= INSTEAD OF",
137142
- /* 231 */ "trigger_time ::=",
137143
- /* 232 */ "trigger_event ::= DELETE|INSERT",
137144
- /* 233 */ "trigger_event ::= UPDATE",
137145
- /* 234 */ "trigger_event ::= UPDATE OF idlist",
137146
- /* 235 */ "when_clause ::=",
137147
- /* 236 */ "when_clause ::= WHEN expr",
137148
- /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137149
- /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137150
- /* 239 */ "trnm ::= nm DOT nm",
137151
- /* 240 */ "tridxby ::= INDEXED BY nm",
137152
- /* 241 */ "tridxby ::= NOT INDEXED",
137153
- /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137154
- /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137155
- /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137156
- /* 245 */ "trigger_cmd ::= select",
137157
- /* 246 */ "expr ::= RAISE LP IGNORE RP",
137158
- /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137159
- /* 248 */ "raisetype ::= ROLLBACK",
137160
- /* 249 */ "raisetype ::= ABORT",
137161
- /* 250 */ "raisetype ::= FAIL",
137162
- /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
137163
- /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137164
- /* 253 */ "cmd ::= DETACH database_kw_opt expr",
137165
- /* 254 */ "key_opt ::=",
137166
- /* 255 */ "key_opt ::= KEY expr",
137167
- /* 256 */ "cmd ::= REINDEX",
137168
- /* 257 */ "cmd ::= REINDEX nm dbnm",
137169
- /* 258 */ "cmd ::= ANALYZE",
137170
- /* 259 */ "cmd ::= ANALYZE nm dbnm",
137171
- /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137172
- /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137173
- /* 262 */ "add_column_fullname ::= fullname",
137174
- /* 263 */ "cmd ::= create_vtab",
137175
- /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
137176
- /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137177
- /* 266 */ "vtabarg ::=",
137178
- /* 267 */ "vtabargtoken ::= ANY",
137179
- /* 268 */ "vtabargtoken ::= lp anylist RP",
137180
- /* 269 */ "lp ::= LP",
137181
- /* 270 */ "with ::=",
137182
- /* 271 */ "with ::= WITH wqlist",
137183
- /* 272 */ "with ::= WITH RECURSIVE wqlist",
137184
- /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137185
- /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137186
- /* 275 */ "input ::= cmdlist",
137187
- /* 276 */ "cmdlist ::= cmdlist ecmd",
137188
- /* 277 */ "cmdlist ::= ecmd",
137189
- /* 278 */ "ecmd ::= SEMI",
137190
- /* 279 */ "ecmd ::= explain cmdx SEMI",
137191
- /* 280 */ "explain ::=",
137192
- /* 281 */ "trans_opt ::=",
137193
- /* 282 */ "trans_opt ::= TRANSACTION",
137194
- /* 283 */ "trans_opt ::= TRANSACTION nm",
137195
- /* 284 */ "savepoint_opt ::= SAVEPOINT",
137196
- /* 285 */ "savepoint_opt ::=",
137197
- /* 286 */ "cmd ::= create_table create_table_args",
137198
- /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
137199
- /* 288 */ "columnlist ::= columnname carglist",
137200
- /* 289 */ "nm ::= ID|INDEXED",
137201
- /* 290 */ "nm ::= STRING",
137202
- /* 291 */ "nm ::= JOIN_KW",
137203
- /* 292 */ "typetoken ::= typename",
137204
- /* 293 */ "typename ::= ID|STRING",
137205
- /* 294 */ "signed ::= plus_num",
137206
- /* 295 */ "signed ::= minus_num",
137207
- /* 296 */ "carglist ::= carglist ccons",
137208
- /* 297 */ "carglist ::=",
137209
- /* 298 */ "ccons ::= NULL onconf",
137210
- /* 299 */ "conslist_opt ::= COMMA conslist",
137211
- /* 300 */ "conslist ::= conslist tconscomma tcons",
137212
- /* 301 */ "conslist ::= tcons",
137213
- /* 302 */ "tconscomma ::=",
137214
- /* 303 */ "defer_subclause_opt ::= defer_subclause",
137215
- /* 304 */ "resolvetype ::= raisetype",
137216
- /* 305 */ "selectnowith ::= oneselect",
137217
- /* 306 */ "oneselect ::= values",
137218
- /* 307 */ "sclp ::= selcollist COMMA",
137219
- /* 308 */ "as ::= ID|STRING",
137220
- /* 309 */ "expr ::= term",
137221
- /* 310 */ "likeop ::= LIKE_KW|MATCH",
137222
- /* 311 */ "exprlist ::= nexprlist",
137223
- /* 312 */ "nmnum ::= plus_num",
137224
- /* 313 */ "nmnum ::= nm",
137225
- /* 314 */ "nmnum ::= ON",
137226
- /* 315 */ "nmnum ::= DELETE",
137227
- /* 316 */ "nmnum ::= DEFAULT",
137228
- /* 317 */ "plus_num ::= INTEGER|FLOAT",
137229
- /* 318 */ "foreach_clause ::=",
137230
- /* 319 */ "foreach_clause ::= FOR EACH ROW",
137231
- /* 320 */ "trnm ::= nm",
137232
- /* 321 */ "tridxby ::=",
137233
- /* 322 */ "database_kw_opt ::= DATABASE",
137234
- /* 323 */ "database_kw_opt ::=",
137235
- /* 324 */ "kwcolumn_opt ::=",
137236
- /* 325 */ "kwcolumn_opt ::= COLUMNKW",
137237
- /* 326 */ "vtabarglist ::= vtabarg",
137238
- /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137239
- /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
137240
- /* 329 */ "anylist ::=",
137241
- /* 330 */ "anylist ::= anylist LP anylist RP",
137242
- /* 331 */ "anylist ::= anylist ANY",
137363
+ /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364
+ /* 229 */ "trigger_time ::= INSTEAD OF",
137365
+ /* 230 */ "trigger_time ::=",
137366
+ /* 231 */ "trigger_event ::= DELETE|INSERT",
137367
+ /* 232 */ "trigger_event ::= UPDATE",
137368
+ /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369
+ /* 234 */ "when_clause ::=",
137370
+ /* 235 */ "when_clause ::= WHEN expr",
137371
+ /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372
+ /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373
+ /* 238 */ "trnm ::= nm DOT nm",
137374
+ /* 239 */ "tridxby ::= INDEXED BY nm",
137375
+ /* 240 */ "tridxby ::= NOT INDEXED",
137376
+ /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377
+ /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378
+ /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379
+ /* 244 */ "trigger_cmd ::= select",
137380
+ /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381
+ /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382
+ /* 247 */ "raisetype ::= ROLLBACK",
137383
+ /* 248 */ "raisetype ::= ABORT",
137384
+ /* 249 */ "raisetype ::= FAIL",
137385
+ /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386
+ /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387
+ /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388
+ /* 253 */ "key_opt ::=",
137389
+ /* 254 */ "key_opt ::= KEY expr",
137390
+ /* 255 */ "cmd ::= REINDEX",
137391
+ /* 256 */ "cmd ::= REINDEX nm dbnm",
137392
+ /* 257 */ "cmd ::= ANALYZE",
137393
+ /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394
+ /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395
+ /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396
+ /* 261 */ "add_column_fullname ::= fullname",
137397
+ /* 262 */ "cmd ::= create_vtab",
137398
+ /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399
+ /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400
+ /* 265 */ "vtabarg ::=",
137401
+ /* 266 */ "vtabargtoken ::= ANY",
137402
+ /* 267 */ "vtabargtoken ::= lp anylist RP",
137403
+ /* 268 */ "lp ::= LP",
137404
+ /* 269 */ "with ::=",
137405
+ /* 270 */ "with ::= WITH wqlist",
137406
+ /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407
+ /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408
+ /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409
+ /* 274 */ "input ::= cmdlist",
137410
+ /* 275 */ "cmdlist ::= cmdlist ecmd",
137411
+ /* 276 */ "cmdlist ::= ecmd",
137412
+ /* 277 */ "ecmd ::= SEMI",
137413
+ /* 278 */ "ecmd ::= explain cmdx SEMI",
137414
+ /* 279 */ "explain ::=",
137415
+ /* 280 */ "trans_opt ::=",
137416
+ /* 281 */ "trans_opt ::= TRANSACTION",
137417
+ /* 282 */ "trans_opt ::= TRANSACTION nm",
137418
+ /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419
+ /* 284 */ "savepoint_opt ::=",
137420
+ /* 285 */ "cmd ::= create_table create_table_args",
137421
+ /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422
+ /* 287 */ "columnlist ::= columnname carglist",
137423
+ /* 288 */ "nm ::= ID|INDEXED",
137424
+ /* 289 */ "nm ::= STRING",
137425
+ /* 290 */ "nm ::= JOIN_KW",
137426
+ /* 291 */ "typetoken ::= typename",
137427
+ /* 292 */ "typename ::= ID|STRING",
137428
+ /* 293 */ "signed ::= plus_num",
137429
+ /* 294 */ "signed ::= minus_num",
137430
+ /* 295 */ "carglist ::= carglist ccons",
137431
+ /* 296 */ "carglist ::=",
137432
+ /* 297 */ "ccons ::= NULL onconf",
137433
+ /* 298 */ "conslist_opt ::= COMMA conslist",
137434
+ /* 299 */ "conslist ::= conslist tconscomma tcons",
137435
+ /* 300 */ "conslist ::= tcons",
137436
+ /* 301 */ "tconscomma ::=",
137437
+ /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438
+ /* 303 */ "resolvetype ::= raisetype",
137439
+ /* 304 */ "selectnowith ::= oneselect",
137440
+ /* 305 */ "oneselect ::= values",
137441
+ /* 306 */ "sclp ::= selcollist COMMA",
137442
+ /* 307 */ "as ::= ID|STRING",
137443
+ /* 308 */ "expr ::= term",
137444
+ /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445
+ /* 310 */ "exprlist ::= nexprlist",
137446
+ /* 311 */ "nmnum ::= plus_num",
137447
+ /* 312 */ "nmnum ::= nm",
137448
+ /* 313 */ "nmnum ::= ON",
137449
+ /* 314 */ "nmnum ::= DELETE",
137450
+ /* 315 */ "nmnum ::= DEFAULT",
137451
+ /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452
+ /* 317 */ "foreach_clause ::=",
137453
+ /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454
+ /* 319 */ "trnm ::= nm",
137455
+ /* 320 */ "tridxby ::=",
137456
+ /* 321 */ "database_kw_opt ::= DATABASE",
137457
+ /* 322 */ "database_kw_opt ::=",
137458
+ /* 323 */ "kwcolumn_opt ::=",
137459
+ /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460
+ /* 325 */ "vtabarglist ::= vtabarg",
137461
+ /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462
+ /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463
+ /* 328 */ "anylist ::=",
137464
+ /* 329 */ "anylist ::= anylist LP anylist RP",
137465
+ /* 330 */ "anylist ::= anylist ANY",
137243137466
};
137244137467
#endif /* NDEBUG */
137245137468
137246137469
137247137470
#if YYSTACKDEPTH<=0
@@ -137306,10 +137529,11 @@
137306137529
pParser->yyerrcnt = -1;
137307137530
#endif
137308137531
pParser->yytos = pParser->yystack;
137309137532
pParser->yystack[0].stateno = 0;
137310137533
pParser->yystack[0].major = 0;
137534
+ pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137311137535
}
137312137536
137313137537
#ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137314137538
/*
137315137539
** This function allocates a new parser.
@@ -137648,11 +137872,11 @@
137648137872
yypParser->yyhwm++;
137649137873
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137650137874
}
137651137875
#endif
137652137876
#if YYSTACKDEPTH>0
137653
- if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
137877
+ if( yypParser->yytos>yypParser->yystackEnd ){
137654137878
yypParser->yytos--;
137655137879
yyStackOverflow(yypParser);
137656137880
return;
137657137881
}
137658137882
#else
@@ -137676,345 +137900,344 @@
137676137900
137677137901
/* The following table contains information about every rule that
137678137902
** is used during the reduce.
137679137903
*/
137680137904
static const struct {
137681
- YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137682
- unsigned char nrhs; /* Number of right-hand side symbols in the rule */
137905
+ YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137906
+ signed char nrhs; /* Negative of the number of RHS symbols in the rule */
137683137907
} yyRuleInfo[] = {
137684
- { 147, 1 },
137685
- { 147, 3 },
137686
- { 148, 1 },
137687
- { 149, 3 },
137908
+ { 147, -1 },
137909
+ { 147, -3 },
137910
+ { 148, -1 },
137911
+ { 149, -3 },
137688137912
{ 150, 0 },
137689
- { 150, 1 },
137690
- { 150, 1 },
137691
- { 150, 1 },
137692
- { 149, 2 },
137693
- { 149, 2 },
137694
- { 149, 2 },
137695
- { 149, 2 },
137696
- { 149, 3 },
137697
- { 149, 5 },
137698
- { 154, 6 },
137699
- { 156, 1 },
137913
+ { 150, -1 },
137914
+ { 150, -1 },
137915
+ { 150, -1 },
137916
+ { 149, -2 },
137917
+ { 149, -2 },
137918
+ { 149, -2 },
137919
+ { 149, -2 },
137920
+ { 149, -3 },
137921
+ { 149, -5 },
137922
+ { 154, -6 },
137923
+ { 156, -1 },
137700137924
{ 158, 0 },
137701
- { 158, 3 },
137702
- { 157, 1 },
137925
+ { 158, -3 },
137926
+ { 157, -1 },
137703137927
{ 157, 0 },
137704
- { 155, 5 },
137705
- { 155, 2 },
137928
+ { 155, -5 },
137929
+ { 155, -2 },
137706137930
{ 162, 0 },
137707
- { 162, 2 },
137708
- { 164, 2 },
137931
+ { 162, -2 },
137932
+ { 164, -2 },
137709137933
{ 166, 0 },
137710
- { 166, 4 },
137711
- { 166, 6 },
137712
- { 167, 2 },
137713
- { 171, 2 },
137714
- { 171, 2 },
137715
- { 171, 4 },
137716
- { 171, 3 },
137717
- { 171, 3 },
137718
- { 171, 2 },
137719
- { 171, 3 },
137720
- { 171, 5 },
137721
- { 171, 2 },
137722
- { 171, 4 },
137723
- { 171, 4 },
137724
- { 171, 1 },
137725
- { 171, 2 },
137934
+ { 166, -4 },
137935
+ { 166, -6 },
137936
+ { 167, -2 },
137937
+ { 171, -2 },
137938
+ { 171, -2 },
137939
+ { 171, -4 },
137940
+ { 171, -3 },
137941
+ { 171, -3 },
137942
+ { 171, -2 },
137943
+ { 171, -3 },
137944
+ { 171, -5 },
137945
+ { 171, -2 },
137946
+ { 171, -4 },
137947
+ { 171, -4 },
137948
+ { 171, -1 },
137949
+ { 171, -2 },
137726137950
{ 176, 0 },
137727
- { 176, 1 },
137951
+ { 176, -1 },
137728137952
{ 178, 0 },
137729
- { 178, 2 },
137730
- { 180, 2 },
137731
- { 180, 3 },
137732
- { 180, 3 },
137733
- { 180, 3 },
137734
- { 181, 2 },
137735
- { 181, 2 },
137736
- { 181, 1 },
137737
- { 181, 1 },
137738
- { 181, 2 },
137739
- { 179, 3 },
137740
- { 179, 2 },
137953
+ { 178, -2 },
137954
+ { 180, -2 },
137955
+ { 180, -3 },
137956
+ { 180, -3 },
137957
+ { 180, -3 },
137958
+ { 181, -2 },
137959
+ { 181, -2 },
137960
+ { 181, -1 },
137961
+ { 181, -1 },
137962
+ { 181, -2 },
137963
+ { 179, -3 },
137964
+ { 179, -2 },
137741137965
{ 182, 0 },
137742
- { 182, 2 },
137743
- { 182, 2 },
137966
+ { 182, -2 },
137967
+ { 182, -2 },
137744137968
{ 161, 0 },
137745
- { 184, 1 },
137746
- { 185, 2 },
137747
- { 185, 7 },
137748
- { 185, 5 },
137749
- { 185, 5 },
137750
- { 185, 10 },
137969
+ { 184, -1 },
137970
+ { 185, -2 },
137971
+ { 185, -7 },
137972
+ { 185, -5 },
137973
+ { 185, -5 },
137974
+ { 185, -10 },
137751137975
{ 188, 0 },
137752137976
{ 174, 0 },
137753
- { 174, 3 },
137977
+ { 174, -3 },
137754137978
{ 189, 0 },
137755
- { 189, 2 },
137756
- { 190, 1 },
137757
- { 190, 1 },
137758
- { 149, 4 },
137759
- { 192, 2 },
137979
+ { 189, -2 },
137980
+ { 190, -1 },
137981
+ { 190, -1 },
137982
+ { 149, -4 },
137983
+ { 192, -2 },
137760137984
{ 192, 0 },
137761
- { 149, 9 },
137762
- { 149, 4 },
137763
- { 149, 1 },
137764
- { 163, 2 },
137765
- { 194, 3 },
137766
- { 197, 1 },
137767
- { 197, 2 },
137768
- { 197, 1 },
137769
- { 195, 9 },
137770
- { 206, 4 },
137771
- { 206, 5 },
137772
- { 198, 1 },
137773
- { 198, 1 },
137985
+ { 149, -9 },
137986
+ { 149, -4 },
137987
+ { 149, -1 },
137988
+ { 163, -2 },
137989
+ { 194, -3 },
137990
+ { 197, -1 },
137991
+ { 197, -2 },
137992
+ { 197, -1 },
137993
+ { 195, -9 },
137994
+ { 206, -4 },
137995
+ { 206, -5 },
137996
+ { 198, -1 },
137997
+ { 198, -1 },
137774137998
{ 198, 0 },
137775137999
{ 209, 0 },
137776
- { 199, 3 },
137777
- { 199, 2 },
137778
- { 199, 4 },
137779
- { 210, 2 },
138000
+ { 199, -3 },
138001
+ { 199, -2 },
138002
+ { 199, -4 },
138003
+ { 210, -2 },
137780138004
{ 210, 0 },
137781138005
{ 200, 0 },
137782
- { 200, 2 },
137783
- { 212, 2 },
138006
+ { 200, -2 },
138007
+ { 212, -2 },
137784138008
{ 212, 0 },
137785
- { 211, 7 },
137786
- { 211, 9 },
137787
- { 211, 7 },
137788
- { 211, 7 },
138009
+ { 211, -7 },
138010
+ { 211, -9 },
138011
+ { 211, -7 },
138012
+ { 211, -7 },
137789138013
{ 159, 0 },
137790
- { 159, 2 },
137791
- { 193, 2 },
137792
- { 213, 1 },
137793
- { 213, 2 },
137794
- { 213, 3 },
137795
- { 213, 4 },
137796
- { 215, 2 },
138014
+ { 159, -2 },
138015
+ { 193, -2 },
138016
+ { 213, -1 },
138017
+ { 213, -2 },
138018
+ { 213, -3 },
138019
+ { 213, -4 },
138020
+ { 215, -2 },
137797138021
{ 215, 0 },
137798138022
{ 214, 0 },
137799
- { 214, 3 },
137800
- { 214, 2 },
137801
- { 216, 4 },
138023
+ { 214, -3 },
138024
+ { 214, -2 },
138025
+ { 216, -4 },
137802138026
{ 216, 0 },
137803138027
{ 204, 0 },
137804
- { 204, 3 },
137805
- { 186, 4 },
137806
- { 186, 2 },
137807
- { 175, 1 },
137808
- { 175, 1 },
138028
+ { 204, -3 },
138029
+ { 186, -4 },
138030
+ { 186, -2 },
138031
+ { 175, -1 },
138032
+ { 175, -1 },
137809138033
{ 175, 0 },
137810138034
{ 202, 0 },
137811
- { 202, 3 },
138035
+ { 202, -3 },
137812138036
{ 203, 0 },
137813
- { 203, 2 },
138037
+ { 203, -2 },
137814138038
{ 205, 0 },
137815
- { 205, 2 },
137816
- { 205, 4 },
137817
- { 205, 4 },
137818
- { 149, 6 },
138039
+ { 205, -2 },
138040
+ { 205, -4 },
138041
+ { 205, -4 },
138042
+ { 149, -6 },
137819138043
{ 201, 0 },
137820
- { 201, 2 },
137821
- { 149, 8 },
137822
- { 218, 5 },
137823
- { 218, 7 },
137824
- { 218, 3 },
137825
- { 218, 5 },
137826
- { 149, 6 },
137827
- { 149, 7 },
137828
- { 219, 2 },
137829
- { 219, 1 },
138044
+ { 201, -2 },
138045
+ { 149, -8 },
138046
+ { 218, -5 },
138047
+ { 218, -7 },
138048
+ { 218, -3 },
138049
+ { 218, -5 },
138050
+ { 149, -6 },
138051
+ { 149, -7 },
138052
+ { 219, -2 },
138053
+ { 219, -1 },
137830138054
{ 220, 0 },
137831
- { 220, 3 },
137832
- { 217, 3 },
137833
- { 217, 1 },
137834
- { 173, 3 },
137835
- { 172, 1 },
137836
- { 173, 1 },
137837
- { 173, 1 },
137838
- { 173, 3 },
137839
- { 173, 5 },
137840
- { 172, 1 },
137841
- { 172, 1 },
137842
- { 172, 1 },
137843
- { 173, 1 },
137844
- { 173, 3 },
137845
- { 173, 6 },
137846
- { 173, 5 },
137847
- { 173, 4 },
137848
- { 172, 1 },
137849
- { 173, 5 },
137850
- { 173, 3 },
137851
- { 173, 3 },
137852
- { 173, 3 },
137853
- { 173, 3 },
137854
- { 173, 3 },
137855
- { 173, 3 },
137856
- { 173, 3 },
137857
- { 173, 3 },
137858
- { 221, 2 },
137859
- { 173, 3 },
137860
- { 173, 5 },
137861
- { 173, 2 },
137862
- { 173, 3 },
137863
- { 173, 3 },
137864
- { 173, 4 },
137865
- { 173, 2 },
137866
- { 173, 2 },
137867
- { 173, 2 },
137868
- { 173, 2 },
137869
- { 222, 1 },
137870
- { 222, 2 },
137871
- { 173, 5 },
137872
- { 223, 1 },
137873
- { 223, 2 },
137874
- { 173, 5 },
137875
- { 173, 3 },
137876
- { 173, 5 },
137877
- { 173, 5 },
137878
- { 173, 4 },
137879
- { 173, 5 },
137880
- { 226, 5 },
137881
- { 226, 4 },
137882
- { 227, 2 },
138055
+ { 220, -3 },
138056
+ { 217, -3 },
138057
+ { 217, -1 },
138058
+ { 173, -3 },
138059
+ { 172, -1 },
138060
+ { 173, -1 },
138061
+ { 173, -1 },
138062
+ { 173, -3 },
138063
+ { 173, -5 },
138064
+ { 172, -1 },
138065
+ { 172, -1 },
138066
+ { 172, -1 },
138067
+ { 173, -1 },
138068
+ { 173, -3 },
138069
+ { 173, -6 },
138070
+ { 173, -5 },
138071
+ { 173, -4 },
138072
+ { 172, -1 },
138073
+ { 173, -5 },
138074
+ { 173, -3 },
138075
+ { 173, -3 },
138076
+ { 173, -3 },
138077
+ { 173, -3 },
138078
+ { 173, -3 },
138079
+ { 173, -3 },
138080
+ { 173, -3 },
138081
+ { 173, -3 },
138082
+ { 221, -2 },
138083
+ { 173, -3 },
138084
+ { 173, -5 },
138085
+ { 173, -2 },
138086
+ { 173, -3 },
138087
+ { 173, -3 },
138088
+ { 173, -4 },
138089
+ { 173, -2 },
138090
+ { 173, -2 },
138091
+ { 173, -2 },
138092
+ { 173, -2 },
138093
+ { 222, -1 },
138094
+ { 222, -2 },
138095
+ { 173, -5 },
138096
+ { 223, -1 },
138097
+ { 223, -2 },
138098
+ { 173, -5 },
138099
+ { 173, -3 },
138100
+ { 173, -5 },
138101
+ { 173, -5 },
138102
+ { 173, -4 },
138103
+ { 173, -5 },
138104
+ { 226, -5 },
138105
+ { 226, -4 },
138106
+ { 227, -2 },
137883138107
{ 227, 0 },
137884
- { 225, 1 },
138108
+ { 225, -1 },
137885138109
{ 225, 0 },
137886138110
{ 208, 0 },
137887
- { 207, 3 },
137888
- { 207, 1 },
138111
+ { 207, -3 },
138112
+ { 207, -1 },
137889138113
{ 224, 0 },
137890
- { 224, 3 },
137891
- { 149, 12 },
137892
- { 228, 1 },
138114
+ { 224, -3 },
138115
+ { 149, -12 },
138116
+ { 228, -1 },
137893138117
{ 228, 0 },
137894138118
{ 177, 0 },
137895
- { 177, 3 },
137896
- { 187, 5 },
137897
- { 187, 3 },
138119
+ { 177, -3 },
138120
+ { 187, -5 },
138121
+ { 187, -3 },
137898138122
{ 229, 0 },
137899
- { 229, 2 },
137900
- { 149, 4 },
137901
- { 149, 1 },
137902
- { 149, 2 },
137903
- { 149, 3 },
137904
- { 149, 5 },
137905
- { 149, 6 },
137906
- { 149, 5 },
137907
- { 149, 6 },
137908
- { 169, 2 },
137909
- { 170, 2 },
137910
- { 149, 5 },
137911
- { 231, 11 },
137912
- { 233, 1 },
137913
- { 233, 1 },
137914
- { 233, 2 },
138123
+ { 229, -2 },
138124
+ { 149, -4 },
138125
+ { 149, -1 },
138126
+ { 149, -2 },
138127
+ { 149, -3 },
138128
+ { 149, -5 },
138129
+ { 149, -6 },
138130
+ { 149, -5 },
138131
+ { 149, -6 },
138132
+ { 169, -2 },
138133
+ { 170, -2 },
138134
+ { 149, -5 },
138135
+ { 231, -11 },
138136
+ { 233, -1 },
138137
+ { 233, -2 },
137915138138
{ 233, 0 },
137916
- { 234, 1 },
137917
- { 234, 1 },
137918
- { 234, 3 },
138139
+ { 234, -1 },
138140
+ { 234, -1 },
138141
+ { 234, -3 },
137919138142
{ 236, 0 },
137920
- { 236, 2 },
137921
- { 232, 3 },
137922
- { 232, 2 },
137923
- { 238, 3 },
137924
- { 239, 3 },
137925
- { 239, 2 },
137926
- { 237, 7 },
137927
- { 237, 5 },
137928
- { 237, 5 },
137929
- { 237, 1 },
137930
- { 173, 4 },
137931
- { 173, 6 },
137932
- { 191, 1 },
137933
- { 191, 1 },
137934
- { 191, 1 },
137935
- { 149, 4 },
137936
- { 149, 6 },
137937
- { 149, 3 },
138143
+ { 236, -2 },
138144
+ { 232, -3 },
138145
+ { 232, -2 },
138146
+ { 238, -3 },
138147
+ { 239, -3 },
138148
+ { 239, -2 },
138149
+ { 237, -7 },
138150
+ { 237, -5 },
138151
+ { 237, -5 },
138152
+ { 237, -1 },
138153
+ { 173, -4 },
138154
+ { 173, -6 },
138155
+ { 191, -1 },
138156
+ { 191, -1 },
138157
+ { 191, -1 },
138158
+ { 149, -4 },
138159
+ { 149, -6 },
138160
+ { 149, -3 },
137938138161
{ 241, 0 },
137939
- { 241, 2 },
137940
- { 149, 1 },
137941
- { 149, 3 },
137942
- { 149, 1 },
137943
- { 149, 3 },
137944
- { 149, 6 },
137945
- { 149, 7 },
137946
- { 242, 1 },
137947
- { 149, 1 },
137948
- { 149, 4 },
137949
- { 244, 8 },
138162
+ { 241, -2 },
138163
+ { 149, -1 },
138164
+ { 149, -3 },
138165
+ { 149, -1 },
138166
+ { 149, -3 },
138167
+ { 149, -6 },
138168
+ { 149, -7 },
138169
+ { 242, -1 },
138170
+ { 149, -1 },
138171
+ { 149, -4 },
138172
+ { 244, -8 },
137950138173
{ 246, 0 },
137951
- { 247, 1 },
137952
- { 247, 3 },
137953
- { 248, 1 },
138174
+ { 247, -1 },
138175
+ { 247, -3 },
138176
+ { 248, -1 },
137954138177
{ 196, 0 },
137955
- { 196, 2 },
137956
- { 196, 3 },
137957
- { 250, 6 },
137958
- { 250, 8 },
137959
- { 144, 1 },
137960
- { 145, 2 },
137961
- { 145, 1 },
137962
- { 146, 1 },
137963
- { 146, 3 },
138178
+ { 196, -2 },
138179
+ { 196, -3 },
138180
+ { 250, -6 },
138181
+ { 250, -8 },
138182
+ { 144, -1 },
138183
+ { 145, -2 },
138184
+ { 145, -1 },
138185
+ { 146, -1 },
138186
+ { 146, -3 },
137964138187
{ 147, 0 },
137965138188
{ 151, 0 },
137966
- { 151, 1 },
137967
- { 151, 2 },
137968
- { 153, 1 },
138189
+ { 151, -1 },
138190
+ { 151, -2 },
138191
+ { 153, -1 },
137969138192
{ 153, 0 },
137970
- { 149, 2 },
137971
- { 160, 4 },
137972
- { 160, 2 },
137973
- { 152, 1 },
137974
- { 152, 1 },
137975
- { 152, 1 },
137976
- { 166, 1 },
137977
- { 167, 1 },
137978
- { 168, 1 },
137979
- { 168, 1 },
137980
- { 165, 2 },
138193
+ { 149, -2 },
138194
+ { 160, -4 },
138195
+ { 160, -2 },
138196
+ { 152, -1 },
138197
+ { 152, -1 },
138198
+ { 152, -1 },
138199
+ { 166, -1 },
138200
+ { 167, -1 },
138201
+ { 168, -1 },
138202
+ { 168, -1 },
138203
+ { 165, -2 },
137981138204
{ 165, 0 },
137982
- { 171, 2 },
137983
- { 161, 2 },
137984
- { 183, 3 },
137985
- { 183, 1 },
138205
+ { 171, -2 },
138206
+ { 161, -2 },
138207
+ { 183, -3 },
138208
+ { 183, -1 },
137986138209
{ 184, 0 },
137987
- { 188, 1 },
137988
- { 190, 1 },
137989
- { 194, 1 },
137990
- { 195, 1 },
137991
- { 209, 2 },
137992
- { 210, 1 },
137993
- { 173, 1 },
137994
- { 221, 1 },
137995
- { 208, 1 },
137996
- { 230, 1 },
137997
- { 230, 1 },
137998
- { 230, 1 },
137999
- { 230, 1 },
138000
- { 230, 1 },
138001
- { 169, 1 },
138210
+ { 188, -1 },
138211
+ { 190, -1 },
138212
+ { 194, -1 },
138213
+ { 195, -1 },
138214
+ { 209, -2 },
138215
+ { 210, -1 },
138216
+ { 173, -1 },
138217
+ { 221, -1 },
138218
+ { 208, -1 },
138219
+ { 230, -1 },
138220
+ { 230, -1 },
138221
+ { 230, -1 },
138222
+ { 230, -1 },
138223
+ { 230, -1 },
138224
+ { 169, -1 },
138002138225
{ 235, 0 },
138003
- { 235, 3 },
138004
- { 238, 1 },
138226
+ { 235, -3 },
138227
+ { 238, -1 },
138005138228
{ 239, 0 },
138006
- { 240, 1 },
138229
+ { 240, -1 },
138007138230
{ 240, 0 },
138008138231
{ 243, 0 },
138009
- { 243, 1 },
138010
- { 245, 1 },
138011
- { 245, 3 },
138012
- { 246, 2 },
138232
+ { 243, -1 },
138233
+ { 245, -1 },
138234
+ { 245, -3 },
138235
+ { 246, -2 },
138013138236
{ 249, 0 },
138014
- { 249, 4 },
138015
- { 249, 2 },
138237
+ { 249, -4 },
138238
+ { 249, -2 },
138016138239
};
138017138240
138018138241
static void yy_accept(yyParser*); /* Forward Declaration */
138019138242
138020138243
/*
@@ -138033,11 +138256,11 @@
138033138256
yymsp = yypParser->yytos;
138034138257
#ifndef NDEBUG
138035138258
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
138036138259
yysize = yyRuleInfo[yyruleno].nrhs;
138037138260
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
138038
- yyRuleName[yyruleno], yymsp[-yysize].stateno);
138261
+ yyRuleName[yyruleno], yymsp[yysize].stateno);
138039138262
}
138040138263
#endif /* NDEBUG */
138041138264
138042138265
/* Check that the stack is large enough to grow by a single entry
138043138266
** if the RHS of the rule is empty. This ensures that there is room
@@ -138048,11 +138271,11 @@
138048138271
yypParser->yyhwm++;
138049138272
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
138050138273
}
138051138274
#endif
138052138275
#if YYSTACKDEPTH>0
138053
- if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
138276
+ if( yypParser->yytos>=yypParser->yystackEnd ){
138054138277
yyStackOverflow(yypParser);
138055138278
return;
138056138279
}
138057138280
#else
138058138281
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139007,11 +139230,11 @@
139007139230
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139008139231
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139009139232
}
139010139233
break;
139011139234
case 208: /* uniqueflag ::= UNIQUE */
139012
- case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
139235
+ case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
139013139236
{yymsp[0].minor.yy194 = OE_Abort;}
139014139237
break;
139015139238
case 209: /* uniqueflag ::= */
139016139239
{yymsp[1].minor.yy194 = OE_None;}
139017139240
break;
@@ -139061,268 +139284,269 @@
139061139284
{
139062139285
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139063139286
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139064139287
}
139065139288
break;
139066
- case 228: /* trigger_time ::= BEFORE */
139067
-{ yymsp[0].minor.yy194 = TK_BEFORE; }
139289
+ case 228: /* trigger_time ::= BEFORE|AFTER */
139290
+{ yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139068139291
break;
139069
- case 229: /* trigger_time ::= AFTER */
139070
-{ yymsp[0].minor.yy194 = TK_AFTER; }
139071
- break;
139072
- case 230: /* trigger_time ::= INSTEAD OF */
139292
+ case 229: /* trigger_time ::= INSTEAD OF */
139073139293
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
139074139294
break;
139075
- case 231: /* trigger_time ::= */
139295
+ case 230: /* trigger_time ::= */
139076139296
{ yymsp[1].minor.yy194 = TK_BEFORE; }
139077139297
break;
139078
- case 232: /* trigger_event ::= DELETE|INSERT */
139079
- case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
139298
+ case 231: /* trigger_event ::= DELETE|INSERT */
139299
+ case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
139080139300
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139081139301
break;
139082
- case 234: /* trigger_event ::= UPDATE OF idlist */
139302
+ case 233: /* trigger_event ::= UPDATE OF idlist */
139083139303
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139084139304
break;
139085
- case 235: /* when_clause ::= */
139086
- case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
139305
+ case 234: /* when_clause ::= */
139306
+ case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
139087139307
{ yymsp[1].minor.yy72 = 0; }
139088139308
break;
139089
- case 236: /* when_clause ::= WHEN expr */
139090
- case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
139309
+ case 235: /* when_clause ::= WHEN expr */
139310
+ case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
139091139311
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139092139312
break;
139093
- case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139313
+ case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139094139314
{
139095139315
assert( yymsp[-2].minor.yy145!=0 );
139096139316
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139097139317
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139098139318
}
139099139319
break;
139100
- case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
139320
+ case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
139101139321
{
139102139322
assert( yymsp[-1].minor.yy145!=0 );
139103139323
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139104139324
}
139105139325
break;
139106
- case 239: /* trnm ::= nm DOT nm */
139326
+ case 238: /* trnm ::= nm DOT nm */
139107139327
{
139108139328
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139109139329
sqlite3ErrorMsg(pParse,
139110139330
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139111139331
"statements within triggers");
139112139332
}
139113139333
break;
139114
- case 240: /* tridxby ::= INDEXED BY nm */
139334
+ case 239: /* tridxby ::= INDEXED BY nm */
139115139335
{
139116139336
sqlite3ErrorMsg(pParse,
139117139337
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139118139338
"within triggers");
139119139339
}
139120139340
break;
139121
- case 241: /* tridxby ::= NOT INDEXED */
139341
+ case 240: /* tridxby ::= NOT INDEXED */
139122139342
{
139123139343
sqlite3ErrorMsg(pParse,
139124139344
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139125139345
"within triggers");
139126139346
}
139127139347
break;
139128
- case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139348
+ case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139129139349
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139130139350
break;
139131
- case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139351
+ case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139132139352
{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139133139353
break;
139134
- case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139354
+ case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139135139355
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139136139356
break;
139137
- case 245: /* trigger_cmd ::= select */
139357
+ case 244: /* trigger_cmd ::= select */
139138139358
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139139139359
break;
139140
- case 246: /* expr ::= RAISE LP IGNORE RP */
139360
+ case 245: /* expr ::= RAISE LP IGNORE RP */
139141139361
{
139142139362
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139143139363
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139144139364
if( yymsp[-3].minor.yy190.pExpr ){
139145139365
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139146139366
}
139147139367
}
139148139368
break;
139149
- case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
139369
+ case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
139150139370
{
139151139371
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139152139372
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139153139373
if( yymsp[-5].minor.yy190.pExpr ) {
139154139374
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139155139375
}
139156139376
}
139157139377
break;
139158
- case 248: /* raisetype ::= ROLLBACK */
139378
+ case 247: /* raisetype ::= ROLLBACK */
139159139379
{yymsp[0].minor.yy194 = OE_Rollback;}
139160139380
break;
139161
- case 250: /* raisetype ::= FAIL */
139381
+ case 249: /* raisetype ::= FAIL */
139162139382
{yymsp[0].minor.yy194 = OE_Fail;}
139163139383
break;
139164
- case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
139384
+ case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
139165139385
{
139166139386
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139167139387
}
139168139388
break;
139169
- case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139389
+ case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139170139390
{
139171139391
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139172139392
}
139173139393
break;
139174
- case 253: /* cmd ::= DETACH database_kw_opt expr */
139394
+ case 252: /* cmd ::= DETACH database_kw_opt expr */
139175139395
{
139176139396
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139177139397
}
139178139398
break;
139179
- case 256: /* cmd ::= REINDEX */
139399
+ case 255: /* cmd ::= REINDEX */
139180139400
{sqlite3Reindex(pParse, 0, 0);}
139181139401
break;
139182
- case 257: /* cmd ::= REINDEX nm dbnm */
139402
+ case 256: /* cmd ::= REINDEX nm dbnm */
139183139403
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139184139404
break;
139185
- case 258: /* cmd ::= ANALYZE */
139405
+ case 257: /* cmd ::= ANALYZE */
139186139406
{sqlite3Analyze(pParse, 0, 0);}
139187139407
break;
139188
- case 259: /* cmd ::= ANALYZE nm dbnm */
139408
+ case 258: /* cmd ::= ANALYZE nm dbnm */
139189139409
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139190139410
break;
139191
- case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139411
+ case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139192139412
{
139193139413
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139194139414
}
139195139415
break;
139196
- case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139416
+ case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139197139417
{
139198139418
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139199139419
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139200139420
}
139201139421
break;
139202
- case 262: /* add_column_fullname ::= fullname */
139422
+ case 261: /* add_column_fullname ::= fullname */
139203139423
{
139204139424
disableLookaside(pParse);
139205139425
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139206139426
}
139207139427
break;
139208
- case 263: /* cmd ::= create_vtab */
139428
+ case 262: /* cmd ::= create_vtab */
139209139429
{sqlite3VtabFinishParse(pParse,0);}
139210139430
break;
139211
- case 264: /* cmd ::= create_vtab LP vtabarglist RP */
139431
+ case 263: /* cmd ::= create_vtab LP vtabarglist RP */
139212139432
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139213139433
break;
139214
- case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139434
+ case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139215139435
{
139216139436
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139217139437
}
139218139438
break;
139219
- case 266: /* vtabarg ::= */
139439
+ case 265: /* vtabarg ::= */
139220139440
{sqlite3VtabArgInit(pParse);}
139221139441
break;
139222
- case 267: /* vtabargtoken ::= ANY */
139223
- case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
139224
- case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
139442
+ case 266: /* vtabargtoken ::= ANY */
139443
+ case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444
+ case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
139225139445
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139226139446
break;
139227
- case 270: /* with ::= */
139447
+ case 269: /* with ::= */
139228139448
{yymsp[1].minor.yy285 = 0;}
139229139449
break;
139230
- case 271: /* with ::= WITH wqlist */
139450
+ case 270: /* with ::= WITH wqlist */
139231139451
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139232139452
break;
139233
- case 272: /* with ::= WITH RECURSIVE wqlist */
139453
+ case 271: /* with ::= WITH RECURSIVE wqlist */
139234139454
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139235139455
break;
139236
- case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
139456
+ case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
139237139457
{
139238139458
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139239139459
}
139240139460
break;
139241
- case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139461
+ case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139242139462
{
139243139463
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139244139464
}
139245139465
break;
139246139466
default:
139247
- /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
139248
- /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
139249
- /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
139250
- /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
139251
- /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
139252
- /* (280) explain ::= */ yytestcase(yyruleno==280);
139253
- /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
139254
- /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
139255
- /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
139256
- /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
139257
- /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
139258
- /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
139259
- /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
139260
- /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
139261
- /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
139262
- /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
139263
- /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
139264
- /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
139265
- /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
139266
- /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139267
- /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
139268
- /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
139269
- /* (297) carglist ::= */ yytestcase(yyruleno==297);
139270
- /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
139271
- /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
139272
- /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
139273
- /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
139274
- /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
139275
- /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
139276
- /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
139277
- /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
139278
- /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
139279
- /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
139280
- /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
139281
- /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
139282
- /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
139283
- /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
139284
- /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
139285
- /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
139286
- /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
139287
- /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
139288
- /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
139289
- /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
139290
- /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
139291
- /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
139292
- /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
139293
- /* (321) tridxby ::= */ yytestcase(yyruleno==321);
139294
- /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
139295
- /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
139296
- /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
139297
- /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
139298
- /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
139299
- /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
139300
- /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
139301
- /* (329) anylist ::= */ yytestcase(yyruleno==329);
139302
- /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
139303
- /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
139467
+ /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468
+ /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469
+ /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470
+ /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471
+ /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472
+ /* (279) explain ::= */ yytestcase(yyruleno==279);
139473
+ /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474
+ /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475
+ /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476
+ /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477
+ /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478
+ /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479
+ /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480
+ /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481
+ /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482
+ /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483
+ /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484
+ /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485
+ /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486
+ /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487
+ /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488
+ /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489
+ /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490
+ /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491
+ /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492
+ /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493
+ /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494
+ /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495
+ /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496
+ /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497
+ /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498
+ /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499
+ /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500
+ /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501
+ /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502
+ /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503
+ /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504
+ /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505
+ /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506
+ /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507
+ /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508
+ /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509
+ /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510
+ /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511
+ /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512
+ /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513
+ /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514
+ /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515
+ /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516
+ /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517
+ /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518
+ /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519
+ /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520
+ /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521
+ /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522
+ /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523
+ /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
139304139524
break;
139305139525
/********** End reduce actions ************************************************/
139306139526
};
139307139527
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139308139528
yygoto = yyRuleInfo[yyruleno].lhs;
139309139529
yysize = yyRuleInfo[yyruleno].nrhs;
139310
- yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
139311
- if( yyact <= YY_MAX_SHIFTREDUCE ){
139312
- if( yyact>YY_MAX_SHIFT ){
139313
- yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
139314
- }
139315
- yymsp -= yysize-1;
139530
+ yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
139531
+
139532
+ /* There are no SHIFTREDUCE actions on nonterminals because the table
139533
+ ** generator has simplified them to pure REDUCE actions. */
139534
+ assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
139535
+
139536
+ /* It is not possible for a REDUCE to be followed by an error */
139537
+ assert( yyact!=YY_ERROR_ACTION );
139538
+
139539
+ if( yyact==YY_ACCEPT_ACTION ){
139540
+ yypParser->yytos += yysize;
139541
+ yy_accept(yypParser);
139542
+ }else{
139543
+ yymsp += yysize+1;
139316139544
yypParser->yytos = yymsp;
139317139545
yymsp->stateno = (YYACTIONTYPE)yyact;
139318139546
yymsp->major = (YYCODETYPE)yygoto;
139319139547
yyTraceShift(yypParser, yyact);
139320
- }else{
139321
- assert( yyact == YY_ACCEPT_ACTION );
139322
- yypParser->yytos -= yysize;
139323
- yy_accept(yypParser);
139324139548
}
139325139549
}
139326139550
139327139551
/*
139328139552
** The following code executes when the parse fails
@@ -140886,10 +141110,13 @@
140886141110
/************** Continuing where we left off in main.c ***********************/
140887141111
#endif
140888141112
#ifdef SQLITE_ENABLE_JSON1
140889141113
SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
140890141114
#endif
141115
+#ifdef SQLITE_ENABLE_STMTVTAB
141116
+SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
141117
+#endif
140891141118
#ifdef SQLITE_ENABLE_FTS5
140892141119
SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
140893141120
#endif
140894141121
140895141122
#ifndef SQLITE_AMALGAMATION
@@ -141669,10 +141896,11 @@
141669141896
{ SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141670141897
{ SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141671141898
{ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141672141899
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141673141900
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
141901
+ { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
141674141902
};
141675141903
unsigned int i;
141676141904
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141677141905
for(i=0; i<ArraySize(aFlagOp); i++){
141678141906
if( aFlagOp[i].op==op ){
@@ -143774,10 +144002,13 @@
143774144002
| SQLITE_CellSizeCk
143775144003
#endif
143776144004
#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
143777144005
| SQLITE_Fts3Tokenizer
143778144006
#endif
144007
+#if defined(SQLITE_ENABLE_QPSG)
144008
+ | SQLITE_EnableQPSG
144009
+#endif
143779144010
;
143780144011
sqlite3HashInit(&db->aCollSeq);
143781144012
#ifndef SQLITE_OMIT_VIRTUALTABLE
143782144013
sqlite3HashInit(&db->aModule);
143783144014
#endif
@@ -143911,10 +144142,16 @@
143911144142
#ifdef SQLITE_ENABLE_JSON1
143912144143
if( !db->mallocFailed && rc==SQLITE_OK){
143913144144
rc = sqlite3Json1Init(db);
143914144145
}
143915144146
#endif
144147
+
144148
+#ifdef SQLITE_ENABLE_STMTVTAB
144149
+ if( !db->mallocFailed && rc==SQLITE_OK){
144150
+ rc = sqlite3StmtVtabInit(db);
144151
+ }
144152
+#endif
143916144153
143917144154
/* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
143918144155
** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
143919144156
** mode. Doing nothing at all also makes NORMAL the default.
143920144157
*/
@@ -148000,11 +148237,11 @@
148000148237
pCsr->pStmt = p->pSeekStmt;
148001148238
p->pSeekStmt = 0;
148002148239
}else{
148003148240
zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
148004148241
if( !zSql ) return SQLITE_NOMEM;
148005
- rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
148242
+ rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
148006148243
sqlite3_free(zSql);
148007148244
}
148008148245
if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
148009148246
}
148010148247
return rc;
@@ -149537,11 +149774,11 @@
149537149774
zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149538149775
p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149539149776
);
149540149777
}
149541149778
if( zSql ){
149542
- rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
149779
+ rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
149543149780
sqlite3_free(zSql);
149544149781
}else{
149545149782
rc = SQLITE_NOMEM;
149546149783
}
149547149784
}else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156744,11 +156981,12 @@
156744156981
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156745156982
}
156746156983
if( !zSql ){
156747156984
rc = SQLITE_NOMEM;
156748156985
}else{
156749
- rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);
156986
+ rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
156987
+ &pStmt, NULL);
156750156988
sqlite3_free(zSql);
156751156989
assert( rc==SQLITE_OK || pStmt==0 );
156752156990
p->aStmt[eStmt] = pStmt;
156753156991
}
156754156992
}
@@ -167854,11 +168092,12 @@
167854168092
167855168093
rc = rtreeQueryStat1(db, pRtree);
167856168094
for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
167857168095
char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
167858168096
if( zSql ){
167859
- rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0);
168097
+ rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
168098
+ appStmt[i], 0);
167860168099
}else{
167861168100
rc = SQLITE_NOMEM;
167862168101
}
167863168102
sqlite3_free(zSql);
167864168103
}
@@ -183900,16 +184139,16 @@
183900184139
** fts5yy_default[] Default action for each state.
183901184140
**
183902184141
*********** Begin parsing tables **********************************************/
183903184142
#define fts5YY_ACTTAB_COUNT (98)
183904184143
static const fts5YYACTIONTYPE fts5yy_action[] = {
183905
- /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17,
183906
- /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6,
183907
- /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26,
183908
- /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65,
183909
- /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24,
183910
- /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65,
184144
+ /* 0 */ 105, 19, 90, 6, 26, 93, 92, 24, 24, 17,
184145
+ /* 10 */ 90, 6, 26, 16, 92, 54, 24, 18, 90, 6,
184146
+ /* 20 */ 26, 10, 92, 12, 24, 75, 86, 90, 6, 26,
184147
+ /* 30 */ 13, 92, 75, 24, 20, 90, 6, 26, 101, 92,
184148
+ /* 40 */ 56, 24, 27, 90, 6, 26, 100, 92, 21, 24,
184149
+ /* 50 */ 23, 15, 30, 11, 1, 91, 22, 25, 9, 92,
183911184150
/* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
183912184151
/* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
183913184152
/* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
183914184153
/* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
183915184154
};
@@ -184010,10 +184249,11 @@
184010184249
int fts5yystksz; /* Current side of the stack */
184011184250
fts5yyStackEntry *fts5yystack; /* The parser's stack */
184012184251
fts5yyStackEntry fts5yystk0; /* First stack entry */
184013184252
#else
184014184253
fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
184254
+ fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */
184015184255
#endif
184016184256
};
184017184257
typedef struct fts5yyParser fts5yyParser;
184018184258
184019184259
#ifndef NDEBUG
@@ -184159,10 +184399,11 @@
184159184399
pParser->fts5yyerrcnt = -1;
184160184400
#endif
184161184401
pParser->fts5yytos = pParser->fts5yystack;
184162184402
pParser->fts5yystack[0].stateno = 0;
184163184403
pParser->fts5yystack[0].major = 0;
184404
+ pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184164184405
}
184165184406
184166184407
#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184167184408
/*
184168184409
** This function allocates a new parser.
@@ -184457,11 +184698,11 @@
184457184698
fts5yypParser->fts5yyhwm++;
184458184699
assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184459184700
}
184460184701
#endif
184461184702
#if fts5YYSTACKDEPTH>0
184462
- if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
184703
+ if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){
184463184704
fts5yypParser->fts5yytos--;
184464184705
fts5yyStackOverflow(fts5yypParser);
184465184706
return;
184466184707
}
184467184708
#else
@@ -184485,39 +184726,39 @@
184485184726
184486184727
/* The following table contains information about every rule that
184487184728
** is used during the reduce.
184488184729
*/
184489184730
static const struct {
184490
- fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184491
- unsigned char nrhs; /* Number of right-hand side symbols in the rule */
184731
+ fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184732
+ signed char nrhs; /* Negative of the number of RHS symbols in the rule */
184492184733
} fts5yyRuleInfo[] = {
184493
- { 16, 1 },
184494
- { 20, 4 },
184495
- { 20, 3 },
184496
- { 20, 1 },
184497
- { 20, 2 },
184498
- { 21, 2 },
184499
- { 21, 1 },
184500
- { 17, 3 },
184501
- { 17, 3 },
184502
- { 17, 3 },
184503
- { 17, 5 },
184504
- { 17, 3 },
184505
- { 17, 1 },
184506
- { 19, 1 },
184507
- { 19, 2 },
184508
- { 18, 1 },
184509
- { 18, 3 },
184510
- { 22, 1 },
184511
- { 22, 5 },
184512
- { 23, 1 },
184513
- { 23, 2 },
184734
+ { 16, -1 },
184735
+ { 20, -4 },
184736
+ { 20, -3 },
184737
+ { 20, -1 },
184738
+ { 20, -2 },
184739
+ { 21, -2 },
184740
+ { 21, -1 },
184741
+ { 17, -3 },
184742
+ { 17, -3 },
184743
+ { 17, -3 },
184744
+ { 17, -5 },
184745
+ { 17, -3 },
184746
+ { 17, -1 },
184747
+ { 19, -1 },
184748
+ { 19, -2 },
184749
+ { 18, -1 },
184750
+ { 18, -3 },
184751
+ { 22, -1 },
184752
+ { 22, -5 },
184753
+ { 23, -1 },
184754
+ { 23, -2 },
184514184755
{ 25, 0 },
184515
- { 25, 2 },
184516
- { 24, 4 },
184517
- { 24, 2 },
184518
- { 26, 1 },
184756
+ { 25, -2 },
184757
+ { 24, -4 },
184758
+ { 24, -2 },
184759
+ { 26, -1 },
184519184760
{ 26, 0 },
184520184761
};
184521184762
184522184763
static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184523184764
@@ -184537,11 +184778,11 @@
184537184778
fts5yymsp = fts5yypParser->fts5yytos;
184538184779
#ifndef NDEBUG
184539184780
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184540184781
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184541184782
fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184542
- fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
184783
+ fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
184543184784
}
184544184785
#endif /* NDEBUG */
184545184786
184546184787
/* Check that the stack is large enough to grow by a single entry
184547184788
** if the RHS of the rule is empty. This ensures that there is room
@@ -184552,11 +184793,11 @@
184552184793
fts5yypParser->fts5yyhwm++;
184553184794
assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184554184795
}
184555184796
#endif
184556184797
#if fts5YYSTACKDEPTH>0
184557
- if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
184798
+ if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
184558184799
fts5yyStackOverflow(fts5yypParser);
184559184800
return;
184560184801
}
184561184802
#else
184562184803
if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184719,24 +184960,28 @@
184719184960
/********** End reduce actions ************************************************/
184720184961
};
184721184962
assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184722184963
fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184723184964
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184724
- fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184725
- if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
184726
- if( fts5yyact>fts5YY_MAX_SHIFT ){
184727
- fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
184728
- }
184729
- fts5yymsp -= fts5yysize-1;
184965
+ fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184966
+
184967
+ /* There are no SHIFTREDUCE actions on nonterminals because the table
184968
+ ** generator has simplified them to pure REDUCE actions. */
184969
+ assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );
184970
+
184971
+ /* It is not possible for a REDUCE to be followed by an error */
184972
+ assert( fts5yyact!=fts5YY_ERROR_ACTION );
184973
+
184974
+ if( fts5yyact==fts5YY_ACCEPT_ACTION ){
184975
+ fts5yypParser->fts5yytos += fts5yysize;
184976
+ fts5yy_accept(fts5yypParser);
184977
+ }else{
184978
+ fts5yymsp += fts5yysize+1;
184730184979
fts5yypParser->fts5yytos = fts5yymsp;
184731184980
fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184732184981
fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184733184982
fts5yyTraceShift(fts5yypParser, fts5yyact);
184734
- }else{
184735
- assert( fts5yyact == fts5YY_ACCEPT_ACTION );
184736
- fts5yypParser->fts5yytos -= fts5yysize;
184737
- fts5yy_accept(fts5yypParser);
184738184983
}
184739184984
}
184740184985
184741184986
/*
184742184987
** The following code executes when the parse fails
@@ -191124,11 +191369,12 @@
191124191369
sqlite3_stmt **ppStmt,
191125191370
char *zSql
191126191371
){
191127191372
if( p->rc==SQLITE_OK ){
191128191373
if( zSql ){
191129
- p->rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, ppStmt, 0);
191374
+ p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
191375
+ SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
191130191376
}else{
191131191377
p->rc = SQLITE_NOMEM;
191132191378
}
191133191379
}
191134191380
sqlite3_free(zSql);
@@ -191173,11 +191419,12 @@
191173191419
pConfig->zDb, pConfig->zName
191174191420
);
191175191421
if( zSql==0 ){
191176191422
rc = SQLITE_NOMEM;
191177191423
}else{
191178
- rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p->pDeleter, 0);
191424
+ rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
191425
+ SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
191179191426
sqlite3_free(zSql);
191180191427
}
191181191428
if( rc!=SQLITE_OK ){
191182191429
p->rc = rc;
191183191430
return;
@@ -197772,11 +198019,12 @@
197772198019
va_start(ap, zFmt);
197773198020
zSql = sqlite3_vmprintf(zFmt, ap);
197774198021
if( zSql==0 ){
197775198022
rc = SQLITE_NOMEM;
197776198023
}else{
197777
- rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0);
198024
+ rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198025
+ SQLITE_PREPARE_PERSISTENT, &pRet, 0);
197778198026
if( rc!=SQLITE_OK ){
197779198027
*pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
197780198028
}
197781198029
sqlite3_free(zSql);
197782198030
}
@@ -197908,11 +198156,12 @@
197908198156
197909198157
if( zRankArgs ){
197910198158
char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
197911198159
if( zSql ){
197912198160
sqlite3_stmt *pStmt = 0;
197913
- rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pStmt, 0);
198161
+ rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198162
+ SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
197914198163
sqlite3_free(zSql);
197915198164
assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
197916198165
if( rc==SQLITE_OK ){
197917198166
if( SQLITE_ROW==sqlite3_step(pStmt) ){
197918198167
int nByte;
@@ -199517,11 +199766,11 @@
199517199766
int nArg, /* Number of args */
199518199767
sqlite3_value **apUnused /* Function arguments */
199519199768
){
199520199769
assert( nArg==0 );
199521199770
UNUSED_PARAM2(nArg, apUnused);
199522
- sqlite3_result_text(pCtx, "fts5: 2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a", -1, SQLITE_TRANSIENT);
199771
+ sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
199523199772
}
199524199773
199525199774
static int fts5Init(sqlite3 *db){
199526199775
static const sqlite3_module fts5Mod = {
199527199776
/* iVersion */ 2,
@@ -199771,11 +200020,12 @@
199771200020
}
199772200021
199773200022
if( zSql==0 ){
199774200023
rc = SQLITE_NOMEM;
199775200024
}else{
199776
- rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0);
200025
+ rc = sqlite3_prepare_v3(pC->db, zSql, -1,
200026
+ SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
199777200027
sqlite3_free(zSql);
199778200028
if( rc!=SQLITE_OK && pzErrMsg ){
199779200029
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
199780200030
}
199781200031
}
@@ -203371,5 +203621,325 @@
203371203621
203372203622
203373203623
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
203374203624
203375203625
/************** End of fts5.c ************************************************/
203626
+/************** Begin file stmt.c ********************************************/
203627
+/*
203628
+** 2017-05-31
203629
+**
203630
+** The author disclaims copyright to this source code. In place of
203631
+** a legal notice, here is a blessing:
203632
+**
203633
+** May you do good and not evil.
203634
+** May you find forgiveness for yourself and forgive others.
203635
+** May you share freely, never taking more than you give.
203636
+**
203637
+*************************************************************************
203638
+**
203639
+** This file demonstrates an eponymous virtual table that returns information
203640
+** about all prepared statements for the database connection.
203641
+**
203642
+** Usage example:
203643
+**
203644
+** .load ./stmt
203645
+** .mode line
203646
+** .header on
203647
+** SELECT * FROM stmt;
203648
+*/
203649
+#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)
203650
+#if !defined(SQLITEINT_H)
203651
+/* #include "sqlite3ext.h" */
203652
+#endif
203653
+SQLITE_EXTENSION_INIT1
203654
+/* #include <assert.h> */
203655
+/* #include <string.h> */
203656
+
203657
+#ifndef SQLITE_OMIT_VIRTUALTABLE
203658
+
203659
+/*
203660
+** The following macros are used to cast pointers to integers.
203661
+** The way you do this varies from one compiler
203662
+** to the next, so we have developed the following set of #if statements
203663
+** to generate appropriate macros for a wide range of compilers.
203664
+*/
203665
+#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
203666
+# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
203667
+#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
203668
+# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
203669
+#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
203670
+# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
203671
+#else /* Generates a warning - but it always works */
203672
+# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
203673
+#endif
203674
+
203675
+
203676
+/* stmt_vtab is a subclass of sqlite3_vtab which will
203677
+** serve as the underlying representation of a stmt virtual table
203678
+*/
203679
+typedef struct stmt_vtab stmt_vtab;
203680
+struct stmt_vtab {
203681
+ sqlite3_vtab base; /* Base class - must be first */
203682
+ sqlite3 *db; /* Database connection for this stmt vtab */
203683
+};
203684
+
203685
+/* stmt_cursor is a subclass of sqlite3_vtab_cursor which will
203686
+** serve as the underlying representation of a cursor that scans
203687
+** over rows of the result
203688
+*/
203689
+typedef struct stmt_cursor stmt_cursor;
203690
+struct stmt_cursor {
203691
+ sqlite3_vtab_cursor base; /* Base class - must be first */
203692
+ sqlite3 *db; /* Database connection for this cursor */
203693
+ sqlite3_stmt *pStmt; /* Statement cursor is currently pointing at */
203694
+ sqlite3_int64 iRowid; /* The rowid */
203695
+};
203696
+
203697
+/*
203698
+** The stmtConnect() method is invoked to create a new
203699
+** stmt_vtab that describes the generate_stmt virtual table.
203700
+**
203701
+** Think of this routine as the constructor for stmt_vtab objects.
203702
+**
203703
+** All this routine needs to do is:
203704
+**
203705
+** (1) Allocate the stmt_vtab object and initialize all fields.
203706
+**
203707
+** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708
+** result set of queries against generate_stmt will look like.
203709
+*/
203710
+static int stmtConnect(
203711
+ sqlite3 *db,
203712
+ void *pAux,
203713
+ int argc, const char *const*argv,
203714
+ sqlite3_vtab **ppVtab,
203715
+ char **pzErr
203716
+){
203717
+ stmt_vtab *pNew;
203718
+ int rc;
203719
+
203720
+/* Column numbers */
203721
+#define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
203722
+#define STMT_COLUMN_SQL 1 /* SQL for the statement */
203723
+#define STMT_COLUMN_NCOL 2 /* Number of result columns */
203724
+#define STMT_COLUMN_RO 3 /* True if read-only */
203725
+#define STMT_COLUMN_BUSY 4 /* True if currently busy */
203726
+#define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
203727
+#define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
203728
+#define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
203729
+#define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
203730
+#define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
203731
+#define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
203732
+#define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
203733
+
203734
+
203735
+ rc = sqlite3_declare_vtab(db,
203736
+ "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
203737
+ "reprep,run,mem)");
203738
+ if( rc==SQLITE_OK ){
203739
+ pNew = sqlite3_malloc( sizeof(*pNew) );
203740
+ *ppVtab = (sqlite3_vtab*)pNew;
203741
+ if( pNew==0 ) return SQLITE_NOMEM;
203742
+ memset(pNew, 0, sizeof(*pNew));
203743
+ pNew->db = db;
203744
+ }
203745
+ return rc;
203746
+}
203747
+
203748
+/*
203749
+** This method is the destructor for stmt_cursor objects.
203750
+*/
203751
+static int stmtDisconnect(sqlite3_vtab *pVtab){
203752
+ sqlite3_free(pVtab);
203753
+ return SQLITE_OK;
203754
+}
203755
+
203756
+/*
203757
+** Constructor for a new stmt_cursor object.
203758
+*/
203759
+static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
203760
+ stmt_cursor *pCur;
203761
+ pCur = sqlite3_malloc( sizeof(*pCur) );
203762
+ if( pCur==0 ) return SQLITE_NOMEM;
203763
+ memset(pCur, 0, sizeof(*pCur));
203764
+ pCur->db = ((stmt_vtab*)p)->db;
203765
+ *ppCursor = &pCur->base;
203766
+ return SQLITE_OK;
203767
+}
203768
+
203769
+/*
203770
+** Destructor for a stmt_cursor.
203771
+*/
203772
+static int stmtClose(sqlite3_vtab_cursor *cur){
203773
+ sqlite3_free(cur);
203774
+ return SQLITE_OK;
203775
+}
203776
+
203777
+
203778
+/*
203779
+** Advance a stmt_cursor to its next row of output.
203780
+*/
203781
+static int stmtNext(sqlite3_vtab_cursor *cur){
203782
+ stmt_cursor *pCur = (stmt_cursor*)cur;
203783
+ pCur->iRowid++;
203784
+ pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);
203785
+ return SQLITE_OK;
203786
+}
203787
+
203788
+/*
203789
+** Return values of columns for the row at which the stmt_cursor
203790
+** is currently pointing.
203791
+*/
203792
+static int stmtColumn(
203793
+ sqlite3_vtab_cursor *cur, /* The cursor */
203794
+ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
203795
+ int i /* Which column to return */
203796
+){
203797
+ stmt_cursor *pCur = (stmt_cursor*)cur;
203798
+ switch( i ){
203799
+ case STMT_COLUMN_PTR: {
203800
+ sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
203801
+ break;
203802
+ }
203803
+ case STMT_COLUMN_SQL: {
203804
+ sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
203805
+ break;
203806
+ }
203807
+ case STMT_COLUMN_NCOL: {
203808
+ sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));
203809
+ break;
203810
+ }
203811
+ case STMT_COLUMN_RO: {
203812
+ sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));
203813
+ break;
203814
+ }
203815
+ case STMT_COLUMN_BUSY: {
203816
+ sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
203817
+ break;
203818
+ }
203819
+ case STMT_COLUMN_MEM: {
203820
+ i = SQLITE_STMTSTATUS_MEMUSED +
203821
+ STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
203822
+ /* Fall thru */
203823
+ }
203824
+ case STMT_COLUMN_NSCAN:
203825
+ case STMT_COLUMN_NSORT:
203826
+ case STMT_COLUMN_NAIDX:
203827
+ case STMT_COLUMN_NSTEP:
203828
+ case STMT_COLUMN_REPREP:
203829
+ case STMT_COLUMN_RUN: {
203830
+ sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
203831
+ i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
203832
+ break;
203833
+ }
203834
+ }
203835
+ return SQLITE_OK;
203836
+}
203837
+
203838
+/*
203839
+** Return the rowid for the current row. In this implementation, the
203840
+** rowid is the same as the output value.
203841
+*/
203842
+static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
203843
+ stmt_cursor *pCur = (stmt_cursor*)cur;
203844
+ *pRowid = pCur->iRowid;
203845
+ return SQLITE_OK;
203846
+}
203847
+
203848
+/*
203849
+** Return TRUE if the cursor has been moved off of the last
203850
+** row of output.
203851
+*/
203852
+static int stmtEof(sqlite3_vtab_cursor *cur){
203853
+ stmt_cursor *pCur = (stmt_cursor*)cur;
203854
+ return pCur->pStmt==0;
203855
+}
203856
+
203857
+/*
203858
+** This method is called to "rewind" the stmt_cursor object back
203859
+** to the first row of output. This method is always called at least
203860
+** once prior to any call to stmtColumn() or stmtRowid() or
203861
+** stmtEof().
203862
+*/
203863
+static int stmtFilter(
203864
+ sqlite3_vtab_cursor *pVtabCursor,
203865
+ int idxNum, const char *idxStr,
203866
+ int argc, sqlite3_value **argv
203867
+){
203868
+ stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;
203869
+ pCur->pStmt = 0;
203870
+ pCur->iRowid = 0;
203871
+ return stmtNext(pVtabCursor);
203872
+}
203873
+
203874
+/*
203875
+** SQLite will invoke this method one or more times while planning a query
203876
+** that uses the generate_stmt virtual table. This routine needs to create
203877
+** a query plan for each invocation and compute an estimated cost for that
203878
+** plan.
203879
+*/
203880
+static int stmtBestIndex(
203881
+ sqlite3_vtab *tab,
203882
+ sqlite3_index_info *pIdxInfo
203883
+){
203884
+ pIdxInfo->estimatedCost = (double)500;
203885
+ pIdxInfo->estimatedRows = 500;
203886
+ return SQLITE_OK;
203887
+}
203888
+
203889
+/*
203890
+** This following structure defines all the methods for the
203891
+** generate_stmt virtual table.
203892
+*/
203893
+static sqlite3_module stmtModule = {
203894
+ 0, /* iVersion */
203895
+ 0, /* xCreate */
203896
+ stmtConnect, /* xConnect */
203897
+ stmtBestIndex, /* xBestIndex */
203898
+ stmtDisconnect, /* xDisconnect */
203899
+ 0, /* xDestroy */
203900
+ stmtOpen, /* xOpen - open a cursor */
203901
+ stmtClose, /* xClose - close a cursor */
203902
+ stmtFilter, /* xFilter - configure scan constraints */
203903
+ stmtNext, /* xNext - advance a cursor */
203904
+ stmtEof, /* xEof - check for end of scan */
203905
+ stmtColumn, /* xColumn - read data */
203906
+ stmtRowid, /* xRowid - read data */
203907
+ 0, /* xUpdate */
203908
+ 0, /* xBegin */
203909
+ 0, /* xSync */
203910
+ 0, /* xCommit */
203911
+ 0, /* xRollback */
203912
+ 0, /* xFindMethod */
203913
+ 0, /* xRename */
203914
+};
203915
+
203916
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
203917
+
203918
+SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
203919
+ int rc = SQLITE_OK;
203920
+#ifndef SQLITE_OMIT_VIRTUALTABLE
203921
+ rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
203922
+#endif
203923
+ return rc;
203924
+}
203925
+
203926
+#ifndef SQLITE_CORE
203927
+#ifdef _WIN32
203928
+__declspec(dllexport)
203929
+#endif
203930
+SQLITE_API int sqlite3_stmt_init(
203931
+ sqlite3 *db,
203932
+ char **pzErrMsg,
203933
+ const sqlite3_api_routines *pApi
203934
+){
203935
+ int rc = SQLITE_OK;
203936
+ SQLITE_EXTENSION_INIT2(pApi);
203937
+#ifndef SQLITE_OMIT_VIRTUALTABLE
203938
+ rc = sqlite3StmtVtabInit(db);
203939
+#endif
203940
+ return rc;
203941
+}
203942
+#endif /* SQLITE_CORE */
203943
+#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
203944
+
203945
+/************** End of stmt.c ************************************************/
203376203946
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -39,10 +39,18 @@
39 ** SQLite was built with.
40 */
41
42 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
43
 
 
 
 
 
 
 
 
44
45 /* These macros are provided to "stringify" the value of the define
46 ** for those options in which the value is meaningful. */
47 #define CTIMEOPT_VAL_(opt) #opt
48 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
@@ -279,10 +287,13 @@
279 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
280 "ENABLE_OVERSIZE_CELL_CHECK",
281 #endif
282 #if SQLITE_ENABLE_PREUPDATE_HOOK
283 "ENABLE_PREUPDATE_HOOK",
 
 
 
284 #endif
285 #if SQLITE_ENABLE_RBU
286 "ENABLE_RBU",
287 #endif
288 #if SQLITE_ENABLE_RTREE
@@ -302,10 +313,13 @@
302 #endif
303 #if defined(SQLITE_ENABLE_STAT4)
304 "ENABLE_STAT4",
305 #elif defined(SQLITE_ENABLE_STAT3)
306 "ENABLE_STAT3",
 
 
 
307 #endif
308 #if SQLITE_ENABLE_STMT_SCANSTATUS
309 "ENABLE_STMT_SCANSTATUS",
310 #endif
311 #if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
@@ -1012,11 +1026,11 @@
1012 ** MinGW.
1013 */
1014 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
1015 /************** Begin file sqlite3.h *****************************************/
1016 /*
1017 ** 2001 September 15
1018 **
1019 ** The author disclaims copyright to this source code. In place of
1020 ** a legal notice, here is a blessing:
1021 **
1022 ** May you do good and not evil.
@@ -1136,11 +1150,11 @@
1136 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1137 ** [sqlite_version()] and [sqlite_source_id()].
1138 */
1139 #define SQLITE_VERSION "3.20.0"
1140 #define SQLITE_VERSION_NUMBER 3020000
1141 #define SQLITE_SOURCE_ID "2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a"
1142
1143 /*
1144 ** CAPI3REF: Run-Time Library Version Numbers
1145 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1146 **
@@ -1248,11 +1262,11 @@
1248 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1249 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1250 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1251 ** and [sqlite3_close_v2()] are its destructors. There are many other
1252 ** interfaces (such as
1253 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
1254 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
1255 ** sqlite3 object.
1256 */
1257 typedef struct sqlite3 sqlite3;
1258
@@ -1352,11 +1366,11 @@
1352 /*
1353 ** CAPI3REF: One-Step Query Execution Interface
1354 ** METHOD: sqlite3
1355 **
1356 ** The sqlite3_exec() interface is a convenience wrapper around
1357 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
1358 ** that allows an application to run multiple statements of SQL
1359 ** without having to use a lot of C code.
1360 **
1361 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1362 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3020,19 +3034,31 @@
3020 ** default) to enable them. The second parameter is a pointer to an integer
3021 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3022 ** have been disabled - 0 if they are not disabled, 1 if they are.
3023 ** </dd>
3024 **
 
 
 
 
 
 
 
 
 
 
 
3025 ** </dl>
3026 */
3027 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3028 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3029 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
3030 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
3031 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
3032 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
3033 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
 
3034
3035
3036 /*
3037 ** CAPI3REF: Enable Or Disable Extended Result Codes
3038 ** METHOD: sqlite3
@@ -3692,25 +3718,26 @@
3692 **
3693 ** ^This routine registers an authorizer callback with a particular
3694 ** [database connection], supplied in the first argument.
3695 ** ^The authorizer callback is invoked as SQL statements are being compiled
3696 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
3697 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
 
3698 ** points during the compilation process, as logic is being created
3699 ** to perform various actions, the authorizer callback is invoked to
3700 ** see if those actions are allowed. ^The authorizer callback should
3701 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
3702 ** specific action but allow the SQL statement to continue to be
3703 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
3704 ** rejected with an error. ^If the authorizer callback returns
3705 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3706 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
3707 ** the authorizer will fail with an error message.
3708 **
3709 ** When the callback returns [SQLITE_OK], that means the operation
3710 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
3711 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
3712 ** authorizer will fail with an error message explaining that
3713 ** access is denied.
3714 **
3715 ** ^The first parameter to the authorizer callback is a copy of the third
3716 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3757,23 +3784,23 @@
3757 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3758 ** The authorizer is disabled by default.
3759 **
3760 ** The authorizer callback must not do anything that will modify
3761 ** the database connection that invoked the authorizer callback.
3762 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3763 ** database connections for the meaning of "modify" in this paragraph.
3764 **
3765 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3766 ** statement might be re-prepared during [sqlite3_step()] due to a
3767 ** schema change. Hence, the application should ensure that the
3768 ** correct authorizer callback remains in place during the [sqlite3_step()].
3769 **
3770 ** ^Note that the authorizer callback is invoked only during
3771 ** [sqlite3_prepare()] or its variants. Authorization is not
3772 ** performed during statement evaluation in [sqlite3_step()], unless
3773 ** as stated in the previous paragraph, sqlite3_step() invokes
3774 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3775 */
3776 SQLITE_API int sqlite3_set_authorizer(
3777 sqlite3*,
3778 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3779 void *pUserData
@@ -4005,11 +4032,11 @@
4005 ** interrupted. This feature can be used to implement a
4006 ** "Cancel" button on a GUI progress dialog box.
4007 **
4008 ** The progress handler callback must not do anything that will modify
4009 ** the database connection that invoked the progress handler.
4010 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4011 ** database connections for the meaning of "modify" in this paragraph.
4012 **
4013 */
4014 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
4015
@@ -4359,11 +4386,11 @@
4359 ** prepared statement before it can be run.
4360 **
4361 ** The life-cycle of a prepared statement object usually goes like this:
4362 **
4363 ** <ol>
4364 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
4365 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
4366 ** interfaces.
4367 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
4368 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
4369 ** to step 2. Do this zero or more times.
@@ -4441,11 +4468,11 @@
4441 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4442 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4443 **
4444 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
4445 ** <dd>The maximum number of instructions in a virtual machine program
4446 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
4447 ** the equivalent tries to allocate space for more than this many opcodes
4448 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
4449 **
4450 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
4451 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4481,28 +4508,61 @@
4481 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
4482 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4483 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4484 #define SQLITE_LIMIT_WORKER_THREADS 11
4485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4486
4487 /*
4488 ** CAPI3REF: Compiling An SQL Statement
4489 ** KEYWORDS: {SQL statement compiler}
4490 ** METHOD: sqlite3
4491 ** CONSTRUCTOR: sqlite3_stmt
4492 **
4493 ** To execute an SQL query, it must first be compiled into a byte-code
4494 ** program using one of these routines.
 
 
 
 
 
 
 
 
 
 
 
4495 **
4496 ** The first argument, "db", is a [database connection] obtained from a
4497 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
4498 ** [sqlite3_open16()]. The database connection must not have been closed.
4499 **
4500 ** The second argument, "zSql", is the statement to be compiled, encoded
4501 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
4502 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
4503 ** use UTF-16.
 
4504 **
4505 ** ^If the nByte argument is negative, then zSql is read up to the
4506 ** first zero terminator. ^If nByte is positive, then it is the
4507 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
4508 ** statement is generated.
@@ -4525,14 +4585,15 @@
4525 ** ppStmt may not be NULL.
4526 **
4527 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
4528 ** otherwise an [error code] is returned.
4529 **
4530 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
4531 ** recommended for all new programs. The two older interfaces are retained
4532 ** for backwards compatibility, but their use is discouraged.
4533 ** ^In the "v2" interfaces, the prepared statement
 
4534 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
4535 ** original SQL text. This causes the [sqlite3_step()] interface to
4536 ** behave differently in three ways:
4537 **
4538 ** <ol>
@@ -4561,10 +4622,16 @@
4561 ** ^The specific value of WHERE-clause [parameter] might influence the
4562 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4563 ** or [GLOB] operator or if the parameter is compared to an indexed column
4564 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
4565 ** </li>
 
 
 
 
 
 
4566 ** </ol>
4567 */
4568 SQLITE_API int sqlite3_prepare(
4569 sqlite3 *db, /* Database handle */
4570 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4574,10 +4641,18 @@
4574 );
4575 SQLITE_API int sqlite3_prepare_v2(
4576 sqlite3 *db, /* Database handle */
4577 const char *zSql, /* SQL statement, UTF-8 encoded */
4578 int nByte, /* Maximum length of zSql in bytes. */
 
 
 
 
 
 
 
 
4579 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4580 const char **pzTail /* OUT: Pointer to unused portion of zSql */
4581 );
4582 SQLITE_API int sqlite3_prepare16(
4583 sqlite3 *db, /* Database handle */
@@ -4591,18 +4666,27 @@
4591 const void *zSql, /* SQL statement, UTF-16 encoded */
4592 int nByte, /* Maximum length of zSql in bytes. */
4593 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4594 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4595 );
 
 
 
 
 
 
 
 
4596
4597 /*
4598 ** CAPI3REF: Retrieving Statement SQL
4599 ** METHOD: sqlite3_stmt
4600 **
4601 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
4602 ** SQL text used to create [prepared statement] P if P was
4603 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
4604 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
4605 ** string containing the SQL text of prepared statement P with
4606 ** [bound parameters] expanded.
4607 **
4608 ** ^(For example, if a prepared statement is created using the SQL
@@ -4744,11 +4828,11 @@
4744 ** CAPI3REF: Binding Values To Prepared Statements
4745 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4746 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4747 ** METHOD: sqlite3_stmt
4748 **
4749 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
4750 ** literals may be replaced by a [parameter] that matches one of following
4751 ** templates:
4752 **
4753 ** <ul>
4754 ** <li> ?
@@ -4763,11 +4847,11 @@
4763 ** parameters (also called "host parameter names" or "SQL parameters")
4764 ** can be set using the sqlite3_bind_*() routines defined here.
4765 **
4766 ** ^The first argument to the sqlite3_bind_*() routines is always
4767 ** a pointer to the [sqlite3_stmt] object returned from
4768 ** [sqlite3_prepare_v2()] or its variants.
4769 **
4770 ** ^The second argument is the index of the SQL parameter to be set.
4771 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4772 ** SQL parameter is used more than once, second and subsequent
4773 ** occurrences have the same index as the first occurrence.
@@ -4900,12 +4984,12 @@
4900 ** ^The first host parameter has an index of 1, not 0.
4901 **
4902 ** ^If the value N is out of range or if the N-th parameter is
4903 ** nameless, then NULL is returned. ^The returned string is
4904 ** always in UTF-8 encoding even if the named parameter was
4905 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
4906 ** [sqlite3_prepare16_v2()].
4907 **
4908 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4909 ** [sqlite3_bind_parameter_count()], and
4910 ** [sqlite3_bind_parameter_index()].
4911 */
@@ -4918,11 +5002,12 @@
4918 ** ^Return the index of an SQL parameter given its name. ^The
4919 ** index value returned is suitable for use as the second
4920 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
4921 ** is returned if no matching parameter is found. ^The parameter
4922 ** name must be given in UTF-8 even if the original statement
4923 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 
4924 **
4925 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4926 ** [sqlite3_bind_parameter_count()], and
4927 ** [sqlite3_bind_parameter_name()].
4928 */
@@ -5072,20 +5157,22 @@
5072
5073 /*
5074 ** CAPI3REF: Evaluate An SQL Statement
5075 ** METHOD: sqlite3_stmt
5076 **
5077 ** After a [prepared statement] has been prepared using either
5078 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
 
5079 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
5080 ** must be called one or more times to evaluate the statement.
5081 **
5082 ** The details of the behavior of the sqlite3_step() interface depend
5083 ** on whether the statement was prepared using the newer "v2" interface
5084 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
5085 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5086 ** new "v2" interface is recommended for new applications but the legacy
 
5087 ** interface will continue to be supported.
5088 **
5089 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
5090 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
5091 ** ^With the "v2" interface, any of the other [result codes] or
@@ -5142,14 +5229,15 @@
5142 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
5143 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
5144 ** specific [error codes] that better describes the error.
5145 ** We admit that this is a goofy design. The problem has been fixed
5146 ** with the "v2" interface. If you prepare all of your SQL statements
5147 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
 
5148 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
5149 ** then the more specific [error codes] are returned directly
5150 ** by sqlite3_step(). The use of the "v2" interface is recommended.
5151 */
5152 SQLITE_API int sqlite3_step(sqlite3_stmt*);
5153
5154 /*
5155 ** CAPI3REF: Number of columns in a result set
@@ -5210,11 +5298,11 @@
5210 ** METHOD: sqlite3_stmt
5211 **
5212 ** ^These routines return information about a single column of the current
5213 ** result row of a query. ^In every case the first argument is a pointer
5214 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5215 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
5216 ** and the second argument is the index of the column for which information
5217 ** should be returned. ^The leftmost column of the result set has the index 0.
5218 ** ^The number of columns in the result can be determined using
5219 ** [sqlite3_column_count()].
5220 **
@@ -6334,11 +6422,11 @@
6334 **
6335 ** ^The sqlite3_db_handle interface returns the [database connection] handle
6336 ** to which a [prepared statement] belongs. ^The [database connection]
6337 ** returned by sqlite3_db_handle is the same [database connection]
6338 ** that was the first argument
6339 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
6340 ** create the statement in the first place.
6341 */
6342 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6343
6344 /*
@@ -6410,11 +6498,11 @@
6410 ** the database connection that invoked the callback. Any actions
6411 ** to modify the database connection must be deferred until after the
6412 ** completion of the [sqlite3_step()] call that triggered the commit
6413 ** or rollback hook in the first place.
6414 ** Note that running any other SQL statements, including SELECT statements,
6415 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
6416 ** the database connections for the meaning of "modify" in this paragraph.
6417 **
6418 ** ^Registering a NULL function disables the callback.
6419 **
6420 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6470,11 +6558,11 @@
6470 **
6471 ** The update hook implementation must not do anything that will modify
6472 ** the database connection that invoked the update hook. Any actions
6473 ** to modify the database connection must be deferred until after the
6474 ** completion of the [sqlite3_step()] call that triggered the update hook.
6475 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
6476 ** database connections for the meaning of "modify" in this paragraph.
6477 **
6478 ** ^The sqlite3_update_hook(D,C,P) function
6479 ** returns the P argument from the previous call
6480 ** on the same [database connection] D, or NULL for
@@ -8148,10 +8236,22 @@
8148 ** by the prepared statement if that number is less than or equal
8149 ** to 2147483647. The number of virtual machine operations can be
8150 ** used as a proxy for the total work done by the prepared statement.
8151 ** If the number of virtual machine operations exceeds 2147483647
8152 ** then the value returned by this statement status code is undefined.
 
 
 
 
 
 
 
 
 
 
 
 
8153 **
8154 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8155 ** <dd>^This is the approximate number of bytes of heap memory
8156 ** used to store the prepared statement. ^This value is not actually
8157 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -8161,11 +8261,13 @@
8161 */
8162 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
8163 #define SQLITE_STMTSTATUS_SORT 2
8164 #define SQLITE_STMTSTATUS_AUTOINDEX 3
8165 #define SQLITE_STMTSTATUS_VM_STEP 4
8166 #define SQLITE_STMTSTATUS_MEMUSED 5
 
 
8167
8168 /*
8169 ** CAPI3REF: Custom Page Cache Object
8170 **
8171 ** The sqlite3_pcache type is opaque. It is implemented by
@@ -11528,12 +11630,13 @@
11528
11529 /*
11530 ** Include the configuration header output by 'configure' if we're using the
11531 ** autoconf-based build
11532 */
11533 #ifdef _HAVE_SQLITE_CONFIG_H
11534 #include "config.h"
 
11535 #endif
11536
11537 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
11538 /************** Begin file sqliteLimit.h *************************************/
11539 /*
@@ -13695,10 +13798,16 @@
13695 #define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
13696
13697 /************** End of opcodes.h *********************************************/
13698 /************** Continuing where we left off in vdbe.h ***********************/
13699
 
 
 
 
 
 
13700 /*
13701 ** Prototypes for the VDBE interface. See comments on the implementation
13702 ** for a description of what each of these routines does.
13703 */
13704 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13752,11 +13861,12 @@
13752 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
13753 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
13754 SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
13755 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
13756 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13757 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
 
13758 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
13759 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
13760 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
13761 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
13762 #ifndef SQLITE_OMIT_TRACE
@@ -14974,12 +15084,12 @@
14974 ** Value constraints (enforced via assert()):
14975 ** SQLITE_FullFSync == PAGER_FULLFSYNC
14976 ** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
14977 ** SQLITE_CacheSpill == PAGER_CACHE_SPILL
14978 */
14979 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
14980 #define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
14981 #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
14982 #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
14983 #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
14984 #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
14985 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -14986,33 +15096,38 @@
14986 #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
14987 /* DELETE, or UPDATE and return */
14988 /* the count using a callback. */
14989 #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
14990 /* result set is empty */
14991 #define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
14992 #define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
14993 #define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
14994 #define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
14995 #define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
14996 #define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
14997 #define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
14998 #define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
14999 #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
15000 #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
15001 #define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
15002 #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
15003 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
15004 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
15005 #define SQLITE_LoadExtFunc 0x00800000 /* Enable load_extension() SQL func */
15006 #define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */
15007 #define SQLITE_DeferFKs 0x02000000 /* Defer all FK constraints */
15008 #define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
15009 #define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
15010 #define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
15011 #define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
15012 #define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
15013 #define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
 
 
 
 
 
15014
15015
15016 /*
15017 ** Bits of the sqlite3.dbOptFlags field that are used by the
15018 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17305,14 +17420,14 @@
17305 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
17306 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
17307 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
17308 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
17309 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
17310 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
17311 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
17312 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
17313 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
17314 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
17315 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
17316 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
17317 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
17318 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18606,22 +18721,22 @@
18606 int rcApp; /* errcode set by sqlite3_result_error_code() */
18607 #endif
18608 u16 nResColumn; /* Number of columns in one row of the result set */
18609 u8 errorAction; /* Recovery action to do in case of an error */
18610 u8 minWriteFileFormat; /* Minimum file format for writable database files */
 
18611 bft expired:1; /* True if the VM needs to be recompiled */
18612 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
18613 bft explain:2; /* True if EXPLAIN present on SQL command */
18614 bft changeCntOn:1; /* True to update the change-counter */
18615 bft runOnlyOnce:1; /* Automatically expire on reset */
18616 bft usesStmtJournal:1; /* True if uses a statement journal */
18617 bft readOnly:1; /* True for statements that do not write */
18618 bft bIsReader:1; /* True for statements that read */
18619 bft isPrepareV2:1; /* True if prepared with prepare_v2() */
18620 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
18621 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18622 u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
18623 char *zSql; /* Text of the SQL statement that generated this */
18624 void *pFree; /* Free this when deleting the vdbe */
18625 VdbeFrame *pFrame; /* Parent frame */
18626 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
18627 int nFrame; /* Number of frames in pFrame list */
@@ -59469,11 +59584,11 @@
59469 /* If this database is not shareable, or if the client is reading
59470 ** and has the read-uncommitted flag set, then no lock is required.
59471 ** Return true immediately.
59472 */
59473 if( (pBtree->sharable==0)
59474 || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))
59475 ){
59476 return 1;
59477 }
59478
59479 /* If the client is reading or writing an index and the schema is
@@ -59546,11 +59661,11 @@
59546 static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
59547 BtCursor *p;
59548 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
59549 if( p->pgnoRoot==iRoot
59550 && p->pBtree!=pBtree
59551 && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted)
59552 ){
59553 return 1;
59554 }
59555 }
59556 return 0;
@@ -59568,11 +59683,11 @@
59568 BtLock *pIter;
59569
59570 assert( sqlite3BtreeHoldsMutex(p) );
59571 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
59572 assert( p->db!=0 );
59573 assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 );
59574
59575 /* If requesting a write-lock, then the Btree must have an open write
59576 ** transaction on this file. And, obviously, for this to be so there
59577 ** must be an open write transaction on the file itself.
59578 */
@@ -59646,11 +59761,11 @@
59646
59647 /* A connection with the read-uncommitted flag set will never try to
59648 ** obtain a read-lock using this function. The only read-lock obtained
59649 ** by a connection in read-uncommitted mode is on the sqlite_master
59650 ** table, and that lock is obtained in BtreeBeginTrans(). */
59651 assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );
59652
59653 /* This function should only be called on a sharable b-tree after it
59654 ** has been determined that no other b-tree holds a conflicting lock. */
59655 assert( p->sharable );
59656 assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -62338,11 +62453,11 @@
62338 freeTempSpace(pBt);
62339 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
62340 pageSize-usableSize);
62341 return rc;
62342 }
62343 if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
62344 rc = SQLITE_CORRUPT_BKPT;
62345 goto page1_init_failed;
62346 }
62347 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
62348 ** be less than 480. In other words, if the page size is 512, then the
@@ -71465,28 +71580,25 @@
71465 sqlite3 *db = pParse->db;
71466
71467 /* Skip over any TK_COLLATE nodes */
71468 pExpr = sqlite3ExprSkipCollate(pExpr);
71469
 
71470 if( !pExpr ){
71471 pVal = valueNew(db, pAlloc);
71472 if( pVal ){
71473 sqlite3VdbeMemSetNull((Mem*)pVal);
71474 }
71475 }else if( pExpr->op==TK_VARIABLE
71476 || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
71477 ){
71478 Vdbe *v;
71479 int iBindVar = pExpr->iColumn;
71480 sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
71481 if( (v = pParse->pReprepare)!=0 ){
71482 pVal = valueNew(db, pAlloc);
71483 if( pVal ){
71484 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71485 if( rc==SQLITE_OK ){
71486 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
71487 }
71488 pVal->db = pParse->db;
71489 }
71490 }
71491 }else{
71492 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71756,20 +71868,18 @@
71756 }
71757
71758 /*
71759 ** Remember the SQL string for a prepared statement.
71760 */
71761 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71762 assert( isPrepareV2==1 || isPrepareV2==0 );
71763 if( p==0 ) return;
71764 if( !isPrepareV2 ) p->expmask = 0;
71765 #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71766 if( !isPrepareV2 ) return;
71767 #endif
71768 assert( p->zSql==0 );
71769 p->zSql = sqlite3DbStrNDup(p->db, z, n);
71770 p->isPrepareV2 = (u8)isPrepareV2;
71771 }
71772
71773 /*
71774 ** Swap all content between two VDBE structures.
71775 */
@@ -71787,12 +71897,14 @@
71787 pA->pPrev = pB->pPrev;
71788 pB->pPrev = pTmp;
71789 zTmp = pA->zSql;
71790 pA->zSql = pB->zSql;
71791 pB->zSql = zTmp;
71792 pB->isPrepareV2 = pA->isPrepareV2;
71793 pB->expmask = pA->expmask;
 
 
 
71794 }
71795
71796 /*
71797 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71798 ** than its current size. nOp is guaranteed to be less than or equal
@@ -76231,10 +76343,17 @@
76231 ** Return the database associated with the Vdbe.
76232 */
76233 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
76234 return v->db;
76235 }
 
 
 
 
 
 
 
76236
76237 /*
76238 ** Return a pointer to an sqlite3_value structure containing the value bound
76239 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
76240 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
@@ -76244,10 +76363,11 @@
76244 */
76245 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
76246 assert( iVar>0 );
76247 if( v ){
76248 Mem *pMem = &v->aVar[iVar-1];
 
76249 if( 0==(pMem->flags & MEM_Null) ){
76250 sqlite3_value *pRet = sqlite3ValueNew(v->db);
76251 if( pRet ){
76252 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
76253 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76263,10 +76383,11 @@
76263 ** to sqlite3_reoptimize() that re-preparing the statement may result
76264 ** in a better query plan.
76265 */
76266 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
76267 assert( iVar>0 );
 
76268 if( iVar>=32 ){
76269 v->expmask |= 0x80000000;
76270 }else{
76271 v->expmask |= ((u32)1 << (iVar-1));
76272 }
@@ -76534,11 +76655,11 @@
76534 sqlite3_mutex_enter(mutex);
76535 for(i=0; i<p->nVar; i++){
76536 sqlite3VdbeMemRelease(&p->aVar[i]);
76537 p->aVar[i].flags = MEM_Null;
76538 }
76539 assert( p->isPrepareV2 || p->expmask==0 );
76540 if( p->expmask ){
76541 p->expired = 1;
76542 }
76543 sqlite3_mutex_leave(mutex);
76544 return rc;
@@ -77013,12 +77134,15 @@
77013 */
77014 assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
77015 || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
77016 );
77017 assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
77018 if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
77019 /* If this statement was prepared using sqlite3_prepare_v2(), and an
 
 
 
77020 ** error has occurred, then return the error code in p->rc to the
77021 ** caller. Set the error code in the database handle to the same value.
77022 */
77023 rc = sqlite3VdbeTransferError(p);
77024 }
@@ -77653,11 +77777,11 @@
77653 ** parameter in the WHERE clause might influence the choice of query plan
77654 ** for a statement, then the statement will be automatically recompiled,
77655 ** as if there had been a schema change, on the first sqlite3_step() call
77656 ** following any change to the bindings of that parameter.
77657 */
77658 assert( p->isPrepareV2 || p->expmask==0 );
77659 if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
77660 p->expired = 1;
77661 }
77662 return SQLITE_OK;
77663 }
@@ -77919,15 +78043,15 @@
77919 Vdbe *pFrom = (Vdbe*)pFromStmt;
77920 Vdbe *pTo = (Vdbe*)pToStmt;
77921 if( pFrom->nVar!=pTo->nVar ){
77922 return SQLITE_ERROR;
77923 }
77924 assert( pTo->isPrepareV2 || pTo->expmask==0 );
77925 if( pTo->expmask ){
77926 pTo->expired = 1;
77927 }
77928 assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
77929 if( pFrom->expmask ){
77930 pFrom->expired = 1;
77931 }
77932 return sqlite3TransferBindings(pFromStmt, pToStmt);
77933 }
@@ -85158,11 +85282,11 @@
85158 ** P4 contains a pointer to the name of the table being locked. This is only
85159 ** used to generate an error message if the lock cannot be obtained.
85160 */
85161 case OP_TableLock: {
85162 u8 isWriteLock = (u8)pOp->p3;
85163 if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){
85164 int p1 = pOp->p1;
85165 assert( p1>=0 && p1<db->nDb );
85166 assert( DbMaskTest(p->btreeMask, p1) );
85167 assert( isWriteLock==0 || isWriteLock==1 );
85168 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85666,10 +85790,11 @@
85666 if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
85667 }
85668 pOp->p1 = 0;
85669 }
85670 pOp->p1++;
 
85671 goto jump_to_p2;
85672 }
85673
85674 #ifdef SQLITE_ENABLE_CURSOR_HINTS
85675 /* Opcode: CursorHint P1 * * P4 *
@@ -90568,11 +90693,11 @@
90568 /* Try to match the ORDER BY expression against an expression
90569 ** in the result set. Return an 1-based index of the matching
90570 ** result-set entry.
90571 */
90572 for(i=0; i<pEList->nExpr; i++){
90573 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
90574 return i+1;
90575 }
90576 }
90577
90578 /* If no match, return 0. */
@@ -90802,11 +90927,11 @@
90802 pItem->u.x.iOrderByCol = 0;
90803 if( sqlite3ResolveExprNames(pNC, pE) ){
90804 return 1;
90805 }
90806 for(j=0; j<pSelect->pEList->nExpr; j++){
90807 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90808 pItem->u.x.iOrderByCol = j+1;
90809 }
90810 }
90811 }
90812 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -93027,11 +93152,11 @@
93027
93028 /* Check if pExpr is identical to any GROUP BY term. If so, consider
93029 ** it constant. */
93030 for(i=0; i<pGroupBy->nExpr; i++){
93031 Expr *p = pGroupBy->a[i].pExpr;
93032 if( sqlite3ExprCompare(pExpr, p, -1)<2 ){
93033 CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
93034 if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
93035 return WRC_Prune;
93036 }
93037 }
@@ -95303,11 +95428,11 @@
95303 p = pParse->pConstExpr;
95304 if( regDest<0 && p ){
95305 struct ExprList_item *pItem;
95306 int i;
95307 for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95308 if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
95309 return pItem->u.iConstExprReg;
95310 }
95311 }
95312 }
95313 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95858,10 +95983,45 @@
95858 sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
95859 }
95860 sqlite3ExprDelete(db, pCopy);
95861 }
95862
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95863
95864 /*
95865 ** Do a deep comparison of two expression trees. Return 0 if the two
95866 ** expressions are completely identical. Return 1 if they differ only
95867 ** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -95880,28 +96040,38 @@
95880 ** expressions are the same. But if you get a 0 or 1 return, then you
95881 ** can be sure the expressions are the same. In the places where
95882 ** this routine is used, it does not hurt to get an extra 2 - that
95883 ** just might result in some slightly slower code. But returning
95884 ** an incorrect 0 or 1 could lead to a malfunction.
 
 
 
 
 
 
 
95885 */
95886 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
95887 u32 combinedFlags;
95888 if( pA==0 || pB==0 ){
95889 return pB==pA ? 0 : 2;
 
 
 
95890 }
95891 combinedFlags = pA->flags | pB->flags;
95892 if( combinedFlags & EP_IntValue ){
95893 if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
95894 return 0;
95895 }
95896 return 2;
95897 }
95898 if( pA->op!=pB->op ){
95899 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
95900 return 1;
95901 }
95902 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
95903 return 1;
95904 }
95905 return 2;
95906 }
95907 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -95912,12 +96082,12 @@
95912 }
95913 }
95914 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
95915 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
95916 if( combinedFlags & EP_xIsSelect ) return 2;
95917 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
95918 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
95919 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
95920 if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
95921 if( pA->iColumn!=pB->iColumn ) return 2;
95922 if( pA->iTable!=pB->iTable
95923 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -95948,21 +96118,21 @@
95948 if( pA->nExpr!=pB->nExpr ) return 1;
95949 for(i=0; i<pA->nExpr; i++){
95950 Expr *pExprA = pA->a[i].pExpr;
95951 Expr *pExprB = pB->a[i].pExpr;
95952 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
95953 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
95954 }
95955 return 0;
95956 }
95957
95958 /*
95959 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
95960 ** are ignored.
95961 */
95962 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
95963 return sqlite3ExprCompare(
95964 sqlite3ExprSkipCollate(pA),
95965 sqlite3ExprSkipCollate(pB),
95966 iTab);
95967 }
95968
@@ -95980,28 +96150,33 @@
95980 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
95981 **
95982 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
95983 ** Expr.iTable<0 then assume a table number given by iTab.
95984 **
 
 
 
 
 
95985 ** When in doubt, return false. Returning true might give a performance
95986 ** improvement. Returning false might cause a performance reduction, but
95987 ** it will always give the correct answer and is hence always safe.
95988 */
95989 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
95990 if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
95991 return 1;
95992 }
95993 if( pE2->op==TK_OR
95994 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
95995 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
95996 ){
95997 return 1;
95998 }
95999 if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
96000 Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
96001 testcase( pX!=pE1->pLeft );
96002 if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
96003 }
96004 return 0;
96005 }
96006
96007 /*
@@ -96238,11 +96413,11 @@
96238 /* Check to see if pExpr is a duplicate of another aggregate
96239 ** function that is already in the pAggInfo structure
96240 */
96241 struct AggInfo_func *pItem = pAggInfo->aFunc;
96242 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
96243 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
96244 break;
96245 }
96246 }
96247 if( i>=pAggInfo->nFunc ){
96248 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96795,11 +96970,11 @@
96795 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
96796 **
96797 ** Or, if zName is not a system table, zero is returned.
96798 */
96799 static int isSystemTable(Parse *pParse, const char *zName){
96800 if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96801 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
96802 return 1;
96803 }
96804 return 0;
96805 }
@@ -104193,11 +104368,13 @@
104193 for(j=0; j<pIdx->nKeyCol; j++){
104194 char *zCol;
104195 assert( pIdx->aiColumn[j]>=0 );
104196 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
104197 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
104198 sqlite3XPrintf(&errMsg, "%s.%s", pTab->zName, zCol);
 
 
104199 }
104200 }
104201 zErr = sqlite3StrAccumFinish(&errMsg);
104202 sqlite3HaltConstraint(pParse,
104203 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -111051,11 +111228,11 @@
111051 if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
111052 return 0; /* Different columns indexed */
111053 }
111054 if( pSrc->aiColumn[i]==XN_EXPR ){
111055 assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
111056 if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr,
111057 pDest->aColExpr->a[i].pExpr, -1)!=0 ){
111058 return 0; /* Different expressions in the index */
111059 }
111060 }
111061 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111063,11 +111240,11 @@
111063 }
111064 if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
111065 return 0; /* Different collating sequences */
111066 }
111067 }
111068 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111069 return 0; /* Different WHERE clauses */
111070 }
111071
111072 /* If no test above fails then the indices must be compatible */
111073 return 1;
@@ -111543,15 +111720,12 @@
111543 if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111544 sqlite3DbFree(db, azCols);
111545
111546 rc = sqlite3ApiExit(db, rc);
111547 if( rc!=SQLITE_OK && pzErrMsg ){
111548 int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
111549 *pzErrMsg = sqlite3Malloc(nErrMsg);
111550 if( *pzErrMsg ){
111551 memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
111552 }else{
111553 rc = SQLITE_NOMEM_BKPT;
111554 sqlite3Error(db, SQLITE_NOMEM);
111555 }
111556 }else if( pzErrMsg ){
111557 *pzErrMsg = 0;
@@ -113415,11 +113589,11 @@
113415 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113416 {/* zName: */ "read_uncommitted",
113417 /* ePragTyp: */ PragTyp_FLAG,
113418 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113419 /* ColNames: */ 0, 0,
113420 /* iArg: */ SQLITE_ReadUncommitted },
113421 {/* zName: */ "recursive_triggers",
113422 /* ePragTyp: */ PragTyp_FLAG,
113423 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113424 /* ColNames: */ 0, 0,
113425 /* iArg: */ SQLITE_RecTriggers },
@@ -113567,11 +113741,11 @@
113567 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113568 {/* zName: */ "writable_schema",
113569 /* ePragTyp: */ PragTyp_FLAG,
113570 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113571 /* ColNames: */ 0, 0,
113572 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
113573 #endif
113574 };
113575 /* Number of pragmas: 60 on by default, 74 total. */
113576
113577 /************** End of pragma.h **********************************************/
@@ -116009,11 +116183,11 @@
116009 InitData *pData, /* Initialization context */
116010 const char *zObj, /* Object being parsed at the point of error */
116011 const char *zExtra /* Error information */
116012 ){
116013 sqlite3 *db = pData->db;
116014 if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
116015 char *z;
116016 if( zObj==0 ) zObj = "?";
116017 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
116018 if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
116019 sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116296,12 +116470,12 @@
116296 }
116297 if( db->mallocFailed ){
116298 rc = SQLITE_NOMEM_BKPT;
116299 sqlite3ResetAllSchemasOfConnection(db);
116300 }
116301 if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){
116302 /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider
116303 ** the schema loaded, even if errors occurred. In this situation the
116304 ** current sqlite3_prepare() operation will fail, but the following one
116305 ** will attempt to compile the supplied statement against whatever subset
116306 ** of the schema was loaded before the error occurred. The primary
116307 ** purpose of this is to allow access to the sqlite_master table
@@ -116497,11 +116671,11 @@
116497 */
116498 static int sqlite3Prepare(
116499 sqlite3 *db, /* Database handle. */
116500 const char *zSql, /* UTF-8 encoded SQL statement. */
116501 int nBytes, /* Length of zSql in bytes. */
116502 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116503 Vdbe *pReprepare, /* VM being reprepared */
116504 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116505 const char **pzTail /* OUT: End of parsed string */
116506 ){
116507 char *zErrMsg = 0; /* Error message */
@@ -116513,10 +116687,18 @@
116513 memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
116514 sParse.pReprepare = pReprepare;
116515 assert( ppStmt && *ppStmt==0 );
116516 /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116517 assert( sqlite3_mutex_held(db->mutex) );
 
 
 
 
 
 
 
 
116518
116519 /* Check to verify that it is possible to get a read lock on all
116520 ** database schemas. The inability to get a read lock indicates that
116521 ** some other database connection is holding a write-lock, which in
116522 ** turn means that the other connection has made uncommitted changes
@@ -116545,11 +116727,11 @@
116545 assert( sqlite3BtreeHoldsMutex(pBt) );
116546 rc = sqlite3BtreeSchemaLocked(pBt);
116547 if( rc ){
116548 const char *zDb = db->aDb[i].zDbSName;
116549 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116550 testcase( db->flags & SQLITE_ReadUncommitted );
116551 goto end_prepare;
116552 }
116553 }
116554 }
116555
@@ -116613,12 +116795,11 @@
116613 }
116614 }
116615 #endif
116616
116617 if( db->init.busy==0 ){
116618 Vdbe *pVdbe = sParse.pVdbe;
116619 sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag);
116620 }
116621 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116622 sqlite3VdbeFinalize(sParse.pVdbe);
116623 assert(!(*ppStmt));
116624 }else{
@@ -116648,11 +116829,11 @@
116648 }
116649 static int sqlite3LockAndPrepare(
116650 sqlite3 *db, /* Database handle. */
116651 const char *zSql, /* UTF-8 encoded SQL statement. */
116652 int nBytes, /* Length of zSql in bytes. */
116653 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116654 Vdbe *pOld, /* VM being reprepared */
116655 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116656 const char **pzTail /* OUT: End of parsed string */
116657 ){
116658 int rc;
@@ -116664,14 +116845,14 @@
116664 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116665 return SQLITE_MISUSE_BKPT;
116666 }
116667 sqlite3_mutex_enter(db->mutex);
116668 sqlite3BtreeEnterAll(db);
116669 rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116670 if( rc==SQLITE_SCHEMA ){
116671 sqlite3_finalize(*ppStmt);
116672 rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116673 }
116674 sqlite3BtreeLeaveAll(db);
116675 sqlite3_mutex_leave(db->mutex);
116676 assert( rc==SQLITE_OK || *ppStmt==0 );
116677 return rc;
@@ -116688,17 +116869,19 @@
116688 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116689 int rc;
116690 sqlite3_stmt *pNew;
116691 const char *zSql;
116692 sqlite3 *db;
 
116693
116694 assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116695 zSql = sqlite3_sql((sqlite3_stmt *)p);
116696 assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116697 db = sqlite3VdbeDb(p);
116698 assert( sqlite3_mutex_held(db->mutex) );
116699 rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);
 
116700 if( rc ){
116701 if( rc==SQLITE_NOMEM ){
116702 sqlite3OomFault(db);
116703 }
116704 assert( pNew==0 );
@@ -116740,11 +116923,27 @@
116740 int nBytes, /* Length of zSql in bytes. */
116741 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116742 const char **pzTail /* OUT: End of parsed string */
116743 ){
116744 int rc;
116745 rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116746 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116747 return rc;
116748 }
116749
116750
@@ -116754,11 +116953,11 @@
116754 */
116755 static int sqlite3Prepare16(
116756 sqlite3 *db, /* Database handle. */
116757 const void *zSql, /* UTF-16 encoded SQL statement. */
116758 int nBytes, /* Length of zSql in bytes. */
116759 int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */
116760 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116761 const void **pzTail /* OUT: End of parsed string */
116762 ){
116763 /* This function currently works by first transforming the UTF-16
116764 ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116782,11 +116981,11 @@
116782 nBytes = sz;
116783 }
116784 sqlite3_mutex_enter(db->mutex);
116785 zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116786 if( zSql8 ){
116787 rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
116788 }
116789
116790 if( zTail8 && pzTail ){
116791 /* If sqlite3_prepare returns a tail pointer, we calculate the
116792 ** equivalent pointer into the UTF-16 string by counting the unicode
@@ -116828,11 +117027,26 @@
116828 int nBytes, /* Length of zSql in bytes. */
116829 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116830 const void **pzTail /* OUT: End of parsed string */
116831 ){
116832 int rc;
116833 rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116834 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116835 return rc;
116836 }
116837
116838 #endif /* SQLITE_OMIT_UTF16 */
@@ -121844,11 +122058,13 @@
121844 if( pItem->pSelect==0 ) continue;
121845 if( pItem->fg.viaCoroutine ) continue;
121846 if( pItem->zName==0 ) continue;
121847 if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
121848 if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
121849 if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){
 
 
121850 /* The view was modified by some other optimization such as
121851 ** pushDownWhereTerms() */
121852 continue;
121853 }
121854 return pItem;
@@ -128193,11 +128409,11 @@
128193 ** If pExpr matches, then transform it into a reference to the index column
128194 ** that contains the value of pExpr.
128195 */
128196 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
128197 IdxExprTrans *pX = p->u.pIdxTrans;
128198 if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128199 pExpr->op = TK_COLUMN;
128200 pExpr->iTable = pX->iIdxCur;
128201 pExpr->iColumn = pX->iIdxCol;
128202 pExpr->pTab = 0;
128203 return WRC_Prune;
@@ -129487,11 +129703,11 @@
129487 pList = pExpr->x.pList;
129488 pLeft = pList->a[1].pExpr;
129489
129490 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129491 op = pRight->op;
129492 if( op==TK_VARIABLE ){
129493 Vdbe *pReprepare = pParse->pReprepare;
129494 int iCol = pRight->iColumn;
129495 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129496 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129497 z = (char *)sqlite3_value_text(pVal);
@@ -129677,12 +129893,12 @@
129677 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129678 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129679 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129680 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129681 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129682 if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129683 if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
129684 /* If we reach this point, it means the two subterms can be combined */
129685 if( (eOp & (eOp-1))!=0 ){
129686 if( eOp & (WO_LT|WO_LE) ){
129687 eOp = WO_LE;
129688 }else{
@@ -130449,10 +130665,13 @@
130449 prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130450 if( (prereqExpr & prereqColumn)==0 ){
130451 Expr *pNewExpr;
130452 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130453 0, sqlite3ExprDup(db, pRight, 0));
 
 
 
130454 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130455 testcase( idxNew==0 );
130456 pNewTerm = &pWC->a[idxNew];
130457 pNewTerm->prereqRight = prereqExpr;
130458 pNewTerm->leftCursor = pLeft->iTable;
@@ -133387,11 +133606,11 @@
133387 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133388 }
133389 }else if( (aColExpr = pIndex->aColExpr)!=0 ){
133390 for(jj=0; jj<pIndex->nKeyCol; jj++){
133391 if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133392 if( sqlite3ExprCompare(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133393 return 1;
133394 }
133395 }
133396 }
133397 }
@@ -133420,18 +133639,20 @@
133420 ** in the current query. Return true if it can be and false if not.
133421 */
133422 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133423 int i;
133424 WhereTerm *pTerm;
 
133425 while( pWhere->op==TK_AND ){
133426 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133427 pWhere = pWhere->pRight;
133428 }
 
133429 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133430 Expr *pExpr = pTerm->pExpr;
133431 if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
133432 && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133433 ){
133434 return 1;
133435 }
133436 }
133437 return 0;
@@ -134406,11 +134627,12 @@
134406 if( iColumn>=(-1) ){
134407 if( pOBExpr->op!=TK_COLUMN ) continue;
134408 if( pOBExpr->iTable!=iCur ) continue;
134409 if( pOBExpr->iColumn!=iColumn ) continue;
134410 }else{
134411 if( sqlite3ExprCompare(pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
 
134412 continue;
134413 }
134414 }
134415 if( iColumn>=0 ){
134416 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134705,10 +134927,11 @@
134705 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134706 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134707 rUnsorted, rCost));
134708 }else{
134709 rCost = rUnsorted;
 
134710 }
134711
134712 /* Check to see if pWLoop should be added to the set of
134713 ** mxChoice best-so-far paths.
134714 **
@@ -136126,19 +136349,19 @@
136126 #define sqlite3ParserARG_PDECL ,Parse *pParse
136127 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136128 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
136129 #define YYFALLBACK 1
136130 #define YYNSTATE 456
136131 #define YYNRULE 332
136132 #define YY_MAX_SHIFT 455
136133 #define YY_MIN_SHIFTREDUCE 668
136134 #define YY_MAX_SHIFTREDUCE 999
136135 #define YY_MIN_REDUCE 1000
136136 #define YY_MAX_REDUCE 1331
136137 #define YY_ERROR_ACTION 1332
136138 #define YY_ACCEPT_ACTION 1333
136139 #define YY_NO_ACTION 1334
136140 /************* End control #defines *******************************************/
136141
136142 /* Define the yytestcase() macro to be a no-op if is not already defined
136143 ** otherwise.
136144 **
@@ -136208,167 +136431,167 @@
136208 ** yy_default[] Default action for each state.
136209 **
136210 *********** Begin parsing tables **********************************************/
136211 #define YY_ACTTAB_COUNT (1566)
136212 static const YYACTIONTYPE yy_action[] = {
136213 /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98,
136214 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136215 /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813,
136216 /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96,
136217 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136218 /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136219 /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136220 /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262,
136221 /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791,
136222 /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95,
136223 /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96,
136224 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813,
136225 /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90,
136226 /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136227 /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136228 /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75,
136229 /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262,
136230 /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371,
136231 /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824,
136232 /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380,
136233 /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845,
136234 /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136235 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132,
136236 /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93,
136237 /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334,
136238 /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845,
136239 /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96,
136240 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136241 /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888,
136242 /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959,
136243 /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978,
136244 /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702,
136245 /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99,
136246 /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136247 /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94,
136248 /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231,
136249 /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25,
136250 /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74,
136251 /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813,
136252 /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415,
136253 /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856,
136254 /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96,
136255 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136256 /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262,
136257 /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959,
136258 /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711,
136259 /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447,
136260 /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178,
136261 /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136262 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136263 /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916,
136264 /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157,
136265 /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415,
136266 /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777,
136267 /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52,
136268 /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90,
136269 /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136270 /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136271 /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450,
136272 /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420,
136273 /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36,
136274 /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425,
136275 /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326,
136276 /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845,
136277 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136278 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846,
136279 /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350,
136280 /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327,
136281 /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978,
136282 /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776,
136283 /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99,
136284 /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136285 /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94,
136286 /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978,
136287 /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675,
136288 /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99,
136289 /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136290 /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136291 /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450,
136292 /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228,
136293 /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31,
136294 /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44,
136295 /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268,
136296 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856,
136297 /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96,
136298 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136299 /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48,
136300 /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245,
136301 /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817,
136302 /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124,
136303 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136304 /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136305 /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136306 /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817,
136307 /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944,
136308 /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107,
136309 /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136310 /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136311 /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742,
136312 /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133,
136313 /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121,
136314 /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97,
136315 /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95,
136316 /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136317 /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263,
136318 /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112,
136319 /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97,
136320 /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136321 /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345,
136322 /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709,
136323 /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110,
136324 /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97,
136325 /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95,
136326 /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136327 /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785,
136328 /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55,
136329 /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709,
136330 /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120,
136331 /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26,
136332 /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390,
136333 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136334 /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730,
136335 /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819,
136336 /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3,
136337 /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824,
136338 /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951,
136339 /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7,
136340 /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713,
136341 /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205,
136342 /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144,
136343 /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366,
136344 /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140,
136345 /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683,
136346 /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383,
136347 /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824,
136348 /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271,
136349 /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85,
136350 /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711,
136351 /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724,
136352 /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290,
136353 /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827,
136354 /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434,
136355 /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136356 /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217,
136357 /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669,
136358 /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136359 /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889,
136360 /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63,
136361 /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13,
136362 /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19,
136363 /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722,
136364 /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830,
136365 /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220,
136366 /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18,
136367 /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163,
136368 /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695,
136369 /* 1560 */ 87, 312, 309, 947, 1291, 1290,
136370 };
136371 static const YYCODETYPE yy_lookahead[] = {
136372 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136373 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136374 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136617,56 +136840,56 @@
136617 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136618 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136619 /* 320 */ 1280, 1281, 1264, 1269, 1283,
136620 };
136621 static const YYACTIONTYPE yy_default[] = {
136622 /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
136623 /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
136624 /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
136625 /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
136626 /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
136627 /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
136628 /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136629 /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136630 /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136631 /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136632 /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
136633 /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
136634 /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
136635 /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136636 /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136637 /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
136638 /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
136639 /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136640 /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
136641 /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136642 /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
136643 /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
136644 /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
136645 /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
136646 /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
136647 /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
136648 /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
136649 /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
136650 /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
136651 /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
136652 /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
136653 /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
136654 /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
136655 /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
136656 /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136657 /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
136658 /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136659 /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
136660 /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
136661 /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136662 /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136663 /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
136664 /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
136665 /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
136666 /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
136667 /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
136668 };
136669 /********** End of lemon-generated parsing tables *****************************/
136670
136671 /* The next table maps tokens (terminal symbols) into fallback tokens.
136672 ** If a construct like the following:
@@ -136796,10 +137019,11 @@
136796 int yystksz; /* Current side of the stack */
136797 yyStackEntry *yystack; /* The parser's stack */
136798 yyStackEntry yystk0; /* First stack entry */
136799 #else
136800 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
 
136801 #endif
136802 };
136803 typedef struct yyParser yyParser;
136804
136805 #ifndef NDEBUG
@@ -137134,114 +137358,113 @@
137134 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137135 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137136 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137137 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137138 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137139 /* 228 */ "trigger_time ::= BEFORE",
137140 /* 229 */ "trigger_time ::= AFTER",
137141 /* 230 */ "trigger_time ::= INSTEAD OF",
137142 /* 231 */ "trigger_time ::=",
137143 /* 232 */ "trigger_event ::= DELETE|INSERT",
137144 /* 233 */ "trigger_event ::= UPDATE",
137145 /* 234 */ "trigger_event ::= UPDATE OF idlist",
137146 /* 235 */ "when_clause ::=",
137147 /* 236 */ "when_clause ::= WHEN expr",
137148 /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137149 /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137150 /* 239 */ "trnm ::= nm DOT nm",
137151 /* 240 */ "tridxby ::= INDEXED BY nm",
137152 /* 241 */ "tridxby ::= NOT INDEXED",
137153 /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137154 /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137155 /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137156 /* 245 */ "trigger_cmd ::= select",
137157 /* 246 */ "expr ::= RAISE LP IGNORE RP",
137158 /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137159 /* 248 */ "raisetype ::= ROLLBACK",
137160 /* 249 */ "raisetype ::= ABORT",
137161 /* 250 */ "raisetype ::= FAIL",
137162 /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
137163 /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137164 /* 253 */ "cmd ::= DETACH database_kw_opt expr",
137165 /* 254 */ "key_opt ::=",
137166 /* 255 */ "key_opt ::= KEY expr",
137167 /* 256 */ "cmd ::= REINDEX",
137168 /* 257 */ "cmd ::= REINDEX nm dbnm",
137169 /* 258 */ "cmd ::= ANALYZE",
137170 /* 259 */ "cmd ::= ANALYZE nm dbnm",
137171 /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137172 /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137173 /* 262 */ "add_column_fullname ::= fullname",
137174 /* 263 */ "cmd ::= create_vtab",
137175 /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
137176 /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137177 /* 266 */ "vtabarg ::=",
137178 /* 267 */ "vtabargtoken ::= ANY",
137179 /* 268 */ "vtabargtoken ::= lp anylist RP",
137180 /* 269 */ "lp ::= LP",
137181 /* 270 */ "with ::=",
137182 /* 271 */ "with ::= WITH wqlist",
137183 /* 272 */ "with ::= WITH RECURSIVE wqlist",
137184 /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137185 /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137186 /* 275 */ "input ::= cmdlist",
137187 /* 276 */ "cmdlist ::= cmdlist ecmd",
137188 /* 277 */ "cmdlist ::= ecmd",
137189 /* 278 */ "ecmd ::= SEMI",
137190 /* 279 */ "ecmd ::= explain cmdx SEMI",
137191 /* 280 */ "explain ::=",
137192 /* 281 */ "trans_opt ::=",
137193 /* 282 */ "trans_opt ::= TRANSACTION",
137194 /* 283 */ "trans_opt ::= TRANSACTION nm",
137195 /* 284 */ "savepoint_opt ::= SAVEPOINT",
137196 /* 285 */ "savepoint_opt ::=",
137197 /* 286 */ "cmd ::= create_table create_table_args",
137198 /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
137199 /* 288 */ "columnlist ::= columnname carglist",
137200 /* 289 */ "nm ::= ID|INDEXED",
137201 /* 290 */ "nm ::= STRING",
137202 /* 291 */ "nm ::= JOIN_KW",
137203 /* 292 */ "typetoken ::= typename",
137204 /* 293 */ "typename ::= ID|STRING",
137205 /* 294 */ "signed ::= plus_num",
137206 /* 295 */ "signed ::= minus_num",
137207 /* 296 */ "carglist ::= carglist ccons",
137208 /* 297 */ "carglist ::=",
137209 /* 298 */ "ccons ::= NULL onconf",
137210 /* 299 */ "conslist_opt ::= COMMA conslist",
137211 /* 300 */ "conslist ::= conslist tconscomma tcons",
137212 /* 301 */ "conslist ::= tcons",
137213 /* 302 */ "tconscomma ::=",
137214 /* 303 */ "defer_subclause_opt ::= defer_subclause",
137215 /* 304 */ "resolvetype ::= raisetype",
137216 /* 305 */ "selectnowith ::= oneselect",
137217 /* 306 */ "oneselect ::= values",
137218 /* 307 */ "sclp ::= selcollist COMMA",
137219 /* 308 */ "as ::= ID|STRING",
137220 /* 309 */ "expr ::= term",
137221 /* 310 */ "likeop ::= LIKE_KW|MATCH",
137222 /* 311 */ "exprlist ::= nexprlist",
137223 /* 312 */ "nmnum ::= plus_num",
137224 /* 313 */ "nmnum ::= nm",
137225 /* 314 */ "nmnum ::= ON",
137226 /* 315 */ "nmnum ::= DELETE",
137227 /* 316 */ "nmnum ::= DEFAULT",
137228 /* 317 */ "plus_num ::= INTEGER|FLOAT",
137229 /* 318 */ "foreach_clause ::=",
137230 /* 319 */ "foreach_clause ::= FOR EACH ROW",
137231 /* 320 */ "trnm ::= nm",
137232 /* 321 */ "tridxby ::=",
137233 /* 322 */ "database_kw_opt ::= DATABASE",
137234 /* 323 */ "database_kw_opt ::=",
137235 /* 324 */ "kwcolumn_opt ::=",
137236 /* 325 */ "kwcolumn_opt ::= COLUMNKW",
137237 /* 326 */ "vtabarglist ::= vtabarg",
137238 /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137239 /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
137240 /* 329 */ "anylist ::=",
137241 /* 330 */ "anylist ::= anylist LP anylist RP",
137242 /* 331 */ "anylist ::= anylist ANY",
137243 };
137244 #endif /* NDEBUG */
137245
137246
137247 #if YYSTACKDEPTH<=0
@@ -137306,10 +137529,11 @@
137306 pParser->yyerrcnt = -1;
137307 #endif
137308 pParser->yytos = pParser->yystack;
137309 pParser->yystack[0].stateno = 0;
137310 pParser->yystack[0].major = 0;
 
137311 }
137312
137313 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137314 /*
137315 ** This function allocates a new parser.
@@ -137648,11 +137872,11 @@
137648 yypParser->yyhwm++;
137649 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137650 }
137651 #endif
137652 #if YYSTACKDEPTH>0
137653 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
137654 yypParser->yytos--;
137655 yyStackOverflow(yypParser);
137656 return;
137657 }
137658 #else
@@ -137676,345 +137900,344 @@
137676
137677 /* The following table contains information about every rule that
137678 ** is used during the reduce.
137679 */
137680 static const struct {
137681 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137682 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
137683 } yyRuleInfo[] = {
137684 { 147, 1 },
137685 { 147, 3 },
137686 { 148, 1 },
137687 { 149, 3 },
137688 { 150, 0 },
137689 { 150, 1 },
137690 { 150, 1 },
137691 { 150, 1 },
137692 { 149, 2 },
137693 { 149, 2 },
137694 { 149, 2 },
137695 { 149, 2 },
137696 { 149, 3 },
137697 { 149, 5 },
137698 { 154, 6 },
137699 { 156, 1 },
137700 { 158, 0 },
137701 { 158, 3 },
137702 { 157, 1 },
137703 { 157, 0 },
137704 { 155, 5 },
137705 { 155, 2 },
137706 { 162, 0 },
137707 { 162, 2 },
137708 { 164, 2 },
137709 { 166, 0 },
137710 { 166, 4 },
137711 { 166, 6 },
137712 { 167, 2 },
137713 { 171, 2 },
137714 { 171, 2 },
137715 { 171, 4 },
137716 { 171, 3 },
137717 { 171, 3 },
137718 { 171, 2 },
137719 { 171, 3 },
137720 { 171, 5 },
137721 { 171, 2 },
137722 { 171, 4 },
137723 { 171, 4 },
137724 { 171, 1 },
137725 { 171, 2 },
137726 { 176, 0 },
137727 { 176, 1 },
137728 { 178, 0 },
137729 { 178, 2 },
137730 { 180, 2 },
137731 { 180, 3 },
137732 { 180, 3 },
137733 { 180, 3 },
137734 { 181, 2 },
137735 { 181, 2 },
137736 { 181, 1 },
137737 { 181, 1 },
137738 { 181, 2 },
137739 { 179, 3 },
137740 { 179, 2 },
137741 { 182, 0 },
137742 { 182, 2 },
137743 { 182, 2 },
137744 { 161, 0 },
137745 { 184, 1 },
137746 { 185, 2 },
137747 { 185, 7 },
137748 { 185, 5 },
137749 { 185, 5 },
137750 { 185, 10 },
137751 { 188, 0 },
137752 { 174, 0 },
137753 { 174, 3 },
137754 { 189, 0 },
137755 { 189, 2 },
137756 { 190, 1 },
137757 { 190, 1 },
137758 { 149, 4 },
137759 { 192, 2 },
137760 { 192, 0 },
137761 { 149, 9 },
137762 { 149, 4 },
137763 { 149, 1 },
137764 { 163, 2 },
137765 { 194, 3 },
137766 { 197, 1 },
137767 { 197, 2 },
137768 { 197, 1 },
137769 { 195, 9 },
137770 { 206, 4 },
137771 { 206, 5 },
137772 { 198, 1 },
137773 { 198, 1 },
137774 { 198, 0 },
137775 { 209, 0 },
137776 { 199, 3 },
137777 { 199, 2 },
137778 { 199, 4 },
137779 { 210, 2 },
137780 { 210, 0 },
137781 { 200, 0 },
137782 { 200, 2 },
137783 { 212, 2 },
137784 { 212, 0 },
137785 { 211, 7 },
137786 { 211, 9 },
137787 { 211, 7 },
137788 { 211, 7 },
137789 { 159, 0 },
137790 { 159, 2 },
137791 { 193, 2 },
137792 { 213, 1 },
137793 { 213, 2 },
137794 { 213, 3 },
137795 { 213, 4 },
137796 { 215, 2 },
137797 { 215, 0 },
137798 { 214, 0 },
137799 { 214, 3 },
137800 { 214, 2 },
137801 { 216, 4 },
137802 { 216, 0 },
137803 { 204, 0 },
137804 { 204, 3 },
137805 { 186, 4 },
137806 { 186, 2 },
137807 { 175, 1 },
137808 { 175, 1 },
137809 { 175, 0 },
137810 { 202, 0 },
137811 { 202, 3 },
137812 { 203, 0 },
137813 { 203, 2 },
137814 { 205, 0 },
137815 { 205, 2 },
137816 { 205, 4 },
137817 { 205, 4 },
137818 { 149, 6 },
137819 { 201, 0 },
137820 { 201, 2 },
137821 { 149, 8 },
137822 { 218, 5 },
137823 { 218, 7 },
137824 { 218, 3 },
137825 { 218, 5 },
137826 { 149, 6 },
137827 { 149, 7 },
137828 { 219, 2 },
137829 { 219, 1 },
137830 { 220, 0 },
137831 { 220, 3 },
137832 { 217, 3 },
137833 { 217, 1 },
137834 { 173, 3 },
137835 { 172, 1 },
137836 { 173, 1 },
137837 { 173, 1 },
137838 { 173, 3 },
137839 { 173, 5 },
137840 { 172, 1 },
137841 { 172, 1 },
137842 { 172, 1 },
137843 { 173, 1 },
137844 { 173, 3 },
137845 { 173, 6 },
137846 { 173, 5 },
137847 { 173, 4 },
137848 { 172, 1 },
137849 { 173, 5 },
137850 { 173, 3 },
137851 { 173, 3 },
137852 { 173, 3 },
137853 { 173, 3 },
137854 { 173, 3 },
137855 { 173, 3 },
137856 { 173, 3 },
137857 { 173, 3 },
137858 { 221, 2 },
137859 { 173, 3 },
137860 { 173, 5 },
137861 { 173, 2 },
137862 { 173, 3 },
137863 { 173, 3 },
137864 { 173, 4 },
137865 { 173, 2 },
137866 { 173, 2 },
137867 { 173, 2 },
137868 { 173, 2 },
137869 { 222, 1 },
137870 { 222, 2 },
137871 { 173, 5 },
137872 { 223, 1 },
137873 { 223, 2 },
137874 { 173, 5 },
137875 { 173, 3 },
137876 { 173, 5 },
137877 { 173, 5 },
137878 { 173, 4 },
137879 { 173, 5 },
137880 { 226, 5 },
137881 { 226, 4 },
137882 { 227, 2 },
137883 { 227, 0 },
137884 { 225, 1 },
137885 { 225, 0 },
137886 { 208, 0 },
137887 { 207, 3 },
137888 { 207, 1 },
137889 { 224, 0 },
137890 { 224, 3 },
137891 { 149, 12 },
137892 { 228, 1 },
137893 { 228, 0 },
137894 { 177, 0 },
137895 { 177, 3 },
137896 { 187, 5 },
137897 { 187, 3 },
137898 { 229, 0 },
137899 { 229, 2 },
137900 { 149, 4 },
137901 { 149, 1 },
137902 { 149, 2 },
137903 { 149, 3 },
137904 { 149, 5 },
137905 { 149, 6 },
137906 { 149, 5 },
137907 { 149, 6 },
137908 { 169, 2 },
137909 { 170, 2 },
137910 { 149, 5 },
137911 { 231, 11 },
137912 { 233, 1 },
137913 { 233, 1 },
137914 { 233, 2 },
137915 { 233, 0 },
137916 { 234, 1 },
137917 { 234, 1 },
137918 { 234, 3 },
137919 { 236, 0 },
137920 { 236, 2 },
137921 { 232, 3 },
137922 { 232, 2 },
137923 { 238, 3 },
137924 { 239, 3 },
137925 { 239, 2 },
137926 { 237, 7 },
137927 { 237, 5 },
137928 { 237, 5 },
137929 { 237, 1 },
137930 { 173, 4 },
137931 { 173, 6 },
137932 { 191, 1 },
137933 { 191, 1 },
137934 { 191, 1 },
137935 { 149, 4 },
137936 { 149, 6 },
137937 { 149, 3 },
137938 { 241, 0 },
137939 { 241, 2 },
137940 { 149, 1 },
137941 { 149, 3 },
137942 { 149, 1 },
137943 { 149, 3 },
137944 { 149, 6 },
137945 { 149, 7 },
137946 { 242, 1 },
137947 { 149, 1 },
137948 { 149, 4 },
137949 { 244, 8 },
137950 { 246, 0 },
137951 { 247, 1 },
137952 { 247, 3 },
137953 { 248, 1 },
137954 { 196, 0 },
137955 { 196, 2 },
137956 { 196, 3 },
137957 { 250, 6 },
137958 { 250, 8 },
137959 { 144, 1 },
137960 { 145, 2 },
137961 { 145, 1 },
137962 { 146, 1 },
137963 { 146, 3 },
137964 { 147, 0 },
137965 { 151, 0 },
137966 { 151, 1 },
137967 { 151, 2 },
137968 { 153, 1 },
137969 { 153, 0 },
137970 { 149, 2 },
137971 { 160, 4 },
137972 { 160, 2 },
137973 { 152, 1 },
137974 { 152, 1 },
137975 { 152, 1 },
137976 { 166, 1 },
137977 { 167, 1 },
137978 { 168, 1 },
137979 { 168, 1 },
137980 { 165, 2 },
137981 { 165, 0 },
137982 { 171, 2 },
137983 { 161, 2 },
137984 { 183, 3 },
137985 { 183, 1 },
137986 { 184, 0 },
137987 { 188, 1 },
137988 { 190, 1 },
137989 { 194, 1 },
137990 { 195, 1 },
137991 { 209, 2 },
137992 { 210, 1 },
137993 { 173, 1 },
137994 { 221, 1 },
137995 { 208, 1 },
137996 { 230, 1 },
137997 { 230, 1 },
137998 { 230, 1 },
137999 { 230, 1 },
138000 { 230, 1 },
138001 { 169, 1 },
138002 { 235, 0 },
138003 { 235, 3 },
138004 { 238, 1 },
138005 { 239, 0 },
138006 { 240, 1 },
138007 { 240, 0 },
138008 { 243, 0 },
138009 { 243, 1 },
138010 { 245, 1 },
138011 { 245, 3 },
138012 { 246, 2 },
138013 { 249, 0 },
138014 { 249, 4 },
138015 { 249, 2 },
138016 };
138017
138018 static void yy_accept(yyParser*); /* Forward Declaration */
138019
138020 /*
@@ -138033,11 +138256,11 @@
138033 yymsp = yypParser->yytos;
138034 #ifndef NDEBUG
138035 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
138036 yysize = yyRuleInfo[yyruleno].nrhs;
138037 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
138038 yyRuleName[yyruleno], yymsp[-yysize].stateno);
138039 }
138040 #endif /* NDEBUG */
138041
138042 /* Check that the stack is large enough to grow by a single entry
138043 ** if the RHS of the rule is empty. This ensures that there is room
@@ -138048,11 +138271,11 @@
138048 yypParser->yyhwm++;
138049 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
138050 }
138051 #endif
138052 #if YYSTACKDEPTH>0
138053 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
138054 yyStackOverflow(yypParser);
138055 return;
138056 }
138057 #else
138058 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139007,11 +139230,11 @@
139007 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139008 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139009 }
139010 break;
139011 case 208: /* uniqueflag ::= UNIQUE */
139012 case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
139013 {yymsp[0].minor.yy194 = OE_Abort;}
139014 break;
139015 case 209: /* uniqueflag ::= */
139016 {yymsp[1].minor.yy194 = OE_None;}
139017 break;
@@ -139061,268 +139284,269 @@
139061 {
139062 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139063 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139064 }
139065 break;
139066 case 228: /* trigger_time ::= BEFORE */
139067 { yymsp[0].minor.yy194 = TK_BEFORE; }
139068 break;
139069 case 229: /* trigger_time ::= AFTER */
139070 { yymsp[0].minor.yy194 = TK_AFTER; }
139071 break;
139072 case 230: /* trigger_time ::= INSTEAD OF */
139073 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
139074 break;
139075 case 231: /* trigger_time ::= */
139076 { yymsp[1].minor.yy194 = TK_BEFORE; }
139077 break;
139078 case 232: /* trigger_event ::= DELETE|INSERT */
139079 case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
139080 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139081 break;
139082 case 234: /* trigger_event ::= UPDATE OF idlist */
139083 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139084 break;
139085 case 235: /* when_clause ::= */
139086 case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
139087 { yymsp[1].minor.yy72 = 0; }
139088 break;
139089 case 236: /* when_clause ::= WHEN expr */
139090 case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
139091 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139092 break;
139093 case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139094 {
139095 assert( yymsp[-2].minor.yy145!=0 );
139096 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139097 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139098 }
139099 break;
139100 case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
139101 {
139102 assert( yymsp[-1].minor.yy145!=0 );
139103 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139104 }
139105 break;
139106 case 239: /* trnm ::= nm DOT nm */
139107 {
139108 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139109 sqlite3ErrorMsg(pParse,
139110 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139111 "statements within triggers");
139112 }
139113 break;
139114 case 240: /* tridxby ::= INDEXED BY nm */
139115 {
139116 sqlite3ErrorMsg(pParse,
139117 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139118 "within triggers");
139119 }
139120 break;
139121 case 241: /* tridxby ::= NOT INDEXED */
139122 {
139123 sqlite3ErrorMsg(pParse,
139124 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139125 "within triggers");
139126 }
139127 break;
139128 case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139129 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139130 break;
139131 case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139132 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139133 break;
139134 case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139135 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139136 break;
139137 case 245: /* trigger_cmd ::= select */
139138 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139139 break;
139140 case 246: /* expr ::= RAISE LP IGNORE RP */
139141 {
139142 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139143 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139144 if( yymsp[-3].minor.yy190.pExpr ){
139145 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139146 }
139147 }
139148 break;
139149 case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
139150 {
139151 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139152 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139153 if( yymsp[-5].minor.yy190.pExpr ) {
139154 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139155 }
139156 }
139157 break;
139158 case 248: /* raisetype ::= ROLLBACK */
139159 {yymsp[0].minor.yy194 = OE_Rollback;}
139160 break;
139161 case 250: /* raisetype ::= FAIL */
139162 {yymsp[0].minor.yy194 = OE_Fail;}
139163 break;
139164 case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
139165 {
139166 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139167 }
139168 break;
139169 case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139170 {
139171 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139172 }
139173 break;
139174 case 253: /* cmd ::= DETACH database_kw_opt expr */
139175 {
139176 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139177 }
139178 break;
139179 case 256: /* cmd ::= REINDEX */
139180 {sqlite3Reindex(pParse, 0, 0);}
139181 break;
139182 case 257: /* cmd ::= REINDEX nm dbnm */
139183 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139184 break;
139185 case 258: /* cmd ::= ANALYZE */
139186 {sqlite3Analyze(pParse, 0, 0);}
139187 break;
139188 case 259: /* cmd ::= ANALYZE nm dbnm */
139189 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139190 break;
139191 case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139192 {
139193 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139194 }
139195 break;
139196 case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139197 {
139198 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139199 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139200 }
139201 break;
139202 case 262: /* add_column_fullname ::= fullname */
139203 {
139204 disableLookaside(pParse);
139205 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139206 }
139207 break;
139208 case 263: /* cmd ::= create_vtab */
139209 {sqlite3VtabFinishParse(pParse,0);}
139210 break;
139211 case 264: /* cmd ::= create_vtab LP vtabarglist RP */
139212 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139213 break;
139214 case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139215 {
139216 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139217 }
139218 break;
139219 case 266: /* vtabarg ::= */
139220 {sqlite3VtabArgInit(pParse);}
139221 break;
139222 case 267: /* vtabargtoken ::= ANY */
139223 case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
139224 case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
139225 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139226 break;
139227 case 270: /* with ::= */
139228 {yymsp[1].minor.yy285 = 0;}
139229 break;
139230 case 271: /* with ::= WITH wqlist */
139231 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139232 break;
139233 case 272: /* with ::= WITH RECURSIVE wqlist */
139234 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139235 break;
139236 case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
139237 {
139238 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139239 }
139240 break;
139241 case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139242 {
139243 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139244 }
139245 break;
139246 default:
139247 /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
139248 /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
139249 /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
139250 /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
139251 /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
139252 /* (280) explain ::= */ yytestcase(yyruleno==280);
139253 /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
139254 /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
139255 /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
139256 /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
139257 /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
139258 /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
139259 /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
139260 /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
139261 /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
139262 /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
139263 /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
139264 /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
139265 /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
139266 /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139267 /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
139268 /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
139269 /* (297) carglist ::= */ yytestcase(yyruleno==297);
139270 /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
139271 /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
139272 /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
139273 /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
139274 /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
139275 /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
139276 /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
139277 /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
139278 /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
139279 /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
139280 /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
139281 /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
139282 /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
139283 /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
139284 /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
139285 /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
139286 /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
139287 /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
139288 /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
139289 /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
139290 /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
139291 /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
139292 /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
139293 /* (321) tridxby ::= */ yytestcase(yyruleno==321);
139294 /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
139295 /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
139296 /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
139297 /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
139298 /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
139299 /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
139300 /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
139301 /* (329) anylist ::= */ yytestcase(yyruleno==329);
139302 /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
139303 /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
139304 break;
139305 /********** End reduce actions ************************************************/
139306 };
139307 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139308 yygoto = yyRuleInfo[yyruleno].lhs;
139309 yysize = yyRuleInfo[yyruleno].nrhs;
139310 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
139311 if( yyact <= YY_MAX_SHIFTREDUCE ){
139312 if( yyact>YY_MAX_SHIFT ){
139313 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
139314 }
139315 yymsp -= yysize-1;
 
 
 
 
 
 
 
 
139316 yypParser->yytos = yymsp;
139317 yymsp->stateno = (YYACTIONTYPE)yyact;
139318 yymsp->major = (YYCODETYPE)yygoto;
139319 yyTraceShift(yypParser, yyact);
139320 }else{
139321 assert( yyact == YY_ACCEPT_ACTION );
139322 yypParser->yytos -= yysize;
139323 yy_accept(yypParser);
139324 }
139325 }
139326
139327 /*
139328 ** The following code executes when the parse fails
@@ -140886,10 +141110,13 @@
140886 /************** Continuing where we left off in main.c ***********************/
140887 #endif
140888 #ifdef SQLITE_ENABLE_JSON1
140889 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
140890 #endif
 
 
 
140891 #ifdef SQLITE_ENABLE_FTS5
140892 SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
140893 #endif
140894
140895 #ifndef SQLITE_AMALGAMATION
@@ -141669,10 +141896,11 @@
141669 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141670 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141671 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141672 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141673 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
 
141674 };
141675 unsigned int i;
141676 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141677 for(i=0; i<ArraySize(aFlagOp); i++){
141678 if( aFlagOp[i].op==op ){
@@ -143774,10 +144002,13 @@
143774 | SQLITE_CellSizeCk
143775 #endif
143776 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
143777 | SQLITE_Fts3Tokenizer
143778 #endif
 
 
 
143779 ;
143780 sqlite3HashInit(&db->aCollSeq);
143781 #ifndef SQLITE_OMIT_VIRTUALTABLE
143782 sqlite3HashInit(&db->aModule);
143783 #endif
@@ -143911,10 +144142,16 @@
143911 #ifdef SQLITE_ENABLE_JSON1
143912 if( !db->mallocFailed && rc==SQLITE_OK){
143913 rc = sqlite3Json1Init(db);
143914 }
143915 #endif
 
 
 
 
 
 
143916
143917 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
143918 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
143919 ** mode. Doing nothing at all also makes NORMAL the default.
143920 */
@@ -148000,11 +148237,11 @@
148000 pCsr->pStmt = p->pSeekStmt;
148001 p->pSeekStmt = 0;
148002 }else{
148003 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
148004 if( !zSql ) return SQLITE_NOMEM;
148005 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
148006 sqlite3_free(zSql);
148007 }
148008 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
148009 }
148010 return rc;
@@ -149537,11 +149774,11 @@
149537 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149538 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149539 );
149540 }
149541 if( zSql ){
149542 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
149543 sqlite3_free(zSql);
149544 }else{
149545 rc = SQLITE_NOMEM;
149546 }
149547 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156744,11 +156981,12 @@
156744 zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156745 }
156746 if( !zSql ){
156747 rc = SQLITE_NOMEM;
156748 }else{
156749 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);
 
156750 sqlite3_free(zSql);
156751 assert( rc==SQLITE_OK || pStmt==0 );
156752 p->aStmt[eStmt] = pStmt;
156753 }
156754 }
@@ -167854,11 +168092,12 @@
167854
167855 rc = rtreeQueryStat1(db, pRtree);
167856 for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
167857 char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
167858 if( zSql ){
167859 rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0);
 
167860 }else{
167861 rc = SQLITE_NOMEM;
167862 }
167863 sqlite3_free(zSql);
167864 }
@@ -183900,16 +184139,16 @@
183900 ** fts5yy_default[] Default action for each state.
183901 **
183902 *********** Begin parsing tables **********************************************/
183903 #define fts5YY_ACTTAB_COUNT (98)
183904 static const fts5YYACTIONTYPE fts5yy_action[] = {
183905 /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17,
183906 /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6,
183907 /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26,
183908 /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65,
183909 /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24,
183910 /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65,
183911 /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
183912 /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
183913 /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
183914 /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
183915 };
@@ -184010,10 +184249,11 @@
184010 int fts5yystksz; /* Current side of the stack */
184011 fts5yyStackEntry *fts5yystack; /* The parser's stack */
184012 fts5yyStackEntry fts5yystk0; /* First stack entry */
184013 #else
184014 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
 
184015 #endif
184016 };
184017 typedef struct fts5yyParser fts5yyParser;
184018
184019 #ifndef NDEBUG
@@ -184159,10 +184399,11 @@
184159 pParser->fts5yyerrcnt = -1;
184160 #endif
184161 pParser->fts5yytos = pParser->fts5yystack;
184162 pParser->fts5yystack[0].stateno = 0;
184163 pParser->fts5yystack[0].major = 0;
 
184164 }
184165
184166 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184167 /*
184168 ** This function allocates a new parser.
@@ -184457,11 +184698,11 @@
184457 fts5yypParser->fts5yyhwm++;
184458 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184459 }
184460 #endif
184461 #if fts5YYSTACKDEPTH>0
184462 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
184463 fts5yypParser->fts5yytos--;
184464 fts5yyStackOverflow(fts5yypParser);
184465 return;
184466 }
184467 #else
@@ -184485,39 +184726,39 @@
184485
184486 /* The following table contains information about every rule that
184487 ** is used during the reduce.
184488 */
184489 static const struct {
184490 fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184491 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
184492 } fts5yyRuleInfo[] = {
184493 { 16, 1 },
184494 { 20, 4 },
184495 { 20, 3 },
184496 { 20, 1 },
184497 { 20, 2 },
184498 { 21, 2 },
184499 { 21, 1 },
184500 { 17, 3 },
184501 { 17, 3 },
184502 { 17, 3 },
184503 { 17, 5 },
184504 { 17, 3 },
184505 { 17, 1 },
184506 { 19, 1 },
184507 { 19, 2 },
184508 { 18, 1 },
184509 { 18, 3 },
184510 { 22, 1 },
184511 { 22, 5 },
184512 { 23, 1 },
184513 { 23, 2 },
184514 { 25, 0 },
184515 { 25, 2 },
184516 { 24, 4 },
184517 { 24, 2 },
184518 { 26, 1 },
184519 { 26, 0 },
184520 };
184521
184522 static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184523
@@ -184537,11 +184778,11 @@
184537 fts5yymsp = fts5yypParser->fts5yytos;
184538 #ifndef NDEBUG
184539 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184540 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184541 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184542 fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
184543 }
184544 #endif /* NDEBUG */
184545
184546 /* Check that the stack is large enough to grow by a single entry
184547 ** if the RHS of the rule is empty. This ensures that there is room
@@ -184552,11 +184793,11 @@
184552 fts5yypParser->fts5yyhwm++;
184553 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184554 }
184555 #endif
184556 #if fts5YYSTACKDEPTH>0
184557 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
184558 fts5yyStackOverflow(fts5yypParser);
184559 return;
184560 }
184561 #else
184562 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184719,24 +184960,28 @@
184719 /********** End reduce actions ************************************************/
184720 };
184721 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184722 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184723 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184724 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184725 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
184726 if( fts5yyact>fts5YY_MAX_SHIFT ){
184727 fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
184728 }
184729 fts5yymsp -= fts5yysize-1;
 
 
 
 
 
 
 
 
184730 fts5yypParser->fts5yytos = fts5yymsp;
184731 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184732 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184733 fts5yyTraceShift(fts5yypParser, fts5yyact);
184734 }else{
184735 assert( fts5yyact == fts5YY_ACCEPT_ACTION );
184736 fts5yypParser->fts5yytos -= fts5yysize;
184737 fts5yy_accept(fts5yypParser);
184738 }
184739 }
184740
184741 /*
184742 ** The following code executes when the parse fails
@@ -191124,11 +191369,12 @@
191124 sqlite3_stmt **ppStmt,
191125 char *zSql
191126 ){
191127 if( p->rc==SQLITE_OK ){
191128 if( zSql ){
191129 p->rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, ppStmt, 0);
 
191130 }else{
191131 p->rc = SQLITE_NOMEM;
191132 }
191133 }
191134 sqlite3_free(zSql);
@@ -191173,11 +191419,12 @@
191173 pConfig->zDb, pConfig->zName
191174 );
191175 if( zSql==0 ){
191176 rc = SQLITE_NOMEM;
191177 }else{
191178 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p->pDeleter, 0);
 
191179 sqlite3_free(zSql);
191180 }
191181 if( rc!=SQLITE_OK ){
191182 p->rc = rc;
191183 return;
@@ -197772,11 +198019,12 @@
197772 va_start(ap, zFmt);
197773 zSql = sqlite3_vmprintf(zFmt, ap);
197774 if( zSql==0 ){
197775 rc = SQLITE_NOMEM;
197776 }else{
197777 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0);
 
197778 if( rc!=SQLITE_OK ){
197779 *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
197780 }
197781 sqlite3_free(zSql);
197782 }
@@ -197908,11 +198156,12 @@
197908
197909 if( zRankArgs ){
197910 char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
197911 if( zSql ){
197912 sqlite3_stmt *pStmt = 0;
197913 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pStmt, 0);
 
197914 sqlite3_free(zSql);
197915 assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
197916 if( rc==SQLITE_OK ){
197917 if( SQLITE_ROW==sqlite3_step(pStmt) ){
197918 int nByte;
@@ -199517,11 +199766,11 @@
199517 int nArg, /* Number of args */
199518 sqlite3_value **apUnused /* Function arguments */
199519 ){
199520 assert( nArg==0 );
199521 UNUSED_PARAM2(nArg, apUnused);
199522 sqlite3_result_text(pCtx, "fts5: 2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a", -1, SQLITE_TRANSIENT);
199523 }
199524
199525 static int fts5Init(sqlite3 *db){
199526 static const sqlite3_module fts5Mod = {
199527 /* iVersion */ 2,
@@ -199771,11 +200020,12 @@
199771 }
199772
199773 if( zSql==0 ){
199774 rc = SQLITE_NOMEM;
199775 }else{
199776 rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0);
 
199777 sqlite3_free(zSql);
199778 if( rc!=SQLITE_OK && pzErrMsg ){
199779 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
199780 }
199781 }
@@ -203371,5 +203621,325 @@
203371
203372
203373 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
203374
203375 /************** End of fts5.c ************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203376
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -39,10 +39,18 @@
39 ** SQLite was built with.
40 */
41
42 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
43
44 /*
45 ** Include the configuration header output by 'configure' if we're using the
46 ** autoconf-based build
47 */
48 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49 #include "config.h"
50 #define SQLITECONFIG_H 1
51 #endif
52
53 /* These macros are provided to "stringify" the value of the define
54 ** for those options in which the value is meaningful. */
55 #define CTIMEOPT_VAL_(opt) #opt
56 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
@@ -279,10 +287,13 @@
287 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
288 "ENABLE_OVERSIZE_CELL_CHECK",
289 #endif
290 #if SQLITE_ENABLE_PREUPDATE_HOOK
291 "ENABLE_PREUPDATE_HOOK",
292 #endif
293 #if SQLITE_ENABLE_QPSG
294 "ENABLE_QPSG",
295 #endif
296 #if SQLITE_ENABLE_RBU
297 "ENABLE_RBU",
298 #endif
299 #if SQLITE_ENABLE_RTREE
@@ -302,10 +313,13 @@
313 #endif
314 #if defined(SQLITE_ENABLE_STAT4)
315 "ENABLE_STAT4",
316 #elif defined(SQLITE_ENABLE_STAT3)
317 "ENABLE_STAT3",
318 #endif
319 #if SQLITE_ENABLE_STMTVTAB
320 "ENABLE_STMTVTAB",
321 #endif
322 #if SQLITE_ENABLE_STMT_SCANSTATUS
323 "ENABLE_STMT_SCANSTATUS",
324 #endif
325 #if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
@@ -1012,11 +1026,11 @@
1026 ** MinGW.
1027 */
1028 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
1029 /************** Begin file sqlite3.h *****************************************/
1030 /*
1031 ** 2001-09-15
1032 **
1033 ** The author disclaims copyright to this source code. In place of
1034 ** a legal notice, here is a blessing:
1035 **
1036 ** May you do good and not evil.
@@ -1136,11 +1150,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1248,11 +1262,11 @@
1262 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1263 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1264 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1265 ** and [sqlite3_close_v2()] are its destructors. There are many other
1266 ** interfaces (such as
1267 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
1268 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
1269 ** sqlite3 object.
1270 */
1271 typedef struct sqlite3 sqlite3;
1272
@@ -1352,11 +1366,11 @@
1366 /*
1367 ** CAPI3REF: One-Step Query Execution Interface
1368 ** METHOD: sqlite3
1369 **
1370 ** The sqlite3_exec() interface is a convenience wrapper around
1371 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
1372 ** that allows an application to run multiple statements of SQL
1373 ** without having to use a lot of C code.
1374 **
1375 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1376 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3020,19 +3034,31 @@
3034 ** default) to enable them. The second parameter is a pointer to an integer
3035 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3036 ** have been disabled - 0 if they are not disabled, 1 if they are.
3037 ** </dd>
3038 **
3039 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042 ** a single SQL query statement will always use the same algorithm regardless
3043 ** of values of [bound parameters]. The QPSG disables some query optimizations
3044 ** that look at the values of bound parameters, which can make some queries
3045 ** slower. But the QPSG has the advantage of more predictable behavior. With
3046 ** the QPSG active, SQLite will always use the same query plan in the field as
3047 ** was used during testing in the lab.
3048 ** </dd>
3049 **
3050 ** </dl>
3051 */
3052 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3053 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3054 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
3055 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
3056 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
3057 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
3058 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3059 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3060
3061
3062 /*
3063 ** CAPI3REF: Enable Or Disable Extended Result Codes
3064 ** METHOD: sqlite3
@@ -3692,25 +3718,26 @@
3718 **
3719 ** ^This routine registers an authorizer callback with a particular
3720 ** [database connection], supplied in the first argument.
3721 ** ^The authorizer callback is invoked as SQL statements are being compiled
3722 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
3723 ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
3724 ** and [sqlite3_prepare16_v3()]. ^At various
3725 ** points during the compilation process, as logic is being created
3726 ** to perform various actions, the authorizer callback is invoked to
3727 ** see if those actions are allowed. ^The authorizer callback should
3728 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
3729 ** specific action but allow the SQL statement to continue to be
3730 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
3731 ** rejected with an error. ^If the authorizer callback returns
3732 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
3734 ** the authorizer will fail with an error message.
3735 **
3736 ** When the callback returns [SQLITE_OK], that means the operation
3737 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
3739 ** authorizer will fail with an error message explaining that
3740 ** access is denied.
3741 **
3742 ** ^The first parameter to the authorizer callback is a copy of the third
3743 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3757,23 +3784,23 @@
3784 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3785 ** The authorizer is disabled by default.
3786 **
3787 ** The authorizer callback must not do anything that will modify
3788 ** the database connection that invoked the authorizer callback.
3789 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3790 ** database connections for the meaning of "modify" in this paragraph.
3791 **
3792 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
3793 ** statement might be re-prepared during [sqlite3_step()] due to a
3794 ** schema change. Hence, the application should ensure that the
3795 ** correct authorizer callback remains in place during the [sqlite3_step()].
3796 **
3797 ** ^Note that the authorizer callback is invoked only during
3798 ** [sqlite3_prepare()] or its variants. Authorization is not
3799 ** performed during statement evaluation in [sqlite3_step()], unless
3800 ** as stated in the previous paragraph, sqlite3_step() invokes
3801 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
3802 */
3803 SQLITE_API int sqlite3_set_authorizer(
3804 sqlite3*,
3805 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3806 void *pUserData
@@ -4005,11 +4032,11 @@
4032 ** interrupted. This feature can be used to implement a
4033 ** "Cancel" button on a GUI progress dialog box.
4034 **
4035 ** The progress handler callback must not do anything that will modify
4036 ** the database connection that invoked the progress handler.
4037 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
4038 ** database connections for the meaning of "modify" in this paragraph.
4039 **
4040 */
4041 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
4042
@@ -4359,11 +4386,11 @@
4386 ** prepared statement before it can be run.
4387 **
4388 ** The life-cycle of a prepared statement object usually goes like this:
4389 **
4390 ** <ol>
4391 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
4392 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
4393 ** interfaces.
4394 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
4395 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
4396 ** to step 2. Do this zero or more times.
@@ -4441,11 +4468,11 @@
4468 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4469 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4470 **
4471 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
4472 ** <dd>The maximum number of instructions in a virtual machine program
4473 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
4474 ** the equivalent tries to allocate space for more than this many opcodes
4475 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
4476 **
4477 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
4478 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4481,28 +4508,61 @@
4508 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
4509 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4510 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4511 #define SQLITE_LIMIT_WORKER_THREADS 11
4512
4513 /*
4514 ** CAPI3REF: Prepare Flags
4515 **
4516 ** These constants define various flags that can be passed into
4517 ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
4518 ** [sqlite3_prepare16_v3()] interfaces.
4519 **
4520 ** New flags may be added in future releases of SQLite.
4521 **
4522 ** <dl>
4523 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525 ** and [sqlite3_prepare16_v3()]
4526 ** to optimize the resulting prepared statement to be retained for a
4527 ** relatively long amount of time.)^ ^Without this flag,
4528 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529 ** the prepared statement will be used just once or at most a few times
4530 ** and then destroyed using [sqlite3_finalize()] relatively soon.
4531 ** </dl>
4532 */
4533 #define SQLITE_PREPARE_PERSISTENT 0x01
4534
4535 /*
4536 ** CAPI3REF: Compiling An SQL Statement
4537 ** KEYWORDS: {SQL statement compiler}
4538 ** METHOD: sqlite3
4539 ** CONSTRUCTOR: sqlite3_stmt
4540 **
4541 ** To execute an SQL statement, it must first be compiled into a byte-code
4542 ** program using one of these routines. Or, in other words, these routines
4543 ** are constructors for the [prepared statement] object.
4544 **
4545 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4546 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4547 ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4548 ** for special purposes.
4549 **
4550 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4551 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4552 ** as a convenience. The UTF-16 interfaces work by converting the
4553 ** input text into UTF-8, then invoking the corresponding UTF-8 interface.
4554 **
4555 ** The first argument, "db", is a [database connection] obtained from a
4556 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
4557 ** [sqlite3_open16()]. The database connection must not have been closed.
4558 **
4559 ** The second argument, "zSql", is the statement to be compiled, encoded
4560 ** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
4561 ** and sqlite3_prepare_v3()
4562 ** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
4563 ** and sqlite3_prepare16_v3() use UTF-16.
4564 **
4565 ** ^If the nByte argument is negative, then zSql is read up to the
4566 ** first zero terminator. ^If nByte is positive, then it is the
4567 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
4568 ** statement is generated.
@@ -4525,14 +4585,15 @@
4585 ** ppStmt may not be NULL.
4586 **
4587 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
4588 ** otherwise an [error code] is returned.
4589 **
4590 ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
4591 ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
4592 ** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
4593 ** are retained for backwards compatibility, but their use is discouraged.
4594 ** ^In the "vX" interfaces, the prepared statement
4595 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
4596 ** original SQL text. This causes the [sqlite3_step()] interface to
4597 ** behave differently in three ways:
4598 **
4599 ** <ol>
@@ -4561,10 +4622,16 @@
4622 ** ^The specific value of WHERE-clause [parameter] might influence the
4623 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4624 ** or [GLOB] operator or if the parameter is compared to an indexed column
4625 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
4626 ** </li>
4627 **
4628 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4629 ** the extra prepFlags parameter, which is a bit array consisting of zero or
4630 ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
4631 ** sqlite3_prepare_v2() interface works exactly the same as
4632 ** sqlite3_prepare_v3() with a zero prepFlags parameter.
4633 ** </ol>
4634 */
4635 SQLITE_API int sqlite3_prepare(
4636 sqlite3 *db, /* Database handle */
4637 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4574,10 +4641,18 @@
4641 );
4642 SQLITE_API int sqlite3_prepare_v2(
4643 sqlite3 *db, /* Database handle */
4644 const char *zSql, /* SQL statement, UTF-8 encoded */
4645 int nByte, /* Maximum length of zSql in bytes. */
4646 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4647 const char **pzTail /* OUT: Pointer to unused portion of zSql */
4648 );
4649 SQLITE_API int sqlite3_prepare_v3(
4650 sqlite3 *db, /* Database handle */
4651 const char *zSql, /* SQL statement, UTF-8 encoded */
4652 int nByte, /* Maximum length of zSql in bytes. */
4653 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
4654 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4655 const char **pzTail /* OUT: Pointer to unused portion of zSql */
4656 );
4657 SQLITE_API int sqlite3_prepare16(
4658 sqlite3 *db, /* Database handle */
@@ -4591,18 +4666,27 @@
4666 const void *zSql, /* SQL statement, UTF-16 encoded */
4667 int nByte, /* Maximum length of zSql in bytes. */
4668 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4669 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4670 );
4671 SQLITE_API int sqlite3_prepare16_v3(
4672 sqlite3 *db, /* Database handle */
4673 const void *zSql, /* SQL statement, UTF-16 encoded */
4674 int nByte, /* Maximum length of zSql in bytes. */
4675 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
4676 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4677 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4678 );
4679
4680 /*
4681 ** CAPI3REF: Retrieving Statement SQL
4682 ** METHOD: sqlite3_stmt
4683 **
4684 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
4685 ** SQL text used to create [prepared statement] P if P was
4686 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4687 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4688 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
4689 ** string containing the SQL text of prepared statement P with
4690 ** [bound parameters] expanded.
4691 **
4692 ** ^(For example, if a prepared statement is created using the SQL
@@ -4744,11 +4828,11 @@
4828 ** CAPI3REF: Binding Values To Prepared Statements
4829 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4830 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4831 ** METHOD: sqlite3_stmt
4832 **
4833 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
4834 ** literals may be replaced by a [parameter] that matches one of following
4835 ** templates:
4836 **
4837 ** <ul>
4838 ** <li> ?
@@ -4763,11 +4847,11 @@
4847 ** parameters (also called "host parameter names" or "SQL parameters")
4848 ** can be set using the sqlite3_bind_*() routines defined here.
4849 **
4850 ** ^The first argument to the sqlite3_bind_*() routines is always
4851 ** a pointer to the [sqlite3_stmt] object returned from
4852 ** [sqlite3_prepare_v3()] or its variants.
4853 **
4854 ** ^The second argument is the index of the SQL parameter to be set.
4855 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4856 ** SQL parameter is used more than once, second and subsequent
4857 ** occurrences have the same index as the first occurrence.
@@ -4900,12 +4984,12 @@
4984 ** ^The first host parameter has an index of 1, not 0.
4985 **
4986 ** ^If the value N is out of range or if the N-th parameter is
4987 ** nameless, then NULL is returned. ^The returned string is
4988 ** always in UTF-8 encoding even if the named parameter was
4989 ** originally specified as UTF-16 in [sqlite3_prepare16()],
4990 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4991 **
4992 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4993 ** [sqlite3_bind_parameter_count()], and
4994 ** [sqlite3_bind_parameter_index()].
4995 */
@@ -4918,11 +5002,12 @@
5002 ** ^Return the index of an SQL parameter given its name. ^The
5003 ** index value returned is suitable for use as the second
5004 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
5005 ** is returned if no matching parameter is found. ^The parameter
5006 ** name must be given in UTF-8 even if the original statement
5007 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
5008 ** [sqlite3_prepare16_v3()].
5009 **
5010 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
5011 ** [sqlite3_bind_parameter_count()], and
5012 ** [sqlite3_bind_parameter_name()].
5013 */
@@ -5072,20 +5157,22 @@
5157
5158 /*
5159 ** CAPI3REF: Evaluate An SQL Statement
5160 ** METHOD: sqlite3_stmt
5161 **
5162 ** After a [prepared statement] has been prepared using any of
5163 ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
5164 ** or [sqlite3_prepare16_v3()] or one of the legacy
5165 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
5166 ** must be called one or more times to evaluate the statement.
5167 **
5168 ** The details of the behavior of the sqlite3_step() interface depend
5169 ** on whether the statement was prepared using the newer "vX" interfaces
5170 ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
5171 ** [sqlite3_prepare16_v2()] or the older legacy
5172 ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5173 ** new "vX" interface is recommended for new applications but the legacy
5174 ** interface will continue to be supported.
5175 **
5176 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
5177 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
5178 ** ^With the "v2" interface, any of the other [result codes] or
@@ -5142,14 +5229,15 @@
5229 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
5230 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
5231 ** specific [error codes] that better describes the error.
5232 ** We admit that this is a goofy design. The problem has been fixed
5233 ** with the "v2" interface. If you prepare all of your SQL statements
5234 ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
5235 ** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
5236 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
5237 ** then the more specific [error codes] are returned directly
5238 ** by sqlite3_step(). The use of the "vX" interfaces is recommended.
5239 */
5240 SQLITE_API int sqlite3_step(sqlite3_stmt*);
5241
5242 /*
5243 ** CAPI3REF: Number of columns in a result set
@@ -5210,11 +5298,11 @@
5298 ** METHOD: sqlite3_stmt
5299 **
5300 ** ^These routines return information about a single column of the current
5301 ** result row of a query. ^In every case the first argument is a pointer
5302 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5303 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
5304 ** and the second argument is the index of the column for which information
5305 ** should be returned. ^The leftmost column of the result set has the index 0.
5306 ** ^The number of columns in the result can be determined using
5307 ** [sqlite3_column_count()].
5308 **
@@ -6334,11 +6422,11 @@
6422 **
6423 ** ^The sqlite3_db_handle interface returns the [database connection] handle
6424 ** to which a [prepared statement] belongs. ^The [database connection]
6425 ** returned by sqlite3_db_handle is the same [database connection]
6426 ** that was the first argument
6427 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
6428 ** create the statement in the first place.
6429 */
6430 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6431
6432 /*
@@ -6410,11 +6498,11 @@
6498 ** the database connection that invoked the callback. Any actions
6499 ** to modify the database connection must be deferred until after the
6500 ** completion of the [sqlite3_step()] call that triggered the commit
6501 ** or rollback hook in the first place.
6502 ** Note that running any other SQL statements, including SELECT statements,
6503 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
6504 ** the database connections for the meaning of "modify" in this paragraph.
6505 **
6506 ** ^Registering a NULL function disables the callback.
6507 **
6508 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6470,11 +6558,11 @@
6558 **
6559 ** The update hook implementation must not do anything that will modify
6560 ** the database connection that invoked the update hook. Any actions
6561 ** to modify the database connection must be deferred until after the
6562 ** completion of the [sqlite3_step()] call that triggered the update hook.
6563 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
6564 ** database connections for the meaning of "modify" in this paragraph.
6565 **
6566 ** ^The sqlite3_update_hook(D,C,P) function
6567 ** returns the P argument from the previous call
6568 ** on the same [database connection] D, or NULL for
@@ -8148,10 +8236,22 @@
8236 ** by the prepared statement if that number is less than or equal
8237 ** to 2147483647. The number of virtual machine operations can be
8238 ** used as a proxy for the total work done by the prepared statement.
8239 ** If the number of virtual machine operations exceeds 2147483647
8240 ** then the value returned by this statement status code is undefined.
8241 **
8242 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
8243 ** <dd>^This is the number of times that the prepare statement has been
8244 ** automatically regenerated due to schema changes or change to
8245 ** [bound parameters] that might affect the query plan.
8246 **
8247 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
8248 ** <dd>^This is the number of times that the prepared statement has
8249 ** been run. A single "run" for the purposes of this counter is one
8250 ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
8251 ** The counter is incremented on the first [sqlite3_step()] call of each
8252 ** cycle.
8253 **
8254 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8255 ** <dd>^This is the approximate number of bytes of heap memory
8256 ** used to store the prepared statement. ^This value is not actually
8257 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -8161,11 +8261,13 @@
8261 */
8262 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
8263 #define SQLITE_STMTSTATUS_SORT 2
8264 #define SQLITE_STMTSTATUS_AUTOINDEX 3
8265 #define SQLITE_STMTSTATUS_VM_STEP 4
8266 #define SQLITE_STMTSTATUS_REPREPARE 5
8267 #define SQLITE_STMTSTATUS_RUN 6
8268 #define SQLITE_STMTSTATUS_MEMUSED 99
8269
8270 /*
8271 ** CAPI3REF: Custom Page Cache Object
8272 **
8273 ** The sqlite3_pcache type is opaque. It is implemented by
@@ -11528,12 +11630,13 @@
11630
11631 /*
11632 ** Include the configuration header output by 'configure' if we're using the
11633 ** autoconf-based build
11634 */
11635 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
11636 /* #include "config.h" */
11637 #define SQLITECONFIG_H 1
11638 #endif
11639
11640 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
11641 /************** Begin file sqliteLimit.h *************************************/
11642 /*
@@ -13695,10 +13798,16 @@
13798 #define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
13799
13800 /************** End of opcodes.h *********************************************/
13801 /************** Continuing where we left off in vdbe.h ***********************/
13802
13803 /*
13804 ** Additional non-public SQLITE_PREPARE_* flags
13805 */
13806 #define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
13807 #define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
13808
13809 /*
13810 ** Prototypes for the VDBE interface. See comments on the implementation
13811 ** for a description of what each of these routines does.
13812 */
13813 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13752,11 +13861,12 @@
13861 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
13862 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
13863 SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
13864 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
13865 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13866 SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);
13867 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
13868 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
13869 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
13870 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
13871 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
13872 #ifndef SQLITE_OMIT_TRACE
@@ -14974,12 +15084,12 @@
15084 ** Value constraints (enforced via assert()):
15085 ** SQLITE_FullFSync == PAGER_FULLFSYNC
15086 ** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
15087 ** SQLITE_CacheSpill == PAGER_CACHE_SPILL
15088 */
15089 #define SQLITE_WriteSchema 0x00000001 /* OK to update SQLITE_MASTER */
15090 #define SQLITE_LegacyFileFmt 0x00000002 /* Create new databases in format 1 */
15091 #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
15092 #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
15093 #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
15094 #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
15095 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -14986,33 +15096,38 @@
15096 #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
15097 /* DELETE, or UPDATE and return */
15098 /* the count using a callback. */
15099 #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
15100 /* result set is empty */
15101 #define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */
15102 #define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */
15103 #define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */
15104 #define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */
15105 #define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */
15106 #define SQLITE_ForeignKeys 0x00004000 /* Enforce foreign key constraints */
15107 #define SQLITE_AutoIndex 0x00008000 /* Enable automatic indexes */
15108 #define SQLITE_LoadExtension 0x00010000 /* Enable load_extension */
15109 #define SQLITE_EnableTrigger 0x00020000 /* True to enable triggers */
15110 #define SQLITE_DeferFKs 0x00040000 /* Defer all FK constraints */
15111 #define SQLITE_QueryOnly 0x00080000 /* Disable database changes */
15112 #define SQLITE_CellSizeCk 0x00100000 /* Check btree cell sizes on load */
15113 #define SQLITE_Fts3Tokenizer 0x00200000 /* Enable fts3_tokenizer(2) */
15114 #define SQLITE_EnableQPSG 0x00400000 /* Query Planner Stability Guarantee */
15115 /* The next four values are not used by PRAGMAs or by sqlite3_dbconfig() and
15116 ** could be factored out into a separate bit vector of the sqlite3 object. */
15117 #define SQLITE_InternChanges 0x00800000 /* Uncommitted Hash table changes */
15118 #define SQLITE_LoadExtFunc 0x01000000 /* Enable load_extension() SQL func */
15119 #define SQLITE_PreferBuiltin 0x02000000 /* Preference to built-in funcs */
15120 #define SQLITE_Vacuum 0x04000000 /* Currently in a VACUUM */
15121 /* Flags used only if debugging */
15122 #ifdef SQLITE_DEBUG
15123 #define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
15124 #define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
15125 #define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
15126 #define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
15127 #define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
15128 #endif
15129
15130
15131 /*
15132 ** Bits of the sqlite3.dbOptFlags field that are used by the
15133 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -17305,14 +17420,14 @@
17420 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
17421 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
17422 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
17423 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
17424 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
17425 SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
17426 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
17427 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
17428 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);
17429 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
17430 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
17431 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
17432 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
17433 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18606,22 +18721,22 @@
18721 int rcApp; /* errcode set by sqlite3_result_error_code() */
18722 #endif
18723 u16 nResColumn; /* Number of columns in one row of the result set */
18724 u8 errorAction; /* Recovery action to do in case of an error */
18725 u8 minWriteFileFormat; /* Minimum file format for writable database files */
18726 u8 prepFlags; /* SQLITE_PREPARE_* flags */
18727 bft expired:1; /* True if the VM needs to be recompiled */
18728 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
18729 bft explain:2; /* True if EXPLAIN present on SQL command */
18730 bft changeCntOn:1; /* True to update the change-counter */
18731 bft runOnlyOnce:1; /* Automatically expire on reset */
18732 bft usesStmtJournal:1; /* True if uses a statement journal */
18733 bft readOnly:1; /* True for statements that do not write */
18734 bft bIsReader:1; /* True for statements that read */
 
18735 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
18736 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18737 u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
18738 char *zSql; /* Text of the SQL statement that generated this */
18739 void *pFree; /* Free this when deleting the vdbe */
18740 VdbeFrame *pFrame; /* Parent frame */
18741 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
18742 int nFrame; /* Number of frames in pFrame list */
@@ -59469,11 +59584,11 @@
59584 /* If this database is not shareable, or if the client is reading
59585 ** and has the read-uncommitted flag set, then no lock is required.
59586 ** Return true immediately.
59587 */
59588 if( (pBtree->sharable==0)
59589 || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))
59590 ){
59591 return 1;
59592 }
59593
59594 /* If the client is reading or writing an index and the schema is
@@ -59546,11 +59661,11 @@
59661 static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
59662 BtCursor *p;
59663 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
59664 if( p->pgnoRoot==iRoot
59665 && p->pBtree!=pBtree
59666 && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)
59667 ){
59668 return 1;
59669 }
59670 }
59671 return 0;
@@ -59568,11 +59683,11 @@
59683 BtLock *pIter;
59684
59685 assert( sqlite3BtreeHoldsMutex(p) );
59686 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
59687 assert( p->db!=0 );
59688 assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );
59689
59690 /* If requesting a write-lock, then the Btree must have an open write
59691 ** transaction on this file. And, obviously, for this to be so there
59692 ** must be an open write transaction on the file itself.
59693 */
@@ -59646,11 +59761,11 @@
59761
59762 /* A connection with the read-uncommitted flag set will never try to
59763 ** obtain a read-lock using this function. The only read-lock obtained
59764 ** by a connection in read-uncommitted mode is on the sqlite_master
59765 ** table, and that lock is obtained in BtreeBeginTrans(). */
59766 assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );
59767
59768 /* This function should only be called on a sharable b-tree after it
59769 ** has been determined that no other b-tree holds a conflicting lock. */
59770 assert( p->sharable );
59771 assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -62338,11 +62453,11 @@
62453 freeTempSpace(pBt);
62454 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
62455 pageSize-usableSize);
62456 return rc;
62457 }
62458 if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
62459 rc = SQLITE_CORRUPT_BKPT;
62460 goto page1_init_failed;
62461 }
62462 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
62463 ** be less than 480. In other words, if the page size is 512, then the
@@ -71465,28 +71580,25 @@
71580 sqlite3 *db = pParse->db;
71581
71582 /* Skip over any TK_COLLATE nodes */
71583 pExpr = sqlite3ExprSkipCollate(pExpr);
71584
71585 assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );
71586 if( !pExpr ){
71587 pVal = valueNew(db, pAlloc);
71588 if( pVal ){
71589 sqlite3VdbeMemSetNull((Mem*)pVal);
71590 }
71591 }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
 
 
71592 Vdbe *v;
71593 int iBindVar = pExpr->iColumn;
71594 sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
71595 if( (v = pParse->pReprepare)!=0 ){
71596 pVal = valueNew(db, pAlloc);
71597 if( pVal ){
71598 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71599 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
 
 
71600 pVal->db = pParse->db;
71601 }
71602 }
71603 }else{
71604 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71756,20 +71868,18 @@
71868 }
71869
71870 /*
71871 ** Remember the SQL string for a prepared statement.
71872 */
71873 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
 
71874 if( p==0 ) return;
71875 p->prepFlags = prepFlags;
71876 if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
71877 p->expmask = 0;
71878 }
71879 assert( p->zSql==0 );
71880 p->zSql = sqlite3DbStrNDup(p->db, z, n);
 
71881 }
71882
71883 /*
71884 ** Swap all content between two VDBE structures.
71885 */
@@ -71787,12 +71897,14 @@
71897 pA->pPrev = pB->pPrev;
71898 pB->pPrev = pTmp;
71899 zTmp = pA->zSql;
71900 pA->zSql = pB->zSql;
71901 pB->zSql = zTmp;
 
71902 pB->expmask = pA->expmask;
71903 pB->prepFlags = pA->prepFlags;
71904 memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
71905 pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
71906 }
71907
71908 /*
71909 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71910 ** than its current size. nOp is guaranteed to be less than or equal
@@ -76231,10 +76343,17 @@
76343 ** Return the database associated with the Vdbe.
76344 */
76345 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
76346 return v->db;
76347 }
76348
76349 /*
76350 ** Return the SQLITE_PREPARE flags for a Vdbe.
76351 */
76352 SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){
76353 return v->prepFlags;
76354 }
76355
76356 /*
76357 ** Return a pointer to an sqlite3_value structure containing the value bound
76358 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
76359 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
@@ -76244,10 +76363,11 @@
76363 */
76364 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
76365 assert( iVar>0 );
76366 if( v ){
76367 Mem *pMem = &v->aVar[iVar-1];
76368 assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
76369 if( 0==(pMem->flags & MEM_Null) ){
76370 sqlite3_value *pRet = sqlite3ValueNew(v->db);
76371 if( pRet ){
76372 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
76373 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76263,10 +76383,11 @@
76383 ** to sqlite3_reoptimize() that re-preparing the statement may result
76384 ** in a better query plan.
76385 */
76386 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
76387 assert( iVar>0 );
76388 assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
76389 if( iVar>=32 ){
76390 v->expmask |= 0x80000000;
76391 }else{
76392 v->expmask |= ((u32)1 << (iVar-1));
76393 }
@@ -76534,11 +76655,11 @@
76655 sqlite3_mutex_enter(mutex);
76656 for(i=0; i<p->nVar; i++){
76657 sqlite3VdbeMemRelease(&p->aVar[i]);
76658 p->aVar[i].flags = MEM_Null;
76659 }
76660 assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
76661 if( p->expmask ){
76662 p->expired = 1;
76663 }
76664 sqlite3_mutex_leave(mutex);
76665 return rc;
@@ -77013,12 +77134,15 @@
77134 */
77135 assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
77136 || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
77137 );
77138 assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
77139 if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
77140 && rc!=SQLITE_ROW
77141 && rc!=SQLITE_DONE
77142 ){
77143 /* If this statement was prepared using saved SQL and an
77144 ** error has occurred, then return the error code in p->rc to the
77145 ** caller. Set the error code in the database handle to the same value.
77146 */
77147 rc = sqlite3VdbeTransferError(p);
77148 }
@@ -77653,11 +77777,11 @@
77777 ** parameter in the WHERE clause might influence the choice of query plan
77778 ** for a statement, then the statement will be automatically recompiled,
77779 ** as if there had been a schema change, on the first sqlite3_step() call
77780 ** following any change to the bindings of that parameter.
77781 */
77782 assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
77783 if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
77784 p->expired = 1;
77785 }
77786 return SQLITE_OK;
77787 }
@@ -77919,15 +78043,15 @@
78043 Vdbe *pFrom = (Vdbe*)pFromStmt;
78044 Vdbe *pTo = (Vdbe*)pToStmt;
78045 if( pFrom->nVar!=pTo->nVar ){
78046 return SQLITE_ERROR;
78047 }
78048 assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );
78049 if( pTo->expmask ){
78050 pTo->expired = 1;
78051 }
78052 assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );
78053 if( pFrom->expmask ){
78054 pFrom->expired = 1;
78055 }
78056 return sqlite3TransferBindings(pFromStmt, pToStmt);
78057 }
@@ -85158,11 +85282,11 @@
85282 ** P4 contains a pointer to the name of the table being locked. This is only
85283 ** used to generate an error message if the lock cannot be obtained.
85284 */
85285 case OP_TableLock: {
85286 u8 isWriteLock = (u8)pOp->p3;
85287 if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){
85288 int p1 = pOp->p1;
85289 assert( p1>=0 && p1<db->nDb );
85290 assert( DbMaskTest(p->btreeMask, p1) );
85291 assert( isWriteLock==0 || isWriteLock==1 );
85292 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85666,10 +85790,11 @@
85790 if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
85791 }
85792 pOp->p1 = 0;
85793 }
85794 pOp->p1++;
85795 p->aCounter[SQLITE_STMTSTATUS_RUN]++;
85796 goto jump_to_p2;
85797 }
85798
85799 #ifdef SQLITE_ENABLE_CURSOR_HINTS
85800 /* Opcode: CursorHint P1 * * P4 *
@@ -90568,11 +90693,11 @@
90693 /* Try to match the ORDER BY expression against an expression
90694 ** in the result set. Return an 1-based index of the matching
90695 ** result-set entry.
90696 */
90697 for(i=0; i<pEList->nExpr; i++){
90698 if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){
90699 return i+1;
90700 }
90701 }
90702
90703 /* If no match, return 0. */
@@ -90802,11 +90927,11 @@
90927 pItem->u.x.iOrderByCol = 0;
90928 if( sqlite3ResolveExprNames(pNC, pE) ){
90929 return 1;
90930 }
90931 for(j=0; j<pSelect->pEList->nExpr; j++){
90932 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90933 pItem->u.x.iOrderByCol = j+1;
90934 }
90935 }
90936 }
90937 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -93027,11 +93152,11 @@
93152
93153 /* Check if pExpr is identical to any GROUP BY term. If so, consider
93154 ** it constant. */
93155 for(i=0; i<pGroupBy->nExpr; i++){
93156 Expr *p = pGroupBy->a[i].pExpr;
93157 if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
93158 CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
93159 if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
93160 return WRC_Prune;
93161 }
93162 }
@@ -95303,11 +95428,11 @@
95428 p = pParse->pConstExpr;
95429 if( regDest<0 && p ){
95430 struct ExprList_item *pItem;
95431 int i;
95432 for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95433 if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){
95434 return pItem->u.iConstExprReg;
95435 }
95436 }
95437 }
95438 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95858,10 +95983,45 @@
95983 sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
95984 }
95985 sqlite3ExprDelete(db, pCopy);
95986 }
95987
95988 /*
95989 ** Expression pVar is guaranteed to be an SQL variable. pExpr may be any
95990 ** type of expression.
95991 **
95992 ** If pExpr is a simple SQL value - an integer, real, string, blob
95993 ** or NULL value - then the VDBE currently being prepared is configured
95994 ** to re-prepare each time a new value is bound to variable pVar.
95995 **
95996 ** Additionally, if pExpr is a simple SQL value and the value is the
95997 ** same as that currently bound to variable pVar, non-zero is returned.
95998 ** Otherwise, if the values are not the same or if pExpr is not a simple
95999 ** SQL value, zero is returned.
96000 */
96001 static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){
96002 int res = 0;
96003 int iVar;
96004 sqlite3_value *pL, *pR = 0;
96005
96006 sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
96007 if( pR ){
96008 iVar = pVar->iColumn;
96009 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
96010 pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
96011 if( pL ){
96012 if( sqlite3_value_type(pL)==SQLITE_TEXT ){
96013 sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
96014 }
96015 res = 0==sqlite3MemCompare(pL, pR, 0);
96016 }
96017 sqlite3ValueFree(pR);
96018 sqlite3ValueFree(pL);
96019 }
96020
96021 return res;
96022 }
96023
96024 /*
96025 ** Do a deep comparison of two expression trees. Return 0 if the two
96026 ** expressions are completely identical. Return 1 if they differ only
96027 ** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -95880,28 +96040,38 @@
96040 ** expressions are the same. But if you get a 0 or 1 return, then you
96041 ** can be sure the expressions are the same. In the places where
96042 ** this routine is used, it does not hurt to get an extra 2 - that
96043 ** just might result in some slightly slower code. But returning
96044 ** an incorrect 0 or 1 could lead to a malfunction.
96045 **
96046 ** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
96047 ** pParse->pReprepare can be matched against literals in pB. The
96048 ** pParse->pVdbe->expmask bitmask is updated for each variable referenced.
96049 ** If pParse is NULL (the normal case) then any TK_VARIABLE term in
96050 ** Argument pParse should normally be NULL. If it is not NULL and pA or
96051 ** pB causes a return value of 2.
96052 */
96053 SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
96054 u32 combinedFlags;
96055 if( pA==0 || pB==0 ){
96056 return pB==pA ? 0 : 2;
96057 }
96058 if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){
96059 return 0;
96060 }
96061 combinedFlags = pA->flags | pB->flags;
96062 if( combinedFlags & EP_IntValue ){
96063 if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
96064 return 0;
96065 }
96066 return 2;
96067 }
96068 if( pA->op!=pB->op ){
96069 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){
96070 return 1;
96071 }
96072 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){
96073 return 1;
96074 }
96075 return 2;
96076 }
96077 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -95912,12 +96082,12 @@
96082 }
96083 }
96084 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
96085 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
96086 if( combinedFlags & EP_xIsSelect ) return 2;
96087 if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
96088 if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
96089 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
96090 if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
96091 if( pA->iColumn!=pB->iColumn ) return 2;
96092 if( pA->iTable!=pB->iTable
96093 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -95948,21 +96118,21 @@
96118 if( pA->nExpr!=pB->nExpr ) return 1;
96119 for(i=0; i<pA->nExpr; i++){
96120 Expr *pExprA = pA->a[i].pExpr;
96121 Expr *pExprB = pB->a[i].pExpr;
96122 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
96123 if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
96124 }
96125 return 0;
96126 }
96127
96128 /*
96129 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
96130 ** are ignored.
96131 */
96132 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
96133 return sqlite3ExprCompare(0,
96134 sqlite3ExprSkipCollate(pA),
96135 sqlite3ExprSkipCollate(pB),
96136 iTab);
96137 }
96138
@@ -95980,28 +96150,33 @@
96150 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
96151 **
96152 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
96153 ** Expr.iTable<0 then assume a table number given by iTab.
96154 **
96155 ** If pParse is not NULL, then the values of bound variables in pE1 are
96156 ** compared against literal values in pE2 and pParse->pVdbe->expmask is
96157 ** modified to record which bound variables are referenced. If pParse
96158 ** is NULL, then false will be returned if pE1 contains any bound variables.
96159 **
96160 ** When in doubt, return false. Returning true might give a performance
96161 ** improvement. Returning false might cause a performance reduction, but
96162 ** it will always give the correct answer and is hence always safe.
96163 */
96164 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
96165 if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){
96166 return 1;
96167 }
96168 if( pE2->op==TK_OR
96169 && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)
96170 || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )
96171 ){
96172 return 1;
96173 }
96174 if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
96175 Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
96176 testcase( pX!=pE1->pLeft );
96177 if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
96178 }
96179 return 0;
96180 }
96181
96182 /*
@@ -96238,11 +96413,11 @@
96413 /* Check to see if pExpr is a duplicate of another aggregate
96414 ** function that is already in the pAggInfo structure
96415 */
96416 struct AggInfo_func *pItem = pAggInfo->aFunc;
96417 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
96418 if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){
96419 break;
96420 }
96421 }
96422 if( i>=pAggInfo->nFunc ){
96423 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96795,11 +96970,11 @@
96970 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
96971 **
96972 ** Or, if zName is not a system table, zero is returned.
96973 */
96974 static int isSystemTable(Parse *pParse, const char *zName){
96975 if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96976 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
96977 return 1;
96978 }
96979 return 0;
96980 }
@@ -104193,11 +104368,13 @@
104368 for(j=0; j<pIdx->nKeyCol; j++){
104369 char *zCol;
104370 assert( pIdx->aiColumn[j]>=0 );
104371 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
104372 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
104373 sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
104374 sqlite3StrAccumAppend(&errMsg, ".", 1);
104375 sqlite3StrAccumAppendAll(&errMsg, zCol);
104376 }
104377 }
104378 zErr = sqlite3StrAccumFinish(&errMsg);
104379 sqlite3HaltConstraint(pParse,
104380 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -111051,11 +111228,11 @@
111228 if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
111229 return 0; /* Different columns indexed */
111230 }
111231 if( pSrc->aiColumn[i]==XN_EXPR ){
111232 assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
111233 if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,
111234 pDest->aColExpr->a[i].pExpr, -1)!=0 ){
111235 return 0; /* Different expressions in the index */
111236 }
111237 }
111238 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111063,11 +111240,11 @@
111240 }
111241 if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
111242 return 0; /* Different collating sequences */
111243 }
111244 }
111245 if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111246 return 0; /* Different WHERE clauses */
111247 }
111248
111249 /* If no test above fails then the indices must be compatible */
111250 return 1;
@@ -111543,15 +111720,12 @@
111720 if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111721 sqlite3DbFree(db, azCols);
111722
111723 rc = sqlite3ApiExit(db, rc);
111724 if( rc!=SQLITE_OK && pzErrMsg ){
111725 *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));
111726 if( *pzErrMsg==0 ){
 
 
 
111727 rc = SQLITE_NOMEM_BKPT;
111728 sqlite3Error(db, SQLITE_NOMEM);
111729 }
111730 }else if( pzErrMsg ){
111731 *pzErrMsg = 0;
@@ -113415,11 +113589,11 @@
113589 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113590 {/* zName: */ "read_uncommitted",
113591 /* ePragTyp: */ PragTyp_FLAG,
113592 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113593 /* ColNames: */ 0, 0,
113594 /* iArg: */ SQLITE_ReadUncommit },
113595 {/* zName: */ "recursive_triggers",
113596 /* ePragTyp: */ PragTyp_FLAG,
113597 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113598 /* ColNames: */ 0, 0,
113599 /* iArg: */ SQLITE_RecTriggers },
@@ -113567,11 +113741,11 @@
113741 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113742 {/* zName: */ "writable_schema",
113743 /* ePragTyp: */ PragTyp_FLAG,
113744 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113745 /* ColNames: */ 0, 0,
113746 /* iArg: */ SQLITE_WriteSchema },
113747 #endif
113748 };
113749 /* Number of pragmas: 60 on by default, 74 total. */
113750
113751 /************** End of pragma.h **********************************************/
@@ -116009,11 +116183,11 @@
116183 InitData *pData, /* Initialization context */
116184 const char *zObj, /* Object being parsed at the point of error */
116185 const char *zExtra /* Error information */
116186 ){
116187 sqlite3 *db = pData->db;
116188 if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
116189 char *z;
116190 if( zObj==0 ) zObj = "?";
116191 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
116192 if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
116193 sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116296,12 +116470,12 @@
116470 }
116471 if( db->mallocFailed ){
116472 rc = SQLITE_NOMEM_BKPT;
116473 sqlite3ResetAllSchemasOfConnection(db);
116474 }
116475 if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
116476 /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
116477 ** the schema loaded, even if errors occurred. In this situation the
116478 ** current sqlite3_prepare() operation will fail, but the following one
116479 ** will attempt to compile the supplied statement against whatever subset
116480 ** of the schema was loaded before the error occurred. The primary
116481 ** purpose of this is to allow access to the sqlite_master table
@@ -116497,11 +116671,11 @@
116671 */
116672 static int sqlite3Prepare(
116673 sqlite3 *db, /* Database handle. */
116674 const char *zSql, /* UTF-8 encoded SQL statement. */
116675 int nBytes, /* Length of zSql in bytes. */
116676 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116677 Vdbe *pReprepare, /* VM being reprepared */
116678 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116679 const char **pzTail /* OUT: End of parsed string */
116680 ){
116681 char *zErrMsg = 0; /* Error message */
@@ -116513,10 +116687,18 @@
116687 memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
116688 sParse.pReprepare = pReprepare;
116689 assert( ppStmt && *ppStmt==0 );
116690 /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116691 assert( sqlite3_mutex_held(db->mutex) );
116692
116693 /* For a long-term use prepared statement avoid the use of
116694 ** lookaside memory.
116695 */
116696 if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
116697 sParse.disableLookaside++;
116698 db->lookaside.bDisable++;
116699 }
116700
116701 /* Check to verify that it is possible to get a read lock on all
116702 ** database schemas. The inability to get a read lock indicates that
116703 ** some other database connection is holding a write-lock, which in
116704 ** turn means that the other connection has made uncommitted changes
@@ -116545,11 +116727,11 @@
116727 assert( sqlite3BtreeHoldsMutex(pBt) );
116728 rc = sqlite3BtreeSchemaLocked(pBt);
116729 if( rc ){
116730 const char *zDb = db->aDb[i].zDbSName;
116731 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116732 testcase( db->flags & SQLITE_ReadUncommit );
116733 goto end_prepare;
116734 }
116735 }
116736 }
116737
@@ -116613,12 +116795,11 @@
116795 }
116796 }
116797 #endif
116798
116799 if( db->init.busy==0 ){
116800 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
 
116801 }
116802 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116803 sqlite3VdbeFinalize(sParse.pVdbe);
116804 assert(!(*ppStmt));
116805 }else{
@@ -116648,11 +116829,11 @@
116829 }
116830 static int sqlite3LockAndPrepare(
116831 sqlite3 *db, /* Database handle. */
116832 const char *zSql, /* UTF-8 encoded SQL statement. */
116833 int nBytes, /* Length of zSql in bytes. */
116834 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116835 Vdbe *pOld, /* VM being reprepared */
116836 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116837 const char **pzTail /* OUT: End of parsed string */
116838 ){
116839 int rc;
@@ -116664,14 +116845,14 @@
116845 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116846 return SQLITE_MISUSE_BKPT;
116847 }
116848 sqlite3_mutex_enter(db->mutex);
116849 sqlite3BtreeEnterAll(db);
116850 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116851 if( rc==SQLITE_SCHEMA ){
116852 sqlite3_finalize(*ppStmt);
116853 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116854 }
116855 sqlite3BtreeLeaveAll(db);
116856 sqlite3_mutex_leave(db->mutex);
116857 assert( rc==SQLITE_OK || *ppStmt==0 );
116858 return rc;
@@ -116688,17 +116869,19 @@
116869 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116870 int rc;
116871 sqlite3_stmt *pNew;
116872 const char *zSql;
116873 sqlite3 *db;
116874 u8 prepFlags;
116875
116876 assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116877 zSql = sqlite3_sql((sqlite3_stmt *)p);
116878 assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116879 db = sqlite3VdbeDb(p);
116880 assert( sqlite3_mutex_held(db->mutex) );
116881 prepFlags = sqlite3VdbePrepareFlags(p);
116882 rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
116883 if( rc ){
116884 if( rc==SQLITE_NOMEM ){
116885 sqlite3OomFault(db);
116886 }
116887 assert( pNew==0 );
@@ -116740,11 +116923,27 @@
116923 int nBytes, /* Length of zSql in bytes. */
116924 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116925 const char **pzTail /* OUT: End of parsed string */
116926 ){
116927 int rc;
116928 rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
116929 ppStmt,pzTail);
116930 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116931 return rc;
116932 }
116933 SQLITE_API int sqlite3_prepare_v3(
116934 sqlite3 *db, /* Database handle. */
116935 const char *zSql, /* UTF-8 encoded SQL statement. */
116936 int nBytes, /* Length of zSql in bytes. */
116937 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116938 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116939 const char **pzTail /* OUT: End of parsed string */
116940 ){
116941 int rc;
116942 rc = sqlite3LockAndPrepare(db,zSql,nBytes,
116943 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
116944 0,ppStmt,pzTail);
116945 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116946 return rc;
116947 }
116948
116949
@@ -116754,11 +116953,11 @@
116953 */
116954 static int sqlite3Prepare16(
116955 sqlite3 *db, /* Database handle. */
116956 const void *zSql, /* UTF-16 encoded SQL statement. */
116957 int nBytes, /* Length of zSql in bytes. */
116958 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116959 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116960 const void **pzTail /* OUT: End of parsed string */
116961 ){
116962 /* This function currently works by first transforming the UTF-16
116963 ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116782,11 +116981,11 @@
116981 nBytes = sz;
116982 }
116983 sqlite3_mutex_enter(db->mutex);
116984 zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116985 if( zSql8 ){
116986 rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
116987 }
116988
116989 if( zTail8 && pzTail ){
116990 /* If sqlite3_prepare returns a tail pointer, we calculate the
116991 ** equivalent pointer into the UTF-16 string by counting the unicode
@@ -116828,11 +117027,26 @@
117027 int nBytes, /* Length of zSql in bytes. */
117028 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117029 const void **pzTail /* OUT: End of parsed string */
117030 ){
117031 int rc;
117032 rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
117033 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117034 return rc;
117035 }
117036 SQLITE_API int sqlite3_prepare16_v3(
117037 sqlite3 *db, /* Database handle. */
117038 const void *zSql, /* UTF-16 encoded SQL statement. */
117039 int nBytes, /* Length of zSql in bytes. */
117040 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117041 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117042 const void **pzTail /* OUT: End of parsed string */
117043 ){
117044 int rc;
117045 rc = sqlite3Prepare16(db,zSql,nBytes,
117046 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117047 ppStmt,pzTail);
117048 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117049 return rc;
117050 }
117051
117052 #endif /* SQLITE_OMIT_UTF16 */
@@ -121844,11 +122058,13 @@
122058 if( pItem->pSelect==0 ) continue;
122059 if( pItem->fg.viaCoroutine ) continue;
122060 if( pItem->zName==0 ) continue;
122061 if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
122062 if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
122063 if( sqlite3ExprCompare(0,
122064 pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
122065 ){
122066 /* The view was modified by some other optimization such as
122067 ** pushDownWhereTerms() */
122068 continue;
122069 }
122070 return pItem;
@@ -128193,11 +128409,11 @@
128409 ** If pExpr matches, then transform it into a reference to the index column
128410 ** that contains the value of pExpr.
128411 */
128412 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
128413 IdxExprTrans *pX = p->u.pIdxTrans;
128414 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128415 pExpr->op = TK_COLUMN;
128416 pExpr->iTable = pX->iIdxCur;
128417 pExpr->iColumn = pX->iIdxCol;
128418 pExpr->pTab = 0;
128419 return WRC_Prune;
@@ -129487,11 +129703,11 @@
129703 pList = pExpr->x.pList;
129704 pLeft = pList->a[1].pExpr;
129705
129706 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129707 op = pRight->op;
129708 if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
129709 Vdbe *pReprepare = pParse->pReprepare;
129710 int iCol = pRight->iColumn;
129711 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129712 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129713 z = (char *)sqlite3_value_text(pVal);
@@ -129677,12 +129893,12 @@
129893 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129894 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129895 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129896 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129897 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129898 if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129899 if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;
129900 /* If we reach this point, it means the two subterms can be combined */
129901 if( (eOp & (eOp-1))!=0 ){
129902 if( eOp & (WO_LT|WO_LE) ){
129903 eOp = WO_LE;
129904 }else{
@@ -130449,10 +130665,13 @@
130665 prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130666 if( (prereqExpr & prereqColumn)==0 ){
130667 Expr *pNewExpr;
130668 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130669 0, sqlite3ExprDup(db, pRight, 0));
130670 if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
130671 ExprSetProperty(pNewExpr, EP_FromJoin);
130672 }
130673 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130674 testcase( idxNew==0 );
130675 pNewTerm = &pWC->a[idxNew];
130676 pNewTerm->prereqRight = prereqExpr;
130677 pNewTerm->leftCursor = pLeft->iTable;
@@ -133387,11 +133606,11 @@
133606 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133607 }
133608 }else if( (aColExpr = pIndex->aColExpr)!=0 ){
133609 for(jj=0; jj<pIndex->nKeyCol; jj++){
133610 if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133611 if( sqlite3ExprCompare(0, pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133612 return 1;
133613 }
133614 }
133615 }
133616 }
@@ -133420,18 +133639,20 @@
133639 ** in the current query. Return true if it can be and false if not.
133640 */
133641 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133642 int i;
133643 WhereTerm *pTerm;
133644 Parse *pParse = pWC->pWInfo->pParse;
133645 while( pWhere->op==TK_AND ){
133646 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133647 pWhere = pWhere->pRight;
133648 }
133649 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
133650 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133651 Expr *pExpr = pTerm->pExpr;
133652 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133653 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
133654 ){
133655 return 1;
133656 }
133657 }
133658 return 0;
@@ -134406,11 +134627,12 @@
134627 if( iColumn>=(-1) ){
134628 if( pOBExpr->op!=TK_COLUMN ) continue;
134629 if( pOBExpr->iTable!=iCur ) continue;
134630 if( pOBExpr->iColumn!=iColumn ) continue;
134631 }else{
134632 if( sqlite3ExprCompare(0,
134633 pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134634 continue;
134635 }
134636 }
134637 if( iColumn>=0 ){
134638 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134705,10 +134927,11 @@
134927 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134928 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134929 rUnsorted, rCost));
134930 }else{
134931 rCost = rUnsorted;
134932 rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
134933 }
134934
134935 /* Check to see if pWLoop should be added to the set of
134936 ** mxChoice best-so-far paths.
134937 **
@@ -136126,19 +136349,19 @@
136349 #define sqlite3ParserARG_PDECL ,Parse *pParse
136350 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136351 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
136352 #define YYFALLBACK 1
136353 #define YYNSTATE 456
136354 #define YYNRULE 331
136355 #define YY_MAX_SHIFT 455
136356 #define YY_MIN_SHIFTREDUCE 667
136357 #define YY_MAX_SHIFTREDUCE 997
136358 #define YY_MIN_REDUCE 998
136359 #define YY_MAX_REDUCE 1328
136360 #define YY_ERROR_ACTION 1329
136361 #define YY_ACCEPT_ACTION 1330
136362 #define YY_NO_ACTION 1331
136363 /************* End control #defines *******************************************/
136364
136365 /* Define the yytestcase() macro to be a no-op if is not already defined
136366 ** otherwise.
136367 **
@@ -136208,167 +136431,167 @@
136431 ** yy_default[] Default action for each state.
136432 **
136433 *********** Begin parsing tables **********************************************/
136434 #define YY_ACTTAB_COUNT (1566)
136435 static const YYACTIONTYPE yy_action[] = {
136436 /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
136437 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136438 /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439 /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
136440 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136441 /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136442 /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136443 /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444 /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445 /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446 /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448 /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449 /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136450 /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136451 /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452 /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453 /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454 /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455 /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456 /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
136457 /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136458 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459 /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460 /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461 /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462 /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
136463 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136464 /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465 /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466 /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467 /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468 /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469 /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470 /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471 /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472 /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473 /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474 /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475 /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476 /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477 /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
136478 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136479 /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480 /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481 /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482 /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483 /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484 /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136485 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136486 /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487 /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488 /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489 /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490 /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491 /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492 /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136493 /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136494 /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495 /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496 /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497 /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498 /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499 /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
136500 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136501 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502 /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503 /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504 /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505 /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506 /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507 /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508 /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509 /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510 /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511 /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512 /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136513 /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136514 /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515 /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516 /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517 /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518 /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520 /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
136521 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136522 /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523 /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524 /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525 /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
136526 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136527 /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136528 /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136529 /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530 /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531 /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532 /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136533 /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136534 /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535 /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536 /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537 /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538 /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
136539 /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136540 /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541 /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542 /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
136543 /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136544 /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545 /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546 /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547 /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548 /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
136549 /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136550 /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551 /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552 /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553 /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554 /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555 /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
136556 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136557 /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558 /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559 /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560 /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561 /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562 /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563 /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564 /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565 /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566 /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567 /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568 /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569 /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570 /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571 /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572 /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573 /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574 /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575 /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576 /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577 /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
136578 /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136579 /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580 /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
136581 /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136582 /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583 /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584 /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585 /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586 /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587 /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588 /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589 /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590 /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591 /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592 /* 1560 */ 87, 312, 309, 945, 1288, 1287,
136593 };
136594 static const YYCODETYPE yy_lookahead[] = {
136595 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136596 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136597 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136617,56 +136840,56 @@
136840 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136841 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136842 /* 320 */ 1280, 1281, 1264, 1269, 1283,
136843 };
136844 static const YYACTIONTYPE yy_default[] = {
136845 /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846 /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847 /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848 /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849 /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850 /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851 /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852 /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853 /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854 /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855 /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856 /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857 /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858 /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859 /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860 /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861 /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862 /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863 /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864 /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865 /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866 /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867 /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868 /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869 /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870 /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871 /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872 /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873 /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874 /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875 /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876 /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877 /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878 /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879 /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880 /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881 /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882 /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883 /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884 /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885 /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886 /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887 /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888 /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889 /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890 /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
136891 };
136892 /********** End of lemon-generated parsing tables *****************************/
136893
136894 /* The next table maps tokens (terminal symbols) into fallback tokens.
136895 ** If a construct like the following:
@@ -136796,10 +137019,11 @@
137019 int yystksz; /* Current side of the stack */
137020 yyStackEntry *yystack; /* The parser's stack */
137021 yyStackEntry yystk0; /* First stack entry */
137022 #else
137023 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
137024 yyStackEntry *yystackEnd; /* Last entry in the stack */
137025 #endif
137026 };
137027 typedef struct yyParser yyParser;
137028
137029 #ifndef NDEBUG
@@ -137134,114 +137358,113 @@
137358 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137359 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137360 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137361 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137362 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137363 /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364 /* 229 */ "trigger_time ::= INSTEAD OF",
137365 /* 230 */ "trigger_time ::=",
137366 /* 231 */ "trigger_event ::= DELETE|INSERT",
137367 /* 232 */ "trigger_event ::= UPDATE",
137368 /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369 /* 234 */ "when_clause ::=",
137370 /* 235 */ "when_clause ::= WHEN expr",
137371 /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372 /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373 /* 238 */ "trnm ::= nm DOT nm",
137374 /* 239 */ "tridxby ::= INDEXED BY nm",
137375 /* 240 */ "tridxby ::= NOT INDEXED",
137376 /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377 /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378 /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379 /* 244 */ "trigger_cmd ::= select",
137380 /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381 /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382 /* 247 */ "raisetype ::= ROLLBACK",
137383 /* 248 */ "raisetype ::= ABORT",
137384 /* 249 */ "raisetype ::= FAIL",
137385 /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386 /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387 /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388 /* 253 */ "key_opt ::=",
137389 /* 254 */ "key_opt ::= KEY expr",
137390 /* 255 */ "cmd ::= REINDEX",
137391 /* 256 */ "cmd ::= REINDEX nm dbnm",
137392 /* 257 */ "cmd ::= ANALYZE",
137393 /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394 /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395 /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396 /* 261 */ "add_column_fullname ::= fullname",
137397 /* 262 */ "cmd ::= create_vtab",
137398 /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399 /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400 /* 265 */ "vtabarg ::=",
137401 /* 266 */ "vtabargtoken ::= ANY",
137402 /* 267 */ "vtabargtoken ::= lp anylist RP",
137403 /* 268 */ "lp ::= LP",
137404 /* 269 */ "with ::=",
137405 /* 270 */ "with ::= WITH wqlist",
137406 /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407 /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408 /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409 /* 274 */ "input ::= cmdlist",
137410 /* 275 */ "cmdlist ::= cmdlist ecmd",
137411 /* 276 */ "cmdlist ::= ecmd",
137412 /* 277 */ "ecmd ::= SEMI",
137413 /* 278 */ "ecmd ::= explain cmdx SEMI",
137414 /* 279 */ "explain ::=",
137415 /* 280 */ "trans_opt ::=",
137416 /* 281 */ "trans_opt ::= TRANSACTION",
137417 /* 282 */ "trans_opt ::= TRANSACTION nm",
137418 /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419 /* 284 */ "savepoint_opt ::=",
137420 /* 285 */ "cmd ::= create_table create_table_args",
137421 /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422 /* 287 */ "columnlist ::= columnname carglist",
137423 /* 288 */ "nm ::= ID|INDEXED",
137424 /* 289 */ "nm ::= STRING",
137425 /* 290 */ "nm ::= JOIN_KW",
137426 /* 291 */ "typetoken ::= typename",
137427 /* 292 */ "typename ::= ID|STRING",
137428 /* 293 */ "signed ::= plus_num",
137429 /* 294 */ "signed ::= minus_num",
137430 /* 295 */ "carglist ::= carglist ccons",
137431 /* 296 */ "carglist ::=",
137432 /* 297 */ "ccons ::= NULL onconf",
137433 /* 298 */ "conslist_opt ::= COMMA conslist",
137434 /* 299 */ "conslist ::= conslist tconscomma tcons",
137435 /* 300 */ "conslist ::= tcons",
137436 /* 301 */ "tconscomma ::=",
137437 /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438 /* 303 */ "resolvetype ::= raisetype",
137439 /* 304 */ "selectnowith ::= oneselect",
137440 /* 305 */ "oneselect ::= values",
137441 /* 306 */ "sclp ::= selcollist COMMA",
137442 /* 307 */ "as ::= ID|STRING",
137443 /* 308 */ "expr ::= term",
137444 /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445 /* 310 */ "exprlist ::= nexprlist",
137446 /* 311 */ "nmnum ::= plus_num",
137447 /* 312 */ "nmnum ::= nm",
137448 /* 313 */ "nmnum ::= ON",
137449 /* 314 */ "nmnum ::= DELETE",
137450 /* 315 */ "nmnum ::= DEFAULT",
137451 /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452 /* 317 */ "foreach_clause ::=",
137453 /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454 /* 319 */ "trnm ::= nm",
137455 /* 320 */ "tridxby ::=",
137456 /* 321 */ "database_kw_opt ::= DATABASE",
137457 /* 322 */ "database_kw_opt ::=",
137458 /* 323 */ "kwcolumn_opt ::=",
137459 /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460 /* 325 */ "vtabarglist ::= vtabarg",
137461 /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462 /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463 /* 328 */ "anylist ::=",
137464 /* 329 */ "anylist ::= anylist LP anylist RP",
137465 /* 330 */ "anylist ::= anylist ANY",
 
137466 };
137467 #endif /* NDEBUG */
137468
137469
137470 #if YYSTACKDEPTH<=0
@@ -137306,10 +137529,11 @@
137529 pParser->yyerrcnt = -1;
137530 #endif
137531 pParser->yytos = pParser->yystack;
137532 pParser->yystack[0].stateno = 0;
137533 pParser->yystack[0].major = 0;
137534 pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137535 }
137536
137537 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137538 /*
137539 ** This function allocates a new parser.
@@ -137648,11 +137872,11 @@
137872 yypParser->yyhwm++;
137873 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137874 }
137875 #endif
137876 #if YYSTACKDEPTH>0
137877 if( yypParser->yytos>yypParser->yystackEnd ){
137878 yypParser->yytos--;
137879 yyStackOverflow(yypParser);
137880 return;
137881 }
137882 #else
@@ -137676,345 +137900,344 @@
137900
137901 /* The following table contains information about every rule that
137902 ** is used during the reduce.
137903 */
137904 static const struct {
137905 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137906 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
137907 } yyRuleInfo[] = {
137908 { 147, -1 },
137909 { 147, -3 },
137910 { 148, -1 },
137911 { 149, -3 },
137912 { 150, 0 },
137913 { 150, -1 },
137914 { 150, -1 },
137915 { 150, -1 },
137916 { 149, -2 },
137917 { 149, -2 },
137918 { 149, -2 },
137919 { 149, -2 },
137920 { 149, -3 },
137921 { 149, -5 },
137922 { 154, -6 },
137923 { 156, -1 },
137924 { 158, 0 },
137925 { 158, -3 },
137926 { 157, -1 },
137927 { 157, 0 },
137928 { 155, -5 },
137929 { 155, -2 },
137930 { 162, 0 },
137931 { 162, -2 },
137932 { 164, -2 },
137933 { 166, 0 },
137934 { 166, -4 },
137935 { 166, -6 },
137936 { 167, -2 },
137937 { 171, -2 },
137938 { 171, -2 },
137939 { 171, -4 },
137940 { 171, -3 },
137941 { 171, -3 },
137942 { 171, -2 },
137943 { 171, -3 },
137944 { 171, -5 },
137945 { 171, -2 },
137946 { 171, -4 },
137947 { 171, -4 },
137948 { 171, -1 },
137949 { 171, -2 },
137950 { 176, 0 },
137951 { 176, -1 },
137952 { 178, 0 },
137953 { 178, -2 },
137954 { 180, -2 },
137955 { 180, -3 },
137956 { 180, -3 },
137957 { 180, -3 },
137958 { 181, -2 },
137959 { 181, -2 },
137960 { 181, -1 },
137961 { 181, -1 },
137962 { 181, -2 },
137963 { 179, -3 },
137964 { 179, -2 },
137965 { 182, 0 },
137966 { 182, -2 },
137967 { 182, -2 },
137968 { 161, 0 },
137969 { 184, -1 },
137970 { 185, -2 },
137971 { 185, -7 },
137972 { 185, -5 },
137973 { 185, -5 },
137974 { 185, -10 },
137975 { 188, 0 },
137976 { 174, 0 },
137977 { 174, -3 },
137978 { 189, 0 },
137979 { 189, -2 },
137980 { 190, -1 },
137981 { 190, -1 },
137982 { 149, -4 },
137983 { 192, -2 },
137984 { 192, 0 },
137985 { 149, -9 },
137986 { 149, -4 },
137987 { 149, -1 },
137988 { 163, -2 },
137989 { 194, -3 },
137990 { 197, -1 },
137991 { 197, -2 },
137992 { 197, -1 },
137993 { 195, -9 },
137994 { 206, -4 },
137995 { 206, -5 },
137996 { 198, -1 },
137997 { 198, -1 },
137998 { 198, 0 },
137999 { 209, 0 },
138000 { 199, -3 },
138001 { 199, -2 },
138002 { 199, -4 },
138003 { 210, -2 },
138004 { 210, 0 },
138005 { 200, 0 },
138006 { 200, -2 },
138007 { 212, -2 },
138008 { 212, 0 },
138009 { 211, -7 },
138010 { 211, -9 },
138011 { 211, -7 },
138012 { 211, -7 },
138013 { 159, 0 },
138014 { 159, -2 },
138015 { 193, -2 },
138016 { 213, -1 },
138017 { 213, -2 },
138018 { 213, -3 },
138019 { 213, -4 },
138020 { 215, -2 },
138021 { 215, 0 },
138022 { 214, 0 },
138023 { 214, -3 },
138024 { 214, -2 },
138025 { 216, -4 },
138026 { 216, 0 },
138027 { 204, 0 },
138028 { 204, -3 },
138029 { 186, -4 },
138030 { 186, -2 },
138031 { 175, -1 },
138032 { 175, -1 },
138033 { 175, 0 },
138034 { 202, 0 },
138035 { 202, -3 },
138036 { 203, 0 },
138037 { 203, -2 },
138038 { 205, 0 },
138039 { 205, -2 },
138040 { 205, -4 },
138041 { 205, -4 },
138042 { 149, -6 },
138043 { 201, 0 },
138044 { 201, -2 },
138045 { 149, -8 },
138046 { 218, -5 },
138047 { 218, -7 },
138048 { 218, -3 },
138049 { 218, -5 },
138050 { 149, -6 },
138051 { 149, -7 },
138052 { 219, -2 },
138053 { 219, -1 },
138054 { 220, 0 },
138055 { 220, -3 },
138056 { 217, -3 },
138057 { 217, -1 },
138058 { 173, -3 },
138059 { 172, -1 },
138060 { 173, -1 },
138061 { 173, -1 },
138062 { 173, -3 },
138063 { 173, -5 },
138064 { 172, -1 },
138065 { 172, -1 },
138066 { 172, -1 },
138067 { 173, -1 },
138068 { 173, -3 },
138069 { 173, -6 },
138070 { 173, -5 },
138071 { 173, -4 },
138072 { 172, -1 },
138073 { 173, -5 },
138074 { 173, -3 },
138075 { 173, -3 },
138076 { 173, -3 },
138077 { 173, -3 },
138078 { 173, -3 },
138079 { 173, -3 },
138080 { 173, -3 },
138081 { 173, -3 },
138082 { 221, -2 },
138083 { 173, -3 },
138084 { 173, -5 },
138085 { 173, -2 },
138086 { 173, -3 },
138087 { 173, -3 },
138088 { 173, -4 },
138089 { 173, -2 },
138090 { 173, -2 },
138091 { 173, -2 },
138092 { 173, -2 },
138093 { 222, -1 },
138094 { 222, -2 },
138095 { 173, -5 },
138096 { 223, -1 },
138097 { 223, -2 },
138098 { 173, -5 },
138099 { 173, -3 },
138100 { 173, -5 },
138101 { 173, -5 },
138102 { 173, -4 },
138103 { 173, -5 },
138104 { 226, -5 },
138105 { 226, -4 },
138106 { 227, -2 },
138107 { 227, 0 },
138108 { 225, -1 },
138109 { 225, 0 },
138110 { 208, 0 },
138111 { 207, -3 },
138112 { 207, -1 },
138113 { 224, 0 },
138114 { 224, -3 },
138115 { 149, -12 },
138116 { 228, -1 },
138117 { 228, 0 },
138118 { 177, 0 },
138119 { 177, -3 },
138120 { 187, -5 },
138121 { 187, -3 },
138122 { 229, 0 },
138123 { 229, -2 },
138124 { 149, -4 },
138125 { 149, -1 },
138126 { 149, -2 },
138127 { 149, -3 },
138128 { 149, -5 },
138129 { 149, -6 },
138130 { 149, -5 },
138131 { 149, -6 },
138132 { 169, -2 },
138133 { 170, -2 },
138134 { 149, -5 },
138135 { 231, -11 },
138136 { 233, -1 },
138137 { 233, -2 },
 
138138 { 233, 0 },
138139 { 234, -1 },
138140 { 234, -1 },
138141 { 234, -3 },
138142 { 236, 0 },
138143 { 236, -2 },
138144 { 232, -3 },
138145 { 232, -2 },
138146 { 238, -3 },
138147 { 239, -3 },
138148 { 239, -2 },
138149 { 237, -7 },
138150 { 237, -5 },
138151 { 237, -5 },
138152 { 237, -1 },
138153 { 173, -4 },
138154 { 173, -6 },
138155 { 191, -1 },
138156 { 191, -1 },
138157 { 191, -1 },
138158 { 149, -4 },
138159 { 149, -6 },
138160 { 149, -3 },
138161 { 241, 0 },
138162 { 241, -2 },
138163 { 149, -1 },
138164 { 149, -3 },
138165 { 149, -1 },
138166 { 149, -3 },
138167 { 149, -6 },
138168 { 149, -7 },
138169 { 242, -1 },
138170 { 149, -1 },
138171 { 149, -4 },
138172 { 244, -8 },
138173 { 246, 0 },
138174 { 247, -1 },
138175 { 247, -3 },
138176 { 248, -1 },
138177 { 196, 0 },
138178 { 196, -2 },
138179 { 196, -3 },
138180 { 250, -6 },
138181 { 250, -8 },
138182 { 144, -1 },
138183 { 145, -2 },
138184 { 145, -1 },
138185 { 146, -1 },
138186 { 146, -3 },
138187 { 147, 0 },
138188 { 151, 0 },
138189 { 151, -1 },
138190 { 151, -2 },
138191 { 153, -1 },
138192 { 153, 0 },
138193 { 149, -2 },
138194 { 160, -4 },
138195 { 160, -2 },
138196 { 152, -1 },
138197 { 152, -1 },
138198 { 152, -1 },
138199 { 166, -1 },
138200 { 167, -1 },
138201 { 168, -1 },
138202 { 168, -1 },
138203 { 165, -2 },
138204 { 165, 0 },
138205 { 171, -2 },
138206 { 161, -2 },
138207 { 183, -3 },
138208 { 183, -1 },
138209 { 184, 0 },
138210 { 188, -1 },
138211 { 190, -1 },
138212 { 194, -1 },
138213 { 195, -1 },
138214 { 209, -2 },
138215 { 210, -1 },
138216 { 173, -1 },
138217 { 221, -1 },
138218 { 208, -1 },
138219 { 230, -1 },
138220 { 230, -1 },
138221 { 230, -1 },
138222 { 230, -1 },
138223 { 230, -1 },
138224 { 169, -1 },
138225 { 235, 0 },
138226 { 235, -3 },
138227 { 238, -1 },
138228 { 239, 0 },
138229 { 240, -1 },
138230 { 240, 0 },
138231 { 243, 0 },
138232 { 243, -1 },
138233 { 245, -1 },
138234 { 245, -3 },
138235 { 246, -2 },
138236 { 249, 0 },
138237 { 249, -4 },
138238 { 249, -2 },
138239 };
138240
138241 static void yy_accept(yyParser*); /* Forward Declaration */
138242
138243 /*
@@ -138033,11 +138256,11 @@
138256 yymsp = yypParser->yytos;
138257 #ifndef NDEBUG
138258 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
138259 yysize = yyRuleInfo[yyruleno].nrhs;
138260 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
138261 yyRuleName[yyruleno], yymsp[yysize].stateno);
138262 }
138263 #endif /* NDEBUG */
138264
138265 /* Check that the stack is large enough to grow by a single entry
138266 ** if the RHS of the rule is empty. This ensures that there is room
@@ -138048,11 +138271,11 @@
138271 yypParser->yyhwm++;
138272 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
138273 }
138274 #endif
138275 #if YYSTACKDEPTH>0
138276 if( yypParser->yytos>=yypParser->yystackEnd ){
138277 yyStackOverflow(yypParser);
138278 return;
138279 }
138280 #else
138281 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139007,11 +139230,11 @@
139230 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139231 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139232 }
139233 break;
139234 case 208: /* uniqueflag ::= UNIQUE */
139235 case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
139236 {yymsp[0].minor.yy194 = OE_Abort;}
139237 break;
139238 case 209: /* uniqueflag ::= */
139239 {yymsp[1].minor.yy194 = OE_None;}
139240 break;
@@ -139061,268 +139284,269 @@
139284 {
139285 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139286 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139287 }
139288 break;
139289 case 228: /* trigger_time ::= BEFORE|AFTER */
139290 { yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139291 break;
139292 case 229: /* trigger_time ::= INSTEAD OF */
 
 
 
139293 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
139294 break;
139295 case 230: /* trigger_time ::= */
139296 { yymsp[1].minor.yy194 = TK_BEFORE; }
139297 break;
139298 case 231: /* trigger_event ::= DELETE|INSERT */
139299 case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
139300 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139301 break;
139302 case 233: /* trigger_event ::= UPDATE OF idlist */
139303 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139304 break;
139305 case 234: /* when_clause ::= */
139306 case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
139307 { yymsp[1].minor.yy72 = 0; }
139308 break;
139309 case 235: /* when_clause ::= WHEN expr */
139310 case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
139311 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139312 break;
139313 case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139314 {
139315 assert( yymsp[-2].minor.yy145!=0 );
139316 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139317 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139318 }
139319 break;
139320 case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
139321 {
139322 assert( yymsp[-1].minor.yy145!=0 );
139323 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139324 }
139325 break;
139326 case 238: /* trnm ::= nm DOT nm */
139327 {
139328 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139329 sqlite3ErrorMsg(pParse,
139330 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139331 "statements within triggers");
139332 }
139333 break;
139334 case 239: /* tridxby ::= INDEXED BY nm */
139335 {
139336 sqlite3ErrorMsg(pParse,
139337 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139338 "within triggers");
139339 }
139340 break;
139341 case 240: /* tridxby ::= NOT INDEXED */
139342 {
139343 sqlite3ErrorMsg(pParse,
139344 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139345 "within triggers");
139346 }
139347 break;
139348 case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139349 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139350 break;
139351 case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139352 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139353 break;
139354 case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139355 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139356 break;
139357 case 244: /* trigger_cmd ::= select */
139358 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139359 break;
139360 case 245: /* expr ::= RAISE LP IGNORE RP */
139361 {
139362 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139363 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139364 if( yymsp[-3].minor.yy190.pExpr ){
139365 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139366 }
139367 }
139368 break;
139369 case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
139370 {
139371 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139372 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139373 if( yymsp[-5].minor.yy190.pExpr ) {
139374 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139375 }
139376 }
139377 break;
139378 case 247: /* raisetype ::= ROLLBACK */
139379 {yymsp[0].minor.yy194 = OE_Rollback;}
139380 break;
139381 case 249: /* raisetype ::= FAIL */
139382 {yymsp[0].minor.yy194 = OE_Fail;}
139383 break;
139384 case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
139385 {
139386 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139387 }
139388 break;
139389 case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139390 {
139391 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139392 }
139393 break;
139394 case 252: /* cmd ::= DETACH database_kw_opt expr */
139395 {
139396 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139397 }
139398 break;
139399 case 255: /* cmd ::= REINDEX */
139400 {sqlite3Reindex(pParse, 0, 0);}
139401 break;
139402 case 256: /* cmd ::= REINDEX nm dbnm */
139403 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139404 break;
139405 case 257: /* cmd ::= ANALYZE */
139406 {sqlite3Analyze(pParse, 0, 0);}
139407 break;
139408 case 258: /* cmd ::= ANALYZE nm dbnm */
139409 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139410 break;
139411 case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139412 {
139413 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139414 }
139415 break;
139416 case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139417 {
139418 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139419 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139420 }
139421 break;
139422 case 261: /* add_column_fullname ::= fullname */
139423 {
139424 disableLookaside(pParse);
139425 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139426 }
139427 break;
139428 case 262: /* cmd ::= create_vtab */
139429 {sqlite3VtabFinishParse(pParse,0);}
139430 break;
139431 case 263: /* cmd ::= create_vtab LP vtabarglist RP */
139432 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139433 break;
139434 case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139435 {
139436 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139437 }
139438 break;
139439 case 265: /* vtabarg ::= */
139440 {sqlite3VtabArgInit(pParse);}
139441 break;
139442 case 266: /* vtabargtoken ::= ANY */
139443 case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444 case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
139445 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139446 break;
139447 case 269: /* with ::= */
139448 {yymsp[1].minor.yy285 = 0;}
139449 break;
139450 case 270: /* with ::= WITH wqlist */
139451 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139452 break;
139453 case 271: /* with ::= WITH RECURSIVE wqlist */
139454 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139455 break;
139456 case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
139457 {
139458 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139459 }
139460 break;
139461 case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139462 {
139463 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139464 }
139465 break;
139466 default:
139467 /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468 /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469 /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470 /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471 /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472 /* (279) explain ::= */ yytestcase(yyruleno==279);
139473 /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474 /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475 /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476 /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477 /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478 /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479 /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480 /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481 /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482 /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483 /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484 /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485 /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486 /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487 /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488 /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489 /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490 /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491 /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492 /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493 /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494 /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495 /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496 /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497 /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498 /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499 /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500 /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501 /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502 /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503 /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504 /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505 /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506 /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507 /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508 /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509 /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510 /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511 /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512 /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513 /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514 /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515 /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516 /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517 /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518 /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519 /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520 /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521 /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522 /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523 /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
139524 break;
139525 /********** End reduce actions ************************************************/
139526 };
139527 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139528 yygoto = yyRuleInfo[yyruleno].lhs;
139529 yysize = yyRuleInfo[yyruleno].nrhs;
139530 yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
139531
139532 /* There are no SHIFTREDUCE actions on nonterminals because the table
139533 ** generator has simplified them to pure REDUCE actions. */
139534 assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
139535
139536 /* It is not possible for a REDUCE to be followed by an error */
139537 assert( yyact!=YY_ERROR_ACTION );
139538
139539 if( yyact==YY_ACCEPT_ACTION ){
139540 yypParser->yytos += yysize;
139541 yy_accept(yypParser);
139542 }else{
139543 yymsp += yysize+1;
139544 yypParser->yytos = yymsp;
139545 yymsp->stateno = (YYACTIONTYPE)yyact;
139546 yymsp->major = (YYCODETYPE)yygoto;
139547 yyTraceShift(yypParser, yyact);
 
 
 
 
139548 }
139549 }
139550
139551 /*
139552 ** The following code executes when the parse fails
@@ -140886,10 +141110,13 @@
141110 /************** Continuing where we left off in main.c ***********************/
141111 #endif
141112 #ifdef SQLITE_ENABLE_JSON1
141113 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
141114 #endif
141115 #ifdef SQLITE_ENABLE_STMTVTAB
141116 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
141117 #endif
141118 #ifdef SQLITE_ENABLE_FTS5
141119 SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
141120 #endif
141121
141122 #ifndef SQLITE_AMALGAMATION
@@ -141669,10 +141896,11 @@
141896 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141897 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141898 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141899 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141900 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
141901 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
141902 };
141903 unsigned int i;
141904 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141905 for(i=0; i<ArraySize(aFlagOp); i++){
141906 if( aFlagOp[i].op==op ){
@@ -143774,10 +144002,13 @@
144002 | SQLITE_CellSizeCk
144003 #endif
144004 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
144005 | SQLITE_Fts3Tokenizer
144006 #endif
144007 #if defined(SQLITE_ENABLE_QPSG)
144008 | SQLITE_EnableQPSG
144009 #endif
144010 ;
144011 sqlite3HashInit(&db->aCollSeq);
144012 #ifndef SQLITE_OMIT_VIRTUALTABLE
144013 sqlite3HashInit(&db->aModule);
144014 #endif
@@ -143911,10 +144142,16 @@
144142 #ifdef SQLITE_ENABLE_JSON1
144143 if( !db->mallocFailed && rc==SQLITE_OK){
144144 rc = sqlite3Json1Init(db);
144145 }
144146 #endif
144147
144148 #ifdef SQLITE_ENABLE_STMTVTAB
144149 if( !db->mallocFailed && rc==SQLITE_OK){
144150 rc = sqlite3StmtVtabInit(db);
144151 }
144152 #endif
144153
144154 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
144155 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
144156 ** mode. Doing nothing at all also makes NORMAL the default.
144157 */
@@ -148000,11 +148237,11 @@
148237 pCsr->pStmt = p->pSeekStmt;
148238 p->pSeekStmt = 0;
148239 }else{
148240 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
148241 if( !zSql ) return SQLITE_NOMEM;
148242 rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
148243 sqlite3_free(zSql);
148244 }
148245 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
148246 }
148247 return rc;
@@ -149537,11 +149774,11 @@
149774 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149775 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149776 );
149777 }
149778 if( zSql ){
149779 rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
149780 sqlite3_free(zSql);
149781 }else{
149782 rc = SQLITE_NOMEM;
149783 }
149784 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156744,11 +156981,12 @@
156981 zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156982 }
156983 if( !zSql ){
156984 rc = SQLITE_NOMEM;
156985 }else{
156986 rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
156987 &pStmt, NULL);
156988 sqlite3_free(zSql);
156989 assert( rc==SQLITE_OK || pStmt==0 );
156990 p->aStmt[eStmt] = pStmt;
156991 }
156992 }
@@ -167854,11 +168092,12 @@
168092
168093 rc = rtreeQueryStat1(db, pRtree);
168094 for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
168095 char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
168096 if( zSql ){
168097 rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
168098 appStmt[i], 0);
168099 }else{
168100 rc = SQLITE_NOMEM;
168101 }
168102 sqlite3_free(zSql);
168103 }
@@ -183900,16 +184139,16 @@
184139 ** fts5yy_default[] Default action for each state.
184140 **
184141 *********** Begin parsing tables **********************************************/
184142 #define fts5YY_ACTTAB_COUNT (98)
184143 static const fts5YYACTIONTYPE fts5yy_action[] = {
184144 /* 0 */ 105, 19, 90, 6, 26, 93, 92, 24, 24, 17,
184145 /* 10 */ 90, 6, 26, 16, 92, 54, 24, 18, 90, 6,
184146 /* 20 */ 26, 10, 92, 12, 24, 75, 86, 90, 6, 26,
184147 /* 30 */ 13, 92, 75, 24, 20, 90, 6, 26, 101, 92,
184148 /* 40 */ 56, 24, 27, 90, 6, 26, 100, 92, 21, 24,
184149 /* 50 */ 23, 15, 30, 11, 1, 91, 22, 25, 9, 92,
184150 /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
184151 /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
184152 /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
184153 /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
184154 };
@@ -184010,10 +184249,11 @@
184249 int fts5yystksz; /* Current side of the stack */
184250 fts5yyStackEntry *fts5yystack; /* The parser's stack */
184251 fts5yyStackEntry fts5yystk0; /* First stack entry */
184252 #else
184253 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
184254 fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */
184255 #endif
184256 };
184257 typedef struct fts5yyParser fts5yyParser;
184258
184259 #ifndef NDEBUG
@@ -184159,10 +184399,11 @@
184399 pParser->fts5yyerrcnt = -1;
184400 #endif
184401 pParser->fts5yytos = pParser->fts5yystack;
184402 pParser->fts5yystack[0].stateno = 0;
184403 pParser->fts5yystack[0].major = 0;
184404 pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184405 }
184406
184407 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184408 /*
184409 ** This function allocates a new parser.
@@ -184457,11 +184698,11 @@
184698 fts5yypParser->fts5yyhwm++;
184699 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184700 }
184701 #endif
184702 #if fts5YYSTACKDEPTH>0
184703 if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){
184704 fts5yypParser->fts5yytos--;
184705 fts5yyStackOverflow(fts5yypParser);
184706 return;
184707 }
184708 #else
@@ -184485,39 +184726,39 @@
184726
184727 /* The following table contains information about every rule that
184728 ** is used during the reduce.
184729 */
184730 static const struct {
184731 fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184732 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
184733 } fts5yyRuleInfo[] = {
184734 { 16, -1 },
184735 { 20, -4 },
184736 { 20, -3 },
184737 { 20, -1 },
184738 { 20, -2 },
184739 { 21, -2 },
184740 { 21, -1 },
184741 { 17, -3 },
184742 { 17, -3 },
184743 { 17, -3 },
184744 { 17, -5 },
184745 { 17, -3 },
184746 { 17, -1 },
184747 { 19, -1 },
184748 { 19, -2 },
184749 { 18, -1 },
184750 { 18, -3 },
184751 { 22, -1 },
184752 { 22, -5 },
184753 { 23, -1 },
184754 { 23, -2 },
184755 { 25, 0 },
184756 { 25, -2 },
184757 { 24, -4 },
184758 { 24, -2 },
184759 { 26, -1 },
184760 { 26, 0 },
184761 };
184762
184763 static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184764
@@ -184537,11 +184778,11 @@
184778 fts5yymsp = fts5yypParser->fts5yytos;
184779 #ifndef NDEBUG
184780 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184781 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184782 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184783 fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
184784 }
184785 #endif /* NDEBUG */
184786
184787 /* Check that the stack is large enough to grow by a single entry
184788 ** if the RHS of the rule is empty. This ensures that there is room
@@ -184552,11 +184793,11 @@
184793 fts5yypParser->fts5yyhwm++;
184794 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184795 }
184796 #endif
184797 #if fts5YYSTACKDEPTH>0
184798 if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
184799 fts5yyStackOverflow(fts5yypParser);
184800 return;
184801 }
184802 #else
184803 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184719,24 +184960,28 @@
184960 /********** End reduce actions ************************************************/
184961 };
184962 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184963 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184964 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184965 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184966
184967 /* There are no SHIFTREDUCE actions on nonterminals because the table
184968 ** generator has simplified them to pure REDUCE actions. */
184969 assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );
184970
184971 /* It is not possible for a REDUCE to be followed by an error */
184972 assert( fts5yyact!=fts5YY_ERROR_ACTION );
184973
184974 if( fts5yyact==fts5YY_ACCEPT_ACTION ){
184975 fts5yypParser->fts5yytos += fts5yysize;
184976 fts5yy_accept(fts5yypParser);
184977 }else{
184978 fts5yymsp += fts5yysize+1;
184979 fts5yypParser->fts5yytos = fts5yymsp;
184980 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184981 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184982 fts5yyTraceShift(fts5yypParser, fts5yyact);
 
 
 
 
184983 }
184984 }
184985
184986 /*
184987 ** The following code executes when the parse fails
@@ -191124,11 +191369,12 @@
191369 sqlite3_stmt **ppStmt,
191370 char *zSql
191371 ){
191372 if( p->rc==SQLITE_OK ){
191373 if( zSql ){
191374 p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
191375 SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
191376 }else{
191377 p->rc = SQLITE_NOMEM;
191378 }
191379 }
191380 sqlite3_free(zSql);
@@ -191173,11 +191419,12 @@
191419 pConfig->zDb, pConfig->zName
191420 );
191421 if( zSql==0 ){
191422 rc = SQLITE_NOMEM;
191423 }else{
191424 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
191425 SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
191426 sqlite3_free(zSql);
191427 }
191428 if( rc!=SQLITE_OK ){
191429 p->rc = rc;
191430 return;
@@ -197772,11 +198019,12 @@
198019 va_start(ap, zFmt);
198020 zSql = sqlite3_vmprintf(zFmt, ap);
198021 if( zSql==0 ){
198022 rc = SQLITE_NOMEM;
198023 }else{
198024 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198025 SQLITE_PREPARE_PERSISTENT, &pRet, 0);
198026 if( rc!=SQLITE_OK ){
198027 *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
198028 }
198029 sqlite3_free(zSql);
198030 }
@@ -197908,11 +198156,12 @@
198156
198157 if( zRankArgs ){
198158 char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
198159 if( zSql ){
198160 sqlite3_stmt *pStmt = 0;
198161 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198162 SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
198163 sqlite3_free(zSql);
198164 assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
198165 if( rc==SQLITE_OK ){
198166 if( SQLITE_ROW==sqlite3_step(pStmt) ){
198167 int nByte;
@@ -199517,11 +199766,11 @@
199766 int nArg, /* Number of args */
199767 sqlite3_value **apUnused /* Function arguments */
199768 ){
199769 assert( nArg==0 );
199770 UNUSED_PARAM2(nArg, apUnused);
199771 sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
199772 }
199773
199774 static int fts5Init(sqlite3 *db){
199775 static const sqlite3_module fts5Mod = {
199776 /* iVersion */ 2,
@@ -199771,11 +200020,12 @@
200020 }
200021
200022 if( zSql==0 ){
200023 rc = SQLITE_NOMEM;
200024 }else{
200025 rc = sqlite3_prepare_v3(pC->db, zSql, -1,
200026 SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
200027 sqlite3_free(zSql);
200028 if( rc!=SQLITE_OK && pzErrMsg ){
200029 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
200030 }
200031 }
@@ -203371,5 +203621,325 @@
203621
203622
203623 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
203624
203625 /************** End of fts5.c ************************************************/
203626 /************** Begin file stmt.c ********************************************/
203627 /*
203628 ** 2017-05-31
203629 **
203630 ** The author disclaims copyright to this source code. In place of
203631 ** a legal notice, here is a blessing:
203632 **
203633 ** May you do good and not evil.
203634 ** May you find forgiveness for yourself and forgive others.
203635 ** May you share freely, never taking more than you give.
203636 **
203637 *************************************************************************
203638 **
203639 ** This file demonstrates an eponymous virtual table that returns information
203640 ** about all prepared statements for the database connection.
203641 **
203642 ** Usage example:
203643 **
203644 ** .load ./stmt
203645 ** .mode line
203646 ** .header on
203647 ** SELECT * FROM stmt;
203648 */
203649 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)
203650 #if !defined(SQLITEINT_H)
203651 /* #include "sqlite3ext.h" */
203652 #endif
203653 SQLITE_EXTENSION_INIT1
203654 /* #include <assert.h> */
203655 /* #include <string.h> */
203656
203657 #ifndef SQLITE_OMIT_VIRTUALTABLE
203658
203659 /*
203660 ** The following macros are used to cast pointers to integers.
203661 ** The way you do this varies from one compiler
203662 ** to the next, so we have developed the following set of #if statements
203663 ** to generate appropriate macros for a wide range of compilers.
203664 */
203665 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
203666 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
203667 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
203668 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
203669 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
203670 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
203671 #else /* Generates a warning - but it always works */
203672 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
203673 #endif
203674
203675
203676 /* stmt_vtab is a subclass of sqlite3_vtab which will
203677 ** serve as the underlying representation of a stmt virtual table
203678 */
203679 typedef struct stmt_vtab stmt_vtab;
203680 struct stmt_vtab {
203681 sqlite3_vtab base; /* Base class - must be first */
203682 sqlite3 *db; /* Database connection for this stmt vtab */
203683 };
203684
203685 /* stmt_cursor is a subclass of sqlite3_vtab_cursor which will
203686 ** serve as the underlying representation of a cursor that scans
203687 ** over rows of the result
203688 */
203689 typedef struct stmt_cursor stmt_cursor;
203690 struct stmt_cursor {
203691 sqlite3_vtab_cursor base; /* Base class - must be first */
203692 sqlite3 *db; /* Database connection for this cursor */
203693 sqlite3_stmt *pStmt; /* Statement cursor is currently pointing at */
203694 sqlite3_int64 iRowid; /* The rowid */
203695 };
203696
203697 /*
203698 ** The stmtConnect() method is invoked to create a new
203699 ** stmt_vtab that describes the generate_stmt virtual table.
203700 **
203701 ** Think of this routine as the constructor for stmt_vtab objects.
203702 **
203703 ** All this routine needs to do is:
203704 **
203705 ** (1) Allocate the stmt_vtab object and initialize all fields.
203706 **
203707 ** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708 ** result set of queries against generate_stmt will look like.
203709 */
203710 static int stmtConnect(
203711 sqlite3 *db,
203712 void *pAux,
203713 int argc, const char *const*argv,
203714 sqlite3_vtab **ppVtab,
203715 char **pzErr
203716 ){
203717 stmt_vtab *pNew;
203718 int rc;
203719
203720 /* Column numbers */
203721 #define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
203722 #define STMT_COLUMN_SQL 1 /* SQL for the statement */
203723 #define STMT_COLUMN_NCOL 2 /* Number of result columns */
203724 #define STMT_COLUMN_RO 3 /* True if read-only */
203725 #define STMT_COLUMN_BUSY 4 /* True if currently busy */
203726 #define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
203727 #define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
203728 #define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
203729 #define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
203730 #define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
203731 #define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
203732 #define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
203733
203734
203735 rc = sqlite3_declare_vtab(db,
203736 "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
203737 "reprep,run,mem)");
203738 if( rc==SQLITE_OK ){
203739 pNew = sqlite3_malloc( sizeof(*pNew) );
203740 *ppVtab = (sqlite3_vtab*)pNew;
203741 if( pNew==0 ) return SQLITE_NOMEM;
203742 memset(pNew, 0, sizeof(*pNew));
203743 pNew->db = db;
203744 }
203745 return rc;
203746 }
203747
203748 /*
203749 ** This method is the destructor for stmt_cursor objects.
203750 */
203751 static int stmtDisconnect(sqlite3_vtab *pVtab){
203752 sqlite3_free(pVtab);
203753 return SQLITE_OK;
203754 }
203755
203756 /*
203757 ** Constructor for a new stmt_cursor object.
203758 */
203759 static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
203760 stmt_cursor *pCur;
203761 pCur = sqlite3_malloc( sizeof(*pCur) );
203762 if( pCur==0 ) return SQLITE_NOMEM;
203763 memset(pCur, 0, sizeof(*pCur));
203764 pCur->db = ((stmt_vtab*)p)->db;
203765 *ppCursor = &pCur->base;
203766 return SQLITE_OK;
203767 }
203768
203769 /*
203770 ** Destructor for a stmt_cursor.
203771 */
203772 static int stmtClose(sqlite3_vtab_cursor *cur){
203773 sqlite3_free(cur);
203774 return SQLITE_OK;
203775 }
203776
203777
203778 /*
203779 ** Advance a stmt_cursor to its next row of output.
203780 */
203781 static int stmtNext(sqlite3_vtab_cursor *cur){
203782 stmt_cursor *pCur = (stmt_cursor*)cur;
203783 pCur->iRowid++;
203784 pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);
203785 return SQLITE_OK;
203786 }
203787
203788 /*
203789 ** Return values of columns for the row at which the stmt_cursor
203790 ** is currently pointing.
203791 */
203792 static int stmtColumn(
203793 sqlite3_vtab_cursor *cur, /* The cursor */
203794 sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
203795 int i /* Which column to return */
203796 ){
203797 stmt_cursor *pCur = (stmt_cursor*)cur;
203798 switch( i ){
203799 case STMT_COLUMN_PTR: {
203800 sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
203801 break;
203802 }
203803 case STMT_COLUMN_SQL: {
203804 sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
203805 break;
203806 }
203807 case STMT_COLUMN_NCOL: {
203808 sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));
203809 break;
203810 }
203811 case STMT_COLUMN_RO: {
203812 sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));
203813 break;
203814 }
203815 case STMT_COLUMN_BUSY: {
203816 sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
203817 break;
203818 }
203819 case STMT_COLUMN_MEM: {
203820 i = SQLITE_STMTSTATUS_MEMUSED +
203821 STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
203822 /* Fall thru */
203823 }
203824 case STMT_COLUMN_NSCAN:
203825 case STMT_COLUMN_NSORT:
203826 case STMT_COLUMN_NAIDX:
203827 case STMT_COLUMN_NSTEP:
203828 case STMT_COLUMN_REPREP:
203829 case STMT_COLUMN_RUN: {
203830 sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
203831 i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
203832 break;
203833 }
203834 }
203835 return SQLITE_OK;
203836 }
203837
203838 /*
203839 ** Return the rowid for the current row. In this implementation, the
203840 ** rowid is the same as the output value.
203841 */
203842 static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
203843 stmt_cursor *pCur = (stmt_cursor*)cur;
203844 *pRowid = pCur->iRowid;
203845 return SQLITE_OK;
203846 }
203847
203848 /*
203849 ** Return TRUE if the cursor has been moved off of the last
203850 ** row of output.
203851 */
203852 static int stmtEof(sqlite3_vtab_cursor *cur){
203853 stmt_cursor *pCur = (stmt_cursor*)cur;
203854 return pCur->pStmt==0;
203855 }
203856
203857 /*
203858 ** This method is called to "rewind" the stmt_cursor object back
203859 ** to the first row of output. This method is always called at least
203860 ** once prior to any call to stmtColumn() or stmtRowid() or
203861 ** stmtEof().
203862 */
203863 static int stmtFilter(
203864 sqlite3_vtab_cursor *pVtabCursor,
203865 int idxNum, const char *idxStr,
203866 int argc, sqlite3_value **argv
203867 ){
203868 stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;
203869 pCur->pStmt = 0;
203870 pCur->iRowid = 0;
203871 return stmtNext(pVtabCursor);
203872 }
203873
203874 /*
203875 ** SQLite will invoke this method one or more times while planning a query
203876 ** that uses the generate_stmt virtual table. This routine needs to create
203877 ** a query plan for each invocation and compute an estimated cost for that
203878 ** plan.
203879 */
203880 static int stmtBestIndex(
203881 sqlite3_vtab *tab,
203882 sqlite3_index_info *pIdxInfo
203883 ){
203884 pIdxInfo->estimatedCost = (double)500;
203885 pIdxInfo->estimatedRows = 500;
203886 return SQLITE_OK;
203887 }
203888
203889 /*
203890 ** This following structure defines all the methods for the
203891 ** generate_stmt virtual table.
203892 */
203893 static sqlite3_module stmtModule = {
203894 0, /* iVersion */
203895 0, /* xCreate */
203896 stmtConnect, /* xConnect */
203897 stmtBestIndex, /* xBestIndex */
203898 stmtDisconnect, /* xDisconnect */
203899 0, /* xDestroy */
203900 stmtOpen, /* xOpen - open a cursor */
203901 stmtClose, /* xClose - close a cursor */
203902 stmtFilter, /* xFilter - configure scan constraints */
203903 stmtNext, /* xNext - advance a cursor */
203904 stmtEof, /* xEof - check for end of scan */
203905 stmtColumn, /* xColumn - read data */
203906 stmtRowid, /* xRowid - read data */
203907 0, /* xUpdate */
203908 0, /* xBegin */
203909 0, /* xSync */
203910 0, /* xCommit */
203911 0, /* xRollback */
203912 0, /* xFindMethod */
203913 0, /* xRename */
203914 };
203915
203916 #endif /* SQLITE_OMIT_VIRTUALTABLE */
203917
203918 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
203919 int rc = SQLITE_OK;
203920 #ifndef SQLITE_OMIT_VIRTUALTABLE
203921 rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
203922 #endif
203923 return rc;
203924 }
203925
203926 #ifndef SQLITE_CORE
203927 #ifdef _WIN32
203928 __declspec(dllexport)
203929 #endif
203930 SQLITE_API int sqlite3_stmt_init(
203931 sqlite3 *db,
203932 char **pzErrMsg,
203933 const sqlite3_api_routines *pApi
203934 ){
203935 int rc = SQLITE_OK;
203936 SQLITE_EXTENSION_INIT2(pApi);
203937 #ifndef SQLITE_OMIT_VIRTUALTABLE
203938 rc = sqlite3StmtVtabInit(db);
203939 #endif
203940 return rc;
203941 }
203942 #endif /* SQLITE_CORE */
203943 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
203944
203945 /************** End of stmt.c ************************************************/
203946
+129 -41
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
11
/*
2
-** 2001 September 15
2
+** 2001-09-15
33
**
44
** The author disclaims copyright to this source code. In place of
55
** a legal notice, here is a blessing:
66
**
77
** May you do good and not evil.
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.20.0"
125125
#define SQLITE_VERSION_NUMBER 3020000
126
-#define SQLITE_SOURCE_ID "2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a"
126
+#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -233,11 +233,11 @@
233233
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234234
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235235
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236236
** and [sqlite3_close_v2()] are its destructors. There are many other
237237
** interfaces (such as
238
-** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
238
+** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
239239
** [sqlite3_busy_timeout()] to name but three) that are methods on an
240240
** sqlite3 object.
241241
*/
242242
typedef struct sqlite3 sqlite3;
243243
@@ -337,11 +337,11 @@
337337
/*
338338
** CAPI3REF: One-Step Query Execution Interface
339339
** METHOD: sqlite3
340340
**
341341
** The sqlite3_exec() interface is a convenience wrapper around
342
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
342
+** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
343343
** that allows an application to run multiple statements of SQL
344344
** without having to use a lot of C code.
345345
**
346346
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347347
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,19 +2005,31 @@
20052005
** default) to enable them. The second parameter is a pointer to an integer
20062006
** into which is written 0 or 1 to indicate whether checkpoints-on-close
20072007
** have been disabled - 0 if they are not disabled, 1 if they are.
20082008
** </dd>
20092009
**
2010
+** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011
+** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012
+** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013
+** a single SQL query statement will always use the same algorithm regardless
2014
+** of values of [bound parameters]. The QPSG disables some query optimizations
2015
+** that look at the values of bound parameters, which can make some queries
2016
+** slower. But the QPSG has the advantage of more predictable behavior. With
2017
+** the QPSG active, SQLite will always use the same query plan in the field as
2018
+** was used during testing in the lab.
2019
+** </dd>
2020
+**
20102021
** </dl>
20112022
*/
20122023
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
20132024
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
20142025
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
20152026
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
20162027
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
20172028
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
20182029
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2030
+#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
20192031
20202032
20212033
/*
20222034
** CAPI3REF: Enable Or Disable Extended Result Codes
20232035
** METHOD: sqlite3
@@ -2677,25 +2689,26 @@
26772689
**
26782690
** ^This routine registers an authorizer callback with a particular
26792691
** [database connection], supplied in the first argument.
26802692
** ^The authorizer callback is invoked as SQL statements are being compiled
26812693
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2682
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
2694
+** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
2695
+** and [sqlite3_prepare16_v3()]. ^At various
26832696
** points during the compilation process, as logic is being created
26842697
** to perform various actions, the authorizer callback is invoked to
26852698
** see if those actions are allowed. ^The authorizer callback should
26862699
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
26872700
** specific action but allow the SQL statement to continue to be
26882701
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
26892702
** rejected with an error. ^If the authorizer callback returns
26902703
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2691
-** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2704
+** then the [sqlite3_prepare_v3()] or equivalent call that triggered
26922705
** the authorizer will fail with an error message.
26932706
**
26942707
** When the callback returns [SQLITE_OK], that means the operation
26952708
** requested is ok. ^When the callback returns [SQLITE_DENY], the
2696
-** [sqlite3_prepare_v2()] or equivalent call that triggered the
2709
+** [sqlite3_prepare_v3()] or equivalent call that triggered the
26972710
** authorizer will fail with an error message explaining that
26982711
** access is denied.
26992712
**
27002713
** ^The first parameter to the authorizer callback is a copy of the third
27012714
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2742,23 +2755,23 @@
27422755
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
27432756
** The authorizer is disabled by default.
27442757
**
27452758
** The authorizer callback must not do anything that will modify
27462759
** the database connection that invoked the authorizer callback.
2747
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2760
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
27482761
** database connections for the meaning of "modify" in this paragraph.
27492762
**
2750
-** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2763
+** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
27512764
** statement might be re-prepared during [sqlite3_step()] due to a
27522765
** schema change. Hence, the application should ensure that the
27532766
** correct authorizer callback remains in place during the [sqlite3_step()].
27542767
**
27552768
** ^Note that the authorizer callback is invoked only during
27562769
** [sqlite3_prepare()] or its variants. Authorization is not
27572770
** performed during statement evaluation in [sqlite3_step()], unless
27582771
** as stated in the previous paragraph, sqlite3_step() invokes
2759
-** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2772
+** sqlite3_prepare_v3() to reprepare a statement after a schema change.
27602773
*/
27612774
SQLITE_API int sqlite3_set_authorizer(
27622775
sqlite3*,
27632776
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
27642777
void *pUserData
@@ -2990,11 +3003,11 @@
29903003
** interrupted. This feature can be used to implement a
29913004
** "Cancel" button on a GUI progress dialog box.
29923005
**
29933006
** The progress handler callback must not do anything that will modify
29943007
** the database connection that invoked the progress handler.
2995
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3008
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
29963009
** database connections for the meaning of "modify" in this paragraph.
29973010
**
29983011
*/
29993012
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
30003013
@@ -3344,11 +3357,11 @@
33443357
** prepared statement before it can be run.
33453358
**
33463359
** The life-cycle of a prepared statement object usually goes like this:
33473360
**
33483361
** <ol>
3349
-** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3362
+** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
33503363
** <li> Bind values to [parameters] using the sqlite3_bind_*()
33513364
** interfaces.
33523365
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
33533366
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
33543367
** to step 2. Do this zero or more times.
@@ -3426,11 +3439,11 @@
34263439
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
34273440
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
34283441
**
34293442
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
34303443
** <dd>The maximum number of instructions in a virtual machine program
3431
-** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3444
+** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
34323445
** the equivalent tries to allocate space for more than this many opcodes
34333446
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
34343447
**
34353448
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
34363449
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3466,28 +3479,61 @@
34663479
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
34673480
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
34683481
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
34693482
#define SQLITE_LIMIT_WORKER_THREADS 11
34703483
3484
+/*
3485
+** CAPI3REF: Prepare Flags
3486
+**
3487
+** These constants define various flags that can be passed into
3488
+** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
3489
+** [sqlite3_prepare16_v3()] interfaces.
3490
+**
3491
+** New flags may be added in future releases of SQLite.
3492
+**
3493
+** <dl>
3494
+** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495
+** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496
+** and [sqlite3_prepare16_v3()]
3497
+** to optimize the resulting prepared statement to be retained for a
3498
+** relatively long amount of time.)^ ^Without this flag,
3499
+** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500
+** the prepared statement will be used just once or at most a few times
3501
+** and then destroyed using [sqlite3_finalize()] relatively soon.
3502
+** </dl>
3503
+*/
3504
+#define SQLITE_PREPARE_PERSISTENT 0x01
34713505
34723506
/*
34733507
** CAPI3REF: Compiling An SQL Statement
34743508
** KEYWORDS: {SQL statement compiler}
34753509
** METHOD: sqlite3
34763510
** CONSTRUCTOR: sqlite3_stmt
34773511
**
3478
-** To execute an SQL query, it must first be compiled into a byte-code
3479
-** program using one of these routines.
3512
+** To execute an SQL statement, it must first be compiled into a byte-code
3513
+** program using one of these routines. Or, in other words, these routines
3514
+** are constructors for the [prepared statement] object.
3515
+**
3516
+** The preferred routine to use is [sqlite3_prepare_v2()]. The
3517
+** [sqlite3_prepare()] interface is legacy and should be avoided.
3518
+** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
3519
+** for special purposes.
3520
+**
3521
+** The use of the UTF-8 interfaces is preferred, as SQLite currently
3522
+** does all parsing using UTF-8. The UTF-16 interfaces are provided
3523
+** as a convenience. The UTF-16 interfaces work by converting the
3524
+** input text into UTF-8, then invoking the corresponding UTF-8 interface.
34803525
**
34813526
** The first argument, "db", is a [database connection] obtained from a
34823527
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
34833528
** [sqlite3_open16()]. The database connection must not have been closed.
34843529
**
34853530
** The second argument, "zSql", is the statement to be compiled, encoded
3486
-** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3487
-** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3488
-** use UTF-16.
3531
+** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
3532
+** and sqlite3_prepare_v3()
3533
+** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
3534
+** and sqlite3_prepare16_v3() use UTF-16.
34893535
**
34903536
** ^If the nByte argument is negative, then zSql is read up to the
34913537
** first zero terminator. ^If nByte is positive, then it is the
34923538
** number of bytes read from zSql. ^If nByte is zero, then no prepared
34933539
** statement is generated.
@@ -3510,14 +3556,15 @@
35103556
** ppStmt may not be NULL.
35113557
**
35123558
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
35133559
** otherwise an [error code] is returned.
35143560
**
3515
-** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3516
-** recommended for all new programs. The two older interfaces are retained
3517
-** for backwards compatibility, but their use is discouraged.
3518
-** ^In the "v2" interfaces, the prepared statement
3561
+** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
3562
+** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
3563
+** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
3564
+** are retained for backwards compatibility, but their use is discouraged.
3565
+** ^In the "vX" interfaces, the prepared statement
35193566
** that is returned (the [sqlite3_stmt] object) contains a copy of the
35203567
** original SQL text. This causes the [sqlite3_step()] interface to
35213568
** behave differently in three ways:
35223569
**
35233570
** <ol>
@@ -3546,10 +3593,16 @@
35463593
** ^The specific value of WHERE-clause [parameter] might influence the
35473594
** choice of query plan if the parameter is the left-hand side of a [LIKE]
35483595
** or [GLOB] operator or if the parameter is compared to an indexed column
35493596
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
35503597
** </li>
3598
+**
3599
+** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3600
+** the extra prepFlags parameter, which is a bit array consisting of zero or
3601
+** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
3602
+** sqlite3_prepare_v2() interface works exactly the same as
3603
+** sqlite3_prepare_v3() with a zero prepFlags parameter.
35513604
** </ol>
35523605
*/
35533606
SQLITE_API int sqlite3_prepare(
35543607
sqlite3 *db, /* Database handle */
35553608
const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3559,10 +3612,18 @@
35593612
);
35603613
SQLITE_API int sqlite3_prepare_v2(
35613614
sqlite3 *db, /* Database handle */
35623615
const char *zSql, /* SQL statement, UTF-8 encoded */
35633616
int nByte, /* Maximum length of zSql in bytes. */
3617
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3618
+ const char **pzTail /* OUT: Pointer to unused portion of zSql */
3619
+);
3620
+SQLITE_API int sqlite3_prepare_v3(
3621
+ sqlite3 *db, /* Database handle */
3622
+ const char *zSql, /* SQL statement, UTF-8 encoded */
3623
+ int nByte, /* Maximum length of zSql in bytes. */
3624
+ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
35643625
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
35653626
const char **pzTail /* OUT: Pointer to unused portion of zSql */
35663627
);
35673628
SQLITE_API int sqlite3_prepare16(
35683629
sqlite3 *db, /* Database handle */
@@ -3576,18 +3637,27 @@
35763637
const void *zSql, /* SQL statement, UTF-16 encoded */
35773638
int nByte, /* Maximum length of zSql in bytes. */
35783639
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
35793640
const void **pzTail /* OUT: Pointer to unused portion of zSql */
35803641
);
3642
+SQLITE_API int sqlite3_prepare16_v3(
3643
+ sqlite3 *db, /* Database handle */
3644
+ const void *zSql, /* SQL statement, UTF-16 encoded */
3645
+ int nByte, /* Maximum length of zSql in bytes. */
3646
+ unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3647
+ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3648
+ const void **pzTail /* OUT: Pointer to unused portion of zSql */
3649
+);
35813650
35823651
/*
35833652
** CAPI3REF: Retrieving Statement SQL
35843653
** METHOD: sqlite3_stmt
35853654
**
35863655
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
35873656
** SQL text used to create [prepared statement] P if P was
3588
-** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3657
+** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3658
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
35893659
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
35903660
** string containing the SQL text of prepared statement P with
35913661
** [bound parameters] expanded.
35923662
**
35933663
** ^(For example, if a prepared statement is created using the SQL
@@ -3729,11 +3799,11 @@
37293799
** CAPI3REF: Binding Values To Prepared Statements
37303800
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
37313801
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
37323802
** METHOD: sqlite3_stmt
37333803
**
3734
-** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3804
+** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
37353805
** literals may be replaced by a [parameter] that matches one of following
37363806
** templates:
37373807
**
37383808
** <ul>
37393809
** <li> ?
@@ -3748,11 +3818,11 @@
37483818
** parameters (also called "host parameter names" or "SQL parameters")
37493819
** can be set using the sqlite3_bind_*() routines defined here.
37503820
**
37513821
** ^The first argument to the sqlite3_bind_*() routines is always
37523822
** a pointer to the [sqlite3_stmt] object returned from
3753
-** [sqlite3_prepare_v2()] or its variants.
3823
+** [sqlite3_prepare_v3()] or its variants.
37543824
**
37553825
** ^The second argument is the index of the SQL parameter to be set.
37563826
** ^The leftmost SQL parameter has an index of 1. ^When the same named
37573827
** SQL parameter is used more than once, second and subsequent
37583828
** occurrences have the same index as the first occurrence.
@@ -3885,12 +3955,12 @@
38853955
** ^The first host parameter has an index of 1, not 0.
38863956
**
38873957
** ^If the value N is out of range or if the N-th parameter is
38883958
** nameless, then NULL is returned. ^The returned string is
38893959
** always in UTF-8 encoding even if the named parameter was
3890
-** originally specified as UTF-16 in [sqlite3_prepare16()] or
3891
-** [sqlite3_prepare16_v2()].
3960
+** originally specified as UTF-16 in [sqlite3_prepare16()],
3961
+** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
38923962
**
38933963
** See also: [sqlite3_bind_blob|sqlite3_bind()],
38943964
** [sqlite3_bind_parameter_count()], and
38953965
** [sqlite3_bind_parameter_index()].
38963966
*/
@@ -3903,11 +3973,12 @@
39033973
** ^Return the index of an SQL parameter given its name. ^The
39043974
** index value returned is suitable for use as the second
39053975
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
39063976
** is returned if no matching parameter is found. ^The parameter
39073977
** name must be given in UTF-8 even if the original statement
3908
-** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
3978
+** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
3979
+** [sqlite3_prepare16_v3()].
39093980
**
39103981
** See also: [sqlite3_bind_blob|sqlite3_bind()],
39113982
** [sqlite3_bind_parameter_count()], and
39123983
** [sqlite3_bind_parameter_name()].
39133984
*/
@@ -4057,20 +4128,22 @@
40574128
40584129
/*
40594130
** CAPI3REF: Evaluate An SQL Statement
40604131
** METHOD: sqlite3_stmt
40614132
**
4062
-** After a [prepared statement] has been prepared using either
4063
-** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
4133
+** After a [prepared statement] has been prepared using any of
4134
+** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
4135
+** or [sqlite3_prepare16_v3()] or one of the legacy
40644136
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
40654137
** must be called one or more times to evaluate the statement.
40664138
**
40674139
** The details of the behavior of the sqlite3_step() interface depend
4068
-** on whether the statement was prepared using the newer "v2" interface
4069
-** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4070
-** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4071
-** new "v2" interface is recommended for new applications but the legacy
4140
+** on whether the statement was prepared using the newer "vX" interfaces
4141
+** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
4142
+** [sqlite3_prepare16_v2()] or the older legacy
4143
+** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4144
+** new "vX" interface is recommended for new applications but the legacy
40724145
** interface will continue to be supported.
40734146
**
40744147
** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
40754148
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
40764149
** ^With the "v2" interface, any of the other [result codes] or
@@ -4127,14 +4200,15 @@
41274200
** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
41284201
** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
41294202
** specific [error codes] that better describes the error.
41304203
** We admit that this is a goofy design. The problem has been fixed
41314204
** with the "v2" interface. If you prepare all of your SQL statements
4132
-** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
4205
+** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
4206
+** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
41334207
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
41344208
** then the more specific [error codes] are returned directly
4135
-** by sqlite3_step(). The use of the "v2" interface is recommended.
4209
+** by sqlite3_step(). The use of the "vX" interfaces is recommended.
41364210
*/
41374211
SQLITE_API int sqlite3_step(sqlite3_stmt*);
41384212
41394213
/*
41404214
** CAPI3REF: Number of columns in a result set
@@ -4195,11 +4269,11 @@
41954269
** METHOD: sqlite3_stmt
41964270
**
41974271
** ^These routines return information about a single column of the current
41984272
** result row of a query. ^In every case the first argument is a pointer
41994273
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4200
-** that was returned from [sqlite3_prepare_v2()] or one of its variants)
4274
+** that was returned from [sqlite3_prepare_v3()] or one of its variants)
42014275
** and the second argument is the index of the column for which information
42024276
** should be returned. ^The leftmost column of the result set has the index 0.
42034277
** ^The number of columns in the result can be determined using
42044278
** [sqlite3_column_count()].
42054279
**
@@ -5319,11 +5393,11 @@
53195393
**
53205394
** ^The sqlite3_db_handle interface returns the [database connection] handle
53215395
** to which a [prepared statement] belongs. ^The [database connection]
53225396
** returned by sqlite3_db_handle is the same [database connection]
53235397
** that was the first argument
5324
-** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5398
+** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
53255399
** create the statement in the first place.
53265400
*/
53275401
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
53285402
53295403
/*
@@ -5395,11 +5469,11 @@
53955469
** the database connection that invoked the callback. Any actions
53965470
** to modify the database connection must be deferred until after the
53975471
** completion of the [sqlite3_step()] call that triggered the commit
53985472
** or rollback hook in the first place.
53995473
** Note that running any other SQL statements, including SELECT statements,
5400
-** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
5474
+** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
54015475
** the database connections for the meaning of "modify" in this paragraph.
54025476
**
54035477
** ^Registering a NULL function disables the callback.
54045478
**
54055479
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5455,11 +5529,11 @@
54555529
**
54565530
** The update hook implementation must not do anything that will modify
54575531
** the database connection that invoked the update hook. Any actions
54585532
** to modify the database connection must be deferred until after the
54595533
** completion of the [sqlite3_step()] call that triggered the update hook.
5460
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
5534
+** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
54615535
** database connections for the meaning of "modify" in this paragraph.
54625536
**
54635537
** ^The sqlite3_update_hook(D,C,P) function
54645538
** returns the P argument from the previous call
54655539
** on the same [database connection] D, or NULL for
@@ -7133,10 +7207,22 @@
71337207
** by the prepared statement if that number is less than or equal
71347208
** to 2147483647. The number of virtual machine operations can be
71357209
** used as a proxy for the total work done by the prepared statement.
71367210
** If the number of virtual machine operations exceeds 2147483647
71377211
** then the value returned by this statement status code is undefined.
7212
+**
7213
+** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7214
+** <dd>^This is the number of times that the prepare statement has been
7215
+** automatically regenerated due to schema changes or change to
7216
+** [bound parameters] that might affect the query plan.
7217
+**
7218
+** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7219
+** <dd>^This is the number of times that the prepared statement has
7220
+** been run. A single "run" for the purposes of this counter is one
7221
+** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
7222
+** The counter is incremented on the first [sqlite3_step()] call of each
7223
+** cycle.
71387224
**
71397225
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
71407226
** <dd>^This is the approximate number of bytes of heap memory
71417227
** used to store the prepared statement. ^This value is not actually
71427228
** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -7146,11 +7232,13 @@
71467232
*/
71477233
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
71487234
#define SQLITE_STMTSTATUS_SORT 2
71497235
#define SQLITE_STMTSTATUS_AUTOINDEX 3
71507236
#define SQLITE_STMTSTATUS_VM_STEP 4
7151
-#define SQLITE_STMTSTATUS_MEMUSED 5
7237
+#define SQLITE_STMTSTATUS_REPREPARE 5
7238
+#define SQLITE_STMTSTATUS_RUN 6
7239
+#define SQLITE_STMTSTATUS_MEMUSED 99
71527240
71537241
/*
71547242
** CAPI3REF: Custom Page Cache Object
71557243
**
71567244
** The sqlite3_pcache type is opaque. It is implemented by
71577245
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
1 /*
2 ** 2001 September 15
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-06-24 13:31:40 0583b84ab444db3ae3c93db619b67bf84b0305ab989200e77214e02ff2dc923a"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,19 +2005,31 @@
2005 ** default) to enable them. The second parameter is a pointer to an integer
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
 
 
 
 
 
 
 
 
 
 
 
2010 ** </dl>
2011 */
2012 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2013 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2014 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2015 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2016 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2017 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2018 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
 
2019
2020
2021 /*
2022 ** CAPI3REF: Enable Or Disable Extended Result Codes
2023 ** METHOD: sqlite3
@@ -2677,25 +2689,26 @@
2677 **
2678 ** ^This routine registers an authorizer callback with a particular
2679 ** [database connection], supplied in the first argument.
2680 ** ^The authorizer callback is invoked as SQL statements are being compiled
2681 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2682 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
 
2683 ** points during the compilation process, as logic is being created
2684 ** to perform various actions, the authorizer callback is invoked to
2685 ** see if those actions are allowed. ^The authorizer callback should
2686 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2687 ** specific action but allow the SQL statement to continue to be
2688 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2689 ** rejected with an error. ^If the authorizer callback returns
2690 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2691 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2692 ** the authorizer will fail with an error message.
2693 **
2694 ** When the callback returns [SQLITE_OK], that means the operation
2695 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2696 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2697 ** authorizer will fail with an error message explaining that
2698 ** access is denied.
2699 **
2700 ** ^The first parameter to the authorizer callback is a copy of the third
2701 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2742,23 +2755,23 @@
2742 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2743 ** The authorizer is disabled by default.
2744 **
2745 ** The authorizer callback must not do anything that will modify
2746 ** the database connection that invoked the authorizer callback.
2747 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2748 ** database connections for the meaning of "modify" in this paragraph.
2749 **
2750 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2751 ** statement might be re-prepared during [sqlite3_step()] due to a
2752 ** schema change. Hence, the application should ensure that the
2753 ** correct authorizer callback remains in place during the [sqlite3_step()].
2754 **
2755 ** ^Note that the authorizer callback is invoked only during
2756 ** [sqlite3_prepare()] or its variants. Authorization is not
2757 ** performed during statement evaluation in [sqlite3_step()], unless
2758 ** as stated in the previous paragraph, sqlite3_step() invokes
2759 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2760 */
2761 SQLITE_API int sqlite3_set_authorizer(
2762 sqlite3*,
2763 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2764 void *pUserData
@@ -2990,11 +3003,11 @@
2990 ** interrupted. This feature can be used to implement a
2991 ** "Cancel" button on a GUI progress dialog box.
2992 **
2993 ** The progress handler callback must not do anything that will modify
2994 ** the database connection that invoked the progress handler.
2995 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2996 ** database connections for the meaning of "modify" in this paragraph.
2997 **
2998 */
2999 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3000
@@ -3344,11 +3357,11 @@
3344 ** prepared statement before it can be run.
3345 **
3346 ** The life-cycle of a prepared statement object usually goes like this:
3347 **
3348 ** <ol>
3349 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3350 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3351 ** interfaces.
3352 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3353 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3354 ** to step 2. Do this zero or more times.
@@ -3426,11 +3439,11 @@
3426 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3427 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3428 **
3429 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3430 ** <dd>The maximum number of instructions in a virtual machine program
3431 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3432 ** the equivalent tries to allocate space for more than this many opcodes
3433 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3434 **
3435 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3436 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3466,28 +3479,61 @@
3466 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3467 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3468 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3469 #define SQLITE_LIMIT_WORKER_THREADS 11
3470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3471
3472 /*
3473 ** CAPI3REF: Compiling An SQL Statement
3474 ** KEYWORDS: {SQL statement compiler}
3475 ** METHOD: sqlite3
3476 ** CONSTRUCTOR: sqlite3_stmt
3477 **
3478 ** To execute an SQL query, it must first be compiled into a byte-code
3479 ** program using one of these routines.
 
 
 
 
 
 
 
 
 
 
 
3480 **
3481 ** The first argument, "db", is a [database connection] obtained from a
3482 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3483 ** [sqlite3_open16()]. The database connection must not have been closed.
3484 **
3485 ** The second argument, "zSql", is the statement to be compiled, encoded
3486 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3487 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3488 ** use UTF-16.
 
3489 **
3490 ** ^If the nByte argument is negative, then zSql is read up to the
3491 ** first zero terminator. ^If nByte is positive, then it is the
3492 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3493 ** statement is generated.
@@ -3510,14 +3556,15 @@
3510 ** ppStmt may not be NULL.
3511 **
3512 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
3513 ** otherwise an [error code] is returned.
3514 **
3515 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3516 ** recommended for all new programs. The two older interfaces are retained
3517 ** for backwards compatibility, but their use is discouraged.
3518 ** ^In the "v2" interfaces, the prepared statement
 
3519 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
3520 ** original SQL text. This causes the [sqlite3_step()] interface to
3521 ** behave differently in three ways:
3522 **
3523 ** <ol>
@@ -3546,10 +3593,16 @@
3546 ** ^The specific value of WHERE-clause [parameter] might influence the
3547 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3548 ** or [GLOB] operator or if the parameter is compared to an indexed column
3549 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3550 ** </li>
 
 
 
 
 
 
3551 ** </ol>
3552 */
3553 SQLITE_API int sqlite3_prepare(
3554 sqlite3 *db, /* Database handle */
3555 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3559,10 +3612,18 @@
3559 );
3560 SQLITE_API int sqlite3_prepare_v2(
3561 sqlite3 *db, /* Database handle */
3562 const char *zSql, /* SQL statement, UTF-8 encoded */
3563 int nByte, /* Maximum length of zSql in bytes. */
 
 
 
 
 
 
 
 
3564 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3565 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3566 );
3567 SQLITE_API int sqlite3_prepare16(
3568 sqlite3 *db, /* Database handle */
@@ -3576,18 +3637,27 @@
3576 const void *zSql, /* SQL statement, UTF-16 encoded */
3577 int nByte, /* Maximum length of zSql in bytes. */
3578 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3579 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3580 );
 
 
 
 
 
 
 
 
3581
3582 /*
3583 ** CAPI3REF: Retrieving Statement SQL
3584 ** METHOD: sqlite3_stmt
3585 **
3586 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3587 ** SQL text used to create [prepared statement] P if P was
3588 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
3589 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3590 ** string containing the SQL text of prepared statement P with
3591 ** [bound parameters] expanded.
3592 **
3593 ** ^(For example, if a prepared statement is created using the SQL
@@ -3729,11 +3799,11 @@
3729 ** CAPI3REF: Binding Values To Prepared Statements
3730 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3731 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3732 ** METHOD: sqlite3_stmt
3733 **
3734 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3735 ** literals may be replaced by a [parameter] that matches one of following
3736 ** templates:
3737 **
3738 ** <ul>
3739 ** <li> ?
@@ -3748,11 +3818,11 @@
3748 ** parameters (also called "host parameter names" or "SQL parameters")
3749 ** can be set using the sqlite3_bind_*() routines defined here.
3750 **
3751 ** ^The first argument to the sqlite3_bind_*() routines is always
3752 ** a pointer to the [sqlite3_stmt] object returned from
3753 ** [sqlite3_prepare_v2()] or its variants.
3754 **
3755 ** ^The second argument is the index of the SQL parameter to be set.
3756 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3757 ** SQL parameter is used more than once, second and subsequent
3758 ** occurrences have the same index as the first occurrence.
@@ -3885,12 +3955,12 @@
3885 ** ^The first host parameter has an index of 1, not 0.
3886 **
3887 ** ^If the value N is out of range or if the N-th parameter is
3888 ** nameless, then NULL is returned. ^The returned string is
3889 ** always in UTF-8 encoding even if the named parameter was
3890 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
3891 ** [sqlite3_prepare16_v2()].
3892 **
3893 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3894 ** [sqlite3_bind_parameter_count()], and
3895 ** [sqlite3_bind_parameter_index()].
3896 */
@@ -3903,11 +3973,12 @@
3903 ** ^Return the index of an SQL parameter given its name. ^The
3904 ** index value returned is suitable for use as the second
3905 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3906 ** is returned if no matching parameter is found. ^The parameter
3907 ** name must be given in UTF-8 even if the original statement
3908 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 
3909 **
3910 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3911 ** [sqlite3_bind_parameter_count()], and
3912 ** [sqlite3_bind_parameter_name()].
3913 */
@@ -4057,20 +4128,22 @@
4057
4058 /*
4059 ** CAPI3REF: Evaluate An SQL Statement
4060 ** METHOD: sqlite3_stmt
4061 **
4062 ** After a [prepared statement] has been prepared using either
4063 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
 
4064 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
4065 ** must be called one or more times to evaluate the statement.
4066 **
4067 ** The details of the behavior of the sqlite3_step() interface depend
4068 ** on whether the statement was prepared using the newer "v2" interface
4069 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4070 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4071 ** new "v2" interface is recommended for new applications but the legacy
 
4072 ** interface will continue to be supported.
4073 **
4074 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
4075 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
4076 ** ^With the "v2" interface, any of the other [result codes] or
@@ -4127,14 +4200,15 @@
4127 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
4128 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
4129 ** specific [error codes] that better describes the error.
4130 ** We admit that this is a goofy design. The problem has been fixed
4131 ** with the "v2" interface. If you prepare all of your SQL statements
4132 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
 
4133 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4134 ** then the more specific [error codes] are returned directly
4135 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4136 */
4137 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4138
4139 /*
4140 ** CAPI3REF: Number of columns in a result set
@@ -4195,11 +4269,11 @@
4195 ** METHOD: sqlite3_stmt
4196 **
4197 ** ^These routines return information about a single column of the current
4198 ** result row of a query. ^In every case the first argument is a pointer
4199 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4200 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
4201 ** and the second argument is the index of the column for which information
4202 ** should be returned. ^The leftmost column of the result set has the index 0.
4203 ** ^The number of columns in the result can be determined using
4204 ** [sqlite3_column_count()].
4205 **
@@ -5319,11 +5393,11 @@
5319 **
5320 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5321 ** to which a [prepared statement] belongs. ^The [database connection]
5322 ** returned by sqlite3_db_handle is the same [database connection]
5323 ** that was the first argument
5324 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5325 ** create the statement in the first place.
5326 */
5327 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5328
5329 /*
@@ -5395,11 +5469,11 @@
5395 ** the database connection that invoked the callback. Any actions
5396 ** to modify the database connection must be deferred until after the
5397 ** completion of the [sqlite3_step()] call that triggered the commit
5398 ** or rollback hook in the first place.
5399 ** Note that running any other SQL statements, including SELECT statements,
5400 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
5401 ** the database connections for the meaning of "modify" in this paragraph.
5402 **
5403 ** ^Registering a NULL function disables the callback.
5404 **
5405 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5455,11 +5529,11 @@
5455 **
5456 ** The update hook implementation must not do anything that will modify
5457 ** the database connection that invoked the update hook. Any actions
5458 ** to modify the database connection must be deferred until after the
5459 ** completion of the [sqlite3_step()] call that triggered the update hook.
5460 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
5461 ** database connections for the meaning of "modify" in this paragraph.
5462 **
5463 ** ^The sqlite3_update_hook(D,C,P) function
5464 ** returns the P argument from the previous call
5465 ** on the same [database connection] D, or NULL for
@@ -7133,10 +7207,22 @@
7133 ** by the prepared statement if that number is less than or equal
7134 ** to 2147483647. The number of virtual machine operations can be
7135 ** used as a proxy for the total work done by the prepared statement.
7136 ** If the number of virtual machine operations exceeds 2147483647
7137 ** then the value returned by this statement status code is undefined.
 
 
 
 
 
 
 
 
 
 
 
 
7138 **
7139 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
7140 ** <dd>^This is the approximate number of bytes of heap memory
7141 ** used to store the prepared statement. ^This value is not actually
7142 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -7146,11 +7232,13 @@
7146 */
7147 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7148 #define SQLITE_STMTSTATUS_SORT 2
7149 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7150 #define SQLITE_STMTSTATUS_VM_STEP 4
7151 #define SQLITE_STMTSTATUS_MEMUSED 5
 
 
7152
7153 /*
7154 ** CAPI3REF: Custom Page Cache Object
7155 **
7156 ** The sqlite3_pcache type is opaque. It is implemented by
7157
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
1 /*
2 ** 2001-09-15
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,19 +2005,31 @@
2005 ** default) to enable them. The second parameter is a pointer to an integer
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
2010 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013 ** a single SQL query statement will always use the same algorithm regardless
2014 ** of values of [bound parameters]. The QPSG disables some query optimizations
2015 ** that look at the values of bound parameters, which can make some queries
2016 ** slower. But the QPSG has the advantage of more predictable behavior. With
2017 ** the QPSG active, SQLite will always use the same query plan in the field as
2018 ** was used during testing in the lab.
2019 ** </dd>
2020 **
2021 ** </dl>
2022 */
2023 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2024 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2025 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2026 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2027 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2028 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2029 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2030 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2031
2032
2033 /*
2034 ** CAPI3REF: Enable Or Disable Extended Result Codes
2035 ** METHOD: sqlite3
@@ -2677,25 +2689,26 @@
2689 **
2690 ** ^This routine registers an authorizer callback with a particular
2691 ** [database connection], supplied in the first argument.
2692 ** ^The authorizer callback is invoked as SQL statements are being compiled
2693 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2694 ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
2695 ** and [sqlite3_prepare16_v3()]. ^At various
2696 ** points during the compilation process, as logic is being created
2697 ** to perform various actions, the authorizer callback is invoked to
2698 ** see if those actions are allowed. ^The authorizer callback should
2699 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2700 ** specific action but allow the SQL statement to continue to be
2701 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2702 ** rejected with an error. ^If the authorizer callback returns
2703 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2705 ** the authorizer will fail with an error message.
2706 **
2707 ** When the callback returns [SQLITE_OK], that means the operation
2708 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
2710 ** authorizer will fail with an error message explaining that
2711 ** access is denied.
2712 **
2713 ** ^The first parameter to the authorizer callback is a copy of the third
2714 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2742,23 +2755,23 @@
2755 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2756 ** The authorizer is disabled by default.
2757 **
2758 ** The authorizer callback must not do anything that will modify
2759 ** the database connection that invoked the authorizer callback.
2760 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2761 ** database connections for the meaning of "modify" in this paragraph.
2762 **
2763 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
2764 ** statement might be re-prepared during [sqlite3_step()] due to a
2765 ** schema change. Hence, the application should ensure that the
2766 ** correct authorizer callback remains in place during the [sqlite3_step()].
2767 **
2768 ** ^Note that the authorizer callback is invoked only during
2769 ** [sqlite3_prepare()] or its variants. Authorization is not
2770 ** performed during statement evaluation in [sqlite3_step()], unless
2771 ** as stated in the previous paragraph, sqlite3_step() invokes
2772 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
2773 */
2774 SQLITE_API int sqlite3_set_authorizer(
2775 sqlite3*,
2776 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2777 void *pUserData
@@ -2990,11 +3003,11 @@
3003 ** interrupted. This feature can be used to implement a
3004 ** "Cancel" button on a GUI progress dialog box.
3005 **
3006 ** The progress handler callback must not do anything that will modify
3007 ** the database connection that invoked the progress handler.
3008 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3009 ** database connections for the meaning of "modify" in this paragraph.
3010 **
3011 */
3012 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3013
@@ -3344,11 +3357,11 @@
3357 ** prepared statement before it can be run.
3358 **
3359 ** The life-cycle of a prepared statement object usually goes like this:
3360 **
3361 ** <ol>
3362 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3363 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3364 ** interfaces.
3365 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3366 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3367 ** to step 2. Do this zero or more times.
@@ -3426,11 +3439,11 @@
3439 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3440 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3441 **
3442 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3443 ** <dd>The maximum number of instructions in a virtual machine program
3444 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3445 ** the equivalent tries to allocate space for more than this many opcodes
3446 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3447 **
3448 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3449 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3466,28 +3479,61 @@
3479 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3480 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3481 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3482 #define SQLITE_LIMIT_WORKER_THREADS 11
3483
3484 /*
3485 ** CAPI3REF: Prepare Flags
3486 **
3487 ** These constants define various flags that can be passed into
3488 ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
3489 ** [sqlite3_prepare16_v3()] interfaces.
3490 **
3491 ** New flags may be added in future releases of SQLite.
3492 **
3493 ** <dl>
3494 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496 ** and [sqlite3_prepare16_v3()]
3497 ** to optimize the resulting prepared statement to be retained for a
3498 ** relatively long amount of time.)^ ^Without this flag,
3499 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500 ** the prepared statement will be used just once or at most a few times
3501 ** and then destroyed using [sqlite3_finalize()] relatively soon.
3502 ** </dl>
3503 */
3504 #define SQLITE_PREPARE_PERSISTENT 0x01
3505
3506 /*
3507 ** CAPI3REF: Compiling An SQL Statement
3508 ** KEYWORDS: {SQL statement compiler}
3509 ** METHOD: sqlite3
3510 ** CONSTRUCTOR: sqlite3_stmt
3511 **
3512 ** To execute an SQL statement, it must first be compiled into a byte-code
3513 ** program using one of these routines. Or, in other words, these routines
3514 ** are constructors for the [prepared statement] object.
3515 **
3516 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
3517 ** [sqlite3_prepare()] interface is legacy and should be avoided.
3518 ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
3519 ** for special purposes.
3520 **
3521 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
3522 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
3523 ** as a convenience. The UTF-16 interfaces work by converting the
3524 ** input text into UTF-8, then invoking the corresponding UTF-8 interface.
3525 **
3526 ** The first argument, "db", is a [database connection] obtained from a
3527 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3528 ** [sqlite3_open16()]. The database connection must not have been closed.
3529 **
3530 ** The second argument, "zSql", is the statement to be compiled, encoded
3531 ** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
3532 ** and sqlite3_prepare_v3()
3533 ** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
3534 ** and sqlite3_prepare16_v3() use UTF-16.
3535 **
3536 ** ^If the nByte argument is negative, then zSql is read up to the
3537 ** first zero terminator. ^If nByte is positive, then it is the
3538 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3539 ** statement is generated.
@@ -3510,14 +3556,15 @@
3556 ** ppStmt may not be NULL.
3557 **
3558 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
3559 ** otherwise an [error code] is returned.
3560 **
3561 ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
3562 ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
3563 ** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
3564 ** are retained for backwards compatibility, but their use is discouraged.
3565 ** ^In the "vX" interfaces, the prepared statement
3566 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
3567 ** original SQL text. This causes the [sqlite3_step()] interface to
3568 ** behave differently in three ways:
3569 **
3570 ** <ol>
@@ -3546,10 +3593,16 @@
3593 ** ^The specific value of WHERE-clause [parameter] might influence the
3594 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3595 ** or [GLOB] operator or if the parameter is compared to an indexed column
3596 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3597 ** </li>
3598 **
3599 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3600 ** the extra prepFlags parameter, which is a bit array consisting of zero or
3601 ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
3602 ** sqlite3_prepare_v2() interface works exactly the same as
3603 ** sqlite3_prepare_v3() with a zero prepFlags parameter.
3604 ** </ol>
3605 */
3606 SQLITE_API int sqlite3_prepare(
3607 sqlite3 *db, /* Database handle */
3608 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3559,10 +3612,18 @@
3612 );
3613 SQLITE_API int sqlite3_prepare_v2(
3614 sqlite3 *db, /* Database handle */
3615 const char *zSql, /* SQL statement, UTF-8 encoded */
3616 int nByte, /* Maximum length of zSql in bytes. */
3617 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3618 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3619 );
3620 SQLITE_API int sqlite3_prepare_v3(
3621 sqlite3 *db, /* Database handle */
3622 const char *zSql, /* SQL statement, UTF-8 encoded */
3623 int nByte, /* Maximum length of zSql in bytes. */
3624 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
3625 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3626 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3627 );
3628 SQLITE_API int sqlite3_prepare16(
3629 sqlite3 *db, /* Database handle */
@@ -3576,18 +3637,27 @@
3637 const void *zSql, /* SQL statement, UTF-16 encoded */
3638 int nByte, /* Maximum length of zSql in bytes. */
3639 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3640 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3641 );
3642 SQLITE_API int sqlite3_prepare16_v3(
3643 sqlite3 *db, /* Database handle */
3644 const void *zSql, /* SQL statement, UTF-16 encoded */
3645 int nByte, /* Maximum length of zSql in bytes. */
3646 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3647 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3648 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3649 );
3650
3651 /*
3652 ** CAPI3REF: Retrieving Statement SQL
3653 ** METHOD: sqlite3_stmt
3654 **
3655 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3656 ** SQL text used to create [prepared statement] P if P was
3657 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3658 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3659 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3660 ** string containing the SQL text of prepared statement P with
3661 ** [bound parameters] expanded.
3662 **
3663 ** ^(For example, if a prepared statement is created using the SQL
@@ -3729,11 +3799,11 @@
3799 ** CAPI3REF: Binding Values To Prepared Statements
3800 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3801 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3802 ** METHOD: sqlite3_stmt
3803 **
3804 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
3805 ** literals may be replaced by a [parameter] that matches one of following
3806 ** templates:
3807 **
3808 ** <ul>
3809 ** <li> ?
@@ -3748,11 +3818,11 @@
3818 ** parameters (also called "host parameter names" or "SQL parameters")
3819 ** can be set using the sqlite3_bind_*() routines defined here.
3820 **
3821 ** ^The first argument to the sqlite3_bind_*() routines is always
3822 ** a pointer to the [sqlite3_stmt] object returned from
3823 ** [sqlite3_prepare_v3()] or its variants.
3824 **
3825 ** ^The second argument is the index of the SQL parameter to be set.
3826 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3827 ** SQL parameter is used more than once, second and subsequent
3828 ** occurrences have the same index as the first occurrence.
@@ -3885,12 +3955,12 @@
3955 ** ^The first host parameter has an index of 1, not 0.
3956 **
3957 ** ^If the value N is out of range or if the N-th parameter is
3958 ** nameless, then NULL is returned. ^The returned string is
3959 ** always in UTF-8 encoding even if the named parameter was
3960 ** originally specified as UTF-16 in [sqlite3_prepare16()],
3961 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3962 **
3963 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3964 ** [sqlite3_bind_parameter_count()], and
3965 ** [sqlite3_bind_parameter_index()].
3966 */
@@ -3903,11 +3973,12 @@
3973 ** ^Return the index of an SQL parameter given its name. ^The
3974 ** index value returned is suitable for use as the second
3975 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3976 ** is returned if no matching parameter is found. ^The parameter
3977 ** name must be given in UTF-8 even if the original statement
3978 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
3979 ** [sqlite3_prepare16_v3()].
3980 **
3981 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3982 ** [sqlite3_bind_parameter_count()], and
3983 ** [sqlite3_bind_parameter_name()].
3984 */
@@ -4057,20 +4128,22 @@
4128
4129 /*
4130 ** CAPI3REF: Evaluate An SQL Statement
4131 ** METHOD: sqlite3_stmt
4132 **
4133 ** After a [prepared statement] has been prepared using any of
4134 ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
4135 ** or [sqlite3_prepare16_v3()] or one of the legacy
4136 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
4137 ** must be called one or more times to evaluate the statement.
4138 **
4139 ** The details of the behavior of the sqlite3_step() interface depend
4140 ** on whether the statement was prepared using the newer "vX" interfaces
4141 ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
4142 ** [sqlite3_prepare16_v2()] or the older legacy
4143 ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4144 ** new "vX" interface is recommended for new applications but the legacy
4145 ** interface will continue to be supported.
4146 **
4147 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
4148 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
4149 ** ^With the "v2" interface, any of the other [result codes] or
@@ -4127,14 +4200,15 @@
4200 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
4201 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
4202 ** specific [error codes] that better describes the error.
4203 ** We admit that this is a goofy design. The problem has been fixed
4204 ** with the "v2" interface. If you prepare all of your SQL statements
4205 ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
4206 ** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
4207 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4208 ** then the more specific [error codes] are returned directly
4209 ** by sqlite3_step(). The use of the "vX" interfaces is recommended.
4210 */
4211 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4212
4213 /*
4214 ** CAPI3REF: Number of columns in a result set
@@ -4195,11 +4269,11 @@
4269 ** METHOD: sqlite3_stmt
4270 **
4271 ** ^These routines return information about a single column of the current
4272 ** result row of a query. ^In every case the first argument is a pointer
4273 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4274 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4275 ** and the second argument is the index of the column for which information
4276 ** should be returned. ^The leftmost column of the result set has the index 0.
4277 ** ^The number of columns in the result can be determined using
4278 ** [sqlite3_column_count()].
4279 **
@@ -5319,11 +5393,11 @@
5393 **
5394 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5395 ** to which a [prepared statement] belongs. ^The [database connection]
5396 ** returned by sqlite3_db_handle is the same [database connection]
5397 ** that was the first argument
5398 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5399 ** create the statement in the first place.
5400 */
5401 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5402
5403 /*
@@ -5395,11 +5469,11 @@
5469 ** the database connection that invoked the callback. Any actions
5470 ** to modify the database connection must be deferred until after the
5471 ** completion of the [sqlite3_step()] call that triggered the commit
5472 ** or rollback hook in the first place.
5473 ** Note that running any other SQL statements, including SELECT statements,
5474 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5475 ** the database connections for the meaning of "modify" in this paragraph.
5476 **
5477 ** ^Registering a NULL function disables the callback.
5478 **
5479 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5455,11 +5529,11 @@
5529 **
5530 ** The update hook implementation must not do anything that will modify
5531 ** the database connection that invoked the update hook. Any actions
5532 ** to modify the database connection must be deferred until after the
5533 ** completion of the [sqlite3_step()] call that triggered the update hook.
5534 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5535 ** database connections for the meaning of "modify" in this paragraph.
5536 **
5537 ** ^The sqlite3_update_hook(D,C,P) function
5538 ** returns the P argument from the previous call
5539 ** on the same [database connection] D, or NULL for
@@ -7133,10 +7207,22 @@
7207 ** by the prepared statement if that number is less than or equal
7208 ** to 2147483647. The number of virtual machine operations can be
7209 ** used as a proxy for the total work done by the prepared statement.
7210 ** If the number of virtual machine operations exceeds 2147483647
7211 ** then the value returned by this statement status code is undefined.
7212 **
7213 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7214 ** <dd>^This is the number of times that the prepare statement has been
7215 ** automatically regenerated due to schema changes or change to
7216 ** [bound parameters] that might affect the query plan.
7217 **
7218 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7219 ** <dd>^This is the number of times that the prepared statement has
7220 ** been run. A single "run" for the purposes of this counter is one
7221 ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
7222 ** The counter is incremented on the first [sqlite3_step()] call of each
7223 ** cycle.
7224 **
7225 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
7226 ** <dd>^This is the approximate number of bytes of heap memory
7227 ** used to store the prepared statement. ^This value is not actually
7228 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
@@ -7146,11 +7232,13 @@
7232 */
7233 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7234 #define SQLITE_STMTSTATUS_SORT 2
7235 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7236 #define SQLITE_STMTSTATUS_VM_STEP 4
7237 #define SQLITE_STMTSTATUS_REPREPARE 5
7238 #define SQLITE_STMTSTATUS_RUN 6
7239 #define SQLITE_STMTSTATUS_MEMUSED 99
7240
7241 /*
7242 ** CAPI3REF: Custom Page Cache Object
7243 **
7244 ** The sqlite3_pcache type is opaque. It is implemented by
7245

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button