Fossil SCM

Update the built-in SQLite to the 3.14 alpha. Use sqlite3_trace_v2() instead of sqlite3_trace(), which is not deprecated.

drh 2016-07-23 20:35 trunk
Commit b9573e55c2933b5bc328e49fe539916700d82f92
4 files changed +3 -2 +12 -5 +2922 -2119 +144 -12
+3 -2
--- src/db.c
+++ src/db.c
@@ -934,11 +934,11 @@
934934
db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
935935
);
936936
sqlite3_create_function(
937937
db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
938938
);
939
- if( g.fSqlTrace ) sqlite3_trace(db, db_sql_trace, 0);
939
+ if( g.fSqlTrace ) sqlite3_trace_v2(db, SQLITE_TRACE_STMT, db_sql_trace, 0);
940940
db_add_aux_functions(db);
941941
re_add_sql_func(db); /* The REGEXP operator */
942942
foci_register(db); /* The "files_of_checkin" virtual table */
943943
sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
944944
return db;
@@ -1808,11 +1808,12 @@
18081808
char c = i==argc-1 ? '\n' : ' ';
18091809
fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
18101810
}
18111811
}
18121812
}
1813
-LOCAL void db_sql_trace(void *notUsed, const char *zSql){
1813
+LOCAL int db_sql_trace(int m, void *notUsed, void *pNotUsed2, void *pX){
1814
+ const char *zSql = (const char*)pX;
18141815
int n = strlen(zSql);
18151816
fossil_trace("%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
18161817
}
18171818
18181819
/*
18191820
--- src/db.c
+++ src/db.c
@@ -934,11 +934,11 @@
934 db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
935 );
936 sqlite3_create_function(
937 db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
938 );
939 if( g.fSqlTrace ) sqlite3_trace(db, db_sql_trace, 0);
940 db_add_aux_functions(db);
941 re_add_sql_func(db); /* The REGEXP operator */
942 foci_register(db); /* The "files_of_checkin" virtual table */
943 sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
944 return db;
@@ -1808,11 +1808,12 @@
1808 char c = i==argc-1 ? '\n' : ' ';
1809 fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
1810 }
1811 }
1812 }
1813 LOCAL void db_sql_trace(void *notUsed, const char *zSql){
 
1814 int n = strlen(zSql);
1815 fossil_trace("%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
1816 }
1817
1818 /*
1819
--- src/db.c
+++ src/db.c
@@ -934,11 +934,11 @@
934 db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
935 );
936 sqlite3_create_function(
937 db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
938 );
939 if( g.fSqlTrace ) sqlite3_trace_v2(db, SQLITE_TRACE_STMT, db_sql_trace, 0);
940 db_add_aux_functions(db);
941 re_add_sql_func(db); /* The REGEXP operator */
942 foci_register(db); /* The "files_of_checkin" virtual table */
943 sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
944 return db;
@@ -1808,11 +1808,12 @@
1808 char c = i==argc-1 ? '\n' : ' ';
1809 fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
1810 }
1811 }
1812 }
1813 LOCAL int db_sql_trace(int m, void *notUsed, void *pNotUsed2, void *pX){
1814 const char *zSql = (const char*)pX;
1815 int n = strlen(zSql);
1816 fossil_trace("%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
1817 }
1818
1819 /*
1820
+12 -5
--- src/shell.c
+++ src/shell.c
@@ -2541,17 +2541,24 @@
25412541
}
25422542
25432543
/*
25442544
** A routine for handling output from sqlite3_trace().
25452545
*/
2546
-static void sql_trace_callback(void *pArg, const char *z){
2546
+static int sql_trace_callback(
2547
+ unsigned mType,
2548
+ void *pArg,
2549
+ void *pP,
2550
+ void *pX
2551
+){
25472552
FILE *f = (FILE*)pArg;
25482553
if( f ){
2554
+ const char *z = (const char*)pX;
25492555
int i = (int)strlen(z);
25502556
while( i>0 && z[i-1]==';' ){ i--; }
25512557
utf8_printf(f, "%.*s;\n", i, z);
25522558
}
2559
+ return 0;
25532560
}
25542561
25552562
/*
25562563
** A no-op routine that runs with the ".breakpoint" doc-command. This is
25572564
** a useful spot to set a debugger breakpoint.
@@ -2944,14 +2951,14 @@
29442951
}
29452952
29462953
/*
29472954
** Convert a 2-byte or 4-byte big-endian integer into a native integer
29482955
*/
2949
-unsigned int get2byteInt(unsigned char *a){
2956
+static unsigned int get2byteInt(unsigned char *a){
29502957
return (a[0]<<8) + a[1];
29512958
}
2952
-unsigned int get4byteInt(unsigned char *a){
2959
+static unsigned int get4byteInt(unsigned char *a){
29532960
return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];
29542961
}
29552962
29562963
/*
29572964
** Implementation of the ".info" command.
@@ -4653,13 +4660,13 @@
46534660
}
46544661
output_file_close(p->traceOut);
46554662
p->traceOut = output_file_open(azArg[1]);
46564663
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
46574664
if( p->traceOut==0 ){
4658
- sqlite3_trace(p->db, 0, 0);
4665
+ sqlite3_trace_v2(p->db, 0, 0, 0);
46594666
}else{
4660
- sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
4667
+ sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);
46614668
}
46624669
#endif
46634670
}else
46644671
46654672
#if SQLITE_USER_AUTHENTICATION
46664673
--- src/shell.c
+++ src/shell.c
@@ -2541,17 +2541,24 @@
2541 }
2542
2543 /*
2544 ** A routine for handling output from sqlite3_trace().
2545 */
2546 static void sql_trace_callback(void *pArg, const char *z){
 
 
 
 
 
2547 FILE *f = (FILE*)pArg;
2548 if( f ){
 
2549 int i = (int)strlen(z);
2550 while( i>0 && z[i-1]==';' ){ i--; }
2551 utf8_printf(f, "%.*s;\n", i, z);
2552 }
 
2553 }
2554
2555 /*
2556 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
2557 ** a useful spot to set a debugger breakpoint.
@@ -2944,14 +2951,14 @@
2944 }
2945
2946 /*
2947 ** Convert a 2-byte or 4-byte big-endian integer into a native integer
2948 */
2949 unsigned int get2byteInt(unsigned char *a){
2950 return (a[0]<<8) + a[1];
2951 }
2952 unsigned int get4byteInt(unsigned char *a){
2953 return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];
2954 }
2955
2956 /*
2957 ** Implementation of the ".info" command.
@@ -4653,13 +4660,13 @@
4653 }
4654 output_file_close(p->traceOut);
4655 p->traceOut = output_file_open(azArg[1]);
4656 #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
4657 if( p->traceOut==0 ){
4658 sqlite3_trace(p->db, 0, 0);
4659 }else{
4660 sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
4661 }
4662 #endif
4663 }else
4664
4665 #if SQLITE_USER_AUTHENTICATION
4666
--- src/shell.c
+++ src/shell.c
@@ -2541,17 +2541,24 @@
2541 }
2542
2543 /*
2544 ** A routine for handling output from sqlite3_trace().
2545 */
2546 static int sql_trace_callback(
2547 unsigned mType,
2548 void *pArg,
2549 void *pP,
2550 void *pX
2551 ){
2552 FILE *f = (FILE*)pArg;
2553 if( f ){
2554 const char *z = (const char*)pX;
2555 int i = (int)strlen(z);
2556 while( i>0 && z[i-1]==';' ){ i--; }
2557 utf8_printf(f, "%.*s;\n", i, z);
2558 }
2559 return 0;
2560 }
2561
2562 /*
2563 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
2564 ** a useful spot to set a debugger breakpoint.
@@ -2944,14 +2951,14 @@
2951 }
2952
2953 /*
2954 ** Convert a 2-byte or 4-byte big-endian integer into a native integer
2955 */
2956 static unsigned int get2byteInt(unsigned char *a){
2957 return (a[0]<<8) + a[1];
2958 }
2959 static unsigned int get4byteInt(unsigned char *a){
2960 return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];
2961 }
2962
2963 /*
2964 ** Implementation of the ".info" command.
@@ -4653,13 +4660,13 @@
4660 }
4661 output_file_close(p->traceOut);
4662 p->traceOut = output_file_open(azArg[1]);
4663 #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
4664 if( p->traceOut==0 ){
4665 sqlite3_trace_v2(p->db, 0, 0, 0);
4666 }else{
4667 sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);
4668 }
4669 #endif
4670 }else
4671
4672 #if SQLITE_USER_AUTHENTICATION
4673
+2922 -2119
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.13.0. By combining all the individual C code files into this
3
+** version 3.14.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -35,12 +35,12 @@
3535
**
3636
*************************************************************************
3737
** Internal interface definitions for SQLite.
3838
**
3939
*/
40
-#ifndef _SQLITEINT_H_
41
-#define _SQLITEINT_H_
40
+#ifndef SQLITEINT_H
41
+#define SQLITEINT_H
4242
4343
/* Special Comments:
4444
**
4545
** Some comments have special meaning to the tools that measure test
4646
** coverage:
@@ -95,12 +95,12 @@
9595
**
9696
******************************************************************************
9797
**
9898
** This file contains code that is specific to MSVC.
9999
*/
100
-#ifndef _MSVC_H_
101
-#define _MSVC_H_
100
+#ifndef SQLITE_MSVC_H
101
+#define SQLITE_MSVC_H
102102
103103
#if defined(_MSC_VER)
104104
#pragma warning(disable : 4054)
105105
#pragma warning(disable : 4055)
106106
#pragma warning(disable : 4100)
@@ -116,11 +116,11 @@
116116
#pragma warning(disable : 4306)
117117
#pragma warning(disable : 4702)
118118
#pragma warning(disable : 4706)
119119
#endif /* defined(_MSC_VER) */
120120
121
-#endif /* _MSVC_H_ */
121
+#endif /* SQLITE_MSVC_H */
122122
123123
/************** End of msvc.h ************************************************/
124124
/************** Continuing where we left off in sqliteInt.h ******************/
125125
126126
/*
@@ -280,12 +280,12 @@
280280
** The name of this file under configuration management is "sqlite.h.in".
281281
** The makefile makes some minor changes to this file (such as inserting
282282
** the version number) and changes its name to "sqlite3.h" as
283283
** part of the build process.
284284
*/
285
-#ifndef _SQLITE3_H_
286
-#define _SQLITE3_H_
285
+#ifndef SQLITE3_H
286
+#define SQLITE3_H
287287
#include <stdarg.h> /* Needed for the definition of va_list */
288288
289289
/*
290290
** Make sure we can call this stuff from C++.
291291
*/
@@ -361,13 +361,13 @@
361361
**
362362
** See also: [sqlite3_libversion()],
363363
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
364364
** [sqlite_version()] and [sqlite_source_id()].
365365
*/
366
-#define SQLITE_VERSION "3.13.0"
367
-#define SQLITE_VERSION_NUMBER 3013000
368
-#define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
366
+#define SQLITE_VERSION "3.14.0"
367
+#define SQLITE_VERSION_NUMBER 3014000
368
+#define SQLITE_SOURCE_ID "2016-07-23 20:27:41 c8e0539b970585cbb3619461a53abb0c3b308a17"
369369
370370
/*
371371
** CAPI3REF: Run-Time Library Version Numbers
372372
** KEYWORDS: sqlite3_version, sqlite3_sourceid
373373
**
@@ -756,10 +756,11 @@
756756
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
757757
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
758758
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
759759
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
760760
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
761
+#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
761762
762763
/*
763764
** CAPI3REF: Flags For File Open Operations
764765
**
765766
** These bit values are intended for use in the
@@ -3003,10 +3004,13 @@
30033004
#define SQLITE_RECURSIVE 33 /* NULL NULL */
30043005
30053006
/*
30063007
** CAPI3REF: Tracing And Profiling Functions
30073008
** METHOD: sqlite3
3009
+**
3010
+** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
3011
+** instead of the routines described here.
30083012
**
30093013
** These routines register callback functions that can be used for
30103014
** tracing and profiling the execution of SQL statements.
30113015
**
30123016
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -3029,13 +3033,104 @@
30293033
** digits in the time are meaningless. Future versions of SQLite
30303034
** might provide greater resolution on the profiler callback. The
30313035
** sqlite3_profile() function is considered experimental and is
30323036
** subject to change in future versions of SQLite.
30333037
*/
3034
-SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
3035
-SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
3038
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
3039
+ void(*xTrace)(void*,const char*), void*);
3040
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
30363041
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
3042
+
3043
+/*
3044
+** CAPI3REF: SQL Trace Event Codes
3045
+** KEYWORDS: SQLITE_TRACE
3046
+**
3047
+** These constants identify classes of events that can be monitored
3048
+** using the [sqlite3_trace_v2()] tracing logic. The third argument
3049
+** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
3050
+** the following constants. ^The first argument to the trace callback
3051
+** is one of the following constants.
3052
+**
3053
+** New tracing constants may be added in future releases.
3054
+**
3055
+** ^A trace callback has four arguments: xCallback(T,C,P,X).
3056
+** ^The T argument is one of the integer type codes above.
3057
+** ^The C argument is a copy of the context pointer passed in as the
3058
+** fourth argument to [sqlite3_trace_v2()].
3059
+** The P and X arguments are pointers whose meanings depend on T.
3060
+**
3061
+** <dl>
3062
+** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
3063
+** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
3064
+** first begins running and possibly at other times during the
3065
+** execution of the prepared statement, such as at the start of each
3066
+** trigger subprogram. ^The P argument is a pointer to the
3067
+** [prepared statement]. ^The X argument is a pointer to a string which
3068
+** is the expanded SQL text of the prepared statement or a comment that
3069
+** indicates the invocation of a trigger.
3070
+**
3071
+** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
3072
+** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
3073
+** information as is provided by the [sqlite3_profile()] callback.
3074
+** ^The P argument is a pointer to the [prepared statement] and the
3075
+** X argument points to a 64-bit integer which is the estimated of
3076
+** the number of nanosecond that the prepared statement took to run.
3077
+** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
3078
+**
3079
+** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
3080
+** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
3081
+** statement generates a single row of result.
3082
+** ^The P argument is a pointer to the [prepared statement] and the
3083
+** X argument is unused.
3084
+**
3085
+** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
3086
+** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
3087
+** connection closes.
3088
+** ^The P argument is a pointer to the [database connection] object
3089
+** and the X argument is unused.
3090
+** </dl>
3091
+*/
3092
+#define SQLITE_TRACE_STMT 0x01
3093
+#define SQLITE_TRACE_PROFILE 0x02
3094
+#define SQLITE_TRACE_ROW 0x04
3095
+#define SQLITE_TRACE_CLOSE 0x08
3096
+
3097
+/*
3098
+** CAPI3REF: SQL Trace Hook
3099
+** METHOD: sqlite3
3100
+**
3101
+** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
3102
+** function X against [database connection] D, using property mask M
3103
+** and context pointer P. ^If the X callback is
3104
+** NULL or if the M mask is zero, then tracing is disabled. The
3105
+** M argument should be the bitwise OR-ed combination of
3106
+** zero or more [SQLITE_TRACE] constants.
3107
+**
3108
+** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
3109
+** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
3110
+**
3111
+** ^The X callback is invoked whenever any of the events identified by
3112
+** mask M occur. ^The integer return value from the callback is currently
3113
+** ignored, though this may change in future releases. Callback
3114
+** implementations should return zero to ensure future compatibility.
3115
+**
3116
+** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
3117
+** ^The T argument is one of the [SQLITE_TRACE]
3118
+** constants to indicate why the callback was invoked.
3119
+** ^The C argument is a copy of the context pointer.
3120
+** The P and X arguments are pointers whose meanings depend on T.
3121
+**
3122
+** The sqlite3_trace_v2() interface is intended to replace the legacy
3123
+** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
3124
+** are deprecated.
3125
+*/
3126
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
3127
+ sqlite3*,
3128
+ unsigned uMask,
3129
+ int(*xCallback)(unsigned,void*,void*,void*),
3130
+ void *pCtx
3131
+);
30373132
30383133
/*
30393134
** CAPI3REF: Query Progress Callbacks
30403135
** METHOD: sqlite3
30413136
**
@@ -3651,15 +3746,39 @@
36513746
36523747
/*
36533748
** CAPI3REF: Retrieving Statement SQL
36543749
** METHOD: sqlite3_stmt
36553750
**
3656
-** ^This interface can be used to retrieve a saved copy of the original
3657
-** SQL text used to create a [prepared statement] if that statement was
3658
-** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3751
+** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3752
+** SQL text used to create [prepared statement] P if P was
3753
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3754
+** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3755
+** string containing the SQL text of prepared statement P with
3756
+** [bound parameters] expanded.
3757
+**
3758
+** ^(For example, if a prepared statement is created using the SQL
3759
+** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3760
+** and parameter :xyz is unbound, then sqlite3_sql() will return
3761
+** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3762
+** will return "SELECT 2345,NULL".)^
3763
+**
3764
+** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3765
+** is available to hold the result, or if the result would exceed the
3766
+** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3767
+**
3768
+** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3769
+** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3770
+** option causes sqlite3_expanded_sql() to always return NULL.
3771
+**
3772
+** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3773
+** automatically freed when the prepared statement is finalized.
3774
+** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3775
+** is obtained from [sqlite3_malloc()] and must be free by the application
3776
+** by passing it to [sqlite3_free()].
36593777
*/
36603778
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3779
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
36613780
36623781
/*
36633782
** CAPI3REF: Determine If An SQL Statement Writes The Database
36643783
** METHOD: sqlite3_stmt
36653784
**
@@ -7014,10 +7133,22 @@
70147133
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
70157134
** <dd>This parameter returns the approximate number of bytes of heap
70167135
** memory used by all pager caches associated with the database connection.)^
70177136
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
70187137
**
7138
+** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
7139
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
7140
+** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
7141
+** pager cache is shared between two or more connections the bytes of heap
7142
+** memory used by that pager cache is divided evenly between the attached
7143
+** connections.)^ In other words, if none of the pager caches associated
7144
+** with the database connection are shared, this request returns the same
7145
+** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
7146
+** shared, the value returned by this call will be smaller than that returned
7147
+** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
7148
+** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
7149
+**
70197150
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
70207151
** <dd>This parameter returns the approximate number of bytes of heap
70217152
** memory used to store the schema for all databases associated
70227153
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
70237154
** ^The full amount of memory used by the schemas is reported, even if the
@@ -7071,11 +7202,12 @@
70717202
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
70727203
#define SQLITE_DBSTATUS_CACHE_HIT 7
70737204
#define SQLITE_DBSTATUS_CACHE_MISS 8
70747205
#define SQLITE_DBSTATUS_CACHE_WRITE 9
70757206
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
7076
-#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
7207
+#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
7208
+#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
70777209
70787210
70797211
/*
70807212
** CAPI3REF: Prepared Statement Status
70817213
** METHOD: sqlite3_stmt
@@ -8454,11 +8586,11 @@
84548586
#endif
84558587
84568588
#if 0
84578589
} /* End of the 'extern "C"' block */
84588590
#endif
8459
-#endif /* _SQLITE3_H_ */
8591
+#endif /* SQLITE3_H */
84608592
84618593
/******** Begin file sqlite3rtree.h *********/
84628594
/*
84638595
** 2010 August 30
84648596
**
@@ -11009,12 +11141,12 @@
1100911141
**
1101011142
*************************************************************************
1101111143
** This is the header file for the generic hash-table implementation
1101211144
** used in SQLite.
1101311145
*/
11014
-#ifndef _SQLITE_HASH_H_
11015
-#define _SQLITE_HASH_H_
11146
+#ifndef SQLITE_HASH_H
11147
+#define SQLITE_HASH_H
1101611148
1101711149
/* Forward declarations of structures. */
1101811150
typedef struct Hash Hash;
1101911151
typedef struct HashElem HashElem;
1102011152
@@ -11090,11 +11222,11 @@
1109011222
/*
1109111223
** Number of entries in a hash table
1109211224
*/
1109311225
/* #define sqliteHashCount(H) ((H)->count) // NOT USED */
1109411226
11095
-#endif /* _SQLITE_HASH_H_ */
11227
+#endif /* SQLITE_HASH_H */
1109611228
1109711229
/************** End of hash.h ************************************************/
1109811230
/************** Continuing where we left off in sqliteInt.h ******************/
1109911231
/************** Include parse.h in the middle of sqliteInt.h *****************/
1110011232
/************** Begin file parse.h *******************************************/
@@ -11838,12 +11970,12 @@
1183811970
*************************************************************************
1183911971
** This header file defines the interface that the sqlite B-Tree file
1184011972
** subsystem. See comments in the source code for a detailed description
1184111973
** of what each interface routine does.
1184211974
*/
11843
-#ifndef _BTREE_H_
11844
-#define _BTREE_H_
11975
+#ifndef SQLITE_BTREE_H
11976
+#define SQLITE_BTREE_H
1184511977
1184611978
/* TODO: This definition is just included so other modules compile. It
1184711979
** needs to be revisited.
1184811980
*/
1184911981
#define SQLITE_N_BTREE_META 16
@@ -11864,10 +11996,11 @@
1186411996
** Forward declarations of structure
1186511997
*/
1186611998
typedef struct Btree Btree;
1186711999
typedef struct BtCursor BtCursor;
1186812000
typedef struct BtShared BtShared;
12001
+typedef struct BtreePayload BtreePayload;
1186912002
1187012003
1187112004
SQLITE_PRIVATE int sqlite3BtreeOpen(
1187212005
sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
1187312006
const char *zFilename, /* Name of database file to open */
@@ -12075,23 +12208,47 @@
1207512208
1207612209
/* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
1207712210
#define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
1207812211
#define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
1207912212
12080
-SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
12081
- const void *pData, int nData,
12082
- int nZero, int bias, int seekResult);
12213
+/* An instance of the BtreePayload object describes the content of a single
12214
+** entry in either an index or table btree.
12215
+**
12216
+** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
12217
+** an arbitrary key and no data. These btrees have pKey,nKey set to their
12218
+** key and pData,nData,nZero set to zero.
12219
+**
12220
+** Table btrees (used for rowid tables) contain an integer rowid used as
12221
+** the key and passed in the nKey field. The pKey field is zero.
12222
+** pData,nData hold the content of the new entry. nZero extra zero bytes
12223
+** are appended to the end of the content when constructing the entry.
12224
+**
12225
+** This object is used to pass information into sqlite3BtreeInsert(). The
12226
+** same information used to be passed as five separate parameters. But placing
12227
+** the information into this object helps to keep the interface more
12228
+** organized and understandable, and it also helps the resulting code to
12229
+** run a little faster by using fewer registers for parameter passing.
12230
+*/
12231
+struct BtreePayload {
12232
+ const void *pKey; /* Key content for indexes. NULL for tables */
12233
+ sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
12234
+ const void *pData; /* Data for tables. NULL for indexes */
12235
+ int nData; /* Size of pData. 0 if none. */
12236
+ int nZero; /* Extra zero data appended after pData,nData */
12237
+};
12238
+
12239
+SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
12240
+ int bias, int seekResult);
1208312241
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
1208412242
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
1208512243
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
1208612244
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
1208712245
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12088
-SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
12246
+SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
1208912247
SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
12090
-SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
12091
-SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
12092
-SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
12248
+SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12249
+SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
1209312250
SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
1209412251
1209512252
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
1209612253
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
1209712254
@@ -12128,15 +12285,17 @@
1212812285
#ifndef SQLITE_OMIT_SHARED_CACHE
1212912286
SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
1213012287
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
1213112288
SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
1213212289
SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
12290
+SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*);
1213312291
#else
1213412292
# define sqlite3BtreeEnter(X)
1213512293
# define sqlite3BtreeEnterAll(X)
1213612294
# define sqlite3BtreeSharable(X) 0
1213712295
# define sqlite3BtreeEnterCursor(X)
12296
+# define sqlite3BtreeConnectionCount(X) 1
1213812297
#endif
1213912298
1214012299
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
1214112300
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
1214212301
SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
@@ -12157,11 +12316,11 @@
1215712316
# define sqlite3BtreeHoldsAllMutexes(X) 1
1215812317
# define sqlite3SchemaMutexHeld(X,Y,Z) 1
1215912318
#endif
1216012319
1216112320
12162
-#endif /* _BTREE_H_ */
12321
+#endif /* SQLITE_BTREE_H */
1216312322
1216412323
/************** End of btree.h ***********************************************/
1216512324
/************** Continuing where we left off in sqliteInt.h ******************/
1216612325
/************** Include vdbe.h in the middle of sqliteInt.h ******************/
1216712326
/************** Begin file vdbe.h ********************************************/
@@ -12180,12 +12339,12 @@
1218012339
**
1218112340
** This header defines the interface to the virtual database engine
1218212341
** or VDBE. The VDBE implements an abstract machine that runs a
1218312342
** simple program to access and modify the underlying database.
1218412343
*/
12185
-#ifndef _SQLITE_VDBE_H_
12186
-#define _SQLITE_VDBE_H_
12344
+#ifndef SQLITE_VDBE_H
12345
+#define SQLITE_VDBE_H
1218712346
/* #include <stdio.h> */
1218812347
1218912348
/*
1219012349
** A single VDBE is an opaque structure named "Vdbe". Only routines
1219112350
** in the source file sqliteVdbe.c are allowed to see the insides
@@ -12366,21 +12525,21 @@
1236612525
#define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1236712526
#define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
1236812527
#define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */
1236912528
#define OP_NotFound 30 /* synopsis: key=r[P3@P4] */
1237012529
#define OP_Found 31 /* synopsis: key=r[P3@P4] */
12371
-#define OP_NotExists 32 /* synopsis: intkey=r[P3] */
12372
-#define OP_Last 33
12530
+#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12531
+#define OP_NotExists 33 /* synopsis: intkey=r[P3] */
1237312532
#define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1237412533
#define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1237512534
#define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
1237612535
#define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
1237712536
#define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
1237812537
#define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
1237912538
#define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
1238012539
#define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12381
-#define OP_SorterSort 42
12540
+#define OP_Last 42
1238212541
#define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1238312542
#define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1238412543
#define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1238512544
#define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1238612545
#define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12387,118 +12546,119 @@
1238712546
#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1238812547
#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1238912548
#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1239012549
#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1239112550
#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12392
-#define OP_Sort 53
12551
+#define OP_SorterSort 53
1239312552
#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12394
-#define OP_Rewind 55
12395
-#define OP_IdxLE 56 /* synopsis: key=r[P3@P4] */
12396
-#define OP_IdxGT 57 /* synopsis: key=r[P3@P4] */
12397
-#define OP_IdxLT 58 /* synopsis: key=r[P3@P4] */
12398
-#define OP_IdxGE 59 /* synopsis: key=r[P3@P4] */
12399
-#define OP_RowSetRead 60 /* synopsis: r[P3]=rowset(P1) */
12400
-#define OP_RowSetTest 61 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12401
-#define OP_Program 62
12402
-#define OP_FkIfZero 63 /* synopsis: if fkctr[P1]==0 goto P2 */
12403
-#define OP_IfPos 64 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12404
-#define OP_IfNotZero 65 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12405
-#define OP_DecrJumpZero 66 /* synopsis: if (--r[P1])==0 goto P2 */
12406
-#define OP_IncrVacuum 67
12407
-#define OP_VNext 68
12408
-#define OP_Init 69 /* synopsis: Start at P2 */
12409
-#define OP_Return 70
12410
-#define OP_EndCoroutine 71
12411
-#define OP_HaltIfNull 72 /* synopsis: if r[P3]=null halt */
12412
-#define OP_Halt 73
12413
-#define OP_Integer 74 /* synopsis: r[P2]=P1 */
12414
-#define OP_Int64 75 /* synopsis: r[P2]=P4 */
12415
-#define OP_String 76 /* synopsis: r[P2]='P4' (len=P1) */
12416
-#define OP_Null 77 /* synopsis: r[P2..P3]=NULL */
12417
-#define OP_SoftNull 78 /* synopsis: r[P1]=NULL */
12418
-#define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */
12419
-#define OP_Variable 80 /* synopsis: r[P2]=parameter(P1,P4) */
12420
-#define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */
12421
-#define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12422
-#define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */
12423
-#define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */
12424
-#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
12425
-#define OP_CollSeq 86
12426
-#define OP_Function0 87 /* synopsis: r[P3]=func(r[P2@P5]) */
12427
-#define OP_Function 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12428
-#define OP_AddImm 89 /* synopsis: r[P1]=r[P1]+P2 */
12429
-#define OP_RealAffinity 90
12430
-#define OP_Cast 91 /* synopsis: affinity(r[P1]) */
12431
-#define OP_Permutation 92
12432
-#define OP_Compare 93 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12433
-#define OP_Column 94 /* synopsis: r[P3]=PX */
12434
-#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
12435
-#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12553
+#define OP_Sort 55
12554
+#define OP_Rewind 56
12555
+#define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12556
+#define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12557
+#define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12558
+#define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12559
+#define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12560
+#define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12561
+#define OP_Program 63
12562
+#define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12563
+#define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12564
+#define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12565
+#define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12566
+#define OP_IncrVacuum 68
12567
+#define OP_VNext 69
12568
+#define OP_Init 70 /* synopsis: Start at P2 */
12569
+#define OP_Return 71
12570
+#define OP_EndCoroutine 72
12571
+#define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12572
+#define OP_Halt 74
12573
+#define OP_Integer 75 /* synopsis: r[P2]=P1 */
12574
+#define OP_Int64 76 /* synopsis: r[P2]=P4 */
12575
+#define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12576
+#define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12577
+#define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12578
+#define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12579
+#define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12580
+#define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12581
+#define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12582
+#define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12583
+#define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12584
+#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12585
+#define OP_CollSeq 87
12586
+#define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12587
+#define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12588
+#define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12589
+#define OP_RealAffinity 91
12590
+#define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12591
+#define OP_Permutation 93
12592
+#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12593
+#define OP_Column 95 /* synopsis: r[P3]=PX */
12594
+#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
1243612595
#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12437
-#define OP_Count 98 /* synopsis: r[P2]=count() */
12438
-#define OP_ReadCookie 99
12439
-#define OP_SetCookie 100
12440
-#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
12441
-#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */
12442
-#define OP_OpenWrite 103 /* synopsis: root=P2 iDb=P3 */
12443
-#define OP_OpenAutoindex 104 /* synopsis: nColumn=P2 */
12444
-#define OP_OpenEphemeral 105 /* synopsis: nColumn=P2 */
12445
-#define OP_SorterOpen 106
12446
-#define OP_SequenceTest 107 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12447
-#define OP_OpenPseudo 108 /* synopsis: P3 columns in r[P2] */
12448
-#define OP_Close 109
12449
-#define OP_ColumnsUsed 110
12450
-#define OP_Sequence 111 /* synopsis: r[P2]=cursor[P1].ctr++ */
12451
-#define OP_NewRowid 112 /* synopsis: r[P2]=rowid */
12452
-#define OP_Insert 113 /* synopsis: intkey=r[P3] data=r[P2] */
12453
-#define OP_InsertInt 114 /* synopsis: intkey=P3 data=r[P2] */
12454
-#define OP_Delete 115
12455
-#define OP_ResetCount 116
12456
-#define OP_SorterCompare 117 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12457
-#define OP_SorterData 118 /* synopsis: r[P2]=data */
12458
-#define OP_RowKey 119 /* synopsis: r[P2]=key */
12459
-#define OP_RowData 120 /* synopsis: r[P2]=data */
12460
-#define OP_Rowid 121 /* synopsis: r[P2]=rowid */
12461
-#define OP_NullRow 122
12462
-#define OP_SorterInsert 123
12463
-#define OP_IdxInsert 124 /* synopsis: key=r[P2] */
12464
-#define OP_IdxDelete 125 /* synopsis: key=r[P2@P3] */
12465
-#define OP_Seek 126 /* synopsis: Move P3 to P1.rowid */
12466
-#define OP_IdxRowid 127 /* synopsis: r[P2]=rowid */
12467
-#define OP_Destroy 128
12468
-#define OP_Clear 129
12469
-#define OP_ResetSorter 130
12470
-#define OP_CreateIndex 131 /* synopsis: r[P2]=root iDb=P1 */
12471
-#define OP_CreateTable 132 /* synopsis: r[P2]=root iDb=P1 */
12596
+#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12597
+#define OP_Count 99 /* synopsis: r[P2]=count() */
12598
+#define OP_ReadCookie 100
12599
+#define OP_SetCookie 101
12600
+#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12601
+#define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12602
+#define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12603
+#define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12604
+#define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12605
+#define OP_SorterOpen 107
12606
+#define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12607
+#define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12608
+#define OP_Close 110
12609
+#define OP_ColumnsUsed 111
12610
+#define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12611
+#define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12612
+#define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12613
+#define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12614
+#define OP_Delete 116
12615
+#define OP_ResetCount 117
12616
+#define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12617
+#define OP_SorterData 119 /* synopsis: r[P2]=data */
12618
+#define OP_RowKey 120 /* synopsis: r[P2]=key */
12619
+#define OP_RowData 121 /* synopsis: r[P2]=data */
12620
+#define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12621
+#define OP_NullRow 123
12622
+#define OP_SorterInsert 124
12623
+#define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12624
+#define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12625
+#define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12626
+#define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12627
+#define OP_Destroy 129
12628
+#define OP_Clear 130
12629
+#define OP_ResetSorter 131
12630
+#define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
1247212631
#define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12473
-#define OP_ParseSchema 134
12474
-#define OP_LoadAnalysis 135
12475
-#define OP_DropTable 136
12476
-#define OP_DropIndex 137
12477
-#define OP_DropTrigger 138
12478
-#define OP_IntegrityCk 139
12479
-#define OP_RowSetAdd 140 /* synopsis: rowset(P1)=r[P2] */
12480
-#define OP_Param 141
12481
-#define OP_FkCounter 142 /* synopsis: fkctr[P1]+=P2 */
12482
-#define OP_MemMax 143 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12483
-#define OP_OffsetLimit 144 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12484
-#define OP_AggStep0 145 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12485
-#define OP_AggStep 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12486
-#define OP_AggFinal 147 /* synopsis: accum=r[P1] N=P2 */
12487
-#define OP_Expire 148
12488
-#define OP_TableLock 149 /* synopsis: iDb=P1 root=P2 write=P3 */
12489
-#define OP_VBegin 150
12490
-#define OP_VCreate 151
12491
-#define OP_VDestroy 152
12492
-#define OP_VOpen 153
12493
-#define OP_VColumn 154 /* synopsis: r[P3]=vcolumn(P2) */
12494
-#define OP_VRename 155
12495
-#define OP_Pagecount 156
12496
-#define OP_MaxPgcnt 157
12497
-#define OP_CursorHint 158
12498
-#define OP_Noop 159
12499
-#define OP_Explain 160
12632
+#define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12633
+#define OP_ParseSchema 135
12634
+#define OP_LoadAnalysis 136
12635
+#define OP_DropTable 137
12636
+#define OP_DropIndex 138
12637
+#define OP_DropTrigger 139
12638
+#define OP_IntegrityCk 140
12639
+#define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12640
+#define OP_Param 142
12641
+#define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12642
+#define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12643
+#define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12644
+#define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12645
+#define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12646
+#define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12647
+#define OP_Expire 149
12648
+#define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12649
+#define OP_VBegin 151
12650
+#define OP_VCreate 152
12651
+#define OP_VDestroy 153
12652
+#define OP_VOpen 154
12653
+#define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12654
+#define OP_VRename 156
12655
+#define OP_Pagecount 157
12656
+#define OP_MaxPgcnt 158
12657
+#define OP_CursorHint 159
12658
+#define OP_Noop 160
12659
+#define OP_Explain 161
1250012660
1250112661
/* Properties such as "out2" or "jump" that are specified in
1250212662
** comments following the "case" for each opcode in the vdbe.c
1250312663
** are encoded into bitvectors as follows:
1250412664
*/
@@ -12511,35 +12671,35 @@
1251112671
#define OPFLG_INITIALIZER {\
1251212672
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
1251312673
/* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
1251412674
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
1251512675
/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12516
-/* 32 */ 0x09, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12676
+/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1251712677
/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
1251812678
/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12519
-/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01,\
12520
-/* 64 */ 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02, 0x02,\
12521
-/* 72 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
12522
-/* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12523
-/* 88 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\
12524
-/* 96 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
12525
-/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
12526
-/* 112 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12527
-/* 120 */ 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
12528
-/* 128 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\
12529
-/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
12530
-/* 144 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12531
-/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12532
-/* 160 */ 0x00,}
12679
+/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12680
+/* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12681
+/* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12682
+/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12683
+/* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12684
+/* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12685
+/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12686
+/* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12687
+/* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12688
+/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12689
+/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12690
+/* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12691
+/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12692
+/* 160 */ 0x00, 0x00,}
1253312693
1253412694
/* The sqlite3P2Values() routine is able to run faster if it knows
1253512695
** the value of the largest JUMP opcode. The smaller the maximum
1253612696
** JUMP opcode the better, so the mkopcodeh.tcl script that
1253712697
** generated this include file strives to group all JUMP opcodes
1253812698
** together near the beginning of the list.
1253912699
*/
12540
-#define SQLITE_MX_JUMP_OPCODE 69 /* Maximum JUMP opcode */
12700
+#define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
1254112701
1254212702
/************** End of opcodes.h *********************************************/
1254312703
/************** Continuing where we left off in vdbe.h ***********************/
1254412704
1254512705
/*
@@ -12682,11 +12842,11 @@
1268212842
SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
1268312843
#else
1268412844
# define sqlite3VdbeScanStatus(a,b,c,d,e)
1268512845
#endif
1268612846
12687
-#endif
12847
+#endif /* SQLITE_VDBE_H */
1268812848
1268912849
/************** End of vdbe.h ************************************************/
1269012850
/************** Continuing where we left off in sqliteInt.h ******************/
1269112851
/************** Include pager.h in the middle of sqliteInt.h *****************/
1269212852
/************** Begin file pager.h *******************************************/
@@ -12704,12 +12864,12 @@
1270412864
** This header file defines the interface that the sqlite page cache
1270512865
** subsystem. The page cache subsystem reads and writes a file a page
1270612866
** at a time and provides a journal for rollback.
1270712867
*/
1270812868
12709
-#ifndef _PAGER_H_
12710
-#define _PAGER_H_
12869
+#ifndef SQLITE_PAGER_H
12870
+#define SQLITE_PAGER_H
1271112871
1271212872
/*
1271312873
** Default maximum size for persistent journal files. A negative
1271412874
** value means no limit. This value may be overridden using the
1271512875
** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
@@ -12893,11 +13053,10 @@
1289313053
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
1289413054
SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
1289513055
SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
1289613056
SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
1289713057
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
12898
-SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
1289913058
SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
1290013059
1290113060
/* Functions used to truncate the database file. */
1290213061
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
1290313062
@@ -12920,11 +13079,11 @@
1292013079
#else
1292113080
# define disable_simulated_io_errors()
1292213081
# define enable_simulated_io_errors()
1292313082
#endif
1292413083
12925
-#endif /* _PAGER_H_ */
13084
+#endif /* SQLITE_PAGER_H */
1292613085
1292713086
/************** End of pager.h ***********************************************/
1292813087
/************** Continuing where we left off in sqliteInt.h ******************/
1292913088
/************** Include pcache.h in the middle of sqliteInt.h ****************/
1293013089
/************** Begin file pcache.h ******************************************/
@@ -13158,12 +13317,12 @@
1315813317
******************************************************************************
1315913318
**
1316013319
** This file contains pre-processor directives related to operating system
1316113320
** detection and/or setup.
1316213321
*/
13163
-#ifndef _OS_SETUP_H_
13164
-#define _OS_SETUP_H_
13322
+#ifndef SQLITE_OS_SETUP_H
13323
+#define SQLITE_OS_SETUP_H
1316513324
1316613325
/*
1316713326
** Figure out if we are dealing with Unix, Windows, or some other operating
1316813327
** system.
1316913328
**
@@ -13199,11 +13358,11 @@
1319913358
# ifndef SQLITE_OS_WIN
1320013359
# define SQLITE_OS_WIN 0
1320113360
# endif
1320213361
#endif
1320313362
13204
-#endif /* _OS_SETUP_H_ */
13363
+#endif /* SQLITE_OS_SETUP_H */
1320513364
1320613365
/************** End of os_setup.h ********************************************/
1320713366
/************** Continuing where we left off in os.h *************************/
1320813367
1320913368
/* If the SET_FULLSYNC macro is not defined above, then make it
@@ -13656,10 +13815,19 @@
1365613815
#else
1365713816
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
1365813817
const char*);
1365913818
#endif
1366013819
13820
+#ifndef SQLITE_OMIT_DEPRECATED
13821
+/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
13822
+** in the style of sqlite3_trace()
13823
+*/
13824
+#define SQLITE_TRACE_LEGACY 0x80
13825
+#else
13826
+#define SQLITE_TRACE_LEGACY 0
13827
+#endif /* SQLITE_OMIT_DEPRECATED */
13828
+
1366113829
1366213830
/*
1366313831
** Each database connection is an instance of the following structure.
1366413832
*/
1366513833
struct sqlite3 {
@@ -13685,10 +13853,11 @@
1368513853
u8 dfltLockMode; /* Default locking-mode for attached dbs */
1368613854
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
1368713855
u8 suppressErr; /* Do not issue error messages if true */
1368813856
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
1368913857
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
13858
+ u8 mTrace; /* zero or more SQLITE_TRACE flags */
1369013859
int nextPagesize; /* Pagesize after VACUUM if >0 */
1369113860
u32 magic; /* Magic number for detect library misuse */
1369213861
int nChange; /* Value returned by sqlite3_changes() */
1369313862
int nTotalChange; /* Value returned by sqlite3_total_changes() */
1369413863
int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -13705,11 +13874,11 @@
1370513874
int nVdbeWrite; /* Number of active VDBEs that read and write */
1370613875
int nVdbeExec; /* Number of nested calls to VdbeExec() */
1370713876
int nVDestroy; /* Number of active OP_VDestroy operations */
1370813877
int nExtension; /* Number of loaded extensions */
1370913878
void **aExtension; /* Array of shared library handles */
13710
- void (*xTrace)(void*,const char*); /* Trace function */
13879
+ int (*xTrace)(u32,void*,void*,void*); /* Trace function */
1371113880
void *pTraceArg; /* Argument to the trace function */
1371213881
void (*xProfile)(void*,const char*,u64); /* Profiling function */
1371313882
void *pProfileArg; /* Argument to profile function */
1371413883
void *pCommitArg; /* Argument to xCommitCallback() */
1371513884
int (*xCommitCallback)(void*); /* Invoked at every commit. */
@@ -14900,11 +15069,11 @@
1490015069
Select *pSelect; /* A SELECT statement used in place of a table name */
1490115070
int addrFillSub; /* Address of subroutine to manifest a subquery */
1490215071
int regReturn; /* Register holding return address of addrFillSub */
1490315072
int regResult; /* Registers holding results of a co-routine */
1490415073
struct {
14905
- u8 jointype; /* Type of join between this able and the previous */
15074
+ u8 jointype; /* Type of join between this table and the previous */
1490615075
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
1490715076
unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
1490815077
unsigned isTabFunc :1; /* True if table-valued-function syntax */
1490915078
unsigned isCorrelated :1; /* True if sub-query is correlated */
1491015079
unsigned viaCoroutine :1; /* Implemented as a co-routine */
@@ -14946,23 +15115,24 @@
1494615115
*/
1494715116
#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
1494815117
#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
1494915118
#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
1495015119
#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
14951
-#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
14952
-#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
14953
-#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
14954
-#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
14955
-#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
14956
-#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
14957
-#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
14958
-#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
14959
-#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
14960
-#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
14961
-#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
14962
-#define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */
14963
-#define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */
15120
+#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */
15121
+#define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */
15122
+#define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of
15123
+ ** the OR optimization */
15124
+#define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */
15125
+#define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */
15126
+#define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */
15127
+#define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */
15128
+#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
15129
+#define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
15130
+ /* 0x1000 not currently used */
15131
+ /* 0x2000 not currently used */
15132
+#define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
15133
+ /* 0x8000 not currently used */
1496415134
1496515135
/* Allowed return values from sqlite3WhereIsDistinct()
1496615136
*/
1496715137
#define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
1496815138
#define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
@@ -16031,12 +16201,12 @@
1603116201
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1603216202
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1603316203
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1603416204
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
1603516205
SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
16036
-SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16037
- Expr*, int, int);
16206
+SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16207
+ Expr*, int, int, u8);
1603816208
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1603916209
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1604016210
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1604116211
Expr*,ExprList*,u32,Expr*,Expr*);
1604216212
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -16051,10 +16221,11 @@
1605116221
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
1605216222
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
1605316223
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
1605416224
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
1605516225
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
16226
+SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
1605616227
SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
1605716228
SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
1605816229
SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
1605916230
SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
1606016231
#define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -16084,12 +16255,14 @@
1608416255
#define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
1608516256
SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
1608616257
SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
1608716258
SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
1608816259
SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
16089
-SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
16090
-SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
16260
+#define LOCATE_VIEW 0x01
16261
+#define LOCATE_NOERR 0x02
16262
+SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
16263
+SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
1609116264
SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
1609216265
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1609316266
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1609416267
SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
1609516268
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
@@ -16648,11 +16821,11 @@
1664816821
1664916822
#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
1665016823
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
1665116824
#endif
1665216825
16653
-#endif /* _SQLITEINT_H_ */
16826
+#endif /* SQLITEINT_H */
1665416827
1665516828
/************** End of sqliteInt.h *******************************************/
1665616829
/************** Begin file global.c ******************************************/
1665716830
/*
1665816831
** 2008 June 13
@@ -16983,10 +17156,17 @@
1698317156
"CASE_SENSITIVE_LIKE",
1698417157
#endif
1698517158
#if SQLITE_CHECK_PAGES
1698617159
"CHECK_PAGES",
1698717160
#endif
17161
+#if defined(__clang__) && defined(__clang_version__)
17162
+ "COMPILER=clang-" __clang_version__,
17163
+#elif defined(_MSC_VER)
17164
+ "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17165
+#elif defined(__GNUC__) && defined(__VERSION__)
17166
+ "COMPILER=gcc-" __VERSION__,
17167
+#endif
1698817168
#if SQLITE_COVERAGE_TEST
1698917169
"COVERAGE_TEST",
1699017170
#endif
1699117171
#if SQLITE_DEBUG
1699217172
"DEBUG",
@@ -17002,11 +17182,11 @@
1700217182
#endif
1700317183
#if SQLITE_DISABLE_LFS
1700417184
"DISABLE_LFS",
1700517185
#endif
1700617186
#if SQLITE_ENABLE_8_3_NAMES
17007
- "ENABLE_8_3_NAMES",
17187
+ "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
1700817188
#endif
1700917189
#if SQLITE_ENABLE_API_ARMOR
1701017190
"ENABLE_API_ARMOR",
1701117191
#endif
1701217192
#if SQLITE_ENABLE_ATOMIC_WRITE
@@ -17416,12 +17596,12 @@
1741617596
** VDBE. This information used to all be at the top of the single
1741717597
** source code file "vdbe.c". When that file became too big (over
1741817598
** 6000 lines long) it was split up into several smaller files and
1741917599
** this header information was factored out.
1742017600
*/
17421
-#ifndef _VDBEINT_H_
17422
-#define _VDBEINT_H_
17601
+#ifndef SQLITE_VDBEINT_H
17602
+#define SQLITE_VDBEINT_H
1742317603
1742417604
/*
1742517605
** The maximum number of times that a statement will try to reparse
1742617606
** itself before giving up and returning SQLITE_SCHEMA.
1742717607
*/
@@ -17959,11 +18139,11 @@
1795918139
#else
1796018140
#define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
1796118141
#define ExpandBlob(P) SQLITE_OK
1796218142
#endif
1796318143
17964
-#endif /* !defined(_VDBEINT_H_) */
18144
+#endif /* !defined(SQLITE_VDBEINT_H) */
1796518145
1796618146
/************** End of vdbeInt.h *********************************************/
1796718147
/************** Continuing where we left off in status.c *********************/
1796818148
1796918149
/*
@@ -18167,19 +18347,24 @@
1816718347
/*
1816818348
** Return an approximation for the amount of memory currently used
1816918349
** by all pagers associated with the given database connection. The
1817018350
** highwater mark is meaningless and is returned as zero.
1817118351
*/
18352
+ case SQLITE_DBSTATUS_CACHE_USED_SHARED:
1817218353
case SQLITE_DBSTATUS_CACHE_USED: {
1817318354
int totalUsed = 0;
1817418355
int i;
1817518356
sqlite3BtreeEnterAll(db);
1817618357
for(i=0; i<db->nDb; i++){
1817718358
Btree *pBt = db->aDb[i].pBt;
1817818359
if( pBt ){
1817918360
Pager *pPager = sqlite3BtreePager(pBt);
18180
- totalUsed += sqlite3PagerMemUsed(pPager);
18361
+ int nByte = sqlite3PagerMemUsed(pPager);
18362
+ if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){
18363
+ nByte = nByte / sqlite3BtreeConnectionCount(pBt);
18364
+ }
18365
+ totalUsed += nByte;
1818118366
}
1818218367
}
1818318368
sqlite3BtreeLeaveAll(db);
1818418369
*pCurrent = totalUsed;
1818518370
*pHighwater = 0;
@@ -19478,13 +19663,11 @@
1947819663
******************************************************************************
1947919664
**
1948019665
** This file contains OS interface code that is common to all
1948119666
** architectures.
1948219667
*/
19483
-#define _SQLITE_OS_C_ 1
1948419668
/* #include "sqliteInt.h" */
19485
-#undef _SQLITE_OS_C_
1948619669
1948719670
/*
1948819671
** If we compile with the SQLITE_TEST macro set, then the following block
1948919672
** of code will give us the ability to simulate a disk I/O error. This
1949019673
** is used for testing the I/O recovery logic.
@@ -22993,12 +23176,12 @@
2299323176
******************************************************************************
2299423177
**
2299523178
** This file contains inline asm code for retrieving "high-performance"
2299623179
** counters for x86 class CPUs.
2299723180
*/
22998
-#ifndef _HWTIME_H_
22999
-#define _HWTIME_H_
23181
+#ifndef SQLITE_HWTIME_H
23182
+#define SQLITE_HWTIME_H
2300023183
2300123184
/*
2300223185
** The following routine only works on pentium-class (or newer) processors.
2300323186
** It uses the RDTSC opcode to read the cycle count value out of the
2300423187
** processor and returns that value. This can be used for high-res
@@ -23062,11 +23245,11 @@
2306223245
*/
2306323246
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
2306423247
2306523248
#endif
2306623249
23067
-#endif /* !defined(_HWTIME_H_) */
23250
+#endif /* !defined(SQLITE_HWTIME_H) */
2306823251
2306923252
/************** End of hwtime.h **********************************************/
2307023253
/************** Continuing where we left off in os_common.h ******************/
2307123254
2307223255
static sqlite_uint64 g_start;
@@ -23152,12 +23335,12 @@
2315223335
**
2315323336
******************************************************************************
2315423337
**
2315523338
** This file contains code that is specific to Windows.
2315623339
*/
23157
-#ifndef _OS_WIN_H_
23158
-#define _OS_WIN_H_
23340
+#ifndef SQLITE_OS_WIN_H
23341
+#define SQLITE_OS_WIN_H
2315923342
2316023343
/*
2316123344
** Include the primary Windows SDK header file.
2316223345
*/
2316323346
#include "windows.h"
@@ -23225,11 +23408,11 @@
2322523408
# define SQLITE_OS_WIN_THREADS 1
2322623409
#else
2322723410
# define SQLITE_OS_WIN_THREADS 0
2322823411
#endif
2322923412
23230
-#endif /* _OS_WIN_H_ */
23413
+#endif /* SQLITE_OS_WIN_H */
2323123414
2323223415
/************** End of os_win.h **********************************************/
2323323416
/************** Continuing where we left off in mutex_w32.c ******************/
2323423417
#endif
2323523418
@@ -25976,10 +26159,16 @@
2597626159
}
2597726160
sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
2597826161
break;
2597926162
}
2598026163
#endif
26164
+ case TK_MATCH: {
26165
+ sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26166
+ pExpr->iTable, pExpr->iColumn, zFlgs);
26167
+ sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26168
+ break;
26169
+ }
2598126170
default: {
2598226171
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
2598326172
break;
2598426173
}
2598526174
}
@@ -28759,21 +28948,21 @@
2875928948
/* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
2876028949
/* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
2876128950
/* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
2876228951
/* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
2876328952
/* 31 */ "Found" OpHelp("key=r[P3@P4]"),
28764
- /* 32 */ "NotExists" OpHelp("intkey=r[P3]"),
28765
- /* 33 */ "Last" OpHelp(""),
28953
+ /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
28954
+ /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
2876628955
/* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
2876728956
/* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
2876828957
/* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
2876928958
/* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
2877028959
/* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
2877128960
/* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
2877228961
/* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
2877328962
/* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
28774
- /* 42 */ "SorterSort" OpHelp(""),
28963
+ /* 42 */ "Last" OpHelp(""),
2877528964
/* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
2877628965
/* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
2877728966
/* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
2877828967
/* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
2877928968
/* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -28780,118 +28969,119 @@
2878028969
/* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
2878128970
/* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
2878228971
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
2878328972
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
2878428973
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
28785
- /* 53 */ "Sort" OpHelp(""),
28974
+ /* 53 */ "SorterSort" OpHelp(""),
2878628975
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
28787
- /* 55 */ "Rewind" OpHelp(""),
28788
- /* 56 */ "IdxLE" OpHelp("key=r[P3@P4]"),
28789
- /* 57 */ "IdxGT" OpHelp("key=r[P3@P4]"),
28790
- /* 58 */ "IdxLT" OpHelp("key=r[P3@P4]"),
28791
- /* 59 */ "IdxGE" OpHelp("key=r[P3@P4]"),
28792
- /* 60 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
28793
- /* 61 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
28794
- /* 62 */ "Program" OpHelp(""),
28795
- /* 63 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
28796
- /* 64 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
28797
- /* 65 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
28798
- /* 66 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
28799
- /* 67 */ "IncrVacuum" OpHelp(""),
28800
- /* 68 */ "VNext" OpHelp(""),
28801
- /* 69 */ "Init" OpHelp("Start at P2"),
28802
- /* 70 */ "Return" OpHelp(""),
28803
- /* 71 */ "EndCoroutine" OpHelp(""),
28804
- /* 72 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
28805
- /* 73 */ "Halt" OpHelp(""),
28806
- /* 74 */ "Integer" OpHelp("r[P2]=P1"),
28807
- /* 75 */ "Int64" OpHelp("r[P2]=P4"),
28808
- /* 76 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
28809
- /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"),
28810
- /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"),
28811
- /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
28812
- /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
28813
- /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
28814
- /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
28815
- /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"),
28816
- /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
28817
- /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
28818
- /* 86 */ "CollSeq" OpHelp(""),
28819
- /* 87 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
28820
- /* 88 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
28821
- /* 89 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
28822
- /* 90 */ "RealAffinity" OpHelp(""),
28823
- /* 91 */ "Cast" OpHelp("affinity(r[P1])"),
28824
- /* 92 */ "Permutation" OpHelp(""),
28825
- /* 93 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
28826
- /* 94 */ "Column" OpHelp("r[P3]=PX"),
28827
- /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
28828
- /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
28976
+ /* 55 */ "Sort" OpHelp(""),
28977
+ /* 56 */ "Rewind" OpHelp(""),
28978
+ /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
28979
+ /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
28980
+ /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
28981
+ /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
28982
+ /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
28983
+ /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
28984
+ /* 63 */ "Program" OpHelp(""),
28985
+ /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
28986
+ /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
28987
+ /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
28988
+ /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
28989
+ /* 68 */ "IncrVacuum" OpHelp(""),
28990
+ /* 69 */ "VNext" OpHelp(""),
28991
+ /* 70 */ "Init" OpHelp("Start at P2"),
28992
+ /* 71 */ "Return" OpHelp(""),
28993
+ /* 72 */ "EndCoroutine" OpHelp(""),
28994
+ /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
28995
+ /* 74 */ "Halt" OpHelp(""),
28996
+ /* 75 */ "Integer" OpHelp("r[P2]=P1"),
28997
+ /* 76 */ "Int64" OpHelp("r[P2]=P4"),
28998
+ /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
28999
+ /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29000
+ /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29001
+ /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29002
+ /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29003
+ /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29004
+ /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29005
+ /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29006
+ /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29007
+ /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29008
+ /* 87 */ "CollSeq" OpHelp(""),
29009
+ /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29010
+ /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29011
+ /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29012
+ /* 91 */ "RealAffinity" OpHelp(""),
29013
+ /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29014
+ /* 93 */ "Permutation" OpHelp(""),
29015
+ /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29016
+ /* 95 */ "Column" OpHelp("r[P3]=PX"),
29017
+ /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
2882929018
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
28830
- /* 98 */ "Count" OpHelp("r[P2]=count()"),
28831
- /* 99 */ "ReadCookie" OpHelp(""),
28832
- /* 100 */ "SetCookie" OpHelp(""),
28833
- /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
28834
- /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
28835
- /* 103 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
28836
- /* 104 */ "OpenAutoindex" OpHelp("nColumn=P2"),
28837
- /* 105 */ "OpenEphemeral" OpHelp("nColumn=P2"),
28838
- /* 106 */ "SorterOpen" OpHelp(""),
28839
- /* 107 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
28840
- /* 108 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
28841
- /* 109 */ "Close" OpHelp(""),
28842
- /* 110 */ "ColumnsUsed" OpHelp(""),
28843
- /* 111 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
28844
- /* 112 */ "NewRowid" OpHelp("r[P2]=rowid"),
28845
- /* 113 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
28846
- /* 114 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
28847
- /* 115 */ "Delete" OpHelp(""),
28848
- /* 116 */ "ResetCount" OpHelp(""),
28849
- /* 117 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
28850
- /* 118 */ "SorterData" OpHelp("r[P2]=data"),
28851
- /* 119 */ "RowKey" OpHelp("r[P2]=key"),
28852
- /* 120 */ "RowData" OpHelp("r[P2]=data"),
28853
- /* 121 */ "Rowid" OpHelp("r[P2]=rowid"),
28854
- /* 122 */ "NullRow" OpHelp(""),
28855
- /* 123 */ "SorterInsert" OpHelp(""),
28856
- /* 124 */ "IdxInsert" OpHelp("key=r[P2]"),
28857
- /* 125 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
28858
- /* 126 */ "Seek" OpHelp("Move P3 to P1.rowid"),
28859
- /* 127 */ "IdxRowid" OpHelp("r[P2]=rowid"),
28860
- /* 128 */ "Destroy" OpHelp(""),
28861
- /* 129 */ "Clear" OpHelp(""),
28862
- /* 130 */ "ResetSorter" OpHelp(""),
28863
- /* 131 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
28864
- /* 132 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29019
+ /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29020
+ /* 99 */ "Count" OpHelp("r[P2]=count()"),
29021
+ /* 100 */ "ReadCookie" OpHelp(""),
29022
+ /* 101 */ "SetCookie" OpHelp(""),
29023
+ /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29024
+ /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29025
+ /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29026
+ /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29027
+ /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29028
+ /* 107 */ "SorterOpen" OpHelp(""),
29029
+ /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29030
+ /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29031
+ /* 110 */ "Close" OpHelp(""),
29032
+ /* 111 */ "ColumnsUsed" OpHelp(""),
29033
+ /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29034
+ /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29035
+ /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29036
+ /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29037
+ /* 116 */ "Delete" OpHelp(""),
29038
+ /* 117 */ "ResetCount" OpHelp(""),
29039
+ /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29040
+ /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29041
+ /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29042
+ /* 121 */ "RowData" OpHelp("r[P2]=data"),
29043
+ /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29044
+ /* 123 */ "NullRow" OpHelp(""),
29045
+ /* 124 */ "SorterInsert" OpHelp(""),
29046
+ /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29047
+ /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29048
+ /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29049
+ /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29050
+ /* 129 */ "Destroy" OpHelp(""),
29051
+ /* 130 */ "Clear" OpHelp(""),
29052
+ /* 131 */ "ResetSorter" OpHelp(""),
29053
+ /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
2886529054
/* 133 */ "Real" OpHelp("r[P2]=P4"),
28866
- /* 134 */ "ParseSchema" OpHelp(""),
28867
- /* 135 */ "LoadAnalysis" OpHelp(""),
28868
- /* 136 */ "DropTable" OpHelp(""),
28869
- /* 137 */ "DropIndex" OpHelp(""),
28870
- /* 138 */ "DropTrigger" OpHelp(""),
28871
- /* 139 */ "IntegrityCk" OpHelp(""),
28872
- /* 140 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
28873
- /* 141 */ "Param" OpHelp(""),
28874
- /* 142 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
28875
- /* 143 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
28876
- /* 144 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
28877
- /* 145 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
28878
- /* 146 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
28879
- /* 147 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
28880
- /* 148 */ "Expire" OpHelp(""),
28881
- /* 149 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
28882
- /* 150 */ "VBegin" OpHelp(""),
28883
- /* 151 */ "VCreate" OpHelp(""),
28884
- /* 152 */ "VDestroy" OpHelp(""),
28885
- /* 153 */ "VOpen" OpHelp(""),
28886
- /* 154 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
28887
- /* 155 */ "VRename" OpHelp(""),
28888
- /* 156 */ "Pagecount" OpHelp(""),
28889
- /* 157 */ "MaxPgcnt" OpHelp(""),
28890
- /* 158 */ "CursorHint" OpHelp(""),
28891
- /* 159 */ "Noop" OpHelp(""),
28892
- /* 160 */ "Explain" OpHelp(""),
29055
+ /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29056
+ /* 135 */ "ParseSchema" OpHelp(""),
29057
+ /* 136 */ "LoadAnalysis" OpHelp(""),
29058
+ /* 137 */ "DropTable" OpHelp(""),
29059
+ /* 138 */ "DropIndex" OpHelp(""),
29060
+ /* 139 */ "DropTrigger" OpHelp(""),
29061
+ /* 140 */ "IntegrityCk" OpHelp(""),
29062
+ /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29063
+ /* 142 */ "Param" OpHelp(""),
29064
+ /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29065
+ /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29066
+ /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29067
+ /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29068
+ /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29069
+ /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29070
+ /* 149 */ "Expire" OpHelp(""),
29071
+ /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29072
+ /* 151 */ "VBegin" OpHelp(""),
29073
+ /* 152 */ "VCreate" OpHelp(""),
29074
+ /* 153 */ "VDestroy" OpHelp(""),
29075
+ /* 154 */ "VOpen" OpHelp(""),
29076
+ /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29077
+ /* 156 */ "VRename" OpHelp(""),
29078
+ /* 157 */ "Pagecount" OpHelp(""),
29079
+ /* 158 */ "MaxPgcnt" OpHelp(""),
29080
+ /* 159 */ "CursorHint" OpHelp(""),
29081
+ /* 160 */ "Noop" OpHelp(""),
29082
+ /* 161 */ "Explain" OpHelp(""),
2889329083
};
2889429084
return azName[i];
2889529085
}
2889629086
#endif
2889729087
@@ -29237,12 +29427,12 @@
2923729427
******************************************************************************
2923829428
**
2923929429
** This file contains inline asm code for retrieving "high-performance"
2924029430
** counters for x86 class CPUs.
2924129431
*/
29242
-#ifndef _HWTIME_H_
29243
-#define _HWTIME_H_
29432
+#ifndef SQLITE_HWTIME_H
29433
+#define SQLITE_HWTIME_H
2924429434
2924529435
/*
2924629436
** The following routine only works on pentium-class (or newer) processors.
2924729437
** It uses the RDTSC opcode to read the cycle count value out of the
2924829438
** processor and returns that value. This can be used for high-res
@@ -29306,11 +29496,11 @@
2930629496
*/
2930729497
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
2930829498
2930929499
#endif
2931029500
29311
-#endif /* !defined(_HWTIME_H_) */
29501
+#endif /* !defined(SQLITE_HWTIME_H) */
2931229502
2931329503
/************** End of hwtime.h **********************************************/
2931429504
/************** Continuing where we left off in os_common.h ******************/
2931529505
2931629506
static sqlite_uint64 g_start;
@@ -36766,12 +36956,12 @@
3676636956
******************************************************************************
3676736957
**
3676836958
** This file contains inline asm code for retrieving "high-performance"
3676936959
** counters for x86 class CPUs.
3677036960
*/
36771
-#ifndef _HWTIME_H_
36772
-#define _HWTIME_H_
36961
+#ifndef SQLITE_HWTIME_H
36962
+#define SQLITE_HWTIME_H
3677336963
3677436964
/*
3677536965
** The following routine only works on pentium-class (or newer) processors.
3677636966
** It uses the RDTSC opcode to read the cycle count value out of the
3677736967
** processor and returns that value. This can be used for high-res
@@ -36835,11 +37025,11 @@
3683537025
*/
3683637026
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
3683737027
3683837028
#endif
3683937029
36840
-#endif /* !defined(_HWTIME_H_) */
37030
+#endif /* !defined(SQLITE_HWTIME_H) */
3684137031
3684237032
/************** End of hwtime.h **********************************************/
3684337033
/************** Continuing where we left off in os_common.h ******************/
3684437034
3684537035
static sqlite_uint64 g_start;
@@ -37175,10 +37365,21 @@
3717537365
sqlite3_int64 mmapSize; /* Usable size of mapped region */
3717637366
sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */
3717737367
sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */
3717837368
#endif
3717937369
};
37370
+
37371
+/*
37372
+** The winVfsAppData structure is used for the pAppData member for all of the
37373
+** Win32 VFS variants.
37374
+*/
37375
+typedef struct winVfsAppData winVfsAppData;
37376
+struct winVfsAppData {
37377
+ const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */
37378
+ void *pAppData; /* The extra pAppData, if any. */
37379
+ BOOL bNoLock; /* Non-zero if locking is disabled. */
37380
+};
3718037381
3718137382
/*
3718237383
** Allowed values for winFile.ctrlFlags
3718337384
*/
3718437385
#define WINFILE_RDONLY 0x02 /* Connection is read only */
@@ -39497,11 +39698,16 @@
3949739698
rc = osCloseHandle(pFile->h);
3949839699
/* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
3949939700
}while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
3950039701
#if SQLITE_OS_WINCE
3950139702
#define WINCE_DELETION_ATTEMPTS 3
39502
- winceDestroyLock(pFile);
39703
+ {
39704
+ winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;
39705
+ if( pAppData==NULL || !pAppData->bNoLock ){
39706
+ winceDestroyLock(pFile);
39707
+ }
39708
+ }
3950339709
if( pFile->zDeleteOnClose ){
3950439710
int cnt = 0;
3950539711
while(
3950639712
osDeleteFileW(pFile->zDeleteOnClose)==0
3950739713
&& osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
@@ -40229,10 +40435,48 @@
4022940435
OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
4023040436
pFile->h, pFile->locktype, sqlite3ErrName(rc)));
4023140437
return rc;
4023240438
}
4023340439
40440
+/******************************************************************************
40441
+****************************** No-op Locking **********************************
40442
+**
40443
+** Of the various locking implementations available, this is by far the
40444
+** simplest: locking is ignored. No attempt is made to lock the database
40445
+** file for reading or writing.
40446
+**
40447
+** This locking mode is appropriate for use on read-only databases
40448
+** (ex: databases that are burned into CD-ROM, for example.) It can
40449
+** also be used if the application employs some external mechanism to
40450
+** prevent simultaneous access of the same database by two or more
40451
+** database connections. But there is a serious risk of database
40452
+** corruption if this locking mode is used in situations where multiple
40453
+** database connections are accessing the same database file at the same
40454
+** time and one or more of those connections are writing.
40455
+*/
40456
+
40457
+static int winNolockLock(sqlite3_file *id, int locktype){
40458
+ UNUSED_PARAMETER(id);
40459
+ UNUSED_PARAMETER(locktype);
40460
+ return SQLITE_OK;
40461
+}
40462
+
40463
+static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){
40464
+ UNUSED_PARAMETER(id);
40465
+ UNUSED_PARAMETER(pResOut);
40466
+ return SQLITE_OK;
40467
+}
40468
+
40469
+static int winNolockUnlock(sqlite3_file *id, int locktype){
40470
+ UNUSED_PARAMETER(id);
40471
+ UNUSED_PARAMETER(locktype);
40472
+ return SQLITE_OK;
40473
+}
40474
+
40475
+/******************* End of the no-op lock implementation *********************
40476
+******************************************************************************/
40477
+
4023440478
/*
4023540479
** If *pArg is initially negative then this is a query. Set *pArg to
4023640480
** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
4023740481
**
4023840482
** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
@@ -40507,16 +40751,16 @@
4050740751
#define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
4050840752
4050940753
/*
4051040754
** Apply advisory locks for all n bytes beginning at ofst.
4051140755
*/
40512
-#define _SHM_UNLCK 1
40513
-#define _SHM_RDLCK 2
40514
-#define _SHM_WRLCK 3
40756
+#define WINSHM_UNLCK 1
40757
+#define WINSHM_RDLCK 2
40758
+#define WINSHM_WRLCK 3
4051540759
static int winShmSystemLock(
4051640760
winShmNode *pFile, /* Apply locks to this open shared-memory segment */
40517
- int lockType, /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */
40761
+ int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */
4051840762
int ofst, /* Offset to first byte to be locked/unlocked */
4051940763
int nByte /* Number of bytes to lock or unlock */
4052040764
){
4052140765
int rc = 0; /* Result code form Lock/UnlockFileEx() */
4052240766
@@ -40525,16 +40769,16 @@
4052540769
4052640770
OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
4052740771
pFile->hFile.h, lockType, ofst, nByte));
4052840772
4052940773
/* Release/Acquire the system-level lock */
40530
- if( lockType==_SHM_UNLCK ){
40774
+ if( lockType==WINSHM_UNLCK ){
4053140775
rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
4053240776
}else{
4053340777
/* Initialize the locking parameters */
4053440778
DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
40535
- if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
40779
+ if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
4053640780
rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
4053740781
}
4053840782
4053940783
if( rc!= 0 ){
4054040784
rc = SQLITE_OK;
@@ -40542,11 +40786,11 @@
4054240786
pFile->lastErrno = osGetLastError();
4054340787
rc = SQLITE_BUSY;
4054440788
}
4054540789
4054640790
OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
40547
- pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" :
40791
+ pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" :
4054840792
"winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
4054940793
4055040794
return rc;
4055140795
}
4055240796
@@ -40670,20 +40914,20 @@
4067040914
}
4067140915
4067240916
/* Check to see if another process is holding the dead-man switch.
4067340917
** If not, truncate the file to zero length.
4067440918
*/
40675
- if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
40919
+ if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
4067640920
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
4067740921
if( rc!=SQLITE_OK ){
4067840922
rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
4067940923
"winOpenShm", pDbFd->zPath);
4068040924
}
4068140925
}
4068240926
if( rc==SQLITE_OK ){
40683
- winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40684
- rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
40927
+ winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40928
+ rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);
4068540929
}
4068640930
if( rc ) goto shm_open_err;
4068740931
}
4068840932
4068940933
/* Make the new connection a child of the winShmNode */
@@ -40708,11 +40952,11 @@
4070840952
sqlite3_mutex_leave(pShmNode->mutex);
4070940953
return SQLITE_OK;
4071040954
4071140955
/* Jump here on any error */
4071240956
shm_open_err:
40713
- winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40957
+ winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
4071440958
winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
4071540959
sqlite3_free(p);
4071640960
sqlite3_free(pNew);
4071740961
winShmLeaveMutex();
4071840962
return rc;
@@ -40797,11 +41041,11 @@
4079741041
allMask |= pX->sharedMask;
4079841042
}
4079941043
4080041044
/* Unlock the system-level locks */
4080141045
if( (mask & allMask)==0 ){
40802
- rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n);
41046
+ rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);
4080341047
}else{
4080441048
rc = SQLITE_OK;
4080541049
}
4080641050
4080741051
/* Undo the local locks */
@@ -40825,11 +41069,11 @@
4082541069
}
4082641070
4082741071
/* Get shared locks at the system level, if necessary */
4082841072
if( rc==SQLITE_OK ){
4082941073
if( (allShared & mask)==0 ){
40830
- rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n);
41074
+ rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);
4083141075
}else{
4083241076
rc = SQLITE_OK;
4083341077
}
4083441078
}
4083541079
@@ -40850,11 +41094,11 @@
4085041094
4085141095
/* Get the exclusive locks at the system level. Then if successful
4085241096
** also mark the local connection as being locked.
4085341097
*/
4085441098
if( rc==SQLITE_OK ){
40855
- rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
41099
+ rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);
4085641100
if( rc==SQLITE_OK ){
4085741101
assert( (p->sharedMask & mask)==0 );
4085841102
p->exclMask |= mask;
4085941103
}
4086041104
}
@@ -41292,10 +41536,48 @@
4129241536
winShmBarrier, /* xShmBarrier */
4129341537
winShmUnmap, /* xShmUnmap */
4129441538
winFetch, /* xFetch */
4129541539
winUnfetch /* xUnfetch */
4129641540
};
41541
+
41542
+/*
41543
+** This vector defines all the methods that can operate on an
41544
+** sqlite3_file for win32 without performing any locking.
41545
+*/
41546
+static const sqlite3_io_methods winIoNolockMethod = {
41547
+ 3, /* iVersion */
41548
+ winClose, /* xClose */
41549
+ winRead, /* xRead */
41550
+ winWrite, /* xWrite */
41551
+ winTruncate, /* xTruncate */
41552
+ winSync, /* xSync */
41553
+ winFileSize, /* xFileSize */
41554
+ winNolockLock, /* xLock */
41555
+ winNolockUnlock, /* xUnlock */
41556
+ winNolockCheckReservedLock, /* xCheckReservedLock */
41557
+ winFileControl, /* xFileControl */
41558
+ winSectorSize, /* xSectorSize */
41559
+ winDeviceCharacteristics, /* xDeviceCharacteristics */
41560
+ winShmMap, /* xShmMap */
41561
+ winShmLock, /* xShmLock */
41562
+ winShmBarrier, /* xShmBarrier */
41563
+ winShmUnmap, /* xShmUnmap */
41564
+ winFetch, /* xFetch */
41565
+ winUnfetch /* xUnfetch */
41566
+};
41567
+
41568
+static winVfsAppData winAppData = {
41569
+ &winIoMethod, /* pMethod */
41570
+ 0, /* pAppData */
41571
+ 0 /* bNoLock */
41572
+};
41573
+
41574
+static winVfsAppData winNolockAppData = {
41575
+ &winIoNolockMethod, /* pMethod */
41576
+ 0, /* pAppData */
41577
+ 1 /* bNoLock */
41578
+};
4129741579
4129841580
/****************************************************************************
4129941581
**************************** sqlite3_vfs methods ****************************
4130041582
**
4130141583
** This division contains the implementation of methods on the
@@ -41625,11 +41907,11 @@
4162541907
4162641908
/*
4162741909
** Open a file.
4162841910
*/
4162941911
static int winOpen(
41630
- sqlite3_vfs *pVfs, /* Used to get maximum path name length */
41912
+ sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
4163141913
const char *zName, /* Name of the file (UTF-8) */
4163241914
sqlite3_file *id, /* Write the SQLite file handle here */
4163341915
int flags, /* Open mode flags */
4163441916
int *pOutFlags /* Status return flags */
4163541917
){
@@ -41640,10 +41922,11 @@
4164041922
DWORD dwCreationDisposition;
4164141923
DWORD dwFlagsAndAttributes = 0;
4164241924
#if SQLITE_OS_WINCE
4164341925
int isTemp = 0;
4164441926
#endif
41927
+ winVfsAppData *pAppData;
4164541928
winFile *pFile = (winFile*)id;
4164641929
void *zConverted; /* Filename in OS encoding */
4164741930
const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
4164841931
int cnt = 0;
4164941932
@@ -41861,19 +42144,24 @@
4186142144
4186242145
OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
4186342146
"rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
4186442147
*pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
4186542148
42149
+ pAppData = (winVfsAppData*)pVfs->pAppData;
42150
+
4186642151
#if SQLITE_OS_WINCE
41867
- if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
41868
- && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
41869
- ){
41870
- osCloseHandle(h);
41871
- sqlite3_free(zConverted);
41872
- sqlite3_free(zTmpname);
41873
- OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
41874
- return rc;
42152
+ {
42153
+ if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
42154
+ && ((pAppData==NULL) || !pAppData->bNoLock)
42155
+ && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
42156
+ ){
42157
+ osCloseHandle(h);
42158
+ sqlite3_free(zConverted);
42159
+ sqlite3_free(zTmpname);
42160
+ OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
42161
+ return rc;
42162
+ }
4187542163
}
4187642164
if( isTemp ){
4187742165
pFile->zDeleteOnClose = zConverted;
4187842166
}else
4187942167
#endif
@@ -41880,11 +42168,11 @@
4188042168
{
4188142169
sqlite3_free(zConverted);
4188242170
}
4188342171
4188442172
sqlite3_free(zTmpname);
41885
- pFile->pMethod = &winIoMethod;
42173
+ pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;
4188642174
pFile->pVfs = pVfs;
4188742175
pFile->h = h;
4188842176
if( isReadonly ){
4188942177
pFile->ctrlFlags |= WINFILE_RDONLY;
4189042178
}
@@ -42155,10 +42443,22 @@
4215542443
sqlite3_vfs *pVfs, /* Pointer to vfs object */
4215642444
const char *zRelative, /* Possibly relative input path */
4215742445
int nFull, /* Size of output buffer in bytes */
4215842446
char *zFull /* Output buffer */
4215942447
){
42448
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42449
+ DWORD nByte;
42450
+ void *zConverted;
42451
+ char *zOut;
42452
+#endif
42453
+
42454
+ /* If this path name begins with "/X:", where "X" is any alphabetic
42455
+ ** character, discard the initial "/" from the pathname.
42456
+ */
42457
+ if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42458
+ zRelative++;
42459
+ }
4216042460
4216142461
#if defined(__CYGWIN__)
4216242462
SimulateIOError( return SQLITE_ERROR );
4216342463
UNUSED_PARAMETER(nFull);
4216442464
assert( nFull>=pVfs->mxPathname );
@@ -42233,21 +42533,10 @@
4223342533
}
4223442534
return SQLITE_OK;
4223542535
#endif
4223642536
4223742537
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42238
- DWORD nByte;
42239
- void *zConverted;
42240
- char *zOut;
42241
-
42242
- /* If this path name begins with "/X:", where "X" is any alphabetic
42243
- ** character, discard the initial "/" from the pathname.
42244
- */
42245
- if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42246
- zRelative++;
42247
- }
42248
-
4224942538
/* It's odd to simulate an io-error here, but really this is just
4225042539
** using the io-error infrastructure to test that SQLite handles this
4225142540
** function failing. This function could fail if, for example, the
4225242541
** current working directory has been unlinked.
4225342542
*/
@@ -42602,57 +42891,107 @@
4260242891
/*
4260342892
** Initialize and deinitialize the operating system interface.
4260442893
*/
4260542894
SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
4260642895
static sqlite3_vfs winVfs = {
42607
- 3, /* iVersion */
42608
- sizeof(winFile), /* szOsFile */
42896
+ 3, /* iVersion */
42897
+ sizeof(winFile), /* szOsFile */
4260942898
SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42610
- 0, /* pNext */
42611
- "win32", /* zName */
42612
- 0, /* pAppData */
42613
- winOpen, /* xOpen */
42614
- winDelete, /* xDelete */
42615
- winAccess, /* xAccess */
42616
- winFullPathname, /* xFullPathname */
42617
- winDlOpen, /* xDlOpen */
42618
- winDlError, /* xDlError */
42619
- winDlSym, /* xDlSym */
42620
- winDlClose, /* xDlClose */
42621
- winRandomness, /* xRandomness */
42622
- winSleep, /* xSleep */
42623
- winCurrentTime, /* xCurrentTime */
42624
- winGetLastError, /* xGetLastError */
42625
- winCurrentTimeInt64, /* xCurrentTimeInt64 */
42626
- winSetSystemCall, /* xSetSystemCall */
42627
- winGetSystemCall, /* xGetSystemCall */
42628
- winNextSystemCall, /* xNextSystemCall */
42899
+ 0, /* pNext */
42900
+ "win32", /* zName */
42901
+ &winAppData, /* pAppData */
42902
+ winOpen, /* xOpen */
42903
+ winDelete, /* xDelete */
42904
+ winAccess, /* xAccess */
42905
+ winFullPathname, /* xFullPathname */
42906
+ winDlOpen, /* xDlOpen */
42907
+ winDlError, /* xDlError */
42908
+ winDlSym, /* xDlSym */
42909
+ winDlClose, /* xDlClose */
42910
+ winRandomness, /* xRandomness */
42911
+ winSleep, /* xSleep */
42912
+ winCurrentTime, /* xCurrentTime */
42913
+ winGetLastError, /* xGetLastError */
42914
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42915
+ winSetSystemCall, /* xSetSystemCall */
42916
+ winGetSystemCall, /* xGetSystemCall */
42917
+ winNextSystemCall, /* xNextSystemCall */
4262942918
};
4263042919
#if defined(SQLITE_WIN32_HAS_WIDE)
4263142920
static sqlite3_vfs winLongPathVfs = {
42632
- 3, /* iVersion */
42633
- sizeof(winFile), /* szOsFile */
42921
+ 3, /* iVersion */
42922
+ sizeof(winFile), /* szOsFile */
42923
+ SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42924
+ 0, /* pNext */
42925
+ "win32-longpath", /* zName */
42926
+ &winAppData, /* pAppData */
42927
+ winOpen, /* xOpen */
42928
+ winDelete, /* xDelete */
42929
+ winAccess, /* xAccess */
42930
+ winFullPathname, /* xFullPathname */
42931
+ winDlOpen, /* xDlOpen */
42932
+ winDlError, /* xDlError */
42933
+ winDlSym, /* xDlSym */
42934
+ winDlClose, /* xDlClose */
42935
+ winRandomness, /* xRandomness */
42936
+ winSleep, /* xSleep */
42937
+ winCurrentTime, /* xCurrentTime */
42938
+ winGetLastError, /* xGetLastError */
42939
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42940
+ winSetSystemCall, /* xSetSystemCall */
42941
+ winGetSystemCall, /* xGetSystemCall */
42942
+ winNextSystemCall, /* xNextSystemCall */
42943
+ };
42944
+#endif
42945
+ static sqlite3_vfs winNolockVfs = {
42946
+ 3, /* iVersion */
42947
+ sizeof(winFile), /* szOsFile */
42948
+ SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42949
+ 0, /* pNext */
42950
+ "win32-none", /* zName */
42951
+ &winNolockAppData, /* pAppData */
42952
+ winOpen, /* xOpen */
42953
+ winDelete, /* xDelete */
42954
+ winAccess, /* xAccess */
42955
+ winFullPathname, /* xFullPathname */
42956
+ winDlOpen, /* xDlOpen */
42957
+ winDlError, /* xDlError */
42958
+ winDlSym, /* xDlSym */
42959
+ winDlClose, /* xDlClose */
42960
+ winRandomness, /* xRandomness */
42961
+ winSleep, /* xSleep */
42962
+ winCurrentTime, /* xCurrentTime */
42963
+ winGetLastError, /* xGetLastError */
42964
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42965
+ winSetSystemCall, /* xSetSystemCall */
42966
+ winGetSystemCall, /* xGetSystemCall */
42967
+ winNextSystemCall, /* xNextSystemCall */
42968
+ };
42969
+#if defined(SQLITE_WIN32_HAS_WIDE)
42970
+ static sqlite3_vfs winLongPathNolockVfs = {
42971
+ 3, /* iVersion */
42972
+ sizeof(winFile), /* szOsFile */
4263442973
SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42635
- 0, /* pNext */
42636
- "win32-longpath", /* zName */
42637
- 0, /* pAppData */
42638
- winOpen, /* xOpen */
42639
- winDelete, /* xDelete */
42640
- winAccess, /* xAccess */
42641
- winFullPathname, /* xFullPathname */
42642
- winDlOpen, /* xDlOpen */
42643
- winDlError, /* xDlError */
42644
- winDlSym, /* xDlSym */
42645
- winDlClose, /* xDlClose */
42646
- winRandomness, /* xRandomness */
42647
- winSleep, /* xSleep */
42648
- winCurrentTime, /* xCurrentTime */
42649
- winGetLastError, /* xGetLastError */
42650
- winCurrentTimeInt64, /* xCurrentTimeInt64 */
42651
- winSetSystemCall, /* xSetSystemCall */
42652
- winGetSystemCall, /* xGetSystemCall */
42653
- winNextSystemCall, /* xNextSystemCall */
42974
+ 0, /* pNext */
42975
+ "win32-longpath-none", /* zName */
42976
+ &winNolockAppData, /* pAppData */
42977
+ winOpen, /* xOpen */
42978
+ winDelete, /* xDelete */
42979
+ winAccess, /* xAccess */
42980
+ winFullPathname, /* xFullPathname */
42981
+ winDlOpen, /* xDlOpen */
42982
+ winDlError, /* xDlError */
42983
+ winDlSym, /* xDlSym */
42984
+ winDlClose, /* xDlClose */
42985
+ winRandomness, /* xRandomness */
42986
+ winSleep, /* xSleep */
42987
+ winCurrentTime, /* xCurrentTime */
42988
+ winGetLastError, /* xGetLastError */
42989
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42990
+ winSetSystemCall, /* xSetSystemCall */
42991
+ winGetSystemCall, /* xGetSystemCall */
42992
+ winNextSystemCall, /* xNextSystemCall */
4265442993
};
4265542994
#endif
4265642995
4265742996
/* Double-check that the aSyscall[] array has been constructed
4265842997
** correctly. See ticket [bb3a86e890c8e96ab] */
@@ -42671,10 +43010,16 @@
4267143010
sqlite3_vfs_register(&winVfs, 1);
4267243011
4267343012
#if defined(SQLITE_WIN32_HAS_WIDE)
4267443013
sqlite3_vfs_register(&winLongPathVfs, 0);
4267543014
#endif
43015
+
43016
+ sqlite3_vfs_register(&winNolockVfs, 0);
43017
+
43018
+#if defined(SQLITE_WIN32_HAS_WIDE)
43019
+ sqlite3_vfs_register(&winLongPathNolockVfs, 0);
43020
+#endif
4267643021
4267743022
return SQLITE_OK;
4267843023
}
4267943024
4268043025
SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
@@ -43792,32 +44137,34 @@
4379244137
sqlite3PcacheTruncate(pCache, 0);
4379344138
}
4379444139
4379544140
/*
4379644141
** Merge two lists of pages connected by pDirty and in pgno order.
43797
-** Do not both fixing the pDirtyPrev pointers.
44142
+** Do not bother fixing the pDirtyPrev pointers.
4379844143
*/
4379944144
static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
4380044145
PgHdr result, *pTail;
4380144146
pTail = &result;
43802
- while( pA && pB ){
44147
+ assert( pA!=0 && pB!=0 );
44148
+ for(;;){
4380344149
if( pA->pgno<pB->pgno ){
4380444150
pTail->pDirty = pA;
4380544151
pTail = pA;
4380644152
pA = pA->pDirty;
44153
+ if( pA==0 ){
44154
+ pTail->pDirty = pB;
44155
+ break;
44156
+ }
4380744157
}else{
4380844158
pTail->pDirty = pB;
4380944159
pTail = pB;
4381044160
pB = pB->pDirty;
43811
- }
43812
- }
43813
- if( pA ){
43814
- pTail->pDirty = pA;
43815
- }else if( pB ){
43816
- pTail->pDirty = pB;
43817
- }else{
43818
- pTail->pDirty = 0;
44161
+ if( pB==0 ){
44162
+ pTail->pDirty = pA;
44163
+ break;
44164
+ }
44165
+ }
4381944166
}
4382044167
return result.pDirty;
4382144168
}
4382244169
4382344170
/*
@@ -43855,11 +44202,12 @@
4385544202
a[i] = pcacheMergeDirtyList(a[i], p);
4385644203
}
4385744204
}
4385844205
p = a[0];
4385944206
for(i=1; i<N_SORT_BUCKET; i++){
43860
- p = pcacheMergeDirtyList(p, a[i]);
44207
+ if( a[i]==0 ) continue;
44208
+ p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
4386144209
}
4386244210
return p;
4386344211
}
4386444212
4386544213
/*
@@ -45460,31 +45808,29 @@
4546045808
){
4546145809
struct RowSetEntry head;
4546245810
struct RowSetEntry *pTail;
4546345811
4546445812
pTail = &head;
45465
- while( pA && pB ){
45813
+ assert( pA!=0 && pB!=0 );
45814
+ for(;;){
4546645815
assert( pA->pRight==0 || pA->v<=pA->pRight->v );
4546745816
assert( pB->pRight==0 || pB->v<=pB->pRight->v );
45468
- if( pA->v<pB->v ){
45469
- pTail->pRight = pA;
45817
+ if( pA->v<=pB->v ){
45818
+ if( pA->v<pB->v ) pTail = pTail->pRight = pA;
4547045819
pA = pA->pRight;
45471
- pTail = pTail->pRight;
45472
- }else if( pB->v<pA->v ){
45473
- pTail->pRight = pB;
45820
+ if( pA==0 ){
45821
+ pTail->pRight = pB;
45822
+ break;
45823
+ }
45824
+ }else{
45825
+ pTail = pTail->pRight = pB;
4547445826
pB = pB->pRight;
45475
- pTail = pTail->pRight;
45476
- }else{
45477
- pA = pA->pRight;
45478
- }
45479
- }
45480
- if( pA ){
45481
- assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45482
- pTail->pRight = pA;
45483
- }else{
45484
- assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v );
45485
- pTail->pRight = pB;
45827
+ if( pB==0 ){
45828
+ pTail->pRight = pA;
45829
+ break;
45830
+ }
45831
+ }
4548645832
}
4548745833
return head.pRight;
4548845834
}
4548945835
4549045836
/*
@@ -45504,13 +45850,14 @@
4550445850
aBucket[i] = 0;
4550545851
}
4550645852
aBucket[i] = pIn;
4550745853
pIn = pNext;
4550845854
}
45509
- pIn = 0;
45510
- for(i=0; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45511
- pIn = rowSetEntryMerge(pIn, aBucket[i]);
45855
+ pIn = aBucket[0];
45856
+ for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45857
+ if( aBucket[i]==0 ) continue;
45858
+ pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];
4551245859
}
4551345860
return pIn;
4551445861
}
4551545862
4551645863
@@ -45758,12 +46105,12 @@
4575846105
** This header file defines the interface to the write-ahead logging
4575946106
** system. Refer to the comments below and the header comment attached to
4576046107
** the implementation of each function in log.c for further details.
4576146108
*/
4576246109
45763
-#ifndef _WAL_H_
45764
-#define _WAL_H_
46110
+#ifndef SQLITE_WAL_H
46111
+#define SQLITE_WAL_H
4576546112
4576646113
/* #include "sqliteInt.h" */
4576746114
4576846115
/* Additional values that can be added to the sync_flags argument of
4576946116
** sqlite3WalFrames():
@@ -45887,11 +46234,11 @@
4588746234
4588846235
/* Return the sqlite3_file object for the WAL file */
4588946236
SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);
4589046237
4589146238
#endif /* ifndef SQLITE_OMIT_WAL */
45892
-#endif /* _WAL_H_ */
46239
+#endif /* SQLITE_WAL_H */
4589346240
4589446241
/************** End of wal.h *************************************************/
4589546242
/************** Continuing where we left off in pager.c **********************/
4589646243
4589746244
@@ -53027,20 +53374,10 @@
5302753374
*/
5302853375
SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
5302953376
return &pPager->pBackup;
5303053377
}
5303153378
53032
-#ifndef SQLITE_OMIT_VACUUM
53033
-/*
53034
-** Unless this is an in-memory or temporary database, clear the pager cache.
53035
-*/
53036
-SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
53037
- assert( MEMDB==0 || pPager->tempFile );
53038
- if( pPager->tempFile==0 ) pager_reset(pPager);
53039
-}
53040
-#endif
53041
-
5304253379
#ifndef SQLITE_OMIT_WAL
5304353380
/*
5304453381
** This function is called when the user invokes "PRAGMA wal_checkpoint",
5304553382
** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
5304653383
** or wal_blocking_checkpoint() API functions.
@@ -56378,20 +56715,25 @@
5637856715
** boundary is crossed. Only the part of the WAL prior to the last
5637956716
** sector boundary is synced; the part of the last frame that extends
5638056717
** past the sector boundary is written after the sync.
5638156718
*/
5638256719
if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
56720
+ int bSync = 1;
5638356721
if( pWal->padToSectorBoundary ){
5638456722
int sectorSize = sqlite3SectorSize(pWal->pWalFd);
5638556723
w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
56724
+ bSync = (w.iSyncPoint==iOffset);
56725
+ testcase( bSync );
5638656726
while( iOffset<w.iSyncPoint ){
5638756727
rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
5638856728
if( rc ) return rc;
5638956729
iOffset += szFrame;
5639056730
nExtra++;
5639156731
}
56392
- }else{
56732
+ }
56733
+ if( bSync ){
56734
+ assert( rc==SQLITE_OK );
5639356735
rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);
5639456736
}
5639556737
}
5639656738
5639756739
/* If this frame set completes the first transaction in the WAL and
@@ -58174,10 +58516,19 @@
5817458516
*/
5817558517
#ifdef SQLITE_DEBUG
5817658518
static int cursorHoldsMutex(BtCursor *p){
5817758519
return sqlite3_mutex_held(p->pBt->mutex);
5817858520
}
58521
+
58522
+/* Verify that the cursor and the BtShared agree about what is the current
58523
+** database connetion. This is important in shared-cache mode. If the database
58524
+** connection pointers get out-of-sync, it is possible for routines like
58525
+** btreeInitPage() to reference an stale connection pointer that references a
58526
+** a connection that has already closed. This routine is used inside assert()
58527
+** statements only and for the purpose of double-checking that the btree code
58528
+** does keep the database connection pointers up-to-date.
58529
+*/
5817958530
static int cursorOwnsBtShared(BtCursor *p){
5818058531
assert( cursorHoldsMutex(p) );
5818158532
return (p->pBtree->db==p->pBt->db);
5818258533
}
5818358534
#endif
@@ -58333,25 +58684,23 @@
5833358684
** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
5833458685
** set to point to a malloced buffer pCur->nKey bytes in size containing
5833558686
** the key.
5833658687
*/
5833758688
static int saveCursorKey(BtCursor *pCur){
58338
- int rc;
58689
+ int rc = SQLITE_OK;
5833958690
assert( CURSOR_VALID==pCur->eState );
5834058691
assert( 0==pCur->pKey );
5834158692
assert( cursorHoldsMutex(pCur) );
5834258693
58343
- rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
58344
- assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
58345
-
58346
- /* If this is an intKey table, then the above call to BtreeKeySize()
58347
- ** stores the integer key in pCur->nKey. In this case this value is
58348
- ** all that is required. Otherwise, if pCur is not open on an intKey
58349
- ** table, then malloc space for and store the pCur->nKey bytes of key
58350
- ** data. */
58351
- if( 0==pCur->curIntKey ){
58352
- void *pKey = sqlite3Malloc( pCur->nKey );
58694
+ if( pCur->curIntKey ){
58695
+ /* Only the rowid is required for a table btree */
58696
+ pCur->nKey = sqlite3BtreeIntegerKey(pCur);
58697
+ }else{
58698
+ /* For an index btree, save the complete key content */
58699
+ void *pKey;
58700
+ pCur->nKey = sqlite3BtreePayloadSize(pCur);
58701
+ pKey = sqlite3Malloc( pCur->nKey );
5835358702
if( pKey ){
5835458703
rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
5835558704
if( rc==SQLITE_OK ){
5835658705
pCur->pKey = pKey;
5835758706
}else{
@@ -60054,13 +60403,13 @@
6005460403
assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
6005560404
6005660405
#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
6005760406
/* Add the new BtShared object to the linked list sharable BtShareds.
6005860407
*/
60408
+ pBt->nRef = 1;
6005960409
if( p->sharable ){
6006060410
MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
60061
- pBt->nRef = 1;
6006260411
MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
6006360412
if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
6006460413
pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
6006560414
if( pBt->mutex==0 ){
6006660415
rc = SQLITE_NOMEM_BKPT;
@@ -60127,10 +60476,11 @@
6012760476
}
6012860477
if( mutexOpen ){
6012960478
assert( sqlite3_mutex_held(mutexOpen) );
6013060479
sqlite3_mutex_leave(mutexOpen);
6013160480
}
60481
+ assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );
6013260482
return rc;
6013360483
}
6013460484
6013560485
/*
6013660486
** Decrement the BtShared.nRef counter. When it reaches zero,
@@ -61986,50 +62336,37 @@
6198662336
return pCur && pCur->eState==CURSOR_VALID;
6198762337
}
6198862338
#endif /* NDEBUG */
6198962339
6199062340
/*
61991
-** Set *pSize to the size of the buffer needed to hold the value of
61992
-** the key for the current entry. If the cursor is not pointing
61993
-** to a valid entry, *pSize is set to 0.
61994
-**
61995
-** For a table with the INTKEY flag set, this routine returns the key
61996
-** itself, not the number of bytes in the key.
61997
-**
61998
-** The caller must position the cursor prior to invoking this routine.
61999
-**
62000
-** This routine cannot fail. It always returns SQLITE_OK.
62341
+** Return the value of the integer key or "rowid" for a table btree.
62342
+** This routine is only valid for a cursor that is pointing into a
62343
+** ordinary table btree. If the cursor points to an index btree or
62344
+** is invalid, the result of this routine is undefined.
6200162345
*/
62002
-SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
62346
+SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
6200362347
assert( cursorHoldsMutex(pCur) );
6200462348
assert( pCur->eState==CURSOR_VALID );
62349
+ assert( pCur->curIntKey );
6200562350
getCellInfo(pCur);
62006
- *pSize = pCur->info.nKey;
62007
- return SQLITE_OK;
62351
+ return pCur->info.nKey;
6200862352
}
6200962353
6201062354
/*
62011
-** Set *pSize to the number of bytes of data in the entry the
62012
-** cursor currently points to.
62355
+** Return the number of bytes of payload for the entry that pCur is
62356
+** currently pointing to. For table btrees, this will be the amount
62357
+** of data. For index btrees, this will be the size of the key.
6201362358
**
6201462359
** The caller must guarantee that the cursor is pointing to a non-NULL
6201562360
** valid entry. In other words, the calling procedure must guarantee
6201662361
** that the cursor has Cursor.eState==CURSOR_VALID.
62017
-**
62018
-** Failure is not possible. This function always returns SQLITE_OK.
62019
-** It might just as well be a procedure (returning void) but we continue
62020
-** to return an integer result code for historical reasons.
6202162362
*/
62022
-SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
62023
- assert( cursorOwnsBtShared(pCur) );
62363
+SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){
62364
+ assert( cursorHoldsMutex(pCur) );
6202462365
assert( pCur->eState==CURSOR_VALID );
62025
- assert( pCur->iPage>=0 );
62026
- assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
62027
- assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
6202862366
getCellInfo(pCur);
62029
- *pSize = pCur->info.nPayload;
62030
- return SQLITE_OK;
62367
+ return pCur->info.nPayload;
6203162368
}
6203262369
6203362370
/*
6203462371
** Given the page number of an overflow page in the database (parameter
6203562372
** ovfl), this function finds the page number of the next page in the
@@ -62467,14 +62804,11 @@
6246762804
** this routine.
6246862805
**
6246962806
** These routines is used to get quick access to key and data
6247062807
** in the common case where no overflow pages are used.
6247162808
*/
62472
-SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
62473
- return fetchPayload(pCur, pAmt);
62474
-}
62475
-SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){
62809
+SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){
6247662810
return fetchPayload(pCur, pAmt);
6247762811
}
6247862812
6247962813
6248062814
/*
@@ -62803,15 +63137,16 @@
6280363137
6280463138
assert( cursorOwnsBtShared(pCur) );
6280563139
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
6280663140
assert( pRes );
6280763141
assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
63142
+ assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
6280863143
6280963144
/* If the cursor is already positioned at the point we are trying
6281063145
** to move to, then just return without doing any work */
62811
- if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
62812
- && pCur->curIntKey
63146
+ if( pIdxKey==0
63147
+ && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
6281363148
){
6281463149
if( pCur->info.nKey==intKey ){
6281563150
*pRes = 0;
6281663151
return SQLITE_OK;
6281763152
}
@@ -63796,13 +64131,11 @@
6379664131
** later.
6379764132
*/
6379864133
static int fillInCell(
6379964134
MemPage *pPage, /* The page that contains the cell */
6380064135
unsigned char *pCell, /* Complete text of the cell */
63801
- const void *pKey, i64 nKey, /* The key */
63802
- const void *pData,int nData, /* The data */
63803
- int nZero, /* Extra zero bytes to append to pData */
64136
+ const BtreePayload *pX, /* Payload with which to construct the cell */
6380464137
int *pnSize /* Write cell size here */
6380564138
){
6380664139
int nPayload;
6380764140
const u8 *pSrc;
6380864141
int nSrc, n, rc;
@@ -63822,30 +64155,27 @@
6382264155
assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
6382364156
|| sqlite3PagerIswriteable(pPage->pDbPage) );
6382464157
6382564158
/* Fill in the header. */
6382664159
nHeader = pPage->childPtrSize;
63827
- nPayload = nData + nZero;
63828
- if( pPage->intKeyLeaf ){
63829
- nHeader += putVarint32(&pCell[nHeader], nPayload);
63830
- }else{
63831
- assert( nData==0 );
63832
- assert( nZero==0 );
63833
- }
63834
- nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey);
63835
-
63836
- /* Fill in the payload size */
6383764160
if( pPage->intKey ){
63838
- pSrc = pData;
63839
- nSrc = nData;
63840
- nData = 0;
63841
- }else{
63842
- assert( nKey<=0x7fffffff && pKey!=0 );
63843
- nPayload = (int)nKey;
63844
- pSrc = pKey;
63845
- nSrc = (int)nKey;
63846
- }
64161
+ nPayload = pX->nData + pX->nZero;
64162
+ pSrc = pX->pData;
64163
+ nSrc = pX->nData;
64164
+ assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */
64165
+ nHeader += putVarint32(&pCell[nHeader], nPayload);
64166
+ nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);
64167
+ }else{
64168
+ assert( pX->nData==0 );
64169
+ assert( pX->nZero==0 );
64170
+ assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );
64171
+ nSrc = nPayload = (int)pX->nKey;
64172
+ pSrc = pX->pKey;
64173
+ nHeader += putVarint32(&pCell[nHeader], nPayload);
64174
+ }
64175
+
64176
+ /* Fill in the payload */
6384764177
if( nPayload<=pPage->maxLocal ){
6384864178
n = nHeader + nPayload;
6384964179
testcase( n==3 );
6385064180
testcase( n==4 );
6385164181
if( n<4 ) n = 4;
@@ -63879,11 +64209,11 @@
6387964209
#if SQLITE_DEBUG
6388064210
{
6388164211
CellInfo info;
6388264212
pPage->xParseCell(pPage, pCell, &info);
6388364213
assert( nHeader==(int)(info.pPayload - pCell) );
63884
- assert( info.nKey==nKey );
64214
+ assert( info.nKey==pX->nKey );
6388564215
assert( *pnSize == info.nSize );
6388664216
assert( spaceLeft == info.nLocal );
6388764217
}
6388864218
#endif
6388964219
@@ -63964,14 +64294,10 @@
6396464294
nPayload -= n;
6396564295
pPayload += n;
6396664296
pSrc += n;
6396764297
nSrc -= n;
6396864298
spaceLeft -= n;
63969
- if( nSrc==0 ){
63970
- nSrc = nData;
63971
- pSrc = pData;
63972
- }
6397364299
}
6397464300
releasePage(pToRelease);
6397564301
return SQLITE_OK;
6397664302
}
6397764303
@@ -64034,10 +64360,12 @@
6403464360
** pTemp is not null. Regardless of pTemp, allocate a new entry
6403564361
** in pPage->apOvfl[] and make it point to the cell content (either
6403664362
** in pTemp or the original pCell) and also record its index.
6403764363
** Allocating a new entry in pPage->aCell[] implies that
6403864364
** pPage->nOverflow is incremented.
64365
+**
64366
+** *pRC must be SQLITE_OK when this routine is called.
6403964367
*/
6404064368
static void insertCell(
6404164369
MemPage *pPage, /* Page into which we are copying */
6404264370
int i, /* New cell becomes the i-th cell of the page */
6404364371
u8 *pCell, /* Content of the new cell */
@@ -64049,12 +64377,11 @@
6404964377
int idx = 0; /* Where to write new cell content in data[] */
6405064378
int j; /* Loop counter */
6405164379
u8 *data; /* The content of the whole page */
6405264380
u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
6405364381
64054
- if( *pRC ) return;
64055
-
64382
+ assert( *pRC==SQLITE_OK );
6405664383
assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
6405764384
assert( MX_CELL(pPage->pBt)<=10921 );
6405864385
assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
6405964386
assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
6406064387
assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
@@ -64556,12 +64883,14 @@
6455664883
while( (*(pCell++)&0x80) && pCell<pStop );
6455764884
pStop = &pCell[9];
6455864885
while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );
6455964886
6456064887
/* Insert the new divider cell into pParent. */
64561
- insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64562
- 0, pPage->pgno, &rc);
64888
+ if( rc==SQLITE_OK ){
64889
+ insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64890
+ 0, pPage->pgno, &rc);
64891
+ }
6456364892
6456464893
/* Set the right-child pointer of pParent to point to the new page. */
6456564894
put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
6456664895
6456764896
/* Release the reference to the new page. */
@@ -65077,11 +65406,11 @@
6507765406
do{
6507865407
assert( d<nMaxCells );
6507965408
assert( r<nMaxCells );
6508065409
(void)cachedCellSize(&b, r);
6508165410
if( szRight!=0
65082
- && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){
65411
+ && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){
6508365412
break;
6508465413
}
6508565414
szRight += b.szCell[d] + 2;
6508665415
szLeft -= b.szCell[r] + 2;
6508765416
cntNew[i-1] = r;
@@ -65649,17 +65978,23 @@
6564965978
return rc;
6565065979
}
6565165980
6565265981
6565365982
/*
65654
-** Insert a new record into the BTree. The key is given by (pKey,nKey)
65655
-** and the data is given by (pData,nData). The cursor is used only to
65656
-** define what table the record should be inserted into. The cursor
65657
-** is left pointing at a random location.
65983
+** Insert a new record into the BTree. The content of the new record
65984
+** is described by the pX object. The pCur cursor is used only to
65985
+** define what table the record should be inserted into, and is left
65986
+** pointing at a random location.
6565865987
**
65659
-** For an INTKEY table, only the nKey value of the key is used. pKey is
65660
-** ignored. For a ZERODATA table, the pData and nData are both ignored.
65988
+** For a table btree (used for rowid tables), only the pX.nKey value of
65989
+** the key is used. The pX.pKey value must be NULL. The pX.nKey is the
65990
+** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields
65991
+** hold the content of the row.
65992
+**
65993
+** For an index btree (used for indexes and WITHOUT ROWID tables), the
65994
+** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
65995
+** pX.pData,nData,nZero fields must be zero.
6566165996
**
6566265997
** If the seekResult parameter is non-zero, then a successful call to
6566365998
** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
6566465999
** been performed. seekResult is the search result returned (a negative
6566566000
** number if pCur points at an entry that is smaller than (pKey, nKey), or
@@ -65672,13 +66007,11 @@
6567266007
** point to any entry or to no entry at all and so this function has to seek
6567366008
** the cursor before the new key can be inserted.
6567466009
*/
6567566010
SQLITE_PRIVATE int sqlite3BtreeInsert(
6567666011
BtCursor *pCur, /* Insert data into the table of this cursor */
65677
- const void *pKey, i64 nKey, /* The key of the new record */
65678
- const void *pData, int nData, /* The data of the new record */
65679
- int nZero, /* Number of extra 0 bytes to append to data */
66012
+ const BtreePayload *pX, /* Content of the row to be inserted */
6568066013
int appendBias, /* True if this is likely an append */
6568166014
int seekResult /* Result of prior MovetoUnpacked() call */
6568266015
){
6568366016
int rc;
6568466017
int loc = seekResult; /* -1: before desired location +1: after */
@@ -65704,11 +66037,11 @@
6570466037
/* Assert that the caller has been consistent. If this cursor was opened
6570566038
** expecting an index b-tree, then the caller should be inserting blob
6570666039
** keys with no associated data. If the cursor was opened expecting an
6570766040
** intkey table, the caller should be inserting integer keys with a
6570866041
** blob of associated data. */
65709
- assert( (pKey==0)==(pCur->pKeyInfo==0) );
66042
+ assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );
6571066043
6571166044
/* Save the positions of any other cursors open on this table.
6571266045
**
6571366046
** In some cases, the call to btreeMoveto() below is a no-op. For
6571466047
** example, when inserting data into a table with auto-generated integer
@@ -65723,42 +66056,42 @@
6572366056
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
6572466057
if( rc ) return rc;
6572566058
}
6572666059
6572766060
if( pCur->pKeyInfo==0 ){
65728
- assert( pKey==0 );
66061
+ assert( pX->pKey==0 );
6572966062
/* If this is an insert into a table b-tree, invalidate any incrblob
6573066063
** cursors open on the row being replaced */
65731
- invalidateIncrblobCursors(p, nKey, 0);
66064
+ invalidateIncrblobCursors(p, pX->nKey, 0);
6573266065
6573366066
/* If the cursor is currently on the last row and we are appending a
6573466067
** new row onto the end, set the "loc" to avoid an unnecessary
6573566068
** btreeMoveto() call */
65736
- if( (pCur->curFlags&BTCF_ValidNKey)!=0 && nKey>0
65737
- && pCur->info.nKey==nKey-1 ){
66069
+ if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0
66070
+ && pCur->info.nKey==pX->nKey-1 ){
6573866071
loc = -1;
6573966072
}else if( loc==0 ){
65740
- rc = sqlite3BtreeMovetoUnpacked(pCur, 0, nKey, appendBias, &loc);
66073
+ rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc);
6574166074
if( rc ) return rc;
6574266075
}
6574366076
}else if( loc==0 ){
65744
- rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
66077
+ rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc);
6574566078
if( rc ) return rc;
6574666079
}
6574766080
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
6574866081
6574966082
pPage = pCur->apPage[pCur->iPage];
65750
- assert( pPage->intKey || nKey>=0 );
66083
+ assert( pPage->intKey || pX->nKey>=0 );
6575166084
assert( pPage->leaf || !pPage->intKey );
6575266085
6575366086
TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
65754
- pCur->pgnoRoot, nKey, nData, pPage->pgno,
66087
+ pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,
6575566088
loc==0 ? "overwrite" : "new entry"));
6575666089
assert( pPage->isInit );
6575766090
newCell = pBt->pTmpSpace;
6575866091
assert( newCell!=0 );
65759
- rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew);
66092
+ rc = fillInCell(pPage, newCell, pX, &szNew);
6576066093
if( rc ) goto end_insert;
6576166094
assert( szNew==pPage->xCellSize(pPage, newCell) );
6576266095
assert( szNew <= MX_CELL_SIZE(pBt) );
6576366096
idx = pCur->aiIdx[pCur->iPage];
6576466097
if( loc==0 ){
@@ -65780,10 +66113,11 @@
6578066113
idx = ++pCur->aiIdx[pCur->iPage];
6578166114
}else{
6578266115
assert( pPage->leaf );
6578366116
}
6578466117
insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
66118
+ assert( pPage->nOverflow==0 || rc==SQLITE_OK );
6578566119
assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
6578666120
6578766121
/* If no error has occurred and pPage has an overflow cell, call balance()
6578866122
** to redistribute the cells within the tree. Since balance() may move
6578966123
** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey
@@ -65803,11 +66137,12 @@
6580366137
** entry in the table, and the next row inserted has an integer key
6580466138
** larger than the largest existing key, it is possible to insert the
6580566139
** row without seeking the cursor. This can be a big performance boost.
6580666140
*/
6580766141
pCur->info.nSize = 0;
65808
- if( rc==SQLITE_OK && pPage->nOverflow ){
66142
+ if( pPage->nOverflow ){
66143
+ assert( rc==SQLITE_OK );
6580966144
pCur->curFlags &= ~(BTCF_ValidNKey);
6581066145
rc = balance(pCur);
6581166146
6581266147
/* Must make sure nOverflow is reset to zero even if the balance()
6581366148
** fails. Internal data structure corruption will result otherwise.
@@ -65939,11 +66274,13 @@
6593966274
nCell = pLeaf->xCellSize(pLeaf, pCell);
6594066275
assert( MX_CELL_SIZE(pBt) >= nCell );
6594166276
pTmp = pBt->pTmpSpace;
6594266277
assert( pTmp!=0 );
6594366278
rc = sqlite3PagerWrite(pLeaf->pDbPage);
65944
- insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66279
+ if( rc==SQLITE_OK ){
66280
+ insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66281
+ }
6594566282
dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
6594666283
if( rc ) return rc;
6594766284
}
6594866285
6594966286
/* Balance the tree. If the entry deleted was located on a leaf page,
@@ -67428,10 +67765,20 @@
6742867765
** Return true if the Btree passed as the only argument is sharable.
6742967766
*/
6743067767
SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
6743167768
return p->sharable;
6743267769
}
67770
+
67771
+/*
67772
+** Return the number of connections to the BtShared object accessed by
67773
+** the Btree handle passed as the only argument. For private caches
67774
+** this is always 1. For shared caches it may be 1 or greater.
67775
+*/
67776
+SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){
67777
+ testcase( p->sharable );
67778
+ return p->pBt->nRef;
67779
+}
6743367780
#endif
6743467781
6743567782
/************** End of btree.c ***********************************************/
6743667783
/************** Begin file backup.c ******************************************/
6743767784
/*
@@ -68218,12 +68565,10 @@
6821868565
sqlite3_backup_step(&b, 0x7FFFFFFF);
6821968566
assert( b.rc!=SQLITE_OK );
6822068567
rc = sqlite3_backup_finish(&b);
6822168568
if( rc==SQLITE_OK ){
6822268569
pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;
68223
- }else{
68224
- sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
6822568570
}
6822668571
6822768572
assert( sqlite3BtreeIsInTrans(pTo)==0 );
6822868573
copy_finished:
6822968574
sqlite3BtreeLeave(pFrom);
@@ -69225,15 +69570,11 @@
6922569570
assert( !VdbeMemDynamic(pMem) );
6922669571
6922769572
/* Note: the calls to BtreeKeyFetch() and DataFetch() below assert()
6922869573
** that both the BtShared and database handle mutexes are held. */
6922969574
assert( (pMem->flags & MEM_RowSet)==0 );
69230
- if( key ){
69231
- zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
69232
- }else{
69233
- zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
69234
- }
69575
+ zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);
6923569576
assert( zData!=0 );
6923669577
6923769578
if( offset+amt<=available ){
6923869579
pMem->z = &zData[offset];
6923969580
pMem->flags = MEM_Blob|MEM_Ephem;
@@ -70009,18 +70350,10 @@
7000970350
assert( p->zSql==0 );
7001070351
p->zSql = sqlite3DbStrNDup(p->db, z, n);
7001170352
p->isPrepareV2 = (u8)isPrepareV2;
7001270353
}
7001370354
70014
-/*
70015
-** Return the SQL associated with a prepared statement
70016
-*/
70017
-SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
70018
- Vdbe *p = (Vdbe *)pStmt;
70019
- return p ? p->zSql : 0;
70020
-}
70021
-
7002270355
/*
7002370356
** Swap all content between two VDBE structures.
7002470357
*/
7002570358
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
7002670359
Vdbe tmp, *pTmp;
@@ -70736,26 +71069,34 @@
7073671069
/*
7073771070
** If the input FuncDef structure is ephemeral, then free it. If
7073871071
** the FuncDef is not ephermal, then do nothing.
7073971072
*/
7074071073
static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
70741
- if( ALWAYS(pDef) && (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
71074
+ if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
7074271075
sqlite3DbFree(db, pDef);
7074371076
}
7074471077
}
7074571078
7074671079
static void vdbeFreeOpArray(sqlite3 *, Op *, int);
7074771080
7074871081
/*
7074971082
** Delete a P4 value if necessary.
7075071083
*/
71084
+static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
71085
+ if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
71086
+ sqlite3DbFree(db, p);
71087
+}
71088
+static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
71089
+ freeEphemeralFunction(db, p->pFunc);
71090
+ sqlite3DbFree(db, p);
71091
+}
7075171092
static void freeP4(sqlite3 *db, int p4type, void *p4){
7075271093
assert( db );
7075371094
switch( p4type ){
7075471095
case P4_FUNCCTX: {
70755
- freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc);
70756
- /* Fall through into the next case */
71096
+ freeP4FuncCtx(db, (sqlite3_context*)p4);
71097
+ break;
7075771098
}
7075871099
case P4_REAL:
7075971100
case P4_INT64:
7076071101
case P4_DYNAMIC:
7076171102
case P4_INTARRAY: {
@@ -70782,13 +71123,11 @@
7078271123
}
7078371124
case P4_MEM: {
7078471125
if( db->pnBytesFreed==0 ){
7078571126
sqlite3ValueFree((sqlite3_value*)p4);
7078671127
}else{
70787
- Mem *p = (Mem*)p4;
70788
- if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
70789
- sqlite3DbFree(db, p);
71128
+ freeP4Mem(db, (Mem*)p4);
7079071129
}
7079171130
break;
7079271131
}
7079371132
case P4_VTAB : {
7079471133
if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
@@ -74254,12 +74593,11 @@
7425474593
** than 2GiB are support - anything large must be database corruption.
7425574594
** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
7425674595
** this code can safely assume that nCellKey is 32-bits
7425774596
*/
7425874597
assert( sqlite3BtreeCursorIsValid(pCur) );
74259
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74260
- assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74598
+ nCellKey = sqlite3BtreePayloadSize(pCur);
7426174599
assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
7426274600
7426374601
/* Read in the complete content of the index entry */
7426474602
sqlite3VdbeMemInit(&m, db, 0);
7426574603
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
@@ -74332,12 +74670,11 @@
7433274670
Mem m;
7433374671
7433474672
assert( pC->eCurType==CURTYPE_BTREE );
7433574673
pCur = pC->uc.pCursor;
7433674674
assert( sqlite3BtreeCursorIsValid(pCur) );
74337
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74338
- assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74675
+ nCellKey = sqlite3BtreePayloadSize(pCur);
7433974676
/* nCellKey will always be between 0 and 0xffffffff because of the way
7434074677
** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
7434174678
if( nCellKey<=0 || nCellKey>0x7fffffff ){
7434274679
*res = 0;
7434374680
return SQLITE_CORRUPT_BKPT;
@@ -74595,16 +74932,23 @@
7459574932
** Invoke the profile callback. This routine is only called if we already
7459674933
** know that the profile callback is defined and needs to be invoked.
7459774934
*/
7459874935
static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
7459974936
sqlite3_int64 iNow;
74937
+ sqlite3_int64 iElapse;
7460074938
assert( p->startTime>0 );
74601
- assert( db->xProfile!=0 );
74939
+ assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
7460274940
assert( db->init.busy==0 );
7460374941
assert( p->zSql!=0 );
7460474942
sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
74605
- db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
74943
+ iElapse = (iNow - p->startTime)*1000000;
74944
+ if( db->xProfile ){
74945
+ db->xProfile(db->pProfileArg, p->zSql, iElapse);
74946
+ }
74947
+ if( db->mTrace & SQLITE_TRACE_PROFILE ){
74948
+ db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
74949
+ }
7460674950
p->startTime = 0;
7460774951
}
7460874952
/*
7460974953
** The checkProfileCallback(DB,P) macro checks to see if a profile callback
7461074954
** is needed, and it invokes the callback if it is needed.
@@ -75104,11 +75448,12 @@
7510475448
assert( db->nVdbeWrite>0 || db->autoCommit==0
7510575449
|| (db->nDeferredCons==0 && db->nDeferredImmCons==0)
7510675450
);
7510775451
7510875452
#ifndef SQLITE_OMIT_TRACE
75109
- if( db->xProfile && !db->init.busy && p->zSql ){
75453
+ if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
75454
+ && !db->init.busy && p->zSql ){
7511075455
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
7511175456
}else{
7511275457
assert( p->startTime==0 );
7511375458
}
7511475459
#endif
@@ -76138,10 +76483,43 @@
7613876483
#endif
7613976484
v = pVdbe->aCounter[op];
7614076485
if( resetFlag ) pVdbe->aCounter[op] = 0;
7614176486
return (int)v;
7614276487
}
76488
+
76489
+/*
76490
+** Return the SQL associated with a prepared statement
76491
+*/
76492
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
76493
+ Vdbe *p = (Vdbe *)pStmt;
76494
+ return p ? p->zSql : 0;
76495
+}
76496
+
76497
+/*
76498
+** Return the SQL associated with a prepared statement with
76499
+** bound parameters expanded. Space to hold the returned string is
76500
+** obtained from sqlite3_malloc(). The caller is responsible for
76501
+** freeing the returned string by passing it to sqlite3_free().
76502
+**
76503
+** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
76504
+** expanded bound parameters.
76505
+*/
76506
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt){
76507
+#ifdef SQLITE_OMIT_TRACE
76508
+ return 0;
76509
+#else
76510
+ char *z = 0;
76511
+ const char *zSql = sqlite3_sql(pStmt);
76512
+ if( zSql ){
76513
+ Vdbe *p = (Vdbe *)pStmt;
76514
+ sqlite3_mutex_enter(p->db->mutex);
76515
+ z = sqlite3VdbeExpandSql(p, zSql);
76516
+ sqlite3_mutex_leave(p->db->mutex);
76517
+ }
76518
+ return z;
76519
+#endif
76520
+}
7614376521
7614476522
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
7614576523
/*
7614676524
** Allocate and populate an UnpackedRecord structure based on the serialized
7614776525
** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
@@ -76185,12 +76563,11 @@
7618576563
/* If the old.* record has not yet been loaded into memory, do so now. */
7618676564
if( p->pUnpacked==0 ){
7618776565
u32 nRec;
7618876566
u8 *aRec;
7618976567
76190
- rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec);
76191
- if( rc!=SQLITE_OK ) goto preupdate_old_out;
76568
+ nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
7619276569
aRec = sqlite3DbMallocRaw(db, nRec);
7619376570
if( !aRec ) goto preupdate_old_out;
7619476571
rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
7619576572
if( rc==SQLITE_OK ){
7619676573
p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
@@ -76474,14 +76851,17 @@
7647476851
int n; /* Length of a token prefix */
7647576852
int nToken; /* Length of the parameter token */
7647676853
int i; /* Loop counter */
7647776854
Mem *pVar; /* Value of a host parameter */
7647876855
StrAccum out; /* Accumulate the output here */
76856
+#ifndef SQLITE_OMIT_UTF16
76857
+ Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */
76858
+#endif
7647976859
char zBase[100]; /* Initial working space */
7648076860
7648176861
db = p->db;
76482
- sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase),
76862
+ sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase),
7648376863
db->aLimit[SQLITE_LIMIT_LENGTH]);
7648476864
if( db->nVdbeExec>1 ){
7648576865
while( *zRawSql ){
7648676866
const char *zStart = zRawSql;
7648776867
while( *(zRawSql++)!='\n' && *zRawSql );
@@ -76528,16 +76908,18 @@
7652876908
sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
7652976909
}else if( pVar->flags & MEM_Str ){
7653076910
int nOut; /* Number of bytes of the string text to include in output */
7653176911
#ifndef SQLITE_OMIT_UTF16
7653276912
u8 enc = ENC(db);
76533
- Mem utf8;
7653476913
if( enc!=SQLITE_UTF8 ){
7653576914
memset(&utf8, 0, sizeof(utf8));
7653676915
utf8.db = db;
7653776916
sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
76538
- sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
76917
+ if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
76918
+ out.accError = STRACCUM_NOMEM;
76919
+ out.nAlloc = 0;
76920
+ }
7653976921
pVar = &utf8;
7654076922
}
7654176923
#endif
7654276924
nOut = pVar->n;
7654376925
#ifdef SQLITE_TRACE_SIZE_LIMIT
@@ -76575,10 +76957,11 @@
7657576957
}
7657676958
#endif
7657776959
}
7657876960
}
7657976961
}
76962
+ if( out.accError ) sqlite3StrAccumReset(&out);
7658076963
return sqlite3StrAccumFinish(&out);
7658176964
}
7658276965
7658376966
#endif /* #ifndef SQLITE_OMIT_TRACE */
7658476967
@@ -77107,12 +77490,12 @@
7710777490
******************************************************************************
7710877491
**
7710977492
** This file contains inline asm code for retrieving "high-performance"
7711077493
** counters for x86 class CPUs.
7711177494
*/
77112
-#ifndef _HWTIME_H_
77113
-#define _HWTIME_H_
77495
+#ifndef SQLITE_HWTIME_H
77496
+#define SQLITE_HWTIME_H
7711477497
7711577498
/*
7711677499
** The following routine only works on pentium-class (or newer) processors.
7711777500
** It uses the RDTSC opcode to read the cycle count value out of the
7711877501
** processor and returns that value. This can be used for high-res
@@ -77176,11 +77559,11 @@
7717677559
*/
7717777560
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
7717877561
7717977562
#endif
7718077563
77181
-#endif /* !defined(_HWTIME_H_) */
77564
+#endif /* !defined(SQLITE_HWTIME_H) */
7718277565
7718377566
/************** End of hwtime.h **********************************************/
7718477567
/************** Continuing where we left off in vdbe.c ***********************/
7718577568
7718677569
#endif
@@ -78055,10 +78438,14 @@
7805578438
|| (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
7805678439
sqlite3VdbeMemNulTerminate(&pMem[i]);
7805778440
REGISTER_TRACE(pOp->p1+i, &pMem[i]);
7805878441
}
7805978442
if( db->mallocFailed ) goto no_mem;
78443
+
78444
+ if( db->mTrace & SQLITE_TRACE_ROW ){
78445
+ db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);
78446
+ }
7806078447
7806178448
/* Return SQLITE_ROW
7806278449
*/
7806378450
p->pc = (int)(pOp - aOp) + 1;
7806478451
rc = SQLITE_ROW;
@@ -78689,10 +79076,11 @@
7868979076
affinity = pOp->p5 & SQLITE_AFF_MASK;
7869079077
if( affinity>=SQLITE_AFF_NUMERIC ){
7869179078
if( (flags1 | flags3)&MEM_Str ){
7869279079
if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7869379080
applyNumericAffinity(pIn1,0);
79081
+ flags3 = pIn3->flags;
7869479082
}
7869579083
if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7869679084
applyNumericAffinity(pIn3,0);
7869779085
}
7869879086
}
@@ -78701,10 +79089,11 @@
7870179089
testcase( pIn1->flags & MEM_Int );
7870279090
testcase( pIn1->flags & MEM_Real );
7870379091
sqlite3VdbeMemStringify(pIn1, encoding, 1);
7870479092
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
7870579093
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
79094
+ flags3 = pIn3->flags;
7870679095
}
7870779096
if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
7870879097
testcase( pIn3->flags & MEM_Int );
7870979098
testcase( pIn3->flags & MEM_Real );
7871079099
sqlite3VdbeMemStringify(pIn3, encoding, 1);
@@ -79053,11 +79442,10 @@
7905379442
** the result is guaranteed to only be used as the argument of a length()
7905479443
** or typeof() function, respectively. The loading of large blobs can be
7905579444
** skipped for length() and all content loading can be skipped for typeof().
7905679445
*/
7905779446
case OP_Column: {
79058
- i64 payloadSize64; /* Number of bytes in the record */
7905979447
int p2; /* column number to retrieve */
7906079448
VdbeCursor *pC; /* The VDBE cursor */
7906179449
BtCursor *pCrsr; /* The BTree cursor */
7906279450
u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
7906379451
int len; /* The length of the serialized data for the column */
@@ -79076,10 +79464,11 @@
7907679464
pC = p->apCsr[pOp->p1];
7907779465
p2 = pOp->p2;
7907879466
7907979467
/* If the cursor cache is stale, bring it up-to-date */
7908079468
rc = sqlite3VdbeCursorMoveto(&pC, &p2);
79469
+ if( rc ) goto abort_due_to_error;
7908179470
7908279471
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
7908379472
pDest = &aMem[pOp->p3];
7908479473
memAboutToChange(p, pDest);
7908579474
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -79089,12 +79478,11 @@
7908979478
assert( pC->eCurType!=CURTYPE_VTAB );
7909079479
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
7909179480
assert( pC->eCurType!=CURTYPE_SORTER );
7909279481
pCrsr = pC->uc.pCursor;
7909379482
79094
- if( rc ) goto abort_due_to_error;
79095
- if( pC->cacheStatus!=p->cacheCtr ){
79483
+ if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/
7909679484
if( pC->nullRow ){
7909779485
if( pC->eCurType==CURTYPE_PSEUDO ){
7909879486
assert( pC->uc.pseudoTableReg>0 );
7909979487
pReg = &aMem[pC->uc.pseudoTableReg];
7910079488
assert( pReg->flags & MEM_Blob );
@@ -79106,26 +79494,13 @@
7910679494
goto op_column_out;
7910779495
}
7910879496
}else{
7910979497
assert( pC->eCurType==CURTYPE_BTREE );
7911079498
assert( pCrsr );
79111
- if( pC->isTable==0 ){
79112
- assert( sqlite3BtreeCursorIsValid(pCrsr) );
79113
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64);
79114
- assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
79115
- /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the
79116
- ** payload size, so it is impossible for payloadSize64 to be
79117
- ** larger than 32 bits. */
79118
- assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 );
79119
- pC->aRow = sqlite3BtreeKeyFetch(pCrsr, &avail);
79120
- pC->payloadSize = (u32)payloadSize64;
79121
- }else{
79122
- assert( sqlite3BtreeCursorIsValid(pCrsr) );
79123
- VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &pC->payloadSize);
79124
- assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
79125
- pC->aRow = sqlite3BtreeDataFetch(pCrsr, &avail);
79126
- }
79499
+ assert( sqlite3BtreeCursorIsValid(pCrsr) );
79500
+ pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
79501
+ pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
7912779502
assert( avail<=65536 ); /* Maximum page size is 64KiB */
7912879503
if( pC->payloadSize <= (u32)avail ){
7912979504
pC->szRow = pC->payloadSize;
7913079505
}else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
7913179506
goto too_big;
@@ -79137,11 +79512,11 @@
7913779512
pC->iHdrOffset = getVarint32(pC->aRow, offset);
7913879513
pC->nHdrParsed = 0;
7913979514
aOffset[0] = offset;
7914079515
7914179516
79142
- if( avail<offset ){
79517
+ if( avail<offset ){ /*OPTIMIZATION-IF-FALSE*/
7914379518
/* pC->aRow does not have to hold the entire row, but it does at least
7914479519
** need to cover the header of the record. If pC->aRow does not contain
7914579520
** the complete header, then set it to zero, forcing the header to be
7914679521
** dynamically allocated. */
7914779522
pC->aRow = 0;
@@ -79158,28 +79533,28 @@
7915879533
*/
7915979534
if( offset > 98307 || offset > pC->payloadSize ){
7916079535
rc = SQLITE_CORRUPT_BKPT;
7916179536
goto abort_due_to_error;
7916279537
}
79163
- }
79164
-
79165
- /* The following goto is an optimization. It can be omitted and
79166
- ** everything will still work. But OP_Column is measurably faster
79167
- ** by skipping the subsequent conditional, which is always true.
79168
- */
79169
- assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79170
- goto op_column_read_header;
79538
+ }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/
79539
+ /* The following goto is an optimization. It can be omitted and
79540
+ ** everything will still work. But OP_Column is measurably faster
79541
+ ** by skipping the subsequent conditional, which is always true.
79542
+ */
79543
+ zData = pC->aRow;
79544
+ assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79545
+ goto op_column_read_header;
79546
+ }
7917179547
}
7917279548
7917379549
/* Make sure at least the first p2+1 entries of the header have been
7917479550
** parsed and valid information is in aOffset[] and pC->aType[].
7917579551
*/
7917679552
if( pC->nHdrParsed<=p2 ){
7917779553
/* If there is more header available for parsing in the record, try
7917879554
** to extract additional fields up through the p2+1-th field
7917979555
*/
79180
- op_column_read_header:
7918179556
if( pC->iHdrOffset<aOffset[0] ){
7918279557
/* Make sure zData points to enough of the record to cover the header. */
7918379558
if( pC->aRow==0 ){
7918479559
memset(&sMem, 0, sizeof(sMem));
7918579560
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
@@ -79188,15 +79563,15 @@
7918879563
}else{
7918979564
zData = pC->aRow;
7919079565
}
7919179566
7919279567
/* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
79568
+ op_column_read_header:
7919379569
i = pC->nHdrParsed;
7919479570
offset64 = aOffset[i];
7919579571
zHdr = zData + pC->iHdrOffset;
7919679572
zEndHdr = zData + aOffset[0];
79197
- assert( i<=p2 && zHdr<zEndHdr );
7919879573
do{
7919979574
if( (t = zHdr[0])<0x80 ){
7920079575
zHdr++;
7920179576
offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
7920279577
}else{
@@ -79204,13 +79579,11 @@
7920479579
offset64 += sqlite3VdbeSerialTypeLen(t);
7920579580
}
7920679581
pC->aType[i++] = t;
7920779582
aOffset[i] = (u32)(offset64 & 0xffffffff);
7920879583
}while( i<=p2 && zHdr<zEndHdr );
79209
- pC->nHdrParsed = i;
79210
- pC->iHdrOffset = (u32)(zHdr - zData);
79211
-
79584
+
7921279585
/* The record is corrupt if any of the following are true:
7921379586
** (1) the bytes of the header extend past the declared header size
7921479587
** (2) the entire header was used but not all data was used
7921579588
** (3) the end of the data extends beyond the end of the record.
7921679589
*/
@@ -79219,12 +79592,14 @@
7921979592
){
7922079593
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
7922179594
rc = SQLITE_CORRUPT_BKPT;
7922279595
goto abort_due_to_error;
7922379596
}
79597
+
79598
+ pC->nHdrParsed = i;
79599
+ pC->iHdrOffset = (u32)(zHdr - zData);
7922479600
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79225
-
7922679601
}else{
7922779602
t = 0;
7922879603
}
7922979604
7923079605
/* If after trying to extract new entries from the header, nHdrParsed is
@@ -79248,13 +79623,14 @@
7924879623
** all valid.
7924979624
*/
7925079625
assert( p2<pC->nHdrParsed );
7925179626
assert( rc==SQLITE_OK );
7925279627
assert( sqlite3VdbeCheckMemInvariants(pDest) );
79253
- if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest);
79628
+ if( VdbeMemDynamic(pDest) ){
79629
+ sqlite3VdbeMemSetNull(pDest);
79630
+ }
7925479631
assert( t==pC->aType[p2] );
79255
- pDest->enc = encoding;
7925679632
if( pC->szRow>=aOffset[p2+1] ){
7925779633
/* This is the common case where the desired content fits on the original
7925879634
** page - where the content is not on an overflow page */
7925979635
zData = pC->aRow + aOffset[p2];
7926079636
if( t<12 ){
@@ -79264,10 +79640,11 @@
7926479640
** a MEM_Ephem value. This branch is a fast short-cut that is equivalent
7926579641
** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().
7926679642
*/
7926779643
static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
7926879644
pDest->n = len = (t-12)/2;
79645
+ pDest->enc = encoding;
7926979646
if( pDest->szMalloc < len+2 ){
7927079647
pDest->flags = MEM_Null;
7927179648
if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
7927279649
}else{
7927379650
pDest->z = pDest->zMalloc;
@@ -79276,10 +79653,11 @@
7927679653
pDest->z[len] = 0;
7927779654
pDest->z[len+1] = 0;
7927879655
pDest->flags = aFlag[t&1];
7927979656
}
7928079657
}else{
79658
+ pDest->enc = encoding;
7928179659
/* This branch happens only when content is on overflow pages */
7928279660
if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
7928379661
&& ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))
7928479662
|| (len = sqlite3VdbeSerialTypeLen(t))==0
7928579663
){
@@ -80693,10 +81071,34 @@
8069381071
if( takeJump || !alreadyExists ) goto jump_to_p2;
8069481072
}
8069581073
break;
8069681074
}
8069781075
81076
+/* Opcode: SeekRowid P1 P2 P3 * *
81077
+** Synopsis: intkey=r[P3]
81078
+**
81079
+** P1 is the index of a cursor open on an SQL table btree (with integer
81080
+** keys). If register P3 does not contain an integer or if P1 does not
81081
+** contain a record with rowid P3 then jump immediately to P2.
81082
+** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain
81083
+** a record with rowid P3 then
81084
+** leave the cursor pointing at that record and fall through to the next
81085
+** instruction.
81086
+**
81087
+** The OP_NotExists opcode performs the same operation, but with OP_NotExists
81088
+** the P3 register must be guaranteed to contain an integer value. With this
81089
+** opcode, register P3 might not contain an integer.
81090
+**
81091
+** The OP_NotFound opcode performs the same operation on index btrees
81092
+** (with arbitrary multi-value keys).
81093
+**
81094
+** This opcode leaves the cursor in a state where it cannot be advanced
81095
+** in either direction. In other words, the Next and Prev opcodes will
81096
+** not work following this opcode.
81097
+**
81098
+** See also: Found, NotFound, NoConflict, SeekRowid
81099
+*/
8069881100
/* Opcode: NotExists P1 P2 P3 * *
8069981101
** Synopsis: intkey=r[P3]
8070081102
**
8070181103
** P1 is the index of a cursor open on an SQL table btree (with integer
8070281104
** keys). P3 is an integer rowid. If P1 does not contain a record with
@@ -80703,26 +81105,37 @@
8070381105
** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an
8070481106
** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then
8070581107
** leave the cursor pointing at that record and fall through to the next
8070681108
** instruction.
8070781109
**
81110
+** The OP_SeekRowid opcode performs the same operation but also allows the
81111
+** P3 register to contain a non-integer value, in which case the jump is
81112
+** always taken. This opcode requires that P3 always contain an integer.
81113
+**
8070881114
** The OP_NotFound opcode performs the same operation on index btrees
8070981115
** (with arbitrary multi-value keys).
8071081116
**
8071181117
** This opcode leaves the cursor in a state where it cannot be advanced
8071281118
** in either direction. In other words, the Next and Prev opcodes will
8071381119
** not work following this opcode.
8071481120
**
80715
-** See also: Found, NotFound, NoConflict
81121
+** See also: Found, NotFound, NoConflict, SeekRowid
8071681122
*/
80717
-case OP_NotExists: { /* jump, in3 */
81123
+case OP_SeekRowid: { /* jump, in3 */
8071881124
VdbeCursor *pC;
8071981125
BtCursor *pCrsr;
8072081126
int res;
8072181127
u64 iKey;
8072281128
8072381129
pIn3 = &aMem[pOp->p3];
81130
+ if( (pIn3->flags & MEM_Int)==0 ){
81131
+ applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
81132
+ if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;
81133
+ }
81134
+ /* Fall through into OP_NotExists */
81135
+case OP_NotExists: /* jump, in3 */
81136
+ pIn3 = &aMem[pOp->p3];
8072481137
assert( pIn3->flags & MEM_Int );
8072581138
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8072681139
pC = p->apCsr[pOp->p1];
8072781140
assert( pC!=0 );
8072881141
#ifdef SQLITE_DEBUG
@@ -80836,12 +81249,11 @@
8083681249
}
8083781250
if( res ){
8083881251
v = 1; /* IMP: R-61914-48074 */
8083981252
}else{
8084081253
assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );
80841
- rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
80842
- assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
81254
+ v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8084381255
if( v>=MAX_ROWID ){
8084481256
pC->useRandomRowid = 1;
8084581257
}else{
8084681258
v++; /* IMP: R-29538-34987 */
8084781259
}
@@ -80920,14 +81332,16 @@
8092081332
** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
8092181333
** then rowid is stored for subsequent return by the
8092281334
** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
8092381335
**
8092481336
** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
80925
-** the last seek operation (OP_NotExists) was a success, then this
81337
+** the last seek operation (OP_NotExists or OP_SeekRowid) was a success,
81338
+** then this
8092681339
** operation will not attempt to find the appropriate row before doing
8092781340
** the insert but will instead overwrite the row that the cursor is
80928
-** currently pointing to. Presumably, the prior OP_NotExists opcode
81341
+** currently pointing to. Presumably, the prior OP_NotExists or
81342
+** OP_SeekRowid opcode
8092981343
** has already positioned the cursor correctly. This is an optimization
8093081344
** that boosts performance by avoiding redundant seeks.
8093181345
**
8093281346
** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
8093381347
** UPDATE operation. Otherwise (if the flag is clear) then this opcode
@@ -80955,17 +81369,16 @@
8095581369
*/
8095681370
case OP_Insert:
8095781371
case OP_InsertInt: {
8095881372
Mem *pData; /* MEM cell holding data for the record to be inserted */
8095981373
Mem *pKey; /* MEM cell holding key for the record */
80960
- i64 iKey; /* The integer ROWID or key for the record to be inserted */
8096181374
VdbeCursor *pC; /* Cursor to table into which insert is written */
80962
- int nZero; /* Number of zero-bytes to append */
8096381375
int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
8096481376
const char *zDb; /* database name - used by the update hook */
8096581377
Table *pTab; /* Table structure - used by update and pre-update hooks */
8096681378
int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
81379
+ BtreePayload x; /* Payload to be inserted */
8096781380
8096881381
op = 0;
8096981382
pData = &aMem[pOp->p2];
8097081383
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8097181384
assert( memIsValid(pData) );
@@ -80980,14 +81393,14 @@
8098081393
if( pOp->opcode==OP_Insert ){
8098181394
pKey = &aMem[pOp->p3];
8098281395
assert( pKey->flags & MEM_Int );
8098381396
assert( memIsValid(pKey) );
8098481397
REGISTER_TRACE(pOp->p3, pKey);
80985
- iKey = pKey->u.i;
81398
+ x.nKey = pKey->u.i;
8098681399
}else{
8098781400
assert( pOp->opcode==OP_InsertInt );
80988
- iKey = pOp->p3;
81401
+ x.nKey = pOp->p3;
8098981402
}
8099081403
8099181404
if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
8099281405
assert( pC->isTable );
8099381406
assert( pC->iDb>=0 );
@@ -81004,39 +81417,41 @@
8100481417
/* Invoke the pre-update hook, if any */
8100581418
if( db->xPreUpdateCallback
8100681419
&& pOp->p4type==P4_TABLE
8100781420
&& !(pOp->p5 & OPFLAG_ISUPDATE)
8100881421
){
81009
- sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
81422
+ sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);
8101081423
}
8101181424
#endif
8101281425
8101381426
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
81014
- if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey;
81427
+ if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey;
8101581428
if( pData->flags & MEM_Null ){
81016
- pData->z = 0;
81017
- pData->n = 0;
81429
+ x.pData = 0;
81430
+ x.nData = 0;
8101881431
}else{
8101981432
assert( pData->flags & (MEM_Blob|MEM_Str) );
81433
+ x.pData = pData->z;
81434
+ x.nData = pData->n;
8102081435
}
8102181436
seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);
8102281437
if( pData->flags & MEM_Zero ){
81023
- nZero = pData->u.nZero;
81438
+ x.nZero = pData->u.nZero;
8102481439
}else{
81025
- nZero = 0;
81440
+ x.nZero = 0;
8102681441
}
81027
- rc = sqlite3BtreeInsert(pC->uc.pCursor, 0, iKey,
81028
- pData->z, pData->n, nZero,
81442
+ x.pKey = 0;
81443
+ rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
8102981444
(pOp->p5 & OPFLAG_APPEND)!=0, seekResult
8103081445
);
8103181446
pC->deferredMoveto = 0;
8103281447
pC->cacheStatus = CACHE_STALE;
8103381448
8103481449
/* Invoke the update-hook if required. */
8103581450
if( rc ) goto abort_due_to_error;
8103681451
if( db->xUpdateCallback && op ){
81037
- db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
81452
+ db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);
8103881453
}
8103981454
break;
8104081455
}
8104181456
8104281457
/* Opcode: Delete P1 P2 P3 P4 P5
@@ -81091,12 +81506,11 @@
8109181506
#ifdef SQLITE_DEBUG
8109281507
if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
8109381508
/* If p5 is zero, the seek operation that positioned the cursor prior to
8109481509
** OP_Delete will have also set the pC->movetoTarget field to the rowid of
8109581510
** the row that is being deleted */
81096
- i64 iKey = 0;
81097
- sqlite3BtreeKeySize(pC->uc.pCursor, &iKey);
81511
+ i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8109881512
assert( pC->movetoTarget==iKey );
8109981513
}
8110081514
#endif
8110181515
8110281516
/* If the update-hook or pre-update-hook will be invoked, set zDb to
@@ -81108,11 +81522,11 @@
8110881522
assert( pC->iDb>=0 );
8110981523
assert( pOp->p4.pTab!=0 );
8111081524
zDb = db->aDb[pC->iDb].zName;
8111181525
pTab = pOp->p4.pTab;
8111281526
if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
81113
- sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
81527
+ pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8111481528
}
8111581529
}else{
8111681530
zDb = 0; /* Not needed. Silence a compiler warning. */
8111781531
pTab = 0; /* Not needed. Silence a compiler warning. */
8111881532
}
@@ -81262,11 +81676,10 @@
8126281676
case OP_RowKey:
8126381677
case OP_RowData: {
8126481678
VdbeCursor *pC;
8126581679
BtCursor *pCrsr;
8126681680
u32 n;
81267
- i64 n64;
8126881681
8126981682
pOut = &aMem[pOp->p2];
8127081683
memAboutToChange(p, pOut);
8127181684
8127281685
/* Note that RowKey and RowData are really exactly the same instruction */
@@ -81280,12 +81693,13 @@
8128081693
assert( pC->nullRow==0 );
8128181694
assert( pC->uc.pCursor!=0 );
8128281695
pCrsr = pC->uc.pCursor;
8128381696
8128481697
/* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
81285
- ** OP_Rewind/Op_Next with no intervening instructions that might invalidate
81286
- ** the cursor. If this where not the case, on of the following assert()s
81698
+ ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions
81699
+ ** that might invalidate the cursor.
81700
+ ** If this where not the case, on of the following assert()s
8128781701
** would fail. Should this ever change (because of changes in the code
8128881702
** generator) then the fix would be to insert a call to
8128981703
** sqlite3VdbeCursorMoveto().
8129081704
*/
8129181705
assert( pC->deferredMoveto==0 );
@@ -81293,24 +81707,13 @@
8129381707
#if 0 /* Not required due to the previous to assert() statements */
8129481708
rc = sqlite3VdbeCursorMoveto(pC);
8129581709
if( rc!=SQLITE_OK ) goto abort_due_to_error;
8129681710
#endif
8129781711
81298
- if( pC->isTable==0 ){
81299
- assert( !pC->isTable );
81300
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64);
81301
- assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
81302
- if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
81303
- goto too_big;
81304
- }
81305
- n = (u32)n64;
81306
- }else{
81307
- VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n);
81308
- assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
81309
- if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81310
- goto too_big;
81311
- }
81712
+ n = sqlite3BtreePayloadSize(pCrsr);
81713
+ if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81714
+ goto too_big;
8131281715
}
8131381716
testcase( n==0 );
8131481717
if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
8131581718
goto no_mem;
8131681719
}
@@ -81371,12 +81774,11 @@
8137181774
if( rc ) goto abort_due_to_error;
8137281775
if( pC->nullRow ){
8137381776
pOut->flags = MEM_Null;
8137481777
break;
8137581778
}
81376
- rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
81377
- assert( rc==SQLITE_OK ); /* Always so because of CursorRestore() above */
81779
+ v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8137881780
}
8137981781
pOut->u.i = v;
8138081782
break;
8138181783
}
8138281784
@@ -81647,12 +82049,11 @@
8164782049
** for tables is OP_Insert.
8164882050
*/
8164982051
case OP_SorterInsert: /* in2 */
8165082052
case OP_IdxInsert: { /* in2 */
8165182053
VdbeCursor *pC;
81652
- int nKey;
81653
- const char *zKey;
82054
+ BtreePayload x;
8165482055
8165582056
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8165682057
pC = p->apCsr[pOp->p1];
8165782058
assert( pC!=0 );
8165882059
assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
@@ -81664,13 +82065,16 @@
8166482065
rc = ExpandBlob(pIn2);
8166582066
if( rc ) goto abort_due_to_error;
8166682067
if( pOp->opcode==OP_SorterInsert ){
8166782068
rc = sqlite3VdbeSorterWrite(pC, pIn2);
8166882069
}else{
81669
- nKey = pIn2->n;
81670
- zKey = pIn2->z;
81671
- rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3,
82070
+ x.nKey = pIn2->n;
82071
+ x.pKey = pIn2->z;
82072
+ x.nData = 0;
82073
+ x.nZero = 0;
82074
+ x.pData = 0;
82075
+ rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3,
8167282076
((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
8167382077
);
8167482078
assert( pC->deferredMoveto==0 );
8167582079
pC->cacheStatus = CACHE_STALE;
8167682080
}
@@ -83437,17 +83841,25 @@
8343783841
case OP_Init: { /* jump */
8343883842
char *zTrace;
8343983843
char *z;
8344083844
8344183845
#ifndef SQLITE_OMIT_TRACE
83442
- if( db->xTrace
83846
+ if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
8344383847
&& !p->doingRerun
8344483848
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
8344583849
){
8344683850
z = sqlite3VdbeExpandSql(p, zTrace);
83447
- db->xTrace(db->pTraceArg, z);
83448
- sqlite3DbFree(db, z);
83851
+#ifndef SQLITE_OMIT_DEPRECATED
83852
+ if( db->mTrace & SQLITE_TRACE_LEGACY ){
83853
+ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
83854
+ x(db->pTraceArg, z);
83855
+ }else
83856
+#endif
83857
+ {
83858
+ (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z);
83859
+ }
83860
+ sqlite3_free(z);
8344983861
}
8345083862
#ifdef SQLITE_USE_FCNTL_TRACE
8345183863
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
8345283864
if( zTrace ){
8345383865
int i;
@@ -84026,11 +84438,11 @@
8402684438
** slightly more efficient). Since you cannot write to a PK column
8402784439
** using the incremental-blob API, this works. For the sessions module
8402884440
** anyhow.
8402984441
*/
8403084442
sqlite3_int64 iKey;
84031
- sqlite3BtreeKeySize(p->pCsr, &iKey);
84443
+ iKey = sqlite3BtreeIntegerKey(p->pCsr);
8403284444
sqlite3VdbePreUpdateHook(
8403384445
v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
8403484446
);
8403584447
}
8403684448
#endif
@@ -85461,41 +85873,47 @@
8546185873
}
8546285874
8546385875
8546485876
/*
8546585877
** Merge the two sorted lists p1 and p2 into a single list.
85466
-** Set *ppOut to the head of the new list.
8546785878
*/
85468
-static void vdbeSorterMerge(
85879
+static SorterRecord *vdbeSorterMerge(
8546985880
SortSubtask *pTask, /* Calling thread context */
8547085881
SorterRecord *p1, /* First list to merge */
85471
- SorterRecord *p2, /* Second list to merge */
85472
- SorterRecord **ppOut /* OUT: Head of merged list */
85882
+ SorterRecord *p2 /* Second list to merge */
8547385883
){
8547485884
SorterRecord *pFinal = 0;
8547585885
SorterRecord **pp = &pFinal;
8547685886
int bCached = 0;
8547785887
85478
- while( p1 && p2 ){
85888
+ assert( p1!=0 && p2!=0 );
85889
+ for(;;){
8547985890
int res;
8548085891
res = pTask->xCompare(
8548185892
pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
8548285893
);
8548385894
8548485895
if( res<=0 ){
8548585896
*pp = p1;
8548685897
pp = &p1->u.pNext;
8548785898
p1 = p1->u.pNext;
85899
+ if( p1==0 ){
85900
+ *pp = p2;
85901
+ break;
85902
+ }
8548885903
}else{
8548985904
*pp = p2;
8549085905
pp = &p2->u.pNext;
8549185906
p2 = p2->u.pNext;
8549285907
bCached = 0;
85908
+ if( p2==0 ){
85909
+ *pp = p1;
85910
+ break;
85911
+ }
8549385912
}
8549485913
}
85495
- *pp = p1 ? p1 : p2;
85496
- *ppOut = pFinal;
85914
+ return pFinal;
8549785915
}
8549885916
8549985917
/*
8550085918
** Return the SorterCompare function to compare values collected by the
8550185919
** sorter object passed as the only argument.
@@ -85544,20 +85962,21 @@
8554485962
pNext = p->u.pNext;
8554585963
}
8554685964
8554785965
p->u.pNext = 0;
8554885966
for(i=0; aSlot[i]; i++){
85549
- vdbeSorterMerge(pTask, p, aSlot[i], &p);
85967
+ p = vdbeSorterMerge(pTask, p, aSlot[i]);
8555085968
aSlot[i] = 0;
8555185969
}
8555285970
aSlot[i] = p;
8555385971
p = pNext;
8555485972
}
8555585973
8555685974
p = 0;
8555785975
for(i=0; i<64; i++){
85558
- vdbeSorterMerge(pTask, p, aSlot[i], &p);
85976
+ if( aSlot[i]==0 ) continue;
85977
+ p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
8555985978
}
8556085979
pList->pList = p;
8556185980
8556285981
sqlite3_free(aSlot);
8556385982
assert( pTask->pUnpacked->errCode==SQLITE_OK
@@ -90773,10 +91192,15 @@
9077391192
VdbeComment((v, "%s", pIdx->zName));
9077491193
assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
9077591194
eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
9077691195
9077791196
if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91197
+#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91198
+ const i64 sOne = 1;
91199
+ sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91200
+ iTab, 0, 0, (u8*)&sOne, P4_INT64);
91201
+#endif
9077891202
*prRhsHasNull = ++pParse->nMem;
9077991203
sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
9078091204
}
9078191205
sqlite3VdbeJumpHere(v, iAddr);
9078291206
}
@@ -90785,11 +91209,11 @@
9078591209
}
9078691210
9078791211
/* If no preexisting index is available for the IN clause
9078891212
** and IN_INDEX_NOOP is an allowed reply
9078991213
** and the RHS of the IN operator is a list, not a subquery
90790
- ** and the RHS is not contant or has two or fewer terms,
91214
+ ** and the RHS is not constant or has two or fewer terms,
9079191215
** then it is not worth creating an ephemeral table to evaluate
9079291216
** the IN operator so return IN_INDEX_NOOP.
9079391217
*/
9079491218
if( eType==0
9079591219
&& (inFlags & IN_INDEX_NOOP_OK)
@@ -91177,12 +91601,11 @@
9117791601
}
9117891602
9117991603
if( eType==IN_INDEX_ROWID ){
9118091604
/* In this case, the RHS is the ROWID of table b-tree
9118191605
*/
91182
- sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); VdbeCoverage(v);
91183
- sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
91606
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
9118491607
VdbeCoverage(v);
9118591608
}else{
9118691609
/* In this case, the RHS is an index b-tree.
9118791610
*/
9118891611
sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
@@ -91491,11 +91914,11 @@
9149191914
if( iCol<0 || iCol==pTab->iPKey ){
9149291915
sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
9149391916
}else{
9149491917
int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
9149591918
int x = iCol;
91496
- if( !HasRowid(pTab) ){
91919
+ if( !HasRowid(pTab) && !IsVirtual(pTab) ){
9149791920
x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
9149891921
}
9149991922
sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
9150091923
}
9150191924
if( iCol>=0 ){
@@ -93870,10 +94293,11 @@
9387094293
char *zCol; /* Null-terminated column definition */
9387194294
Column *pCol; /* The new column */
9387294295
Expr *pDflt; /* Default value for the new column */
9387394296
sqlite3 *db; /* The database connection; */
9387494297
Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
94298
+ int r1; /* Temporary registers */
9387594299
9387694300
db = pParse->db;
9387794301
if( pParse->nErr || db->mallocFailed ) return;
9387894302
assert( v!=0 );
9387994303
pNew = pParse->pNewTable;
@@ -93964,20 +94388,22 @@
9396494388
);
9396594389
sqlite3DbFree(db, zCol);
9396694390
db->flags = savedDbFlags;
9396794391
}
9396894392
93969
- /* If the default value of the new column is NULL, then the file
93970
- ** format to 2. If the default value of the new column is not NULL,
93971
- ** the file format be 3. Back when this feature was first added
93972
- ** in 2006, we went to the trouble to upgrade the file format to the
93973
- ** minimum support values. But 10-years on, we can assume that all
93974
- ** extent versions of SQLite support file-format 4, so we always and
93975
- ** unconditionally upgrade to 4.
94393
+ /* Make sure the schema version is at least 3. But do not upgrade
94394
+ ** from less than 3 to 4, as that will corrupt any preexisting DESC
94395
+ ** index.
9397694396
*/
93977
- sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT,
93978
- SQLITE_MAX_FILE_FORMAT);
94397
+ r1 = sqlite3GetTempReg(pParse);
94398
+ sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
94399
+ sqlite3VdbeUsesBtree(v, iDb);
94400
+ sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
94401
+ sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
94402
+ VdbeCoverage(v);
94403
+ sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
94404
+ sqlite3ReleaseTempReg(pParse, r1);
9397994405
9398094406
/* Reload the schema of the modified table. */
9398194407
reloadTableSchema(pParse, pTab, pTab->zName);
9398294408
}
9398394409
@@ -97152,11 +97578,11 @@
9715297578
** routine leaves an error message in pParse->zErrMsg where
9715397579
** sqlite3FindTable() does not.
9715497580
*/
9715597581
SQLITE_PRIVATE Table *sqlite3LocateTable(
9715697582
Parse *pParse, /* context in which to report errors */
97157
- int isView, /* True if looking for a VIEW rather than a TABLE */
97583
+ u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */
9715897584
const char *zName, /* Name of the table we are looking for */
9715997585
const char *zDbase /* Name of the database. Might be NULL */
9716097586
){
9716197587
Table *p;
9716297588
@@ -97166,11 +97592,11 @@
9716697592
return 0;
9716797593
}
9716897594
9716997595
p = sqlite3FindTable(pParse->db, zName, zDbase);
9717097596
if( p==0 ){
97171
- const char *zMsg = isView ? "no such view" : "no such table";
97597
+ const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
9717297598
#ifndef SQLITE_OMIT_VIRTUALTABLE
9717397599
if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
9717497600
/* If zName is the not the name of a table in the schema created using
9717597601
** CREATE, then check to see if it is the name of an virtual table that
9717697602
** can be an eponymous virtual table. */
@@ -97178,16 +97604,18 @@
9717897604
if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
9717997605
return pMod->pEpoTab;
9718097606
}
9718197607
}
9718297608
#endif
97183
- if( zDbase ){
97184
- sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97185
- }else{
97186
- sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97609
+ if( (flags & LOCATE_NOERR)==0 ){
97610
+ if( zDbase ){
97611
+ sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97612
+ }else{
97613
+ sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97614
+ }
97615
+ pParse->checkSchema = 1;
9718797616
}
97188
- pParse->checkSchema = 1;
9718997617
}
9719097618
9719197619
return p;
9719297620
}
9719397621
@@ -97200,11 +97628,11 @@
9720097628
** non-NULL if it is part of a view or trigger program definition. See
9720197629
** sqlite3FixSrcList() for details.
9720297630
*/
9720397631
SQLITE_PRIVATE Table *sqlite3LocateTableItem(
9720497632
Parse *pParse,
97205
- int isView,
97633
+ u32 flags,
9720697634
struct SrcList_item *p
9720797635
){
9720897636
const char *zDb;
9720997637
assert( p->pSchema==0 || p->zDatabase==0 );
9721097638
if( p->pSchema ){
@@ -97211,11 +97639,11 @@
9721197639
int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
9721297640
zDb = pParse->db->aDb[iDb].zName;
9721397641
}else{
9721497642
zDb = p->zDatabase;
9721597643
}
97216
- return sqlite3LocateTable(pParse, isView, p->zName, zDb);
97644
+ return sqlite3LocateTable(pParse, flags, p->zName, zDb);
9721797645
}
9721897646
9721997647
/*
9722097648
** Locate the in-memory structure that describes
9722197649
** a particular index given the name of that index
@@ -97419,12 +97847,13 @@
9741997847
db->lookaside.nOut : 0 );
9742097848
9742197849
/* Delete all indices associated with this table. */
9742297850
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
9742397851
pNext = pIndex->pNext;
97424
- assert( pIndex->pSchema==pTable->pSchema );
97425
- if( !db || db->pnBytesFreed==0 ){
97852
+ assert( pIndex->pSchema==pTable->pSchema
97853
+ || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );
97854
+ if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
9742697855
char *zName = pIndex->zName;
9742797856
TESTONLY ( Index *pOld = ) sqlite3HashInsert(
9742897857
&pIndex->pSchema->idxHash, zName, 0
9742997858
);
9743097859
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
@@ -98102,11 +98531,11 @@
9810298531
){
9810398532
Table *pTab = pParse->pNewTable;
9810498533
Column *pCol = 0;
9810598534
int iCol = -1, i;
9810698535
int nTerm;
98107
- if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;
98536
+ if( pTab==0 ) goto primary_key_exit;
9810898537
if( pTab->tabFlags & TF_HasPrimaryKey ){
9810998538
sqlite3ErrorMsg(pParse,
9811098539
"table \"%s\" has more than one primary key", pTab->zName);
9811198540
goto primary_key_exit;
9811298541
}
@@ -98148,16 +98577,12 @@
9814898577
#ifndef SQLITE_OMIT_AUTOINCREMENT
9814998578
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
9815098579
"INTEGER PRIMARY KEY");
9815198580
#endif
9815298581
}else{
98153
- Index *p;
98154
- p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98155
- 0, sortOrder, 0);
98156
- if( p ){
98157
- p->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
98158
- }
98582
+ sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98583
+ 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);
9815998584
pList = 0;
9816098585
}
9816198586
9816298587
primary_key_exit:
9816398588
sqlite3ExprListDelete(pParse->db, pList);
@@ -98470,33 +98895,49 @@
9847098895
** has a WITHOUT ROWID clause. The job of this routine is to convert both
9847198896
** internal schema data structures and the generated VDBE code so that they
9847298897
** are appropriate for a WITHOUT ROWID table instead of a rowid table.
9847398898
** Changes include:
9847498899
**
98475
-** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is
98900
+** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
98901
+** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is
9847698902
** no rowid btree for a WITHOUT ROWID. Instead, the canonical
9847798903
** data storage is a covering index btree.
98478
-** (2) Bypass the creation of the sqlite_master table entry
98904
+** (3) Bypass the creation of the sqlite_master table entry
9847998905
** for the PRIMARY KEY as the primary key index is now
9848098906
** identified by the sqlite_master table entry of the table itself.
98481
-** (3) Set the Index.tnum of the PRIMARY KEY Index object in the
98907
+** (4) Set the Index.tnum of the PRIMARY KEY Index object in the
9848298908
** schema to the rootpage from the main table.
98483
-** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
9848498909
** (5) Add all table columns to the PRIMARY KEY Index object
9848598910
** so that the PRIMARY KEY is a covering index. The surplus
9848698911
** columns are part of KeyInfo.nXField and are not used for
9848798912
** sorting or lookup or uniqueness checks.
9848898913
** (6) Replace the rowid tail on all automatically generated UNIQUE
9848998914
** indices with the PRIMARY KEY columns.
98915
+**
98916
+** For virtual tables, only (1) is performed.
9849098917
*/
9849198918
static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
9849298919
Index *pIdx;
9849398920
Index *pPk;
9849498921
int nPk;
9849598922
int i, j;
9849698923
sqlite3 *db = pParse->db;
9849798924
Vdbe *v = pParse->pVdbe;
98925
+
98926
+ /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
98927
+ */
98928
+ if( !db->init.imposterTable ){
98929
+ for(i=0; i<pTab->nCol; i++){
98930
+ if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
98931
+ pTab->aCol[i].notNull = OE_Abort;
98932
+ }
98933
+ }
98934
+ }
98935
+
98936
+ /* The remaining transformations only apply to b-tree tables, not to
98937
+ ** virtual tables */
98938
+ if( IN_DECLARE_VTAB ) return;
9849898939
9849998940
/* Convert the OP_CreateTable opcode that would normally create the
9850098941
** root-page for the table into an OP_CreateIndex opcode. The index
9850198942
** created will become the PRIMARY KEY index.
9850298943
*/
@@ -98515,13 +98956,14 @@
9851598956
pList = sqlite3ExprListAppend(pParse, 0,
9851698957
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
9851798958
if( pList==0 ) return;
9851898959
pList->a[0].sortOrder = pParse->iPkSortOrder;
9851998960
assert( pParse->pNewTable==pTab );
98520
- pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0);
98521
- if( pPk==0 ) return;
98522
- pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
98961
+ sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
98962
+ SQLITE_IDXTYPE_PRIMARYKEY);
98963
+ if( db->mallocFailed ) return;
98964
+ pPk = sqlite3PrimaryKeyIndex(pTab);
9852398965
pTab->iPKey = -1;
9852498966
}else{
9852598967
pPk = sqlite3PrimaryKeyIndex(pTab);
9852698968
9852798969
/* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
@@ -98545,23 +98987,15 @@
9854598987
pPk->aiColumn[j++] = pPk->aiColumn[i];
9854698988
}
9854798989
}
9854898990
pPk->nKeyCol = j;
9854998991
}
98550
- pPk->isCovering = 1;
9855198992
assert( pPk!=0 );
98993
+ pPk->isCovering = 1;
98994
+ if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
9855298995
nPk = pPk->nKeyCol;
9855398996
98554
- /* Make sure every column of the PRIMARY KEY is NOT NULL. (Except,
98555
- ** do not enforce this for imposter tables.) */
98556
- if( !db->init.imposterTable ){
98557
- for(i=0; i<nPk; i++){
98558
- pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort;
98559
- }
98560
- pPk->uniqNotNull = 1;
98561
- }
98562
-
9856398997
/* The root page of the PRIMARY KEY is the table root page */
9856498998
pPk->tnum = pTab->tnum;
9856598999
9856699000
/* Update the in-memory representation of all UNIQUE indices by converting
9856799001
** the final rowid column into one or more columns of the PRIMARY KEY.
@@ -99312,10 +99746,11 @@
9931299746
}
9931399747
assert( pParse->nErr==0 );
9931499748
assert( pName->nSrc==1 );
9931599749
if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
9931699750
if( noErr ) db->suppressErr++;
99751
+ assert( isView==0 || isView==LOCATE_VIEW );
9931799752
pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
9931899753
if( noErr ) db->suppressErr--;
9931999754
9932099755
if( pTab==0 ){
9932199756
if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
@@ -99682,28 +100117,24 @@
99682100117
** currently being constructed by a CREATE TABLE statement.
99683100118
**
99684100119
** pList is a list of columns to be indexed. pList will be NULL if this
99685100120
** is a primary key or unique-constraint on the most recent column added
99686100121
** to the table currently under construction.
99687
-**
99688
-** If the index is created successfully, return a pointer to the new Index
99689
-** structure. This is used by sqlite3AddPrimaryKey() to mark the index
99690
-** as the tables primary key (Index.idxType==SQLITE_IDXTYPE_PRIMARYKEY)
99691100122
*/
99692
-SQLITE_PRIVATE Index *sqlite3CreateIndex(
100123
+SQLITE_PRIVATE void sqlite3CreateIndex(
99693100124
Parse *pParse, /* All information about this parse */
99694100125
Token *pName1, /* First part of index name. May be NULL */
99695100126
Token *pName2, /* Second part of index name. May be NULL */
99696100127
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
99697100128
ExprList *pList, /* A list of columns to be indexed */
99698100129
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
99699100130
Token *pStart, /* The CREATE token that begins this statement */
99700100131
Expr *pPIWhere, /* WHERE clause for partial indices */
99701100132
int sortOrder, /* Sort order of primary key when pList==NULL */
99702
- int ifNotExist /* Omit error if index already exists */
100133
+ int ifNotExist, /* Omit error if index already exists */
100134
+ u8 idxType /* The index type */
99703100135
){
99704
- Index *pRet = 0; /* Pointer to return */
99705100136
Table *pTab = 0; /* Table to be indexed */
99706100137
Index *pIndex = 0; /* The index to be created */
99707100138
char *zName = 0; /* Name of the index */
99708100139
int nName; /* Number of characters in zName */
99709100140
int i, j;
@@ -99717,11 +100148,14 @@
99717100148
int nExtra = 0; /* Space allocated for zExtra[] */
99718100149
int nExtraCol; /* Number of extra columns needed */
99719100150
char *zExtra = 0; /* Extra space after the Index object */
99720100151
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
99721100152
99722
- if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){
100153
+ if( db->mallocFailed || pParse->nErr>0 ){
100154
+ goto exit_create_index;
100155
+ }
100156
+ if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
99723100157
goto exit_create_index;
99724100158
}
99725100159
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
99726100160
goto exit_create_index;
99727100161
}
@@ -99906,11 +100340,11 @@
99906100340
zExtra += nName + 1;
99907100341
memcpy(pIndex->zName, zName, nName+1);
99908100342
pIndex->pTable = pTab;
99909100343
pIndex->onError = (u8)onError;
99910100344
pIndex->uniqNotNull = onError!=OE_None;
99911
- pIndex->idxType = pName ? SQLITE_IDXTYPE_APPDEF : SQLITE_IDXTYPE_UNIQUE;
100345
+ pIndex->idxType = idxType;
99912100346
pIndex->pSchema = db->aDb[iDb].pSchema;
99913100347
pIndex->nKeyCol = pList->nExpr;
99914100348
if( pPIWhere ){
99915100349
sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
99916100350
pIndex->pPartIdxWhere = pPIWhere;
@@ -100086,11 +100520,11 @@
100086100520
}
100087100521
if( pIdx->onError==OE_Default ){
100088100522
pIdx->onError = pIndex->onError;
100089100523
}
100090100524
}
100091
- pRet = pIdx;
100525
+ if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
100092100526
goto exit_create_index;
100093100527
}
100094100528
}
100095100529
}
100096100530
@@ -100098,10 +100532,11 @@
100098100532
** in-memory database structures.
100099100533
*/
100100100534
assert( pParse->nErr==0 );
100101100535
if( db->init.busy ){
100102100536
Index *p;
100537
+ assert( !IN_DECLARE_VTAB );
100103100538
assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
100104100539
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
100105100540
pIndex->zName, pIndex);
100106100541
if( p ){
100107100542
assert( p==pIndex ); /* Malloc must have failed */
@@ -100179,11 +100614,11 @@
100179100614
if( pTblName ){
100180100615
sqlite3RefillIndex(pParse, pIndex, iMem);
100181100616
sqlite3ChangeCookie(pParse, iDb);
100182100617
sqlite3VdbeAddParseSchemaOp(v, iDb,
100183100618
sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
100184
- sqlite3VdbeAddOp1(v, OP_Expire, 0);
100619
+ sqlite3VdbeAddOp0(v, OP_Expire);
100185100620
}
100186100621
100187100622
sqlite3VdbeJumpHere(v, pIndex->tnum);
100188100623
}
100189100624
@@ -100204,11 +100639,10 @@
100204100639
pOther = pOther->pNext;
100205100640
}
100206100641
pIndex->pNext = pOther->pNext;
100207100642
pOther->pNext = pIndex;
100208100643
}
100209
- pRet = pIndex;
100210100644
pIndex = 0;
100211100645
}
100212100646
100213100647
/* Clean up before exiting */
100214100648
exit_create_index:
@@ -100215,11 +100649,10 @@
100215100649
if( pIndex ) freeIndex(db, pIndex);
100216100650
sqlite3ExprDelete(db, pPIWhere);
100217100651
sqlite3ExprListDelete(db, pList);
100218100652
sqlite3SrcListDelete(db, pTblName);
100219100653
sqlite3DbFree(db, zName);
100220
- return pRet;
100221100654
}
100222100655
100223100656
/*
100224100657
** Fill the Index.aiRowEst[] array with default information - information
100225100658
** to be used when we have not run the ANALYZE command.
@@ -100244,14 +100677,15 @@
100244100677
LogEst *a = pIdx->aiRowLogEst;
100245100678
int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
100246100679
int i;
100247100680
100248100681
/* Set the first entry (number of rows in the index) to the estimated
100249
- ** number of rows in the table. Or 10, if the estimated number of rows
100250
- ** in the table is less than that. */
100682
+ ** number of rows in the table, or half the number of rows in the table
100683
+ ** for a partial index. But do not let the estimate drop below 10. */
100251100684
a[0] = pIdx->pTable->nRowLogEst;
100252
- if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100685
+ if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
100686
+ if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100253100687
100254100688
/* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
100255100689
** 6 and each subsequent value (if any) is 5. */
100256100690
memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
100257100691
for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
@@ -101129,14 +101563,10 @@
101129101563
#endif
101130101564
101131101565
/*
101132101566
** Return a KeyInfo structure that is appropriate for the given Index.
101133101567
**
101134
-** The KeyInfo structure for an index is cached in the Index object.
101135
-** So there might be multiple references to the returned pointer. The
101136
-** caller should not try to modify the KeyInfo object.
101137
-**
101138101568
** The caller should invoke sqlite3KeyInfoUnref() on the returned object
101139101569
** when it has finished using it.
101140101570
*/
101141101571
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
101142101572
int i;
@@ -103364,11 +103794,11 @@
103364103794
continue;
103365103795
}
103366103796
}
103367103797
c2 = Utf8Read(zString);
103368103798
if( c==c2 ) continue;
103369
- if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
103799
+ if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){
103370103800
continue;
103371103801
}
103372103802
if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
103373103803
return 0;
103374103804
}
@@ -105823,11 +106253,12 @@
105823106253
*/
105824106254
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
105825106255
FKey *pFKey; /* Iterator variable */
105826106256
FKey *pNext; /* Copy of pFKey->pNextFrom */
105827106257
105828
- assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
106258
+ assert( db==0 || IsVirtual(pTab)
106259
+ || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
105829106260
for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
105830106261
105831106262
/* Remove the FK from the fkeyHash hash table. */
105832106263
if( !db || db->pnBytesFreed==0 ){
105833106264
if( pFKey->pPrevTo ){
@@ -108233,12 +108664,12 @@
108233108664
** shared libraries that want to be imported as extensions into
108234108665
** an SQLite instance. Shared libraries that intend to be loaded
108235108666
** as extensions by SQLite should #include this file instead of
108236108667
** sqlite3.h.
108237108668
*/
108238
-#ifndef _SQLITE3EXT_H_
108239
-#define _SQLITE3EXT_H_
108669
+#ifndef SQLITE3EXT_H
108670
+#define SQLITE3EXT_H
108240108671
/* #include "sqlite3.h" */
108241108672
108242108673
typedef struct sqlite3_api_routines sqlite3_api_routines;
108243108674
108244108675
/*
@@ -108499,10 +108930,13 @@
108499108930
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
108500108931
int (*strlike)(const char*,const char*,unsigned int);
108501108932
int (*db_cacheflush)(sqlite3*);
108502108933
/* Version 3.12.0 and later */
108503108934
int (*system_errno)(sqlite3*);
108935
+ /* Version 3.14.0 and later */
108936
+ int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
108937
+ char *(*expanded_sql)(sqlite3_stmt*);
108504108938
};
108505108939
108506108940
/*
108507108941
** The following macros redefine the API routines so that they are
108508108942
** redirected through the global sqlite3_api structure.
@@ -108744,10 +109178,13 @@
108744109178
#define sqlite3_status64 sqlite3_api->status64
108745109179
#define sqlite3_strlike sqlite3_api->strlike
108746109180
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
108747109181
/* Version 3.12.0 and later */
108748109182
#define sqlite3_system_errno sqlite3_api->system_errno
109183
+/* Version 3.14.0 and later */
109184
+#define sqlite3_trace_v2 sqlite3_api->trace_v2
109185
+#define sqlite3_expanded_sql sqlite3_api->expanded_sql
108749109186
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
108750109187
108751109188
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
108752109189
/* This case when the file really is being compiled as a loadable
108753109190
** extension */
@@ -108761,11 +109198,11 @@
108761109198
# define SQLITE_EXTENSION_INIT1 /*no-op*/
108762109199
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
108763109200
# define SQLITE_EXTENSION_INIT3 /*no-op*/
108764109201
#endif
108765109202
108766
-#endif /* _SQLITE3EXT_H_ */
109203
+#endif /* SQLITE3EXT_H */
108767109204
108768109205
/************** End of sqlite3ext.h ******************************************/
108769109206
/************** Continuing where we left off in loadext.c ********************/
108770109207
/* #include "sqliteInt.h" */
108771109208
/* #include <string.h> */
@@ -109194,10 +109631,11 @@
109194109631
const char *zEntry;
109195109632
char *zAltEntry = 0;
109196109633
void **aHandle;
109197109634
u64 nMsg = 300 + sqlite3Strlen30(zFile);
109198109635
int ii;
109636
+ int rc;
109199109637
109200109638
/* Shared library endings to try if zFile cannot be loaded as written */
109201109639
static const char *azEndings[] = {
109202109640
#if SQLITE_OS_WIN
109203109641
"dll"
@@ -109296,11 +109734,13 @@
109296109734
sqlite3OsDlClose(pVfs, handle);
109297109735
sqlite3_free(zAltEntry);
109298109736
return SQLITE_ERROR;
109299109737
}
109300109738
sqlite3_free(zAltEntry);
109301
- if( xInit(db, &zErrmsg, &sqlite3Apis) ){
109739
+ rc = xInit(db, &zErrmsg, &sqlite3Apis);
109740
+ if( rc ){
109741
+ if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
109302109742
if( pzErrMsg ){
109303109743
*pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
109304109744
}
109305109745
sqlite3_free(zErrmsg);
109306109746
sqlite3OsDlClose(pVfs, handle);
@@ -111034,11 +111474,11 @@
111034111474
111035111475
/* Many of the flag-pragmas modify the code generated by the SQL
111036111476
** compiler (eg. count_changes). So add an opcode to expire all
111037111477
** compiled SQL statements after modifying a pragma value.
111038111478
*/
111039
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
111479
+ sqlite3VdbeAddOp0(v, OP_Expire);
111040111480
setAllPagerFlags(db);
111041111481
}
111042111482
break;
111043111483
}
111044111484
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -111056,11 +111496,11 @@
111056111496
** notnull: True if 'NOT NULL' is part of column declaration
111057111497
** dflt_value: The default value for the column, if any.
111058111498
*/
111059111499
case PragTyp_TABLE_INFO: if( zRight ){
111060111500
Table *pTab;
111061
- pTab = sqlite3FindTable(db, zRight, zDb);
111501
+ pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
111062111502
if( pTab ){
111063111503
static const char *azCol[] = {
111064111504
"cid", "name", "type", "notnull", "dflt_value", "pk"
111065111505
};
111066111506
int i, k;
@@ -111338,16 +111778,14 @@
111338111778
assert( iKey>=0 && iKey<pTab->nCol );
111339111779
if( iKey!=pTab->iPKey ){
111340111780
sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
111341111781
sqlite3ColumnDefault(v, pTab, iKey, regRow);
111342111782
sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v);
111343
- sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow,
111344
- sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v);
111345111783
}else{
111346111784
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
111347111785
}
111348
- sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v);
111786
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v);
111349111787
sqlite3VdbeGoto(v, addrOk);
111350111788
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
111351111789
}else{
111352111790
for(j=0; j<pFK->nCol; j++){
111353111791
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
@@ -112914,10 +113352,11 @@
112914113352
int regReturn; /* Register holding block-output return address */
112915113353
int labelBkOut; /* Start label for the block-output subroutine */
112916113354
int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
112917113355
int labelDone; /* Jump here when done, ex: LIMIT reached */
112918113356
u8 sortFlags; /* Zero or more SORTFLAG_* bits */
113357
+ u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
112919113358
};
112920113359
#define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
112921113360
112922113361
/*
112923113362
** Delete all the content of a Select structure. Deallocate the structure
@@ -113447,13 +113886,34 @@
113447113886
op = OP_IdxInsert;
113448113887
}
113449113888
sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
113450113889
if( iLimit ){
113451113890
int addr;
113891
+ int r1 = 0;
113892
+ /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit
113893
+ ** register is initialized with value of LIMIT+OFFSET.) After the sorter
113894
+ ** fills up, delete the least entry in the sorter after each insert.
113895
+ ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
113452113896
addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
113453113897
sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
113898
+ if( pSort->bOrderedInnerLoop ){
113899
+ r1 = ++pParse->nMem;
113900
+ sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
113901
+ VdbeComment((v, "seq"));
113902
+ }
113454113903
sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
113904
+ if( pSort->bOrderedInnerLoop ){
113905
+ /* If the inner loop is driven by an index such that values from
113906
+ ** the same iteration of the inner loop are in sorted order, then
113907
+ ** immediately jump to the next iteration of an inner loop if the
113908
+ ** entry from the current iteration does not fit into the top
113909
+ ** LIMIT+OFFSET entries of the sorter. */
113910
+ int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
113911
+ sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
113912
+ sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
113913
+ VdbeCoverage(v);
113914
+ }
113455113915
sqlite3VdbeJumpHere(v, addr);
113456113916
}
113457113917
}
113458113918
113459113919
/*
@@ -113864,11 +114324,11 @@
113864114324
** Allocate a KeyInfo object sufficient for an index of N key columns and
113865114325
** X extra columns.
113866114326
*/
113867114327
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
113868114328
int nExtra = (N+X)*(sizeof(CollSeq*)+1);
113869
- KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra);
114329
+ KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra);
113870114330
if( p ){
113871114331
p->aSortOrder = (u8*)&p->aColl[N+X];
113872114332
p->nField = (u16)N;
113873114333
p->nXField = (u16)X;
113874114334
p->enc = ENC(db);
@@ -113886,11 +114346,11 @@
113886114346
*/
113887114347
SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){
113888114348
if( p ){
113889114349
assert( p->nRef>0 );
113890114350
p->nRef--;
113891
- if( p->nRef==0 ) sqlite3DbFree(0, p);
114351
+ if( p->nRef==0 ) sqlite3DbFree(p->db, p);
113892114352
}
113893114353
}
113894114354
113895114355
/*
113896114356
** Make a new pointer to a KeyInfo object
@@ -118034,10 +118494,11 @@
118034118494
if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
118035118495
sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
118036118496
}
118037118497
if( sSort.pOrderBy ){
118038118498
sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
118499
+ sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
118039118500
if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
118040118501
sSort.pOrderBy = 0;
118041118502
}
118042118503
}
118043118504
@@ -120803,11 +121264,11 @@
120803121264
Btree *pTemp; /* The temporary database we vacuum into */
120804121265
char *zSql = 0; /* SQL statements */
120805121266
int saved_flags; /* Saved value of the db->flags */
120806121267
int saved_nChange; /* Saved value of db->nChange */
120807121268
int saved_nTotalChange; /* Saved value of db->nTotalChange */
120808
- void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */
121269
+ u8 saved_mTrace; /* Saved trace settings */
120809121270
Db *pDb = 0; /* Database to detach at end of vacuum */
120810121271
int isMemDb; /* True if vacuuming a :memory: database */
120811121272
int nRes; /* Bytes of reserved space at the end of each page */
120812121273
int nDb; /* Number of attached databases */
120813121274
@@ -120824,14 +121285,14 @@
120824121285
** restored before returning. Then set the writable-schema flag, and
120825121286
** disable CHECK and foreign key constraints. */
120826121287
saved_flags = db->flags;
120827121288
saved_nChange = db->nChange;
120828121289
saved_nTotalChange = db->nTotalChange;
120829
- saved_xTrace = db->xTrace;
121290
+ saved_mTrace = db->mTrace;
120830121291
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
120831121292
db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
120832
- db->xTrace = 0;
121293
+ db->mTrace = 0;
120833121294
120834121295
pMain = db->aDb[0].pBt;
120835121296
isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
120836121297
120837121298
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -121027,11 +121488,11 @@
121027121488
end_of_vacuum:
121028121489
/* Restore the original value of db->flags */
121029121490
db->flags = saved_flags;
121030121491
db->nChange = saved_nChange;
121031121492
db->nTotalChange = saved_nTotalChange;
121032
- db->xTrace = saved_xTrace;
121493
+ db->mTrace = saved_mTrace;
121033121494
sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
121034121495
121035121496
/* Currently there is an SQL level transaction open on the vacuum
121036121497
** database. No locks are held on any other files (since the main file
121037121498
** was committed at the btree level). So it safe to end the transaction
@@ -121476,11 +121937,11 @@
121476121937
);
121477121938
sqlite3DbFree(db, zStmt);
121478121939
v = sqlite3GetVdbe(pParse);
121479121940
sqlite3ChangeCookie(pParse, iDb);
121480121941
121481
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
121942
+ sqlite3VdbeAddOp0(v, OP_Expire);
121482121943
zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
121483121944
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
121484121945
121485121946
iReg = ++pParse->nMem;
121486121947
sqlite3VdbeLoadString(v, iReg, pTab->zName);
@@ -121812,14 +122273,28 @@
121812122273
&& !db->mallocFailed
121813122274
&& !pParse->pNewTable->pSelect
121814122275
&& (pParse->pNewTable->tabFlags & TF_Virtual)==0
121815122276
){
121816122277
if( !pTab->aCol ){
121817
- pTab->aCol = pParse->pNewTable->aCol;
121818
- pTab->nCol = pParse->pNewTable->nCol;
121819
- pParse->pNewTable->nCol = 0;
121820
- pParse->pNewTable->aCol = 0;
122278
+ Table *pNew = pParse->pNewTable;
122279
+ Index *pIdx;
122280
+ pTab->aCol = pNew->aCol;
122281
+ pTab->nCol = pNew->nCol;
122282
+ pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
122283
+ pNew->nCol = 0;
122284
+ pNew->aCol = 0;
122285
+ assert( pTab->pIndex==0 );
122286
+ if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){
122287
+ rc = SQLITE_ERROR;
122288
+ }
122289
+ pIdx = pNew->pIndex;
122290
+ if( pIdx ){
122291
+ assert( pIdx->pNext==0 );
122292
+ pTab->pIndex = pIdx;
122293
+ pNew->pIndex = 0;
122294
+ pIdx->pTable = pTab;
122295
+ }
121821122296
}
121822122297
pCtx->bDeclared = 1;
121823122298
}else{
121824122299
sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
121825122300
sqlite3DbFree(db, zErr);
@@ -122145,11 +122620,11 @@
122145122620
sqlite3OomFault(pToplevel->db);
122146122621
}
122147122622
}
122148122623
122149122624
/*
122150
-** Check to see if virtual tale module pMod can be have an eponymous
122625
+** Check to see if virtual table module pMod can be have an eponymous
122151122626
** virtual table instance. If it can, create one if one does not already
122152122627
** exist. Return non-zero if the eponymous virtual table instance exists
122153122628
** when this routine returns, and return zero if it does not exist.
122154122629
**
122155122630
** An eponymous virtual table instance is one that is named after its
@@ -122162,21 +122637,22 @@
122162122637
*/
122163122638
SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
122164122639
const sqlite3_module *pModule = pMod->pModule;
122165122640
Table *pTab;
122166122641
char *zErr = 0;
122167
- int nName;
122168122642
int rc;
122169122643
sqlite3 *db = pParse->db;
122170122644
if( pMod->pEpoTab ) return 1;
122171122645
if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;
122172
- nName = sqlite3Strlen30(pMod->zName) + 1;
122173
- pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName);
122646
+ pTab = sqlite3DbMallocZero(db, sizeof(Table));
122174122647
if( pTab==0 ) return 0;
122648
+ pTab->zName = sqlite3DbStrDup(db, pMod->zName);
122649
+ if( pTab->zName==0 ){
122650
+ sqlite3DbFree(db, pTab);
122651
+ return 0;
122652
+ }
122175122653
pMod->pEpoTab = pTab;
122176
- pTab->zName = (char*)&pTab[1];
122177
- memcpy(pTab->zName, pMod->zName, nName);
122178122654
pTab->nRef = 1;
122179122655
pTab->pSchema = db->aDb[0].pSchema;
122180122656
pTab->tabFlags |= TF_Virtual;
122181122657
pTab->nModuleArg = 0;
122182122658
pTab->iPKey = -1;
@@ -122198,13 +122674,15 @@
122198122674
** virtual table module pMod, if it exists.
122199122675
*/
122200122676
SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){
122201122677
Table *pTab = pMod->pEpoTab;
122202122678
if( pTab!=0 ){
122203
- sqlite3DeleteColumnNames(db, pTab);
122204
- sqlite3VtabClear(db, pTab);
122205
- sqlite3DbFree(db, pTab);
122679
+ /* Mark the table as Ephemeral prior to deleting it, so that the
122680
+ ** sqlite3DeleteTable() routine will know that it is not stored in
122681
+ ** the schema. */
122682
+ pTab->tabFlags |= TF_Ephemeral;
122683
+ sqlite3DeleteTable(db, pTab);
122206122684
pMod->pEpoTab = 0;
122207122685
}
122208122686
}
122209122687
122210122688
/*
@@ -122707,12 +123185,13 @@
122707123185
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
122708123186
i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
122709123187
u8 sorted; /* True if really sorted (not just grouped) */
122710123188
u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
122711123189
u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
122712
- u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */
123190
+ u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
122713123191
u8 nLevel; /* Number of nested loop */
123192
+ u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */
122714123193
int iTop; /* The very beginning of the WHERE loop */
122715123194
int iContinue; /* Jump here to continue with next record */
122716123195
int iBreak; /* Jump here to break out of the loop */
122717123196
int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
122718123197
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
@@ -122725,10 +123204,13 @@
122725123204
** Private interfaces - callable only by other where.c routines.
122726123205
**
122727123206
** where.c:
122728123207
*/
122729123208
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
123209
+#ifdef WHERETRACE_ENABLED
123210
+SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);
123211
+#endif
122730123212
SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(
122731123213
WhereClause *pWC, /* The WHERE clause to be searched */
122732123214
int iCur, /* Cursor number of LHS */
122733123215
int iColumn, /* Column number of LHS */
122734123216
Bitmask notReady, /* RHS must not overlap with this mask */
@@ -122941,11 +123423,11 @@
122941123423
StrAccum str; /* EQP output string */
122942123424
char zBuf[100]; /* Initial space for EQP output string */
122943123425
122944123426
pLoop = pLevel->pWLoop;
122945123427
flags = pLoop->wsFlags;
122946
- if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0;
123428
+ if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;
122947123429
122948123430
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
122949123431
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
122950123432
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
122951123433
@@ -123384,11 +123866,11 @@
123384123866
**
123385123867
** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
123386123868
** expression: "x>='ABC' AND x<'abd'". But this requires that the range
123387123869
** scan loop run twice, once for strings and a second time for BLOBs.
123388123870
** The OP_String opcodes on the second pass convert the upper and lower
123389
-** bound string contants to blobs. This routine makes the necessary changes
123871
+** bound string constants to blobs. This routine makes the necessary changes
123390123872
** to the OP_String opcodes for that to happen.
123391123873
**
123392123874
** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then
123393123875
** only the one pass through the string space is required, so this routine
123394123876
** becomes a no-op.
@@ -123441,10 +123923,42 @@
123441123923
pWalker->eCode = 1;
123442123924
}
123443123925
return WRC_Continue;
123444123926
}
123445123927
123928
+/*
123929
+** Test whether or not expression pExpr, which was part of a WHERE clause,
123930
+** should be included in the cursor-hint for a table that is on the rhs
123931
+** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the
123932
+** expression is not suitable.
123933
+**
123934
+** An expression is unsuitable if it might evaluate to non NULL even if
123935
+** a TK_COLUMN node that does affect the value of the expression is set
123936
+** to NULL. For example:
123937
+**
123938
+** col IS NULL
123939
+** col IS NOT NULL
123940
+** coalesce(col, 1)
123941
+** CASE WHEN col THEN 0 ELSE 1 END
123942
+*/
123943
+static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
123944
+ if( pExpr->op==TK_IS
123945
+ || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT
123946
+ || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE
123947
+ ){
123948
+ pWalker->eCode = 1;
123949
+ }else if( pExpr->op==TK_FUNCTION ){
123950
+ int d1;
123951
+ char d2[3];
123952
+ if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){
123953
+ pWalker->eCode = 1;
123954
+ }
123955
+ }
123956
+
123957
+ return WRC_Continue;
123958
+}
123959
+
123446123960
123447123961
/*
123448123962
** This function is called on every node of an expression tree used as an
123449123963
** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN
123450123964
** that accesses any table other than the one identified by
@@ -123493,10 +124007,11 @@
123493124007
123494124008
/*
123495124009
** Insert an OP_CursorHint instruction if it is appropriate to do so.
123496124010
*/
123497124011
static void codeCursorHint(
124012
+ struct SrcList_item *pTabItem, /* FROM clause item */
123498124013
WhereInfo *pWInfo, /* The where clause */
123499124014
WhereLevel *pLevel, /* Which loop to provide hints for */
123500124015
WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
123501124016
){
123502124017
Parse *pParse = pWInfo->pParse;
@@ -123523,11 +124038,46 @@
123523124038
pWC = &pWInfo->sWC;
123524124039
for(i=0; i<pWC->nTerm; i++){
123525124040
pTerm = &pWC->a[i];
123526124041
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
123527124042
if( pTerm->prereqAll & pLevel->notReady ) continue;
123528
- if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124043
+
124044
+ /* Any terms specified as part of the ON(...) clause for any LEFT
124045
+ ** JOIN for which the current table is not the rhs are omitted
124046
+ ** from the cursor-hint.
124047
+ **
124048
+ ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
124049
+ ** that were specified as part of the WHERE clause must be excluded.
124050
+ ** This is to address the following:
124051
+ **
124052
+ ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;
124053
+ **
124054
+ ** Say there is a single row in t2 that matches (t1.a=t2.b), but its
124055
+ ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is
124056
+ ** pushed down to the cursor, this row is filtered out, causing
124057
+ ** SQLite to synthesize a row of NULL values. Which does match the
124058
+ ** WHERE clause, and so the query returns a row. Which is incorrect.
124059
+ **
124060
+ ** For the same reason, WHERE terms such as:
124061
+ **
124062
+ ** WHERE 1 = (t2.c IS NULL)
124063
+ **
124064
+ ** are also excluded. See codeCursorHintIsOrFunction() for details.
124065
+ */
124066
+ if( pTabItem->fg.jointype & JT_LEFT ){
124067
+ Expr *pExpr = pTerm->pExpr;
124068
+ if( !ExprHasProperty(pExpr, EP_FromJoin)
124069
+ || pExpr->iRightJoinTable!=pTabItem->iCursor
124070
+ ){
124071
+ sWalker.eCode = 0;
124072
+ sWalker.xExprCallback = codeCursorHintIsOrFunction;
124073
+ sqlite3WalkExpr(&sWalker, pTerm->pExpr);
124074
+ if( sWalker.eCode ) continue;
124075
+ }
124076
+ }else{
124077
+ if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124078
+ }
123529124079
123530124080
/* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize
123531124081
** the cursor. These terms are not needed as hints for a pure range
123532124082
** scan (that has no == terms) so omit them. */
123533124083
if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
@@ -123557,11 +124107,11 @@
123557124107
(sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
123558124108
(const char*)pExpr, P4_EXPR);
123559124109
}
123560124110
}
123561124111
#else
123562
-# define codeCursorHint(A,B,C) /* No-op */
124112
+# define codeCursorHint(A,B,C,D) /* No-op */
123563124113
#endif /* SQLITE_ENABLE_CURSOR_HINTS */
123564124114
123565124115
/*
123566124116
** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
123567124117
** a rowid value just read from cursor iIdxCur, open on index pIdx. This
@@ -123591,11 +124141,11 @@
123591124141
123592124142
assert( iIdxCur>0 );
123593124143
assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
123594124144
123595124145
sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
123596
- if( (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)
124146
+ if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
123597124147
&& DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
123598124148
){
123599124149
int i;
123600124150
Table *pTab = pIdx->pTable;
123601124151
int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
@@ -123646,11 +124196,11 @@
123646124196
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
123647124197
iCur = pTabItem->iCursor;
123648124198
pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
123649124199
bRev = (pWInfo->revMask>>iLevel)&1;
123650124200
omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
123651
- && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
124201
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
123652124202
VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
123653124203
123654124204
/* Create labels for the "break" and "continue" instructions
123655124205
** for the current loop. Jump to addrBrk to break out of a loop.
123656124206
** Jump to cont to go immediately to the next iteration of the
@@ -123786,12 +124336,11 @@
123786124336
testcase( pTerm->wtFlags & TERM_VIRTUAL );
123787124337
iReleaseReg = ++pParse->nMem;
123788124338
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
123789124339
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
123790124340
addrNxt = pLevel->addrNxt;
123791
- sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); VdbeCoverage(v);
123792
- sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
124341
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
123793124342
VdbeCoverage(v);
123794124343
sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
123795124344
sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
123796124345
VdbeComment((v, "pk"));
123797124346
pLevel->op = OP_Noop;
@@ -123814,11 +124363,11 @@
123814124363
if( bRev ){
123815124364
pTerm = pStart;
123816124365
pStart = pEnd;
123817124366
pEnd = pTerm;
123818124367
}
123819
- codeCursorHint(pWInfo, pLevel, pEnd);
124368
+ codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
123820124369
if( pStart ){
123821124370
Expr *pX; /* The expression that defines the start bound */
123822124371
int r1, rTemp; /* Registers for holding the start boundary */
123823124372
123824124373
/* The following constant maps TK_xx codes into corresponding
@@ -124028,11 +124577,11 @@
124028124577
124029124578
/* Generate code to evaluate all constraint terms using == or IN
124030124579
** and store the values of those terms in an array of registers
124031124580
** starting at regBase.
124032124581
*/
124033
- codeCursorHint(pWInfo, pLevel, pRangeEnd);
124582
+ codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124034124583
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124035124584
assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124036124585
if( zStartAff ) cEndAff = zStartAff[nEq];
124037124586
addrNxt = pLevel->addrNxt;
124038124587
@@ -124332,15 +124881,11 @@
124332124881
124333124882
/* Run a separate WHERE clause for each term of the OR clause. After
124334124883
** eliminating duplicates from other WHERE clauses, the action for each
124335124884
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
124336124885
*/
124337
- wctrlFlags = WHERE_OMIT_OPEN_CLOSE
124338
- | WHERE_FORCE_TABLE
124339
- | WHERE_ONETABLE_ONLY
124340
- | WHERE_NO_AUTOINDEX
124341
- | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
124886
+ wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
124342124887
for(ii=0; ii<pOrWc->nTerm; ii++){
124343124888
WhereTerm *pOrTerm = &pOrWc->a[ii];
124344124889
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
124345124890
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
124346124891
Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -124444,11 +124989,10 @@
124444124989
&& (ii==0 || pSubLoop->u.btree.pIndex==pCov)
124445124990
&& (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
124446124991
){
124447124992
assert( pSubWInfo->a[0].iIdxCur==iCovCur );
124448124993
pCov = pSubLoop->u.btree.pIndex;
124449
- wctrlFlags |= WHERE_REOPEN_IDX;
124450124994
}else{
124451124995
pCov = 0;
124452124996
}
124453124997
124454124998
/* Finish the loop through table entries that match term pOrTerm. */
@@ -124481,11 +125025,11 @@
124481125025
if( pTabItem->fg.isRecursive ){
124482125026
/* Tables marked isRecursive have only a single row that is stored in
124483125027
** a pseudo-cursor. No need to Rewind or Next such cursors. */
124484125028
pLevel->op = OP_Noop;
124485125029
}else{
124486
- codeCursorHint(pWInfo, pLevel, 0);
125030
+ codeCursorHint(pTabItem, pWInfo, pLevel, 0);
124487125031
pLevel->op = aStep[bRev];
124488125032
pLevel->p1 = iCur;
124489125033
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
124490125034
VdbeCoverageIf(v, bRev==0);
124491125035
VdbeCoverageIf(v, bRev!=0);
@@ -124506,11 +125050,11 @@
124506125050
testcase( pTerm->wtFlags & TERM_VIRTUAL );
124507125051
testcase( pTerm->wtFlags & TERM_CODED );
124508125052
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
124509125053
if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
124510125054
testcase( pWInfo->untestedTerms==0
124511
- && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
125055
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
124512125056
pWInfo->untestedTerms = 1;
124513125057
continue;
124514125058
}
124515125059
pE = pTerm->pExpr;
124516125060
assert( pE!=0 );
@@ -125168,11 +125712,13 @@
125168125712
sqlite3WhereExprAnalyze(pSrc, pAndWC);
125169125713
pAndWC->pOuter = pWC;
125170125714
if( !db->mallocFailed ){
125171125715
for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
125172125716
assert( pAndTerm->pExpr );
125173
- if( allowedOp(pAndTerm->pExpr->op) ){
125717
+ if( allowedOp(pAndTerm->pExpr->op)
125718
+ || pAndTerm->eOperator==WO_MATCH
125719
+ ){
125174125720
b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);
125175125721
}
125176125722
}
125177125723
}
125178125724
indexable &= b;
@@ -125383,16 +125929,14 @@
125383125929
return 0;
125384125930
}
125385125931
pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
125386125932
if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
125387125933
pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
125388
- /* Since pLeft and pRight are both a column references, their collating
125389
- ** sequence should always be defined. */
125390
- zColl1 = ALWAYS(pColl) ? pColl->zName : 0;
125934
+ zColl1 = pColl ? pColl->zName : 0;
125391125935
pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
125392
- zColl2 = ALWAYS(pColl) ? pColl->zName : 0;
125393
- return sqlite3StrICmp(zColl1, zColl2)==0;
125936
+ zColl2 = pColl ? pColl->zName : 0;
125937
+ return sqlite3_stricmp(zColl1, zColl2)==0;
125394125938
}
125395125939
125396125940
/*
125397125941
** Recursively walk the expressions of a SELECT statement and generate
125398125942
** a bitmask indicating which tables are used in that expression
@@ -125722,11 +126266,11 @@
125722126266
** current expression is of the form: column MATCH expr.
125723126267
** This information is used by the xBestIndex methods of
125724126268
** virtual tables. The native query optimizer does not attempt
125725126269
** to do anything with MATCH functions.
125726126270
*/
125727
- if( isMatchOfColumn(pExpr, &eOp2) ){
126271
+ if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){
125728126272
int idxNew;
125729126273
Expr *pRight, *pLeft;
125730126274
WhereTerm *pNewTerm;
125731126275
Bitmask prereqColumn, prereqExpr;
125732126276
@@ -126014,10 +126558,22 @@
126014126558
** Return FALSE if the output needs to be sorted.
126015126559
*/
126016126560
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
126017126561
return pWInfo->nOBSat;
126018126562
}
126563
+
126564
+/*
126565
+** Return TRUE if the innermost loop of the WHERE clause implementation
126566
+** returns rows in ORDER BY order for complete run of the inner loop.
126567
+**
126568
+** Across multiple iterations of outer loops, the output rows need not be
126569
+** sorted. As long as rows are sorted for just the innermost loop, this
126570
+** routine can return TRUE.
126571
+*/
126572
+SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
126573
+ return pWInfo->bOrderedInnerLoop;
126574
+}
126019126575
126020126576
/*
126021126577
** Return the VDBE address or label to jump to in order to continue
126022126578
** immediately with the next row of a WHERE clause.
126023126579
*/
@@ -127600,20 +128156,42 @@
127600128156
static void whereTermPrint(WhereTerm *pTerm, int iTerm){
127601128157
if( pTerm==0 ){
127602128158
sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
127603128159
}else{
127604128160
char zType[4];
128161
+ char zLeft[50];
127605128162
memcpy(zType, "...", 4);
127606128163
if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
127607128164
if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
127608128165
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
128166
+ if( pTerm->eOperator & WO_SINGLE ){
128167
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
128168
+ pTerm->leftCursor, pTerm->u.leftColumn);
128169
+ }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
128170
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
128171
+ pTerm->u.pOrInfo->indexable);
128172
+ }else{
128173
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128174
+ }
127609128175
sqlite3DebugPrintf(
127610
- "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n",
127611
- iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb,
128176
+ "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
128177
+ iTerm, pTerm, zType, zLeft, pTerm->truthProb,
127612128178
pTerm->eOperator, pTerm->wtFlags);
127613128179
sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
127614128180
}
128181
+}
128182
+#endif
128183
+
128184
+#ifdef WHERETRACE_ENABLED
128185
+/*
128186
+** Show the complete content of a WhereClause
128187
+*/
128188
+SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){
128189
+ int i;
128190
+ for(i=0; i<pWC->nTerm; i++){
128191
+ whereTermPrint(&pWC->a[i], i);
128192
+ }
127615128193
}
127616128194
#endif
127617128195
127618128196
#ifdef WHERETRACE_ENABLED
127619128197
/*
@@ -128599,11 +129177,11 @@
128599129177
rLogSize = estLog(rSize);
128600129178
128601129179
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
128602129180
/* Automatic indexes */
128603129181
if( !pBuilder->pOrSet /* Not part of an OR optimization */
128604
- && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
129182
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
128605129183
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
128606129184
&& pSrc->pIBIndex==0 /* Has no INDEXED BY clause */
128607129185
&& !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
128608129186
&& HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
128609129187
&& !pSrc->fg.isCorrelated /* Not a correlated subquery */
@@ -128631,10 +129209,11 @@
128631129209
pNew->rSetup = rLogSize + rSize + 4;
128632129210
if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
128633129211
pNew->rSetup += 24;
128634129212
}
128635129213
ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
129214
+ if( pNew->rSetup<0 ) pNew->rSetup = 0;
128636129215
/* TUNING: Each index lookup yields 20 rows in the table. This
128637129216
** is more than the usual guess of 10 rows, since we have no way
128638129217
** of knowing how selective the index will ultimately be. It would
128639129218
** not be unreasonable to make this value much larger. */
128640129219
pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
@@ -128691,10 +129270,11 @@
128691129270
}
128692129271
128693129272
/* Full scan via index */
128694129273
if( b
128695129274
|| !HasRowid(pTab)
129275
+ || pProbe->pPartIdxWhere!=0
128696129276
|| ( m==0
128697129277
&& pProbe->bUnordered==0
128698129278
&& (pProbe->szIdxRow<pTab->szTabRow)
128699129279
&& (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
128700129280
&& sqlite3GlobalConfig.bUseCis
@@ -129076,13 +129656,11 @@
129076129656
sCur.n = 0;
129077129657
#ifdef WHERETRACE_ENABLED
129078129658
WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
129079129659
(int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
129080129660
if( sqlite3WhereTrace & 0x400 ){
129081
- for(i=0; i<sSubBuild.pWC->nTerm; i++){
129082
- whereTermPrint(&sSubBuild.pWC->a[i], i);
129083
- }
129661
+ sqlite3WhereClausePrint(sSubBuild.pWC);
129084129662
}
129085129663
#endif
129086129664
#ifndef SQLITE_OMIT_VIRTUALTABLE
129087129665
if( IsVirtual(pItem->pTab) ){
129088129666
rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
@@ -129171,19 +129749,22 @@
129171129749
/* This condition is true when pItem is the FROM clause term on the
129172129750
** right-hand-side of a LEFT or CROSS JOIN. */
129173129751
mPrereq = mPrior;
129174129752
}
129175129753
priorJointype = pItem->fg.jointype;
129754
+#ifndef SQLITE_OMIT_VIRTUALTABLE
129176129755
if( IsVirtual(pItem->pTab) ){
129177129756
struct SrcList_item *p;
129178129757
for(p=&pItem[1]; p<pEnd; p++){
129179129758
if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){
129180129759
mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
129181129760
}
129182129761
}
129183129762
rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
129184
- }else{
129763
+ }else
129764
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
129765
+ {
129185129766
rc = whereLoopAddBtree(pBuilder, mPrereq);
129186129767
}
129187129768
if( rc==SQLITE_OK ){
129188129769
rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
129189129770
}
@@ -129214,11 +129795,11 @@
129214129795
*/
129215129796
static i8 wherePathSatisfiesOrderBy(
129216129797
WhereInfo *pWInfo, /* The WHERE clause */
129217129798
ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
129218129799
WherePath *pPath, /* The WherePath to check */
129219
- u16 wctrlFlags, /* Might contain WHERE_GROUPBY or WHERE_DISTINCTBY */
129800
+ u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */
129220129801
u16 nLoop, /* Number of entries in pPath->aLoop[] */
129221129802
WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
129222129803
Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */
129223129804
){
129224129805
u8 revSet; /* True if rev is known */
@@ -129225,10 +129806,11 @@
129225129806
u8 rev; /* Composite sort order */
129226129807
u8 revIdx; /* Index sort order */
129227129808
u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */
129228129809
u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */
129229129810
u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
129811
+ u16 eqOpMask; /* Allowed equality operators */
129230129812
u16 nKeyCol; /* Number of key columns in pIndex */
129231129813
u16 nColumn; /* Total number of ordered columns in the index */
129232129814
u16 nOrderBy; /* Number terms in the ORDER BY clause */
129233129815
int iLoop; /* Index of WhereLoop in pPath being processed */
129234129816
int i, j; /* Loop counters */
@@ -129275,13 +129857,20 @@
129275129857
if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
129276129858
isOrderDistinct = 1;
129277129859
obDone = MASKBIT(nOrderBy)-1;
129278129860
orderDistinctMask = 0;
129279129861
ready = 0;
129862
+ eqOpMask = WO_EQ | WO_IS | WO_ISNULL;
129863
+ if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;
129280129864
for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
129281129865
if( iLoop>0 ) ready |= pLoop->maskSelf;
129282
- pLoop = iLoop<nLoop ? pPath->aLoop[iLoop] : pLast;
129866
+ if( iLoop<nLoop ){
129867
+ pLoop = pPath->aLoop[iLoop];
129868
+ if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
129869
+ }else{
129870
+ pLoop = pLast;
129871
+ }
129283129872
if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
129284129873
if( pLoop->u.vtab.isOrdered ) obSat = obDone;
129285129874
break;
129286129875
}
129287129876
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -129295,11 +129884,11 @@
129295129884
if( MASKBIT(i) & obSat ) continue;
129296129885
pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
129297129886
if( pOBExpr->op!=TK_COLUMN ) continue;
129298129887
if( pOBExpr->iTable!=iCur ) continue;
129299129888
pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
129300
- ~ready, WO_EQ|WO_ISNULL|WO_IS, 0);
129889
+ ~ready, eqOpMask, 0);
129301129890
if( pTerm==0 ) continue;
129302129891
if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
129303129892
const char *z1, *z2;
129304129893
pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
129305129894
if( !pColl ) pColl = db->pDfltColl;
@@ -129335,14 +129924,16 @@
129335129924
rev = revSet = 0;
129336129925
distinctColumns = 0;
129337129926
for(j=0; j<nColumn; j++){
129338129927
u8 bOnce; /* True to run the ORDER BY search loop */
129339129928
129340
- /* Skip over == and IS NULL terms */
129929
+ /* Skip over == and IS and ISNULL terms.
129930
+ ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
129931
+ */
129341129932
if( j<pLoop->u.btree.nEq
129342129933
&& pLoop->nSkip==0
129343
- && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0
129934
+ && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
129344129935
){
129345129936
if( i & WO_ISNULL ){
129346129937
testcase( isOrderDistinct );
129347129938
isOrderDistinct = 0;
129348129939
}
@@ -129862,12 +130453,23 @@
129862130453
if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
129863130454
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
129864130455
}
129865130456
}else{
129866130457
pWInfo->nOBSat = pFrom->isOrdered;
129867
- if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
129868130458
pWInfo->revMask = pFrom->revLoop;
130459
+ if( pWInfo->nOBSat<=0 ){
130460
+ pWInfo->nOBSat = 0;
130461
+ if( nLoop>0 ){
130462
+ Bitmask m;
130463
+ int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
130464
+ WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
130465
+ if( rc==pWInfo->pOrderBy->nExpr ){
130466
+ pWInfo->bOrderedInnerLoop = 1;
130467
+ pWInfo->revMask = m;
130468
+ }
130469
+ }
130470
+ }
129869130471
}
129870130472
if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
129871130473
&& pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
129872130474
){
129873130475
Bitmask revMask = 0;
@@ -129911,11 +130513,11 @@
129911130513
int j;
129912130514
Table *pTab;
129913130515
Index *pIdx;
129914130516
129915130517
pWInfo = pBuilder->pWInfo;
129916
- if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0;
130518
+ if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
129917130519
assert( pWInfo->pTabList->nSrc>=1 );
129918130520
pItem = pWInfo->pTabList->a;
129919130521
pTab = pItem->pTab;
129920130522
if( IsVirtual(pTab) ) return 0;
129921130523
if( pItem->fg.isIndexedBy ) return 0;
@@ -130058,11 +130660,11 @@
130058130660
** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
130059130661
** if there is one. If there is no ORDER BY clause or if this routine
130060130662
** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
130061130663
**
130062130664
** The iIdxCur parameter is the cursor number of an index. If
130063
-** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index
130665
+** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
130064130666
** to use for OR clause processing. The WHERE clause should use this
130065130667
** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
130066130668
** the first cursor in an array of cursors for all indices. iIdxCur should
130067130669
** be used to compute the appropriate cursor depending on which index is
130068130670
** used.
@@ -130072,11 +130674,11 @@
130072130674
SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
130073130675
Expr *pWhere, /* The WHERE clause */
130074130676
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
130075130677
ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
130076130678
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
130077
- int iAuxArg /* If WHERE_ONETABLE_ONLY is set, index cursor number
130679
+ int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
130078130680
** If WHERE_USE_LIMIT, then the limit amount */
130079130681
){
130080130682
int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
130081130683
int nTabList; /* Number of elements in pTabList */
130082130684
WhereInfo *pWInfo; /* Will become the return value of this function */
@@ -130091,15 +130693,15 @@
130091130693
int rc; /* Return code */
130092130694
u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */
130093130695
130094130696
assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (
130095130697
(wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
130096
- && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
130698
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130097130699
));
130098130700
130099
- /* Only one of WHERE_ONETABLE_ONLY or WHERE_USE_LIMIT */
130100
- assert( (wctrlFlags & WHERE_ONETABLE_ONLY)==0
130701
+ /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */
130702
+ assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130101130703
|| (wctrlFlags & WHERE_USE_LIMIT)==0 );
130102130704
130103130705
/* Variable initialization */
130104130706
db = pParse->db;
130105130707
memset(&sWLB, 0, sizeof(sWLB));
@@ -130123,15 +130725,15 @@
130123130725
sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
130124130726
return 0;
130125130727
}
130126130728
130127130729
/* This function normally generates a nested loop for all tables in
130128
- ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should
130730
+ ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should
130129130731
** only generate code for the first table in pTabList and assume that
130130130732
** any cursors associated with subsequent tables are uninitialized.
130131130733
*/
130132
- nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
130734
+ nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;
130133130735
130134130736
/* Allocate and initialize the WhereInfo structure that will become the
130135130737
** return value. A single allocation is used to store the WhereInfo
130136130738
** struct, the contents of WhereInfo.a[], the WhereClause structure
130137130739
** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
@@ -130203,11 +130805,11 @@
130203130805
** important. Ticket #3015.
130204130806
**
130205130807
** Note that bitmasks are created for all pTabList->nSrc tables in
130206130808
** pTabList, not just the first nTabList tables. nTabList is normally
130207130809
** equal to pTabList->nSrc but might be shortened to 1 if the
130208
- ** WHERE_ONETABLE_ONLY flag is set.
130810
+ ** WHERE_OR_SUBCLAUSE flag is set.
130209130811
*/
130210130812
for(ii=0; ii<pTabList->nSrc; ii++){
130211130813
createMask(pMaskSet, pTabList->a[ii].iCursor);
130212130814
sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
130213130815
}
@@ -130241,14 +130843,11 @@
130241130843
sqlite3DebugPrintf(", limit: %d", iAuxArg);
130242130844
}
130243130845
sqlite3DebugPrintf(")\n");
130244130846
}
130245130847
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
130246
- int i;
130247
- for(i=0; i<sWLB.pWC->nTerm; i++){
130248
- whereTermPrint(&sWLB.pWC->a[i], i);
130249
- }
130848
+ sqlite3WhereClausePrint(sWLB.pWC);
130250130849
}
130251130850
#endif
130252130851
130253130852
if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
130254130853
rc = whereLoopAddAll(&sWLB);
@@ -130386,11 +130985,11 @@
130386130985
}else if( IsVirtual(pTab) ){
130387130986
/* noop */
130388130987
}else
130389130988
#endif
130390130989
if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
130391
- && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
130990
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
130392130991
int op = OP_OpenRead;
130393130992
if( pWInfo->eOnePass!=ONEPASS_OFF ){
130394130993
op = OP_OpenWrite;
130395130994
pWInfo->aiCurOnePass[0] = pTabItem->iCursor;
130396130995
};
@@ -130425,11 +131024,11 @@
130425131024
int iIndexCur;
130426131025
int op = OP_OpenRead;
130427131026
/* iAuxArg is always set if to a positive value if ONEPASS is possible */
130428131027
assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );
130429131028
if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)
130430
- && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0
131029
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0
130431131030
){
130432131031
/* This is one term of an OR-optimization using the PRIMARY KEY of a
130433131032
** WITHOUT ROWID table. No need for a separate index */
130434131033
iIndexCur = pLevel->iTabCur;
130435131034
op = 0;
@@ -130441,13 +131040,13 @@
130441131040
iIndexCur++;
130442131041
pJ = pJ->pNext;
130443131042
}
130444131043
op = OP_OpenWrite;
130445131044
pWInfo->aiCurOnePass[1] = iIndexCur;
130446
- }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){
131045
+ }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){
130447131046
iIndexCur = iAuxArg;
130448
- if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx;
131047
+ op = OP_ReopenIdx;
130449131048
}else{
130450131049
iIndexCur = pParse->nTab++;
130451131050
}
130452131051
pLevel->iIdxCur = iIndexCur;
130453131052
assert( pIx->pSchema==pTab->pSchema );
@@ -130505,11 +131104,11 @@
130505131104
pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
130506131105
);
130507131106
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
130508131107
notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
130509131108
pWInfo->iContinue = pLevel->addrCont;
130510
- if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){
131109
+ if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
130511131110
sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
130512131111
}
130513131112
}
130514131113
130515131114
/* Done. */
@@ -130628,16 +131227,16 @@
130628131227
continue;
130629131228
}
130630131229
130631131230
/* Close all of the cursors that were opened by sqlite3WhereBegin.
130632131231
** Except, do not close cursors that will be reused by the OR optimization
130633
- ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors
131232
+ ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
130634131233
** created for the ONEPASS optimization.
130635131234
*/
130636131235
if( (pTab->tabFlags & TF_Ephemeral)==0
130637131236
&& pTab->pSelect==0
130638
- && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
131237
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130639131238
){
130640131239
int ws = pLoop->wsFlags;
130641131240
if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
130642131241
sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
130643131242
}
@@ -130980,49 +131579,49 @@
130980131579
#ifndef INTERFACE
130981131580
# define INTERFACE 1
130982131581
#endif
130983131582
/************* Begin control #defines *****************************************/
130984131583
#define YYCODETYPE unsigned char
130985
-#define YYNOCODE 251
131584
+#define YYNOCODE 252
130986131585
#define YYACTIONTYPE unsigned short int
130987131586
#define YYWILDCARD 96
130988131587
#define sqlite3ParserTOKENTYPE Token
130989131588
typedef union {
130990131589
int yyinit;
130991131590
sqlite3ParserTOKENTYPE yy0;
130992
- struct LimitVal yy64;
130993
- Expr* yy122;
130994
- Select* yy159;
130995
- IdList* yy180;
130996
- struct {int value; int mask;} yy207;
130997
- struct LikeOp yy318;
130998
- TriggerStep* yy327;
130999
- With* yy331;
131000
- ExprSpan yy342;
131001
- SrcList* yy347;
131002
- int yy392;
131003
- struct TrigEvent yy410;
131004
- ExprList* yy442;
131591
+ Expr* yy72;
131592
+ TriggerStep* yy145;
131593
+ ExprList* yy148;
131594
+ SrcList* yy185;
131595
+ ExprSpan yy190;
131596
+ int yy194;
131597
+ Select* yy243;
131598
+ IdList* yy254;
131599
+ With* yy285;
131600
+ struct TrigEvent yy332;
131601
+ struct LimitVal yy354;
131602
+ struct LikeOp yy392;
131603
+ struct {int value; int mask;} yy497;
131005131604
} YYMINORTYPE;
131006131605
#ifndef YYSTACKDEPTH
131007131606
#define YYSTACKDEPTH 100
131008131607
#endif
131009131608
#define sqlite3ParserARG_SDECL Parse *pParse;
131010131609
#define sqlite3ParserARG_PDECL ,Parse *pParse
131011131610
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131012131611
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
131013131612
#define YYFALLBACK 1
131014
-#define YYNSTATE 440
131015
-#define YYNRULE 326
131016
-#define YY_MAX_SHIFT 439
131017
-#define YY_MIN_SHIFTREDUCE 649
131018
-#define YY_MAX_SHIFTREDUCE 974
131019
-#define YY_MIN_REDUCE 975
131020
-#define YY_MAX_REDUCE 1300
131021
-#define YY_ERROR_ACTION 1301
131022
-#define YY_ACCEPT_ACTION 1302
131023
-#define YY_NO_ACTION 1303
131613
+#define YYNSTATE 443
131614
+#define YYNRULE 328
131615
+#define YY_MAX_SHIFT 442
131616
+#define YY_MIN_SHIFTREDUCE 653
131617
+#define YY_MAX_SHIFTREDUCE 980
131618
+#define YY_MIN_REDUCE 981
131619
+#define YY_MAX_REDUCE 1308
131620
+#define YY_ERROR_ACTION 1309
131621
+#define YY_ACCEPT_ACTION 1310
131622
+#define YY_NO_ACTION 1311
131024131623
/************* End control #defines *******************************************/
131025131624
131026131625
/* Define the yytestcase() macro to be a no-op if is not already defined
131027131626
** otherwise.
131028131627
**
@@ -131086,450 +131685,452 @@
131086131685
** yy_reduce_ofst[] For each state, the offset into yy_action for
131087131686
** shifting non-terminals after a reduce.
131088131687
** yy_default[] Default action for each state.
131089131688
**
131090131689
*********** Begin parsing tables **********************************************/
131091
-#define YY_ACTTAB_COUNT (1501)
131690
+#define YY_ACTTAB_COUNT (1507)
131092131691
static const YYACTIONTYPE yy_action[] = {
131093
- /* 0 */ 315, 810, 339, 804, 5, 194, 194, 798, 92, 93,
131094
- /* 10 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131095
- /* 20 */ 91, 91, 91, 290, 89, 89, 89, 89, 88, 88,
131096
- /* 30 */ 87, 87, 87, 86, 339, 315, 952, 952, 803, 803,
131097
- /* 40 */ 803, 922, 342, 92, 93, 83, 819, 819, 831, 834,
131098
- /* 50 */ 823, 823, 90, 90, 91, 91, 91, 91, 123, 89,
131099
- /* 60 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131100
- /* 70 */ 88, 88, 87, 87, 87, 86, 339, 772, 952, 952,
131101
- /* 80 */ 315, 87, 87, 87, 86, 339, 773, 68, 92, 93,
131102
- /* 90 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131103
- /* 100 */ 91, 91, 91, 434, 89, 89, 89, 89, 88, 88,
131104
- /* 110 */ 87, 87, 87, 86, 339, 1302, 146, 921, 2, 315,
131105
- /* 120 */ 427, 24, 679, 953, 48, 86, 339, 92, 93, 83,
131106
- /* 130 */ 819, 819, 831, 834, 823, 823, 90, 90, 91, 91,
131107
- /* 140 */ 91, 91, 94, 89, 89, 89, 89, 88, 88, 87,
131108
- /* 150 */ 87, 87, 86, 339, 933, 933, 315, 259, 412, 398,
131109
- /* 160 */ 396, 57, 733, 733, 92, 93, 83, 819, 819, 831,
131110
- /* 170 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 56,
131111
- /* 180 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131112
- /* 190 */ 339, 315, 1245, 922, 342, 268, 934, 935, 241, 92,
131113
- /* 200 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131114
- /* 210 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131115
- /* 220 */ 88, 87, 87, 87, 86, 339, 315, 913, 1295, 682,
131116
- /* 230 */ 687, 1295, 233, 397, 92, 93, 83, 819, 819, 831,
131117
- /* 240 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 326,
131118
- /* 250 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131119
- /* 260 */ 339, 315, 85, 82, 168, 680, 431, 938, 939, 92,
131120
- /* 270 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131121
- /* 280 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131122
- /* 290 */ 88, 87, 87, 87, 86, 339, 315, 319, 913, 1296,
131123
- /* 300 */ 797, 911, 1296, 681, 92, 93, 83, 819, 819, 831,
131124
- /* 310 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 335,
131125
- /* 320 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131126
- /* 330 */ 339, 315, 876, 876, 373, 85, 82, 168, 944, 92,
131127
- /* 340 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131128
- /* 350 */ 91, 91, 91, 91, 896, 89, 89, 89, 89, 88,
131129
- /* 360 */ 88, 87, 87, 87, 86, 339, 315, 370, 307, 973,
131130
- /* 370 */ 367, 1, 911, 433, 92, 93, 83, 819, 819, 831,
131131
- /* 380 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 189,
131132
- /* 390 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131133
- /* 400 */ 339, 315, 720, 948, 933, 933, 149, 718, 948, 92,
131134
- /* 410 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131135
- /* 420 */ 91, 91, 91, 91, 434, 89, 89, 89, 89, 88,
131136
- /* 430 */ 88, 87, 87, 87, 86, 339, 338, 938, 939, 947,
131137
- /* 440 */ 694, 940, 974, 315, 953, 48, 934, 935, 715, 689,
131138
- /* 450 */ 71, 92, 93, 83, 819, 819, 831, 834, 823, 823,
131139
- /* 460 */ 90, 90, 91, 91, 91, 91, 320, 89, 89, 89,
131140
- /* 470 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 412,
131141
- /* 480 */ 403, 820, 820, 832, 835, 74, 92, 81, 83, 819,
131142
- /* 490 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131143
- /* 500 */ 91, 698, 89, 89, 89, 89, 88, 88, 87, 87,
131144
- /* 510 */ 87, 86, 339, 315, 259, 654, 655, 656, 393, 111,
131145
- /* 520 */ 331, 153, 93, 83, 819, 819, 831, 834, 823, 823,
131146
- /* 530 */ 90, 90, 91, 91, 91, 91, 434, 89, 89, 89,
131147
- /* 540 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 188,
131148
- /* 550 */ 187, 186, 824, 937, 328, 219, 953, 48, 83, 819,
131149
- /* 560 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131150
- /* 570 */ 91, 956, 89, 89, 89, 89, 88, 88, 87, 87,
131151
- /* 580 */ 87, 86, 339, 79, 429, 738, 3, 1174, 955, 348,
131152
- /* 590 */ 737, 332, 792, 933, 933, 937, 79, 429, 730, 3,
131153
- /* 600 */ 203, 160, 278, 391, 273, 390, 190, 892, 434, 400,
131154
- /* 610 */ 741, 76, 77, 271, 287, 253, 353, 242, 78, 340,
131155
- /* 620 */ 340, 85, 82, 168, 76, 77, 233, 397, 953, 48,
131156
- /* 630 */ 432, 78, 340, 340, 277, 934, 935, 185, 439, 651,
131157
- /* 640 */ 388, 385, 384, 432, 234, 276, 107, 418, 349, 337,
131158
- /* 650 */ 336, 383, 893, 728, 215, 949, 123, 971, 308, 810,
131159
- /* 660 */ 418, 436, 435, 412, 394, 798, 400, 873, 894, 123,
131160
- /* 670 */ 721, 872, 810, 889, 436, 435, 215, 949, 798, 351,
131161
- /* 680 */ 722, 697, 380, 434, 771, 371, 22, 434, 400, 79,
131162
- /* 690 */ 429, 232, 3, 189, 413, 870, 803, 803, 803, 805,
131163
- /* 700 */ 18, 54, 148, 953, 48, 956, 113, 953, 9, 803,
131164
- /* 710 */ 803, 803, 805, 18, 310, 123, 748, 76, 77, 742,
131165
- /* 720 */ 123, 325, 955, 866, 78, 340, 340, 113, 350, 359,
131166
- /* 730 */ 85, 82, 168, 343, 960, 960, 432, 770, 412, 414,
131167
- /* 740 */ 407, 23, 1240, 1240, 79, 429, 357, 3, 166, 91,
131168
- /* 750 */ 91, 91, 91, 418, 89, 89, 89, 89, 88, 88,
131169
- /* 760 */ 87, 87, 87, 86, 339, 810, 434, 436, 435, 792,
131170
- /* 770 */ 320, 798, 76, 77, 789, 271, 123, 434, 360, 78,
131171
- /* 780 */ 340, 340, 864, 85, 82, 168, 953, 9, 395, 743,
131172
- /* 790 */ 360, 432, 253, 358, 252, 933, 933, 953, 30, 889,
131173
- /* 800 */ 327, 216, 803, 803, 803, 805, 18, 113, 418, 89,
131174
- /* 810 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131175
- /* 820 */ 810, 113, 436, 435, 792, 185, 798, 288, 388, 385,
131176
- /* 830 */ 384, 123, 113, 920, 2, 796, 696, 934, 935, 383,
131177
- /* 840 */ 69, 429, 434, 3, 218, 110, 738, 253, 358, 252,
131178
- /* 850 */ 434, 737, 933, 933, 892, 359, 222, 803, 803, 803,
131179
- /* 860 */ 805, 18, 953, 47, 933, 933, 933, 933, 76, 77,
131180
- /* 870 */ 953, 9, 366, 904, 217, 78, 340, 340, 677, 305,
131181
- /* 880 */ 304, 303, 206, 301, 224, 259, 664, 432, 337, 336,
131182
- /* 890 */ 434, 228, 247, 144, 934, 935, 933, 933, 667, 893,
131183
- /* 900 */ 324, 1259, 96, 434, 418, 796, 934, 935, 934, 935,
131184
- /* 910 */ 953, 48, 401, 148, 289, 894, 810, 417, 436, 435,
131185
- /* 920 */ 677, 759, 798, 953, 9, 314, 220, 162, 161, 170,
131186
- /* 930 */ 402, 239, 953, 8, 194, 683, 683, 410, 934, 935,
131187
- /* 940 */ 238, 959, 933, 933, 225, 408, 945, 365, 957, 212,
131188
- /* 950 */ 958, 172, 757, 803, 803, 803, 805, 18, 173, 365,
131189
- /* 960 */ 176, 123, 171, 113, 244, 952, 246, 434, 356, 796,
131190
- /* 970 */ 372, 365, 236, 960, 960, 810, 290, 804, 191, 165,
131191
- /* 980 */ 852, 798, 259, 316, 934, 935, 237, 953, 34, 404,
131192
- /* 990 */ 91, 91, 91, 91, 84, 89, 89, 89, 89, 88,
131193
- /* 1000 */ 88, 87, 87, 87, 86, 339, 701, 952, 434, 240,
131194
- /* 1010 */ 347, 758, 803, 803, 803, 434, 245, 1179, 434, 389,
131195
- /* 1020 */ 434, 376, 434, 895, 167, 434, 405, 702, 953, 35,
131196
- /* 1030 */ 673, 321, 221, 434, 333, 953, 11, 434, 953, 26,
131197
- /* 1040 */ 953, 36, 953, 37, 251, 953, 38, 434, 259, 434,
131198
- /* 1050 */ 757, 434, 329, 953, 27, 434, 223, 953, 28, 434,
131199
- /* 1060 */ 690, 434, 67, 434, 65, 434, 862, 953, 39, 953,
131200
- /* 1070 */ 40, 953, 41, 423, 434, 953, 10, 434, 772, 953,
131201
- /* 1080 */ 42, 953, 98, 953, 43, 953, 44, 773, 434, 346,
131202
- /* 1090 */ 434, 75, 434, 73, 953, 31, 434, 953, 45, 434,
131203
- /* 1100 */ 259, 434, 690, 434, 757, 434, 887, 434, 953, 46,
131204
- /* 1110 */ 953, 32, 953, 115, 434, 266, 953, 116, 951, 953,
131205
- /* 1120 */ 117, 953, 52, 953, 33, 953, 99, 953, 49, 726,
131206
- /* 1130 */ 434, 909, 434, 19, 953, 100, 434, 344, 434, 113,
131207
- /* 1140 */ 434, 258, 692, 434, 259, 434, 670, 434, 20, 434,
131208
- /* 1150 */ 953, 101, 953, 97, 434, 259, 953, 114, 953, 112,
131209
- /* 1160 */ 953, 105, 113, 953, 104, 953, 102, 953, 103, 953,
131210
- /* 1170 */ 51, 434, 148, 434, 953, 53, 167, 434, 259, 113,
131211
- /* 1180 */ 300, 307, 912, 363, 311, 860, 248, 261, 209, 264,
131212
- /* 1190 */ 416, 953, 50, 953, 25, 420, 727, 953, 29, 430,
131213
- /* 1200 */ 321, 424, 757, 428, 322, 124, 1269, 214, 165, 710,
131214
- /* 1210 */ 859, 908, 806, 794, 309, 158, 193, 361, 254, 723,
131215
- /* 1220 */ 364, 67, 381, 269, 735, 199, 67, 70, 113, 700,
131216
- /* 1230 */ 699, 707, 708, 884, 113, 766, 113, 855, 193, 883,
131217
- /* 1240 */ 199, 869, 869, 675, 868, 868, 109, 368, 255, 260,
131218
- /* 1250 */ 263, 280, 859, 265, 806, 974, 267, 711, 695, 272,
131219
- /* 1260 */ 764, 282, 795, 284, 150, 744, 755, 415, 292, 293,
131220
- /* 1270 */ 802, 678, 672, 661, 660, 662, 927, 6, 306, 386,
131221
- /* 1280 */ 352, 786, 243, 250, 886, 362, 163, 286, 419, 298,
131222
- /* 1290 */ 930, 159, 968, 196, 126, 903, 901, 965, 55, 58,
131223
- /* 1300 */ 323, 275, 857, 136, 147, 694, 856, 121, 65, 354,
131224
- /* 1310 */ 355, 379, 175, 61, 151, 369, 180, 871, 375, 129,
131225
- /* 1320 */ 257, 756, 210, 181, 145, 131, 132, 377, 262, 663,
131226
- /* 1330 */ 133, 134, 139, 783, 791, 182, 392, 183, 312, 330,
131227
- /* 1340 */ 714, 888, 713, 851, 692, 195, 712, 406, 686, 705,
131228
- /* 1350 */ 313, 685, 64, 839, 274, 72, 684, 334, 942, 95,
131229
- /* 1360 */ 752, 279, 281, 704, 753, 751, 422, 283, 411, 750,
131230
- /* 1370 */ 426, 66, 204, 409, 21, 285, 928, 669, 437, 205,
131231
- /* 1380 */ 207, 208, 438, 658, 657, 652, 118, 108, 119, 226,
131232
- /* 1390 */ 650, 341, 157, 235, 169, 345, 106, 734, 790, 296,
131233
- /* 1400 */ 294, 295, 120, 297, 867, 865, 127, 128, 130, 724,
131234
- /* 1410 */ 229, 174, 249, 882, 137, 230, 138, 135, 885, 231,
131235
- /* 1420 */ 59, 60, 177, 881, 7, 178, 12, 179, 256, 874,
131236
- /* 1430 */ 140, 193, 962, 374, 141, 152, 666, 378, 276, 184,
131237
- /* 1440 */ 270, 122, 142, 382, 387, 62, 13, 14, 703, 63,
131238
- /* 1450 */ 125, 317, 318, 227, 809, 808, 837, 732, 15, 164,
131239
- /* 1460 */ 736, 4, 765, 211, 399, 213, 192, 143, 760, 70,
131240
- /* 1470 */ 67, 16, 17, 838, 836, 891, 841, 890, 198, 197,
131241
- /* 1480 */ 917, 154, 421, 923, 918, 155, 200, 977, 425, 840,
131242
- /* 1490 */ 156, 201, 807, 676, 80, 302, 299, 977, 202, 1261,
131243
- /* 1500 */ 1260,
131692
+ /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131693
+ /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131694
+ /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131695
+ /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131696
+ /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131697
+ /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131698
+ /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131699
+ /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131700
+ /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131701
+ /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131702
+ /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131703
+ /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131704
+ /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131705
+ /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131706
+ /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131707
+ /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131708
+ /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131709
+ /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131710
+ /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131711
+ /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131712
+ /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131713
+ /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131714
+ /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131715
+ /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131716
+ /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131717
+ /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131718
+ /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131719
+ /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131720
+ /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131721
+ /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131722
+ /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131723
+ /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131724
+ /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131725
+ /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131726
+ /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131727
+ /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131728
+ /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131729
+ /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131730
+ /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131731
+ /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131732
+ /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131733
+ /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131734
+ /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131735
+ /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131736
+ /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131737
+ /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131738
+ /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131739
+ /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131740
+ /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131741
+ /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131742
+ /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131743
+ /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131744
+ /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131745
+ /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131746
+ /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131747
+ /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131748
+ /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131749
+ /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131750
+ /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131751
+ /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131752
+ /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131753
+ /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131754
+ /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131755
+ /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131756
+ /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131757
+ /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131758
+ /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131759
+ /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131760
+ /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
131761
+ /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
131762
+ /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
131763
+ /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
131764
+ /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
131765
+ /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
131766
+ /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
131767
+ /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
131768
+ /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
131769
+ /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
131770
+ /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
131771
+ /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
131772
+ /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
131773
+ /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131774
+ /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
131775
+ /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
131776
+ /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
131777
+ /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
131778
+ /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
131779
+ /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
131780
+ /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
131781
+ /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
131782
+ /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
131783
+ /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
131784
+ /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
131785
+ /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
131786
+ /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
131787
+ /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
131788
+ /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
131789
+ /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
131790
+ /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
131791
+ /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
131792
+ /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
131793
+ /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
131794
+ /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
131795
+ /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
131796
+ /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
131797
+ /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
131798
+ /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
131799
+ /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
131800
+ /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
131801
+ /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
131802
+ /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
131803
+ /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
131804
+ /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
131805
+ /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
131806
+ /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
131807
+ /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
131808
+ /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
131809
+ /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
131810
+ /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
131811
+ /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
131812
+ /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
131813
+ /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
131814
+ /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
131815
+ /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
131816
+ /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
131817
+ /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
131818
+ /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
131819
+ /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
131820
+ /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
131821
+ /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
131822
+ /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
131823
+ /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
131824
+ /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
131825
+ /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
131826
+ /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
131827
+ /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
131828
+ /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
131829
+ /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
131830
+ /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
131831
+ /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
131832
+ /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
131833
+ /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
131834
+ /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
131835
+ /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
131836
+ /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
131837
+ /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
131838
+ /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
131839
+ /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
131840
+ /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
131841
+ /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
131842
+ /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
131244131843
};
131245131844
static const YYCODETYPE yy_lookahead[] = {
131246131845
/* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
131247131846
/* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131248131847
/* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131249131848
/* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
131250131849
/* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
131251
- /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 92, 43,
131850
+ /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43,
131252131851
/* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131253131852
/* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
131254131853
/* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
131255131854
/* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131256131855
/* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131257131856
/* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
131258
- /* 120 */ 249, 22, 172, 172, 173, 52, 53, 27, 28, 29,
131857
+ /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
131259131858
/* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
131260131859
/* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
131261131860
/* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
131262131861
/* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
131263131862
/* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
131264131863
/* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131265131864
/* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
131266131865
/* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131267131866
/* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131268
- /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172,
131269
- /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32,
131867
+ /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
131868
+ /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
131270131869
/* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131271131870
/* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131272
- /* 260 */ 53, 19, 221, 222, 223, 23, 168, 169, 170, 27,
131871
+ /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
131273131872
/* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131274
- /* 280 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131275
- /* 290 */ 48, 49, 50, 51, 52, 53, 19, 157, 22, 23,
131276
- /* 300 */ 23, 96, 26, 172, 27, 28, 29, 30, 31, 32,
131277
- /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131873
+ /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
131874
+ /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
131875
+ /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
131876
+ /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
131278131877
/* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131279
- /* 330 */ 53, 19, 108, 109, 110, 221, 222, 223, 185, 27,
131878
+ /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
131280131879
/* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131281
- /* 350 */ 38, 39, 40, 41, 240, 43, 44, 45, 46, 47,
131282
- /* 360 */ 48, 49, 50, 51, 52, 53, 19, 227, 22, 23,
131283
- /* 370 */ 230, 22, 96, 152, 27, 28, 29, 30, 31, 32,
131880
+ /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
131881
+ /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
131882
+ /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
131284131883
/* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
131285131884
/* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131286
- /* 400 */ 53, 19, 190, 191, 55, 56, 24, 190, 191, 27,
131885
+ /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
131287131886
/* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131288131887
/* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131289
- /* 430 */ 48, 49, 50, 51, 52, 53, 168, 169, 170, 179,
131290
- /* 440 */ 180, 171, 96, 19, 172, 173, 97, 98, 188, 179,
131888
+ /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
131889
+ /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
131291131890
/* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
131292131891
/* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
131293131892
/* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
131294131893
/* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
131295131894
/* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131296
- /* 500 */ 41, 181, 43, 44, 45, 46, 47, 48, 49, 50,
131297
- /* 510 */ 51, 52, 53, 19, 152, 7, 8, 9, 49, 22,
131298
- /* 520 */ 19, 24, 28, 29, 30, 31, 32, 33, 34, 35,
131895
+ /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
131896
+ /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
131897
+ /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
131299131898
/* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
131300131899
/* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
131301
- /* 550 */ 109, 110, 101, 55, 53, 193, 172, 173, 29, 30,
131900
+ /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
131302131901
/* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131303131902
/* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
131304131903
/* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
131305
- /* 590 */ 121, 207, 85, 55, 56, 97, 19, 20, 195, 22,
131306
- /* 600 */ 99, 100, 101, 102, 103, 104, 105, 12, 152, 206,
131904
+ /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
131905
+ /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
131307131906
/* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
131308131907
/* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
131309
- /* 630 */ 66, 54, 55, 56, 101, 97, 98, 99, 148, 149,
131310
- /* 640 */ 102, 103, 104, 66, 154, 112, 156, 83, 229, 47,
131311
- /* 650 */ 48, 113, 57, 163, 194, 195, 92, 246, 247, 95,
131312
- /* 660 */ 83, 97, 98, 207, 208, 101, 206, 59, 73, 92,
131313
- /* 670 */ 75, 63, 95, 163, 97, 98, 194, 195, 101, 219,
131314
- /* 680 */ 85, 181, 19, 152, 175, 77, 196, 152, 206, 19,
131315
- /* 690 */ 20, 199, 22, 30, 163, 11, 132, 133, 134, 135,
131316
- /* 700 */ 136, 209, 152, 172, 173, 152, 196, 172, 173, 132,
131317
- /* 710 */ 133, 134, 135, 136, 164, 92, 213, 47, 48, 49,
131318
- /* 720 */ 92, 186, 169, 170, 54, 55, 56, 196, 100, 219,
131319
- /* 730 */ 221, 222, 223, 243, 132, 133, 66, 175, 207, 208,
131320
- /* 740 */ 152, 231, 119, 120, 19, 20, 236, 22, 152, 38,
131908
+ /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
131909
+ /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
131910
+ /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
131911
+ /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
131912
+ /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
131913
+ /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
131914
+ /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
131915
+ /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
131916
+ /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
131917
+ /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
131918
+ /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
131919
+ /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
131321131920
/* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
131322
- /* 760 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 85,
131323
- /* 770 */ 107, 101, 47, 48, 163, 112, 92, 152, 152, 54,
131324
- /* 780 */ 55, 56, 229, 221, 222, 223, 172, 173, 163, 49,
131325
- /* 790 */ 152, 66, 108, 109, 110, 55, 56, 172, 173, 163,
131326
- /* 800 */ 186, 22, 132, 133, 134, 135, 136, 196, 83, 43,
131921
+ /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
131922
+ /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
131923
+ /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
131924
+ /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
131925
+ /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
131327131926
/* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131328
- /* 820 */ 95, 196, 97, 98, 85, 99, 101, 152, 102, 103,
131329
- /* 830 */ 104, 92, 196, 146, 147, 152, 181, 97, 98, 113,
131330
- /* 840 */ 19, 20, 152, 22, 218, 22, 116, 108, 109, 110,
131331
- /* 850 */ 152, 121, 55, 56, 12, 219, 218, 132, 133, 134,
131332
- /* 860 */ 135, 136, 172, 173, 55, 56, 55, 56, 47, 48,
131333
- /* 870 */ 172, 173, 236, 152, 5, 54, 55, 56, 55, 10,
131334
- /* 880 */ 11, 12, 13, 14, 186, 152, 17, 66, 47, 48,
131335
- /* 890 */ 152, 210, 16, 84, 97, 98, 55, 56, 21, 57,
131336
- /* 900 */ 217, 122, 22, 152, 83, 152, 97, 98, 97, 98,
131337
- /* 910 */ 172, 173, 152, 152, 224, 73, 95, 75, 97, 98,
131338
- /* 920 */ 97, 124, 101, 172, 173, 164, 193, 47, 48, 60,
131339
- /* 930 */ 163, 62, 172, 173, 24, 55, 56, 186, 97, 98,
131340
- /* 940 */ 71, 100, 55, 56, 183, 207, 185, 152, 107, 23,
131341
- /* 950 */ 109, 82, 26, 132, 133, 134, 135, 136, 89, 152,
131342
- /* 960 */ 26, 92, 93, 196, 88, 55, 90, 152, 91, 152,
131343
- /* 970 */ 217, 152, 152, 132, 133, 95, 152, 97, 211, 212,
131344
- /* 980 */ 103, 101, 152, 114, 97, 98, 152, 172, 173, 19,
131927
+ /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
131928
+ /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
131929
+ /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
131930
+ /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
131931
+ /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
131932
+ /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
131933
+ /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
131934
+ /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
131935
+ /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
131936
+ /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
131937
+ /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
131938
+ /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
131939
+ /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
131940
+ /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
131941
+ /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
131942
+ /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
131943
+ /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
131345131944
/* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
131346
- /* 1000 */ 48, 49, 50, 51, 52, 53, 65, 97, 152, 152,
131347
- /* 1010 */ 141, 124, 132, 133, 134, 152, 140, 140, 152, 78,
131348
- /* 1020 */ 152, 233, 152, 193, 98, 152, 56, 86, 172, 173,
131349
- /* 1030 */ 166, 167, 237, 152, 217, 172, 173, 152, 172, 173,
131350
- /* 1040 */ 172, 173, 172, 173, 237, 172, 173, 152, 152, 152,
131351
- /* 1050 */ 124, 152, 111, 172, 173, 152, 237, 172, 173, 152,
131352
- /* 1060 */ 55, 152, 26, 152, 130, 152, 152, 172, 173, 172,
131353
- /* 1070 */ 173, 172, 173, 249, 152, 172, 173, 152, 61, 172,
131354
- /* 1080 */ 173, 172, 173, 172, 173, 172, 173, 70, 152, 193,
131355
- /* 1090 */ 152, 137, 152, 139, 172, 173, 152, 172, 173, 152,
131356
- /* 1100 */ 152, 152, 97, 152, 26, 152, 163, 152, 172, 173,
131357
- /* 1110 */ 172, 173, 172, 173, 152, 16, 172, 173, 26, 172,
131358
- /* 1120 */ 173, 172, 173, 172, 173, 172, 173, 172, 173, 163,
131359
- /* 1130 */ 152, 152, 152, 22, 172, 173, 152, 241, 152, 196,
131360
- /* 1140 */ 152, 193, 106, 152, 152, 152, 163, 152, 37, 152,
131361
- /* 1150 */ 172, 173, 172, 173, 152, 152, 172, 173, 172, 173,
131362
- /* 1160 */ 172, 173, 196, 172, 173, 172, 173, 172, 173, 172,
131363
- /* 1170 */ 173, 152, 152, 152, 172, 173, 98, 152, 152, 196,
131364
- /* 1180 */ 160, 22, 23, 19, 164, 193, 152, 88, 232, 90,
131365
- /* 1190 */ 191, 172, 173, 172, 173, 163, 193, 172, 173, 166,
131366
- /* 1200 */ 167, 163, 124, 163, 244, 245, 23, 211, 212, 26,
131367
- /* 1210 */ 55, 23, 55, 23, 26, 123, 26, 152, 23, 193,
131368
- /* 1220 */ 56, 26, 23, 23, 23, 26, 26, 26, 196, 100,
131369
- /* 1230 */ 101, 7, 8, 152, 196, 23, 196, 23, 26, 152,
131370
- /* 1240 */ 26, 132, 133, 23, 132, 133, 26, 152, 152, 152,
131371
- /* 1250 */ 152, 210, 97, 152, 97, 96, 152, 152, 152, 152,
131372
- /* 1260 */ 152, 210, 152, 210, 197, 152, 152, 152, 152, 152,
131373
- /* 1270 */ 152, 152, 152, 152, 152, 152, 152, 198, 150, 176,
131374
- /* 1280 */ 214, 201, 214, 238, 201, 238, 184, 214, 226, 200,
131375
- /* 1290 */ 155, 198, 67, 122, 242, 159, 159, 69, 239, 239,
131376
- /* 1300 */ 159, 175, 175, 22, 220, 180, 175, 27, 130, 18,
131377
- /* 1310 */ 159, 18, 158, 137, 220, 159, 158, 235, 74, 189,
131378
- /* 1320 */ 234, 159, 159, 158, 22, 192, 192, 177, 159, 159,
131379
- /* 1330 */ 192, 192, 189, 201, 189, 158, 107, 158, 177, 76,
131380
- /* 1340 */ 174, 201, 174, 201, 106, 159, 174, 125, 174, 182,
131381
- /* 1350 */ 177, 176, 107, 159, 174, 137, 174, 53, 174, 129,
131382
- /* 1360 */ 216, 215, 215, 182, 216, 216, 177, 215, 126, 216,
131383
- /* 1370 */ 177, 128, 25, 127, 26, 215, 13, 162, 161, 153,
131384
- /* 1380 */ 153, 6, 151, 151, 151, 151, 165, 178, 165, 178,
131385
- /* 1390 */ 4, 3, 22, 142, 15, 94, 16, 205, 120, 202,
131386
- /* 1400 */ 204, 203, 165, 201, 23, 23, 131, 111, 123, 20,
131387
- /* 1410 */ 225, 125, 16, 1, 131, 228, 111, 123, 56, 228,
131388
- /* 1420 */ 37, 37, 64, 1, 5, 122, 22, 107, 140, 80,
131389
- /* 1430 */ 80, 26, 87, 72, 107, 24, 20, 19, 112, 105,
131390
- /* 1440 */ 23, 68, 22, 79, 79, 22, 22, 22, 58, 22,
131391
- /* 1450 */ 245, 248, 248, 79, 23, 23, 23, 116, 22, 122,
131392
- /* 1460 */ 23, 22, 56, 23, 26, 23, 64, 22, 124, 26,
131393
- /* 1470 */ 26, 64, 64, 23, 23, 23, 11, 23, 22, 26,
131394
- /* 1480 */ 23, 22, 24, 1, 23, 22, 26, 250, 24, 23,
131395
- /* 1490 */ 22, 122, 23, 23, 22, 15, 23, 250, 122, 122,
131396
- /* 1500 */ 122,
131945
+ /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
131946
+ /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
131947
+ /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
131948
+ /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
131949
+ /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
131950
+ /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
131951
+ /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
131952
+ /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
131953
+ /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
131954
+ /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
131955
+ /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
131956
+ /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
131957
+ /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
131958
+ /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
131959
+ /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
131960
+ /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
131961
+ /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
131962
+ /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
131963
+ /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
131964
+ /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
131965
+ /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
131966
+ /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
131967
+ /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
131968
+ /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
131969
+ /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
131970
+ /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
131971
+ /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
131972
+ /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
131973
+ /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
131974
+ /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
131975
+ /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
131976
+ /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
131977
+ /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
131978
+ /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
131979
+ /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
131980
+ /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
131981
+ /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
131982
+ /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
131983
+ /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
131984
+ /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
131985
+ /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
131986
+ /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
131987
+ /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
131988
+ /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
131989
+ /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
131990
+ /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
131991
+ /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
131992
+ /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
131993
+ /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
131994
+ /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
131995
+ /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
131397131996
};
131398131997
#define YY_SHIFT_USE_DFLT (-95)
131399
-#define YY_SHIFT_COUNT (439)
131998
+#define YY_SHIFT_COUNT (442)
131400131999
#define YY_SHIFT_MIN (-94)
131401
-#define YY_SHIFT_MAX (1482)
132000
+#define YY_SHIFT_MAX (1491)
131402132001
static const short yy_shift_ofst[] = {
131403
- /* 0 */ 40, 564, 869, 577, 725, 725, 725, 739, -19, 16,
131404
- /* 10 */ 16, 100, 725, 725, 725, 725, 725, 725, 725, 841,
131405
- /* 20 */ 841, 538, 507, 684, 623, 61, 137, 172, 207, 242,
131406
- /* 30 */ 277, 312, 347, 382, 424, 424, 424, 424, 424, 424,
131407
- /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 459,
131408
- /* 50 */ 424, 494, 529, 529, 670, 725, 725, 725, 725, 725,
132002
+ /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132003
+ /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132004
+ /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132005
+ /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132006
+ /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132007
+ /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
131409132008
/* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131410132009
/* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131411
- /* 80 */ 725, 725, 725, 821, 725, 725, 725, 725, 725, 725,
131412
- /* 90 */ 725, 725, 725, 725, 725, 725, 725, 952, 711, 711,
131413
- /* 100 */ 711, 711, 711, 766, 23, 32, 811, 877, 663, 602,
131414
- /* 110 */ 602, 811, 73, 113, -51, -95, -95, -95, 501, 501,
131415
- /* 120 */ 501, 595, 595, 809, 205, 276, 811, 811, 811, 811,
131416
- /* 130 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131417
- /* 140 */ 811, 811, 811, 811, 811, 811, 192, 628, 498, 498,
131418
- /* 150 */ 113, -34, -34, -34, -34, -34, -34, -95, -95, -95,
131419
- /* 160 */ 880, -94, -94, 726, 740, 99, 797, 887, 349, 811,
131420
- /* 170 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131421
- /* 180 */ 811, 811, 811, 811, 811, 811, 941, 941, 941, 811,
131422
- /* 190 */ 811, 926, 811, 811, 811, -18, 811, 811, 842, 811,
131423
- /* 200 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 224,
131424
- /* 210 */ 608, 910, 910, 910, 1078, 45, 469, 508, 934, 970,
131425
- /* 220 */ 970, 1164, 934, 1164, 1036, 1183, 359, 1017, 970, 954,
131426
- /* 230 */ 1017, 1017, 1092, 730, 497, 1225, 1171, 1171, 1228, 1228,
131427
- /* 240 */ 1171, 1281, 1280, 1178, 1291, 1291, 1291, 1291, 1171, 1293,
131428
- /* 250 */ 1178, 1281, 1280, 1280, 1178, 1171, 1293, 1176, 1244, 1171,
131429
- /* 260 */ 1171, 1293, 1302, 1171, 1293, 1171, 1293, 1302, 1229, 1229,
131430
- /* 270 */ 1229, 1263, 1302, 1229, 1238, 1229, 1263, 1229, 1229, 1222,
131431
- /* 280 */ 1245, 1222, 1245, 1222, 1245, 1222, 1245, 1171, 1171, 1218,
131432
- /* 290 */ 1302, 1304, 1304, 1302, 1230, 1242, 1243, 1246, 1178, 1347,
131433
- /* 300 */ 1348, 1363, 1363, 1375, 1375, 1375, 1375, -95, -95, -95,
131434
- /* 310 */ -95, -95, -95, -95, -95, 451, 876, 346, 1159, 1099,
131435
- /* 320 */ 441, 823, 1188, 1111, 1190, 1195, 1199, 1200, 1005, 1129,
131436
- /* 330 */ 1224, 533, 1201, 1212, 1155, 1214, 1109, 1112, 1220, 1157,
131437
- /* 340 */ 779, 1386, 1388, 1370, 1251, 1379, 1301, 1380, 1381, 1382,
131438
- /* 350 */ 1278, 1275, 1296, 1285, 1389, 1286, 1396, 1412, 1294, 1283,
131439
- /* 360 */ 1383, 1384, 1305, 1362, 1358, 1303, 1422, 1419, 1404, 1320,
131440
- /* 370 */ 1288, 1349, 1405, 1350, 1345, 1361, 1327, 1411, 1416, 1418,
131441
- /* 380 */ 1326, 1334, 1420, 1364, 1423, 1424, 1417, 1425, 1365, 1390,
131442
- /* 390 */ 1427, 1374, 1373, 1431, 1432, 1433, 1341, 1436, 1437, 1439,
131443
- /* 400 */ 1438, 1337, 1440, 1442, 1406, 1402, 1445, 1344, 1443, 1407,
131444
- /* 410 */ 1444, 1408, 1443, 1450, 1451, 1452, 1453, 1454, 1456, 1465,
131445
- /* 420 */ 1457, 1459, 1458, 1460, 1461, 1463, 1464, 1460, 1466, 1468,
131446
- /* 430 */ 1469, 1470, 1472, 1369, 1376, 1377, 1378, 1473, 1480, 1482,
132010
+ /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132011
+ /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132012
+ /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132013
+ /* 110 */ 837, 837, 924, 73, 183, -51, -95, -95, -95, 501,
132014
+ /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132015
+ /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132016
+ /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132017
+ /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, -95, -95,
132018
+ /* 160 */ -95, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132019
+ /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132020
+ /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132021
+ /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132022
+ /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132023
+ /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132024
+ /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132025
+ /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132026
+ /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132027
+ /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132028
+ /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132029
+ /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132030
+ /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132031
+ /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132032
+ /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, -95,
132033
+ /* 310 */ -95, -95, -95, -95, -95, -95, -95, 451, 936, 816,
132034
+ /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132035
+ /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132036
+ /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132037
+ /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132038
+ /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132039
+ /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132040
+ /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132041
+ /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132042
+ /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132043
+ /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132044
+ /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132045
+ /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132046
+ /* 440 */ 1482, 1491, 1490,
131447132047
};
131448132048
#define YY_REDUCE_USE_DFLT (-130)
131449
-#define YY_REDUCE_COUNT (314)
132049
+#define YY_REDUCE_COUNT (316)
131450132050
#define YY_REDUCE_MIN (-129)
131451
-#define YY_REDUCE_MAX (1237)
132051
+#define YY_REDUCE_MAX (1243)
131452132052
static const short yy_reduce_ofst[] = {
131453
- /* 0 */ -29, 531, 490, 625, -49, 272, 456, 510, 400, 509,
131454
- /* 10 */ 562, 114, 535, 614, 698, 384, 738, 751, 690, 419,
131455
- /* 20 */ 553, 761, 460, 636, 767, 41, 41, 41, 41, 41,
131456
- /* 30 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131457
- /* 40 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131458
- /* 50 */ 41, 41, 41, 41, 760, 815, 856, 863, 866, 868,
131459
- /* 60 */ 870, 873, 881, 885, 895, 897, 899, 903, 907, 909,
131460
- /* 70 */ 911, 913, 922, 925, 936, 938, 940, 944, 947, 949,
131461
- /* 80 */ 951, 953, 955, 962, 978, 980, 984, 986, 988, 991,
131462
- /* 90 */ 993, 995, 997, 1002, 1019, 1021, 1025, 41, 41, 41,
131463
- /* 100 */ 41, 41, 41, 41, 41, 41, 896, 140, 260, 98,
131464
- /* 110 */ 268, 1020, 41, 482, 41, 41, 41, 41, 270, 270,
131465
- /* 120 */ 270, 212, 217, -129, 411, 411, 550, 5, 626, 362,
131466
- /* 130 */ 733, 830, 992, 1003, 1026, 795, 683, 807, 638, 819,
131467
- /* 140 */ 753, 948, 62, 817, 824, 132, 687, 611, 864, 1033,
131468
- /* 150 */ 403, 943, 966, 983, 1032, 1038, 1040, 960, 996, 492,
131469
- /* 160 */ -50, 57, 131, 153, 221, 462, 588, 596, 675, 721,
131470
- /* 170 */ 820, 834, 857, 914, 979, 1034, 1065, 1081, 1087, 1095,
131471
- /* 180 */ 1096, 1097, 1098, 1101, 1104, 1105, 320, 500, 655, 1106,
131472
- /* 190 */ 1107, 503, 1108, 1110, 1113, 681, 1114, 1115, 999, 1116,
131473
- /* 200 */ 1117, 1118, 221, 1119, 1120, 1121, 1122, 1123, 1124, 788,
131474
- /* 210 */ 956, 1041, 1051, 1053, 503, 1067, 1079, 1128, 1080, 1066,
131475
- /* 220 */ 1068, 1045, 1083, 1047, 1103, 1102, 1125, 1126, 1073, 1062,
131476
- /* 230 */ 1127, 1131, 1089, 1093, 1135, 1052, 1136, 1137, 1059, 1060,
131477
- /* 240 */ 1141, 1084, 1130, 1132, 1133, 1134, 1138, 1139, 1151, 1154,
131478
- /* 250 */ 1140, 1094, 1143, 1145, 1142, 1156, 1158, 1082, 1086, 1162,
131479
- /* 260 */ 1163, 1165, 1150, 1169, 1177, 1170, 1179, 1161, 1166, 1168,
131480
- /* 270 */ 1172, 1167, 1173, 1174, 1175, 1180, 1181, 1182, 1184, 1144,
131481
- /* 280 */ 1146, 1148, 1147, 1149, 1152, 1153, 1160, 1186, 1194, 1185,
131482
- /* 290 */ 1189, 1187, 1191, 1193, 1192, 1196, 1198, 1197, 1202, 1215,
131483
- /* 300 */ 1217, 1226, 1227, 1231, 1232, 1233, 1234, 1203, 1204, 1205,
131484
- /* 310 */ 1221, 1223, 1209, 1211, 1237,
132053
+ /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132054
+ /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132055
+ /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
132056
+ /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132057
+ /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132058
+ /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132059
+ /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132060
+ /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132061
+ /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132062
+ /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132063
+ /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132064
+ /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132065
+ /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132066
+ /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132067
+ /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132068
+ /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132069
+ /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132070
+ /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132071
+ /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132072
+ /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132073
+ /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132074
+ /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132075
+ /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132076
+ /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132077
+ /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132078
+ /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132079
+ /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132080
+ /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132081
+ /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132082
+ /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132083
+ /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132084
+ /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
131485132085
};
131486132086
static const YYACTIONTYPE yy_default[] = {
131487
- /* 0 */ 1250, 1240, 1240, 1240, 1174, 1174, 1174, 1240, 1071, 1100,
131488
- /* 10 */ 1100, 1224, 1301, 1301, 1301, 1301, 1301, 1301, 1173, 1301,
131489
- /* 20 */ 1301, 1301, 1301, 1240, 1075, 1106, 1301, 1301, 1301, 1301,
131490
- /* 30 */ 1301, 1301, 1301, 1301, 1223, 1225, 1114, 1113, 1206, 1087,
131491
- /* 40 */ 1111, 1104, 1108, 1175, 1169, 1170, 1168, 1172, 1176, 1301,
131492
- /* 50 */ 1107, 1138, 1153, 1137, 1301, 1301, 1301, 1301, 1301, 1301,
131493
- /* 60 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131494
- /* 70 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131495
- /* 80 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131496
- /* 90 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1147, 1152, 1159,
131497
- /* 100 */ 1151, 1148, 1140, 1139, 1141, 1142, 1301, 994, 1042, 1301,
131498
- /* 110 */ 1301, 1301, 1143, 1301, 1144, 1156, 1155, 1154, 1231, 1258,
131499
- /* 120 */ 1257, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131500
- /* 130 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131501
- /* 140 */ 1301, 1301, 1301, 1301, 1301, 1301, 1250, 1240, 1000, 1000,
131502
- /* 150 */ 1301, 1240, 1240, 1240, 1240, 1240, 1240, 1236, 1075, 1066,
131503
- /* 160 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131504
- /* 170 */ 1228, 1226, 1301, 1187, 1301, 1301, 1301, 1301, 1301, 1301,
131505
- /* 180 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131506
- /* 190 */ 1301, 1301, 1301, 1301, 1301, 1071, 1301, 1301, 1301, 1301,
131507
- /* 200 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1252, 1301,
131508
- /* 210 */ 1201, 1071, 1071, 1071, 1073, 1055, 1065, 979, 1110, 1089,
131509
- /* 220 */ 1089, 1290, 1110, 1290, 1017, 1272, 1014, 1100, 1089, 1171,
131510
- /* 230 */ 1100, 1100, 1072, 1065, 1301, 1293, 1080, 1080, 1292, 1292,
131511
- /* 240 */ 1080, 1119, 1045, 1110, 1051, 1051, 1051, 1051, 1080, 991,
131512
- /* 250 */ 1110, 1119, 1045, 1045, 1110, 1080, 991, 1205, 1287, 1080,
131513
- /* 260 */ 1080, 991, 1180, 1080, 991, 1080, 991, 1180, 1043, 1043,
131514
- /* 270 */ 1043, 1032, 1180, 1043, 1017, 1043, 1032, 1043, 1043, 1093,
131515
- /* 280 */ 1088, 1093, 1088, 1093, 1088, 1093, 1088, 1080, 1080, 1301,
131516
- /* 290 */ 1180, 1184, 1184, 1180, 1105, 1094, 1103, 1101, 1110, 997,
131517
- /* 300 */ 1035, 1255, 1255, 1251, 1251, 1251, 1251, 1298, 1298, 1236,
131518
- /* 310 */ 1267, 1267, 1019, 1019, 1267, 1301, 1301, 1301, 1301, 1301,
131519
- /* 320 */ 1301, 1262, 1301, 1189, 1301, 1301, 1301, 1301, 1301, 1301,
131520
- /* 330 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131521
- /* 340 */ 1125, 1301, 975, 1233, 1301, 1301, 1232, 1301, 1301, 1301,
131522
- /* 350 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131523
- /* 360 */ 1301, 1301, 1301, 1301, 1301, 1289, 1301, 1301, 1301, 1301,
131524
- /* 370 */ 1301, 1301, 1204, 1203, 1301, 1301, 1301, 1301, 1301, 1301,
131525
- /* 380 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131526
- /* 390 */ 1301, 1301, 1301, 1301, 1301, 1301, 1057, 1301, 1301, 1301,
131527
- /* 400 */ 1276, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1102, 1301,
131528
- /* 410 */ 1095, 1301, 1280, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131529
- /* 420 */ 1301, 1301, 1301, 1242, 1301, 1301, 1301, 1241, 1301, 1301,
131530
- /* 430 */ 1301, 1301, 1301, 1127, 1301, 1126, 1130, 1301, 985, 1301,
132087
+ /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132088
+ /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132089
+ /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132090
+ /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132091
+ /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132092
+ /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132093
+ /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132094
+ /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132095
+ /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132096
+ /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132097
+ /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132098
+ /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132099
+ /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132100
+ /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132101
+ /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132102
+ /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132103
+ /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132104
+ /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132105
+ /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132106
+ /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132107
+ /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132108
+ /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132109
+ /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132110
+ /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132111
+ /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132112
+ /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132113
+ /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132114
+ /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132115
+ /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132116
+ /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132117
+ /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132118
+ /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132119
+ /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132120
+ /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132121
+ /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132122
+ /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132123
+ /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132124
+ /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132125
+ /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132126
+ /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132127
+ /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132128
+ /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132129
+ /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132130
+ /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132131
+ /* 440 */ 1309, 991, 1309,
131531132132
};
131532132133
/********** End of lemon-generated parsing tables *****************************/
131533132134
131534132135
/* The next table maps tokens (terminal symbols) into fallback tokens.
131535132136
** If a construct like the following:
@@ -131672,21 +132273,22 @@
131672132273
typedef struct yyStackEntry yyStackEntry;
131673132274
131674132275
/* The state of the parser is completely contained in an instance of
131675132276
** the following structure */
131676132277
struct yyParser {
131677
- int yyidx; /* Index of top element in stack */
132278
+ yyStackEntry *yytos; /* Pointer to top element of the stack */
131678132279
#ifdef YYTRACKMAXSTACKDEPTH
131679
- int yyidxMax; /* Maximum value of yyidx */
132280
+ int yyhwm; /* High-water mark of the stack */
131680132281
#endif
131681132282
#ifndef YYNOERRORRECOVERY
131682132283
int yyerrcnt; /* Shifts left before out of the error */
131683132284
#endif
131684132285
sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
131685132286
#if YYSTACKDEPTH<=0
131686132287
int yystksz; /* Current side of the stack */
131687132288
yyStackEntry *yystack; /* The parser's stack */
132289
+ yyStackEntry yystk0; /* First stack entry */
131688132290
#else
131689132291
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
131690132292
#endif
131691132293
};
131692132294
typedef struct yyParser yyParser;
@@ -131781,17 +132383,17 @@
131781132383
"orderby_opt", "limit_opt", "values", "nexprlist",
131782132384
"exprlist", "sclp", "as", "seltablist",
131783132385
"stl_prefix", "joinop", "indexed_opt", "on_opt",
131784132386
"using_opt", "idlist", "setlist", "insert_cmd",
131785132387
"idlist_opt", "likeop", "between_op", "in_op",
131786
- "case_operand", "case_exprlist", "case_else", "uniqueflag",
131787
- "collate", "nmnum", "trigger_decl", "trigger_cmd_list",
131788
- "trigger_time", "trigger_event", "foreach_clause", "when_clause",
131789
- "trigger_cmd", "trnm", "tridxby", "database_kw_opt",
131790
- "key_opt", "add_column_fullname", "kwcolumn_opt", "create_vtab",
131791
- "vtabarglist", "vtabarg", "vtabargtoken", "lp",
131792
- "anylist", "wqlist",
132388
+ "paren_exprlist", "case_operand", "case_exprlist", "case_else",
132389
+ "uniqueflag", "collate", "nmnum", "trigger_decl",
132390
+ "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause",
132391
+ "when_clause", "trigger_cmd", "trnm", "tridxby",
132392
+ "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt",
132393
+ "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken",
132394
+ "lp", "anylist", "wqlist",
131793132395
};
131794132396
#endif /* NDEBUG */
131795132397
131796132398
#ifndef NDEBUG
131797132399
/* For tracing reduce actions, the names of all rules are required.
@@ -131985,11 +132587,11 @@
131985132587
/* 185 */ "in_op ::= IN",
131986132588
/* 186 */ "in_op ::= NOT IN",
131987132589
/* 187 */ "expr ::= expr in_op LP exprlist RP",
131988132590
/* 188 */ "expr ::= LP select RP",
131989132591
/* 189 */ "expr ::= expr in_op LP select RP",
131990
- /* 190 */ "expr ::= expr in_op nm dbnm",
132592
+ /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
131991132593
/* 191 */ "expr ::= EXISTS LP select RP",
131992132594
/* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
131993132595
/* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
131994132596
/* 194 */ "case_exprlist ::= WHEN expr THEN expr",
131995132597
/* 195 */ "case_else ::= ELSE expr",
@@ -131997,158 +132599,170 @@
131997132599
/* 197 */ "case_operand ::= expr",
131998132600
/* 198 */ "case_operand ::=",
131999132601
/* 199 */ "exprlist ::=",
132000132602
/* 200 */ "nexprlist ::= nexprlist COMMA expr",
132001132603
/* 201 */ "nexprlist ::= expr",
132002
- /* 202 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132003
- /* 203 */ "uniqueflag ::= UNIQUE",
132004
- /* 204 */ "uniqueflag ::=",
132005
- /* 205 */ "eidlist_opt ::=",
132006
- /* 206 */ "eidlist_opt ::= LP eidlist RP",
132007
- /* 207 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132008
- /* 208 */ "eidlist ::= nm collate sortorder",
132009
- /* 209 */ "collate ::=",
132010
- /* 210 */ "collate ::= COLLATE ID|STRING",
132011
- /* 211 */ "cmd ::= DROP INDEX ifexists fullname",
132012
- /* 212 */ "cmd ::= VACUUM",
132013
- /* 213 */ "cmd ::= VACUUM nm",
132014
- /* 214 */ "cmd ::= PRAGMA nm dbnm",
132015
- /* 215 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132016
- /* 216 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132017
- /* 217 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132018
- /* 218 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132019
- /* 219 */ "plus_num ::= PLUS INTEGER|FLOAT",
132020
- /* 220 */ "minus_num ::= MINUS INTEGER|FLOAT",
132021
- /* 221 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132022
- /* 222 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132023
- /* 223 */ "trigger_time ::= BEFORE",
132024
- /* 224 */ "trigger_time ::= AFTER",
132025
- /* 225 */ "trigger_time ::= INSTEAD OF",
132026
- /* 226 */ "trigger_time ::=",
132027
- /* 227 */ "trigger_event ::= DELETE|INSERT",
132028
- /* 228 */ "trigger_event ::= UPDATE",
132029
- /* 229 */ "trigger_event ::= UPDATE OF idlist",
132030
- /* 230 */ "when_clause ::=",
132031
- /* 231 */ "when_clause ::= WHEN expr",
132032
- /* 232 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132033
- /* 233 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132034
- /* 234 */ "trnm ::= nm DOT nm",
132035
- /* 235 */ "tridxby ::= INDEXED BY nm",
132036
- /* 236 */ "tridxby ::= NOT INDEXED",
132037
- /* 237 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132038
- /* 238 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132039
- /* 239 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132040
- /* 240 */ "trigger_cmd ::= select",
132041
- /* 241 */ "expr ::= RAISE LP IGNORE RP",
132042
- /* 242 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132043
- /* 243 */ "raisetype ::= ROLLBACK",
132044
- /* 244 */ "raisetype ::= ABORT",
132045
- /* 245 */ "raisetype ::= FAIL",
132046
- /* 246 */ "cmd ::= DROP TRIGGER ifexists fullname",
132047
- /* 247 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132048
- /* 248 */ "cmd ::= DETACH database_kw_opt expr",
132049
- /* 249 */ "key_opt ::=",
132050
- /* 250 */ "key_opt ::= KEY expr",
132051
- /* 251 */ "cmd ::= REINDEX",
132052
- /* 252 */ "cmd ::= REINDEX nm dbnm",
132053
- /* 253 */ "cmd ::= ANALYZE",
132054
- /* 254 */ "cmd ::= ANALYZE nm dbnm",
132055
- /* 255 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132056
- /* 256 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132057
- /* 257 */ "add_column_fullname ::= fullname",
132058
- /* 258 */ "cmd ::= create_vtab",
132059
- /* 259 */ "cmd ::= create_vtab LP vtabarglist RP",
132060
- /* 260 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132061
- /* 261 */ "vtabarg ::=",
132062
- /* 262 */ "vtabargtoken ::= ANY",
132063
- /* 263 */ "vtabargtoken ::= lp anylist RP",
132064
- /* 264 */ "lp ::= LP",
132065
- /* 265 */ "with ::=",
132066
- /* 266 */ "with ::= WITH wqlist",
132067
- /* 267 */ "with ::= WITH RECURSIVE wqlist",
132068
- /* 268 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132069
- /* 269 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132070
- /* 270 */ "input ::= cmdlist",
132071
- /* 271 */ "cmdlist ::= cmdlist ecmd",
132072
- /* 272 */ "cmdlist ::= ecmd",
132073
- /* 273 */ "ecmd ::= SEMI",
132074
- /* 274 */ "ecmd ::= explain cmdx SEMI",
132075
- /* 275 */ "explain ::=",
132076
- /* 276 */ "trans_opt ::=",
132077
- /* 277 */ "trans_opt ::= TRANSACTION",
132078
- /* 278 */ "trans_opt ::= TRANSACTION nm",
132079
- /* 279 */ "savepoint_opt ::= SAVEPOINT",
132080
- /* 280 */ "savepoint_opt ::=",
132081
- /* 281 */ "cmd ::= create_table create_table_args",
132082
- /* 282 */ "columnlist ::= columnlist COMMA columnname carglist",
132083
- /* 283 */ "columnlist ::= columnname carglist",
132084
- /* 284 */ "nm ::= ID|INDEXED",
132085
- /* 285 */ "nm ::= STRING",
132086
- /* 286 */ "nm ::= JOIN_KW",
132087
- /* 287 */ "typetoken ::= typename",
132088
- /* 288 */ "typename ::= ID|STRING",
132089
- /* 289 */ "signed ::= plus_num",
132090
- /* 290 */ "signed ::= minus_num",
132091
- /* 291 */ "carglist ::= carglist ccons",
132092
- /* 292 */ "carglist ::=",
132093
- /* 293 */ "ccons ::= NULL onconf",
132094
- /* 294 */ "conslist_opt ::= COMMA conslist",
132095
- /* 295 */ "conslist ::= conslist tconscomma tcons",
132096
- /* 296 */ "conslist ::= tcons",
132097
- /* 297 */ "tconscomma ::=",
132098
- /* 298 */ "defer_subclause_opt ::= defer_subclause",
132099
- /* 299 */ "resolvetype ::= raisetype",
132100
- /* 300 */ "selectnowith ::= oneselect",
132101
- /* 301 */ "oneselect ::= values",
132102
- /* 302 */ "sclp ::= selcollist COMMA",
132103
- /* 303 */ "as ::= ID|STRING",
132104
- /* 304 */ "expr ::= term",
132105
- /* 305 */ "exprlist ::= nexprlist",
132106
- /* 306 */ "nmnum ::= plus_num",
132107
- /* 307 */ "nmnum ::= nm",
132108
- /* 308 */ "nmnum ::= ON",
132109
- /* 309 */ "nmnum ::= DELETE",
132110
- /* 310 */ "nmnum ::= DEFAULT",
132111
- /* 311 */ "plus_num ::= INTEGER|FLOAT",
132112
- /* 312 */ "foreach_clause ::=",
132113
- /* 313 */ "foreach_clause ::= FOR EACH ROW",
132114
- /* 314 */ "trnm ::= nm",
132115
- /* 315 */ "tridxby ::=",
132116
- /* 316 */ "database_kw_opt ::= DATABASE",
132117
- /* 317 */ "database_kw_opt ::=",
132118
- /* 318 */ "kwcolumn_opt ::=",
132119
- /* 319 */ "kwcolumn_opt ::= COLUMNKW",
132120
- /* 320 */ "vtabarglist ::= vtabarg",
132121
- /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132122
- /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
132123
- /* 323 */ "anylist ::=",
132124
- /* 324 */ "anylist ::= anylist LP anylist RP",
132125
- /* 325 */ "anylist ::= anylist ANY",
132604
+ /* 202 */ "paren_exprlist ::=",
132605
+ /* 203 */ "paren_exprlist ::= LP exprlist RP",
132606
+ /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132607
+ /* 205 */ "uniqueflag ::= UNIQUE",
132608
+ /* 206 */ "uniqueflag ::=",
132609
+ /* 207 */ "eidlist_opt ::=",
132610
+ /* 208 */ "eidlist_opt ::= LP eidlist RP",
132611
+ /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132612
+ /* 210 */ "eidlist ::= nm collate sortorder",
132613
+ /* 211 */ "collate ::=",
132614
+ /* 212 */ "collate ::= COLLATE ID|STRING",
132615
+ /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132616
+ /* 214 */ "cmd ::= VACUUM",
132617
+ /* 215 */ "cmd ::= VACUUM nm",
132618
+ /* 216 */ "cmd ::= PRAGMA nm dbnm",
132619
+ /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132620
+ /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132621
+ /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132622
+ /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132623
+ /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132624
+ /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132625
+ /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132626
+ /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132627
+ /* 225 */ "trigger_time ::= BEFORE",
132628
+ /* 226 */ "trigger_time ::= AFTER",
132629
+ /* 227 */ "trigger_time ::= INSTEAD OF",
132630
+ /* 228 */ "trigger_time ::=",
132631
+ /* 229 */ "trigger_event ::= DELETE|INSERT",
132632
+ /* 230 */ "trigger_event ::= UPDATE",
132633
+ /* 231 */ "trigger_event ::= UPDATE OF idlist",
132634
+ /* 232 */ "when_clause ::=",
132635
+ /* 233 */ "when_clause ::= WHEN expr",
132636
+ /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132637
+ /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132638
+ /* 236 */ "trnm ::= nm DOT nm",
132639
+ /* 237 */ "tridxby ::= INDEXED BY nm",
132640
+ /* 238 */ "tridxby ::= NOT INDEXED",
132641
+ /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132642
+ /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132643
+ /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132644
+ /* 242 */ "trigger_cmd ::= select",
132645
+ /* 243 */ "expr ::= RAISE LP IGNORE RP",
132646
+ /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132647
+ /* 245 */ "raisetype ::= ROLLBACK",
132648
+ /* 246 */ "raisetype ::= ABORT",
132649
+ /* 247 */ "raisetype ::= FAIL",
132650
+ /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132651
+ /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132652
+ /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132653
+ /* 251 */ "key_opt ::=",
132654
+ /* 252 */ "key_opt ::= KEY expr",
132655
+ /* 253 */ "cmd ::= REINDEX",
132656
+ /* 254 */ "cmd ::= REINDEX nm dbnm",
132657
+ /* 255 */ "cmd ::= ANALYZE",
132658
+ /* 256 */ "cmd ::= ANALYZE nm dbnm",
132659
+ /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132660
+ /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132661
+ /* 259 */ "add_column_fullname ::= fullname",
132662
+ /* 260 */ "cmd ::= create_vtab",
132663
+ /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132664
+ /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132665
+ /* 263 */ "vtabarg ::=",
132666
+ /* 264 */ "vtabargtoken ::= ANY",
132667
+ /* 265 */ "vtabargtoken ::= lp anylist RP",
132668
+ /* 266 */ "lp ::= LP",
132669
+ /* 267 */ "with ::=",
132670
+ /* 268 */ "with ::= WITH wqlist",
132671
+ /* 269 */ "with ::= WITH RECURSIVE wqlist",
132672
+ /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132673
+ /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132674
+ /* 272 */ "input ::= cmdlist",
132675
+ /* 273 */ "cmdlist ::= cmdlist ecmd",
132676
+ /* 274 */ "cmdlist ::= ecmd",
132677
+ /* 275 */ "ecmd ::= SEMI",
132678
+ /* 276 */ "ecmd ::= explain cmdx SEMI",
132679
+ /* 277 */ "explain ::=",
132680
+ /* 278 */ "trans_opt ::=",
132681
+ /* 279 */ "trans_opt ::= TRANSACTION",
132682
+ /* 280 */ "trans_opt ::= TRANSACTION nm",
132683
+ /* 281 */ "savepoint_opt ::= SAVEPOINT",
132684
+ /* 282 */ "savepoint_opt ::=",
132685
+ /* 283 */ "cmd ::= create_table create_table_args",
132686
+ /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132687
+ /* 285 */ "columnlist ::= columnname carglist",
132688
+ /* 286 */ "nm ::= ID|INDEXED",
132689
+ /* 287 */ "nm ::= STRING",
132690
+ /* 288 */ "nm ::= JOIN_KW",
132691
+ /* 289 */ "typetoken ::= typename",
132692
+ /* 290 */ "typename ::= ID|STRING",
132693
+ /* 291 */ "signed ::= plus_num",
132694
+ /* 292 */ "signed ::= minus_num",
132695
+ /* 293 */ "carglist ::= carglist ccons",
132696
+ /* 294 */ "carglist ::=",
132697
+ /* 295 */ "ccons ::= NULL onconf",
132698
+ /* 296 */ "conslist_opt ::= COMMA conslist",
132699
+ /* 297 */ "conslist ::= conslist tconscomma tcons",
132700
+ /* 298 */ "conslist ::= tcons",
132701
+ /* 299 */ "tconscomma ::=",
132702
+ /* 300 */ "defer_subclause_opt ::= defer_subclause",
132703
+ /* 301 */ "resolvetype ::= raisetype",
132704
+ /* 302 */ "selectnowith ::= oneselect",
132705
+ /* 303 */ "oneselect ::= values",
132706
+ /* 304 */ "sclp ::= selcollist COMMA",
132707
+ /* 305 */ "as ::= ID|STRING",
132708
+ /* 306 */ "expr ::= term",
132709
+ /* 307 */ "exprlist ::= nexprlist",
132710
+ /* 308 */ "nmnum ::= plus_num",
132711
+ /* 309 */ "nmnum ::= nm",
132712
+ /* 310 */ "nmnum ::= ON",
132713
+ /* 311 */ "nmnum ::= DELETE",
132714
+ /* 312 */ "nmnum ::= DEFAULT",
132715
+ /* 313 */ "plus_num ::= INTEGER|FLOAT",
132716
+ /* 314 */ "foreach_clause ::=",
132717
+ /* 315 */ "foreach_clause ::= FOR EACH ROW",
132718
+ /* 316 */ "trnm ::= nm",
132719
+ /* 317 */ "tridxby ::=",
132720
+ /* 318 */ "database_kw_opt ::= DATABASE",
132721
+ /* 319 */ "database_kw_opt ::=",
132722
+ /* 320 */ "kwcolumn_opt ::=",
132723
+ /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132724
+ /* 322 */ "vtabarglist ::= vtabarg",
132725
+ /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132726
+ /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132727
+ /* 325 */ "anylist ::=",
132728
+ /* 326 */ "anylist ::= anylist LP anylist RP",
132729
+ /* 327 */ "anylist ::= anylist ANY",
132126132730
};
132127132731
#endif /* NDEBUG */
132128132732
132129132733
132130132734
#if YYSTACKDEPTH<=0
132131132735
/*
132132
-** Try to increase the size of the parser stack.
132736
+** Try to increase the size of the parser stack. Return the number
132737
+** of errors. Return 0 on success.
132133132738
*/
132134
-static void yyGrowStack(yyParser *p){
132739
+static int yyGrowStack(yyParser *p){
132135132740
int newSize;
132741
+ int idx;
132136132742
yyStackEntry *pNew;
132137132743
132138132744
newSize = p->yystksz*2 + 100;
132139
- pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132745
+ idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
132746
+ if( p->yystack==&p->yystk0 ){
132747
+ pNew = malloc(newSize*sizeof(pNew[0]));
132748
+ if( pNew ) pNew[0] = p->yystk0;
132749
+ }else{
132750
+ pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132751
+ }
132140132752
if( pNew ){
132141132753
p->yystack = pNew;
132142
- p->yystksz = newSize;
132754
+ p->yytos = &p->yystack[idx];
132143132755
#ifndef NDEBUG
132144132756
if( yyTraceFILE ){
132145
- fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
132146
- yyTracePrompt, p->yystksz);
132757
+ fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
132758
+ yyTracePrompt, p->yystksz, newSize);
132147132759
}
132148132760
#endif
132761
+ p->yystksz = newSize;
132149132762
}
132763
+ return pNew==0;
132150132764
}
132151132765
#endif
132152132766
132153132767
/* Datatype of the argument to the memory allocated passed as the
132154132768
** second argument to sqlite3ParserAlloc() below. This can be changed by
@@ -132173,19 +132787,28 @@
132173132787
*/
132174132788
SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
132175132789
yyParser *pParser;
132176132790
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
132177132791
if( pParser ){
132178
- pParser->yyidx = -1;
132179132792
#ifdef YYTRACKMAXSTACKDEPTH
132180
- pParser->yyidxMax = 0;
132793
+ pParser->yyhwm = 0;
132181132794
#endif
132182132795
#if YYSTACKDEPTH<=0
132796
+ pParser->yytos = NULL;
132183132797
pParser->yystack = NULL;
132184132798
pParser->yystksz = 0;
132185
- yyGrowStack(pParser);
132799
+ if( yyGrowStack(pParser) ){
132800
+ pParser->yystack = &pParser->yystk0;
132801
+ pParser->yystksz = 1;
132802
+ }
132186132803
#endif
132804
+#ifndef YYNOERRORRECOVERY
132805
+ pParser->yyerrcnt = -1;
132806
+#endif
132807
+ pParser->yytos = pParser->yystack;
132808
+ pParser->yystack[0].stateno = 0;
132809
+ pParser->yystack[0].major = 0;
132187132810
}
132188132811
return pParser;
132189132812
}
132190132813
132191132814
/* The following function deletes the "minor type" or semantic value
@@ -132216,17 +132839,17 @@
132216132839
case 163: /* select */
132217132840
case 194: /* selectnowith */
132218132841
case 195: /* oneselect */
132219132842
case 206: /* values */
132220132843
{
132221
-sqlite3SelectDelete(pParse->db, (yypminor->yy159));
132844
+sqlite3SelectDelete(pParse->db, (yypminor->yy243));
132222132845
}
132223132846
break;
132224132847
case 172: /* term */
132225132848
case 173: /* expr */
132226132849
{
132227
-sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);
132850
+sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);
132228132851
}
132229132852
break;
132230132853
case 177: /* eidlist_opt */
132231132854
case 186: /* sortlist */
132232132855
case 187: /* eidlist */
@@ -132235,56 +132858,57 @@
132235132858
case 204: /* orderby_opt */
132236132859
case 207: /* nexprlist */
132237132860
case 208: /* exprlist */
132238132861
case 209: /* sclp */
132239132862
case 218: /* setlist */
132240
- case 225: /* case_exprlist */
132863
+ case 224: /* paren_exprlist */
132864
+ case 226: /* case_exprlist */
132241132865
{
132242
-sqlite3ExprListDelete(pParse->db, (yypminor->yy442));
132866
+sqlite3ExprListDelete(pParse->db, (yypminor->yy148));
132243132867
}
132244132868
break;
132245132869
case 193: /* fullname */
132246132870
case 200: /* from */
132247132871
case 211: /* seltablist */
132248132872
case 212: /* stl_prefix */
132249132873
{
132250
-sqlite3SrcListDelete(pParse->db, (yypminor->yy347));
132874
+sqlite3SrcListDelete(pParse->db, (yypminor->yy185));
132251132875
}
132252132876
break;
132253132877
case 196: /* with */
132254
- case 249: /* wqlist */
132878
+ case 250: /* wqlist */
132255132879
{
132256
-sqlite3WithDelete(pParse->db, (yypminor->yy331));
132880
+sqlite3WithDelete(pParse->db, (yypminor->yy285));
132257132881
}
132258132882
break;
132259132883
case 201: /* where_opt */
132260132884
case 203: /* having_opt */
132261132885
case 215: /* on_opt */
132262
- case 224: /* case_operand */
132263
- case 226: /* case_else */
132264
- case 235: /* when_clause */
132265
- case 240: /* key_opt */
132886
+ case 225: /* case_operand */
132887
+ case 227: /* case_else */
132888
+ case 236: /* when_clause */
132889
+ case 241: /* key_opt */
132266132890
{
132267
-sqlite3ExprDelete(pParse->db, (yypminor->yy122));
132891
+sqlite3ExprDelete(pParse->db, (yypminor->yy72));
132268132892
}
132269132893
break;
132270132894
case 216: /* using_opt */
132271132895
case 217: /* idlist */
132272132896
case 220: /* idlist_opt */
132273132897
{
132274
-sqlite3IdListDelete(pParse->db, (yypminor->yy180));
132898
+sqlite3IdListDelete(pParse->db, (yypminor->yy254));
132275132899
}
132276132900
break;
132277
- case 231: /* trigger_cmd_list */
132278
- case 236: /* trigger_cmd */
132901
+ case 232: /* trigger_cmd_list */
132902
+ case 237: /* trigger_cmd */
132279132903
{
132280
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327));
132904
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145));
132281132905
}
132282132906
break;
132283
- case 233: /* trigger_event */
132907
+ case 234: /* trigger_event */
132284132908
{
132285
-sqlite3IdListDelete(pParse->db, (yypminor->yy410).b);
132909
+sqlite3IdListDelete(pParse->db, (yypminor->yy332).b);
132286132910
}
132287132911
break;
132288132912
/********* End destructor definitions *****************************************/
132289132913
default: break; /* If no destructor action specified: do nothing */
132290132914
}
@@ -132296,12 +132920,13 @@
132296132920
** If there is a destructor routine associated with the token which
132297132921
** is popped from the stack, then call it.
132298132922
*/
132299132923
static void yy_pop_parser_stack(yyParser *pParser){
132300132924
yyStackEntry *yytos;
132301
- assert( pParser->yyidx>=0 );
132302
- yytos = &pParser->yystack[pParser->yyidx--];
132925
+ assert( pParser->yytos!=0 );
132926
+ assert( pParser->yytos > pParser->yystack );
132927
+ yytos = pParser->yytos--;
132303132928
#ifndef NDEBUG
132304132929
if( yyTraceFILE ){
132305132930
fprintf(yyTraceFILE,"%sPopping %s\n",
132306132931
yyTracePrompt,
132307132932
yyTokenName[yytos->major]);
@@ -132324,13 +132949,13 @@
132324132949
){
132325132950
yyParser *pParser = (yyParser*)p;
132326132951
#ifndef YYPARSEFREENEVERNULL
132327132952
if( pParser==0 ) return;
132328132953
#endif
132329
- while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
132954
+ while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
132330132955
#if YYSTACKDEPTH<=0
132331
- free(pParser->yystack);
132956
+ if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
132332132957
#endif
132333132958
(*freeProc)((void*)pParser);
132334132959
}
132335132960
132336132961
/*
@@ -132337,11 +132962,11 @@
132337132962
** Return the peak depth of the stack for a parser.
132338132963
*/
132339132964
#ifdef YYTRACKMAXSTACKDEPTH
132340132965
SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){
132341132966
yyParser *pParser = (yyParser*)p;
132342
- return pParser->yyidxMax;
132967
+ return pParser->yyhwm;
132343132968
}
132344132969
#endif
132345132970
132346132971
/*
132347132972
** Find the appropriate action for a parser given the terminal
@@ -132350,11 +132975,11 @@
132350132975
static unsigned int yy_find_shift_action(
132351132976
yyParser *pParser, /* The parser */
132352132977
YYCODETYPE iLookAhead /* The look-ahead token */
132353132978
){
132354132979
int i;
132355
- int stateno = pParser->yystack[pParser->yyidx].stateno;
132980
+ int stateno = pParser->yytos->stateno;
132356132981
132357132982
if( stateno>=YY_MIN_REDUCE ) return stateno;
132358132983
assert( stateno <= YY_SHIFT_COUNT );
132359132984
do{
132360132985
i = yy_shift_ofst[stateno];
@@ -132443,17 +133068,17 @@
132443133068
/*
132444133069
** The following routine is called if the stack overflows.
132445133070
*/
132446133071
static void yyStackOverflow(yyParser *yypParser){
132447133072
sqlite3ParserARG_FETCH;
132448
- yypParser->yyidx--;
133073
+ yypParser->yytos--;
132449133074
#ifndef NDEBUG
132450133075
if( yyTraceFILE ){
132451133076
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
132452133077
}
132453133078
#endif
132454
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
133079
+ while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
132455133080
/* Here code is inserted which will execute if the parser
132456133081
** stack every overflows */
132457133082
/******** Begin %stack_overflow code ******************************************/
132458133083
132459133084
sqlite3ErrorMsg(pParse, "parser stack overflow");
@@ -132467,15 +133092,15 @@
132467133092
#ifndef NDEBUG
132468133093
static void yyTraceShift(yyParser *yypParser, int yyNewState){
132469133094
if( yyTraceFILE ){
132470133095
if( yyNewState<YYNSTATE ){
132471133096
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
132472
- yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
133097
+ yyTracePrompt,yyTokenName[yypParser->yytos->major],
132473133098
yyNewState);
132474133099
}else{
132475133100
fprintf(yyTraceFILE,"%sShift '%s'\n",
132476
- yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
133101
+ yyTracePrompt,yyTokenName[yypParser->yytos->major]);
132477133102
}
132478133103
}
132479133104
}
132480133105
#else
132481133106
# define yyTraceShift(X,Y)
@@ -132489,31 +133114,34 @@
132489133114
int yyNewState, /* The new state to shift in */
132490133115
int yyMajor, /* The major token to shift in */
132491133116
sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
132492133117
){
132493133118
yyStackEntry *yytos;
132494
- yypParser->yyidx++;
133119
+ yypParser->yytos++;
132495133120
#ifdef YYTRACKMAXSTACKDEPTH
132496
- if( yypParser->yyidx>yypParser->yyidxMax ){
132497
- yypParser->yyidxMax = yypParser->yyidx;
133121
+ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133122
+ yypParser->yyhwm++;
133123
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
132498133124
}
132499133125
#endif
132500133126
#if YYSTACKDEPTH>0
132501
- if( yypParser->yyidx>=YYSTACKDEPTH ){
133127
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
132502133128
yyStackOverflow(yypParser);
132503133129
return;
132504133130
}
132505133131
#else
132506
- if( yypParser->yyidx>=yypParser->yystksz ){
132507
- yyGrowStack(yypParser);
132508
- if( yypParser->yyidx>=yypParser->yystksz ){
133132
+ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
133133
+ if( yyGrowStack(yypParser) ){
132509133134
yyStackOverflow(yypParser);
132510133135
return;
132511133136
}
132512133137
}
132513133138
#endif
132514
- yytos = &yypParser->yystack[yypParser->yyidx];
133139
+ if( yyNewState > YY_MAX_SHIFT ){
133140
+ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
133141
+ }
133142
+ yytos = yypParser->yytos;
132515133143
yytos->stateno = (YYACTIONTYPE)yyNewState;
132516133144
yytos->major = (YYCODETYPE)yyMajor;
132517133145
yytos->minor.yy0 = yyMinor;
132518133146
yyTraceShift(yypParser, yyNewState);
132519133147
}
@@ -132713,31 +133341,33 @@
132713133341
{ 223, 1 },
132714133342
{ 223, 2 },
132715133343
{ 173, 5 },
132716133344
{ 173, 3 },
132717133345
{ 173, 5 },
132718
- { 173, 4 },
133346
+ { 173, 5 },
132719133347
{ 173, 4 },
132720133348
{ 173, 5 },
132721
- { 225, 5 },
132722
- { 225, 4 },
132723
- { 226, 2 },
132724
- { 226, 0 },
132725
- { 224, 1 },
132726
- { 224, 0 },
133349
+ { 226, 5 },
133350
+ { 226, 4 },
133351
+ { 227, 2 },
133352
+ { 227, 0 },
133353
+ { 225, 1 },
133354
+ { 225, 0 },
132727133355
{ 208, 0 },
132728133356
{ 207, 3 },
132729133357
{ 207, 1 },
133358
+ { 224, 0 },
133359
+ { 224, 3 },
132730133360
{ 149, 12 },
132731
- { 227, 1 },
132732
- { 227, 0 },
133361
+ { 228, 1 },
133362
+ { 228, 0 },
132733133363
{ 177, 0 },
132734133364
{ 177, 3 },
132735133365
{ 187, 5 },
132736133366
{ 187, 3 },
132737
- { 228, 0 },
132738
- { 228, 2 },
133367
+ { 229, 0 },
133368
+ { 229, 2 },
132739133369
{ 149, 4 },
132740133370
{ 149, 1 },
132741133371
{ 149, 2 },
132742133372
{ 149, 3 },
132743133373
{ 149, 5 },
@@ -132745,58 +133375,58 @@
132745133375
{ 149, 5 },
132746133376
{ 149, 6 },
132747133377
{ 169, 2 },
132748133378
{ 170, 2 },
132749133379
{ 149, 5 },
132750
- { 230, 11 },
132751
- { 232, 1 },
132752
- { 232, 1 },
132753
- { 232, 2 },
132754
- { 232, 0 },
133380
+ { 231, 11 },
132755133381
{ 233, 1 },
132756133382
{ 233, 1 },
132757
- { 233, 3 },
132758
- { 235, 0 },
132759
- { 235, 2 },
132760
- { 231, 3 },
132761
- { 231, 2 },
132762
- { 237, 3 },
133383
+ { 233, 2 },
133384
+ { 233, 0 },
133385
+ { 234, 1 },
133386
+ { 234, 1 },
133387
+ { 234, 3 },
133388
+ { 236, 0 },
133389
+ { 236, 2 },
133390
+ { 232, 3 },
133391
+ { 232, 2 },
132763133392
{ 238, 3 },
132764
- { 238, 2 },
132765
- { 236, 7 },
132766
- { 236, 5 },
132767
- { 236, 5 },
132768
- { 236, 1 },
133393
+ { 239, 3 },
133394
+ { 239, 2 },
133395
+ { 237, 7 },
133396
+ { 237, 5 },
133397
+ { 237, 5 },
133398
+ { 237, 1 },
132769133399
{ 173, 4 },
132770133400
{ 173, 6 },
132771133401
{ 191, 1 },
132772133402
{ 191, 1 },
132773133403
{ 191, 1 },
132774133404
{ 149, 4 },
132775133405
{ 149, 6 },
132776133406
{ 149, 3 },
132777
- { 240, 0 },
132778
- { 240, 2 },
133407
+ { 241, 0 },
133408
+ { 241, 2 },
132779133409
{ 149, 1 },
132780133410
{ 149, 3 },
132781133411
{ 149, 1 },
132782133412
{ 149, 3 },
132783133413
{ 149, 6 },
132784133414
{ 149, 7 },
132785
- { 241, 1 },
133415
+ { 242, 1 },
132786133416
{ 149, 1 },
132787133417
{ 149, 4 },
132788
- { 243, 8 },
132789
- { 245, 0 },
132790
- { 246, 1 },
132791
- { 246, 3 },
133418
+ { 244, 8 },
133419
+ { 246, 0 },
132792133420
{ 247, 1 },
133421
+ { 247, 3 },
133422
+ { 248, 1 },
132793133423
{ 196, 0 },
132794133424
{ 196, 2 },
132795133425
{ 196, 3 },
132796
- { 249, 6 },
132797
- { 249, 8 },
133426
+ { 250, 6 },
133427
+ { 250, 8 },
132798133428
{ 144, 1 },
132799133429
{ 145, 2 },
132800133430
{ 145, 1 },
132801133431
{ 146, 1 },
132802133432
{ 146, 3 },
@@ -132829,30 +133459,30 @@
132829133459
{ 195, 1 },
132830133460
{ 209, 2 },
132831133461
{ 210, 1 },
132832133462
{ 173, 1 },
132833133463
{ 208, 1 },
132834
- { 229, 1 },
132835
- { 229, 1 },
132836
- { 229, 1 },
132837
- { 229, 1 },
132838
- { 229, 1 },
133464
+ { 230, 1 },
133465
+ { 230, 1 },
133466
+ { 230, 1 },
133467
+ { 230, 1 },
133468
+ { 230, 1 },
132839133469
{ 169, 1 },
132840
- { 234, 0 },
132841
- { 234, 3 },
132842
- { 237, 1 },
132843
- { 238, 0 },
132844
- { 239, 1 },
133470
+ { 235, 0 },
133471
+ { 235, 3 },
133472
+ { 238, 1 },
132845133473
{ 239, 0 },
132846
- { 242, 0 },
132847
- { 242, 1 },
132848
- { 244, 1 },
132849
- { 244, 3 },
132850
- { 245, 2 },
132851
- { 248, 0 },
132852
- { 248, 4 },
132853
- { 248, 2 },
133474
+ { 240, 1 },
133475
+ { 240, 0 },
133476
+ { 243, 0 },
133477
+ { 243, 1 },
133478
+ { 245, 1 },
133479
+ { 245, 3 },
133480
+ { 246, 2 },
133481
+ { 249, 0 },
133482
+ { 249, 4 },
133483
+ { 249, 2 },
132854133484
};
132855133485
132856133486
static void yy_accept(yyParser*); /* Forward Declaration */
132857133487
132858133488
/*
@@ -132866,11 +133496,11 @@
132866133496
int yygoto; /* The next state */
132867133497
int yyact; /* The next action */
132868133498
yyStackEntry *yymsp; /* The top of the parser's stack */
132869133499
int yysize; /* Amount to pop the stack */
132870133500
sqlite3ParserARG_FETCH;
132871
- yymsp = &yypParser->yystack[yypParser->yyidx];
133501
+ yymsp = yypParser->yytos;
132872133502
#ifndef NDEBUG
132873133503
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
132874133504
yysize = yyRuleInfo[yyruleno].nrhs;
132875133505
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
132876133506
yyRuleName[yyruleno], yymsp[-yysize].stateno);
@@ -132880,26 +133510,27 @@
132880133510
/* Check that the stack is large enough to grow by a single entry
132881133511
** if the RHS of the rule is empty. This ensures that there is room
132882133512
** enough on the stack to push the LHS value */
132883133513
if( yyRuleInfo[yyruleno].nrhs==0 ){
132884133514
#ifdef YYTRACKMAXSTACKDEPTH
132885
- if( yypParser->yyidx>yypParser->yyidxMax ){
132886
- yypParser->yyidxMax = yypParser->yyidx;
133515
+ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133516
+ yypParser->yyhwm++;
133517
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
132887133518
}
132888133519
#endif
132889133520
#if YYSTACKDEPTH>0
132890
- if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
133521
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
132891133522
yyStackOverflow(yypParser);
132892133523
return;
132893133524
}
132894133525
#else
132895
- if( yypParser->yyidx>=yypParser->yystksz-1 ){
132896
- yyGrowStack(yypParser);
132897
- if( yypParser->yyidx>=yypParser->yystksz-1 ){
133526
+ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
133527
+ if( yyGrowStack(yypParser) ){
132898133528
yyStackOverflow(yypParser);
132899133529
return;
132900133530
}
133531
+ yymsp = yypParser->yytos;
132901133532
}
132902133533
#endif
132903133534
}
132904133535
132905133536
switch( yyruleno ){
@@ -132921,19 +133552,19 @@
132921133552
break;
132922133553
case 2: /* cmdx ::= cmd */
132923133554
{ sqlite3FinishCoding(pParse); }
132924133555
break;
132925133556
case 3: /* cmd ::= BEGIN transtype trans_opt */
132926
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);}
133557
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);}
132927133558
break;
132928133559
case 4: /* transtype ::= */
132929
-{yymsp[1].minor.yy392 = TK_DEFERRED;}
133560
+{yymsp[1].minor.yy194 = TK_DEFERRED;}
132930133561
break;
132931133562
case 5: /* transtype ::= DEFERRED */
132932133563
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
132933133564
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
132934
-{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-X*/}
133565
+{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
132935133566
break;
132936133567
case 8: /* cmd ::= COMMIT trans_opt */
132937133568
case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
132938133569
{sqlite3CommitTransaction(pParse);}
132939133570
break;
@@ -132955,11 +133586,11 @@
132955133586
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
132956133587
}
132957133588
break;
132958133589
case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
132959133590
{
132960
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392);
133591
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
132961133592
}
132962133593
break;
132963133594
case 15: /* createkw ::= CREATE */
132964133595
{disableLookaside(pParse);}
132965133596
break;
@@ -132969,37 +133600,37 @@
132969133600
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
132970133601
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
132971133602
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
132972133603
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
132973133604
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
132974
- case 209: /* collate ::= */ yytestcase(yyruleno==209);
132975
-{yymsp[1].minor.yy392 = 0;}
133605
+ case 211: /* collate ::= */ yytestcase(yyruleno==211);
133606
+{yymsp[1].minor.yy194 = 0;}
132976133607
break;
132977133608
case 17: /* ifnotexists ::= IF NOT EXISTS */
132978
-{yymsp[-2].minor.yy392 = 1;}
133609
+{yymsp[-2].minor.yy194 = 1;}
132979133610
break;
132980133611
case 18: /* temp ::= TEMP */
132981133612
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
132982
-{yymsp[0].minor.yy392 = 1;}
133613
+{yymsp[0].minor.yy194 = 1;}
132983133614
break;
132984133615
case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
132985133616
{
132986
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy392,0);
133617
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
132987133618
}
132988133619
break;
132989133620
case 21: /* create_table_args ::= AS select */
132990133621
{
132991
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy159);
132992
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
133622
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
133623
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
132993133624
}
132994133625
break;
132995133626
case 23: /* table_options ::= WITHOUT nm */
132996133627
{
132997133628
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
132998
- yymsp[-1].minor.yy392 = TF_WithoutRowid | TF_NoVisibleRowid;
133629
+ yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
132999133630
}else{
133000
- yymsp[-1].minor.yy392 = 0;
133631
+ yymsp[-1].minor.yy194 = 0;
133001133632
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
133002133633
}
133003133634
}
133004133635
break;
133005133636
case 24: /* columnname ::= nm typetoken */
@@ -133027,21 +133658,21 @@
133027133658
case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
133028133659
{pParse->constraintName = yymsp[0].minor.yy0;}
133029133660
break;
133030133661
case 30: /* ccons ::= DEFAULT term */
133031133662
case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
133032
-{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
133663
+{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
133033133664
break;
133034133665
case 31: /* ccons ::= DEFAULT LP expr RP */
133035
-{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);}
133666
+{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
133036133667
break;
133037133668
case 33: /* ccons ::= DEFAULT MINUS term */
133038133669
{
133039133670
ExprSpan v;
133040
- v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);
133671
+ v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0, 0);
133041133672
v.zStart = yymsp[-1].minor.yy0.z;
133042
- v.zEnd = yymsp[0].minor.yy342.zEnd;
133673
+ v.zEnd = yymsp[0].minor.yy190.zEnd;
133043133674
sqlite3AddDefaultValue(pParse,&v);
133044133675
}
133045133676
break;
133046133677
case 34: /* ccons ::= DEFAULT ID|INDEXED */
133047133678
{
@@ -133049,184 +133680,186 @@
133049133680
spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
133050133681
sqlite3AddDefaultValue(pParse,&v);
133051133682
}
133052133683
break;
133053133684
case 35: /* ccons ::= NOT NULL onconf */
133054
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);}
133685
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
133055133686
break;
133056133687
case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
133057
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);}
133688
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
133058133689
break;
133059133690
case 37: /* ccons ::= UNIQUE onconf */
133060
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);}
133691
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
133692
+ SQLITE_IDXTYPE_UNIQUE);}
133061133693
break;
133062133694
case 38: /* ccons ::= CHECK LP expr RP */
133063
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}
133695
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
133064133696
break;
133065133697
case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
133066
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);}
133698
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
133067133699
break;
133068133700
case 40: /* ccons ::= defer_subclause */
133069
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);}
133701
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
133070133702
break;
133071133703
case 41: /* ccons ::= COLLATE ID|STRING */
133072133704
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
133073133705
break;
133074133706
case 44: /* refargs ::= */
133075
-{ yymsp[1].minor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */}
133707
+{ yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
133076133708
break;
133077133709
case 45: /* refargs ::= refargs refarg */
133078
-{ yymsp[-1].minor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }
133710
+{ yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
133079133711
break;
133080133712
case 46: /* refarg ::= MATCH nm */
133081
-{ yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; }
133713
+{ yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
133082133714
break;
133083133715
case 47: /* refarg ::= ON INSERT refact */
133084
-{ yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; }
133716
+{ yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
133085133717
break;
133086133718
case 48: /* refarg ::= ON DELETE refact */
133087
-{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392; yymsp[-2].minor.yy207.mask = 0x0000ff; }
133719
+{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
133088133720
break;
133089133721
case 49: /* refarg ::= ON UPDATE refact */
133090
-{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; }
133722
+{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
133091133723
break;
133092133724
case 50: /* refact ::= SET NULL */
133093
-{ yymsp[-1].minor.yy392 = OE_SetNull; /* EV: R-33326-45252 */}
133725
+{ yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
133094133726
break;
133095133727
case 51: /* refact ::= SET DEFAULT */
133096
-{ yymsp[-1].minor.yy392 = OE_SetDflt; /* EV: R-33326-45252 */}
133728
+{ yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
133097133729
break;
133098133730
case 52: /* refact ::= CASCADE */
133099
-{ yymsp[0].minor.yy392 = OE_Cascade; /* EV: R-33326-45252 */}
133731
+{ yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
133100133732
break;
133101133733
case 53: /* refact ::= RESTRICT */
133102
-{ yymsp[0].minor.yy392 = OE_Restrict; /* EV: R-33326-45252 */}
133734
+{ yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
133103133735
break;
133104133736
case 54: /* refact ::= NO ACTION */
133105
-{ yymsp[-1].minor.yy392 = OE_None; /* EV: R-33326-45252 */}
133737
+{ yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
133106133738
break;
133107133739
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133108
-{yymsp[-2].minor.yy392 = 0;}
133740
+{yymsp[-2].minor.yy194 = 0;}
133109133741
break;
133110133742
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133111133743
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133112133744
case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133113
-{yymsp[-1].minor.yy392 = yymsp[0].minor.yy392;}
133745
+{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133114133746
break;
133115133747
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133116133748
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133117133749
case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133118133750
case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133119
- case 210: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==210);
133120
-{yymsp[-1].minor.yy392 = 1;}
133751
+ case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
133752
+{yymsp[-1].minor.yy194 = 1;}
133121133753
break;
133122133754
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133123
-{yymsp[-1].minor.yy392 = 0;}
133755
+{yymsp[-1].minor.yy194 = 0;}
133124133756
break;
133125133757
case 61: /* tconscomma ::= COMMA */
133126133758
{pParse->constraintName.n = 0;}
133127133759
break;
133128133760
case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
133129
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
133761
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
133130133762
break;
133131133763
case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
133132
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
133764
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
133765
+ SQLITE_IDXTYPE_UNIQUE);}
133133133766
break;
133134133767
case 65: /* tcons ::= CHECK LP expr RP onconf */
133135
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
133768
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
133136133769
break;
133137133770
case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
133138133771
{
133139
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
133140
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
133772
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
133773
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
133141133774
}
133142133775
break;
133143133776
case 68: /* onconf ::= */
133144133777
case 70: /* orconf ::= */ yytestcase(yyruleno==70);
133145
-{yymsp[1].minor.yy392 = OE_Default;}
133778
+{yymsp[1].minor.yy194 = OE_Default;}
133146133779
break;
133147133780
case 69: /* onconf ::= ON CONFLICT resolvetype */
133148
-{yymsp[-2].minor.yy392 = yymsp[0].minor.yy392;}
133781
+{yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
133149133782
break;
133150133783
case 72: /* resolvetype ::= IGNORE */
133151
-{yymsp[0].minor.yy392 = OE_Ignore;}
133784
+{yymsp[0].minor.yy194 = OE_Ignore;}
133152133785
break;
133153133786
case 73: /* resolvetype ::= REPLACE */
133154133787
case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
133155
-{yymsp[0].minor.yy392 = OE_Replace;}
133788
+{yymsp[0].minor.yy194 = OE_Replace;}
133156133789
break;
133157133790
case 74: /* cmd ::= DROP TABLE ifexists fullname */
133158133791
{
133159
- sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
133792
+ sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
133160133793
}
133161133794
break;
133162133795
case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
133163133796
{
133164
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy159, yymsp[-7].minor.yy392, yymsp[-5].minor.yy392);
133797
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
133165133798
}
133166133799
break;
133167133800
case 78: /* cmd ::= DROP VIEW ifexists fullname */
133168133801
{
133169
- sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
133802
+ sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
133170133803
}
133171133804
break;
133172133805
case 79: /* cmd ::= select */
133173133806
{
133174133807
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
133175
- sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
133176
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
133808
+ sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
133809
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
133177133810
}
133178133811
break;
133179133812
case 80: /* select ::= with selectnowith */
133180133813
{
133181
- Select *p = yymsp[0].minor.yy159;
133814
+ Select *p = yymsp[0].minor.yy243;
133182133815
if( p ){
133183
- p->pWith = yymsp[-1].minor.yy331;
133816
+ p->pWith = yymsp[-1].minor.yy285;
133184133817
parserDoubleLinkSelect(pParse, p);
133185133818
}else{
133186
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy331);
133819
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
133187133820
}
133188
- yymsp[-1].minor.yy159 = p; /*A-overwrites-W*/
133821
+ yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
133189133822
}
133190133823
break;
133191133824
case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
133192133825
{
133193
- Select *pRhs = yymsp[0].minor.yy159;
133194
- Select *pLhs = yymsp[-2].minor.yy159;
133826
+ Select *pRhs = yymsp[0].minor.yy243;
133827
+ Select *pLhs = yymsp[-2].minor.yy243;
133195133828
if( pRhs && pRhs->pPrior ){
133196133829
SrcList *pFrom;
133197133830
Token x;
133198133831
x.n = 0;
133199133832
parserDoubleLinkSelect(pParse, pRhs);
133200133833
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
133201133834
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
133202133835
}
133203133836
if( pRhs ){
133204
- pRhs->op = (u8)yymsp[-1].minor.yy392;
133837
+ pRhs->op = (u8)yymsp[-1].minor.yy194;
133205133838
pRhs->pPrior = pLhs;
133206133839
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
133207133840
pRhs->selFlags &= ~SF_MultiValue;
133208
- if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
133841
+ if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1;
133209133842
}else{
133210133843
sqlite3SelectDelete(pParse->db, pLhs);
133211133844
}
133212
- yymsp[-2].minor.yy159 = pRhs;
133845
+ yymsp[-2].minor.yy243 = pRhs;
133213133846
}
133214133847
break;
133215133848
case 82: /* multiselect_op ::= UNION */
133216133849
case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
133217
-{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-OP*/}
133850
+{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
133218133851
break;
133219133852
case 83: /* multiselect_op ::= UNION ALL */
133220
-{yymsp[-1].minor.yy392 = TK_ALL;}
133853
+{yymsp[-1].minor.yy194 = TK_ALL;}
133221133854
break;
133222133855
case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
133223133856
{
133224133857
#if SELECTTRACE_ENABLED
133225133858
Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
133226133859
#endif
133227
- yymsp[-8].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
133860
+ yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
133228133861
#if SELECTTRACE_ENABLED
133229133862
/* Populate the Select.zSelName[] string that is used to help with
133230133863
** query planner debugging, to differentiate between multiple Select
133231133864
** objects in a complex query.
133232133865
**
@@ -133233,464 +133866,465 @@
133233133866
** If the SELECT keyword is immediately followed by a C-style comment
133234133867
** then extract the first few alphanumeric characters from within that
133235133868
** comment to be the zSelName value. Otherwise, the label is #N where
133236133869
** is an integer that is incremented with each SELECT statement seen.
133237133870
*/
133238
- if( yymsp[-8].minor.yy159!=0 ){
133871
+ if( yymsp[-8].minor.yy243!=0 ){
133239133872
const char *z = s.z+6;
133240133873
int i;
133241
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "#%d",
133874
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "#%d",
133242133875
++pParse->nSelect);
133243133876
while( z[0]==' ' ) z++;
133244133877
if( z[0]=='/' && z[1]=='*' ){
133245133878
z += 2;
133246133879
while( z[0]==' ' ) z++;
133247133880
for(i=0; sqlite3Isalnum(z[i]); i++){}
133248
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "%.*s", i, z);
133881
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "%.*s", i, z);
133249133882
}
133250133883
}
133251133884
#endif /* SELECTRACE_ENABLED */
133252133885
}
133253133886
break;
133254133887
case 86: /* values ::= VALUES LP nexprlist RP */
133255133888
{
133256
- yymsp[-3].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0,0);
133889
+ yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
133257133890
}
133258133891
break;
133259133892
case 87: /* values ::= values COMMA LP exprlist RP */
133260133893
{
133261
- Select *pRight, *pLeft = yymsp[-4].minor.yy159;
133262
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
133894
+ Select *pRight, *pLeft = yymsp[-4].minor.yy243;
133895
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
133263133896
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
133264133897
if( pRight ){
133265133898
pRight->op = TK_ALL;
133266133899
pRight->pPrior = pLeft;
133267
- yymsp[-4].minor.yy159 = pRight;
133900
+ yymsp[-4].minor.yy243 = pRight;
133268133901
}else{
133269
- yymsp[-4].minor.yy159 = pLeft;
133902
+ yymsp[-4].minor.yy243 = pLeft;
133270133903
}
133271133904
}
133272133905
break;
133273133906
case 88: /* distinct ::= DISTINCT */
133274
-{yymsp[0].minor.yy392 = SF_Distinct;}
133907
+{yymsp[0].minor.yy194 = SF_Distinct;}
133275133908
break;
133276133909
case 89: /* distinct ::= ALL */
133277
-{yymsp[0].minor.yy392 = SF_All;}
133910
+{yymsp[0].minor.yy194 = SF_All;}
133278133911
break;
133279133912
case 91: /* sclp ::= */
133280133913
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
133281133914
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
133282133915
case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
133283
- case 205: /* eidlist_opt ::= */ yytestcase(yyruleno==205);
133284
-{yymsp[1].minor.yy442 = 0;}
133916
+ case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
133917
+ case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
133918
+{yymsp[1].minor.yy148 = 0;}
133285133919
break;
133286133920
case 92: /* selcollist ::= sclp expr as */
133287133921
{
133288
- yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
133289
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0, 1);
133290
- sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy442,&yymsp[-1].minor.yy342);
133922
+ yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
133923
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
133924
+ sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
133291133925
}
133292133926
break;
133293133927
case 93: /* selcollist ::= sclp STAR */
133294133928
{
133295133929
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
133296
- yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
133930
+ yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
133297133931
}
133298133932
break;
133299133933
case 94: /* selcollist ::= sclp nm DOT STAR */
133300133934
{
133301133935
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0);
133302133936
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133303133937
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
133304
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
133938
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
133305133939
}
133306133940
break;
133307133941
case 95: /* as ::= AS nm */
133308133942
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
133309
- case 219: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==219);
133310
- case 220: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==220);
133943
+ case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
133944
+ case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
133311133945
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
133312133946
break;
133313133947
case 97: /* from ::= */
133314
-{yymsp[1].minor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy347));}
133948
+{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
133315133949
break;
133316133950
case 98: /* from ::= FROM seltablist */
133317133951
{
133318
- yymsp[-1].minor.yy347 = yymsp[0].minor.yy347;
133319
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy347);
133952
+ yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
133953
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
133320133954
}
133321133955
break;
133322133956
case 99: /* stl_prefix ::= seltablist joinop */
133323133957
{
133324
- if( ALWAYS(yymsp[-1].minor.yy347 && yymsp[-1].minor.yy347->nSrc>0) ) yymsp[-1].minor.yy347->a[yymsp[-1].minor.yy347->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy392;
133958
+ if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
133325133959
}
133326133960
break;
133327133961
case 100: /* stl_prefix ::= */
133328
-{yymsp[1].minor.yy347 = 0;}
133962
+{yymsp[1].minor.yy185 = 0;}
133329133963
break;
133330133964
case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
133331133965
{
133332
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133333
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy347, &yymsp[-2].minor.yy0);
133966
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133967
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
133334133968
}
133335133969
break;
133336133970
case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
133337133971
{
133338
- yymsp[-8].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy347,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133339
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy347, yymsp[-4].minor.yy442);
133972
+ yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133973
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
133340133974
}
133341133975
break;
133342133976
case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
133343133977
{
133344
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133978
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133345133979
}
133346133980
break;
133347133981
case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
133348133982
{
133349
- if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
133350
- yymsp[-6].minor.yy347 = yymsp[-4].minor.yy347;
133351
- }else if( yymsp[-4].minor.yy347->nSrc==1 ){
133352
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133353
- if( yymsp[-6].minor.yy347 ){
133354
- struct SrcList_item *pNew = &yymsp[-6].minor.yy347->a[yymsp[-6].minor.yy347->nSrc-1];
133355
- struct SrcList_item *pOld = yymsp[-4].minor.yy347->a;
133983
+ if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
133984
+ yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
133985
+ }else if( yymsp[-4].minor.yy185->nSrc==1 ){
133986
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133987
+ if( yymsp[-6].minor.yy185 ){
133988
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1];
133989
+ struct SrcList_item *pOld = yymsp[-4].minor.yy185->a;
133356133990
pNew->zName = pOld->zName;
133357133991
pNew->zDatabase = pOld->zDatabase;
133358133992
pNew->pSelect = pOld->pSelect;
133359133993
pOld->zName = pOld->zDatabase = 0;
133360133994
pOld->pSelect = 0;
133361133995
}
133362
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347);
133996
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185);
133363133997
}else{
133364133998
Select *pSubquery;
133365
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347);
133366
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0);
133367
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133999
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185);
134000
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
134001
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133368134002
}
133369134003
}
133370134004
break;
133371134005
case 105: /* dbnm ::= */
133372134006
case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
133373134007
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
133374134008
break;
133375134009
case 107: /* fullname ::= nm dbnm */
133376
-{yymsp[-1].minor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
134010
+{yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
133377134011
break;
133378134012
case 108: /* joinop ::= COMMA|JOIN */
133379
-{ yymsp[0].minor.yy392 = JT_INNER; }
134013
+{ yymsp[0].minor.yy194 = JT_INNER; }
133380134014
break;
133381134015
case 109: /* joinop ::= JOIN_KW JOIN */
133382
-{yymsp[-1].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
134016
+{yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
133383134017
break;
133384134018
case 110: /* joinop ::= JOIN_KW nm JOIN */
133385
-{yymsp[-2].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
134019
+{yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
133386134020
break;
133387134021
case 111: /* joinop ::= JOIN_KW nm nm JOIN */
133388
-{yymsp[-3].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134022
+{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
133389134023
break;
133390134024
case 112: /* on_opt ::= ON expr */
133391134025
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
133392134026
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
133393134027
case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
133394
-{yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr;}
134028
+{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
133395134029
break;
133396134030
case 113: /* on_opt ::= */
133397134031
case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
133398134032
case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
133399134033
case 196: /* case_else ::= */ yytestcase(yyruleno==196);
133400134034
case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
133401
-{yymsp[1].minor.yy122 = 0;}
134035
+{yymsp[1].minor.yy72 = 0;}
133402134036
break;
133403134037
case 115: /* indexed_opt ::= INDEXED BY nm */
133404134038
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
133405134039
break;
133406134040
case 116: /* indexed_opt ::= NOT INDEXED */
133407134041
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
133408134042
break;
133409134043
case 117: /* using_opt ::= USING LP idlist RP */
133410
-{yymsp[-3].minor.yy180 = yymsp[-1].minor.yy180;}
134044
+{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
133411134045
break;
133412134046
case 118: /* using_opt ::= */
133413134047
case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
133414
-{yymsp[1].minor.yy180 = 0;}
134048
+{yymsp[1].minor.yy254 = 0;}
133415134049
break;
133416134050
case 120: /* orderby_opt ::= ORDER BY sortlist */
133417134051
case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
133418
-{yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;}
134052
+{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
133419134053
break;
133420134054
case 121: /* sortlist ::= sortlist COMMA expr sortorder */
133421134055
{
133422
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
133423
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy392);
134056
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
134057
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
133424134058
}
133425134059
break;
133426134060
case 122: /* sortlist ::= expr sortorder */
133427134061
{
133428
- yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); /*A-overwrites-Y*/
133429
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy392);
134062
+ yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
134063
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
133430134064
}
133431134065
break;
133432134066
case 123: /* sortorder ::= ASC */
133433
-{yymsp[0].minor.yy392 = SQLITE_SO_ASC;}
134067
+{yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
133434134068
break;
133435134069
case 124: /* sortorder ::= DESC */
133436
-{yymsp[0].minor.yy392 = SQLITE_SO_DESC;}
134070
+{yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
133437134071
break;
133438134072
case 125: /* sortorder ::= */
133439
-{yymsp[1].minor.yy392 = SQLITE_SO_UNDEFINED;}
134073
+{yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
133440134074
break;
133441134075
case 130: /* limit_opt ::= */
133442
-{yymsp[1].minor.yy64.pLimit = 0; yymsp[1].minor.yy64.pOffset = 0;}
134076
+{yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
133443134077
break;
133444134078
case 131: /* limit_opt ::= LIMIT expr */
133445
-{yymsp[-1].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yymsp[-1].minor.yy64.pOffset = 0;}
134079
+{yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
133446134080
break;
133447134081
case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
133448
-{yymsp[-3].minor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
134082
+{yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
133449134083
break;
133450134084
case 133: /* limit_opt ::= LIMIT expr COMMA expr */
133451
-{yymsp[-3].minor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
134085
+{yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
133452134086
break;
133453134087
case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
133454134088
{
133455
- sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133456
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
133457
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
134089
+ sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134090
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
134091
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
133458134092
}
133459134093
break;
133460134094
case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
133461134095
{
133462
- sqlite3WithPush(pParse, yymsp[-7].minor.yy331, 1);
133463
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
133464
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
133465
- sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy392);
134096
+ sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
134097
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
134098
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
134099
+ sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
133466134100
}
133467134101
break;
133468134102
case 138: /* setlist ::= setlist COMMA nm EQ expr */
133469134103
{
133470
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
133471
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1);
134104
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134105
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
133472134106
}
133473134107
break;
133474134108
case 139: /* setlist ::= nm EQ expr */
133475134109
{
133476
- yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
133477
- sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1);
134110
+ yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134111
+ sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
133478134112
}
133479
- yymsp[-2].minor.yy442 = yylhsminor.yy442;
134113
+ yymsp[-2].minor.yy148 = yylhsminor.yy148;
133480134114
break;
133481134115
case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
133482134116
{
133483
- sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133484
- sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy392);
134117
+ sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134118
+ sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
133485134119
}
133486134120
break;
133487134121
case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
133488134122
{
133489
- sqlite3WithPush(pParse, yymsp[-6].minor.yy331, 1);
133490
- sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy392);
134123
+ sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134124
+ sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
133491134125
}
133492134126
break;
133493134127
case 145: /* idlist_opt ::= LP idlist RP */
133494
-{yymsp[-2].minor.yy180 = yymsp[-1].minor.yy180;}
134128
+{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
133495134129
break;
133496134130
case 146: /* idlist ::= idlist COMMA nm */
133497
-{yymsp[-2].minor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
134131
+{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
133498134132
break;
133499134133
case 147: /* idlist ::= nm */
133500
-{yymsp[0].minor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134134
+{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
133501134135
break;
133502134136
case 148: /* expr ::= LP expr RP */
133503
-{spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr;}
134137
+{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
133504134138
break;
133505134139
case 149: /* term ::= NULL */
133506134140
case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
133507134141
case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
133508
-{spanExpr(&yymsp[0].minor.yy342,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134142
+{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
133509134143
break;
133510134144
case 150: /* expr ::= ID|INDEXED */
133511134145
case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
133512
-{spanExpr(&yymsp[0].minor.yy342,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134146
+{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
133513134147
break;
133514134148
case 152: /* expr ::= nm DOT nm */
133515134149
{
133516134150
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133517134151
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133518
- spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133519
- yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134152
+ spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134153
+ yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
133520134154
}
133521134155
break;
133522134156
case 153: /* expr ::= nm DOT nm DOT nm */
133523134157
{
133524134158
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
133525134159
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133526134160
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133527134161
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
133528
- spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133529
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134162
+ spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134163
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
133530134164
}
133531134165
break;
133532134166
case 156: /* expr ::= VARIABLE */
133533134167
{
133534134168
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
133535
- spanExpr(&yymsp[0].minor.yy342, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
133536
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy342.pExpr);
134169
+ spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134170
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
133537134171
}else{
133538134172
/* When doing a nested parse, one can include terms in an expression
133539134173
** that look like this: #1 #2 ... These terms refer to registers
133540134174
** in the virtual machine. #N is the N-th register. */
133541134175
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
133542134176
assert( t.n>=2 );
133543
- spanSet(&yymsp[0].minor.yy342, &t, &t);
134177
+ spanSet(&yymsp[0].minor.yy190, &t, &t);
133544134178
if( pParse->nested==0 ){
133545134179
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
133546
- yymsp[0].minor.yy342.pExpr = 0;
134180
+ yymsp[0].minor.yy190.pExpr = 0;
133547134181
}else{
133548
- yymsp[0].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
133549
- if( yymsp[0].minor.yy342.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy342.pExpr->iTable);
134182
+ yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
134183
+ if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
133550134184
}
133551134185
}
133552134186
}
133553134187
break;
133554134188
case 157: /* expr ::= expr COLLATE ID|STRING */
133555134189
{
133556
- yymsp[-2].minor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0, 1);
133557
- yymsp[-2].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134190
+ yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134191
+ yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133558134192
}
133559134193
break;
133560134194
case 158: /* expr ::= CAST LP expr AS typetoken RP */
133561134195
{
133562
- spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133563
- yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
134196
+ spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134197
+ yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
133564134198
}
133565134199
break;
133566134200
case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
133567134201
{
133568
- if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134202
+ if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
133569134203
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
133570134204
}
133571
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
133572
- spanSet(&yylhsminor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
133573
- if( yymsp[-2].minor.yy392==SF_Distinct && yylhsminor.yy342.pExpr ){
133574
- yylhsminor.yy342.pExpr->flags |= EP_Distinct;
134205
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
134206
+ spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
134207
+ if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){
134208
+ yylhsminor.yy190.pExpr->flags |= EP_Distinct;
133575134209
}
133576134210
}
133577
- yymsp[-4].minor.yy342 = yylhsminor.yy342;
134211
+ yymsp[-4].minor.yy190 = yylhsminor.yy190;
133578134212
break;
133579134213
case 160: /* expr ::= ID|INDEXED LP STAR RP */
133580134214
{
133581
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
133582
- spanSet(&yylhsminor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134215
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134216
+ spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
133583134217
}
133584
- yymsp[-3].minor.yy342 = yylhsminor.yy342;
134218
+ yymsp[-3].minor.yy190 = yylhsminor.yy190;
133585134219
break;
133586134220
case 161: /* term ::= CTIME_KW */
133587134221
{
133588
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
133589
- spanSet(&yylhsminor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134222
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134223
+ spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
133590134224
}
133591
- yymsp[0].minor.yy342 = yylhsminor.yy342;
134225
+ yymsp[0].minor.yy190 = yylhsminor.yy190;
133592134226
break;
133593134227
case 162: /* expr ::= expr AND expr */
133594134228
case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
133595134229
case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
133596134230
case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
133597134231
case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
133598134232
case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
133599134233
case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
133600134234
case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
133601
-{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
134235
+{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
133602134236
break;
133603134237
case 170: /* likeop ::= LIKE_KW|MATCH */
133604
-{yymsp[0].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy318.bNot = 0;/*A-overwrites-X*/}
134238
+{yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
133605134239
break;
133606134240
case 171: /* likeop ::= NOT LIKE_KW|MATCH */
133607
-{yymsp[-1].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy318.bNot = 1;}
134241
+{yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
133608134242
break;
133609134243
case 172: /* expr ::= expr likeop expr */
133610134244
{
133611134245
ExprList *pList;
133612
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
133613
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
133614
- yymsp[-2].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
133615
- exprNot(pParse, yymsp[-1].minor.yy318.bNot, &yymsp[-2].minor.yy342);
133616
- yymsp[-2].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133617
- if( yymsp[-2].minor.yy342.pExpr ) yymsp[-2].minor.yy342.pExpr->flags |= EP_InfixFunc;
134246
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134247
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134248
+ yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
134249
+ exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134250
+ yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134251
+ if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
133618134252
}
133619134253
break;
133620134254
case 173: /* expr ::= expr likeop expr ESCAPE expr */
133621134255
{
133622134256
ExprList *pList;
133623
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133624
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
133625
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133626
- yymsp[-4].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
133627
- exprNot(pParse, yymsp[-3].minor.yy318.bNot, &yymsp[-4].minor.yy342);
133628
- yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133629
- if( yymsp[-4].minor.yy342.pExpr ) yymsp[-4].minor.yy342.pExpr->flags |= EP_InfixFunc;
134257
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134258
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134259
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134260
+ yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy392.eOperator);
134261
+ exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134262
+ yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134263
+ if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
133630134264
}
133631134265
break;
133632134266
case 174: /* expr ::= expr ISNULL|NOTNULL */
133633
-{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
134267
+{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
133634134268
break;
133635134269
case 175: /* expr ::= expr NOT NULL */
133636
-{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
134270
+{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
133637134271
break;
133638134272
case 176: /* expr ::= expr IS expr */
133639134273
{
133640
- spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
133641
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-2].minor.yy342.pExpr, TK_ISNULL);
134274
+ spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134275
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
133642134276
}
133643134277
break;
133644134278
case 177: /* expr ::= expr IS NOT expr */
133645134279
{
133646
- spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
133647
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-3].minor.yy342.pExpr, TK_NOTNULL);
134280
+ spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134281
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
133648134282
}
133649134283
break;
133650134284
case 178: /* expr ::= NOT expr */
133651134285
case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
133652
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134286
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133653134287
break;
133654134288
case 180: /* expr ::= MINUS expr */
133655
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134289
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133656134290
break;
133657134291
case 181: /* expr ::= PLUS expr */
133658
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134292
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133659134293
break;
133660134294
case 182: /* between_op ::= BETWEEN */
133661134295
case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
133662
-{yymsp[0].minor.yy392 = 0;}
134296
+{yymsp[0].minor.yy194 = 0;}
133663134297
break;
133664134298
case 184: /* expr ::= expr between_op expr AND expr */
133665134299
{
133666
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133667
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133668
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133669
- if( yymsp[-4].minor.yy342.pExpr ){
133670
- yymsp[-4].minor.yy342.pExpr->x.pList = pList;
134300
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134301
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134302
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134303
+ if( yymsp[-4].minor.yy190.pExpr ){
134304
+ yymsp[-4].minor.yy190.pExpr->x.pList = pList;
133671134305
}else{
133672134306
sqlite3ExprListDelete(pParse->db, pList);
133673134307
}
133674
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133675
- yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
134308
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134309
+ yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
133676134310
}
133677134311
break;
133678134312
case 187: /* expr ::= expr in_op LP exprlist RP */
133679134313
{
133680
- if( yymsp[-1].minor.yy442==0 ){
134314
+ if( yymsp[-1].minor.yy148==0 ){
133681134315
/* Expressions of the form
133682134316
**
133683134317
** expr1 IN ()
133684134318
** expr1 NOT IN ()
133685134319
**
133686134320
** simplify to constants 0 (false) and 1 (true), respectively,
133687134321
** regardless of the value of expr1.
133688134322
*/
133689
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);
133690
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);
133691
- }else if( yymsp[-1].minor.yy442->nExpr==1 ){
134323
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);
134324
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy194]);
134325
+ }else if( yymsp[-1].minor.yy148->nExpr==1 ){
133692134326
/* Expressions of the form:
133693134327
**
133694134328
** expr1 IN (?1)
133695134329
** expr1 NOT IN (?2)
133696134330
**
@@ -133703,417 +134337,421 @@
133703134337
** But, the RHS of the == or <> is marked with the EP_Generic flag
133704134338
** so that it may not contribute to the computation of comparison
133705134339
** affinity or the collating sequence to use for comparison. Otherwise,
133706134340
** the semantics would be subtly different from IN or NOT IN.
133707134341
*/
133708
- Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr;
133709
- yymsp[-1].minor.yy442->a[0].pExpr = 0;
133710
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
134342
+ Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;
134343
+ yymsp[-1].minor.yy148->a[0].pExpr = 0;
134344
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
133711134345
/* pRHS cannot be NULL because a malloc error would have been detected
133712134346
** before now and control would have never reached this point */
133713134347
if( ALWAYS(pRHS) ){
133714134348
pRHS->flags &= ~EP_Collate;
133715134349
pRHS->flags |= EP_Generic;
133716134350
}
133717
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy392 ? TK_NE : TK_EQ, yymsp[-4].minor.yy342.pExpr, pRHS, 0);
133718
- }else{
133719
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133720
- if( yymsp[-4].minor.yy342.pExpr ){
133721
- yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;
133722
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
133723
- }else{
133724
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
133725
- }
133726
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133727
- }
133728
- yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134351
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS, 0);
134352
+ }else{
134353
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134354
+ if( yymsp[-4].minor.yy190.pExpr ){
134355
+ yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;
134356
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134357
+ }else{
134358
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134359
+ }
134360
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134361
+ }
134362
+ yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133729134363
}
133730134364
break;
133731134365
case 188: /* expr ::= LP select RP */
133732134366
{
133733
- spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133734
- yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
133735
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy342.pExpr, yymsp[-1].minor.yy159);
134367
+ spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134368
+ yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134369
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
133736134370
}
133737134371
break;
133738134372
case 189: /* expr ::= expr in_op LP select RP */
133739134373
{
133740
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133741
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy342.pExpr, yymsp[-1].minor.yy159);
133742
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133743
- yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133744
- }
133745
- break;
133746
- case 190: /* expr ::= expr in_op nm dbnm */
133747
-{
133748
- SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
134374
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134375
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134376
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134377
+ yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134378
+ }
134379
+ break;
134380
+ case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
134381
+{
134382
+ SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
133749134383
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
133750
- yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
133751
- sqlite3PExprAddSelect(pParse, yymsp[-3].minor.yy342.pExpr, pSelect);
133752
- exprNot(pParse, yymsp[-2].minor.yy392, &yymsp[-3].minor.yy342);
133753
- yymsp[-3].minor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
134384
+ if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134385
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134386
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134387
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134388
+ yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
133754134389
}
133755134390
break;
133756134391
case 191: /* expr ::= EXISTS LP select RP */
133757134392
{
133758134393
Expr *p;
133759
- spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133760
- p = yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
133761
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy159);
134394
+ spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134395
+ p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134396
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
133762134397
}
133763134398
break;
133764134399
case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
133765134400
{
133766
- spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
133767
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0);
133768
- if( yymsp[-4].minor.yy342.pExpr ){
133769
- yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442;
133770
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
134401
+ spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134402
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134403
+ if( yymsp[-4].minor.yy190.pExpr ){
134404
+ yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
134405
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
133771134406
}else{
133772
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
133773
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122);
134407
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134408
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
133774134409
}
133775134410
}
133776134411
break;
133777134412
case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
133778134413
{
133779
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
133780
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
134414
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134415
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
133781134416
}
133782134417
break;
133783134418
case 194: /* case_exprlist ::= WHEN expr THEN expr */
133784134419
{
133785
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133786
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy342.pExpr);
134420
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134421
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
133787134422
}
133788134423
break;
133789134424
case 197: /* case_operand ::= expr */
133790
-{yymsp[0].minor.yy122 = yymsp[0].minor.yy342.pExpr; /*A-overwrites-X*/}
134425
+{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
133791134426
break;
133792134427
case 200: /* nexprlist ::= nexprlist COMMA expr */
133793
-{yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
134428
+{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
133794134429
break;
133795134430
case 201: /* nexprlist ::= expr */
133796
-{yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr); /*A-overwrites-Y*/}
134431
+{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
133797134432
break;
133798
- case 202: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134433
+ case 203: /* paren_exprlist ::= LP exprlist RP */
134434
+ case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
134435
+{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134436
+ break;
134437
+ case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
133799134438
{
133800134439
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
133801
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
133802
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
133803
-}
133804
- break;
133805
- case 203: /* uniqueflag ::= UNIQUE */
133806
- case 244: /* raisetype ::= ABORT */ yytestcase(yyruleno==244);
133807
-{yymsp[0].minor.yy392 = OE_Abort;}
133808
- break;
133809
- case 204: /* uniqueflag ::= */
133810
-{yymsp[1].minor.yy392 = OE_None;}
133811
- break;
133812
- case 206: /* eidlist_opt ::= LP eidlist RP */
133813
-{yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;}
133814
- break;
133815
- case 207: /* eidlist ::= eidlist COMMA nm collate sortorder */
133816
-{
133817
- yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392);
133818
-}
133819
- break;
133820
- case 208: /* eidlist ::= nm collate sortorder */
133821
-{
133822
- yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); /*A-overwrites-Y*/
133823
-}
133824
- break;
133825
- case 211: /* cmd ::= DROP INDEX ifexists fullname */
133826
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
133827
- break;
133828
- case 212: /* cmd ::= VACUUM */
133829
- case 213: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==213);
134440
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134441
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134442
+}
134443
+ break;
134444
+ case 205: /* uniqueflag ::= UNIQUE */
134445
+ case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
134446
+{yymsp[0].minor.yy194 = OE_Abort;}
134447
+ break;
134448
+ case 206: /* uniqueflag ::= */
134449
+{yymsp[1].minor.yy194 = OE_None;}
134450
+ break;
134451
+ case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
134452
+{
134453
+ yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134454
+}
134455
+ break;
134456
+ case 210: /* eidlist ::= nm collate sortorder */
134457
+{
134458
+ yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134459
+}
134460
+ break;
134461
+ case 213: /* cmd ::= DROP INDEX ifexists fullname */
134462
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134463
+ break;
134464
+ case 214: /* cmd ::= VACUUM */
134465
+ case 215: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==215);
133830134466
{sqlite3Vacuum(pParse);}
133831134467
break;
133832
- case 214: /* cmd ::= PRAGMA nm dbnm */
134468
+ case 216: /* cmd ::= PRAGMA nm dbnm */
133833134469
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
133834134470
break;
133835
- case 215: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134471
+ case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
133836134472
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
133837134473
break;
133838
- case 216: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134474
+ case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
133839134475
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
133840134476
break;
133841
- case 217: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134477
+ case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
133842134478
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
133843134479
break;
133844
- case 218: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134480
+ case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
133845134481
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
133846134482
break;
133847
- case 221: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134483
+ case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
133848134484
{
133849134485
Token all;
133850134486
all.z = yymsp[-3].minor.yy0.z;
133851134487
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
133852
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
134488
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
133853134489
}
133854134490
break;
133855
- case 222: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134491
+ case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
133856134492
{
133857
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
134493
+ 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);
133858134494
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
133859134495
}
133860134496
break;
133861
- case 223: /* trigger_time ::= BEFORE */
133862
-{ yymsp[0].minor.yy392 = TK_BEFORE; }
133863
- break;
133864
- case 224: /* trigger_time ::= AFTER */
133865
-{ yymsp[0].minor.yy392 = TK_AFTER; }
133866
- break;
133867
- case 225: /* trigger_time ::= INSTEAD OF */
133868
-{ yymsp[-1].minor.yy392 = TK_INSTEAD;}
133869
- break;
133870
- case 226: /* trigger_time ::= */
133871
-{ yymsp[1].minor.yy392 = TK_BEFORE; }
133872
- break;
133873
- case 227: /* trigger_event ::= DELETE|INSERT */
133874
- case 228: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==228);
133875
-{yymsp[0].minor.yy410.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy410.b = 0;}
133876
- break;
133877
- case 229: /* trigger_event ::= UPDATE OF idlist */
133878
-{yymsp[-2].minor.yy410.a = TK_UPDATE; yymsp[-2].minor.yy410.b = yymsp[0].minor.yy180;}
133879
- break;
133880
- case 230: /* when_clause ::= */
133881
- case 249: /* key_opt ::= */ yytestcase(yyruleno==249);
133882
-{ yymsp[1].minor.yy122 = 0; }
133883
- break;
133884
- case 231: /* when_clause ::= WHEN expr */
133885
- case 250: /* key_opt ::= KEY expr */ yytestcase(yyruleno==250);
133886
-{ yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr; }
133887
- break;
133888
- case 232: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
133889
-{
133890
- assert( yymsp[-2].minor.yy327!=0 );
133891
- yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
133892
- yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
133893
-}
133894
- break;
133895
- case 233: /* trigger_cmd_list ::= trigger_cmd SEMI */
133896
-{
133897
- assert( yymsp[-1].minor.yy327!=0 );
133898
- yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
133899
-}
133900
- break;
133901
- case 234: /* trnm ::= nm DOT nm */
134497
+ case 225: /* trigger_time ::= BEFORE */
134498
+{ yymsp[0].minor.yy194 = TK_BEFORE; }
134499
+ break;
134500
+ case 226: /* trigger_time ::= AFTER */
134501
+{ yymsp[0].minor.yy194 = TK_AFTER; }
134502
+ break;
134503
+ case 227: /* trigger_time ::= INSTEAD OF */
134504
+{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
134505
+ break;
134506
+ case 228: /* trigger_time ::= */
134507
+{ yymsp[1].minor.yy194 = TK_BEFORE; }
134508
+ break;
134509
+ case 229: /* trigger_event ::= DELETE|INSERT */
134510
+ case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
134511
+{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134512
+ break;
134513
+ case 231: /* trigger_event ::= UPDATE OF idlist */
134514
+{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134515
+ break;
134516
+ case 232: /* when_clause ::= */
134517
+ case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
134518
+{ yymsp[1].minor.yy72 = 0; }
134519
+ break;
134520
+ case 233: /* when_clause ::= WHEN expr */
134521
+ case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
134522
+{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134523
+ break;
134524
+ case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134525
+{
134526
+ assert( yymsp[-2].minor.yy145!=0 );
134527
+ yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134528
+ yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134529
+}
134530
+ break;
134531
+ case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
134532
+{
134533
+ assert( yymsp[-1].minor.yy145!=0 );
134534
+ yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134535
+}
134536
+ break;
134537
+ case 236: /* trnm ::= nm DOT nm */
133902134538
{
133903134539
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
133904134540
sqlite3ErrorMsg(pParse,
133905134541
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
133906134542
"statements within triggers");
133907134543
}
133908134544
break;
133909
- case 235: /* tridxby ::= INDEXED BY nm */
134545
+ case 237: /* tridxby ::= INDEXED BY nm */
133910134546
{
133911134547
sqlite3ErrorMsg(pParse,
133912134548
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
133913134549
"within triggers");
133914134550
}
133915134551
break;
133916
- case 236: /* tridxby ::= NOT INDEXED */
134552
+ case 238: /* tridxby ::= NOT INDEXED */
133917134553
{
133918134554
sqlite3ErrorMsg(pParse,
133919134555
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
133920134556
"within triggers");
133921134557
}
133922134558
break;
133923
- case 237: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
133924
-{yymsp[-6].minor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy392);}
133925
- break;
133926
- case 238: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
133927
-{yymsp[-4].minor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy159, yymsp[-4].minor.yy392);/*A-overwrites-R*/}
133928
- break;
133929
- case 239: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
133930
-{yymsp[-4].minor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
133931
- break;
133932
- case 240: /* trigger_cmd ::= select */
133933
-{yymsp[0].minor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); /*A-overwrites-X*/}
133934
- break;
133935
- case 241: /* expr ::= RAISE LP IGNORE RP */
133936
-{
133937
- spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133938
- yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
133939
- if( yymsp[-3].minor.yy342.pExpr ){
133940
- yymsp[-3].minor.yy342.pExpr->affinity = OE_Ignore;
133941
- }
133942
-}
133943
- break;
133944
- case 242: /* expr ::= RAISE LP raisetype COMMA nm RP */
133945
-{
133946
- spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133947
- yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
133948
- if( yymsp[-5].minor.yy342.pExpr ) {
133949
- yymsp[-5].minor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
133950
- }
133951
-}
133952
- break;
133953
- case 243: /* raisetype ::= ROLLBACK */
133954
-{yymsp[0].minor.yy392 = OE_Rollback;}
133955
- break;
133956
- case 245: /* raisetype ::= FAIL */
133957
-{yymsp[0].minor.yy392 = OE_Fail;}
133958
- break;
133959
- case 246: /* cmd ::= DROP TRIGGER ifexists fullname */
133960
-{
133961
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
133962
-}
133963
- break;
133964
- case 247: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
133965
-{
133966
- sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
133967
-}
133968
- break;
133969
- case 248: /* cmd ::= DETACH database_kw_opt expr */
133970
-{
133971
- sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
133972
-}
133973
- break;
133974
- case 251: /* cmd ::= REINDEX */
134559
+ case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134560
+{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134561
+ break;
134562
+ case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134563
+{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*/}
134564
+ break;
134565
+ case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134566
+{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134567
+ break;
134568
+ case 242: /* trigger_cmd ::= select */
134569
+{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134570
+ break;
134571
+ case 243: /* expr ::= RAISE LP IGNORE RP */
134572
+{
134573
+ spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134574
+ yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134575
+ if( yymsp[-3].minor.yy190.pExpr ){
134576
+ yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134577
+ }
134578
+}
134579
+ break;
134580
+ case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
134581
+{
134582
+ spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134583
+ yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134584
+ if( yymsp[-5].minor.yy190.pExpr ) {
134585
+ yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134586
+ }
134587
+}
134588
+ break;
134589
+ case 245: /* raisetype ::= ROLLBACK */
134590
+{yymsp[0].minor.yy194 = OE_Rollback;}
134591
+ break;
134592
+ case 247: /* raisetype ::= FAIL */
134593
+{yymsp[0].minor.yy194 = OE_Fail;}
134594
+ break;
134595
+ case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
134596
+{
134597
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134598
+}
134599
+ break;
134600
+ case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134601
+{
134602
+ sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134603
+}
134604
+ break;
134605
+ case 250: /* cmd ::= DETACH database_kw_opt expr */
134606
+{
134607
+ sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134608
+}
134609
+ break;
134610
+ case 253: /* cmd ::= REINDEX */
133975134611
{sqlite3Reindex(pParse, 0, 0);}
133976134612
break;
133977
- case 252: /* cmd ::= REINDEX nm dbnm */
134613
+ case 254: /* cmd ::= REINDEX nm dbnm */
133978134614
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133979134615
break;
133980
- case 253: /* cmd ::= ANALYZE */
134616
+ case 255: /* cmd ::= ANALYZE */
133981134617
{sqlite3Analyze(pParse, 0, 0);}
133982134618
break;
133983
- case 254: /* cmd ::= ANALYZE nm dbnm */
134619
+ case 256: /* cmd ::= ANALYZE nm dbnm */
133984134620
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133985134621
break;
133986
- case 255: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134622
+ case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
133987134623
{
133988
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
134624
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
133989134625
}
133990134626
break;
133991
- case 256: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134627
+ case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
133992134628
{
133993134629
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
133994134630
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
133995134631
}
133996134632
break;
133997
- case 257: /* add_column_fullname ::= fullname */
134633
+ case 259: /* add_column_fullname ::= fullname */
133998134634
{
133999134635
disableLookaside(pParse);
134000
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
134636
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134001134637
}
134002134638
break;
134003
- case 258: /* cmd ::= create_vtab */
134639
+ case 260: /* cmd ::= create_vtab */
134004134640
{sqlite3VtabFinishParse(pParse,0);}
134005134641
break;
134006
- case 259: /* cmd ::= create_vtab LP vtabarglist RP */
134642
+ case 261: /* cmd ::= create_vtab LP vtabarglist RP */
134007134643
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134008134644
break;
134009
- case 260: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134645
+ case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134010134646
{
134011
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
134647
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134012134648
}
134013134649
break;
134014
- case 261: /* vtabarg ::= */
134650
+ case 263: /* vtabarg ::= */
134015134651
{sqlite3VtabArgInit(pParse);}
134016134652
break;
134017
- case 262: /* vtabargtoken ::= ANY */
134018
- case 263: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==263);
134019
- case 264: /* lp ::= LP */ yytestcase(yyruleno==264);
134653
+ case 264: /* vtabargtoken ::= ANY */
134654
+ case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134655
+ case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
134020134656
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134021134657
break;
134022
- case 265: /* with ::= */
134023
-{yymsp[1].minor.yy331 = 0;}
134024
- break;
134025
- case 266: /* with ::= WITH wqlist */
134026
-{ yymsp[-1].minor.yy331 = yymsp[0].minor.yy331; }
134027
- break;
134028
- case 267: /* with ::= WITH RECURSIVE wqlist */
134029
-{ yymsp[-2].minor.yy331 = yymsp[0].minor.yy331; }
134030
- break;
134031
- case 268: /* wqlist ::= nm eidlist_opt AS LP select RP */
134032
-{
134033
- yymsp[-5].minor.yy331 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159); /*A-overwrites-X*/
134034
-}
134035
- break;
134036
- case 269: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134037
-{
134038
- yymsp[-7].minor.yy331 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy331, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159);
134658
+ case 267: /* with ::= */
134659
+{yymsp[1].minor.yy285 = 0;}
134660
+ break;
134661
+ case 268: /* with ::= WITH wqlist */
134662
+{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134663
+ break;
134664
+ case 269: /* with ::= WITH RECURSIVE wqlist */
134665
+{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134666
+ break;
134667
+ case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
134668
+{
134669
+ yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134670
+}
134671
+ break;
134672
+ case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134673
+{
134674
+ yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134039134675
}
134040134676
break;
134041134677
default:
134042
- /* (270) input ::= cmdlist */ yytestcase(yyruleno==270);
134043
- /* (271) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==271);
134044
- /* (272) cmdlist ::= ecmd */ yytestcase(yyruleno==272);
134045
- /* (273) ecmd ::= SEMI */ yytestcase(yyruleno==273);
134046
- /* (274) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==274);
134047
- /* (275) explain ::= */ yytestcase(yyruleno==275);
134048
- /* (276) trans_opt ::= */ yytestcase(yyruleno==276);
134049
- /* (277) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==277);
134050
- /* (278) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==278);
134051
- /* (279) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==279);
134052
- /* (280) savepoint_opt ::= */ yytestcase(yyruleno==280);
134053
- /* (281) cmd ::= create_table create_table_args */ yytestcase(yyruleno==281);
134054
- /* (282) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==282);
134055
- /* (283) columnlist ::= columnname carglist */ yytestcase(yyruleno==283);
134056
- /* (284) nm ::= ID|INDEXED */ yytestcase(yyruleno==284);
134057
- /* (285) nm ::= STRING */ yytestcase(yyruleno==285);
134058
- /* (286) nm ::= JOIN_KW */ yytestcase(yyruleno==286);
134059
- /* (287) typetoken ::= typename */ yytestcase(yyruleno==287);
134060
- /* (288) typename ::= ID|STRING */ yytestcase(yyruleno==288);
134061
- /* (289) signed ::= plus_num */ yytestcase(yyruleno==289);
134062
- /* (290) signed ::= minus_num */ yytestcase(yyruleno==290);
134063
- /* (291) carglist ::= carglist ccons */ yytestcase(yyruleno==291);
134064
- /* (292) carglist ::= */ yytestcase(yyruleno==292);
134065
- /* (293) ccons ::= NULL onconf */ yytestcase(yyruleno==293);
134066
- /* (294) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==294);
134067
- /* (295) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==295);
134068
- /* (296) conslist ::= tcons */ yytestcase(yyruleno==296);
134069
- /* (297) tconscomma ::= */ yytestcase(yyruleno==297);
134070
- /* (298) defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==298);
134071
- /* (299) resolvetype ::= raisetype */ yytestcase(yyruleno==299);
134072
- /* (300) selectnowith ::= oneselect */ yytestcase(yyruleno==300);
134073
- /* (301) oneselect ::= values */ yytestcase(yyruleno==301);
134074
- /* (302) sclp ::= selcollist COMMA */ yytestcase(yyruleno==302);
134075
- /* (303) as ::= ID|STRING */ yytestcase(yyruleno==303);
134076
- /* (304) expr ::= term */ yytestcase(yyruleno==304);
134077
- /* (305) exprlist ::= nexprlist */ yytestcase(yyruleno==305);
134078
- /* (306) nmnum ::= plus_num */ yytestcase(yyruleno==306);
134079
- /* (307) nmnum ::= nm */ yytestcase(yyruleno==307);
134080
- /* (308) nmnum ::= ON */ yytestcase(yyruleno==308);
134081
- /* (309) nmnum ::= DELETE */ yytestcase(yyruleno==309);
134082
- /* (310) nmnum ::= DEFAULT */ yytestcase(yyruleno==310);
134083
- /* (311) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==311);
134084
- /* (312) foreach_clause ::= */ yytestcase(yyruleno==312);
134085
- /* (313) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==313);
134086
- /* (314) trnm ::= nm */ yytestcase(yyruleno==314);
134087
- /* (315) tridxby ::= */ yytestcase(yyruleno==315);
134088
- /* (316) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==316);
134089
- /* (317) database_kw_opt ::= */ yytestcase(yyruleno==317);
134090
- /* (318) kwcolumn_opt ::= */ yytestcase(yyruleno==318);
134091
- /* (319) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==319);
134092
- /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
134093
- /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
134094
- /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
134095
- /* (323) anylist ::= */ yytestcase(yyruleno==323);
134096
- /* (324) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==324);
134097
- /* (325) anylist ::= anylist ANY */ yytestcase(yyruleno==325);
134678
+ /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134679
+ /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134680
+ /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134681
+ /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134682
+ /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134683
+ /* (277) explain ::= */ yytestcase(yyruleno==277);
134684
+ /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134685
+ /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134686
+ /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134687
+ /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134688
+ /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134689
+ /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134690
+ /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134691
+ /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134692
+ /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134693
+ /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134694
+ /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134695
+ /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134696
+ /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134697
+ /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134698
+ /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134699
+ /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134700
+ /* (294) carglist ::= */ yytestcase(yyruleno==294);
134701
+ /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134702
+ /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134703
+ /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134704
+ /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134705
+ /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134706
+ /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134707
+ /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134708
+ /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134709
+ /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134710
+ /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134711
+ /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134712
+ /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134713
+ /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134714
+ /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134715
+ /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134716
+ /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134717
+ /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134718
+ /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134719
+ /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134720
+ /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134721
+ /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134722
+ /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134723
+ /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134724
+ /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134725
+ /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134726
+ /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134727
+ /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134728
+ /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134729
+ /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134730
+ /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134731
+ /* (325) anylist ::= */ yytestcase(yyruleno==325);
134732
+ /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134733
+ /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
134098134734
break;
134099134735
/********** End reduce actions ************************************************/
134100134736
};
134101134737
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134102134738
yygoto = yyRuleInfo[yyruleno].lhs;
134103134739
yysize = yyRuleInfo[yyruleno].nrhs;
134104134740
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
134105134741
if( yyact <= YY_MAX_SHIFTREDUCE ){
134106
- if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134107
- yypParser->yyidx -= yysize - 1;
134742
+ if( yyact>YY_MAX_SHIFT ){
134743
+ yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134744
+ }
134108134745
yymsp -= yysize-1;
134746
+ yypParser->yytos = yymsp;
134109134747
yymsp->stateno = (YYACTIONTYPE)yyact;
134110134748
yymsp->major = (YYCODETYPE)yygoto;
134111134749
yyTraceShift(yypParser, yyact);
134112134750
}else{
134113134751
assert( yyact == YY_ACCEPT_ACTION );
134114
- yypParser->yyidx -= yysize;
134752
+ yypParser->yytos -= yysize;
134115134753
yy_accept(yypParser);
134116134754
}
134117134755
}
134118134756
134119134757
/*
@@ -134127,11 +134765,11 @@
134127134765
#ifndef NDEBUG
134128134766
if( yyTraceFILE ){
134129134767
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
134130134768
}
134131134769
#endif
134132
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
134770
+ while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
134133134771
/* Here code is inserted which will be executed whenever the
134134134772
** parser fails */
134135134773
/************ Begin %parse_failure code ***************************************/
134136134774
/************ End %parse_failure code *****************************************/
134137134775
sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134167,11 +134805,14 @@
134167134805
#ifndef NDEBUG
134168134806
if( yyTraceFILE ){
134169134807
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
134170134808
}
134171134809
#endif
134172
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
134810
+#ifndef YYNOERRORRECOVERY
134811
+ yypParser->yyerrcnt = -1;
134812
+#endif
134813
+ assert( yypParser->yytos==yypParser->yystack );
134173134814
/* Here code is inserted which will be executed whenever the
134174134815
** parser accepts */
134175134816
/*********** Begin %parse_accept code *****************************************/
134176134817
/*********** End %parse_accept code *******************************************/
134177134818
sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134210,32 +134851,12 @@
134210134851
#ifdef YYERRORSYMBOL
134211134852
int yyerrorhit = 0; /* True if yymajor has invoked an error */
134212134853
#endif
134213134854
yyParser *yypParser; /* The parser */
134214134855
134215
- /* (re)initialize the parser, if necessary */
134216134856
yypParser = (yyParser*)yyp;
134217
- if( yypParser->yyidx<0 ){
134218
-#if YYSTACKDEPTH<=0
134219
- if( yypParser->yystksz <=0 ){
134220
- yyStackOverflow(yypParser);
134221
- return;
134222
- }
134223
-#endif
134224
- yypParser->yyidx = 0;
134225
-#ifndef YYNOERRORRECOVERY
134226
- yypParser->yyerrcnt = -1;
134227
-#endif
134228
- yypParser->yystack[0].stateno = 0;
134229
- yypParser->yystack[0].major = 0;
134230
-#ifndef NDEBUG
134231
- if( yyTraceFILE ){
134232
- fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
134233
- yyTracePrompt);
134234
- }
134235
-#endif
134236
- }
134857
+ assert( yypParser->yytos!=0 );
134237134858
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
134238134859
yyendofinput = (yymajor==0);
134239134860
#endif
134240134861
sqlite3ParserARG_STORE;
134241134862
@@ -134246,11 +134867,10 @@
134246134867
#endif
134247134868
134248134869
do{
134249134870
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
134250134871
if( yyact <= YY_MAX_SHIFTREDUCE ){
134251
- if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134252134872
yy_shift(yypParser,yyact,yymajor,yyminor);
134253134873
#ifndef YYNOERRORRECOVERY
134254134874
yypParser->yyerrcnt--;
134255134875
#endif
134256134876
yymajor = YYNOCODE;
@@ -134288,11 +134908,11 @@
134288134908
**
134289134909
*/
134290134910
if( yypParser->yyerrcnt<0 ){
134291134911
yy_syntax_error(yypParser,yymajor,yyminor);
134292134912
}
134293
- yymx = yypParser->yystack[yypParser->yyidx].major;
134913
+ yymx = yypParser->yytos->major;
134294134914
if( yymx==YYERRORSYMBOL || yyerrorhit ){
134295134915
#ifndef NDEBUG
134296134916
if( yyTraceFILE ){
134297134917
fprintf(yyTraceFILE,"%sDiscard input token %s\n",
134298134918
yyTracePrompt,yyTokenName[yymajor]);
@@ -134299,22 +134919,24 @@
134299134919
}
134300134920
#endif
134301134921
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
134302134922
yymajor = YYNOCODE;
134303134923
}else{
134304
- while(
134305
- yypParser->yyidx >= 0 &&
134306
- yymx != YYERRORSYMBOL &&
134307
- (yyact = yy_find_reduce_action(
134308
- yypParser->yystack[yypParser->yyidx].stateno,
134924
+ while( yypParser->yytos >= &yypParser->yystack
134925
+ && yymx != YYERRORSYMBOL
134926
+ && (yyact = yy_find_reduce_action(
134927
+ yypParser->yytos->stateno,
134309134928
YYERRORSYMBOL)) >= YY_MIN_REDUCE
134310134929
){
134311134930
yy_pop_parser_stack(yypParser);
134312134931
}
134313
- if( yypParser->yyidx < 0 || yymajor==0 ){
134932
+ if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
134314134933
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134315134934
yy_parse_failed(yypParser);
134935
+#ifndef YYNOERRORRECOVERY
134936
+ yypParser->yyerrcnt = -1;
134937
+#endif
134316134938
yymajor = YYNOCODE;
134317134939
}else if( yymx!=YYERRORSYMBOL ){
134318134940
yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
134319134941
}
134320134942
}
@@ -134347,22 +134969,27 @@
134347134969
}
134348134970
yypParser->yyerrcnt = 3;
134349134971
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134350134972
if( yyendofinput ){
134351134973
yy_parse_failed(yypParser);
134974
+#ifndef YYNOERRORRECOVERY
134975
+ yypParser->yyerrcnt = -1;
134976
+#endif
134352134977
}
134353134978
yymajor = YYNOCODE;
134354134979
#endif
134355134980
}
134356
- }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
134981
+ }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
134357134982
#ifndef NDEBUG
134358134983
if( yyTraceFILE ){
134359
- int i;
134984
+ yyStackEntry *i;
134985
+ char cDiv = '[';
134360134986
fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
134361
- for(i=1; i<=yypParser->yyidx; i++)
134362
- fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
134363
- yyTokenName[yypParser->yystack[i].major]);
134987
+ for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
134988
+ fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
134989
+ cDiv = ' ';
134990
+ }
134364134991
fprintf(yyTraceFILE,"]\n");
134365134992
}
134366134993
#endif
134367134994
return;
134368134995
}
@@ -136680,10 +137307,13 @@
136680137307
}
136681137308
if( !sqlite3SafetyCheckSickOrOk(db) ){
136682137309
return SQLITE_MISUSE_BKPT;
136683137310
}
136684137311
sqlite3_mutex_enter(db->mutex);
137312
+ if( db->mTrace & SQLITE_TRACE_CLOSE ){
137313
+ db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);
137314
+ }
136685137315
136686137316
/* Force xDisconnect calls on all virtual tables */
136687137317
disconnectAllVtab(db);
136688137318
136689137319
/* If a transaction is open, the disconnectAllVtab() call above
@@ -137448,11 +138078,12 @@
137448138078
**
137449138079
** A NULL trace function means that no tracing is executes. A non-NULL
137450138080
** trace is a pointer to a function that is invoked at the start of each
137451138081
** SQL statement.
137452138082
*/
137453
-SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
138083
+#ifndef SQLITE_OMIT_DEPRECATED
138084
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){
137454138085
void *pOld;
137455138086
137456138087
#ifdef SQLITE_ENABLE_API_ARMOR
137457138088
if( !sqlite3SafetyCheckOk(db) ){
137458138089
(void)SQLITE_MISUSE_BKPT;
@@ -137459,15 +138090,39 @@
137459138090
return 0;
137460138091
}
137461138092
#endif
137462138093
sqlite3_mutex_enter(db->mutex);
137463138094
pOld = db->pTraceArg;
137464
- db->xTrace = xTrace;
138095
+ db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;
138096
+ db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;
137465138097
db->pTraceArg = pArg;
137466138098
sqlite3_mutex_leave(db->mutex);
137467138099
return pOld;
137468138100
}
138101
+#endif /* SQLITE_OMIT_DEPRECATED */
138102
+
138103
+/* Register a trace callback using the version-2 interface.
138104
+*/
138105
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
138106
+ sqlite3 *db, /* Trace this connection */
138107
+ unsigned mTrace, /* Mask of events to be traced */
138108
+ int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */
138109
+ void *pArg /* Context */
138110
+){
138111
+#ifdef SQLITE_ENABLE_API_ARMOR
138112
+ if( !sqlite3SafetyCheckOk(db) ){
138113
+ return SQLITE_MISUSE_BKPT;
138114
+ }
138115
+#endif
138116
+ sqlite3_mutex_enter(db->mutex);
138117
+ db->mTrace = mTrace;
138118
+ db->xTrace = xTrace;
138119
+ db->pTraceArg = pArg;
138120
+ sqlite3_mutex_leave(db->mutex);
138121
+ return SQLITE_OK;
138122
+}
138123
+
137469138124
/*
137470138125
** Register a profile function. The pArg from the previously registered
137471138126
** profile function is returned.
137472138127
**
137473138128
** A NULL profile function means that no profiling is executes. A non-NULL
@@ -161881,10 +162536,57 @@
161881162536
}
161882162537
return f;
161883162538
}
161884162539
#endif /* !defined(SQLITE_RTREE_INT_ONLY) */
161885162540
162541
+/*
162542
+** A constraint has failed while inserting a row into an rtree table.
162543
+** Assuming no OOM error occurs, this function sets the error message
162544
+** (at pRtree->base.zErrMsg) to an appropriate value and returns
162545
+** SQLITE_CONSTRAINT.
162546
+**
162547
+** Parameter iCol is the index of the leftmost column involved in the
162548
+** constraint failure. If it is 0, then the constraint that failed is
162549
+** the unique constraint on the id column. Otherwise, it is the rtree
162550
+** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.
162551
+**
162552
+** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.
162553
+*/
162554
+static int rtreeConstraintError(Rtree *pRtree, int iCol){
162555
+ sqlite3_stmt *pStmt = 0;
162556
+ char *zSql;
162557
+ int rc;
162558
+
162559
+ assert( iCol==0 || iCol%2 );
162560
+ zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName);
162561
+ if( zSql ){
162562
+ rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);
162563
+ }else{
162564
+ rc = SQLITE_NOMEM;
162565
+ }
162566
+ sqlite3_free(zSql);
162567
+
162568
+ if( rc==SQLITE_OK ){
162569
+ if( iCol==0 ){
162570
+ const char *zCol = sqlite3_column_name(pStmt, 0);
162571
+ pRtree->base.zErrMsg = sqlite3_mprintf(
162572
+ "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol
162573
+ );
162574
+ }else{
162575
+ const char *zCol1 = sqlite3_column_name(pStmt, iCol);
162576
+ const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);
162577
+ pRtree->base.zErrMsg = sqlite3_mprintf(
162578
+ "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2
162579
+ );
162580
+ }
162581
+ }
162582
+
162583
+ sqlite3_finalize(pStmt);
162584
+ return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);
162585
+}
162586
+
162587
+
161886162588
161887162589
/*
161888162590
** The xUpdate method for rtree module virtual tables.
161889162591
*/
161890162592
static int rtreeUpdate(
@@ -161931,11 +162633,11 @@
161931162633
if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
161932162634
for(ii=0; ii<nData-4; ii+=2){
161933162635
cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
161934162636
cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
161935162637
if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
161936
- rc = SQLITE_CONSTRAINT;
162638
+ rc = rtreeConstraintError(pRtree, ii+1);
161937162639
goto constraint;
161938162640
}
161939162641
}
161940162642
}else
161941162643
#endif
@@ -161942,11 +162644,11 @@
161942162644
{
161943162645
for(ii=0; ii<nData-4; ii+=2){
161944162646
cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
161945162647
cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
161946162648
if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
161947
- rc = SQLITE_CONSTRAINT;
162649
+ rc = rtreeConstraintError(pRtree, ii+1);
161948162650
goto constraint;
161949162651
}
161950162652
}
161951162653
}
161952162654
@@ -161963,11 +162665,11 @@
161963162665
rc = sqlite3_reset(pRtree->pReadRowid);
161964162666
if( SQLITE_ROW==steprc ){
161965162667
if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
161966162668
rc = rtreeDeleteRowid(pRtree, cell.iRowid);
161967162669
}else{
161968
- rc = SQLITE_CONSTRAINT;
162670
+ rc = rtreeConstraintError(pRtree, 0);
161969162671
goto constraint;
161970162672
}
161971162673
}
161972162674
}
161973162675
bHaveRowid = 1;
@@ -162046,10 +162748,15 @@
162046162748
char *zSql;
162047162749
sqlite3_stmt *p;
162048162750
int rc;
162049162751
i64 nRow = 0;
162050162752
162753
+ if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1",
162754
+ 0,0,0,0,0,0)==SQLITE_ERROR ){
162755
+ pRtree->nRowEst = RTREE_DEFAULT_ROWEST;
162756
+ return SQLITE_OK;
162757
+ }
162051162758
zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
162052162759
if( zSql==0 ){
162053162760
rc = SQLITE_NOMEM;
162054162761
}else{
162055162762
rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
@@ -163977,10 +164684,48 @@
163977164684
** table exists but is not correctly populated, the value of the *pnOne
163978164685
** output variable during stage 1 is undefined.
163979164686
*/
163980164687
SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
163981164688
164689
+/*
164690
+** Obtain an indication as to the current stage of an RBU update or vacuum.
164691
+** This function always returns one of the SQLITE_RBU_STATE_XXX constants
164692
+** defined in this file. Return values should be interpreted as follows:
164693
+**
164694
+** SQLITE_RBU_STATE_OAL:
164695
+** RBU is currently building a *-oal file. The next call to sqlite3rbu_step()
164696
+** may either add further data to the *-oal file, or compute data that will
164697
+** be added by a subsequent call.
164698
+**
164699
+** SQLITE_RBU_STATE_MOVE:
164700
+** RBU has finished building the *-oal file. The next call to sqlite3rbu_step()
164701
+** will move the *-oal file to the equivalent *-wal path. If the current
164702
+** operation is an RBU update, then the updated version of the database
164703
+** file will become visible to ordinary SQLite clients following the next
164704
+** call to sqlite3rbu_step().
164705
+**
164706
+** SQLITE_RBU_STATE_CHECKPOINT:
164707
+** RBU is currently performing an incremental checkpoint. The next call to
164708
+** sqlite3rbu_step() will copy a page of data from the *-wal file into
164709
+** the target database file.
164710
+**
164711
+** SQLITE_RBU_STATE_DONE:
164712
+** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()
164713
+** will immediately return SQLITE_DONE.
164714
+**
164715
+** SQLITE_RBU_STATE_ERROR:
164716
+** An error has occurred. Any subsequent calls to sqlite3rbu_step() will
164717
+** immediately return the SQLite error code associated with the error.
164718
+*/
164719
+#define SQLITE_RBU_STATE_OAL 1
164720
+#define SQLITE_RBU_STATE_MOVE 2
164721
+#define SQLITE_RBU_STATE_CHECKPOINT 3
164722
+#define SQLITE_RBU_STATE_DONE 4
164723
+#define SQLITE_RBU_STATE_ERROR 5
164724
+
164725
+SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *pRbu);
164726
+
163982164727
/*
163983164728
** Create an RBU VFS named zName that accesses the underlying file-system
163984164729
** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
163985164730
** then the new RBU VFS uses the default system VFS to access the file-system.
163986164731
** The new object is registered as a non-default VFS with SQLite before
@@ -164872,16 +165617,18 @@
164872165617
*/
164873165618
static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
164874165619
int rc;
164875165620
memset(pIter, 0, sizeof(RbuObjIter));
164876165621
164877
- rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165622
+ rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165623
+ sqlite3_mprintf(
164878165624
"SELECT rbu_target_name(name, type='view') AS target, name "
164879165625
"FROM sqlite_master "
164880165626
"WHERE type IN ('table', 'view') AND target IS NOT NULL "
165627
+ " %s "
164881165628
"ORDER BY name"
164882
- );
165629
+ , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : ""));
164883165630
164884165631
if( rc==SQLITE_OK ){
164885165632
rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
164886165633
"SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' "
164887165634
" FROM main.sqlite_master "
@@ -166456,13 +167203,13 @@
166456167203
#if SQLITE_ENABLE_8_3_NAMES<2
166457167204
if( sqlite3_uri_boolean(zBase, "8_3_names", 0) )
166458167205
#endif
166459167206
{
166460167207
int i, sz;
166461
- sz = sqlite3Strlen30(z);
167208
+ sz = (int)strlen(z)&0xffffff;
166462167209
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
166463
- if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
167210
+ if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);
166464167211
}
166465167212
#endif
166466167213
}
166467167214
166468167215
/*
@@ -167504,34 +168251,11 @@
167504168251
}
167505168252
167506168253
if( p->rc==SQLITE_OK ){
167507168254
if( p->eStage==RBU_STAGE_OAL ){
167508168255
sqlite3 *db = p->dbMain;
167509
-
167510
- if( pState->eStage==0 && rbuIsVacuum(p) ){
167511
- rbuCopyPragma(p, "page_size");
167512
- rbuCopyPragma(p, "auto_vacuum");
167513
- }
167514
-
167515
- /* Open transactions both databases. The *-oal file is opened or
167516
- ** created at this point. */
167517
- if( p->rc==SQLITE_OK ){
167518
- p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
167519
- }
167520
- if( p->rc==SQLITE_OK ){
167521
- p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
167522
- }
167523
-
167524
- /* Check if the main database is a zipvfs db. If it is, set the upper
167525
- ** level pager to use "journal_mode=off". This prevents it from
167526
- ** generating a large journal using a temp file. */
167527
- if( p->rc==SQLITE_OK ){
167528
- int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
167529
- if( frc==SQLITE_OK ){
167530
- p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
167531
- }
167532
- }
168256
+ p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
167533168257
167534168258
/* Point the object iterator at the first object */
167535168259
if( p->rc==SQLITE_OK ){
167536168260
p->rc = rbuObjIterFirst(p, &p->objiter);
167537168261
}
@@ -167538,16 +168262,38 @@
167538168262
167539168263
/* If the RBU database contains no data_xxx tables, declare the RBU
167540168264
** update finished. */
167541168265
if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
167542168266
p->rc = SQLITE_DONE;
168267
+ p->eStage = RBU_STAGE_DONE;
168268
+ }else{
168269
+ if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){
168270
+ rbuCopyPragma(p, "page_size");
168271
+ rbuCopyPragma(p, "auto_vacuum");
168272
+ }
168273
+
168274
+ /* Open transactions both databases. The *-oal file is opened or
168275
+ ** created at this point. */
168276
+ if( p->rc==SQLITE_OK ){
168277
+ p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
168278
+ }
168279
+
168280
+ /* Check if the main database is a zipvfs db. If it is, set the upper
168281
+ ** level pager to use "journal_mode=off". This prevents it from
168282
+ ** generating a large journal using a temp file. */
168283
+ if( p->rc==SQLITE_OK ){
168284
+ int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
168285
+ if( frc==SQLITE_OK ){
168286
+ p->rc = sqlite3_exec(
168287
+ db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
168288
+ }
168289
+ }
168290
+
168291
+ if( p->rc==SQLITE_OK ){
168292
+ rbuSetupOal(p, pState);
168293
+ }
167543168294
}
167544
-
167545
- if( p->rc==SQLITE_OK ){
167546
- rbuSetupOal(p, pState);
167547
- }
167548
-
167549168295
}else if( p->eStage==RBU_STAGE_MOVE ){
167550168296
/* no-op */
167551168297
}else if( p->eStage==RBU_STAGE_CKPT ){
167552168298
rbuSetupCheckpoint(p, pState);
167553168299
}else if( p->eStage==RBU_STAGE_DONE ){
@@ -167709,14 +168455,44 @@
167709168455
167710168456
default:
167711168457
assert( 0 );
167712168458
}
167713168459
}
168460
+
168461
+/*
168462
+** Return the current state of the RBU vacuum or update operation.
168463
+*/
168464
+SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *p){
168465
+ int aRes[] = {
168466
+ 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,
168467
+ 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE
168468
+ };
168469
+
168470
+ assert( RBU_STAGE_OAL==1 );
168471
+ assert( RBU_STAGE_MOVE==2 );
168472
+ assert( RBU_STAGE_CKPT==4 );
168473
+ assert( RBU_STAGE_DONE==5 );
168474
+ assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );
168475
+ assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );
168476
+ assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );
168477
+ assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );
168478
+
168479
+ if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){
168480
+ return SQLITE_RBU_STATE_ERROR;
168481
+ }else{
168482
+ assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );
168483
+ assert( p->eStage==RBU_STAGE_OAL
168484
+ || p->eStage==RBU_STAGE_MOVE
168485
+ || p->eStage==RBU_STAGE_CKPT
168486
+ || p->eStage==RBU_STAGE_DONE
168487
+ );
168488
+ return aRes[p->eStage];
168489
+ }
168490
+}
167714168491
167715168492
SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){
167716168493
int rc = p->rc;
167717
-
167718168494
if( rc==SQLITE_DONE ) return SQLITE_OK;
167719168495
167720168496
assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
167721168497
if( p->eStage==RBU_STAGE_OAL ){
167722168498
assert( rc!=SQLITE_DONE );
@@ -168694,14 +169470,14 @@
168694169470
**
168695169471
** '/1c2/000/' // Left-most child of 451st child of root
168696169472
*/
168697169473
#define VTAB_SCHEMA \
168698169474
"CREATE TABLE xx( " \
168699
- " name STRING, /* Name of table or index */" \
168700
- " path INTEGER, /* Path to page from root */" \
169475
+ " name TEXT, /* Name of table or index */" \
169476
+ " path TEXT, /* Path to page from root */" \
168701169477
" pageno INTEGER, /* Page number */" \
168702
- " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \
169478
+ " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
168703169479
" ncell INTEGER, /* Cells on page (0 for overflow) */" \
168704169480
" payload INTEGER, /* Bytes of payload on this page */" \
168705169481
" unused INTEGER, /* Bytes of unused space on this page */" \
168706169482
" mx_payload INTEGER, /* Largest payload size of all cells */" \
168707169483
" pgoffset INTEGER, /* Offset of page in file */" \
@@ -175195,10 +175971,29 @@
175195175971
#endif /* SQLITE_DEBUG */
175196175972
175197175973
/****************************************************************************
175198175974
** Scalar SQL function implementations
175199175975
****************************************************************************/
175976
+
175977
+/*
175978
+** Implementation of the json_QUOTE(VALUE) function. Return a JSON value
175979
+** corresponding to the SQL value input. Mostly this means putting
175980
+** double-quotes around strings and returning the unquoted string "null"
175981
+** when given a NULL input.
175982
+*/
175983
+static void jsonQuoteFunc(
175984
+ sqlite3_context *ctx,
175985
+ int argc,
175986
+ sqlite3_value **argv
175987
+){
175988
+ JsonString jx;
175989
+
175990
+ jsonInit(&jx, ctx);
175991
+ jsonAppendValue(&jx, argv[0]);
175992
+ jsonResult(&jx);
175993
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
175994
+}
175200175995
175201175996
/*
175202175997
** Implementation of the json_array(VALUE,...) function. Return a JSON
175203175998
** array that contains all values given in arguments. Or if any argument
175204175999
** is a BLOB, throw an error.
@@ -176109,10 +176904,11 @@
176109176904
{ "json_array_length", 1, 0, jsonArrayLengthFunc },
176110176905
{ "json_array_length", 2, 0, jsonArrayLengthFunc },
176111176906
{ "json_extract", -1, 0, jsonExtractFunc },
176112176907
{ "json_insert", -1, 0, jsonSetFunc },
176113176908
{ "json_object", -1, 0, jsonObjectFunc },
176909
+ { "json_quote", 1, 0, jsonQuoteFunc },
176114176910
{ "json_remove", -1, 0, jsonRemoveFunc },
176115176911
{ "json_replace", -1, 0, jsonReplaceFunc },
176116176912
{ "json_set", -1, 1, jsonSetFunc },
176117176913
{ "json_type", 1, 0, jsonTypeFunc },
176118176914
{ "json_type", 2, 0, jsonTypeFunc },
@@ -177458,11 +178254,10 @@
177458178254
static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
177459178255
static int sqlite3Fts5ExprPopulatePoslists(
177460178256
Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
177461178257
);
177462178258
static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
177463
-static void sqlite3Fts5ExprClearEof(Fts5Expr*);
177464178259
177465178260
static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
177466178261
177467178262
static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
177468178263
@@ -177874,21 +178669,22 @@
177874178669
typedef struct fts5yyStackEntry fts5yyStackEntry;
177875178670
177876178671
/* The state of the parser is completely contained in an instance of
177877178672
** the following structure */
177878178673
struct fts5yyParser {
177879
- int fts5yyidx; /* Index of top element in stack */
178674
+ fts5yyStackEntry *fts5yytos; /* Pointer to top element of the stack */
177880178675
#ifdef fts5YYTRACKMAXSTACKDEPTH
177881
- int fts5yyidxMax; /* Maximum value of fts5yyidx */
178676
+ int fts5yyhwm; /* High-water mark of the stack */
177882178677
#endif
177883178678
#ifndef fts5YYNOERRORRECOVERY
177884178679
int fts5yyerrcnt; /* Shifts left before out of the error */
177885178680
#endif
177886178681
sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
177887178682
#if fts5YYSTACKDEPTH<=0
177888178683
int fts5yystksz; /* Current side of the stack */
177889178684
fts5yyStackEntry *fts5yystack; /* The parser's stack */
178685
+ fts5yyStackEntry fts5yystk0; /* First stack entry */
177890178686
#else
177891178687
fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
177892178688
#endif
177893178689
};
177894178690
typedef struct fts5yyParser fts5yyParser;
@@ -177971,28 +178767,38 @@
177971178767
#endif /* NDEBUG */
177972178768
177973178769
177974178770
#if fts5YYSTACKDEPTH<=0
177975178771
/*
177976
-** Try to increase the size of the parser stack.
178772
+** Try to increase the size of the parser stack. Return the number
178773
+** of errors. Return 0 on success.
177977178774
*/
177978
-static void fts5yyGrowStack(fts5yyParser *p){
178775
+static int fts5yyGrowStack(fts5yyParser *p){
177979178776
int newSize;
178777
+ int idx;
177980178778
fts5yyStackEntry *pNew;
177981178779
177982178780
newSize = p->fts5yystksz*2 + 100;
177983
- pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
178781
+ idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;
178782
+ if( p->fts5yystack==&p->fts5yystk0 ){
178783
+ pNew = malloc(newSize*sizeof(pNew[0]));
178784
+ if( pNew ) pNew[0] = p->fts5yystk0;
178785
+ }else{
178786
+ pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
178787
+ }
177984178788
if( pNew ){
177985178789
p->fts5yystack = pNew;
177986
- p->fts5yystksz = newSize;
178790
+ p->fts5yytos = &p->fts5yystack[idx];
177987178791
#ifndef NDEBUG
177988178792
if( fts5yyTraceFILE ){
177989
- fprintf(fts5yyTraceFILE,"%sStack grows to %d entries!\n",
177990
- fts5yyTracePrompt, p->fts5yystksz);
178793
+ fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
178794
+ fts5yyTracePrompt, p->fts5yystksz, newSize);
177991178795
}
177992178796
#endif
178797
+ p->fts5yystksz = newSize;
177993178798
}
178799
+ return pNew==0;
177994178800
}
177995178801
#endif
177996178802
177997178803
/* Datatype of the argument to the memory allocated passed as the
177998178804
** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by
@@ -178017,19 +178823,28 @@
178017178823
*/
178018178824
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
178019178825
fts5yyParser *pParser;
178020178826
pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
178021178827
if( pParser ){
178022
- pParser->fts5yyidx = -1;
178023178828
#ifdef fts5YYTRACKMAXSTACKDEPTH
178024
- pParser->fts5yyidxMax = 0;
178829
+ pParser->fts5yyhwm = 0;
178025178830
#endif
178026178831
#if fts5YYSTACKDEPTH<=0
178832
+ pParser->fts5yytos = NULL;
178027178833
pParser->fts5yystack = NULL;
178028178834
pParser->fts5yystksz = 0;
178029
- fts5yyGrowStack(pParser);
178835
+ if( fts5yyGrowStack(pParser) ){
178836
+ pParser->fts5yystack = &pParser->fts5yystk0;
178837
+ pParser->fts5yystksz = 1;
178838
+ }
178030178839
#endif
178840
+#ifndef fts5YYNOERRORRECOVERY
178841
+ pParser->fts5yyerrcnt = -1;
178842
+#endif
178843
+ pParser->fts5yytos = pParser->fts5yystack;
178844
+ pParser->fts5yystack[0].stateno = 0;
178845
+ pParser->fts5yystack[0].major = 0;
178031178846
}
178032178847
return pParser;
178033178848
}
178034178849
178035178850
/* The following function deletes the "minor type" or semantic value
@@ -178097,12 +178912,13 @@
178097178912
** If there is a destructor routine associated with the token which
178098178913
** is popped from the stack, then call it.
178099178914
*/
178100178915
static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
178101178916
fts5yyStackEntry *fts5yytos;
178102
- assert( pParser->fts5yyidx>=0 );
178103
- fts5yytos = &pParser->fts5yystack[pParser->fts5yyidx--];
178917
+ assert( pParser->fts5yytos!=0 );
178918
+ assert( pParser->fts5yytos > pParser->fts5yystack );
178919
+ fts5yytos = pParser->fts5yytos--;
178104178920
#ifndef NDEBUG
178105178921
if( fts5yyTraceFILE ){
178106178922
fprintf(fts5yyTraceFILE,"%sPopping %s\n",
178107178923
fts5yyTracePrompt,
178108178924
fts5yyTokenName[fts5yytos->major]);
@@ -178125,13 +178941,13 @@
178125178941
){
178126178942
fts5yyParser *pParser = (fts5yyParser*)p;
178127178943
#ifndef fts5YYPARSEFREENEVERNULL
178128178944
if( pParser==0 ) return;
178129178945
#endif
178130
- while( pParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(pParser);
178946
+ while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);
178131178947
#if fts5YYSTACKDEPTH<=0
178132
- free(pParser->fts5yystack);
178948
+ if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);
178133178949
#endif
178134178950
(*freeProc)((void*)pParser);
178135178951
}
178136178952
178137178953
/*
@@ -178138,11 +178954,11 @@
178138178954
** Return the peak depth of the stack for a parser.
178139178955
*/
178140178956
#ifdef fts5YYTRACKMAXSTACKDEPTH
178141178957
static int sqlite3Fts5ParserStackPeak(void *p){
178142178958
fts5yyParser *pParser = (fts5yyParser*)p;
178143
- return pParser->fts5yyidxMax;
178959
+ return pParser->fts5yyhwm;
178144178960
}
178145178961
#endif
178146178962
178147178963
/*
178148178964
** Find the appropriate action for a parser given the terminal
@@ -178151,11 +178967,11 @@
178151178967
static unsigned int fts5yy_find_shift_action(
178152178968
fts5yyParser *pParser, /* The parser */
178153178969
fts5YYCODETYPE iLookAhead /* The look-ahead token */
178154178970
){
178155178971
int i;
178156
- int stateno = pParser->fts5yystack[pParser->fts5yyidx].stateno;
178972
+ int stateno = pParser->fts5yytos->stateno;
178157178973
178158178974
if( stateno>=fts5YY_MIN_REDUCE ) return stateno;
178159178975
assert( stateno <= fts5YY_SHIFT_COUNT );
178160178976
do{
178161178977
i = fts5yy_shift_ofst[stateno];
@@ -178244,17 +179060,17 @@
178244179060
/*
178245179061
** The following routine is called if the stack overflows.
178246179062
*/
178247179063
static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
178248179064
sqlite3Fts5ParserARG_FETCH;
178249
- fts5yypParser->fts5yyidx--;
179065
+ fts5yypParser->fts5yytos--;
178250179066
#ifndef NDEBUG
178251179067
if( fts5yyTraceFILE ){
178252179068
fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
178253179069
}
178254179070
#endif
178255
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179071
+ while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
178256179072
/* Here code is inserted which will execute if the parser
178257179073
** stack every overflows */
178258179074
/******** Begin %stack_overflow code ******************************************/
178259179075
178260179076
sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
@@ -178268,15 +179084,15 @@
178268179084
#ifndef NDEBUG
178269179085
static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){
178270179086
if( fts5yyTraceFILE ){
178271179087
if( fts5yyNewState<fts5YYNSTATE ){
178272179088
fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n",
178273
- fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major],
179089
+ fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major],
178274179090
fts5yyNewState);
178275179091
}else{
178276179092
fprintf(fts5yyTraceFILE,"%sShift '%s'\n",
178277
- fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major]);
179093
+ fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]);
178278179094
}
178279179095
}
178280179096
}
178281179097
#else
178282179098
# define fts5yyTraceShift(X,Y)
@@ -178290,31 +179106,34 @@
178290179106
int fts5yyNewState, /* The new state to shift in */
178291179107
int fts5yyMajor, /* The major token to shift in */
178292179108
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
178293179109
){
178294179110
fts5yyStackEntry *fts5yytos;
178295
- fts5yypParser->fts5yyidx++;
179111
+ fts5yypParser->fts5yytos++;
178296179112
#ifdef fts5YYTRACKMAXSTACKDEPTH
178297
- if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178298
- fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
179113
+ if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179114
+ fts5yypParser->fts5yyhwm++;
179115
+ assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
178299179116
}
178300179117
#endif
178301179118
#if fts5YYSTACKDEPTH>0
178302
- if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH ){
179119
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
178303179120
fts5yyStackOverflow(fts5yypParser);
178304179121
return;
178305179122
}
178306179123
#else
178307
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
178308
- fts5yyGrowStack(fts5yypParser);
178309
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
179124
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){
179125
+ if( fts5yyGrowStack(fts5yypParser) ){
178310179126
fts5yyStackOverflow(fts5yypParser);
178311179127
return;
178312179128
}
178313179129
}
178314179130
#endif
178315
- fts5yytos = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
179131
+ if( fts5yyNewState > fts5YY_MAX_SHIFT ){
179132
+ fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179133
+ }
179134
+ fts5yytos = fts5yypParser->fts5yytos;
178316179135
fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
178317179136
fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
178318179137
fts5yytos->minor.fts5yy0 = fts5yyMinor;
178319179138
fts5yyTraceShift(fts5yypParser, fts5yyNewState);
178320179139
}
@@ -178365,11 +179184,11 @@
178365179184
int fts5yygoto; /* The next state */
178366179185
int fts5yyact; /* The next action */
178367179186
fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
178368179187
int fts5yysize; /* Amount to pop the stack */
178369179188
sqlite3Fts5ParserARG_FETCH;
178370
- fts5yymsp = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
179189
+ fts5yymsp = fts5yypParser->fts5yytos;
178371179190
#ifndef NDEBUG
178372179191
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
178373179192
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178374179193
fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
178375179194
fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
@@ -178379,26 +179198,27 @@
178379179198
/* Check that the stack is large enough to grow by a single entry
178380179199
** if the RHS of the rule is empty. This ensures that there is room
178381179200
** enough on the stack to push the LHS value */
178382179201
if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
178383179202
#ifdef fts5YYTRACKMAXSTACKDEPTH
178384
- if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178385
- fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
179203
+ if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179204
+ fts5yypParser->fts5yyhwm++;
179205
+ assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
178386179206
}
178387179207
#endif
178388179208
#if fts5YYSTACKDEPTH>0
178389
- if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH-1 ){
179209
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
178390179210
fts5yyStackOverflow(fts5yypParser);
178391179211
return;
178392179212
}
178393179213
#else
178394
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
178395
- fts5yyGrowStack(fts5yypParser);
178396
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
179214
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
179215
+ if( fts5yyGrowStack(fts5yypParser) ){
178397179216
fts5yyStackOverflow(fts5yypParser);
178398179217
return;
178399179218
}
179219
+ fts5yymsp = fts5yypParser->fts5yytos;
178400179220
}
178401179221
#endif
178402179222
}
178403179223
178404179224
switch( fts5yyruleno ){
@@ -178535,19 +179355,21 @@
178535179355
assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
178536179356
fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
178537179357
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178538179358
fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
178539179359
if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178540
- if( fts5yyact>fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178541
- fts5yypParser->fts5yyidx -= fts5yysize - 1;
179360
+ if( fts5yyact>fts5YY_MAX_SHIFT ){
179361
+ fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179362
+ }
178542179363
fts5yymsp -= fts5yysize-1;
179364
+ fts5yypParser->fts5yytos = fts5yymsp;
178543179365
fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
178544179366
fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
178545179367
fts5yyTraceShift(fts5yypParser, fts5yyact);
178546179368
}else{
178547179369
assert( fts5yyact == fts5YY_ACCEPT_ACTION );
178548
- fts5yypParser->fts5yyidx -= fts5yysize;
179370
+ fts5yypParser->fts5yytos -= fts5yysize;
178549179371
fts5yy_accept(fts5yypParser);
178550179372
}
178551179373
}
178552179374
178553179375
/*
@@ -178561,11 +179383,11 @@
178561179383
#ifndef NDEBUG
178562179384
if( fts5yyTraceFILE ){
178563179385
fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
178564179386
}
178565179387
#endif
178566
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179388
+ while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
178567179389
/* Here code is inserted which will be executed whenever the
178568179390
** parser fails */
178569179391
/************ Begin %parse_failure code ***************************************/
178570179392
/************ End %parse_failure code *****************************************/
178571179393
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178602,11 +179424,14 @@
178602179424
#ifndef NDEBUG
178603179425
if( fts5yyTraceFILE ){
178604179426
fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
178605179427
}
178606179428
#endif
178607
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179429
+#ifndef fts5YYNOERRORRECOVERY
179430
+ fts5yypParser->fts5yyerrcnt = -1;
179431
+#endif
179432
+ assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
178608179433
/* Here code is inserted which will be executed whenever the
178609179434
** parser accepts */
178610179435
/*********** Begin %parse_accept code *****************************************/
178611179436
/*********** End %parse_accept code *******************************************/
178612179437
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178645,32 +179470,12 @@
178645179470
#ifdef fts5YYERRORSYMBOL
178646179471
int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
178647179472
#endif
178648179473
fts5yyParser *fts5yypParser; /* The parser */
178649179474
178650
- /* (re)initialize the parser, if necessary */
178651179475
fts5yypParser = (fts5yyParser*)fts5yyp;
178652
- if( fts5yypParser->fts5yyidx<0 ){
178653
-#if fts5YYSTACKDEPTH<=0
178654
- if( fts5yypParser->fts5yystksz <=0 ){
178655
- fts5yyStackOverflow(fts5yypParser);
178656
- return;
178657
- }
178658
-#endif
178659
- fts5yypParser->fts5yyidx = 0;
178660
-#ifndef fts5YYNOERRORRECOVERY
178661
- fts5yypParser->fts5yyerrcnt = -1;
178662
-#endif
178663
- fts5yypParser->fts5yystack[0].stateno = 0;
178664
- fts5yypParser->fts5yystack[0].major = 0;
178665
-#ifndef NDEBUG
178666
- if( fts5yyTraceFILE ){
178667
- fprintf(fts5yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
178668
- fts5yyTracePrompt);
178669
- }
178670
-#endif
178671
- }
179476
+ assert( fts5yypParser->fts5yytos!=0 );
178672179477
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
178673179478
fts5yyendofinput = (fts5yymajor==0);
178674179479
#endif
178675179480
sqlite3Fts5ParserARG_STORE;
178676179481
@@ -178681,11 +179486,10 @@
178681179486
#endif
178682179487
178683179488
do{
178684179489
fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
178685179490
if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178686
- if( fts5yyact > fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178687179491
fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
178688179492
#ifndef fts5YYNOERRORRECOVERY
178689179493
fts5yypParser->fts5yyerrcnt--;
178690179494
#endif
178691179495
fts5yymajor = fts5YYNOCODE;
@@ -178723,11 +179527,11 @@
178723179527
**
178724179528
*/
178725179529
if( fts5yypParser->fts5yyerrcnt<0 ){
178726179530
fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);
178727179531
}
178728
- fts5yymx = fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major;
179532
+ fts5yymx = fts5yypParser->fts5yytos->major;
178729179533
if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){
178730179534
#ifndef NDEBUG
178731179535
if( fts5yyTraceFILE ){
178732179536
fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n",
178733179537
fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);
@@ -178734,22 +179538,24 @@
178734179538
}
178735179539
#endif
178736179540
fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);
178737179541
fts5yymajor = fts5YYNOCODE;
178738179542
}else{
178739
- while(
178740
- fts5yypParser->fts5yyidx >= 0 &&
178741
- fts5yymx != fts5YYERRORSYMBOL &&
178742
- (fts5yyact = fts5yy_find_reduce_action(
178743
- fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].stateno,
179543
+ while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack
179544
+ && fts5yymx != fts5YYERRORSYMBOL
179545
+ && (fts5yyact = fts5yy_find_reduce_action(
179546
+ fts5yypParser->fts5yytos->stateno,
178744179547
fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE
178745179548
){
178746179549
fts5yy_pop_parser_stack(fts5yypParser);
178747179550
}
178748
- if( fts5yypParser->fts5yyidx < 0 || fts5yymajor==0 ){
179551
+ if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){
178749179552
fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178750179553
fts5yy_parse_failed(fts5yypParser);
179554
+#ifndef fts5YYNOERRORRECOVERY
179555
+ fts5yypParser->fts5yyerrcnt = -1;
179556
+#endif
178751179557
fts5yymajor = fts5YYNOCODE;
178752179558
}else if( fts5yymx!=fts5YYERRORSYMBOL ){
178753179559
fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
178754179560
}
178755179561
}
@@ -178782,22 +179588,27 @@
178782179588
}
178783179589
fts5yypParser->fts5yyerrcnt = 3;
178784179590
fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178785179591
if( fts5yyendofinput ){
178786179592
fts5yy_parse_failed(fts5yypParser);
179593
+#ifndef fts5YYNOERRORRECOVERY
179594
+ fts5yypParser->fts5yyerrcnt = -1;
179595
+#endif
178787179596
}
178788179597
fts5yymajor = fts5YYNOCODE;
178789179598
#endif
178790179599
}
178791
- }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yyidx>=0 );
179600
+ }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
178792179601
#ifndef NDEBUG
178793179602
if( fts5yyTraceFILE ){
178794
- int i;
179603
+ fts5yyStackEntry *i;
179604
+ char cDiv = '[';
178795179605
fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
178796
- for(i=1; i<=fts5yypParser->fts5yyidx; i++)
178797
- fprintf(fts5yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
178798
- fts5yyTokenName[fts5yypParser->fts5yystack[i].major]);
179606
+ for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
179607
+ fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
179608
+ cDiv = ' ';
179609
+ }
178799179610
fprintf(fts5yyTraceFILE,"]\n");
178800179611
}
178801179612
#endif
178802179613
return;
178803179614
}
@@ -183337,21 +184148,10 @@
183337184148
183338184149
static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
183339184150
fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
183340184151
}
183341184152
183342
-static void fts5ExprClearEof(Fts5ExprNode *pNode){
183343
- int i;
183344
- for(i=0; i<pNode->nChild; i++){
183345
- fts5ExprClearEof(pNode->apChild[i]);
183346
- }
183347
- pNode->bEof = 0;
183348
-}
183349
-static void sqlite3Fts5ExprClearEof(Fts5Expr *pExpr){
183350
- fts5ExprClearEof(pExpr->pRoot);
183351
-}
183352
-
183353184153
/*
183354184154
** This function is only called for detail=columns tables.
183355184155
*/
183356184156
static int sqlite3Fts5ExprPhraseCollist(
183357184157
Fts5Expr *pExpr,
@@ -191565,11 +192365,10 @@
191565192365
assert( pCsr->iLastRowid==LARGEST_INT64 );
191566192366
assert( pCsr->iFirstRowid==SMALLEST_INT64 );
191567192367
pCsr->ePlan = FTS5_PLAN_SOURCE;
191568192368
pCsr->pExpr = pTab->pSortCsr->pExpr;
191569192369
rc = fts5CursorFirst(pTab, pCsr, bDesc);
191570
- sqlite3Fts5ExprClearEof(pCsr->pExpr);
191571192370
}else if( pMatch ){
191572192371
const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
191573192372
if( zExpr==0 ) zExpr = "";
191574192373
191575192374
rc = fts5CursorParseRank(pConfig, pCsr, pRank);
@@ -192994,11 +193793,11 @@
192994193793
int nArg, /* Number of args */
192995193794
sqlite3_value **apUnused /* Function arguments */
192996193795
){
192997193796
assert( nArg==0 );
192998193797
UNUSED_PARAM2(nArg, apUnused);
192999
- sqlite3_result_text(pCtx, "fts5: 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2", -1, SQLITE_TRANSIENT);
193798
+ sqlite3_result_text(pCtx, "fts5: 2016-07-22 21:35:38 f50a3fd6606c14b82c9b938bfca284d54b6c650f", -1, SQLITE_TRANSIENT);
193000193799
}
193001193800
193002193801
static int fts5Init(sqlite3 *db){
193003193802
static const sqlite3_module fts5Mod = {
193004193803
/* iVersion */ 2,
@@ -193359,11 +194158,15 @@
193359194158
){
193360194159
int rc;
193361194160
char *zErr = 0;
193362194161
193363194162
rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
193364
- pConfig->zDb, pConfig->zName, zPost, zDefn, bWithout?" WITHOUT ROWID":""
194163
+ pConfig->zDb, pConfig->zName, zPost, zDefn,
194164
+#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID
194165
+ bWithout?" WITHOUT ROWID":
194166
+#endif
194167
+ ""
193365194168
);
193366194169
if( zErr ){
193367194170
*pzErr = sqlite3_mprintf(
193368194171
"fts5: error creating shadow table %q_%s: %s",
193369194172
pConfig->zName, zPost, zErr
193370194173
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.13.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -35,12 +35,12 @@
35 **
36 *************************************************************************
37 ** Internal interface definitions for SQLite.
38 **
39 */
40 #ifndef _SQLITEINT_H_
41 #define _SQLITEINT_H_
42
43 /* Special Comments:
44 **
45 ** Some comments have special meaning to the tools that measure test
46 ** coverage:
@@ -95,12 +95,12 @@
95 **
96 ******************************************************************************
97 **
98 ** This file contains code that is specific to MSVC.
99 */
100 #ifndef _MSVC_H_
101 #define _MSVC_H_
102
103 #if defined(_MSC_VER)
104 #pragma warning(disable : 4054)
105 #pragma warning(disable : 4055)
106 #pragma warning(disable : 4100)
@@ -116,11 +116,11 @@
116 #pragma warning(disable : 4306)
117 #pragma warning(disable : 4702)
118 #pragma warning(disable : 4706)
119 #endif /* defined(_MSC_VER) */
120
121 #endif /* _MSVC_H_ */
122
123 /************** End of msvc.h ************************************************/
124 /************** Continuing where we left off in sqliteInt.h ******************/
125
126 /*
@@ -280,12 +280,12 @@
280 ** The name of this file under configuration management is "sqlite.h.in".
281 ** The makefile makes some minor changes to this file (such as inserting
282 ** the version number) and changes its name to "sqlite3.h" as
283 ** part of the build process.
284 */
285 #ifndef _SQLITE3_H_
286 #define _SQLITE3_H_
287 #include <stdarg.h> /* Needed for the definition of va_list */
288
289 /*
290 ** Make sure we can call this stuff from C++.
291 */
@@ -361,13 +361,13 @@
361 **
362 ** See also: [sqlite3_libversion()],
363 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
364 ** [sqlite_version()] and [sqlite_source_id()].
365 */
366 #define SQLITE_VERSION "3.13.0"
367 #define SQLITE_VERSION_NUMBER 3013000
368 #define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
369
370 /*
371 ** CAPI3REF: Run-Time Library Version Numbers
372 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
373 **
@@ -756,10 +756,11 @@
756 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
757 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
758 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
759 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
760 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
 
761
762 /*
763 ** CAPI3REF: Flags For File Open Operations
764 **
765 ** These bit values are intended for use in the
@@ -3003,10 +3004,13 @@
3003 #define SQLITE_RECURSIVE 33 /* NULL NULL */
3004
3005 /*
3006 ** CAPI3REF: Tracing And Profiling Functions
3007 ** METHOD: sqlite3
 
 
 
3008 **
3009 ** These routines register callback functions that can be used for
3010 ** tracing and profiling the execution of SQL statements.
3011 **
3012 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -3029,13 +3033,104 @@
3029 ** digits in the time are meaningless. Future versions of SQLite
3030 ** might provide greater resolution on the profiler callback. The
3031 ** sqlite3_profile() function is considered experimental and is
3032 ** subject to change in future versions of SQLite.
3033 */
3034 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
3035 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
 
3036 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3037
3038 /*
3039 ** CAPI3REF: Query Progress Callbacks
3040 ** METHOD: sqlite3
3041 **
@@ -3651,15 +3746,39 @@
3651
3652 /*
3653 ** CAPI3REF: Retrieving Statement SQL
3654 ** METHOD: sqlite3_stmt
3655 **
3656 ** ^This interface can be used to retrieve a saved copy of the original
3657 ** SQL text used to create a [prepared statement] if that statement was
3658 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3659 */
3660 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
 
3661
3662 /*
3663 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3664 ** METHOD: sqlite3_stmt
3665 **
@@ -7014,10 +7133,22 @@
7014 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
7015 ** <dd>This parameter returns the approximate number of bytes of heap
7016 ** memory used by all pager caches associated with the database connection.)^
7017 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
7018 **
 
 
 
 
 
 
 
 
 
 
 
 
7019 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
7020 ** <dd>This parameter returns the approximate number of bytes of heap
7021 ** memory used to store the schema for all databases associated
7022 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
7023 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -7071,11 +7202,12 @@
7071 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
7072 #define SQLITE_DBSTATUS_CACHE_HIT 7
7073 #define SQLITE_DBSTATUS_CACHE_MISS 8
7074 #define SQLITE_DBSTATUS_CACHE_WRITE 9
7075 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
7076 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
 
7077
7078
7079 /*
7080 ** CAPI3REF: Prepared Statement Status
7081 ** METHOD: sqlite3_stmt
@@ -8454,11 +8586,11 @@
8454 #endif
8455
8456 #if 0
8457 } /* End of the 'extern "C"' block */
8458 #endif
8459 #endif /* _SQLITE3_H_ */
8460
8461 /******** Begin file sqlite3rtree.h *********/
8462 /*
8463 ** 2010 August 30
8464 **
@@ -11009,12 +11141,12 @@
11009 **
11010 *************************************************************************
11011 ** This is the header file for the generic hash-table implementation
11012 ** used in SQLite.
11013 */
11014 #ifndef _SQLITE_HASH_H_
11015 #define _SQLITE_HASH_H_
11016
11017 /* Forward declarations of structures. */
11018 typedef struct Hash Hash;
11019 typedef struct HashElem HashElem;
11020
@@ -11090,11 +11222,11 @@
11090 /*
11091 ** Number of entries in a hash table
11092 */
11093 /* #define sqliteHashCount(H) ((H)->count) // NOT USED */
11094
11095 #endif /* _SQLITE_HASH_H_ */
11096
11097 /************** End of hash.h ************************************************/
11098 /************** Continuing where we left off in sqliteInt.h ******************/
11099 /************** Include parse.h in the middle of sqliteInt.h *****************/
11100 /************** Begin file parse.h *******************************************/
@@ -11838,12 +11970,12 @@
11838 *************************************************************************
11839 ** This header file defines the interface that the sqlite B-Tree file
11840 ** subsystem. See comments in the source code for a detailed description
11841 ** of what each interface routine does.
11842 */
11843 #ifndef _BTREE_H_
11844 #define _BTREE_H_
11845
11846 /* TODO: This definition is just included so other modules compile. It
11847 ** needs to be revisited.
11848 */
11849 #define SQLITE_N_BTREE_META 16
@@ -11864,10 +11996,11 @@
11864 ** Forward declarations of structure
11865 */
11866 typedef struct Btree Btree;
11867 typedef struct BtCursor BtCursor;
11868 typedef struct BtShared BtShared;
 
11869
11870
11871 SQLITE_PRIVATE int sqlite3BtreeOpen(
11872 sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
11873 const char *zFilename, /* Name of database file to open */
@@ -12075,23 +12208,47 @@
12075
12076 /* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
12077 #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
12078 #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
12079
12080 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
12081 const void *pData, int nData,
12082 int nZero, int bias, int seekResult);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12083 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
12084 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
12085 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
12086 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
12087 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12088 SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
12089 SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
12090 SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
12091 SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
12092 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
12093 SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
12094
12095 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
12096 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
12097
@@ -12128,15 +12285,17 @@
12128 #ifndef SQLITE_OMIT_SHARED_CACHE
12129 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
12130 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
12131 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
12132 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
 
12133 #else
12134 # define sqlite3BtreeEnter(X)
12135 # define sqlite3BtreeEnterAll(X)
12136 # define sqlite3BtreeSharable(X) 0
12137 # define sqlite3BtreeEnterCursor(X)
 
12138 #endif
12139
12140 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
12141 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
12142 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
@@ -12157,11 +12316,11 @@
12157 # define sqlite3BtreeHoldsAllMutexes(X) 1
12158 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
12159 #endif
12160
12161
12162 #endif /* _BTREE_H_ */
12163
12164 /************** End of btree.h ***********************************************/
12165 /************** Continuing where we left off in sqliteInt.h ******************/
12166 /************** Include vdbe.h in the middle of sqliteInt.h ******************/
12167 /************** Begin file vdbe.h ********************************************/
@@ -12180,12 +12339,12 @@
12180 **
12181 ** This header defines the interface to the virtual database engine
12182 ** or VDBE. The VDBE implements an abstract machine that runs a
12183 ** simple program to access and modify the underlying database.
12184 */
12185 #ifndef _SQLITE_VDBE_H_
12186 #define _SQLITE_VDBE_H_
12187 /* #include <stdio.h> */
12188
12189 /*
12190 ** A single VDBE is an opaque structure named "Vdbe". Only routines
12191 ** in the source file sqliteVdbe.c are allowed to see the insides
@@ -12366,21 +12525,21 @@
12366 #define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
12367 #define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
12368 #define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */
12369 #define OP_NotFound 30 /* synopsis: key=r[P3@P4] */
12370 #define OP_Found 31 /* synopsis: key=r[P3@P4] */
12371 #define OP_NotExists 32 /* synopsis: intkey=r[P3] */
12372 #define OP_Last 33
12373 #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
12374 #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12375 #define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
12376 #define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
12377 #define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
12378 #define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
12379 #define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
12380 #define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12381 #define OP_SorterSort 42
12382 #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
12383 #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
12384 #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
12385 #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
12386 #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12387,118 +12546,119 @@
12387 #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
12388 #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
12389 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12390 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12391 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12392 #define OP_Sort 53
12393 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12394 #define OP_Rewind 55
12395 #define OP_IdxLE 56 /* synopsis: key=r[P3@P4] */
12396 #define OP_IdxGT 57 /* synopsis: key=r[P3@P4] */
12397 #define OP_IdxLT 58 /* synopsis: key=r[P3@P4] */
12398 #define OP_IdxGE 59 /* synopsis: key=r[P3@P4] */
12399 #define OP_RowSetRead 60 /* synopsis: r[P3]=rowset(P1) */
12400 #define OP_RowSetTest 61 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12401 #define OP_Program 62
12402 #define OP_FkIfZero 63 /* synopsis: if fkctr[P1]==0 goto P2 */
12403 #define OP_IfPos 64 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12404 #define OP_IfNotZero 65 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12405 #define OP_DecrJumpZero 66 /* synopsis: if (--r[P1])==0 goto P2 */
12406 #define OP_IncrVacuum 67
12407 #define OP_VNext 68
12408 #define OP_Init 69 /* synopsis: Start at P2 */
12409 #define OP_Return 70
12410 #define OP_EndCoroutine 71
12411 #define OP_HaltIfNull 72 /* synopsis: if r[P3]=null halt */
12412 #define OP_Halt 73
12413 #define OP_Integer 74 /* synopsis: r[P2]=P1 */
12414 #define OP_Int64 75 /* synopsis: r[P2]=P4 */
12415 #define OP_String 76 /* synopsis: r[P2]='P4' (len=P1) */
12416 #define OP_Null 77 /* synopsis: r[P2..P3]=NULL */
12417 #define OP_SoftNull 78 /* synopsis: r[P1]=NULL */
12418 #define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */
12419 #define OP_Variable 80 /* synopsis: r[P2]=parameter(P1,P4) */
12420 #define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */
12421 #define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12422 #define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */
12423 #define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */
12424 #define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
12425 #define OP_CollSeq 86
12426 #define OP_Function0 87 /* synopsis: r[P3]=func(r[P2@P5]) */
12427 #define OP_Function 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12428 #define OP_AddImm 89 /* synopsis: r[P1]=r[P1]+P2 */
12429 #define OP_RealAffinity 90
12430 #define OP_Cast 91 /* synopsis: affinity(r[P1]) */
12431 #define OP_Permutation 92
12432 #define OP_Compare 93 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12433 #define OP_Column 94 /* synopsis: r[P3]=PX */
12434 #define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
12435 #define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12436 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12437 #define OP_Count 98 /* synopsis: r[P2]=count() */
12438 #define OP_ReadCookie 99
12439 #define OP_SetCookie 100
12440 #define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
12441 #define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */
12442 #define OP_OpenWrite 103 /* synopsis: root=P2 iDb=P3 */
12443 #define OP_OpenAutoindex 104 /* synopsis: nColumn=P2 */
12444 #define OP_OpenEphemeral 105 /* synopsis: nColumn=P2 */
12445 #define OP_SorterOpen 106
12446 #define OP_SequenceTest 107 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12447 #define OP_OpenPseudo 108 /* synopsis: P3 columns in r[P2] */
12448 #define OP_Close 109
12449 #define OP_ColumnsUsed 110
12450 #define OP_Sequence 111 /* synopsis: r[P2]=cursor[P1].ctr++ */
12451 #define OP_NewRowid 112 /* synopsis: r[P2]=rowid */
12452 #define OP_Insert 113 /* synopsis: intkey=r[P3] data=r[P2] */
12453 #define OP_InsertInt 114 /* synopsis: intkey=P3 data=r[P2] */
12454 #define OP_Delete 115
12455 #define OP_ResetCount 116
12456 #define OP_SorterCompare 117 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12457 #define OP_SorterData 118 /* synopsis: r[P2]=data */
12458 #define OP_RowKey 119 /* synopsis: r[P2]=key */
12459 #define OP_RowData 120 /* synopsis: r[P2]=data */
12460 #define OP_Rowid 121 /* synopsis: r[P2]=rowid */
12461 #define OP_NullRow 122
12462 #define OP_SorterInsert 123
12463 #define OP_IdxInsert 124 /* synopsis: key=r[P2] */
12464 #define OP_IdxDelete 125 /* synopsis: key=r[P2@P3] */
12465 #define OP_Seek 126 /* synopsis: Move P3 to P1.rowid */
12466 #define OP_IdxRowid 127 /* synopsis: r[P2]=rowid */
12467 #define OP_Destroy 128
12468 #define OP_Clear 129
12469 #define OP_ResetSorter 130
12470 #define OP_CreateIndex 131 /* synopsis: r[P2]=root iDb=P1 */
12471 #define OP_CreateTable 132 /* synopsis: r[P2]=root iDb=P1 */
12472 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12473 #define OP_ParseSchema 134
12474 #define OP_LoadAnalysis 135
12475 #define OP_DropTable 136
12476 #define OP_DropIndex 137
12477 #define OP_DropTrigger 138
12478 #define OP_IntegrityCk 139
12479 #define OP_RowSetAdd 140 /* synopsis: rowset(P1)=r[P2] */
12480 #define OP_Param 141
12481 #define OP_FkCounter 142 /* synopsis: fkctr[P1]+=P2 */
12482 #define OP_MemMax 143 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12483 #define OP_OffsetLimit 144 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12484 #define OP_AggStep0 145 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12485 #define OP_AggStep 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12486 #define OP_AggFinal 147 /* synopsis: accum=r[P1] N=P2 */
12487 #define OP_Expire 148
12488 #define OP_TableLock 149 /* synopsis: iDb=P1 root=P2 write=P3 */
12489 #define OP_VBegin 150
12490 #define OP_VCreate 151
12491 #define OP_VDestroy 152
12492 #define OP_VOpen 153
12493 #define OP_VColumn 154 /* synopsis: r[P3]=vcolumn(P2) */
12494 #define OP_VRename 155
12495 #define OP_Pagecount 156
12496 #define OP_MaxPgcnt 157
12497 #define OP_CursorHint 158
12498 #define OP_Noop 159
12499 #define OP_Explain 160
 
12500
12501 /* Properties such as "out2" or "jump" that are specified in
12502 ** comments following the "case" for each opcode in the vdbe.c
12503 ** are encoded into bitvectors as follows:
12504 */
@@ -12511,35 +12671,35 @@
12511 #define OPFLG_INITIALIZER {\
12512 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
12513 /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
12514 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12515 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12516 /* 32 */ 0x09, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12517 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12518 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12519 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01,\
12520 /* 64 */ 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02, 0x02,\
12521 /* 72 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
12522 /* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12523 /* 88 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\
12524 /* 96 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
12525 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
12526 /* 112 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12527 /* 120 */ 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
12528 /* 128 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\
12529 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
12530 /* 144 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12531 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12532 /* 160 */ 0x00,}
12533
12534 /* The sqlite3P2Values() routine is able to run faster if it knows
12535 ** the value of the largest JUMP opcode. The smaller the maximum
12536 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12537 ** generated this include file strives to group all JUMP opcodes
12538 ** together near the beginning of the list.
12539 */
12540 #define SQLITE_MX_JUMP_OPCODE 69 /* Maximum JUMP opcode */
12541
12542 /************** End of opcodes.h *********************************************/
12543 /************** Continuing where we left off in vdbe.h ***********************/
12544
12545 /*
@@ -12682,11 +12842,11 @@
12682 SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
12683 #else
12684 # define sqlite3VdbeScanStatus(a,b,c,d,e)
12685 #endif
12686
12687 #endif
12688
12689 /************** End of vdbe.h ************************************************/
12690 /************** Continuing where we left off in sqliteInt.h ******************/
12691 /************** Include pager.h in the middle of sqliteInt.h *****************/
12692 /************** Begin file pager.h *******************************************/
@@ -12704,12 +12864,12 @@
12704 ** This header file defines the interface that the sqlite page cache
12705 ** subsystem. The page cache subsystem reads and writes a file a page
12706 ** at a time and provides a journal for rollback.
12707 */
12708
12709 #ifndef _PAGER_H_
12710 #define _PAGER_H_
12711
12712 /*
12713 ** Default maximum size for persistent journal files. A negative
12714 ** value means no limit. This value may be overridden using the
12715 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
@@ -12893,11 +13053,10 @@
12893 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
12894 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
12895 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
12896 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
12897 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
12898 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
12899 SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
12900
12901 /* Functions used to truncate the database file. */
12902 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
12903
@@ -12920,11 +13079,11 @@
12920 #else
12921 # define disable_simulated_io_errors()
12922 # define enable_simulated_io_errors()
12923 #endif
12924
12925 #endif /* _PAGER_H_ */
12926
12927 /************** End of pager.h ***********************************************/
12928 /************** Continuing where we left off in sqliteInt.h ******************/
12929 /************** Include pcache.h in the middle of sqliteInt.h ****************/
12930 /************** Begin file pcache.h ******************************************/
@@ -13158,12 +13317,12 @@
13158 ******************************************************************************
13159 **
13160 ** This file contains pre-processor directives related to operating system
13161 ** detection and/or setup.
13162 */
13163 #ifndef _OS_SETUP_H_
13164 #define _OS_SETUP_H_
13165
13166 /*
13167 ** Figure out if we are dealing with Unix, Windows, or some other operating
13168 ** system.
13169 **
@@ -13199,11 +13358,11 @@
13199 # ifndef SQLITE_OS_WIN
13200 # define SQLITE_OS_WIN 0
13201 # endif
13202 #endif
13203
13204 #endif /* _OS_SETUP_H_ */
13205
13206 /************** End of os_setup.h ********************************************/
13207 /************** Continuing where we left off in os.h *************************/
13208
13209 /* If the SET_FULLSYNC macro is not defined above, then make it
@@ -13656,10 +13815,19 @@
13656 #else
13657 typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
13658 const char*);
13659 #endif
13660
 
 
 
 
 
 
 
 
 
13661
13662 /*
13663 ** Each database connection is an instance of the following structure.
13664 */
13665 struct sqlite3 {
@@ -13685,10 +13853,11 @@
13685 u8 dfltLockMode; /* Default locking-mode for attached dbs */
13686 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
13687 u8 suppressErr; /* Do not issue error messages if true */
13688 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
13689 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
 
13690 int nextPagesize; /* Pagesize after VACUUM if >0 */
13691 u32 magic; /* Magic number for detect library misuse */
13692 int nChange; /* Value returned by sqlite3_changes() */
13693 int nTotalChange; /* Value returned by sqlite3_total_changes() */
13694 int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -13705,11 +13874,11 @@
13705 int nVdbeWrite; /* Number of active VDBEs that read and write */
13706 int nVdbeExec; /* Number of nested calls to VdbeExec() */
13707 int nVDestroy; /* Number of active OP_VDestroy operations */
13708 int nExtension; /* Number of loaded extensions */
13709 void **aExtension; /* Array of shared library handles */
13710 void (*xTrace)(void*,const char*); /* Trace function */
13711 void *pTraceArg; /* Argument to the trace function */
13712 void (*xProfile)(void*,const char*,u64); /* Profiling function */
13713 void *pProfileArg; /* Argument to profile function */
13714 void *pCommitArg; /* Argument to xCommitCallback() */
13715 int (*xCommitCallback)(void*); /* Invoked at every commit. */
@@ -14900,11 +15069,11 @@
14900 Select *pSelect; /* A SELECT statement used in place of a table name */
14901 int addrFillSub; /* Address of subroutine to manifest a subquery */
14902 int regReturn; /* Register holding return address of addrFillSub */
14903 int regResult; /* Registers holding results of a co-routine */
14904 struct {
14905 u8 jointype; /* Type of join between this able and the previous */
14906 unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
14907 unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
14908 unsigned isTabFunc :1; /* True if table-valued-function syntax */
14909 unsigned isCorrelated :1; /* True if sub-query is correlated */
14910 unsigned viaCoroutine :1; /* Implemented as a co-routine */
@@ -14946,23 +15115,24 @@
14946 */
14947 #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
14948 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
14949 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
14950 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
14951 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
14952 #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
14953 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
14954 #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
14955 #define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
14956 #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
14957 #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
14958 #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
14959 #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
14960 #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
14961 #define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
14962 #define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */
14963 #define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */
 
14964
14965 /* Allowed return values from sqlite3WhereIsDistinct()
14966 */
14967 #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
14968 #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
@@ -16031,12 +16201,12 @@
16031 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
16032 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
16033 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
16034 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
16035 SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
16036 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16037 Expr*, int, int);
16038 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
16039 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
16040 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
16041 Expr*,ExprList*,u32,Expr*,Expr*);
16042 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -16051,10 +16221,11 @@
16051 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
16052 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
16053 SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
16054 SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
16055 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
 
16056 SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
16057 SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
16058 SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
16059 SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
16060 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -16084,12 +16255,14 @@
16084 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
16085 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
16086 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
16087 SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
16088 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
16089 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
16090 SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
 
 
16091 SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
16092 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
16093 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16094 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
16095 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
@@ -16648,11 +16821,11 @@
16648
16649 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
16650 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
16651 #endif
16652
16653 #endif /* _SQLITEINT_H_ */
16654
16655 /************** End of sqliteInt.h *******************************************/
16656 /************** Begin file global.c ******************************************/
16657 /*
16658 ** 2008 June 13
@@ -16983,10 +17156,17 @@
16983 "CASE_SENSITIVE_LIKE",
16984 #endif
16985 #if SQLITE_CHECK_PAGES
16986 "CHECK_PAGES",
16987 #endif
 
 
 
 
 
 
 
16988 #if SQLITE_COVERAGE_TEST
16989 "COVERAGE_TEST",
16990 #endif
16991 #if SQLITE_DEBUG
16992 "DEBUG",
@@ -17002,11 +17182,11 @@
17002 #endif
17003 #if SQLITE_DISABLE_LFS
17004 "DISABLE_LFS",
17005 #endif
17006 #if SQLITE_ENABLE_8_3_NAMES
17007 "ENABLE_8_3_NAMES",
17008 #endif
17009 #if SQLITE_ENABLE_API_ARMOR
17010 "ENABLE_API_ARMOR",
17011 #endif
17012 #if SQLITE_ENABLE_ATOMIC_WRITE
@@ -17416,12 +17596,12 @@
17416 ** VDBE. This information used to all be at the top of the single
17417 ** source code file "vdbe.c". When that file became too big (over
17418 ** 6000 lines long) it was split up into several smaller files and
17419 ** this header information was factored out.
17420 */
17421 #ifndef _VDBEINT_H_
17422 #define _VDBEINT_H_
17423
17424 /*
17425 ** The maximum number of times that a statement will try to reparse
17426 ** itself before giving up and returning SQLITE_SCHEMA.
17427 */
@@ -17959,11 +18139,11 @@
17959 #else
17960 #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
17961 #define ExpandBlob(P) SQLITE_OK
17962 #endif
17963
17964 #endif /* !defined(_VDBEINT_H_) */
17965
17966 /************** End of vdbeInt.h *********************************************/
17967 /************** Continuing where we left off in status.c *********************/
17968
17969 /*
@@ -18167,19 +18347,24 @@
18167 /*
18168 ** Return an approximation for the amount of memory currently used
18169 ** by all pagers associated with the given database connection. The
18170 ** highwater mark is meaningless and is returned as zero.
18171 */
 
18172 case SQLITE_DBSTATUS_CACHE_USED: {
18173 int totalUsed = 0;
18174 int i;
18175 sqlite3BtreeEnterAll(db);
18176 for(i=0; i<db->nDb; i++){
18177 Btree *pBt = db->aDb[i].pBt;
18178 if( pBt ){
18179 Pager *pPager = sqlite3BtreePager(pBt);
18180 totalUsed += sqlite3PagerMemUsed(pPager);
 
 
 
 
18181 }
18182 }
18183 sqlite3BtreeLeaveAll(db);
18184 *pCurrent = totalUsed;
18185 *pHighwater = 0;
@@ -19478,13 +19663,11 @@
19478 ******************************************************************************
19479 **
19480 ** This file contains OS interface code that is common to all
19481 ** architectures.
19482 */
19483 #define _SQLITE_OS_C_ 1
19484 /* #include "sqliteInt.h" */
19485 #undef _SQLITE_OS_C_
19486
19487 /*
19488 ** If we compile with the SQLITE_TEST macro set, then the following block
19489 ** of code will give us the ability to simulate a disk I/O error. This
19490 ** is used for testing the I/O recovery logic.
@@ -22993,12 +23176,12 @@
22993 ******************************************************************************
22994 **
22995 ** This file contains inline asm code for retrieving "high-performance"
22996 ** counters for x86 class CPUs.
22997 */
22998 #ifndef _HWTIME_H_
22999 #define _HWTIME_H_
23000
23001 /*
23002 ** The following routine only works on pentium-class (or newer) processors.
23003 ** It uses the RDTSC opcode to read the cycle count value out of the
23004 ** processor and returns that value. This can be used for high-res
@@ -23062,11 +23245,11 @@
23062 */
23063 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
23064
23065 #endif
23066
23067 #endif /* !defined(_HWTIME_H_) */
23068
23069 /************** End of hwtime.h **********************************************/
23070 /************** Continuing where we left off in os_common.h ******************/
23071
23072 static sqlite_uint64 g_start;
@@ -23152,12 +23335,12 @@
23152 **
23153 ******************************************************************************
23154 **
23155 ** This file contains code that is specific to Windows.
23156 */
23157 #ifndef _OS_WIN_H_
23158 #define _OS_WIN_H_
23159
23160 /*
23161 ** Include the primary Windows SDK header file.
23162 */
23163 #include "windows.h"
@@ -23225,11 +23408,11 @@
23225 # define SQLITE_OS_WIN_THREADS 1
23226 #else
23227 # define SQLITE_OS_WIN_THREADS 0
23228 #endif
23229
23230 #endif /* _OS_WIN_H_ */
23231
23232 /************** End of os_win.h **********************************************/
23233 /************** Continuing where we left off in mutex_w32.c ******************/
23234 #endif
23235
@@ -25976,10 +26159,16 @@
25976 }
25977 sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
25978 break;
25979 }
25980 #endif
 
 
 
 
 
 
25981 default: {
25982 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
25983 break;
25984 }
25985 }
@@ -28759,21 +28948,21 @@
28759 /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
28760 /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
28761 /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
28762 /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
28763 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
28764 /* 32 */ "NotExists" OpHelp("intkey=r[P3]"),
28765 /* 33 */ "Last" OpHelp(""),
28766 /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
28767 /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
28768 /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
28769 /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
28770 /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
28771 /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
28772 /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
28773 /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
28774 /* 42 */ "SorterSort" OpHelp(""),
28775 /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
28776 /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
28777 /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
28778 /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
28779 /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -28780,118 +28969,119 @@
28780 /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
28781 /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
28782 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
28783 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
28784 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
28785 /* 53 */ "Sort" OpHelp(""),
28786 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
28787 /* 55 */ "Rewind" OpHelp(""),
28788 /* 56 */ "IdxLE" OpHelp("key=r[P3@P4]"),
28789 /* 57 */ "IdxGT" OpHelp("key=r[P3@P4]"),
28790 /* 58 */ "IdxLT" OpHelp("key=r[P3@P4]"),
28791 /* 59 */ "IdxGE" OpHelp("key=r[P3@P4]"),
28792 /* 60 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
28793 /* 61 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
28794 /* 62 */ "Program" OpHelp(""),
28795 /* 63 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
28796 /* 64 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
28797 /* 65 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
28798 /* 66 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
28799 /* 67 */ "IncrVacuum" OpHelp(""),
28800 /* 68 */ "VNext" OpHelp(""),
28801 /* 69 */ "Init" OpHelp("Start at P2"),
28802 /* 70 */ "Return" OpHelp(""),
28803 /* 71 */ "EndCoroutine" OpHelp(""),
28804 /* 72 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
28805 /* 73 */ "Halt" OpHelp(""),
28806 /* 74 */ "Integer" OpHelp("r[P2]=P1"),
28807 /* 75 */ "Int64" OpHelp("r[P2]=P4"),
28808 /* 76 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
28809 /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"),
28810 /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"),
28811 /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
28812 /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
28813 /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
28814 /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
28815 /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"),
28816 /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
28817 /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
28818 /* 86 */ "CollSeq" OpHelp(""),
28819 /* 87 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
28820 /* 88 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
28821 /* 89 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
28822 /* 90 */ "RealAffinity" OpHelp(""),
28823 /* 91 */ "Cast" OpHelp("affinity(r[P1])"),
28824 /* 92 */ "Permutation" OpHelp(""),
28825 /* 93 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
28826 /* 94 */ "Column" OpHelp("r[P3]=PX"),
28827 /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
28828 /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
28829 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
28830 /* 98 */ "Count" OpHelp("r[P2]=count()"),
28831 /* 99 */ "ReadCookie" OpHelp(""),
28832 /* 100 */ "SetCookie" OpHelp(""),
28833 /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
28834 /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
28835 /* 103 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
28836 /* 104 */ "OpenAutoindex" OpHelp("nColumn=P2"),
28837 /* 105 */ "OpenEphemeral" OpHelp("nColumn=P2"),
28838 /* 106 */ "SorterOpen" OpHelp(""),
28839 /* 107 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
28840 /* 108 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
28841 /* 109 */ "Close" OpHelp(""),
28842 /* 110 */ "ColumnsUsed" OpHelp(""),
28843 /* 111 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
28844 /* 112 */ "NewRowid" OpHelp("r[P2]=rowid"),
28845 /* 113 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
28846 /* 114 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
28847 /* 115 */ "Delete" OpHelp(""),
28848 /* 116 */ "ResetCount" OpHelp(""),
28849 /* 117 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
28850 /* 118 */ "SorterData" OpHelp("r[P2]=data"),
28851 /* 119 */ "RowKey" OpHelp("r[P2]=key"),
28852 /* 120 */ "RowData" OpHelp("r[P2]=data"),
28853 /* 121 */ "Rowid" OpHelp("r[P2]=rowid"),
28854 /* 122 */ "NullRow" OpHelp(""),
28855 /* 123 */ "SorterInsert" OpHelp(""),
28856 /* 124 */ "IdxInsert" OpHelp("key=r[P2]"),
28857 /* 125 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
28858 /* 126 */ "Seek" OpHelp("Move P3 to P1.rowid"),
28859 /* 127 */ "IdxRowid" OpHelp("r[P2]=rowid"),
28860 /* 128 */ "Destroy" OpHelp(""),
28861 /* 129 */ "Clear" OpHelp(""),
28862 /* 130 */ "ResetSorter" OpHelp(""),
28863 /* 131 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
28864 /* 132 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
28865 /* 133 */ "Real" OpHelp("r[P2]=P4"),
28866 /* 134 */ "ParseSchema" OpHelp(""),
28867 /* 135 */ "LoadAnalysis" OpHelp(""),
28868 /* 136 */ "DropTable" OpHelp(""),
28869 /* 137 */ "DropIndex" OpHelp(""),
28870 /* 138 */ "DropTrigger" OpHelp(""),
28871 /* 139 */ "IntegrityCk" OpHelp(""),
28872 /* 140 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
28873 /* 141 */ "Param" OpHelp(""),
28874 /* 142 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
28875 /* 143 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
28876 /* 144 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
28877 /* 145 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
28878 /* 146 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
28879 /* 147 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
28880 /* 148 */ "Expire" OpHelp(""),
28881 /* 149 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
28882 /* 150 */ "VBegin" OpHelp(""),
28883 /* 151 */ "VCreate" OpHelp(""),
28884 /* 152 */ "VDestroy" OpHelp(""),
28885 /* 153 */ "VOpen" OpHelp(""),
28886 /* 154 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
28887 /* 155 */ "VRename" OpHelp(""),
28888 /* 156 */ "Pagecount" OpHelp(""),
28889 /* 157 */ "MaxPgcnt" OpHelp(""),
28890 /* 158 */ "CursorHint" OpHelp(""),
28891 /* 159 */ "Noop" OpHelp(""),
28892 /* 160 */ "Explain" OpHelp(""),
 
28893 };
28894 return azName[i];
28895 }
28896 #endif
28897
@@ -29237,12 +29427,12 @@
29237 ******************************************************************************
29238 **
29239 ** This file contains inline asm code for retrieving "high-performance"
29240 ** counters for x86 class CPUs.
29241 */
29242 #ifndef _HWTIME_H_
29243 #define _HWTIME_H_
29244
29245 /*
29246 ** The following routine only works on pentium-class (or newer) processors.
29247 ** It uses the RDTSC opcode to read the cycle count value out of the
29248 ** processor and returns that value. This can be used for high-res
@@ -29306,11 +29496,11 @@
29306 */
29307 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
29308
29309 #endif
29310
29311 #endif /* !defined(_HWTIME_H_) */
29312
29313 /************** End of hwtime.h **********************************************/
29314 /************** Continuing where we left off in os_common.h ******************/
29315
29316 static sqlite_uint64 g_start;
@@ -36766,12 +36956,12 @@
36766 ******************************************************************************
36767 **
36768 ** This file contains inline asm code for retrieving "high-performance"
36769 ** counters for x86 class CPUs.
36770 */
36771 #ifndef _HWTIME_H_
36772 #define _HWTIME_H_
36773
36774 /*
36775 ** The following routine only works on pentium-class (or newer) processors.
36776 ** It uses the RDTSC opcode to read the cycle count value out of the
36777 ** processor and returns that value. This can be used for high-res
@@ -36835,11 +37025,11 @@
36835 */
36836 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
36837
36838 #endif
36839
36840 #endif /* !defined(_HWTIME_H_) */
36841
36842 /************** End of hwtime.h **********************************************/
36843 /************** Continuing where we left off in os_common.h ******************/
36844
36845 static sqlite_uint64 g_start;
@@ -37175,10 +37365,21 @@
37175 sqlite3_int64 mmapSize; /* Usable size of mapped region */
37176 sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */
37177 sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */
37178 #endif
37179 };
 
 
 
 
 
 
 
 
 
 
 
37180
37181 /*
37182 ** Allowed values for winFile.ctrlFlags
37183 */
37184 #define WINFILE_RDONLY 0x02 /* Connection is read only */
@@ -39497,11 +39698,16 @@
39497 rc = osCloseHandle(pFile->h);
39498 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
39499 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
39500 #if SQLITE_OS_WINCE
39501 #define WINCE_DELETION_ATTEMPTS 3
39502 winceDestroyLock(pFile);
 
 
 
 
 
39503 if( pFile->zDeleteOnClose ){
39504 int cnt = 0;
39505 while(
39506 osDeleteFileW(pFile->zDeleteOnClose)==0
39507 && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
@@ -40229,10 +40435,48 @@
40229 OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
40230 pFile->h, pFile->locktype, sqlite3ErrName(rc)));
40231 return rc;
40232 }
40233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40234 /*
40235 ** If *pArg is initially negative then this is a query. Set *pArg to
40236 ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
40237 **
40238 ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
@@ -40507,16 +40751,16 @@
40507 #define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
40508
40509 /*
40510 ** Apply advisory locks for all n bytes beginning at ofst.
40511 */
40512 #define _SHM_UNLCK 1
40513 #define _SHM_RDLCK 2
40514 #define _SHM_WRLCK 3
40515 static int winShmSystemLock(
40516 winShmNode *pFile, /* Apply locks to this open shared-memory segment */
40517 int lockType, /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */
40518 int ofst, /* Offset to first byte to be locked/unlocked */
40519 int nByte /* Number of bytes to lock or unlock */
40520 ){
40521 int rc = 0; /* Result code form Lock/UnlockFileEx() */
40522
@@ -40525,16 +40769,16 @@
40525
40526 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
40527 pFile->hFile.h, lockType, ofst, nByte));
40528
40529 /* Release/Acquire the system-level lock */
40530 if( lockType==_SHM_UNLCK ){
40531 rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
40532 }else{
40533 /* Initialize the locking parameters */
40534 DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
40535 if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
40536 rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
40537 }
40538
40539 if( rc!= 0 ){
40540 rc = SQLITE_OK;
@@ -40542,11 +40786,11 @@
40542 pFile->lastErrno = osGetLastError();
40543 rc = SQLITE_BUSY;
40544 }
40545
40546 OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
40547 pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" :
40548 "winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
40549
40550 return rc;
40551 }
40552
@@ -40670,20 +40914,20 @@
40670 }
40671
40672 /* Check to see if another process is holding the dead-man switch.
40673 ** If not, truncate the file to zero length.
40674 */
40675 if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
40676 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
40677 if( rc!=SQLITE_OK ){
40678 rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
40679 "winOpenShm", pDbFd->zPath);
40680 }
40681 }
40682 if( rc==SQLITE_OK ){
40683 winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40684 rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
40685 }
40686 if( rc ) goto shm_open_err;
40687 }
40688
40689 /* Make the new connection a child of the winShmNode */
@@ -40708,11 +40952,11 @@
40708 sqlite3_mutex_leave(pShmNode->mutex);
40709 return SQLITE_OK;
40710
40711 /* Jump here on any error */
40712 shm_open_err:
40713 winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40714 winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
40715 sqlite3_free(p);
40716 sqlite3_free(pNew);
40717 winShmLeaveMutex();
40718 return rc;
@@ -40797,11 +41041,11 @@
40797 allMask |= pX->sharedMask;
40798 }
40799
40800 /* Unlock the system-level locks */
40801 if( (mask & allMask)==0 ){
40802 rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n);
40803 }else{
40804 rc = SQLITE_OK;
40805 }
40806
40807 /* Undo the local locks */
@@ -40825,11 +41069,11 @@
40825 }
40826
40827 /* Get shared locks at the system level, if necessary */
40828 if( rc==SQLITE_OK ){
40829 if( (allShared & mask)==0 ){
40830 rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n);
40831 }else{
40832 rc = SQLITE_OK;
40833 }
40834 }
40835
@@ -40850,11 +41094,11 @@
40850
40851 /* Get the exclusive locks at the system level. Then if successful
40852 ** also mark the local connection as being locked.
40853 */
40854 if( rc==SQLITE_OK ){
40855 rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
40856 if( rc==SQLITE_OK ){
40857 assert( (p->sharedMask & mask)==0 );
40858 p->exclMask |= mask;
40859 }
40860 }
@@ -41292,10 +41536,48 @@
41292 winShmBarrier, /* xShmBarrier */
41293 winShmUnmap, /* xShmUnmap */
41294 winFetch, /* xFetch */
41295 winUnfetch /* xUnfetch */
41296 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41297
41298 /****************************************************************************
41299 **************************** sqlite3_vfs methods ****************************
41300 **
41301 ** This division contains the implementation of methods on the
@@ -41625,11 +41907,11 @@
41625
41626 /*
41627 ** Open a file.
41628 */
41629 static int winOpen(
41630 sqlite3_vfs *pVfs, /* Used to get maximum path name length */
41631 const char *zName, /* Name of the file (UTF-8) */
41632 sqlite3_file *id, /* Write the SQLite file handle here */
41633 int flags, /* Open mode flags */
41634 int *pOutFlags /* Status return flags */
41635 ){
@@ -41640,10 +41922,11 @@
41640 DWORD dwCreationDisposition;
41641 DWORD dwFlagsAndAttributes = 0;
41642 #if SQLITE_OS_WINCE
41643 int isTemp = 0;
41644 #endif
 
41645 winFile *pFile = (winFile*)id;
41646 void *zConverted; /* Filename in OS encoding */
41647 const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
41648 int cnt = 0;
41649
@@ -41861,19 +42144,24 @@
41861
41862 OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
41863 "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
41864 *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
41865
 
 
41866 #if SQLITE_OS_WINCE
41867 if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
41868 && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
41869 ){
41870 osCloseHandle(h);
41871 sqlite3_free(zConverted);
41872 sqlite3_free(zTmpname);
41873 OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
41874 return rc;
 
 
 
41875 }
41876 if( isTemp ){
41877 pFile->zDeleteOnClose = zConverted;
41878 }else
41879 #endif
@@ -41880,11 +42168,11 @@
41880 {
41881 sqlite3_free(zConverted);
41882 }
41883
41884 sqlite3_free(zTmpname);
41885 pFile->pMethod = &winIoMethod;
41886 pFile->pVfs = pVfs;
41887 pFile->h = h;
41888 if( isReadonly ){
41889 pFile->ctrlFlags |= WINFILE_RDONLY;
41890 }
@@ -42155,10 +42443,22 @@
42155 sqlite3_vfs *pVfs, /* Pointer to vfs object */
42156 const char *zRelative, /* Possibly relative input path */
42157 int nFull, /* Size of output buffer in bytes */
42158 char *zFull /* Output buffer */
42159 ){
 
 
 
 
 
 
 
 
 
 
 
 
42160
42161 #if defined(__CYGWIN__)
42162 SimulateIOError( return SQLITE_ERROR );
42163 UNUSED_PARAMETER(nFull);
42164 assert( nFull>=pVfs->mxPathname );
@@ -42233,21 +42533,10 @@
42233 }
42234 return SQLITE_OK;
42235 #endif
42236
42237 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42238 DWORD nByte;
42239 void *zConverted;
42240 char *zOut;
42241
42242 /* If this path name begins with "/X:", where "X" is any alphabetic
42243 ** character, discard the initial "/" from the pathname.
42244 */
42245 if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42246 zRelative++;
42247 }
42248
42249 /* It's odd to simulate an io-error here, but really this is just
42250 ** using the io-error infrastructure to test that SQLite handles this
42251 ** function failing. This function could fail if, for example, the
42252 ** current working directory has been unlinked.
42253 */
@@ -42602,57 +42891,107 @@
42602 /*
42603 ** Initialize and deinitialize the operating system interface.
42604 */
42605 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
42606 static sqlite3_vfs winVfs = {
42607 3, /* iVersion */
42608 sizeof(winFile), /* szOsFile */
42609 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42610 0, /* pNext */
42611 "win32", /* zName */
42612 0, /* pAppData */
42613 winOpen, /* xOpen */
42614 winDelete, /* xDelete */
42615 winAccess, /* xAccess */
42616 winFullPathname, /* xFullPathname */
42617 winDlOpen, /* xDlOpen */
42618 winDlError, /* xDlError */
42619 winDlSym, /* xDlSym */
42620 winDlClose, /* xDlClose */
42621 winRandomness, /* xRandomness */
42622 winSleep, /* xSleep */
42623 winCurrentTime, /* xCurrentTime */
42624 winGetLastError, /* xGetLastError */
42625 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42626 winSetSystemCall, /* xSetSystemCall */
42627 winGetSystemCall, /* xGetSystemCall */
42628 winNextSystemCall, /* xNextSystemCall */
42629 };
42630 #if defined(SQLITE_WIN32_HAS_WIDE)
42631 static sqlite3_vfs winLongPathVfs = {
42632 3, /* iVersion */
42633 sizeof(winFile), /* szOsFile */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42634 SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42635 0, /* pNext */
42636 "win32-longpath", /* zName */
42637 0, /* pAppData */
42638 winOpen, /* xOpen */
42639 winDelete, /* xDelete */
42640 winAccess, /* xAccess */
42641 winFullPathname, /* xFullPathname */
42642 winDlOpen, /* xDlOpen */
42643 winDlError, /* xDlError */
42644 winDlSym, /* xDlSym */
42645 winDlClose, /* xDlClose */
42646 winRandomness, /* xRandomness */
42647 winSleep, /* xSleep */
42648 winCurrentTime, /* xCurrentTime */
42649 winGetLastError, /* xGetLastError */
42650 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42651 winSetSystemCall, /* xSetSystemCall */
42652 winGetSystemCall, /* xGetSystemCall */
42653 winNextSystemCall, /* xNextSystemCall */
42654 };
42655 #endif
42656
42657 /* Double-check that the aSyscall[] array has been constructed
42658 ** correctly. See ticket [bb3a86e890c8e96ab] */
@@ -42671,10 +43010,16 @@
42671 sqlite3_vfs_register(&winVfs, 1);
42672
42673 #if defined(SQLITE_WIN32_HAS_WIDE)
42674 sqlite3_vfs_register(&winLongPathVfs, 0);
42675 #endif
 
 
 
 
 
 
42676
42677 return SQLITE_OK;
42678 }
42679
42680 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
@@ -43792,32 +44137,34 @@
43792 sqlite3PcacheTruncate(pCache, 0);
43793 }
43794
43795 /*
43796 ** Merge two lists of pages connected by pDirty and in pgno order.
43797 ** Do not both fixing the pDirtyPrev pointers.
43798 */
43799 static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
43800 PgHdr result, *pTail;
43801 pTail = &result;
43802 while( pA && pB ){
 
43803 if( pA->pgno<pB->pgno ){
43804 pTail->pDirty = pA;
43805 pTail = pA;
43806 pA = pA->pDirty;
 
 
 
 
43807 }else{
43808 pTail->pDirty = pB;
43809 pTail = pB;
43810 pB = pB->pDirty;
43811 }
43812 }
43813 if( pA ){
43814 pTail->pDirty = pA;
43815 }else if( pB ){
43816 pTail->pDirty = pB;
43817 }else{
43818 pTail->pDirty = 0;
43819 }
43820 return result.pDirty;
43821 }
43822
43823 /*
@@ -43855,11 +44202,12 @@
43855 a[i] = pcacheMergeDirtyList(a[i], p);
43856 }
43857 }
43858 p = a[0];
43859 for(i=1; i<N_SORT_BUCKET; i++){
43860 p = pcacheMergeDirtyList(p, a[i]);
 
43861 }
43862 return p;
43863 }
43864
43865 /*
@@ -45460,31 +45808,29 @@
45460 ){
45461 struct RowSetEntry head;
45462 struct RowSetEntry *pTail;
45463
45464 pTail = &head;
45465 while( pA && pB ){
 
45466 assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45467 assert( pB->pRight==0 || pB->v<=pB->pRight->v );
45468 if( pA->v<pB->v ){
45469 pTail->pRight = pA;
45470 pA = pA->pRight;
45471 pTail = pTail->pRight;
45472 }else if( pB->v<pA->v ){
45473 pTail->pRight = pB;
 
 
 
45474 pB = pB->pRight;
45475 pTail = pTail->pRight;
45476 }else{
45477 pA = pA->pRight;
45478 }
45479 }
45480 if( pA ){
45481 assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45482 pTail->pRight = pA;
45483 }else{
45484 assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v );
45485 pTail->pRight = pB;
45486 }
45487 return head.pRight;
45488 }
45489
45490 /*
@@ -45504,13 +45850,14 @@
45504 aBucket[i] = 0;
45505 }
45506 aBucket[i] = pIn;
45507 pIn = pNext;
45508 }
45509 pIn = 0;
45510 for(i=0; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45511 pIn = rowSetEntryMerge(pIn, aBucket[i]);
 
45512 }
45513 return pIn;
45514 }
45515
45516
@@ -45758,12 +46105,12 @@
45758 ** This header file defines the interface to the write-ahead logging
45759 ** system. Refer to the comments below and the header comment attached to
45760 ** the implementation of each function in log.c for further details.
45761 */
45762
45763 #ifndef _WAL_H_
45764 #define _WAL_H_
45765
45766 /* #include "sqliteInt.h" */
45767
45768 /* Additional values that can be added to the sync_flags argument of
45769 ** sqlite3WalFrames():
@@ -45887,11 +46234,11 @@
45887
45888 /* Return the sqlite3_file object for the WAL file */
45889 SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);
45890
45891 #endif /* ifndef SQLITE_OMIT_WAL */
45892 #endif /* _WAL_H_ */
45893
45894 /************** End of wal.h *************************************************/
45895 /************** Continuing where we left off in pager.c **********************/
45896
45897
@@ -53027,20 +53374,10 @@
53027 */
53028 SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
53029 return &pPager->pBackup;
53030 }
53031
53032 #ifndef SQLITE_OMIT_VACUUM
53033 /*
53034 ** Unless this is an in-memory or temporary database, clear the pager cache.
53035 */
53036 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
53037 assert( MEMDB==0 || pPager->tempFile );
53038 if( pPager->tempFile==0 ) pager_reset(pPager);
53039 }
53040 #endif
53041
53042 #ifndef SQLITE_OMIT_WAL
53043 /*
53044 ** This function is called when the user invokes "PRAGMA wal_checkpoint",
53045 ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
53046 ** or wal_blocking_checkpoint() API functions.
@@ -56378,20 +56715,25 @@
56378 ** boundary is crossed. Only the part of the WAL prior to the last
56379 ** sector boundary is synced; the part of the last frame that extends
56380 ** past the sector boundary is written after the sync.
56381 */
56382 if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
 
56383 if( pWal->padToSectorBoundary ){
56384 int sectorSize = sqlite3SectorSize(pWal->pWalFd);
56385 w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
 
 
56386 while( iOffset<w.iSyncPoint ){
56387 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
56388 if( rc ) return rc;
56389 iOffset += szFrame;
56390 nExtra++;
56391 }
56392 }else{
 
 
56393 rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);
56394 }
56395 }
56396
56397 /* If this frame set completes the first transaction in the WAL and
@@ -58174,10 +58516,19 @@
58174 */
58175 #ifdef SQLITE_DEBUG
58176 static int cursorHoldsMutex(BtCursor *p){
58177 return sqlite3_mutex_held(p->pBt->mutex);
58178 }
 
 
 
 
 
 
 
 
 
58179 static int cursorOwnsBtShared(BtCursor *p){
58180 assert( cursorHoldsMutex(p) );
58181 return (p->pBtree->db==p->pBt->db);
58182 }
58183 #endif
@@ -58333,25 +58684,23 @@
58333 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
58334 ** set to point to a malloced buffer pCur->nKey bytes in size containing
58335 ** the key.
58336 */
58337 static int saveCursorKey(BtCursor *pCur){
58338 int rc;
58339 assert( CURSOR_VALID==pCur->eState );
58340 assert( 0==pCur->pKey );
58341 assert( cursorHoldsMutex(pCur) );
58342
58343 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
58344 assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
58345
58346 /* If this is an intKey table, then the above call to BtreeKeySize()
58347 ** stores the integer key in pCur->nKey. In this case this value is
58348 ** all that is required. Otherwise, if pCur is not open on an intKey
58349 ** table, then malloc space for and store the pCur->nKey bytes of key
58350 ** data. */
58351 if( 0==pCur->curIntKey ){
58352 void *pKey = sqlite3Malloc( pCur->nKey );
58353 if( pKey ){
58354 rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
58355 if( rc==SQLITE_OK ){
58356 pCur->pKey = pKey;
58357 }else{
@@ -60054,13 +60403,13 @@
60054 assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
60055
60056 #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
60057 /* Add the new BtShared object to the linked list sharable BtShareds.
60058 */
 
60059 if( p->sharable ){
60060 MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
60061 pBt->nRef = 1;
60062 MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
60063 if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
60064 pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
60065 if( pBt->mutex==0 ){
60066 rc = SQLITE_NOMEM_BKPT;
@@ -60127,10 +60476,11 @@
60127 }
60128 if( mutexOpen ){
60129 assert( sqlite3_mutex_held(mutexOpen) );
60130 sqlite3_mutex_leave(mutexOpen);
60131 }
 
60132 return rc;
60133 }
60134
60135 /*
60136 ** Decrement the BtShared.nRef counter. When it reaches zero,
@@ -61986,50 +62336,37 @@
61986 return pCur && pCur->eState==CURSOR_VALID;
61987 }
61988 #endif /* NDEBUG */
61989
61990 /*
61991 ** Set *pSize to the size of the buffer needed to hold the value of
61992 ** the key for the current entry. If the cursor is not pointing
61993 ** to a valid entry, *pSize is set to 0.
61994 **
61995 ** For a table with the INTKEY flag set, this routine returns the key
61996 ** itself, not the number of bytes in the key.
61997 **
61998 ** The caller must position the cursor prior to invoking this routine.
61999 **
62000 ** This routine cannot fail. It always returns SQLITE_OK.
62001 */
62002 SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
62003 assert( cursorHoldsMutex(pCur) );
62004 assert( pCur->eState==CURSOR_VALID );
 
62005 getCellInfo(pCur);
62006 *pSize = pCur->info.nKey;
62007 return SQLITE_OK;
62008 }
62009
62010 /*
62011 ** Set *pSize to the number of bytes of data in the entry the
62012 ** cursor currently points to.
 
62013 **
62014 ** The caller must guarantee that the cursor is pointing to a non-NULL
62015 ** valid entry. In other words, the calling procedure must guarantee
62016 ** that the cursor has Cursor.eState==CURSOR_VALID.
62017 **
62018 ** Failure is not possible. This function always returns SQLITE_OK.
62019 ** It might just as well be a procedure (returning void) but we continue
62020 ** to return an integer result code for historical reasons.
62021 */
62022 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
62023 assert( cursorOwnsBtShared(pCur) );
62024 assert( pCur->eState==CURSOR_VALID );
62025 assert( pCur->iPage>=0 );
62026 assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
62027 assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
62028 getCellInfo(pCur);
62029 *pSize = pCur->info.nPayload;
62030 return SQLITE_OK;
62031 }
62032
62033 /*
62034 ** Given the page number of an overflow page in the database (parameter
62035 ** ovfl), this function finds the page number of the next page in the
@@ -62467,14 +62804,11 @@
62467 ** this routine.
62468 **
62469 ** These routines is used to get quick access to key and data
62470 ** in the common case where no overflow pages are used.
62471 */
62472 SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
62473 return fetchPayload(pCur, pAmt);
62474 }
62475 SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){
62476 return fetchPayload(pCur, pAmt);
62477 }
62478
62479
62480 /*
@@ -62803,15 +63137,16 @@
62803
62804 assert( cursorOwnsBtShared(pCur) );
62805 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
62806 assert( pRes );
62807 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
 
62808
62809 /* If the cursor is already positioned at the point we are trying
62810 ** to move to, then just return without doing any work */
62811 if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
62812 && pCur->curIntKey
62813 ){
62814 if( pCur->info.nKey==intKey ){
62815 *pRes = 0;
62816 return SQLITE_OK;
62817 }
@@ -63796,13 +64131,11 @@
63796 ** later.
63797 */
63798 static int fillInCell(
63799 MemPage *pPage, /* The page that contains the cell */
63800 unsigned char *pCell, /* Complete text of the cell */
63801 const void *pKey, i64 nKey, /* The key */
63802 const void *pData,int nData, /* The data */
63803 int nZero, /* Extra zero bytes to append to pData */
63804 int *pnSize /* Write cell size here */
63805 ){
63806 int nPayload;
63807 const u8 *pSrc;
63808 int nSrc, n, rc;
@@ -63822,30 +64155,27 @@
63822 assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
63823 || sqlite3PagerIswriteable(pPage->pDbPage) );
63824
63825 /* Fill in the header. */
63826 nHeader = pPage->childPtrSize;
63827 nPayload = nData + nZero;
63828 if( pPage->intKeyLeaf ){
63829 nHeader += putVarint32(&pCell[nHeader], nPayload);
63830 }else{
63831 assert( nData==0 );
63832 assert( nZero==0 );
63833 }
63834 nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey);
63835
63836 /* Fill in the payload size */
63837 if( pPage->intKey ){
63838 pSrc = pData;
63839 nSrc = nData;
63840 nData = 0;
63841 }else{
63842 assert( nKey<=0x7fffffff && pKey!=0 );
63843 nPayload = (int)nKey;
63844 pSrc = pKey;
63845 nSrc = (int)nKey;
63846 }
 
 
 
 
 
 
 
63847 if( nPayload<=pPage->maxLocal ){
63848 n = nHeader + nPayload;
63849 testcase( n==3 );
63850 testcase( n==4 );
63851 if( n<4 ) n = 4;
@@ -63879,11 +64209,11 @@
63879 #if SQLITE_DEBUG
63880 {
63881 CellInfo info;
63882 pPage->xParseCell(pPage, pCell, &info);
63883 assert( nHeader==(int)(info.pPayload - pCell) );
63884 assert( info.nKey==nKey );
63885 assert( *pnSize == info.nSize );
63886 assert( spaceLeft == info.nLocal );
63887 }
63888 #endif
63889
@@ -63964,14 +64294,10 @@
63964 nPayload -= n;
63965 pPayload += n;
63966 pSrc += n;
63967 nSrc -= n;
63968 spaceLeft -= n;
63969 if( nSrc==0 ){
63970 nSrc = nData;
63971 pSrc = pData;
63972 }
63973 }
63974 releasePage(pToRelease);
63975 return SQLITE_OK;
63976 }
63977
@@ -64034,10 +64360,12 @@
64034 ** pTemp is not null. Regardless of pTemp, allocate a new entry
64035 ** in pPage->apOvfl[] and make it point to the cell content (either
64036 ** in pTemp or the original pCell) and also record its index.
64037 ** Allocating a new entry in pPage->aCell[] implies that
64038 ** pPage->nOverflow is incremented.
 
 
64039 */
64040 static void insertCell(
64041 MemPage *pPage, /* Page into which we are copying */
64042 int i, /* New cell becomes the i-th cell of the page */
64043 u8 *pCell, /* Content of the new cell */
@@ -64049,12 +64377,11 @@
64049 int idx = 0; /* Where to write new cell content in data[] */
64050 int j; /* Loop counter */
64051 u8 *data; /* The content of the whole page */
64052 u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
64053
64054 if( *pRC ) return;
64055
64056 assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
64057 assert( MX_CELL(pPage->pBt)<=10921 );
64058 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
64059 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
64060 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
@@ -64556,12 +64883,14 @@
64556 while( (*(pCell++)&0x80) && pCell<pStop );
64557 pStop = &pCell[9];
64558 while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );
64559
64560 /* Insert the new divider cell into pParent. */
64561 insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64562 0, pPage->pgno, &rc);
 
 
64563
64564 /* Set the right-child pointer of pParent to point to the new page. */
64565 put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
64566
64567 /* Release the reference to the new page. */
@@ -65077,11 +65406,11 @@
65077 do{
65078 assert( d<nMaxCells );
65079 assert( r<nMaxCells );
65080 (void)cachedCellSize(&b, r);
65081 if( szRight!=0
65082 && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){
65083 break;
65084 }
65085 szRight += b.szCell[d] + 2;
65086 szLeft -= b.szCell[r] + 2;
65087 cntNew[i-1] = r;
@@ -65649,17 +65978,23 @@
65649 return rc;
65650 }
65651
65652
65653 /*
65654 ** Insert a new record into the BTree. The key is given by (pKey,nKey)
65655 ** and the data is given by (pData,nData). The cursor is used only to
65656 ** define what table the record should be inserted into. The cursor
65657 ** is left pointing at a random location.
65658 **
65659 ** For an INTKEY table, only the nKey value of the key is used. pKey is
65660 ** ignored. For a ZERODATA table, the pData and nData are both ignored.
 
 
 
 
 
 
65661 **
65662 ** If the seekResult parameter is non-zero, then a successful call to
65663 ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
65664 ** been performed. seekResult is the search result returned (a negative
65665 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
@@ -65672,13 +66007,11 @@
65672 ** point to any entry or to no entry at all and so this function has to seek
65673 ** the cursor before the new key can be inserted.
65674 */
65675 SQLITE_PRIVATE int sqlite3BtreeInsert(
65676 BtCursor *pCur, /* Insert data into the table of this cursor */
65677 const void *pKey, i64 nKey, /* The key of the new record */
65678 const void *pData, int nData, /* The data of the new record */
65679 int nZero, /* Number of extra 0 bytes to append to data */
65680 int appendBias, /* True if this is likely an append */
65681 int seekResult /* Result of prior MovetoUnpacked() call */
65682 ){
65683 int rc;
65684 int loc = seekResult; /* -1: before desired location +1: after */
@@ -65704,11 +66037,11 @@
65704 /* Assert that the caller has been consistent. If this cursor was opened
65705 ** expecting an index b-tree, then the caller should be inserting blob
65706 ** keys with no associated data. If the cursor was opened expecting an
65707 ** intkey table, the caller should be inserting integer keys with a
65708 ** blob of associated data. */
65709 assert( (pKey==0)==(pCur->pKeyInfo==0) );
65710
65711 /* Save the positions of any other cursors open on this table.
65712 **
65713 ** In some cases, the call to btreeMoveto() below is a no-op. For
65714 ** example, when inserting data into a table with auto-generated integer
@@ -65723,42 +66056,42 @@
65723 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
65724 if( rc ) return rc;
65725 }
65726
65727 if( pCur->pKeyInfo==0 ){
65728 assert( pKey==0 );
65729 /* If this is an insert into a table b-tree, invalidate any incrblob
65730 ** cursors open on the row being replaced */
65731 invalidateIncrblobCursors(p, nKey, 0);
65732
65733 /* If the cursor is currently on the last row and we are appending a
65734 ** new row onto the end, set the "loc" to avoid an unnecessary
65735 ** btreeMoveto() call */
65736 if( (pCur->curFlags&BTCF_ValidNKey)!=0 && nKey>0
65737 && pCur->info.nKey==nKey-1 ){
65738 loc = -1;
65739 }else if( loc==0 ){
65740 rc = sqlite3BtreeMovetoUnpacked(pCur, 0, nKey, appendBias, &loc);
65741 if( rc ) return rc;
65742 }
65743 }else if( loc==0 ){
65744 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
65745 if( rc ) return rc;
65746 }
65747 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
65748
65749 pPage = pCur->apPage[pCur->iPage];
65750 assert( pPage->intKey || nKey>=0 );
65751 assert( pPage->leaf || !pPage->intKey );
65752
65753 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
65754 pCur->pgnoRoot, nKey, nData, pPage->pgno,
65755 loc==0 ? "overwrite" : "new entry"));
65756 assert( pPage->isInit );
65757 newCell = pBt->pTmpSpace;
65758 assert( newCell!=0 );
65759 rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew);
65760 if( rc ) goto end_insert;
65761 assert( szNew==pPage->xCellSize(pPage, newCell) );
65762 assert( szNew <= MX_CELL_SIZE(pBt) );
65763 idx = pCur->aiIdx[pCur->iPage];
65764 if( loc==0 ){
@@ -65780,10 +66113,11 @@
65780 idx = ++pCur->aiIdx[pCur->iPage];
65781 }else{
65782 assert( pPage->leaf );
65783 }
65784 insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
 
65785 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
65786
65787 /* If no error has occurred and pPage has an overflow cell, call balance()
65788 ** to redistribute the cells within the tree. Since balance() may move
65789 ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey
@@ -65803,11 +66137,12 @@
65803 ** entry in the table, and the next row inserted has an integer key
65804 ** larger than the largest existing key, it is possible to insert the
65805 ** row without seeking the cursor. This can be a big performance boost.
65806 */
65807 pCur->info.nSize = 0;
65808 if( rc==SQLITE_OK && pPage->nOverflow ){
 
65809 pCur->curFlags &= ~(BTCF_ValidNKey);
65810 rc = balance(pCur);
65811
65812 /* Must make sure nOverflow is reset to zero even if the balance()
65813 ** fails. Internal data structure corruption will result otherwise.
@@ -65939,11 +66274,13 @@
65939 nCell = pLeaf->xCellSize(pLeaf, pCell);
65940 assert( MX_CELL_SIZE(pBt) >= nCell );
65941 pTmp = pBt->pTmpSpace;
65942 assert( pTmp!=0 );
65943 rc = sqlite3PagerWrite(pLeaf->pDbPage);
65944 insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
 
 
65945 dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
65946 if( rc ) return rc;
65947 }
65948
65949 /* Balance the tree. If the entry deleted was located on a leaf page,
@@ -67428,10 +67765,20 @@
67428 ** Return true if the Btree passed as the only argument is sharable.
67429 */
67430 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
67431 return p->sharable;
67432 }
 
 
 
 
 
 
 
 
 
 
67433 #endif
67434
67435 /************** End of btree.c ***********************************************/
67436 /************** Begin file backup.c ******************************************/
67437 /*
@@ -68218,12 +68565,10 @@
68218 sqlite3_backup_step(&b, 0x7FFFFFFF);
68219 assert( b.rc!=SQLITE_OK );
68220 rc = sqlite3_backup_finish(&b);
68221 if( rc==SQLITE_OK ){
68222 pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;
68223 }else{
68224 sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
68225 }
68226
68227 assert( sqlite3BtreeIsInTrans(pTo)==0 );
68228 copy_finished:
68229 sqlite3BtreeLeave(pFrom);
@@ -69225,15 +69570,11 @@
69225 assert( !VdbeMemDynamic(pMem) );
69226
69227 /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert()
69228 ** that both the BtShared and database handle mutexes are held. */
69229 assert( (pMem->flags & MEM_RowSet)==0 );
69230 if( key ){
69231 zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
69232 }else{
69233 zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
69234 }
69235 assert( zData!=0 );
69236
69237 if( offset+amt<=available ){
69238 pMem->z = &zData[offset];
69239 pMem->flags = MEM_Blob|MEM_Ephem;
@@ -70009,18 +70350,10 @@
70009 assert( p->zSql==0 );
70010 p->zSql = sqlite3DbStrNDup(p->db, z, n);
70011 p->isPrepareV2 = (u8)isPrepareV2;
70012 }
70013
70014 /*
70015 ** Return the SQL associated with a prepared statement
70016 */
70017 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
70018 Vdbe *p = (Vdbe *)pStmt;
70019 return p ? p->zSql : 0;
70020 }
70021
70022 /*
70023 ** Swap all content between two VDBE structures.
70024 */
70025 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
70026 Vdbe tmp, *pTmp;
@@ -70736,26 +71069,34 @@
70736 /*
70737 ** If the input FuncDef structure is ephemeral, then free it. If
70738 ** the FuncDef is not ephermal, then do nothing.
70739 */
70740 static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
70741 if( ALWAYS(pDef) && (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
70742 sqlite3DbFree(db, pDef);
70743 }
70744 }
70745
70746 static void vdbeFreeOpArray(sqlite3 *, Op *, int);
70747
70748 /*
70749 ** Delete a P4 value if necessary.
70750 */
 
 
 
 
 
 
 
 
70751 static void freeP4(sqlite3 *db, int p4type, void *p4){
70752 assert( db );
70753 switch( p4type ){
70754 case P4_FUNCCTX: {
70755 freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc);
70756 /* Fall through into the next case */
70757 }
70758 case P4_REAL:
70759 case P4_INT64:
70760 case P4_DYNAMIC:
70761 case P4_INTARRAY: {
@@ -70782,13 +71123,11 @@
70782 }
70783 case P4_MEM: {
70784 if( db->pnBytesFreed==0 ){
70785 sqlite3ValueFree((sqlite3_value*)p4);
70786 }else{
70787 Mem *p = (Mem*)p4;
70788 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
70789 sqlite3DbFree(db, p);
70790 }
70791 break;
70792 }
70793 case P4_VTAB : {
70794 if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
@@ -74254,12 +74593,11 @@
74254 ** than 2GiB are support - anything large must be database corruption.
74255 ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
74256 ** this code can safely assume that nCellKey is 32-bits
74257 */
74258 assert( sqlite3BtreeCursorIsValid(pCur) );
74259 VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74260 assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74261 assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
74262
74263 /* Read in the complete content of the index entry */
74264 sqlite3VdbeMemInit(&m, db, 0);
74265 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
@@ -74332,12 +74670,11 @@
74332 Mem m;
74333
74334 assert( pC->eCurType==CURTYPE_BTREE );
74335 pCur = pC->uc.pCursor;
74336 assert( sqlite3BtreeCursorIsValid(pCur) );
74337 VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74338 assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74339 /* nCellKey will always be between 0 and 0xffffffff because of the way
74340 ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
74341 if( nCellKey<=0 || nCellKey>0x7fffffff ){
74342 *res = 0;
74343 return SQLITE_CORRUPT_BKPT;
@@ -74595,16 +74932,23 @@
74595 ** Invoke the profile callback. This routine is only called if we already
74596 ** know that the profile callback is defined and needs to be invoked.
74597 */
74598 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
74599 sqlite3_int64 iNow;
 
74600 assert( p->startTime>0 );
74601 assert( db->xProfile!=0 );
74602 assert( db->init.busy==0 );
74603 assert( p->zSql!=0 );
74604 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
74605 db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
 
 
 
 
 
 
74606 p->startTime = 0;
74607 }
74608 /*
74609 ** The checkProfileCallback(DB,P) macro checks to see if a profile callback
74610 ** is needed, and it invokes the callback if it is needed.
@@ -75104,11 +75448,12 @@
75104 assert( db->nVdbeWrite>0 || db->autoCommit==0
75105 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
75106 );
75107
75108 #ifndef SQLITE_OMIT_TRACE
75109 if( db->xProfile && !db->init.busy && p->zSql ){
 
75110 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
75111 }else{
75112 assert( p->startTime==0 );
75113 }
75114 #endif
@@ -76138,10 +76483,43 @@
76138 #endif
76139 v = pVdbe->aCounter[op];
76140 if( resetFlag ) pVdbe->aCounter[op] = 0;
76141 return (int)v;
76142 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76143
76144 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
76145 /*
76146 ** Allocate and populate an UnpackedRecord structure based on the serialized
76147 ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
@@ -76185,12 +76563,11 @@
76185 /* If the old.* record has not yet been loaded into memory, do so now. */
76186 if( p->pUnpacked==0 ){
76187 u32 nRec;
76188 u8 *aRec;
76189
76190 rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec);
76191 if( rc!=SQLITE_OK ) goto preupdate_old_out;
76192 aRec = sqlite3DbMallocRaw(db, nRec);
76193 if( !aRec ) goto preupdate_old_out;
76194 rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
76195 if( rc==SQLITE_OK ){
76196 p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
@@ -76474,14 +76851,17 @@
76474 int n; /* Length of a token prefix */
76475 int nToken; /* Length of the parameter token */
76476 int i; /* Loop counter */
76477 Mem *pVar; /* Value of a host parameter */
76478 StrAccum out; /* Accumulate the output here */
 
 
 
76479 char zBase[100]; /* Initial working space */
76480
76481 db = p->db;
76482 sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase),
76483 db->aLimit[SQLITE_LIMIT_LENGTH]);
76484 if( db->nVdbeExec>1 ){
76485 while( *zRawSql ){
76486 const char *zStart = zRawSql;
76487 while( *(zRawSql++)!='\n' && *zRawSql );
@@ -76528,16 +76908,18 @@
76528 sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
76529 }else if( pVar->flags & MEM_Str ){
76530 int nOut; /* Number of bytes of the string text to include in output */
76531 #ifndef SQLITE_OMIT_UTF16
76532 u8 enc = ENC(db);
76533 Mem utf8;
76534 if( enc!=SQLITE_UTF8 ){
76535 memset(&utf8, 0, sizeof(utf8));
76536 utf8.db = db;
76537 sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
76538 sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
 
 
 
76539 pVar = &utf8;
76540 }
76541 #endif
76542 nOut = pVar->n;
76543 #ifdef SQLITE_TRACE_SIZE_LIMIT
@@ -76575,10 +76957,11 @@
76575 }
76576 #endif
76577 }
76578 }
76579 }
 
76580 return sqlite3StrAccumFinish(&out);
76581 }
76582
76583 #endif /* #ifndef SQLITE_OMIT_TRACE */
76584
@@ -77107,12 +77490,12 @@
77107 ******************************************************************************
77108 **
77109 ** This file contains inline asm code for retrieving "high-performance"
77110 ** counters for x86 class CPUs.
77111 */
77112 #ifndef _HWTIME_H_
77113 #define _HWTIME_H_
77114
77115 /*
77116 ** The following routine only works on pentium-class (or newer) processors.
77117 ** It uses the RDTSC opcode to read the cycle count value out of the
77118 ** processor and returns that value. This can be used for high-res
@@ -77176,11 +77559,11 @@
77176 */
77177 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
77178
77179 #endif
77180
77181 #endif /* !defined(_HWTIME_H_) */
77182
77183 /************** End of hwtime.h **********************************************/
77184 /************** Continuing where we left off in vdbe.c ***********************/
77185
77186 #endif
@@ -78055,10 +78438,14 @@
78055 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
78056 sqlite3VdbeMemNulTerminate(&pMem[i]);
78057 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
78058 }
78059 if( db->mallocFailed ) goto no_mem;
 
 
 
 
78060
78061 /* Return SQLITE_ROW
78062 */
78063 p->pc = (int)(pOp - aOp) + 1;
78064 rc = SQLITE_ROW;
@@ -78689,10 +79076,11 @@
78689 affinity = pOp->p5 & SQLITE_AFF_MASK;
78690 if( affinity>=SQLITE_AFF_NUMERIC ){
78691 if( (flags1 | flags3)&MEM_Str ){
78692 if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
78693 applyNumericAffinity(pIn1,0);
 
78694 }
78695 if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
78696 applyNumericAffinity(pIn3,0);
78697 }
78698 }
@@ -78701,10 +79089,11 @@
78701 testcase( pIn1->flags & MEM_Int );
78702 testcase( pIn1->flags & MEM_Real );
78703 sqlite3VdbeMemStringify(pIn1, encoding, 1);
78704 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
78705 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
 
78706 }
78707 if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
78708 testcase( pIn3->flags & MEM_Int );
78709 testcase( pIn3->flags & MEM_Real );
78710 sqlite3VdbeMemStringify(pIn3, encoding, 1);
@@ -79053,11 +79442,10 @@
79053 ** the result is guaranteed to only be used as the argument of a length()
79054 ** or typeof() function, respectively. The loading of large blobs can be
79055 ** skipped for length() and all content loading can be skipped for typeof().
79056 */
79057 case OP_Column: {
79058 i64 payloadSize64; /* Number of bytes in the record */
79059 int p2; /* column number to retrieve */
79060 VdbeCursor *pC; /* The VDBE cursor */
79061 BtCursor *pCrsr; /* The BTree cursor */
79062 u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
79063 int len; /* The length of the serialized data for the column */
@@ -79076,10 +79464,11 @@
79076 pC = p->apCsr[pOp->p1];
79077 p2 = pOp->p2;
79078
79079 /* If the cursor cache is stale, bring it up-to-date */
79080 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
 
79081
79082 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
79083 pDest = &aMem[pOp->p3];
79084 memAboutToChange(p, pDest);
79085 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -79089,12 +79478,11 @@
79089 assert( pC->eCurType!=CURTYPE_VTAB );
79090 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
79091 assert( pC->eCurType!=CURTYPE_SORTER );
79092 pCrsr = pC->uc.pCursor;
79093
79094 if( rc ) goto abort_due_to_error;
79095 if( pC->cacheStatus!=p->cacheCtr ){
79096 if( pC->nullRow ){
79097 if( pC->eCurType==CURTYPE_PSEUDO ){
79098 assert( pC->uc.pseudoTableReg>0 );
79099 pReg = &aMem[pC->uc.pseudoTableReg];
79100 assert( pReg->flags & MEM_Blob );
@@ -79106,26 +79494,13 @@
79106 goto op_column_out;
79107 }
79108 }else{
79109 assert( pC->eCurType==CURTYPE_BTREE );
79110 assert( pCrsr );
79111 if( pC->isTable==0 ){
79112 assert( sqlite3BtreeCursorIsValid(pCrsr) );
79113 VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64);
79114 assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
79115 /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the
79116 ** payload size, so it is impossible for payloadSize64 to be
79117 ** larger than 32 bits. */
79118 assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 );
79119 pC->aRow = sqlite3BtreeKeyFetch(pCrsr, &avail);
79120 pC->payloadSize = (u32)payloadSize64;
79121 }else{
79122 assert( sqlite3BtreeCursorIsValid(pCrsr) );
79123 VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &pC->payloadSize);
79124 assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
79125 pC->aRow = sqlite3BtreeDataFetch(pCrsr, &avail);
79126 }
79127 assert( avail<=65536 ); /* Maximum page size is 64KiB */
79128 if( pC->payloadSize <= (u32)avail ){
79129 pC->szRow = pC->payloadSize;
79130 }else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
79131 goto too_big;
@@ -79137,11 +79512,11 @@
79137 pC->iHdrOffset = getVarint32(pC->aRow, offset);
79138 pC->nHdrParsed = 0;
79139 aOffset[0] = offset;
79140
79141
79142 if( avail<offset ){
79143 /* pC->aRow does not have to hold the entire row, but it does at least
79144 ** need to cover the header of the record. If pC->aRow does not contain
79145 ** the complete header, then set it to zero, forcing the header to be
79146 ** dynamically allocated. */
79147 pC->aRow = 0;
@@ -79158,28 +79533,28 @@
79158 */
79159 if( offset > 98307 || offset > pC->payloadSize ){
79160 rc = SQLITE_CORRUPT_BKPT;
79161 goto abort_due_to_error;
79162 }
79163 }
79164
79165 /* The following goto is an optimization. It can be omitted and
79166 ** everything will still work. But OP_Column is measurably faster
79167 ** by skipping the subsequent conditional, which is always true.
79168 */
79169 assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79170 goto op_column_read_header;
 
79171 }
79172
79173 /* Make sure at least the first p2+1 entries of the header have been
79174 ** parsed and valid information is in aOffset[] and pC->aType[].
79175 */
79176 if( pC->nHdrParsed<=p2 ){
79177 /* If there is more header available for parsing in the record, try
79178 ** to extract additional fields up through the p2+1-th field
79179 */
79180 op_column_read_header:
79181 if( pC->iHdrOffset<aOffset[0] ){
79182 /* Make sure zData points to enough of the record to cover the header. */
79183 if( pC->aRow==0 ){
79184 memset(&sMem, 0, sizeof(sMem));
79185 rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
@@ -79188,15 +79563,15 @@
79188 }else{
79189 zData = pC->aRow;
79190 }
79191
79192 /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
 
79193 i = pC->nHdrParsed;
79194 offset64 = aOffset[i];
79195 zHdr = zData + pC->iHdrOffset;
79196 zEndHdr = zData + aOffset[0];
79197 assert( i<=p2 && zHdr<zEndHdr );
79198 do{
79199 if( (t = zHdr[0])<0x80 ){
79200 zHdr++;
79201 offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
79202 }else{
@@ -79204,13 +79579,11 @@
79204 offset64 += sqlite3VdbeSerialTypeLen(t);
79205 }
79206 pC->aType[i++] = t;
79207 aOffset[i] = (u32)(offset64 & 0xffffffff);
79208 }while( i<=p2 && zHdr<zEndHdr );
79209 pC->nHdrParsed = i;
79210 pC->iHdrOffset = (u32)(zHdr - zData);
79211
79212 /* The record is corrupt if any of the following are true:
79213 ** (1) the bytes of the header extend past the declared header size
79214 ** (2) the entire header was used but not all data was used
79215 ** (3) the end of the data extends beyond the end of the record.
79216 */
@@ -79219,12 +79592,14 @@
79219 ){
79220 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79221 rc = SQLITE_CORRUPT_BKPT;
79222 goto abort_due_to_error;
79223 }
 
 
 
79224 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79225
79226 }else{
79227 t = 0;
79228 }
79229
79230 /* If after trying to extract new entries from the header, nHdrParsed is
@@ -79248,13 +79623,14 @@
79248 ** all valid.
79249 */
79250 assert( p2<pC->nHdrParsed );
79251 assert( rc==SQLITE_OK );
79252 assert( sqlite3VdbeCheckMemInvariants(pDest) );
79253 if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest);
 
 
79254 assert( t==pC->aType[p2] );
79255 pDest->enc = encoding;
79256 if( pC->szRow>=aOffset[p2+1] ){
79257 /* This is the common case where the desired content fits on the original
79258 ** page - where the content is not on an overflow page */
79259 zData = pC->aRow + aOffset[p2];
79260 if( t<12 ){
@@ -79264,10 +79640,11 @@
79264 ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent
79265 ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().
79266 */
79267 static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
79268 pDest->n = len = (t-12)/2;
 
79269 if( pDest->szMalloc < len+2 ){
79270 pDest->flags = MEM_Null;
79271 if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
79272 }else{
79273 pDest->z = pDest->zMalloc;
@@ -79276,10 +79653,11 @@
79276 pDest->z[len] = 0;
79277 pDest->z[len+1] = 0;
79278 pDest->flags = aFlag[t&1];
79279 }
79280 }else{
 
79281 /* This branch happens only when content is on overflow pages */
79282 if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
79283 && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))
79284 || (len = sqlite3VdbeSerialTypeLen(t))==0
79285 ){
@@ -80693,10 +81071,34 @@
80693 if( takeJump || !alreadyExists ) goto jump_to_p2;
80694 }
80695 break;
80696 }
80697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80698 /* Opcode: NotExists P1 P2 P3 * *
80699 ** Synopsis: intkey=r[P3]
80700 **
80701 ** P1 is the index of a cursor open on an SQL table btree (with integer
80702 ** keys). P3 is an integer rowid. If P1 does not contain a record with
@@ -80703,26 +81105,37 @@
80703 ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an
80704 ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then
80705 ** leave the cursor pointing at that record and fall through to the next
80706 ** instruction.
80707 **
 
 
 
 
80708 ** The OP_NotFound opcode performs the same operation on index btrees
80709 ** (with arbitrary multi-value keys).
80710 **
80711 ** This opcode leaves the cursor in a state where it cannot be advanced
80712 ** in either direction. In other words, the Next and Prev opcodes will
80713 ** not work following this opcode.
80714 **
80715 ** See also: Found, NotFound, NoConflict
80716 */
80717 case OP_NotExists: { /* jump, in3 */
80718 VdbeCursor *pC;
80719 BtCursor *pCrsr;
80720 int res;
80721 u64 iKey;
80722
80723 pIn3 = &aMem[pOp->p3];
 
 
 
 
 
 
 
80724 assert( pIn3->flags & MEM_Int );
80725 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
80726 pC = p->apCsr[pOp->p1];
80727 assert( pC!=0 );
80728 #ifdef SQLITE_DEBUG
@@ -80836,12 +81249,11 @@
80836 }
80837 if( res ){
80838 v = 1; /* IMP: R-61914-48074 */
80839 }else{
80840 assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );
80841 rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
80842 assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
80843 if( v>=MAX_ROWID ){
80844 pC->useRandomRowid = 1;
80845 }else{
80846 v++; /* IMP: R-29538-34987 */
80847 }
@@ -80920,14 +81332,16 @@
80920 ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
80921 ** then rowid is stored for subsequent return by the
80922 ** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
80923 **
80924 ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
80925 ** the last seek operation (OP_NotExists) was a success, then this
 
80926 ** operation will not attempt to find the appropriate row before doing
80927 ** the insert but will instead overwrite the row that the cursor is
80928 ** currently pointing to. Presumably, the prior OP_NotExists opcode
 
80929 ** has already positioned the cursor correctly. This is an optimization
80930 ** that boosts performance by avoiding redundant seeks.
80931 **
80932 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
80933 ** UPDATE operation. Otherwise (if the flag is clear) then this opcode
@@ -80955,17 +81369,16 @@
80955 */
80956 case OP_Insert:
80957 case OP_InsertInt: {
80958 Mem *pData; /* MEM cell holding data for the record to be inserted */
80959 Mem *pKey; /* MEM cell holding key for the record */
80960 i64 iKey; /* The integer ROWID or key for the record to be inserted */
80961 VdbeCursor *pC; /* Cursor to table into which insert is written */
80962 int nZero; /* Number of zero-bytes to append */
80963 int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
80964 const char *zDb; /* database name - used by the update hook */
80965 Table *pTab; /* Table structure - used by update and pre-update hooks */
80966 int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
 
80967
80968 op = 0;
80969 pData = &aMem[pOp->p2];
80970 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
80971 assert( memIsValid(pData) );
@@ -80980,14 +81393,14 @@
80980 if( pOp->opcode==OP_Insert ){
80981 pKey = &aMem[pOp->p3];
80982 assert( pKey->flags & MEM_Int );
80983 assert( memIsValid(pKey) );
80984 REGISTER_TRACE(pOp->p3, pKey);
80985 iKey = pKey->u.i;
80986 }else{
80987 assert( pOp->opcode==OP_InsertInt );
80988 iKey = pOp->p3;
80989 }
80990
80991 if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
80992 assert( pC->isTable );
80993 assert( pC->iDb>=0 );
@@ -81004,39 +81417,41 @@
81004 /* Invoke the pre-update hook, if any */
81005 if( db->xPreUpdateCallback
81006 && pOp->p4type==P4_TABLE
81007 && !(pOp->p5 & OPFLAG_ISUPDATE)
81008 ){
81009 sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
81010 }
81011 #endif
81012
81013 if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
81014 if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey;
81015 if( pData->flags & MEM_Null ){
81016 pData->z = 0;
81017 pData->n = 0;
81018 }else{
81019 assert( pData->flags & (MEM_Blob|MEM_Str) );
 
 
81020 }
81021 seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);
81022 if( pData->flags & MEM_Zero ){
81023 nZero = pData->u.nZero;
81024 }else{
81025 nZero = 0;
81026 }
81027 rc = sqlite3BtreeInsert(pC->uc.pCursor, 0, iKey,
81028 pData->z, pData->n, nZero,
81029 (pOp->p5 & OPFLAG_APPEND)!=0, seekResult
81030 );
81031 pC->deferredMoveto = 0;
81032 pC->cacheStatus = CACHE_STALE;
81033
81034 /* Invoke the update-hook if required. */
81035 if( rc ) goto abort_due_to_error;
81036 if( db->xUpdateCallback && op ){
81037 db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
81038 }
81039 break;
81040 }
81041
81042 /* Opcode: Delete P1 P2 P3 P4 P5
@@ -81091,12 +81506,11 @@
81091 #ifdef SQLITE_DEBUG
81092 if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
81093 /* If p5 is zero, the seek operation that positioned the cursor prior to
81094 ** OP_Delete will have also set the pC->movetoTarget field to the rowid of
81095 ** the row that is being deleted */
81096 i64 iKey = 0;
81097 sqlite3BtreeKeySize(pC->uc.pCursor, &iKey);
81098 assert( pC->movetoTarget==iKey );
81099 }
81100 #endif
81101
81102 /* If the update-hook or pre-update-hook will be invoked, set zDb to
@@ -81108,11 +81522,11 @@
81108 assert( pC->iDb>=0 );
81109 assert( pOp->p4.pTab!=0 );
81110 zDb = db->aDb[pC->iDb].zName;
81111 pTab = pOp->p4.pTab;
81112 if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
81113 sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
81114 }
81115 }else{
81116 zDb = 0; /* Not needed. Silence a compiler warning. */
81117 pTab = 0; /* Not needed. Silence a compiler warning. */
81118 }
@@ -81262,11 +81676,10 @@
81262 case OP_RowKey:
81263 case OP_RowData: {
81264 VdbeCursor *pC;
81265 BtCursor *pCrsr;
81266 u32 n;
81267 i64 n64;
81268
81269 pOut = &aMem[pOp->p2];
81270 memAboutToChange(p, pOut);
81271
81272 /* Note that RowKey and RowData are really exactly the same instruction */
@@ -81280,12 +81693,13 @@
81280 assert( pC->nullRow==0 );
81281 assert( pC->uc.pCursor!=0 );
81282 pCrsr = pC->uc.pCursor;
81283
81284 /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
81285 ** OP_Rewind/Op_Next with no intervening instructions that might invalidate
81286 ** the cursor. If this where not the case, on of the following assert()s
 
81287 ** would fail. Should this ever change (because of changes in the code
81288 ** generator) then the fix would be to insert a call to
81289 ** sqlite3VdbeCursorMoveto().
81290 */
81291 assert( pC->deferredMoveto==0 );
@@ -81293,24 +81707,13 @@
81293 #if 0 /* Not required due to the previous to assert() statements */
81294 rc = sqlite3VdbeCursorMoveto(pC);
81295 if( rc!=SQLITE_OK ) goto abort_due_to_error;
81296 #endif
81297
81298 if( pC->isTable==0 ){
81299 assert( !pC->isTable );
81300 VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64);
81301 assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
81302 if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
81303 goto too_big;
81304 }
81305 n = (u32)n64;
81306 }else{
81307 VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n);
81308 assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
81309 if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81310 goto too_big;
81311 }
81312 }
81313 testcase( n==0 );
81314 if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
81315 goto no_mem;
81316 }
@@ -81371,12 +81774,11 @@
81371 if( rc ) goto abort_due_to_error;
81372 if( pC->nullRow ){
81373 pOut->flags = MEM_Null;
81374 break;
81375 }
81376 rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
81377 assert( rc==SQLITE_OK ); /* Always so because of CursorRestore() above */
81378 }
81379 pOut->u.i = v;
81380 break;
81381 }
81382
@@ -81647,12 +82049,11 @@
81647 ** for tables is OP_Insert.
81648 */
81649 case OP_SorterInsert: /* in2 */
81650 case OP_IdxInsert: { /* in2 */
81651 VdbeCursor *pC;
81652 int nKey;
81653 const char *zKey;
81654
81655 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
81656 pC = p->apCsr[pOp->p1];
81657 assert( pC!=0 );
81658 assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
@@ -81664,13 +82065,16 @@
81664 rc = ExpandBlob(pIn2);
81665 if( rc ) goto abort_due_to_error;
81666 if( pOp->opcode==OP_SorterInsert ){
81667 rc = sqlite3VdbeSorterWrite(pC, pIn2);
81668 }else{
81669 nKey = pIn2->n;
81670 zKey = pIn2->z;
81671 rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3,
 
 
 
81672 ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
81673 );
81674 assert( pC->deferredMoveto==0 );
81675 pC->cacheStatus = CACHE_STALE;
81676 }
@@ -83437,17 +83841,25 @@
83437 case OP_Init: { /* jump */
83438 char *zTrace;
83439 char *z;
83440
83441 #ifndef SQLITE_OMIT_TRACE
83442 if( db->xTrace
83443 && !p->doingRerun
83444 && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
83445 ){
83446 z = sqlite3VdbeExpandSql(p, zTrace);
83447 db->xTrace(db->pTraceArg, z);
83448 sqlite3DbFree(db, z);
 
 
 
 
 
 
 
 
83449 }
83450 #ifdef SQLITE_USE_FCNTL_TRACE
83451 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
83452 if( zTrace ){
83453 int i;
@@ -84026,11 +84438,11 @@
84026 ** slightly more efficient). Since you cannot write to a PK column
84027 ** using the incremental-blob API, this works. For the sessions module
84028 ** anyhow.
84029 */
84030 sqlite3_int64 iKey;
84031 sqlite3BtreeKeySize(p->pCsr, &iKey);
84032 sqlite3VdbePreUpdateHook(
84033 v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
84034 );
84035 }
84036 #endif
@@ -85461,41 +85873,47 @@
85461 }
85462
85463
85464 /*
85465 ** Merge the two sorted lists p1 and p2 into a single list.
85466 ** Set *ppOut to the head of the new list.
85467 */
85468 static void vdbeSorterMerge(
85469 SortSubtask *pTask, /* Calling thread context */
85470 SorterRecord *p1, /* First list to merge */
85471 SorterRecord *p2, /* Second list to merge */
85472 SorterRecord **ppOut /* OUT: Head of merged list */
85473 ){
85474 SorterRecord *pFinal = 0;
85475 SorterRecord **pp = &pFinal;
85476 int bCached = 0;
85477
85478 while( p1 && p2 ){
 
85479 int res;
85480 res = pTask->xCompare(
85481 pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
85482 );
85483
85484 if( res<=0 ){
85485 *pp = p1;
85486 pp = &p1->u.pNext;
85487 p1 = p1->u.pNext;
 
 
 
 
85488 }else{
85489 *pp = p2;
85490 pp = &p2->u.pNext;
85491 p2 = p2->u.pNext;
85492 bCached = 0;
 
 
 
 
85493 }
85494 }
85495 *pp = p1 ? p1 : p2;
85496 *ppOut = pFinal;
85497 }
85498
85499 /*
85500 ** Return the SorterCompare function to compare values collected by the
85501 ** sorter object passed as the only argument.
@@ -85544,20 +85962,21 @@
85544 pNext = p->u.pNext;
85545 }
85546
85547 p->u.pNext = 0;
85548 for(i=0; aSlot[i]; i++){
85549 vdbeSorterMerge(pTask, p, aSlot[i], &p);
85550 aSlot[i] = 0;
85551 }
85552 aSlot[i] = p;
85553 p = pNext;
85554 }
85555
85556 p = 0;
85557 for(i=0; i<64; i++){
85558 vdbeSorterMerge(pTask, p, aSlot[i], &p);
 
85559 }
85560 pList->pList = p;
85561
85562 sqlite3_free(aSlot);
85563 assert( pTask->pUnpacked->errCode==SQLITE_OK
@@ -90773,10 +91192,15 @@
90773 VdbeComment((v, "%s", pIdx->zName));
90774 assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
90775 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
90776
90777 if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
 
 
 
 
 
90778 *prRhsHasNull = ++pParse->nMem;
90779 sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
90780 }
90781 sqlite3VdbeJumpHere(v, iAddr);
90782 }
@@ -90785,11 +91209,11 @@
90785 }
90786
90787 /* If no preexisting index is available for the IN clause
90788 ** and IN_INDEX_NOOP is an allowed reply
90789 ** and the RHS of the IN operator is a list, not a subquery
90790 ** and the RHS is not contant or has two or fewer terms,
90791 ** then it is not worth creating an ephemeral table to evaluate
90792 ** the IN operator so return IN_INDEX_NOOP.
90793 */
90794 if( eType==0
90795 && (inFlags & IN_INDEX_NOOP_OK)
@@ -91177,12 +91601,11 @@
91177 }
91178
91179 if( eType==IN_INDEX_ROWID ){
91180 /* In this case, the RHS is the ROWID of table b-tree
91181 */
91182 sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); VdbeCoverage(v);
91183 sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
91184 VdbeCoverage(v);
91185 }else{
91186 /* In this case, the RHS is an index b-tree.
91187 */
91188 sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
@@ -91491,11 +91914,11 @@
91491 if( iCol<0 || iCol==pTab->iPKey ){
91492 sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
91493 }else{
91494 int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
91495 int x = iCol;
91496 if( !HasRowid(pTab) ){
91497 x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
91498 }
91499 sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
91500 }
91501 if( iCol>=0 ){
@@ -93870,10 +94293,11 @@
93870 char *zCol; /* Null-terminated column definition */
93871 Column *pCol; /* The new column */
93872 Expr *pDflt; /* Default value for the new column */
93873 sqlite3 *db; /* The database connection; */
93874 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
 
93875
93876 db = pParse->db;
93877 if( pParse->nErr || db->mallocFailed ) return;
93878 assert( v!=0 );
93879 pNew = pParse->pNewTable;
@@ -93964,20 +94388,22 @@
93964 );
93965 sqlite3DbFree(db, zCol);
93966 db->flags = savedDbFlags;
93967 }
93968
93969 /* If the default value of the new column is NULL, then the file
93970 ** format to 2. If the default value of the new column is not NULL,
93971 ** the file format be 3. Back when this feature was first added
93972 ** in 2006, we went to the trouble to upgrade the file format to the
93973 ** minimum support values. But 10-years on, we can assume that all
93974 ** extent versions of SQLite support file-format 4, so we always and
93975 ** unconditionally upgrade to 4.
93976 */
93977 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT,
93978 SQLITE_MAX_FILE_FORMAT);
 
 
 
 
 
 
93979
93980 /* Reload the schema of the modified table. */
93981 reloadTableSchema(pParse, pTab, pTab->zName);
93982 }
93983
@@ -97152,11 +97578,11 @@
97152 ** routine leaves an error message in pParse->zErrMsg where
97153 ** sqlite3FindTable() does not.
97154 */
97155 SQLITE_PRIVATE Table *sqlite3LocateTable(
97156 Parse *pParse, /* context in which to report errors */
97157 int isView, /* True if looking for a VIEW rather than a TABLE */
97158 const char *zName, /* Name of the table we are looking for */
97159 const char *zDbase /* Name of the database. Might be NULL */
97160 ){
97161 Table *p;
97162
@@ -97166,11 +97592,11 @@
97166 return 0;
97167 }
97168
97169 p = sqlite3FindTable(pParse->db, zName, zDbase);
97170 if( p==0 ){
97171 const char *zMsg = isView ? "no such view" : "no such table";
97172 #ifndef SQLITE_OMIT_VIRTUALTABLE
97173 if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
97174 /* If zName is the not the name of a table in the schema created using
97175 ** CREATE, then check to see if it is the name of an virtual table that
97176 ** can be an eponymous virtual table. */
@@ -97178,16 +97604,18 @@
97178 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
97179 return pMod->pEpoTab;
97180 }
97181 }
97182 #endif
97183 if( zDbase ){
97184 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97185 }else{
97186 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
 
 
 
97187 }
97188 pParse->checkSchema = 1;
97189 }
97190
97191 return p;
97192 }
97193
@@ -97200,11 +97628,11 @@
97200 ** non-NULL if it is part of a view or trigger program definition. See
97201 ** sqlite3FixSrcList() for details.
97202 */
97203 SQLITE_PRIVATE Table *sqlite3LocateTableItem(
97204 Parse *pParse,
97205 int isView,
97206 struct SrcList_item *p
97207 ){
97208 const char *zDb;
97209 assert( p->pSchema==0 || p->zDatabase==0 );
97210 if( p->pSchema ){
@@ -97211,11 +97639,11 @@
97211 int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
97212 zDb = pParse->db->aDb[iDb].zName;
97213 }else{
97214 zDb = p->zDatabase;
97215 }
97216 return sqlite3LocateTable(pParse, isView, p->zName, zDb);
97217 }
97218
97219 /*
97220 ** Locate the in-memory structure that describes
97221 ** a particular index given the name of that index
@@ -97419,12 +97847,13 @@
97419 db->lookaside.nOut : 0 );
97420
97421 /* Delete all indices associated with this table. */
97422 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
97423 pNext = pIndex->pNext;
97424 assert( pIndex->pSchema==pTable->pSchema );
97425 if( !db || db->pnBytesFreed==0 ){
 
97426 char *zName = pIndex->zName;
97427 TESTONLY ( Index *pOld = ) sqlite3HashInsert(
97428 &pIndex->pSchema->idxHash, zName, 0
97429 );
97430 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
@@ -98102,11 +98531,11 @@
98102 ){
98103 Table *pTab = pParse->pNewTable;
98104 Column *pCol = 0;
98105 int iCol = -1, i;
98106 int nTerm;
98107 if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;
98108 if( pTab->tabFlags & TF_HasPrimaryKey ){
98109 sqlite3ErrorMsg(pParse,
98110 "table \"%s\" has more than one primary key", pTab->zName);
98111 goto primary_key_exit;
98112 }
@@ -98148,16 +98577,12 @@
98148 #ifndef SQLITE_OMIT_AUTOINCREMENT
98149 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
98150 "INTEGER PRIMARY KEY");
98151 #endif
98152 }else{
98153 Index *p;
98154 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98155 0, sortOrder, 0);
98156 if( p ){
98157 p->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
98158 }
98159 pList = 0;
98160 }
98161
98162 primary_key_exit:
98163 sqlite3ExprListDelete(pParse->db, pList);
@@ -98470,33 +98895,49 @@
98470 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
98471 ** internal schema data structures and the generated VDBE code so that they
98472 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
98473 ** Changes include:
98474 **
98475 ** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is
 
98476 ** no rowid btree for a WITHOUT ROWID. Instead, the canonical
98477 ** data storage is a covering index btree.
98478 ** (2) Bypass the creation of the sqlite_master table entry
98479 ** for the PRIMARY KEY as the primary key index is now
98480 ** identified by the sqlite_master table entry of the table itself.
98481 ** (3) Set the Index.tnum of the PRIMARY KEY Index object in the
98482 ** schema to the rootpage from the main table.
98483 ** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
98484 ** (5) Add all table columns to the PRIMARY KEY Index object
98485 ** so that the PRIMARY KEY is a covering index. The surplus
98486 ** columns are part of KeyInfo.nXField and are not used for
98487 ** sorting or lookup or uniqueness checks.
98488 ** (6) Replace the rowid tail on all automatically generated UNIQUE
98489 ** indices with the PRIMARY KEY columns.
 
 
98490 */
98491 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
98492 Index *pIdx;
98493 Index *pPk;
98494 int nPk;
98495 int i, j;
98496 sqlite3 *db = pParse->db;
98497 Vdbe *v = pParse->pVdbe;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98498
98499 /* Convert the OP_CreateTable opcode that would normally create the
98500 ** root-page for the table into an OP_CreateIndex opcode. The index
98501 ** created will become the PRIMARY KEY index.
98502 */
@@ -98515,13 +98956,14 @@
98515 pList = sqlite3ExprListAppend(pParse, 0,
98516 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
98517 if( pList==0 ) return;
98518 pList->a[0].sortOrder = pParse->iPkSortOrder;
98519 assert( pParse->pNewTable==pTab );
98520 pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0);
98521 if( pPk==0 ) return;
98522 pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
 
98523 pTab->iPKey = -1;
98524 }else{
98525 pPk = sqlite3PrimaryKeyIndex(pTab);
98526
98527 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
@@ -98545,23 +98987,15 @@
98545 pPk->aiColumn[j++] = pPk->aiColumn[i];
98546 }
98547 }
98548 pPk->nKeyCol = j;
98549 }
98550 pPk->isCovering = 1;
98551 assert( pPk!=0 );
 
 
98552 nPk = pPk->nKeyCol;
98553
98554 /* Make sure every column of the PRIMARY KEY is NOT NULL. (Except,
98555 ** do not enforce this for imposter tables.) */
98556 if( !db->init.imposterTable ){
98557 for(i=0; i<nPk; i++){
98558 pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort;
98559 }
98560 pPk->uniqNotNull = 1;
98561 }
98562
98563 /* The root page of the PRIMARY KEY is the table root page */
98564 pPk->tnum = pTab->tnum;
98565
98566 /* Update the in-memory representation of all UNIQUE indices by converting
98567 ** the final rowid column into one or more columns of the PRIMARY KEY.
@@ -99312,10 +99746,11 @@
99312 }
99313 assert( pParse->nErr==0 );
99314 assert( pName->nSrc==1 );
99315 if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
99316 if( noErr ) db->suppressErr++;
 
99317 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
99318 if( noErr ) db->suppressErr--;
99319
99320 if( pTab==0 ){
99321 if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
@@ -99682,28 +100117,24 @@
99682 ** currently being constructed by a CREATE TABLE statement.
99683 **
99684 ** pList is a list of columns to be indexed. pList will be NULL if this
99685 ** is a primary key or unique-constraint on the most recent column added
99686 ** to the table currently under construction.
99687 **
99688 ** If the index is created successfully, return a pointer to the new Index
99689 ** structure. This is used by sqlite3AddPrimaryKey() to mark the index
99690 ** as the tables primary key (Index.idxType==SQLITE_IDXTYPE_PRIMARYKEY)
99691 */
99692 SQLITE_PRIVATE Index *sqlite3CreateIndex(
99693 Parse *pParse, /* All information about this parse */
99694 Token *pName1, /* First part of index name. May be NULL */
99695 Token *pName2, /* Second part of index name. May be NULL */
99696 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
99697 ExprList *pList, /* A list of columns to be indexed */
99698 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
99699 Token *pStart, /* The CREATE token that begins this statement */
99700 Expr *pPIWhere, /* WHERE clause for partial indices */
99701 int sortOrder, /* Sort order of primary key when pList==NULL */
99702 int ifNotExist /* Omit error if index already exists */
 
99703 ){
99704 Index *pRet = 0; /* Pointer to return */
99705 Table *pTab = 0; /* Table to be indexed */
99706 Index *pIndex = 0; /* The index to be created */
99707 char *zName = 0; /* Name of the index */
99708 int nName; /* Number of characters in zName */
99709 int i, j;
@@ -99717,11 +100148,14 @@
99717 int nExtra = 0; /* Space allocated for zExtra[] */
99718 int nExtraCol; /* Number of extra columns needed */
99719 char *zExtra = 0; /* Extra space after the Index object */
99720 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
99721
99722 if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){
 
 
 
99723 goto exit_create_index;
99724 }
99725 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
99726 goto exit_create_index;
99727 }
@@ -99906,11 +100340,11 @@
99906 zExtra += nName + 1;
99907 memcpy(pIndex->zName, zName, nName+1);
99908 pIndex->pTable = pTab;
99909 pIndex->onError = (u8)onError;
99910 pIndex->uniqNotNull = onError!=OE_None;
99911 pIndex->idxType = pName ? SQLITE_IDXTYPE_APPDEF : SQLITE_IDXTYPE_UNIQUE;
99912 pIndex->pSchema = db->aDb[iDb].pSchema;
99913 pIndex->nKeyCol = pList->nExpr;
99914 if( pPIWhere ){
99915 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
99916 pIndex->pPartIdxWhere = pPIWhere;
@@ -100086,11 +100520,11 @@
100086 }
100087 if( pIdx->onError==OE_Default ){
100088 pIdx->onError = pIndex->onError;
100089 }
100090 }
100091 pRet = pIdx;
100092 goto exit_create_index;
100093 }
100094 }
100095 }
100096
@@ -100098,10 +100532,11 @@
100098 ** in-memory database structures.
100099 */
100100 assert( pParse->nErr==0 );
100101 if( db->init.busy ){
100102 Index *p;
 
100103 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
100104 p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
100105 pIndex->zName, pIndex);
100106 if( p ){
100107 assert( p==pIndex ); /* Malloc must have failed */
@@ -100179,11 +100614,11 @@
100179 if( pTblName ){
100180 sqlite3RefillIndex(pParse, pIndex, iMem);
100181 sqlite3ChangeCookie(pParse, iDb);
100182 sqlite3VdbeAddParseSchemaOp(v, iDb,
100183 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
100184 sqlite3VdbeAddOp1(v, OP_Expire, 0);
100185 }
100186
100187 sqlite3VdbeJumpHere(v, pIndex->tnum);
100188 }
100189
@@ -100204,11 +100639,10 @@
100204 pOther = pOther->pNext;
100205 }
100206 pIndex->pNext = pOther->pNext;
100207 pOther->pNext = pIndex;
100208 }
100209 pRet = pIndex;
100210 pIndex = 0;
100211 }
100212
100213 /* Clean up before exiting */
100214 exit_create_index:
@@ -100215,11 +100649,10 @@
100215 if( pIndex ) freeIndex(db, pIndex);
100216 sqlite3ExprDelete(db, pPIWhere);
100217 sqlite3ExprListDelete(db, pList);
100218 sqlite3SrcListDelete(db, pTblName);
100219 sqlite3DbFree(db, zName);
100220 return pRet;
100221 }
100222
100223 /*
100224 ** Fill the Index.aiRowEst[] array with default information - information
100225 ** to be used when we have not run the ANALYZE command.
@@ -100244,14 +100677,15 @@
100244 LogEst *a = pIdx->aiRowLogEst;
100245 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
100246 int i;
100247
100248 /* Set the first entry (number of rows in the index) to the estimated
100249 ** number of rows in the table. Or 10, if the estimated number of rows
100250 ** in the table is less than that. */
100251 a[0] = pIdx->pTable->nRowLogEst;
100252 if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
 
100253
100254 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
100255 ** 6 and each subsequent value (if any) is 5. */
100256 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
100257 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
@@ -101129,14 +101563,10 @@
101129 #endif
101130
101131 /*
101132 ** Return a KeyInfo structure that is appropriate for the given Index.
101133 **
101134 ** The KeyInfo structure for an index is cached in the Index object.
101135 ** So there might be multiple references to the returned pointer. The
101136 ** caller should not try to modify the KeyInfo object.
101137 **
101138 ** The caller should invoke sqlite3KeyInfoUnref() on the returned object
101139 ** when it has finished using it.
101140 */
101141 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
101142 int i;
@@ -103364,11 +103794,11 @@
103364 continue;
103365 }
103366 }
103367 c2 = Utf8Read(zString);
103368 if( c==c2 ) continue;
103369 if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
103370 continue;
103371 }
103372 if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
103373 return 0;
103374 }
@@ -105823,11 +106253,12 @@
105823 */
105824 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
105825 FKey *pFKey; /* Iterator variable */
105826 FKey *pNext; /* Copy of pFKey->pNextFrom */
105827
105828 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
 
105829 for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
105830
105831 /* Remove the FK from the fkeyHash hash table. */
105832 if( !db || db->pnBytesFreed==0 ){
105833 if( pFKey->pPrevTo ){
@@ -108233,12 +108664,12 @@
108233 ** shared libraries that want to be imported as extensions into
108234 ** an SQLite instance. Shared libraries that intend to be loaded
108235 ** as extensions by SQLite should #include this file instead of
108236 ** sqlite3.h.
108237 */
108238 #ifndef _SQLITE3EXT_H_
108239 #define _SQLITE3EXT_H_
108240 /* #include "sqlite3.h" */
108241
108242 typedef struct sqlite3_api_routines sqlite3_api_routines;
108243
108244 /*
@@ -108499,10 +108930,13 @@
108499 int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
108500 int (*strlike)(const char*,const char*,unsigned int);
108501 int (*db_cacheflush)(sqlite3*);
108502 /* Version 3.12.0 and later */
108503 int (*system_errno)(sqlite3*);
 
 
 
108504 };
108505
108506 /*
108507 ** The following macros redefine the API routines so that they are
108508 ** redirected through the global sqlite3_api structure.
@@ -108744,10 +109178,13 @@
108744 #define sqlite3_status64 sqlite3_api->status64
108745 #define sqlite3_strlike sqlite3_api->strlike
108746 #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
108747 /* Version 3.12.0 and later */
108748 #define sqlite3_system_errno sqlite3_api->system_errno
 
 
 
108749 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
108750
108751 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
108752 /* This case when the file really is being compiled as a loadable
108753 ** extension */
@@ -108761,11 +109198,11 @@
108761 # define SQLITE_EXTENSION_INIT1 /*no-op*/
108762 # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
108763 # define SQLITE_EXTENSION_INIT3 /*no-op*/
108764 #endif
108765
108766 #endif /* _SQLITE3EXT_H_ */
108767
108768 /************** End of sqlite3ext.h ******************************************/
108769 /************** Continuing where we left off in loadext.c ********************/
108770 /* #include "sqliteInt.h" */
108771 /* #include <string.h> */
@@ -109194,10 +109631,11 @@
109194 const char *zEntry;
109195 char *zAltEntry = 0;
109196 void **aHandle;
109197 u64 nMsg = 300 + sqlite3Strlen30(zFile);
109198 int ii;
 
109199
109200 /* Shared library endings to try if zFile cannot be loaded as written */
109201 static const char *azEndings[] = {
109202 #if SQLITE_OS_WIN
109203 "dll"
@@ -109296,11 +109734,13 @@
109296 sqlite3OsDlClose(pVfs, handle);
109297 sqlite3_free(zAltEntry);
109298 return SQLITE_ERROR;
109299 }
109300 sqlite3_free(zAltEntry);
109301 if( xInit(db, &zErrmsg, &sqlite3Apis) ){
 
 
109302 if( pzErrMsg ){
109303 *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
109304 }
109305 sqlite3_free(zErrmsg);
109306 sqlite3OsDlClose(pVfs, handle);
@@ -111034,11 +111474,11 @@
111034
111035 /* Many of the flag-pragmas modify the code generated by the SQL
111036 ** compiler (eg. count_changes). So add an opcode to expire all
111037 ** compiled SQL statements after modifying a pragma value.
111038 */
111039 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
111040 setAllPagerFlags(db);
111041 }
111042 break;
111043 }
111044 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -111056,11 +111496,11 @@
111056 ** notnull: True if 'NOT NULL' is part of column declaration
111057 ** dflt_value: The default value for the column, if any.
111058 */
111059 case PragTyp_TABLE_INFO: if( zRight ){
111060 Table *pTab;
111061 pTab = sqlite3FindTable(db, zRight, zDb);
111062 if( pTab ){
111063 static const char *azCol[] = {
111064 "cid", "name", "type", "notnull", "dflt_value", "pk"
111065 };
111066 int i, k;
@@ -111338,16 +111778,14 @@
111338 assert( iKey>=0 && iKey<pTab->nCol );
111339 if( iKey!=pTab->iPKey ){
111340 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
111341 sqlite3ColumnDefault(v, pTab, iKey, regRow);
111342 sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v);
111343 sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow,
111344 sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v);
111345 }else{
111346 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
111347 }
111348 sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v);
111349 sqlite3VdbeGoto(v, addrOk);
111350 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
111351 }else{
111352 for(j=0; j<pFK->nCol; j++){
111353 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
@@ -112914,10 +113352,11 @@
112914 int regReturn; /* Register holding block-output return address */
112915 int labelBkOut; /* Start label for the block-output subroutine */
112916 int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
112917 int labelDone; /* Jump here when done, ex: LIMIT reached */
112918 u8 sortFlags; /* Zero or more SORTFLAG_* bits */
 
112919 };
112920 #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
112921
112922 /*
112923 ** Delete all the content of a Select structure. Deallocate the structure
@@ -113447,13 +113886,34 @@
113447 op = OP_IdxInsert;
113448 }
113449 sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
113450 if( iLimit ){
113451 int addr;
 
 
 
 
 
113452 addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
113453 sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
 
 
 
 
 
113454 sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
 
 
 
 
 
 
 
 
 
 
 
113455 sqlite3VdbeJumpHere(v, addr);
113456 }
113457 }
113458
113459 /*
@@ -113864,11 +114324,11 @@
113864 ** Allocate a KeyInfo object sufficient for an index of N key columns and
113865 ** X extra columns.
113866 */
113867 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
113868 int nExtra = (N+X)*(sizeof(CollSeq*)+1);
113869 KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra);
113870 if( p ){
113871 p->aSortOrder = (u8*)&p->aColl[N+X];
113872 p->nField = (u16)N;
113873 p->nXField = (u16)X;
113874 p->enc = ENC(db);
@@ -113886,11 +114346,11 @@
113886 */
113887 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){
113888 if( p ){
113889 assert( p->nRef>0 );
113890 p->nRef--;
113891 if( p->nRef==0 ) sqlite3DbFree(0, p);
113892 }
113893 }
113894
113895 /*
113896 ** Make a new pointer to a KeyInfo object
@@ -118034,10 +118494,11 @@
118034 if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
118035 sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
118036 }
118037 if( sSort.pOrderBy ){
118038 sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
 
118039 if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
118040 sSort.pOrderBy = 0;
118041 }
118042 }
118043
@@ -120803,11 +121264,11 @@
120803 Btree *pTemp; /* The temporary database we vacuum into */
120804 char *zSql = 0; /* SQL statements */
120805 int saved_flags; /* Saved value of the db->flags */
120806 int saved_nChange; /* Saved value of db->nChange */
120807 int saved_nTotalChange; /* Saved value of db->nTotalChange */
120808 void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */
120809 Db *pDb = 0; /* Database to detach at end of vacuum */
120810 int isMemDb; /* True if vacuuming a :memory: database */
120811 int nRes; /* Bytes of reserved space at the end of each page */
120812 int nDb; /* Number of attached databases */
120813
@@ -120824,14 +121285,14 @@
120824 ** restored before returning. Then set the writable-schema flag, and
120825 ** disable CHECK and foreign key constraints. */
120826 saved_flags = db->flags;
120827 saved_nChange = db->nChange;
120828 saved_nTotalChange = db->nTotalChange;
120829 saved_xTrace = db->xTrace;
120830 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
120831 db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
120832 db->xTrace = 0;
120833
120834 pMain = db->aDb[0].pBt;
120835 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
120836
120837 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -121027,11 +121488,11 @@
121027 end_of_vacuum:
121028 /* Restore the original value of db->flags */
121029 db->flags = saved_flags;
121030 db->nChange = saved_nChange;
121031 db->nTotalChange = saved_nTotalChange;
121032 db->xTrace = saved_xTrace;
121033 sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
121034
121035 /* Currently there is an SQL level transaction open on the vacuum
121036 ** database. No locks are held on any other files (since the main file
121037 ** was committed at the btree level). So it safe to end the transaction
@@ -121476,11 +121937,11 @@
121476 );
121477 sqlite3DbFree(db, zStmt);
121478 v = sqlite3GetVdbe(pParse);
121479 sqlite3ChangeCookie(pParse, iDb);
121480
121481 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
121482 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
121483 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
121484
121485 iReg = ++pParse->nMem;
121486 sqlite3VdbeLoadString(v, iReg, pTab->zName);
@@ -121812,14 +122273,28 @@
121812 && !db->mallocFailed
121813 && !pParse->pNewTable->pSelect
121814 && (pParse->pNewTable->tabFlags & TF_Virtual)==0
121815 ){
121816 if( !pTab->aCol ){
121817 pTab->aCol = pParse->pNewTable->aCol;
121818 pTab->nCol = pParse->pNewTable->nCol;
121819 pParse->pNewTable->nCol = 0;
121820 pParse->pNewTable->aCol = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121821 }
121822 pCtx->bDeclared = 1;
121823 }else{
121824 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
121825 sqlite3DbFree(db, zErr);
@@ -122145,11 +122620,11 @@
122145 sqlite3OomFault(pToplevel->db);
122146 }
122147 }
122148
122149 /*
122150 ** Check to see if virtual tale module pMod can be have an eponymous
122151 ** virtual table instance. If it can, create one if one does not already
122152 ** exist. Return non-zero if the eponymous virtual table instance exists
122153 ** when this routine returns, and return zero if it does not exist.
122154 **
122155 ** An eponymous virtual table instance is one that is named after its
@@ -122162,21 +122637,22 @@
122162 */
122163 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
122164 const sqlite3_module *pModule = pMod->pModule;
122165 Table *pTab;
122166 char *zErr = 0;
122167 int nName;
122168 int rc;
122169 sqlite3 *db = pParse->db;
122170 if( pMod->pEpoTab ) return 1;
122171 if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;
122172 nName = sqlite3Strlen30(pMod->zName) + 1;
122173 pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName);
122174 if( pTab==0 ) return 0;
 
 
 
 
 
122175 pMod->pEpoTab = pTab;
122176 pTab->zName = (char*)&pTab[1];
122177 memcpy(pTab->zName, pMod->zName, nName);
122178 pTab->nRef = 1;
122179 pTab->pSchema = db->aDb[0].pSchema;
122180 pTab->tabFlags |= TF_Virtual;
122181 pTab->nModuleArg = 0;
122182 pTab->iPKey = -1;
@@ -122198,13 +122674,15 @@
122198 ** virtual table module pMod, if it exists.
122199 */
122200 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){
122201 Table *pTab = pMod->pEpoTab;
122202 if( pTab!=0 ){
122203 sqlite3DeleteColumnNames(db, pTab);
122204 sqlite3VtabClear(db, pTab);
122205 sqlite3DbFree(db, pTab);
 
 
122206 pMod->pEpoTab = 0;
122207 }
122208 }
122209
122210 /*
@@ -122707,12 +123185,13 @@
122707 u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
122708 i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
122709 u8 sorted; /* True if really sorted (not just grouped) */
122710 u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
122711 u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
122712 u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */
122713 u8 nLevel; /* Number of nested loop */
 
122714 int iTop; /* The very beginning of the WHERE loop */
122715 int iContinue; /* Jump here to continue with next record */
122716 int iBreak; /* Jump here to break out of the loop */
122717 int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
122718 int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
@@ -122725,10 +123204,13 @@
122725 ** Private interfaces - callable only by other where.c routines.
122726 **
122727 ** where.c:
122728 */
122729 SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
 
 
 
122730 SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(
122731 WhereClause *pWC, /* The WHERE clause to be searched */
122732 int iCur, /* Cursor number of LHS */
122733 int iColumn, /* Column number of LHS */
122734 Bitmask notReady, /* RHS must not overlap with this mask */
@@ -122941,11 +123423,11 @@
122941 StrAccum str; /* EQP output string */
122942 char zBuf[100]; /* Initial space for EQP output string */
122943
122944 pLoop = pLevel->pWLoop;
122945 flags = pLoop->wsFlags;
122946 if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0;
122947
122948 isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
122949 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
122950 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
122951
@@ -123384,11 +123866,11 @@
123384 **
123385 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
123386 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
123387 ** scan loop run twice, once for strings and a second time for BLOBs.
123388 ** The OP_String opcodes on the second pass convert the upper and lower
123389 ** bound string contants to blobs. This routine makes the necessary changes
123390 ** to the OP_String opcodes for that to happen.
123391 **
123392 ** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then
123393 ** only the one pass through the string space is required, so this routine
123394 ** becomes a no-op.
@@ -123441,10 +123923,42 @@
123441 pWalker->eCode = 1;
123442 }
123443 return WRC_Continue;
123444 }
123445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123446
123447 /*
123448 ** This function is called on every node of an expression tree used as an
123449 ** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN
123450 ** that accesses any table other than the one identified by
@@ -123493,10 +124007,11 @@
123493
123494 /*
123495 ** Insert an OP_CursorHint instruction if it is appropriate to do so.
123496 */
123497 static void codeCursorHint(
 
123498 WhereInfo *pWInfo, /* The where clause */
123499 WhereLevel *pLevel, /* Which loop to provide hints for */
123500 WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
123501 ){
123502 Parse *pParse = pWInfo->pParse;
@@ -123523,11 +124038,46 @@
123523 pWC = &pWInfo->sWC;
123524 for(i=0; i<pWC->nTerm; i++){
123525 pTerm = &pWC->a[i];
123526 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
123527 if( pTerm->prereqAll & pLevel->notReady ) continue;
123528 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123529
123530 /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize
123531 ** the cursor. These terms are not needed as hints for a pure range
123532 ** scan (that has no == terms) so omit them. */
123533 if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
@@ -123557,11 +124107,11 @@
123557 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
123558 (const char*)pExpr, P4_EXPR);
123559 }
123560 }
123561 #else
123562 # define codeCursorHint(A,B,C) /* No-op */
123563 #endif /* SQLITE_ENABLE_CURSOR_HINTS */
123564
123565 /*
123566 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
123567 ** a rowid value just read from cursor iIdxCur, open on index pIdx. This
@@ -123591,11 +124141,11 @@
123591
123592 assert( iIdxCur>0 );
123593 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
123594
123595 sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
123596 if( (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)
123597 && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
123598 ){
123599 int i;
123600 Table *pTab = pIdx->pTable;
123601 int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
@@ -123646,11 +124196,11 @@
123646 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
123647 iCur = pTabItem->iCursor;
123648 pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
123649 bRev = (pWInfo->revMask>>iLevel)&1;
123650 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
123651 && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
123652 VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
123653
123654 /* Create labels for the "break" and "continue" instructions
123655 ** for the current loop. Jump to addrBrk to break out of a loop.
123656 ** Jump to cont to go immediately to the next iteration of the
@@ -123786,12 +124336,11 @@
123786 testcase( pTerm->wtFlags & TERM_VIRTUAL );
123787 iReleaseReg = ++pParse->nMem;
123788 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
123789 if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
123790 addrNxt = pLevel->addrNxt;
123791 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); VdbeCoverage(v);
123792 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
123793 VdbeCoverage(v);
123794 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
123795 sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
123796 VdbeComment((v, "pk"));
123797 pLevel->op = OP_Noop;
@@ -123814,11 +124363,11 @@
123814 if( bRev ){
123815 pTerm = pStart;
123816 pStart = pEnd;
123817 pEnd = pTerm;
123818 }
123819 codeCursorHint(pWInfo, pLevel, pEnd);
123820 if( pStart ){
123821 Expr *pX; /* The expression that defines the start bound */
123822 int r1, rTemp; /* Registers for holding the start boundary */
123823
123824 /* The following constant maps TK_xx codes into corresponding
@@ -124028,11 +124577,11 @@
124028
124029 /* Generate code to evaluate all constraint terms using == or IN
124030 ** and store the values of those terms in an array of registers
124031 ** starting at regBase.
124032 */
124033 codeCursorHint(pWInfo, pLevel, pRangeEnd);
124034 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124035 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124036 if( zStartAff ) cEndAff = zStartAff[nEq];
124037 addrNxt = pLevel->addrNxt;
124038
@@ -124332,15 +124881,11 @@
124332
124333 /* Run a separate WHERE clause for each term of the OR clause. After
124334 ** eliminating duplicates from other WHERE clauses, the action for each
124335 ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
124336 */
124337 wctrlFlags = WHERE_OMIT_OPEN_CLOSE
124338 | WHERE_FORCE_TABLE
124339 | WHERE_ONETABLE_ONLY
124340 | WHERE_NO_AUTOINDEX
124341 | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
124342 for(ii=0; ii<pOrWc->nTerm; ii++){
124343 WhereTerm *pOrTerm = &pOrWc->a[ii];
124344 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
124345 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
124346 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -124444,11 +124989,10 @@
124444 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
124445 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
124446 ){
124447 assert( pSubWInfo->a[0].iIdxCur==iCovCur );
124448 pCov = pSubLoop->u.btree.pIndex;
124449 wctrlFlags |= WHERE_REOPEN_IDX;
124450 }else{
124451 pCov = 0;
124452 }
124453
124454 /* Finish the loop through table entries that match term pOrTerm. */
@@ -124481,11 +125025,11 @@
124481 if( pTabItem->fg.isRecursive ){
124482 /* Tables marked isRecursive have only a single row that is stored in
124483 ** a pseudo-cursor. No need to Rewind or Next such cursors. */
124484 pLevel->op = OP_Noop;
124485 }else{
124486 codeCursorHint(pWInfo, pLevel, 0);
124487 pLevel->op = aStep[bRev];
124488 pLevel->p1 = iCur;
124489 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
124490 VdbeCoverageIf(v, bRev==0);
124491 VdbeCoverageIf(v, bRev!=0);
@@ -124506,11 +125050,11 @@
124506 testcase( pTerm->wtFlags & TERM_VIRTUAL );
124507 testcase( pTerm->wtFlags & TERM_CODED );
124508 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
124509 if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
124510 testcase( pWInfo->untestedTerms==0
124511 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
124512 pWInfo->untestedTerms = 1;
124513 continue;
124514 }
124515 pE = pTerm->pExpr;
124516 assert( pE!=0 );
@@ -125168,11 +125712,13 @@
125168 sqlite3WhereExprAnalyze(pSrc, pAndWC);
125169 pAndWC->pOuter = pWC;
125170 if( !db->mallocFailed ){
125171 for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
125172 assert( pAndTerm->pExpr );
125173 if( allowedOp(pAndTerm->pExpr->op) ){
 
 
125174 b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);
125175 }
125176 }
125177 }
125178 indexable &= b;
@@ -125383,16 +125929,14 @@
125383 return 0;
125384 }
125385 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
125386 if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
125387 pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
125388 /* Since pLeft and pRight are both a column references, their collating
125389 ** sequence should always be defined. */
125390 zColl1 = ALWAYS(pColl) ? pColl->zName : 0;
125391 pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
125392 zColl2 = ALWAYS(pColl) ? pColl->zName : 0;
125393 return sqlite3StrICmp(zColl1, zColl2)==0;
125394 }
125395
125396 /*
125397 ** Recursively walk the expressions of a SELECT statement and generate
125398 ** a bitmask indicating which tables are used in that expression
@@ -125722,11 +126266,11 @@
125722 ** current expression is of the form: column MATCH expr.
125723 ** This information is used by the xBestIndex methods of
125724 ** virtual tables. The native query optimizer does not attempt
125725 ** to do anything with MATCH functions.
125726 */
125727 if( isMatchOfColumn(pExpr, &eOp2) ){
125728 int idxNew;
125729 Expr *pRight, *pLeft;
125730 WhereTerm *pNewTerm;
125731 Bitmask prereqColumn, prereqExpr;
125732
@@ -126014,10 +126558,22 @@
126014 ** Return FALSE if the output needs to be sorted.
126015 */
126016 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
126017 return pWInfo->nOBSat;
126018 }
 
 
 
 
 
 
 
 
 
 
 
 
126019
126020 /*
126021 ** Return the VDBE address or label to jump to in order to continue
126022 ** immediately with the next row of a WHERE clause.
126023 */
@@ -127600,20 +128156,42 @@
127600 static void whereTermPrint(WhereTerm *pTerm, int iTerm){
127601 if( pTerm==0 ){
127602 sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
127603 }else{
127604 char zType[4];
 
127605 memcpy(zType, "...", 4);
127606 if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
127607 if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
127608 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
 
 
 
 
 
 
 
 
 
127609 sqlite3DebugPrintf(
127610 "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n",
127611 iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb,
127612 pTerm->eOperator, pTerm->wtFlags);
127613 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
127614 }
 
 
 
 
 
 
 
 
 
 
 
 
127615 }
127616 #endif
127617
127618 #ifdef WHERETRACE_ENABLED
127619 /*
@@ -128599,11 +129177,11 @@
128599 rLogSize = estLog(rSize);
128600
128601 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
128602 /* Automatic indexes */
128603 if( !pBuilder->pOrSet /* Not part of an OR optimization */
128604 && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
128605 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
128606 && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */
128607 && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
128608 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
128609 && !pSrc->fg.isCorrelated /* Not a correlated subquery */
@@ -128631,10 +129209,11 @@
128631 pNew->rSetup = rLogSize + rSize + 4;
128632 if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
128633 pNew->rSetup += 24;
128634 }
128635 ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
 
128636 /* TUNING: Each index lookup yields 20 rows in the table. This
128637 ** is more than the usual guess of 10 rows, since we have no way
128638 ** of knowing how selective the index will ultimately be. It would
128639 ** not be unreasonable to make this value much larger. */
128640 pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
@@ -128691,10 +129270,11 @@
128691 }
128692
128693 /* Full scan via index */
128694 if( b
128695 || !HasRowid(pTab)
 
128696 || ( m==0
128697 && pProbe->bUnordered==0
128698 && (pProbe->szIdxRow<pTab->szTabRow)
128699 && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
128700 && sqlite3GlobalConfig.bUseCis
@@ -129076,13 +129656,11 @@
129076 sCur.n = 0;
129077 #ifdef WHERETRACE_ENABLED
129078 WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
129079 (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
129080 if( sqlite3WhereTrace & 0x400 ){
129081 for(i=0; i<sSubBuild.pWC->nTerm; i++){
129082 whereTermPrint(&sSubBuild.pWC->a[i], i);
129083 }
129084 }
129085 #endif
129086 #ifndef SQLITE_OMIT_VIRTUALTABLE
129087 if( IsVirtual(pItem->pTab) ){
129088 rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
@@ -129171,19 +129749,22 @@
129171 /* This condition is true when pItem is the FROM clause term on the
129172 ** right-hand-side of a LEFT or CROSS JOIN. */
129173 mPrereq = mPrior;
129174 }
129175 priorJointype = pItem->fg.jointype;
 
129176 if( IsVirtual(pItem->pTab) ){
129177 struct SrcList_item *p;
129178 for(p=&pItem[1]; p<pEnd; p++){
129179 if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){
129180 mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
129181 }
129182 }
129183 rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
129184 }else{
 
 
129185 rc = whereLoopAddBtree(pBuilder, mPrereq);
129186 }
129187 if( rc==SQLITE_OK ){
129188 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
129189 }
@@ -129214,11 +129795,11 @@
129214 */
129215 static i8 wherePathSatisfiesOrderBy(
129216 WhereInfo *pWInfo, /* The WHERE clause */
129217 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
129218 WherePath *pPath, /* The WherePath to check */
129219 u16 wctrlFlags, /* Might contain WHERE_GROUPBY or WHERE_DISTINCTBY */
129220 u16 nLoop, /* Number of entries in pPath->aLoop[] */
129221 WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
129222 Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */
129223 ){
129224 u8 revSet; /* True if rev is known */
@@ -129225,10 +129806,11 @@
129225 u8 rev; /* Composite sort order */
129226 u8 revIdx; /* Index sort order */
129227 u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */
129228 u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */
129229 u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
 
129230 u16 nKeyCol; /* Number of key columns in pIndex */
129231 u16 nColumn; /* Total number of ordered columns in the index */
129232 u16 nOrderBy; /* Number terms in the ORDER BY clause */
129233 int iLoop; /* Index of WhereLoop in pPath being processed */
129234 int i, j; /* Loop counters */
@@ -129275,13 +129857,20 @@
129275 if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
129276 isOrderDistinct = 1;
129277 obDone = MASKBIT(nOrderBy)-1;
129278 orderDistinctMask = 0;
129279 ready = 0;
 
 
129280 for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
129281 if( iLoop>0 ) ready |= pLoop->maskSelf;
129282 pLoop = iLoop<nLoop ? pPath->aLoop[iLoop] : pLast;
 
 
 
 
 
129283 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
129284 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
129285 break;
129286 }
129287 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -129295,11 +129884,11 @@
129295 if( MASKBIT(i) & obSat ) continue;
129296 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
129297 if( pOBExpr->op!=TK_COLUMN ) continue;
129298 if( pOBExpr->iTable!=iCur ) continue;
129299 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
129300 ~ready, WO_EQ|WO_ISNULL|WO_IS, 0);
129301 if( pTerm==0 ) continue;
129302 if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
129303 const char *z1, *z2;
129304 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
129305 if( !pColl ) pColl = db->pDfltColl;
@@ -129335,14 +129924,16 @@
129335 rev = revSet = 0;
129336 distinctColumns = 0;
129337 for(j=0; j<nColumn; j++){
129338 u8 bOnce; /* True to run the ORDER BY search loop */
129339
129340 /* Skip over == and IS NULL terms */
 
 
129341 if( j<pLoop->u.btree.nEq
129342 && pLoop->nSkip==0
129343 && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0
129344 ){
129345 if( i & WO_ISNULL ){
129346 testcase( isOrderDistinct );
129347 isOrderDistinct = 0;
129348 }
@@ -129862,12 +130453,23 @@
129862 if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
129863 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
129864 }
129865 }else{
129866 pWInfo->nOBSat = pFrom->isOrdered;
129867 if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
129868 pWInfo->revMask = pFrom->revLoop;
 
 
 
 
 
 
 
 
 
 
 
 
129869 }
129870 if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
129871 && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
129872 ){
129873 Bitmask revMask = 0;
@@ -129911,11 +130513,11 @@
129911 int j;
129912 Table *pTab;
129913 Index *pIdx;
129914
129915 pWInfo = pBuilder->pWInfo;
129916 if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0;
129917 assert( pWInfo->pTabList->nSrc>=1 );
129918 pItem = pWInfo->pTabList->a;
129919 pTab = pItem->pTab;
129920 if( IsVirtual(pTab) ) return 0;
129921 if( pItem->fg.isIndexedBy ) return 0;
@@ -130058,11 +130660,11 @@
130058 ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
130059 ** if there is one. If there is no ORDER BY clause or if this routine
130060 ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
130061 **
130062 ** The iIdxCur parameter is the cursor number of an index. If
130063 ** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index
130064 ** to use for OR clause processing. The WHERE clause should use this
130065 ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
130066 ** the first cursor in an array of cursors for all indices. iIdxCur should
130067 ** be used to compute the appropriate cursor depending on which index is
130068 ** used.
@@ -130072,11 +130674,11 @@
130072 SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
130073 Expr *pWhere, /* The WHERE clause */
130074 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
130075 ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
130076 u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
130077 int iAuxArg /* If WHERE_ONETABLE_ONLY is set, index cursor number
130078 ** If WHERE_USE_LIMIT, then the limit amount */
130079 ){
130080 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
130081 int nTabList; /* Number of elements in pTabList */
130082 WhereInfo *pWInfo; /* Will become the return value of this function */
@@ -130091,15 +130693,15 @@
130091 int rc; /* Return code */
130092 u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */
130093
130094 assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (
130095 (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
130096 && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
130097 ));
130098
130099 /* Only one of WHERE_ONETABLE_ONLY or WHERE_USE_LIMIT */
130100 assert( (wctrlFlags & WHERE_ONETABLE_ONLY)==0
130101 || (wctrlFlags & WHERE_USE_LIMIT)==0 );
130102
130103 /* Variable initialization */
130104 db = pParse->db;
130105 memset(&sWLB, 0, sizeof(sWLB));
@@ -130123,15 +130725,15 @@
130123 sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
130124 return 0;
130125 }
130126
130127 /* This function normally generates a nested loop for all tables in
130128 ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should
130129 ** only generate code for the first table in pTabList and assume that
130130 ** any cursors associated with subsequent tables are uninitialized.
130131 */
130132 nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
130133
130134 /* Allocate and initialize the WhereInfo structure that will become the
130135 ** return value. A single allocation is used to store the WhereInfo
130136 ** struct, the contents of WhereInfo.a[], the WhereClause structure
130137 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
@@ -130203,11 +130805,11 @@
130203 ** important. Ticket #3015.
130204 **
130205 ** Note that bitmasks are created for all pTabList->nSrc tables in
130206 ** pTabList, not just the first nTabList tables. nTabList is normally
130207 ** equal to pTabList->nSrc but might be shortened to 1 if the
130208 ** WHERE_ONETABLE_ONLY flag is set.
130209 */
130210 for(ii=0; ii<pTabList->nSrc; ii++){
130211 createMask(pMaskSet, pTabList->a[ii].iCursor);
130212 sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
130213 }
@@ -130241,14 +130843,11 @@
130241 sqlite3DebugPrintf(", limit: %d", iAuxArg);
130242 }
130243 sqlite3DebugPrintf(")\n");
130244 }
130245 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
130246 int i;
130247 for(i=0; i<sWLB.pWC->nTerm; i++){
130248 whereTermPrint(&sWLB.pWC->a[i], i);
130249 }
130250 }
130251 #endif
130252
130253 if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
130254 rc = whereLoopAddAll(&sWLB);
@@ -130386,11 +130985,11 @@
130386 }else if( IsVirtual(pTab) ){
130387 /* noop */
130388 }else
130389 #endif
130390 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
130391 && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
130392 int op = OP_OpenRead;
130393 if( pWInfo->eOnePass!=ONEPASS_OFF ){
130394 op = OP_OpenWrite;
130395 pWInfo->aiCurOnePass[0] = pTabItem->iCursor;
130396 };
@@ -130425,11 +131024,11 @@
130425 int iIndexCur;
130426 int op = OP_OpenRead;
130427 /* iAuxArg is always set if to a positive value if ONEPASS is possible */
130428 assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );
130429 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)
130430 && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0
130431 ){
130432 /* This is one term of an OR-optimization using the PRIMARY KEY of a
130433 ** WITHOUT ROWID table. No need for a separate index */
130434 iIndexCur = pLevel->iTabCur;
130435 op = 0;
@@ -130441,13 +131040,13 @@
130441 iIndexCur++;
130442 pJ = pJ->pNext;
130443 }
130444 op = OP_OpenWrite;
130445 pWInfo->aiCurOnePass[1] = iIndexCur;
130446 }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){
130447 iIndexCur = iAuxArg;
130448 if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx;
130449 }else{
130450 iIndexCur = pParse->nTab++;
130451 }
130452 pLevel->iIdxCur = iIndexCur;
130453 assert( pIx->pSchema==pTab->pSchema );
@@ -130505,11 +131104,11 @@
130505 pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
130506 );
130507 pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
130508 notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
130509 pWInfo->iContinue = pLevel->addrCont;
130510 if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){
130511 sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
130512 }
130513 }
130514
130515 /* Done. */
@@ -130628,16 +131227,16 @@
130628 continue;
130629 }
130630
130631 /* Close all of the cursors that were opened by sqlite3WhereBegin.
130632 ** Except, do not close cursors that will be reused by the OR optimization
130633 ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors
130634 ** created for the ONEPASS optimization.
130635 */
130636 if( (pTab->tabFlags & TF_Ephemeral)==0
130637 && pTab->pSelect==0
130638 && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
130639 ){
130640 int ws = pLoop->wsFlags;
130641 if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
130642 sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
130643 }
@@ -130980,49 +131579,49 @@
130980 #ifndef INTERFACE
130981 # define INTERFACE 1
130982 #endif
130983 /************* Begin control #defines *****************************************/
130984 #define YYCODETYPE unsigned char
130985 #define YYNOCODE 251
130986 #define YYACTIONTYPE unsigned short int
130987 #define YYWILDCARD 96
130988 #define sqlite3ParserTOKENTYPE Token
130989 typedef union {
130990 int yyinit;
130991 sqlite3ParserTOKENTYPE yy0;
130992 struct LimitVal yy64;
130993 Expr* yy122;
130994 Select* yy159;
130995 IdList* yy180;
130996 struct {int value; int mask;} yy207;
130997 struct LikeOp yy318;
130998 TriggerStep* yy327;
130999 With* yy331;
131000 ExprSpan yy342;
131001 SrcList* yy347;
131002 int yy392;
131003 struct TrigEvent yy410;
131004 ExprList* yy442;
131005 } YYMINORTYPE;
131006 #ifndef YYSTACKDEPTH
131007 #define YYSTACKDEPTH 100
131008 #endif
131009 #define sqlite3ParserARG_SDECL Parse *pParse;
131010 #define sqlite3ParserARG_PDECL ,Parse *pParse
131011 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131012 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
131013 #define YYFALLBACK 1
131014 #define YYNSTATE 440
131015 #define YYNRULE 326
131016 #define YY_MAX_SHIFT 439
131017 #define YY_MIN_SHIFTREDUCE 649
131018 #define YY_MAX_SHIFTREDUCE 974
131019 #define YY_MIN_REDUCE 975
131020 #define YY_MAX_REDUCE 1300
131021 #define YY_ERROR_ACTION 1301
131022 #define YY_ACCEPT_ACTION 1302
131023 #define YY_NO_ACTION 1303
131024 /************* End control #defines *******************************************/
131025
131026 /* Define the yytestcase() macro to be a no-op if is not already defined
131027 ** otherwise.
131028 **
@@ -131086,450 +131685,452 @@
131086 ** yy_reduce_ofst[] For each state, the offset into yy_action for
131087 ** shifting non-terminals after a reduce.
131088 ** yy_default[] Default action for each state.
131089 **
131090 *********** Begin parsing tables **********************************************/
131091 #define YY_ACTTAB_COUNT (1501)
131092 static const YYACTIONTYPE yy_action[] = {
131093 /* 0 */ 315, 810, 339, 804, 5, 194, 194, 798, 92, 93,
131094 /* 10 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131095 /* 20 */ 91, 91, 91, 290, 89, 89, 89, 89, 88, 88,
131096 /* 30 */ 87, 87, 87, 86, 339, 315, 952, 952, 803, 803,
131097 /* 40 */ 803, 922, 342, 92, 93, 83, 819, 819, 831, 834,
131098 /* 50 */ 823, 823, 90, 90, 91, 91, 91, 91, 123, 89,
131099 /* 60 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131100 /* 70 */ 88, 88, 87, 87, 87, 86, 339, 772, 952, 952,
131101 /* 80 */ 315, 87, 87, 87, 86, 339, 773, 68, 92, 93,
131102 /* 90 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131103 /* 100 */ 91, 91, 91, 434, 89, 89, 89, 89, 88, 88,
131104 /* 110 */ 87, 87, 87, 86, 339, 1302, 146, 921, 2, 315,
131105 /* 120 */ 427, 24, 679, 953, 48, 86, 339, 92, 93, 83,
131106 /* 130 */ 819, 819, 831, 834, 823, 823, 90, 90, 91, 91,
131107 /* 140 */ 91, 91, 94, 89, 89, 89, 89, 88, 88, 87,
131108 /* 150 */ 87, 87, 86, 339, 933, 933, 315, 259, 412, 398,
131109 /* 160 */ 396, 57, 733, 733, 92, 93, 83, 819, 819, 831,
131110 /* 170 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 56,
131111 /* 180 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131112 /* 190 */ 339, 315, 1245, 922, 342, 268, 934, 935, 241, 92,
131113 /* 200 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131114 /* 210 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131115 /* 220 */ 88, 87, 87, 87, 86, 339, 315, 913, 1295, 682,
131116 /* 230 */ 687, 1295, 233, 397, 92, 93, 83, 819, 819, 831,
131117 /* 240 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 326,
131118 /* 250 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131119 /* 260 */ 339, 315, 85, 82, 168, 680, 431, 938, 939, 92,
131120 /* 270 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131121 /* 280 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131122 /* 290 */ 88, 87, 87, 87, 86, 339, 315, 319, 913, 1296,
131123 /* 300 */ 797, 911, 1296, 681, 92, 93, 83, 819, 819, 831,
131124 /* 310 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 335,
131125 /* 320 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131126 /* 330 */ 339, 315, 876, 876, 373, 85, 82, 168, 944, 92,
131127 /* 340 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131128 /* 350 */ 91, 91, 91, 91, 896, 89, 89, 89, 89, 88,
131129 /* 360 */ 88, 87, 87, 87, 86, 339, 315, 370, 307, 973,
131130 /* 370 */ 367, 1, 911, 433, 92, 93, 83, 819, 819, 831,
131131 /* 380 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 189,
131132 /* 390 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131133 /* 400 */ 339, 315, 720, 948, 933, 933, 149, 718, 948, 92,
131134 /* 410 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131135 /* 420 */ 91, 91, 91, 91, 434, 89, 89, 89, 89, 88,
131136 /* 430 */ 88, 87, 87, 87, 86, 339, 338, 938, 939, 947,
131137 /* 440 */ 694, 940, 974, 315, 953, 48, 934, 935, 715, 689,
131138 /* 450 */ 71, 92, 93, 83, 819, 819, 831, 834, 823, 823,
131139 /* 460 */ 90, 90, 91, 91, 91, 91, 320, 89, 89, 89,
131140 /* 470 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 412,
131141 /* 480 */ 403, 820, 820, 832, 835, 74, 92, 81, 83, 819,
131142 /* 490 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131143 /* 500 */ 91, 698, 89, 89, 89, 89, 88, 88, 87, 87,
131144 /* 510 */ 87, 86, 339, 315, 259, 654, 655, 656, 393, 111,
131145 /* 520 */ 331, 153, 93, 83, 819, 819, 831, 834, 823, 823,
131146 /* 530 */ 90, 90, 91, 91, 91, 91, 434, 89, 89, 89,
131147 /* 540 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 188,
131148 /* 550 */ 187, 186, 824, 937, 328, 219, 953, 48, 83, 819,
131149 /* 560 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131150 /* 570 */ 91, 956, 89, 89, 89, 89, 88, 88, 87, 87,
131151 /* 580 */ 87, 86, 339, 79, 429, 738, 3, 1174, 955, 348,
131152 /* 590 */ 737, 332, 792, 933, 933, 937, 79, 429, 730, 3,
131153 /* 600 */ 203, 160, 278, 391, 273, 390, 190, 892, 434, 400,
131154 /* 610 */ 741, 76, 77, 271, 287, 253, 353, 242, 78, 340,
131155 /* 620 */ 340, 85, 82, 168, 76, 77, 233, 397, 953, 48,
131156 /* 630 */ 432, 78, 340, 340, 277, 934, 935, 185, 439, 651,
131157 /* 640 */ 388, 385, 384, 432, 234, 276, 107, 418, 349, 337,
131158 /* 650 */ 336, 383, 893, 728, 215, 949, 123, 971, 308, 810,
131159 /* 660 */ 418, 436, 435, 412, 394, 798, 400, 873, 894, 123,
131160 /* 670 */ 721, 872, 810, 889, 436, 435, 215, 949, 798, 351,
131161 /* 680 */ 722, 697, 380, 434, 771, 371, 22, 434, 400, 79,
131162 /* 690 */ 429, 232, 3, 189, 413, 870, 803, 803, 803, 805,
131163 /* 700 */ 18, 54, 148, 953, 48, 956, 113, 953, 9, 803,
131164 /* 710 */ 803, 803, 805, 18, 310, 123, 748, 76, 77, 742,
131165 /* 720 */ 123, 325, 955, 866, 78, 340, 340, 113, 350, 359,
131166 /* 730 */ 85, 82, 168, 343, 960, 960, 432, 770, 412, 414,
131167 /* 740 */ 407, 23, 1240, 1240, 79, 429, 357, 3, 166, 91,
131168 /* 750 */ 91, 91, 91, 418, 89, 89, 89, 89, 88, 88,
131169 /* 760 */ 87, 87, 87, 86, 339, 810, 434, 436, 435, 792,
131170 /* 770 */ 320, 798, 76, 77, 789, 271, 123, 434, 360, 78,
131171 /* 780 */ 340, 340, 864, 85, 82, 168, 953, 9, 395, 743,
131172 /* 790 */ 360, 432, 253, 358, 252, 933, 933, 953, 30, 889,
131173 /* 800 */ 327, 216, 803, 803, 803, 805, 18, 113, 418, 89,
131174 /* 810 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131175 /* 820 */ 810, 113, 436, 435, 792, 185, 798, 288, 388, 385,
131176 /* 830 */ 384, 123, 113, 920, 2, 796, 696, 934, 935, 383,
131177 /* 840 */ 69, 429, 434, 3, 218, 110, 738, 253, 358, 252,
131178 /* 850 */ 434, 737, 933, 933, 892, 359, 222, 803, 803, 803,
131179 /* 860 */ 805, 18, 953, 47, 933, 933, 933, 933, 76, 77,
131180 /* 870 */ 953, 9, 366, 904, 217, 78, 340, 340, 677, 305,
131181 /* 880 */ 304, 303, 206, 301, 224, 259, 664, 432, 337, 336,
131182 /* 890 */ 434, 228, 247, 144, 934, 935, 933, 933, 667, 893,
131183 /* 900 */ 324, 1259, 96, 434, 418, 796, 934, 935, 934, 935,
131184 /* 910 */ 953, 48, 401, 148, 289, 894, 810, 417, 436, 435,
131185 /* 920 */ 677, 759, 798, 953, 9, 314, 220, 162, 161, 170,
131186 /* 930 */ 402, 239, 953, 8, 194, 683, 683, 410, 934, 935,
131187 /* 940 */ 238, 959, 933, 933, 225, 408, 945, 365, 957, 212,
131188 /* 950 */ 958, 172, 757, 803, 803, 803, 805, 18, 173, 365,
131189 /* 960 */ 176, 123, 171, 113, 244, 952, 246, 434, 356, 796,
131190 /* 970 */ 372, 365, 236, 960, 960, 810, 290, 804, 191, 165,
131191 /* 980 */ 852, 798, 259, 316, 934, 935, 237, 953, 34, 404,
131192 /* 990 */ 91, 91, 91, 91, 84, 89, 89, 89, 89, 88,
131193 /* 1000 */ 88, 87, 87, 87, 86, 339, 701, 952, 434, 240,
131194 /* 1010 */ 347, 758, 803, 803, 803, 434, 245, 1179, 434, 389,
131195 /* 1020 */ 434, 376, 434, 895, 167, 434, 405, 702, 953, 35,
131196 /* 1030 */ 673, 321, 221, 434, 333, 953, 11, 434, 953, 26,
131197 /* 1040 */ 953, 36, 953, 37, 251, 953, 38, 434, 259, 434,
131198 /* 1050 */ 757, 434, 329, 953, 27, 434, 223, 953, 28, 434,
131199 /* 1060 */ 690, 434, 67, 434, 65, 434, 862, 953, 39, 953,
131200 /* 1070 */ 40, 953, 41, 423, 434, 953, 10, 434, 772, 953,
131201 /* 1080 */ 42, 953, 98, 953, 43, 953, 44, 773, 434, 346,
131202 /* 1090 */ 434, 75, 434, 73, 953, 31, 434, 953, 45, 434,
131203 /* 1100 */ 259, 434, 690, 434, 757, 434, 887, 434, 953, 46,
131204 /* 1110 */ 953, 32, 953, 115, 434, 266, 953, 116, 951, 953,
131205 /* 1120 */ 117, 953, 52, 953, 33, 953, 99, 953, 49, 726,
131206 /* 1130 */ 434, 909, 434, 19, 953, 100, 434, 344, 434, 113,
131207 /* 1140 */ 434, 258, 692, 434, 259, 434, 670, 434, 20, 434,
131208 /* 1150 */ 953, 101, 953, 97, 434, 259, 953, 114, 953, 112,
131209 /* 1160 */ 953, 105, 113, 953, 104, 953, 102, 953, 103, 953,
131210 /* 1170 */ 51, 434, 148, 434, 953, 53, 167, 434, 259, 113,
131211 /* 1180 */ 300, 307, 912, 363, 311, 860, 248, 261, 209, 264,
131212 /* 1190 */ 416, 953, 50, 953, 25, 420, 727, 953, 29, 430,
131213 /* 1200 */ 321, 424, 757, 428, 322, 124, 1269, 214, 165, 710,
131214 /* 1210 */ 859, 908, 806, 794, 309, 158, 193, 361, 254, 723,
131215 /* 1220 */ 364, 67, 381, 269, 735, 199, 67, 70, 113, 700,
131216 /* 1230 */ 699, 707, 708, 884, 113, 766, 113, 855, 193, 883,
131217 /* 1240 */ 199, 869, 869, 675, 868, 868, 109, 368, 255, 260,
131218 /* 1250 */ 263, 280, 859, 265, 806, 974, 267, 711, 695, 272,
131219 /* 1260 */ 764, 282, 795, 284, 150, 744, 755, 415, 292, 293,
131220 /* 1270 */ 802, 678, 672, 661, 660, 662, 927, 6, 306, 386,
131221 /* 1280 */ 352, 786, 243, 250, 886, 362, 163, 286, 419, 298,
131222 /* 1290 */ 930, 159, 968, 196, 126, 903, 901, 965, 55, 58,
131223 /* 1300 */ 323, 275, 857, 136, 147, 694, 856, 121, 65, 354,
131224 /* 1310 */ 355, 379, 175, 61, 151, 369, 180, 871, 375, 129,
131225 /* 1320 */ 257, 756, 210, 181, 145, 131, 132, 377, 262, 663,
131226 /* 1330 */ 133, 134, 139, 783, 791, 182, 392, 183, 312, 330,
131227 /* 1340 */ 714, 888, 713, 851, 692, 195, 712, 406, 686, 705,
131228 /* 1350 */ 313, 685, 64, 839, 274, 72, 684, 334, 942, 95,
131229 /* 1360 */ 752, 279, 281, 704, 753, 751, 422, 283, 411, 750,
131230 /* 1370 */ 426, 66, 204, 409, 21, 285, 928, 669, 437, 205,
131231 /* 1380 */ 207, 208, 438, 658, 657, 652, 118, 108, 119, 226,
131232 /* 1390 */ 650, 341, 157, 235, 169, 345, 106, 734, 790, 296,
131233 /* 1400 */ 294, 295, 120, 297, 867, 865, 127, 128, 130, 724,
131234 /* 1410 */ 229, 174, 249, 882, 137, 230, 138, 135, 885, 231,
131235 /* 1420 */ 59, 60, 177, 881, 7, 178, 12, 179, 256, 874,
131236 /* 1430 */ 140, 193, 962, 374, 141, 152, 666, 378, 276, 184,
131237 /* 1440 */ 270, 122, 142, 382, 387, 62, 13, 14, 703, 63,
131238 /* 1450 */ 125, 317, 318, 227, 809, 808, 837, 732, 15, 164,
131239 /* 1460 */ 736, 4, 765, 211, 399, 213, 192, 143, 760, 70,
131240 /* 1470 */ 67, 16, 17, 838, 836, 891, 841, 890, 198, 197,
131241 /* 1480 */ 917, 154, 421, 923, 918, 155, 200, 977, 425, 840,
131242 /* 1490 */ 156, 201, 807, 676, 80, 302, 299, 977, 202, 1261,
131243 /* 1500 */ 1260,
131244 };
131245 static const YYCODETYPE yy_lookahead[] = {
131246 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
131247 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131248 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131249 /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
131250 /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
131251 /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 92, 43,
131252 /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131253 /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
131254 /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
131255 /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131256 /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131257 /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
131258 /* 120 */ 249, 22, 172, 172, 173, 52, 53, 27, 28, 29,
131259 /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
131260 /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
131261 /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
131262 /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
131263 /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
131264 /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131265 /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
131266 /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131267 /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131268 /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172,
131269 /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32,
131270 /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131271 /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131272 /* 260 */ 53, 19, 221, 222, 223, 23, 168, 169, 170, 27,
131273 /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131274 /* 280 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131275 /* 290 */ 48, 49, 50, 51, 52, 53, 19, 157, 22, 23,
131276 /* 300 */ 23, 96, 26, 172, 27, 28, 29, 30, 31, 32,
131277 /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131278 /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131279 /* 330 */ 53, 19, 108, 109, 110, 221, 222, 223, 185, 27,
131280 /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131281 /* 350 */ 38, 39, 40, 41, 240, 43, 44, 45, 46, 47,
131282 /* 360 */ 48, 49, 50, 51, 52, 53, 19, 227, 22, 23,
131283 /* 370 */ 230, 22, 96, 152, 27, 28, 29, 30, 31, 32,
131284 /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
131285 /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131286 /* 400 */ 53, 19, 190, 191, 55, 56, 24, 190, 191, 27,
131287 /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131288 /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131289 /* 430 */ 48, 49, 50, 51, 52, 53, 168, 169, 170, 179,
131290 /* 440 */ 180, 171, 96, 19, 172, 173, 97, 98, 188, 179,
131291 /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
131292 /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
131293 /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
131294 /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
131295 /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131296 /* 500 */ 41, 181, 43, 44, 45, 46, 47, 48, 49, 50,
131297 /* 510 */ 51, 52, 53, 19, 152, 7, 8, 9, 49, 22,
131298 /* 520 */ 19, 24, 28, 29, 30, 31, 32, 33, 34, 35,
131299 /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
131300 /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
131301 /* 550 */ 109, 110, 101, 55, 53, 193, 172, 173, 29, 30,
131302 /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131303 /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
131304 /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
131305 /* 590 */ 121, 207, 85, 55, 56, 97, 19, 20, 195, 22,
131306 /* 600 */ 99, 100, 101, 102, 103, 104, 105, 12, 152, 206,
131307 /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
131308 /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
131309 /* 630 */ 66, 54, 55, 56, 101, 97, 98, 99, 148, 149,
131310 /* 640 */ 102, 103, 104, 66, 154, 112, 156, 83, 229, 47,
131311 /* 650 */ 48, 113, 57, 163, 194, 195, 92, 246, 247, 95,
131312 /* 660 */ 83, 97, 98, 207, 208, 101, 206, 59, 73, 92,
131313 /* 670 */ 75, 63, 95, 163, 97, 98, 194, 195, 101, 219,
131314 /* 680 */ 85, 181, 19, 152, 175, 77, 196, 152, 206, 19,
131315 /* 690 */ 20, 199, 22, 30, 163, 11, 132, 133, 134, 135,
131316 /* 700 */ 136, 209, 152, 172, 173, 152, 196, 172, 173, 132,
131317 /* 710 */ 133, 134, 135, 136, 164, 92, 213, 47, 48, 49,
131318 /* 720 */ 92, 186, 169, 170, 54, 55, 56, 196, 100, 219,
131319 /* 730 */ 221, 222, 223, 243, 132, 133, 66, 175, 207, 208,
131320 /* 740 */ 152, 231, 119, 120, 19, 20, 236, 22, 152, 38,
131321 /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
131322 /* 760 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 85,
131323 /* 770 */ 107, 101, 47, 48, 163, 112, 92, 152, 152, 54,
131324 /* 780 */ 55, 56, 229, 221, 222, 223, 172, 173, 163, 49,
131325 /* 790 */ 152, 66, 108, 109, 110, 55, 56, 172, 173, 163,
131326 /* 800 */ 186, 22, 132, 133, 134, 135, 136, 196, 83, 43,
131327 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131328 /* 820 */ 95, 196, 97, 98, 85, 99, 101, 152, 102, 103,
131329 /* 830 */ 104, 92, 196, 146, 147, 152, 181, 97, 98, 113,
131330 /* 840 */ 19, 20, 152, 22, 218, 22, 116, 108, 109, 110,
131331 /* 850 */ 152, 121, 55, 56, 12, 219, 218, 132, 133, 134,
131332 /* 860 */ 135, 136, 172, 173, 55, 56, 55, 56, 47, 48,
131333 /* 870 */ 172, 173, 236, 152, 5, 54, 55, 56, 55, 10,
131334 /* 880 */ 11, 12, 13, 14, 186, 152, 17, 66, 47, 48,
131335 /* 890 */ 152, 210, 16, 84, 97, 98, 55, 56, 21, 57,
131336 /* 900 */ 217, 122, 22, 152, 83, 152, 97, 98, 97, 98,
131337 /* 910 */ 172, 173, 152, 152, 224, 73, 95, 75, 97, 98,
131338 /* 920 */ 97, 124, 101, 172, 173, 164, 193, 47, 48, 60,
131339 /* 930 */ 163, 62, 172, 173, 24, 55, 56, 186, 97, 98,
131340 /* 940 */ 71, 100, 55, 56, 183, 207, 185, 152, 107, 23,
131341 /* 950 */ 109, 82, 26, 132, 133, 134, 135, 136, 89, 152,
131342 /* 960 */ 26, 92, 93, 196, 88, 55, 90, 152, 91, 152,
131343 /* 970 */ 217, 152, 152, 132, 133, 95, 152, 97, 211, 212,
131344 /* 980 */ 103, 101, 152, 114, 97, 98, 152, 172, 173, 19,
131345 /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
131346 /* 1000 */ 48, 49, 50, 51, 52, 53, 65, 97, 152, 152,
131347 /* 1010 */ 141, 124, 132, 133, 134, 152, 140, 140, 152, 78,
131348 /* 1020 */ 152, 233, 152, 193, 98, 152, 56, 86, 172, 173,
131349 /* 1030 */ 166, 167, 237, 152, 217, 172, 173, 152, 172, 173,
131350 /* 1040 */ 172, 173, 172, 173, 237, 172, 173, 152, 152, 152,
131351 /* 1050 */ 124, 152, 111, 172, 173, 152, 237, 172, 173, 152,
131352 /* 1060 */ 55, 152, 26, 152, 130, 152, 152, 172, 173, 172,
131353 /* 1070 */ 173, 172, 173, 249, 152, 172, 173, 152, 61, 172,
131354 /* 1080 */ 173, 172, 173, 172, 173, 172, 173, 70, 152, 193,
131355 /* 1090 */ 152, 137, 152, 139, 172, 173, 152, 172, 173, 152,
131356 /* 1100 */ 152, 152, 97, 152, 26, 152, 163, 152, 172, 173,
131357 /* 1110 */ 172, 173, 172, 173, 152, 16, 172, 173, 26, 172,
131358 /* 1120 */ 173, 172, 173, 172, 173, 172, 173, 172, 173, 163,
131359 /* 1130 */ 152, 152, 152, 22, 172, 173, 152, 241, 152, 196,
131360 /* 1140 */ 152, 193, 106, 152, 152, 152, 163, 152, 37, 152,
131361 /* 1150 */ 172, 173, 172, 173, 152, 152, 172, 173, 172, 173,
131362 /* 1160 */ 172, 173, 196, 172, 173, 172, 173, 172, 173, 172,
131363 /* 1170 */ 173, 152, 152, 152, 172, 173, 98, 152, 152, 196,
131364 /* 1180 */ 160, 22, 23, 19, 164, 193, 152, 88, 232, 90,
131365 /* 1190 */ 191, 172, 173, 172, 173, 163, 193, 172, 173, 166,
131366 /* 1200 */ 167, 163, 124, 163, 244, 245, 23, 211, 212, 26,
131367 /* 1210 */ 55, 23, 55, 23, 26, 123, 26, 152, 23, 193,
131368 /* 1220 */ 56, 26, 23, 23, 23, 26, 26, 26, 196, 100,
131369 /* 1230 */ 101, 7, 8, 152, 196, 23, 196, 23, 26, 152,
131370 /* 1240 */ 26, 132, 133, 23, 132, 133, 26, 152, 152, 152,
131371 /* 1250 */ 152, 210, 97, 152, 97, 96, 152, 152, 152, 152,
131372 /* 1260 */ 152, 210, 152, 210, 197, 152, 152, 152, 152, 152,
131373 /* 1270 */ 152, 152, 152, 152, 152, 152, 152, 198, 150, 176,
131374 /* 1280 */ 214, 201, 214, 238, 201, 238, 184, 214, 226, 200,
131375 /* 1290 */ 155, 198, 67, 122, 242, 159, 159, 69, 239, 239,
131376 /* 1300 */ 159, 175, 175, 22, 220, 180, 175, 27, 130, 18,
131377 /* 1310 */ 159, 18, 158, 137, 220, 159, 158, 235, 74, 189,
131378 /* 1320 */ 234, 159, 159, 158, 22, 192, 192, 177, 159, 159,
131379 /* 1330 */ 192, 192, 189, 201, 189, 158, 107, 158, 177, 76,
131380 /* 1340 */ 174, 201, 174, 201, 106, 159, 174, 125, 174, 182,
131381 /* 1350 */ 177, 176, 107, 159, 174, 137, 174, 53, 174, 129,
131382 /* 1360 */ 216, 215, 215, 182, 216, 216, 177, 215, 126, 216,
131383 /* 1370 */ 177, 128, 25, 127, 26, 215, 13, 162, 161, 153,
131384 /* 1380 */ 153, 6, 151, 151, 151, 151, 165, 178, 165, 178,
131385 /* 1390 */ 4, 3, 22, 142, 15, 94, 16, 205, 120, 202,
131386 /* 1400 */ 204, 203, 165, 201, 23, 23, 131, 111, 123, 20,
131387 /* 1410 */ 225, 125, 16, 1, 131, 228, 111, 123, 56, 228,
131388 /* 1420 */ 37, 37, 64, 1, 5, 122, 22, 107, 140, 80,
131389 /* 1430 */ 80, 26, 87, 72, 107, 24, 20, 19, 112, 105,
131390 /* 1440 */ 23, 68, 22, 79, 79, 22, 22, 22, 58, 22,
131391 /* 1450 */ 245, 248, 248, 79, 23, 23, 23, 116, 22, 122,
131392 /* 1460 */ 23, 22, 56, 23, 26, 23, 64, 22, 124, 26,
131393 /* 1470 */ 26, 64, 64, 23, 23, 23, 11, 23, 22, 26,
131394 /* 1480 */ 23, 22, 24, 1, 23, 22, 26, 250, 24, 23,
131395 /* 1490 */ 22, 122, 23, 23, 22, 15, 23, 250, 122, 122,
131396 /* 1500 */ 122,
131397 };
131398 #define YY_SHIFT_USE_DFLT (-95)
131399 #define YY_SHIFT_COUNT (439)
131400 #define YY_SHIFT_MIN (-94)
131401 #define YY_SHIFT_MAX (1482)
131402 static const short yy_shift_ofst[] = {
131403 /* 0 */ 40, 564, 869, 577, 725, 725, 725, 739, -19, 16,
131404 /* 10 */ 16, 100, 725, 725, 725, 725, 725, 725, 725, 841,
131405 /* 20 */ 841, 538, 507, 684, 623, 61, 137, 172, 207, 242,
131406 /* 30 */ 277, 312, 347, 382, 424, 424, 424, 424, 424, 424,
131407 /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 459,
131408 /* 50 */ 424, 494, 529, 529, 670, 725, 725, 725, 725, 725,
131409 /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131410 /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131411 /* 80 */ 725, 725, 725, 821, 725, 725, 725, 725, 725, 725,
131412 /* 90 */ 725, 725, 725, 725, 725, 725, 725, 952, 711, 711,
131413 /* 100 */ 711, 711, 711, 766, 23, 32, 811, 877, 663, 602,
131414 /* 110 */ 602, 811, 73, 113, -51, -95, -95, -95, 501, 501,
131415 /* 120 */ 501, 595, 595, 809, 205, 276, 811, 811, 811, 811,
131416 /* 130 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131417 /* 140 */ 811, 811, 811, 811, 811, 811, 192, 628, 498, 498,
131418 /* 150 */ 113, -34, -34, -34, -34, -34, -34, -95, -95, -95,
131419 /* 160 */ 880, -94, -94, 726, 740, 99, 797, 887, 349, 811,
131420 /* 170 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131421 /* 180 */ 811, 811, 811, 811, 811, 811, 941, 941, 941, 811,
131422 /* 190 */ 811, 926, 811, 811, 811, -18, 811, 811, 842, 811,
131423 /* 200 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 224,
131424 /* 210 */ 608, 910, 910, 910, 1078, 45, 469, 508, 934, 970,
131425 /* 220 */ 970, 1164, 934, 1164, 1036, 1183, 359, 1017, 970, 954,
131426 /* 230 */ 1017, 1017, 1092, 730, 497, 1225, 1171, 1171, 1228, 1228,
131427 /* 240 */ 1171, 1281, 1280, 1178, 1291, 1291, 1291, 1291, 1171, 1293,
131428 /* 250 */ 1178, 1281, 1280, 1280, 1178, 1171, 1293, 1176, 1244, 1171,
131429 /* 260 */ 1171, 1293, 1302, 1171, 1293, 1171, 1293, 1302, 1229, 1229,
131430 /* 270 */ 1229, 1263, 1302, 1229, 1238, 1229, 1263, 1229, 1229, 1222,
131431 /* 280 */ 1245, 1222, 1245, 1222, 1245, 1222, 1245, 1171, 1171, 1218,
131432 /* 290 */ 1302, 1304, 1304, 1302, 1230, 1242, 1243, 1246, 1178, 1347,
131433 /* 300 */ 1348, 1363, 1363, 1375, 1375, 1375, 1375, -95, -95, -95,
131434 /* 310 */ -95, -95, -95, -95, -95, 451, 876, 346, 1159, 1099,
131435 /* 320 */ 441, 823, 1188, 1111, 1190, 1195, 1199, 1200, 1005, 1129,
131436 /* 330 */ 1224, 533, 1201, 1212, 1155, 1214, 1109, 1112, 1220, 1157,
131437 /* 340 */ 779, 1386, 1388, 1370, 1251, 1379, 1301, 1380, 1381, 1382,
131438 /* 350 */ 1278, 1275, 1296, 1285, 1389, 1286, 1396, 1412, 1294, 1283,
131439 /* 360 */ 1383, 1384, 1305, 1362, 1358, 1303, 1422, 1419, 1404, 1320,
131440 /* 370 */ 1288, 1349, 1405, 1350, 1345, 1361, 1327, 1411, 1416, 1418,
131441 /* 380 */ 1326, 1334, 1420, 1364, 1423, 1424, 1417, 1425, 1365, 1390,
131442 /* 390 */ 1427, 1374, 1373, 1431, 1432, 1433, 1341, 1436, 1437, 1439,
131443 /* 400 */ 1438, 1337, 1440, 1442, 1406, 1402, 1445, 1344, 1443, 1407,
131444 /* 410 */ 1444, 1408, 1443, 1450, 1451, 1452, 1453, 1454, 1456, 1465,
131445 /* 420 */ 1457, 1459, 1458, 1460, 1461, 1463, 1464, 1460, 1466, 1468,
131446 /* 430 */ 1469, 1470, 1472, 1369, 1376, 1377, 1378, 1473, 1480, 1482,
 
131447 };
131448 #define YY_REDUCE_USE_DFLT (-130)
131449 #define YY_REDUCE_COUNT (314)
131450 #define YY_REDUCE_MIN (-129)
131451 #define YY_REDUCE_MAX (1237)
131452 static const short yy_reduce_ofst[] = {
131453 /* 0 */ -29, 531, 490, 625, -49, 272, 456, 510, 400, 509,
131454 /* 10 */ 562, 114, 535, 614, 698, 384, 738, 751, 690, 419,
131455 /* 20 */ 553, 761, 460, 636, 767, 41, 41, 41, 41, 41,
131456 /* 30 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131457 /* 40 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131458 /* 50 */ 41, 41, 41, 41, 760, 815, 856, 863, 866, 868,
131459 /* 60 */ 870, 873, 881, 885, 895, 897, 899, 903, 907, 909,
131460 /* 70 */ 911, 913, 922, 925, 936, 938, 940, 944, 947, 949,
131461 /* 80 */ 951, 953, 955, 962, 978, 980, 984, 986, 988, 991,
131462 /* 90 */ 993, 995, 997, 1002, 1019, 1021, 1025, 41, 41, 41,
131463 /* 100 */ 41, 41, 41, 41, 41, 41, 896, 140, 260, 98,
131464 /* 110 */ 268, 1020, 41, 482, 41, 41, 41, 41, 270, 270,
131465 /* 120 */ 270, 212, 217, -129, 411, 411, 550, 5, 626, 362,
131466 /* 130 */ 733, 830, 992, 1003, 1026, 795, 683, 807, 638, 819,
131467 /* 140 */ 753, 948, 62, 817, 824, 132, 687, 611, 864, 1033,
131468 /* 150 */ 403, 943, 966, 983, 1032, 1038, 1040, 960, 996, 492,
131469 /* 160 */ -50, 57, 131, 153, 221, 462, 588, 596, 675, 721,
131470 /* 170 */ 820, 834, 857, 914, 979, 1034, 1065, 1081, 1087, 1095,
131471 /* 180 */ 1096, 1097, 1098, 1101, 1104, 1105, 320, 500, 655, 1106,
131472 /* 190 */ 1107, 503, 1108, 1110, 1113, 681, 1114, 1115, 999, 1116,
131473 /* 200 */ 1117, 1118, 221, 1119, 1120, 1121, 1122, 1123, 1124, 788,
131474 /* 210 */ 956, 1041, 1051, 1053, 503, 1067, 1079, 1128, 1080, 1066,
131475 /* 220 */ 1068, 1045, 1083, 1047, 1103, 1102, 1125, 1126, 1073, 1062,
131476 /* 230 */ 1127, 1131, 1089, 1093, 1135, 1052, 1136, 1137, 1059, 1060,
131477 /* 240 */ 1141, 1084, 1130, 1132, 1133, 1134, 1138, 1139, 1151, 1154,
131478 /* 250 */ 1140, 1094, 1143, 1145, 1142, 1156, 1158, 1082, 1086, 1162,
131479 /* 260 */ 1163, 1165, 1150, 1169, 1177, 1170, 1179, 1161, 1166, 1168,
131480 /* 270 */ 1172, 1167, 1173, 1174, 1175, 1180, 1181, 1182, 1184, 1144,
131481 /* 280 */ 1146, 1148, 1147, 1149, 1152, 1153, 1160, 1186, 1194, 1185,
131482 /* 290 */ 1189, 1187, 1191, 1193, 1192, 1196, 1198, 1197, 1202, 1215,
131483 /* 300 */ 1217, 1226, 1227, 1231, 1232, 1233, 1234, 1203, 1204, 1205,
131484 /* 310 */ 1221, 1223, 1209, 1211, 1237,
131485 };
131486 static const YYACTIONTYPE yy_default[] = {
131487 /* 0 */ 1250, 1240, 1240, 1240, 1174, 1174, 1174, 1240, 1071, 1100,
131488 /* 10 */ 1100, 1224, 1301, 1301, 1301, 1301, 1301, 1301, 1173, 1301,
131489 /* 20 */ 1301, 1301, 1301, 1240, 1075, 1106, 1301, 1301, 1301, 1301,
131490 /* 30 */ 1301, 1301, 1301, 1301, 1223, 1225, 1114, 1113, 1206, 1087,
131491 /* 40 */ 1111, 1104, 1108, 1175, 1169, 1170, 1168, 1172, 1176, 1301,
131492 /* 50 */ 1107, 1138, 1153, 1137, 1301, 1301, 1301, 1301, 1301, 1301,
131493 /* 60 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131494 /* 70 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131495 /* 80 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131496 /* 90 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1147, 1152, 1159,
131497 /* 100 */ 1151, 1148, 1140, 1139, 1141, 1142, 1301, 994, 1042, 1301,
131498 /* 110 */ 1301, 1301, 1143, 1301, 1144, 1156, 1155, 1154, 1231, 1258,
131499 /* 120 */ 1257, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131500 /* 130 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131501 /* 140 */ 1301, 1301, 1301, 1301, 1301, 1301, 1250, 1240, 1000, 1000,
131502 /* 150 */ 1301, 1240, 1240, 1240, 1240, 1240, 1240, 1236, 1075, 1066,
131503 /* 160 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131504 /* 170 */ 1228, 1226, 1301, 1187, 1301, 1301, 1301, 1301, 1301, 1301,
131505 /* 180 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131506 /* 190 */ 1301, 1301, 1301, 1301, 1301, 1071, 1301, 1301, 1301, 1301,
131507 /* 200 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1252, 1301,
131508 /* 210 */ 1201, 1071, 1071, 1071, 1073, 1055, 1065, 979, 1110, 1089,
131509 /* 220 */ 1089, 1290, 1110, 1290, 1017, 1272, 1014, 1100, 1089, 1171,
131510 /* 230 */ 1100, 1100, 1072, 1065, 1301, 1293, 1080, 1080, 1292, 1292,
131511 /* 240 */ 1080, 1119, 1045, 1110, 1051, 1051, 1051, 1051, 1080, 991,
131512 /* 250 */ 1110, 1119, 1045, 1045, 1110, 1080, 991, 1205, 1287, 1080,
131513 /* 260 */ 1080, 991, 1180, 1080, 991, 1080, 991, 1180, 1043, 1043,
131514 /* 270 */ 1043, 1032, 1180, 1043, 1017, 1043, 1032, 1043, 1043, 1093,
131515 /* 280 */ 1088, 1093, 1088, 1093, 1088, 1093, 1088, 1080, 1080, 1301,
131516 /* 290 */ 1180, 1184, 1184, 1180, 1105, 1094, 1103, 1101, 1110, 997,
131517 /* 300 */ 1035, 1255, 1255, 1251, 1251, 1251, 1251, 1298, 1298, 1236,
131518 /* 310 */ 1267, 1267, 1019, 1019, 1267, 1301, 1301, 1301, 1301, 1301,
131519 /* 320 */ 1301, 1262, 1301, 1189, 1301, 1301, 1301, 1301, 1301, 1301,
131520 /* 330 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131521 /* 340 */ 1125, 1301, 975, 1233, 1301, 1301, 1232, 1301, 1301, 1301,
131522 /* 350 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131523 /* 360 */ 1301, 1301, 1301, 1301, 1301, 1289, 1301, 1301, 1301, 1301,
131524 /* 370 */ 1301, 1301, 1204, 1203, 1301, 1301, 1301, 1301, 1301, 1301,
131525 /* 380 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131526 /* 390 */ 1301, 1301, 1301, 1301, 1301, 1301, 1057, 1301, 1301, 1301,
131527 /* 400 */ 1276, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1102, 1301,
131528 /* 410 */ 1095, 1301, 1280, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131529 /* 420 */ 1301, 1301, 1301, 1242, 1301, 1301, 1301, 1241, 1301, 1301,
131530 /* 430 */ 1301, 1301, 1301, 1127, 1301, 1126, 1130, 1301, 985, 1301,
 
131531 };
131532 /********** End of lemon-generated parsing tables *****************************/
131533
131534 /* The next table maps tokens (terminal symbols) into fallback tokens.
131535 ** If a construct like the following:
@@ -131672,21 +132273,22 @@
131672 typedef struct yyStackEntry yyStackEntry;
131673
131674 /* The state of the parser is completely contained in an instance of
131675 ** the following structure */
131676 struct yyParser {
131677 int yyidx; /* Index of top element in stack */
131678 #ifdef YYTRACKMAXSTACKDEPTH
131679 int yyidxMax; /* Maximum value of yyidx */
131680 #endif
131681 #ifndef YYNOERRORRECOVERY
131682 int yyerrcnt; /* Shifts left before out of the error */
131683 #endif
131684 sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
131685 #if YYSTACKDEPTH<=0
131686 int yystksz; /* Current side of the stack */
131687 yyStackEntry *yystack; /* The parser's stack */
 
131688 #else
131689 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
131690 #endif
131691 };
131692 typedef struct yyParser yyParser;
@@ -131781,17 +132383,17 @@
131781 "orderby_opt", "limit_opt", "values", "nexprlist",
131782 "exprlist", "sclp", "as", "seltablist",
131783 "stl_prefix", "joinop", "indexed_opt", "on_opt",
131784 "using_opt", "idlist", "setlist", "insert_cmd",
131785 "idlist_opt", "likeop", "between_op", "in_op",
131786 "case_operand", "case_exprlist", "case_else", "uniqueflag",
131787 "collate", "nmnum", "trigger_decl", "trigger_cmd_list",
131788 "trigger_time", "trigger_event", "foreach_clause", "when_clause",
131789 "trigger_cmd", "trnm", "tridxby", "database_kw_opt",
131790 "key_opt", "add_column_fullname", "kwcolumn_opt", "create_vtab",
131791 "vtabarglist", "vtabarg", "vtabargtoken", "lp",
131792 "anylist", "wqlist",
131793 };
131794 #endif /* NDEBUG */
131795
131796 #ifndef NDEBUG
131797 /* For tracing reduce actions, the names of all rules are required.
@@ -131985,11 +132587,11 @@
131985 /* 185 */ "in_op ::= IN",
131986 /* 186 */ "in_op ::= NOT IN",
131987 /* 187 */ "expr ::= expr in_op LP exprlist RP",
131988 /* 188 */ "expr ::= LP select RP",
131989 /* 189 */ "expr ::= expr in_op LP select RP",
131990 /* 190 */ "expr ::= expr in_op nm dbnm",
131991 /* 191 */ "expr ::= EXISTS LP select RP",
131992 /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
131993 /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
131994 /* 194 */ "case_exprlist ::= WHEN expr THEN expr",
131995 /* 195 */ "case_else ::= ELSE expr",
@@ -131997,158 +132599,170 @@
131997 /* 197 */ "case_operand ::= expr",
131998 /* 198 */ "case_operand ::=",
131999 /* 199 */ "exprlist ::=",
132000 /* 200 */ "nexprlist ::= nexprlist COMMA expr",
132001 /* 201 */ "nexprlist ::= expr",
132002 /* 202 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132003 /* 203 */ "uniqueflag ::= UNIQUE",
132004 /* 204 */ "uniqueflag ::=",
132005 /* 205 */ "eidlist_opt ::=",
132006 /* 206 */ "eidlist_opt ::= LP eidlist RP",
132007 /* 207 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132008 /* 208 */ "eidlist ::= nm collate sortorder",
132009 /* 209 */ "collate ::=",
132010 /* 210 */ "collate ::= COLLATE ID|STRING",
132011 /* 211 */ "cmd ::= DROP INDEX ifexists fullname",
132012 /* 212 */ "cmd ::= VACUUM",
132013 /* 213 */ "cmd ::= VACUUM nm",
132014 /* 214 */ "cmd ::= PRAGMA nm dbnm",
132015 /* 215 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132016 /* 216 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132017 /* 217 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132018 /* 218 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132019 /* 219 */ "plus_num ::= PLUS INTEGER|FLOAT",
132020 /* 220 */ "minus_num ::= MINUS INTEGER|FLOAT",
132021 /* 221 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132022 /* 222 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132023 /* 223 */ "trigger_time ::= BEFORE",
132024 /* 224 */ "trigger_time ::= AFTER",
132025 /* 225 */ "trigger_time ::= INSTEAD OF",
132026 /* 226 */ "trigger_time ::=",
132027 /* 227 */ "trigger_event ::= DELETE|INSERT",
132028 /* 228 */ "trigger_event ::= UPDATE",
132029 /* 229 */ "trigger_event ::= UPDATE OF idlist",
132030 /* 230 */ "when_clause ::=",
132031 /* 231 */ "when_clause ::= WHEN expr",
132032 /* 232 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132033 /* 233 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132034 /* 234 */ "trnm ::= nm DOT nm",
132035 /* 235 */ "tridxby ::= INDEXED BY nm",
132036 /* 236 */ "tridxby ::= NOT INDEXED",
132037 /* 237 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132038 /* 238 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132039 /* 239 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132040 /* 240 */ "trigger_cmd ::= select",
132041 /* 241 */ "expr ::= RAISE LP IGNORE RP",
132042 /* 242 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132043 /* 243 */ "raisetype ::= ROLLBACK",
132044 /* 244 */ "raisetype ::= ABORT",
132045 /* 245 */ "raisetype ::= FAIL",
132046 /* 246 */ "cmd ::= DROP TRIGGER ifexists fullname",
132047 /* 247 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132048 /* 248 */ "cmd ::= DETACH database_kw_opt expr",
132049 /* 249 */ "key_opt ::=",
132050 /* 250 */ "key_opt ::= KEY expr",
132051 /* 251 */ "cmd ::= REINDEX",
132052 /* 252 */ "cmd ::= REINDEX nm dbnm",
132053 /* 253 */ "cmd ::= ANALYZE",
132054 /* 254 */ "cmd ::= ANALYZE nm dbnm",
132055 /* 255 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132056 /* 256 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132057 /* 257 */ "add_column_fullname ::= fullname",
132058 /* 258 */ "cmd ::= create_vtab",
132059 /* 259 */ "cmd ::= create_vtab LP vtabarglist RP",
132060 /* 260 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132061 /* 261 */ "vtabarg ::=",
132062 /* 262 */ "vtabargtoken ::= ANY",
132063 /* 263 */ "vtabargtoken ::= lp anylist RP",
132064 /* 264 */ "lp ::= LP",
132065 /* 265 */ "with ::=",
132066 /* 266 */ "with ::= WITH wqlist",
132067 /* 267 */ "with ::= WITH RECURSIVE wqlist",
132068 /* 268 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132069 /* 269 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132070 /* 270 */ "input ::= cmdlist",
132071 /* 271 */ "cmdlist ::= cmdlist ecmd",
132072 /* 272 */ "cmdlist ::= ecmd",
132073 /* 273 */ "ecmd ::= SEMI",
132074 /* 274 */ "ecmd ::= explain cmdx SEMI",
132075 /* 275 */ "explain ::=",
132076 /* 276 */ "trans_opt ::=",
132077 /* 277 */ "trans_opt ::= TRANSACTION",
132078 /* 278 */ "trans_opt ::= TRANSACTION nm",
132079 /* 279 */ "savepoint_opt ::= SAVEPOINT",
132080 /* 280 */ "savepoint_opt ::=",
132081 /* 281 */ "cmd ::= create_table create_table_args",
132082 /* 282 */ "columnlist ::= columnlist COMMA columnname carglist",
132083 /* 283 */ "columnlist ::= columnname carglist",
132084 /* 284 */ "nm ::= ID|INDEXED",
132085 /* 285 */ "nm ::= STRING",
132086 /* 286 */ "nm ::= JOIN_KW",
132087 /* 287 */ "typetoken ::= typename",
132088 /* 288 */ "typename ::= ID|STRING",
132089 /* 289 */ "signed ::= plus_num",
132090 /* 290 */ "signed ::= minus_num",
132091 /* 291 */ "carglist ::= carglist ccons",
132092 /* 292 */ "carglist ::=",
132093 /* 293 */ "ccons ::= NULL onconf",
132094 /* 294 */ "conslist_opt ::= COMMA conslist",
132095 /* 295 */ "conslist ::= conslist tconscomma tcons",
132096 /* 296 */ "conslist ::= tcons",
132097 /* 297 */ "tconscomma ::=",
132098 /* 298 */ "defer_subclause_opt ::= defer_subclause",
132099 /* 299 */ "resolvetype ::= raisetype",
132100 /* 300 */ "selectnowith ::= oneselect",
132101 /* 301 */ "oneselect ::= values",
132102 /* 302 */ "sclp ::= selcollist COMMA",
132103 /* 303 */ "as ::= ID|STRING",
132104 /* 304 */ "expr ::= term",
132105 /* 305 */ "exprlist ::= nexprlist",
132106 /* 306 */ "nmnum ::= plus_num",
132107 /* 307 */ "nmnum ::= nm",
132108 /* 308 */ "nmnum ::= ON",
132109 /* 309 */ "nmnum ::= DELETE",
132110 /* 310 */ "nmnum ::= DEFAULT",
132111 /* 311 */ "plus_num ::= INTEGER|FLOAT",
132112 /* 312 */ "foreach_clause ::=",
132113 /* 313 */ "foreach_clause ::= FOR EACH ROW",
132114 /* 314 */ "trnm ::= nm",
132115 /* 315 */ "tridxby ::=",
132116 /* 316 */ "database_kw_opt ::= DATABASE",
132117 /* 317 */ "database_kw_opt ::=",
132118 /* 318 */ "kwcolumn_opt ::=",
132119 /* 319 */ "kwcolumn_opt ::= COLUMNKW",
132120 /* 320 */ "vtabarglist ::= vtabarg",
132121 /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132122 /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
132123 /* 323 */ "anylist ::=",
132124 /* 324 */ "anylist ::= anylist LP anylist RP",
132125 /* 325 */ "anylist ::= anylist ANY",
 
 
132126 };
132127 #endif /* NDEBUG */
132128
132129
132130 #if YYSTACKDEPTH<=0
132131 /*
132132 ** Try to increase the size of the parser stack.
 
132133 */
132134 static void yyGrowStack(yyParser *p){
132135 int newSize;
 
132136 yyStackEntry *pNew;
132137
132138 newSize = p->yystksz*2 + 100;
132139 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
 
 
 
 
 
 
132140 if( pNew ){
132141 p->yystack = pNew;
132142 p->yystksz = newSize;
132143 #ifndef NDEBUG
132144 if( yyTraceFILE ){
132145 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
132146 yyTracePrompt, p->yystksz);
132147 }
132148 #endif
 
132149 }
 
132150 }
132151 #endif
132152
132153 /* Datatype of the argument to the memory allocated passed as the
132154 ** second argument to sqlite3ParserAlloc() below. This can be changed by
@@ -132173,19 +132787,28 @@
132173 */
132174 SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
132175 yyParser *pParser;
132176 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
132177 if( pParser ){
132178 pParser->yyidx = -1;
132179 #ifdef YYTRACKMAXSTACKDEPTH
132180 pParser->yyidxMax = 0;
132181 #endif
132182 #if YYSTACKDEPTH<=0
 
132183 pParser->yystack = NULL;
132184 pParser->yystksz = 0;
132185 yyGrowStack(pParser);
 
 
 
132186 #endif
 
 
 
 
 
 
132187 }
132188 return pParser;
132189 }
132190
132191 /* The following function deletes the "minor type" or semantic value
@@ -132216,17 +132839,17 @@
132216 case 163: /* select */
132217 case 194: /* selectnowith */
132218 case 195: /* oneselect */
132219 case 206: /* values */
132220 {
132221 sqlite3SelectDelete(pParse->db, (yypminor->yy159));
132222 }
132223 break;
132224 case 172: /* term */
132225 case 173: /* expr */
132226 {
132227 sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);
132228 }
132229 break;
132230 case 177: /* eidlist_opt */
132231 case 186: /* sortlist */
132232 case 187: /* eidlist */
@@ -132235,56 +132858,57 @@
132235 case 204: /* orderby_opt */
132236 case 207: /* nexprlist */
132237 case 208: /* exprlist */
132238 case 209: /* sclp */
132239 case 218: /* setlist */
132240 case 225: /* case_exprlist */
 
132241 {
132242 sqlite3ExprListDelete(pParse->db, (yypminor->yy442));
132243 }
132244 break;
132245 case 193: /* fullname */
132246 case 200: /* from */
132247 case 211: /* seltablist */
132248 case 212: /* stl_prefix */
132249 {
132250 sqlite3SrcListDelete(pParse->db, (yypminor->yy347));
132251 }
132252 break;
132253 case 196: /* with */
132254 case 249: /* wqlist */
132255 {
132256 sqlite3WithDelete(pParse->db, (yypminor->yy331));
132257 }
132258 break;
132259 case 201: /* where_opt */
132260 case 203: /* having_opt */
132261 case 215: /* on_opt */
132262 case 224: /* case_operand */
132263 case 226: /* case_else */
132264 case 235: /* when_clause */
132265 case 240: /* key_opt */
132266 {
132267 sqlite3ExprDelete(pParse->db, (yypminor->yy122));
132268 }
132269 break;
132270 case 216: /* using_opt */
132271 case 217: /* idlist */
132272 case 220: /* idlist_opt */
132273 {
132274 sqlite3IdListDelete(pParse->db, (yypminor->yy180));
132275 }
132276 break;
132277 case 231: /* trigger_cmd_list */
132278 case 236: /* trigger_cmd */
132279 {
132280 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327));
132281 }
132282 break;
132283 case 233: /* trigger_event */
132284 {
132285 sqlite3IdListDelete(pParse->db, (yypminor->yy410).b);
132286 }
132287 break;
132288 /********* End destructor definitions *****************************************/
132289 default: break; /* If no destructor action specified: do nothing */
132290 }
@@ -132296,12 +132920,13 @@
132296 ** If there is a destructor routine associated with the token which
132297 ** is popped from the stack, then call it.
132298 */
132299 static void yy_pop_parser_stack(yyParser *pParser){
132300 yyStackEntry *yytos;
132301 assert( pParser->yyidx>=0 );
132302 yytos = &pParser->yystack[pParser->yyidx--];
 
132303 #ifndef NDEBUG
132304 if( yyTraceFILE ){
132305 fprintf(yyTraceFILE,"%sPopping %s\n",
132306 yyTracePrompt,
132307 yyTokenName[yytos->major]);
@@ -132324,13 +132949,13 @@
132324 ){
132325 yyParser *pParser = (yyParser*)p;
132326 #ifndef YYPARSEFREENEVERNULL
132327 if( pParser==0 ) return;
132328 #endif
132329 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
132330 #if YYSTACKDEPTH<=0
132331 free(pParser->yystack);
132332 #endif
132333 (*freeProc)((void*)pParser);
132334 }
132335
132336 /*
@@ -132337,11 +132962,11 @@
132337 ** Return the peak depth of the stack for a parser.
132338 */
132339 #ifdef YYTRACKMAXSTACKDEPTH
132340 SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){
132341 yyParser *pParser = (yyParser*)p;
132342 return pParser->yyidxMax;
132343 }
132344 #endif
132345
132346 /*
132347 ** Find the appropriate action for a parser given the terminal
@@ -132350,11 +132975,11 @@
132350 static unsigned int yy_find_shift_action(
132351 yyParser *pParser, /* The parser */
132352 YYCODETYPE iLookAhead /* The look-ahead token */
132353 ){
132354 int i;
132355 int stateno = pParser->yystack[pParser->yyidx].stateno;
132356
132357 if( stateno>=YY_MIN_REDUCE ) return stateno;
132358 assert( stateno <= YY_SHIFT_COUNT );
132359 do{
132360 i = yy_shift_ofst[stateno];
@@ -132443,17 +133068,17 @@
132443 /*
132444 ** The following routine is called if the stack overflows.
132445 */
132446 static void yyStackOverflow(yyParser *yypParser){
132447 sqlite3ParserARG_FETCH;
132448 yypParser->yyidx--;
132449 #ifndef NDEBUG
132450 if( yyTraceFILE ){
132451 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
132452 }
132453 #endif
132454 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
132455 /* Here code is inserted which will execute if the parser
132456 ** stack every overflows */
132457 /******** Begin %stack_overflow code ******************************************/
132458
132459 sqlite3ErrorMsg(pParse, "parser stack overflow");
@@ -132467,15 +133092,15 @@
132467 #ifndef NDEBUG
132468 static void yyTraceShift(yyParser *yypParser, int yyNewState){
132469 if( yyTraceFILE ){
132470 if( yyNewState<YYNSTATE ){
132471 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
132472 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
132473 yyNewState);
132474 }else{
132475 fprintf(yyTraceFILE,"%sShift '%s'\n",
132476 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
132477 }
132478 }
132479 }
132480 #else
132481 # define yyTraceShift(X,Y)
@@ -132489,31 +133114,34 @@
132489 int yyNewState, /* The new state to shift in */
132490 int yyMajor, /* The major token to shift in */
132491 sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
132492 ){
132493 yyStackEntry *yytos;
132494 yypParser->yyidx++;
132495 #ifdef YYTRACKMAXSTACKDEPTH
132496 if( yypParser->yyidx>yypParser->yyidxMax ){
132497 yypParser->yyidxMax = yypParser->yyidx;
 
132498 }
132499 #endif
132500 #if YYSTACKDEPTH>0
132501 if( yypParser->yyidx>=YYSTACKDEPTH ){
132502 yyStackOverflow(yypParser);
132503 return;
132504 }
132505 #else
132506 if( yypParser->yyidx>=yypParser->yystksz ){
132507 yyGrowStack(yypParser);
132508 if( yypParser->yyidx>=yypParser->yystksz ){
132509 yyStackOverflow(yypParser);
132510 return;
132511 }
132512 }
132513 #endif
132514 yytos = &yypParser->yystack[yypParser->yyidx];
 
 
 
132515 yytos->stateno = (YYACTIONTYPE)yyNewState;
132516 yytos->major = (YYCODETYPE)yyMajor;
132517 yytos->minor.yy0 = yyMinor;
132518 yyTraceShift(yypParser, yyNewState);
132519 }
@@ -132713,31 +133341,33 @@
132713 { 223, 1 },
132714 { 223, 2 },
132715 { 173, 5 },
132716 { 173, 3 },
132717 { 173, 5 },
132718 { 173, 4 },
132719 { 173, 4 },
132720 { 173, 5 },
132721 { 225, 5 },
132722 { 225, 4 },
132723 { 226, 2 },
132724 { 226, 0 },
132725 { 224, 1 },
132726 { 224, 0 },
132727 { 208, 0 },
132728 { 207, 3 },
132729 { 207, 1 },
 
 
132730 { 149, 12 },
132731 { 227, 1 },
132732 { 227, 0 },
132733 { 177, 0 },
132734 { 177, 3 },
132735 { 187, 5 },
132736 { 187, 3 },
132737 { 228, 0 },
132738 { 228, 2 },
132739 { 149, 4 },
132740 { 149, 1 },
132741 { 149, 2 },
132742 { 149, 3 },
132743 { 149, 5 },
@@ -132745,58 +133375,58 @@
132745 { 149, 5 },
132746 { 149, 6 },
132747 { 169, 2 },
132748 { 170, 2 },
132749 { 149, 5 },
132750 { 230, 11 },
132751 { 232, 1 },
132752 { 232, 1 },
132753 { 232, 2 },
132754 { 232, 0 },
132755 { 233, 1 },
132756 { 233, 1 },
132757 { 233, 3 },
132758 { 235, 0 },
132759 { 235, 2 },
132760 { 231, 3 },
132761 { 231, 2 },
132762 { 237, 3 },
 
 
 
132763 { 238, 3 },
132764 { 238, 2 },
132765 { 236, 7 },
132766 { 236, 5 },
132767 { 236, 5 },
132768 { 236, 1 },
 
132769 { 173, 4 },
132770 { 173, 6 },
132771 { 191, 1 },
132772 { 191, 1 },
132773 { 191, 1 },
132774 { 149, 4 },
132775 { 149, 6 },
132776 { 149, 3 },
132777 { 240, 0 },
132778 { 240, 2 },
132779 { 149, 1 },
132780 { 149, 3 },
132781 { 149, 1 },
132782 { 149, 3 },
132783 { 149, 6 },
132784 { 149, 7 },
132785 { 241, 1 },
132786 { 149, 1 },
132787 { 149, 4 },
132788 { 243, 8 },
132789 { 245, 0 },
132790 { 246, 1 },
132791 { 246, 3 },
132792 { 247, 1 },
 
 
132793 { 196, 0 },
132794 { 196, 2 },
132795 { 196, 3 },
132796 { 249, 6 },
132797 { 249, 8 },
132798 { 144, 1 },
132799 { 145, 2 },
132800 { 145, 1 },
132801 { 146, 1 },
132802 { 146, 3 },
@@ -132829,30 +133459,30 @@
132829 { 195, 1 },
132830 { 209, 2 },
132831 { 210, 1 },
132832 { 173, 1 },
132833 { 208, 1 },
132834 { 229, 1 },
132835 { 229, 1 },
132836 { 229, 1 },
132837 { 229, 1 },
132838 { 229, 1 },
132839 { 169, 1 },
132840 { 234, 0 },
132841 { 234, 3 },
132842 { 237, 1 },
132843 { 238, 0 },
132844 { 239, 1 },
132845 { 239, 0 },
132846 { 242, 0 },
132847 { 242, 1 },
132848 { 244, 1 },
132849 { 244, 3 },
132850 { 245, 2 },
132851 { 248, 0 },
132852 { 248, 4 },
132853 { 248, 2 },
 
 
132854 };
132855
132856 static void yy_accept(yyParser*); /* Forward Declaration */
132857
132858 /*
@@ -132866,11 +133496,11 @@
132866 int yygoto; /* The next state */
132867 int yyact; /* The next action */
132868 yyStackEntry *yymsp; /* The top of the parser's stack */
132869 int yysize; /* Amount to pop the stack */
132870 sqlite3ParserARG_FETCH;
132871 yymsp = &yypParser->yystack[yypParser->yyidx];
132872 #ifndef NDEBUG
132873 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
132874 yysize = yyRuleInfo[yyruleno].nrhs;
132875 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
132876 yyRuleName[yyruleno], yymsp[-yysize].stateno);
@@ -132880,26 +133510,27 @@
132880 /* Check that the stack is large enough to grow by a single entry
132881 ** if the RHS of the rule is empty. This ensures that there is room
132882 ** enough on the stack to push the LHS value */
132883 if( yyRuleInfo[yyruleno].nrhs==0 ){
132884 #ifdef YYTRACKMAXSTACKDEPTH
132885 if( yypParser->yyidx>yypParser->yyidxMax ){
132886 yypParser->yyidxMax = yypParser->yyidx;
 
132887 }
132888 #endif
132889 #if YYSTACKDEPTH>0
132890 if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
132891 yyStackOverflow(yypParser);
132892 return;
132893 }
132894 #else
132895 if( yypParser->yyidx>=yypParser->yystksz-1 ){
132896 yyGrowStack(yypParser);
132897 if( yypParser->yyidx>=yypParser->yystksz-1 ){
132898 yyStackOverflow(yypParser);
132899 return;
132900 }
 
132901 }
132902 #endif
132903 }
132904
132905 switch( yyruleno ){
@@ -132921,19 +133552,19 @@
132921 break;
132922 case 2: /* cmdx ::= cmd */
132923 { sqlite3FinishCoding(pParse); }
132924 break;
132925 case 3: /* cmd ::= BEGIN transtype trans_opt */
132926 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);}
132927 break;
132928 case 4: /* transtype ::= */
132929 {yymsp[1].minor.yy392 = TK_DEFERRED;}
132930 break;
132931 case 5: /* transtype ::= DEFERRED */
132932 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
132933 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
132934 {yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-X*/}
132935 break;
132936 case 8: /* cmd ::= COMMIT trans_opt */
132937 case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
132938 {sqlite3CommitTransaction(pParse);}
132939 break;
@@ -132955,11 +133586,11 @@
132955 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
132956 }
132957 break;
132958 case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
132959 {
132960 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392);
132961 }
132962 break;
132963 case 15: /* createkw ::= CREATE */
132964 {disableLookaside(pParse);}
132965 break;
@@ -132969,37 +133600,37 @@
132969 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
132970 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
132971 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
132972 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
132973 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
132974 case 209: /* collate ::= */ yytestcase(yyruleno==209);
132975 {yymsp[1].minor.yy392 = 0;}
132976 break;
132977 case 17: /* ifnotexists ::= IF NOT EXISTS */
132978 {yymsp[-2].minor.yy392 = 1;}
132979 break;
132980 case 18: /* temp ::= TEMP */
132981 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
132982 {yymsp[0].minor.yy392 = 1;}
132983 break;
132984 case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
132985 {
132986 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy392,0);
132987 }
132988 break;
132989 case 21: /* create_table_args ::= AS select */
132990 {
132991 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy159);
132992 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
132993 }
132994 break;
132995 case 23: /* table_options ::= WITHOUT nm */
132996 {
132997 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
132998 yymsp[-1].minor.yy392 = TF_WithoutRowid | TF_NoVisibleRowid;
132999 }else{
133000 yymsp[-1].minor.yy392 = 0;
133001 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
133002 }
133003 }
133004 break;
133005 case 24: /* columnname ::= nm typetoken */
@@ -133027,21 +133658,21 @@
133027 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
133028 {pParse->constraintName = yymsp[0].minor.yy0;}
133029 break;
133030 case 30: /* ccons ::= DEFAULT term */
133031 case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
133032 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
133033 break;
133034 case 31: /* ccons ::= DEFAULT LP expr RP */
133035 {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);}
133036 break;
133037 case 33: /* ccons ::= DEFAULT MINUS term */
133038 {
133039 ExprSpan v;
133040 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);
133041 v.zStart = yymsp[-1].minor.yy0.z;
133042 v.zEnd = yymsp[0].minor.yy342.zEnd;
133043 sqlite3AddDefaultValue(pParse,&v);
133044 }
133045 break;
133046 case 34: /* ccons ::= DEFAULT ID|INDEXED */
133047 {
@@ -133049,184 +133680,186 @@
133049 spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
133050 sqlite3AddDefaultValue(pParse,&v);
133051 }
133052 break;
133053 case 35: /* ccons ::= NOT NULL onconf */
133054 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);}
133055 break;
133056 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
133057 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);}
133058 break;
133059 case 37: /* ccons ::= UNIQUE onconf */
133060 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);}
 
133061 break;
133062 case 38: /* ccons ::= CHECK LP expr RP */
133063 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}
133064 break;
133065 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
133066 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);}
133067 break;
133068 case 40: /* ccons ::= defer_subclause */
133069 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);}
133070 break;
133071 case 41: /* ccons ::= COLLATE ID|STRING */
133072 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
133073 break;
133074 case 44: /* refargs ::= */
133075 { yymsp[1].minor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */}
133076 break;
133077 case 45: /* refargs ::= refargs refarg */
133078 { yymsp[-1].minor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }
133079 break;
133080 case 46: /* refarg ::= MATCH nm */
133081 { yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; }
133082 break;
133083 case 47: /* refarg ::= ON INSERT refact */
133084 { yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; }
133085 break;
133086 case 48: /* refarg ::= ON DELETE refact */
133087 { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392; yymsp[-2].minor.yy207.mask = 0x0000ff; }
133088 break;
133089 case 49: /* refarg ::= ON UPDATE refact */
133090 { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; }
133091 break;
133092 case 50: /* refact ::= SET NULL */
133093 { yymsp[-1].minor.yy392 = OE_SetNull; /* EV: R-33326-45252 */}
133094 break;
133095 case 51: /* refact ::= SET DEFAULT */
133096 { yymsp[-1].minor.yy392 = OE_SetDflt; /* EV: R-33326-45252 */}
133097 break;
133098 case 52: /* refact ::= CASCADE */
133099 { yymsp[0].minor.yy392 = OE_Cascade; /* EV: R-33326-45252 */}
133100 break;
133101 case 53: /* refact ::= RESTRICT */
133102 { yymsp[0].minor.yy392 = OE_Restrict; /* EV: R-33326-45252 */}
133103 break;
133104 case 54: /* refact ::= NO ACTION */
133105 { yymsp[-1].minor.yy392 = OE_None; /* EV: R-33326-45252 */}
133106 break;
133107 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133108 {yymsp[-2].minor.yy392 = 0;}
133109 break;
133110 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133111 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133112 case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133113 {yymsp[-1].minor.yy392 = yymsp[0].minor.yy392;}
133114 break;
133115 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133116 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133117 case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133118 case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133119 case 210: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==210);
133120 {yymsp[-1].minor.yy392 = 1;}
133121 break;
133122 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133123 {yymsp[-1].minor.yy392 = 0;}
133124 break;
133125 case 61: /* tconscomma ::= COMMA */
133126 {pParse->constraintName.n = 0;}
133127 break;
133128 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
133129 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
133130 break;
133131 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
133132 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
 
133133 break;
133134 case 65: /* tcons ::= CHECK LP expr RP onconf */
133135 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
133136 break;
133137 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
133138 {
133139 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
133140 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
133141 }
133142 break;
133143 case 68: /* onconf ::= */
133144 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
133145 {yymsp[1].minor.yy392 = OE_Default;}
133146 break;
133147 case 69: /* onconf ::= ON CONFLICT resolvetype */
133148 {yymsp[-2].minor.yy392 = yymsp[0].minor.yy392;}
133149 break;
133150 case 72: /* resolvetype ::= IGNORE */
133151 {yymsp[0].minor.yy392 = OE_Ignore;}
133152 break;
133153 case 73: /* resolvetype ::= REPLACE */
133154 case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
133155 {yymsp[0].minor.yy392 = OE_Replace;}
133156 break;
133157 case 74: /* cmd ::= DROP TABLE ifexists fullname */
133158 {
133159 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
133160 }
133161 break;
133162 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
133163 {
133164 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy159, yymsp[-7].minor.yy392, yymsp[-5].minor.yy392);
133165 }
133166 break;
133167 case 78: /* cmd ::= DROP VIEW ifexists fullname */
133168 {
133169 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
133170 }
133171 break;
133172 case 79: /* cmd ::= select */
133173 {
133174 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
133175 sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
133176 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
133177 }
133178 break;
133179 case 80: /* select ::= with selectnowith */
133180 {
133181 Select *p = yymsp[0].minor.yy159;
133182 if( p ){
133183 p->pWith = yymsp[-1].minor.yy331;
133184 parserDoubleLinkSelect(pParse, p);
133185 }else{
133186 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy331);
133187 }
133188 yymsp[-1].minor.yy159 = p; /*A-overwrites-W*/
133189 }
133190 break;
133191 case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
133192 {
133193 Select *pRhs = yymsp[0].minor.yy159;
133194 Select *pLhs = yymsp[-2].minor.yy159;
133195 if( pRhs && pRhs->pPrior ){
133196 SrcList *pFrom;
133197 Token x;
133198 x.n = 0;
133199 parserDoubleLinkSelect(pParse, pRhs);
133200 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
133201 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
133202 }
133203 if( pRhs ){
133204 pRhs->op = (u8)yymsp[-1].minor.yy392;
133205 pRhs->pPrior = pLhs;
133206 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
133207 pRhs->selFlags &= ~SF_MultiValue;
133208 if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
133209 }else{
133210 sqlite3SelectDelete(pParse->db, pLhs);
133211 }
133212 yymsp[-2].minor.yy159 = pRhs;
133213 }
133214 break;
133215 case 82: /* multiselect_op ::= UNION */
133216 case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
133217 {yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-OP*/}
133218 break;
133219 case 83: /* multiselect_op ::= UNION ALL */
133220 {yymsp[-1].minor.yy392 = TK_ALL;}
133221 break;
133222 case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
133223 {
133224 #if SELECTTRACE_ENABLED
133225 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
133226 #endif
133227 yymsp[-8].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
133228 #if SELECTTRACE_ENABLED
133229 /* Populate the Select.zSelName[] string that is used to help with
133230 ** query planner debugging, to differentiate between multiple Select
133231 ** objects in a complex query.
133232 **
@@ -133233,464 +133866,465 @@
133233 ** If the SELECT keyword is immediately followed by a C-style comment
133234 ** then extract the first few alphanumeric characters from within that
133235 ** comment to be the zSelName value. Otherwise, the label is #N where
133236 ** is an integer that is incremented with each SELECT statement seen.
133237 */
133238 if( yymsp[-8].minor.yy159!=0 ){
133239 const char *z = s.z+6;
133240 int i;
133241 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "#%d",
133242 ++pParse->nSelect);
133243 while( z[0]==' ' ) z++;
133244 if( z[0]=='/' && z[1]=='*' ){
133245 z += 2;
133246 while( z[0]==' ' ) z++;
133247 for(i=0; sqlite3Isalnum(z[i]); i++){}
133248 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "%.*s", i, z);
133249 }
133250 }
133251 #endif /* SELECTRACE_ENABLED */
133252 }
133253 break;
133254 case 86: /* values ::= VALUES LP nexprlist RP */
133255 {
133256 yymsp[-3].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0,0);
133257 }
133258 break;
133259 case 87: /* values ::= values COMMA LP exprlist RP */
133260 {
133261 Select *pRight, *pLeft = yymsp[-4].minor.yy159;
133262 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
133263 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
133264 if( pRight ){
133265 pRight->op = TK_ALL;
133266 pRight->pPrior = pLeft;
133267 yymsp[-4].minor.yy159 = pRight;
133268 }else{
133269 yymsp[-4].minor.yy159 = pLeft;
133270 }
133271 }
133272 break;
133273 case 88: /* distinct ::= DISTINCT */
133274 {yymsp[0].minor.yy392 = SF_Distinct;}
133275 break;
133276 case 89: /* distinct ::= ALL */
133277 {yymsp[0].minor.yy392 = SF_All;}
133278 break;
133279 case 91: /* sclp ::= */
133280 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
133281 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
133282 case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
133283 case 205: /* eidlist_opt ::= */ yytestcase(yyruleno==205);
133284 {yymsp[1].minor.yy442 = 0;}
 
133285 break;
133286 case 92: /* selcollist ::= sclp expr as */
133287 {
133288 yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
133289 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0, 1);
133290 sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy442,&yymsp[-1].minor.yy342);
133291 }
133292 break;
133293 case 93: /* selcollist ::= sclp STAR */
133294 {
133295 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
133296 yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
133297 }
133298 break;
133299 case 94: /* selcollist ::= sclp nm DOT STAR */
133300 {
133301 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0);
133302 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133303 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
133304 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
133305 }
133306 break;
133307 case 95: /* as ::= AS nm */
133308 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
133309 case 219: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==219);
133310 case 220: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==220);
133311 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
133312 break;
133313 case 97: /* from ::= */
133314 {yymsp[1].minor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy347));}
133315 break;
133316 case 98: /* from ::= FROM seltablist */
133317 {
133318 yymsp[-1].minor.yy347 = yymsp[0].minor.yy347;
133319 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy347);
133320 }
133321 break;
133322 case 99: /* stl_prefix ::= seltablist joinop */
133323 {
133324 if( ALWAYS(yymsp[-1].minor.yy347 && yymsp[-1].minor.yy347->nSrc>0) ) yymsp[-1].minor.yy347->a[yymsp[-1].minor.yy347->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy392;
133325 }
133326 break;
133327 case 100: /* stl_prefix ::= */
133328 {yymsp[1].minor.yy347 = 0;}
133329 break;
133330 case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
133331 {
133332 yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133333 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy347, &yymsp[-2].minor.yy0);
133334 }
133335 break;
133336 case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
133337 {
133338 yymsp[-8].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy347,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133339 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy347, yymsp[-4].minor.yy442);
133340 }
133341 break;
133342 case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
133343 {
133344 yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133345 }
133346 break;
133347 case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
133348 {
133349 if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
133350 yymsp[-6].minor.yy347 = yymsp[-4].minor.yy347;
133351 }else if( yymsp[-4].minor.yy347->nSrc==1 ){
133352 yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133353 if( yymsp[-6].minor.yy347 ){
133354 struct SrcList_item *pNew = &yymsp[-6].minor.yy347->a[yymsp[-6].minor.yy347->nSrc-1];
133355 struct SrcList_item *pOld = yymsp[-4].minor.yy347->a;
133356 pNew->zName = pOld->zName;
133357 pNew->zDatabase = pOld->zDatabase;
133358 pNew->pSelect = pOld->pSelect;
133359 pOld->zName = pOld->zDatabase = 0;
133360 pOld->pSelect = 0;
133361 }
133362 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347);
133363 }else{
133364 Select *pSubquery;
133365 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347);
133366 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0);
133367 yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133368 }
133369 }
133370 break;
133371 case 105: /* dbnm ::= */
133372 case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
133373 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
133374 break;
133375 case 107: /* fullname ::= nm dbnm */
133376 {yymsp[-1].minor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
133377 break;
133378 case 108: /* joinop ::= COMMA|JOIN */
133379 { yymsp[0].minor.yy392 = JT_INNER; }
133380 break;
133381 case 109: /* joinop ::= JOIN_KW JOIN */
133382 {yymsp[-1].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
133383 break;
133384 case 110: /* joinop ::= JOIN_KW nm JOIN */
133385 {yymsp[-2].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
133386 break;
133387 case 111: /* joinop ::= JOIN_KW nm nm JOIN */
133388 {yymsp[-3].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
133389 break;
133390 case 112: /* on_opt ::= ON expr */
133391 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
133392 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
133393 case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
133394 {yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr;}
133395 break;
133396 case 113: /* on_opt ::= */
133397 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
133398 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
133399 case 196: /* case_else ::= */ yytestcase(yyruleno==196);
133400 case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
133401 {yymsp[1].minor.yy122 = 0;}
133402 break;
133403 case 115: /* indexed_opt ::= INDEXED BY nm */
133404 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
133405 break;
133406 case 116: /* indexed_opt ::= NOT INDEXED */
133407 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
133408 break;
133409 case 117: /* using_opt ::= USING LP idlist RP */
133410 {yymsp[-3].minor.yy180 = yymsp[-1].minor.yy180;}
133411 break;
133412 case 118: /* using_opt ::= */
133413 case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
133414 {yymsp[1].minor.yy180 = 0;}
133415 break;
133416 case 120: /* orderby_opt ::= ORDER BY sortlist */
133417 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
133418 {yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;}
133419 break;
133420 case 121: /* sortlist ::= sortlist COMMA expr sortorder */
133421 {
133422 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
133423 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy392);
133424 }
133425 break;
133426 case 122: /* sortlist ::= expr sortorder */
133427 {
133428 yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); /*A-overwrites-Y*/
133429 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy392);
133430 }
133431 break;
133432 case 123: /* sortorder ::= ASC */
133433 {yymsp[0].minor.yy392 = SQLITE_SO_ASC;}
133434 break;
133435 case 124: /* sortorder ::= DESC */
133436 {yymsp[0].minor.yy392 = SQLITE_SO_DESC;}
133437 break;
133438 case 125: /* sortorder ::= */
133439 {yymsp[1].minor.yy392 = SQLITE_SO_UNDEFINED;}
133440 break;
133441 case 130: /* limit_opt ::= */
133442 {yymsp[1].minor.yy64.pLimit = 0; yymsp[1].minor.yy64.pOffset = 0;}
133443 break;
133444 case 131: /* limit_opt ::= LIMIT expr */
133445 {yymsp[-1].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yymsp[-1].minor.yy64.pOffset = 0;}
133446 break;
133447 case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
133448 {yymsp[-3].minor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
133449 break;
133450 case 133: /* limit_opt ::= LIMIT expr COMMA expr */
133451 {yymsp[-3].minor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
133452 break;
133453 case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
133454 {
133455 sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133456 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
133457 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
133458 }
133459 break;
133460 case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
133461 {
133462 sqlite3WithPush(pParse, yymsp[-7].minor.yy331, 1);
133463 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
133464 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
133465 sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy392);
133466 }
133467 break;
133468 case 138: /* setlist ::= setlist COMMA nm EQ expr */
133469 {
133470 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
133471 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1);
133472 }
133473 break;
133474 case 139: /* setlist ::= nm EQ expr */
133475 {
133476 yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
133477 sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1);
133478 }
133479 yymsp[-2].minor.yy442 = yylhsminor.yy442;
133480 break;
133481 case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
133482 {
133483 sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133484 sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy392);
133485 }
133486 break;
133487 case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
133488 {
133489 sqlite3WithPush(pParse, yymsp[-6].minor.yy331, 1);
133490 sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy392);
133491 }
133492 break;
133493 case 145: /* idlist_opt ::= LP idlist RP */
133494 {yymsp[-2].minor.yy180 = yymsp[-1].minor.yy180;}
133495 break;
133496 case 146: /* idlist ::= idlist COMMA nm */
133497 {yymsp[-2].minor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
133498 break;
133499 case 147: /* idlist ::= nm */
133500 {yymsp[0].minor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
133501 break;
133502 case 148: /* expr ::= LP expr RP */
133503 {spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr;}
133504 break;
133505 case 149: /* term ::= NULL */
133506 case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
133507 case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
133508 {spanExpr(&yymsp[0].minor.yy342,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
133509 break;
133510 case 150: /* expr ::= ID|INDEXED */
133511 case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
133512 {spanExpr(&yymsp[0].minor.yy342,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
133513 break;
133514 case 152: /* expr ::= nm DOT nm */
133515 {
133516 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133517 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133518 spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133519 yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
133520 }
133521 break;
133522 case 153: /* expr ::= nm DOT nm DOT nm */
133523 {
133524 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
133525 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133526 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133527 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
133528 spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133529 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
133530 }
133531 break;
133532 case 156: /* expr ::= VARIABLE */
133533 {
133534 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
133535 spanExpr(&yymsp[0].minor.yy342, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
133536 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy342.pExpr);
133537 }else{
133538 /* When doing a nested parse, one can include terms in an expression
133539 ** that look like this: #1 #2 ... These terms refer to registers
133540 ** in the virtual machine. #N is the N-th register. */
133541 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
133542 assert( t.n>=2 );
133543 spanSet(&yymsp[0].minor.yy342, &t, &t);
133544 if( pParse->nested==0 ){
133545 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
133546 yymsp[0].minor.yy342.pExpr = 0;
133547 }else{
133548 yymsp[0].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
133549 if( yymsp[0].minor.yy342.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy342.pExpr->iTable);
133550 }
133551 }
133552 }
133553 break;
133554 case 157: /* expr ::= expr COLLATE ID|STRING */
133555 {
133556 yymsp[-2].minor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0, 1);
133557 yymsp[-2].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133558 }
133559 break;
133560 case 158: /* expr ::= CAST LP expr AS typetoken RP */
133561 {
133562 spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133563 yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
133564 }
133565 break;
133566 case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
133567 {
133568 if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
133569 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
133570 }
133571 yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
133572 spanSet(&yylhsminor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
133573 if( yymsp[-2].minor.yy392==SF_Distinct && yylhsminor.yy342.pExpr ){
133574 yylhsminor.yy342.pExpr->flags |= EP_Distinct;
133575 }
133576 }
133577 yymsp[-4].minor.yy342 = yylhsminor.yy342;
133578 break;
133579 case 160: /* expr ::= ID|INDEXED LP STAR RP */
133580 {
133581 yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
133582 spanSet(&yylhsminor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
133583 }
133584 yymsp[-3].minor.yy342 = yylhsminor.yy342;
133585 break;
133586 case 161: /* term ::= CTIME_KW */
133587 {
133588 yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
133589 spanSet(&yylhsminor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
133590 }
133591 yymsp[0].minor.yy342 = yylhsminor.yy342;
133592 break;
133593 case 162: /* expr ::= expr AND expr */
133594 case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
133595 case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
133596 case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
133597 case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
133598 case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
133599 case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
133600 case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
133601 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
133602 break;
133603 case 170: /* likeop ::= LIKE_KW|MATCH */
133604 {yymsp[0].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy318.bNot = 0;/*A-overwrites-X*/}
133605 break;
133606 case 171: /* likeop ::= NOT LIKE_KW|MATCH */
133607 {yymsp[-1].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy318.bNot = 1;}
133608 break;
133609 case 172: /* expr ::= expr likeop expr */
133610 {
133611 ExprList *pList;
133612 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
133613 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
133614 yymsp[-2].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
133615 exprNot(pParse, yymsp[-1].minor.yy318.bNot, &yymsp[-2].minor.yy342);
133616 yymsp[-2].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133617 if( yymsp[-2].minor.yy342.pExpr ) yymsp[-2].minor.yy342.pExpr->flags |= EP_InfixFunc;
133618 }
133619 break;
133620 case 173: /* expr ::= expr likeop expr ESCAPE expr */
133621 {
133622 ExprList *pList;
133623 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133624 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
133625 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133626 yymsp[-4].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
133627 exprNot(pParse, yymsp[-3].minor.yy318.bNot, &yymsp[-4].minor.yy342);
133628 yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133629 if( yymsp[-4].minor.yy342.pExpr ) yymsp[-4].minor.yy342.pExpr->flags |= EP_InfixFunc;
133630 }
133631 break;
133632 case 174: /* expr ::= expr ISNULL|NOTNULL */
133633 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
133634 break;
133635 case 175: /* expr ::= expr NOT NULL */
133636 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
133637 break;
133638 case 176: /* expr ::= expr IS expr */
133639 {
133640 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
133641 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-2].minor.yy342.pExpr, TK_ISNULL);
133642 }
133643 break;
133644 case 177: /* expr ::= expr IS NOT expr */
133645 {
133646 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
133647 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-3].minor.yy342.pExpr, TK_NOTNULL);
133648 }
133649 break;
133650 case 178: /* expr ::= NOT expr */
133651 case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
133652 {spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133653 break;
133654 case 180: /* expr ::= MINUS expr */
133655 {spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133656 break;
133657 case 181: /* expr ::= PLUS expr */
133658 {spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133659 break;
133660 case 182: /* between_op ::= BETWEEN */
133661 case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
133662 {yymsp[0].minor.yy392 = 0;}
133663 break;
133664 case 184: /* expr ::= expr between_op expr AND expr */
133665 {
133666 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133667 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133668 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133669 if( yymsp[-4].minor.yy342.pExpr ){
133670 yymsp[-4].minor.yy342.pExpr->x.pList = pList;
133671 }else{
133672 sqlite3ExprListDelete(pParse->db, pList);
133673 }
133674 exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133675 yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133676 }
133677 break;
133678 case 187: /* expr ::= expr in_op LP exprlist RP */
133679 {
133680 if( yymsp[-1].minor.yy442==0 ){
133681 /* Expressions of the form
133682 **
133683 ** expr1 IN ()
133684 ** expr1 NOT IN ()
133685 **
133686 ** simplify to constants 0 (false) and 1 (true), respectively,
133687 ** regardless of the value of expr1.
133688 */
133689 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);
133690 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);
133691 }else if( yymsp[-1].minor.yy442->nExpr==1 ){
133692 /* Expressions of the form:
133693 **
133694 ** expr1 IN (?1)
133695 ** expr1 NOT IN (?2)
133696 **
@@ -133703,417 +134337,421 @@
133703 ** But, the RHS of the == or <> is marked with the EP_Generic flag
133704 ** so that it may not contribute to the computation of comparison
133705 ** affinity or the collating sequence to use for comparison. Otherwise,
133706 ** the semantics would be subtly different from IN or NOT IN.
133707 */
133708 Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr;
133709 yymsp[-1].minor.yy442->a[0].pExpr = 0;
133710 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
133711 /* pRHS cannot be NULL because a malloc error would have been detected
133712 ** before now and control would have never reached this point */
133713 if( ALWAYS(pRHS) ){
133714 pRHS->flags &= ~EP_Collate;
133715 pRHS->flags |= EP_Generic;
133716 }
133717 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy392 ? TK_NE : TK_EQ, yymsp[-4].minor.yy342.pExpr, pRHS, 0);
133718 }else{
133719 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133720 if( yymsp[-4].minor.yy342.pExpr ){
133721 yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;
133722 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
133723 }else{
133724 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
133725 }
133726 exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133727 }
133728 yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133729 }
133730 break;
133731 case 188: /* expr ::= LP select RP */
133732 {
133733 spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133734 yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
133735 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy342.pExpr, yymsp[-1].minor.yy159);
133736 }
133737 break;
133738 case 189: /* expr ::= expr in_op LP select RP */
133739 {
133740 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133741 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy342.pExpr, yymsp[-1].minor.yy159);
133742 exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133743 yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133744 }
133745 break;
133746 case 190: /* expr ::= expr in_op nm dbnm */
133747 {
133748 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
133749 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
133750 yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
133751 sqlite3PExprAddSelect(pParse, yymsp[-3].minor.yy342.pExpr, pSelect);
133752 exprNot(pParse, yymsp[-2].minor.yy392, &yymsp[-3].minor.yy342);
133753 yymsp[-3].minor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
 
133754 }
133755 break;
133756 case 191: /* expr ::= EXISTS LP select RP */
133757 {
133758 Expr *p;
133759 spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133760 p = yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
133761 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy159);
133762 }
133763 break;
133764 case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
133765 {
133766 spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
133767 yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0);
133768 if( yymsp[-4].minor.yy342.pExpr ){
133769 yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442;
133770 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
133771 }else{
133772 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
133773 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122);
133774 }
133775 }
133776 break;
133777 case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
133778 {
133779 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
133780 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
133781 }
133782 break;
133783 case 194: /* case_exprlist ::= WHEN expr THEN expr */
133784 {
133785 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133786 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy342.pExpr);
133787 }
133788 break;
133789 case 197: /* case_operand ::= expr */
133790 {yymsp[0].minor.yy122 = yymsp[0].minor.yy342.pExpr; /*A-overwrites-X*/}
133791 break;
133792 case 200: /* nexprlist ::= nexprlist COMMA expr */
133793 {yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
133794 break;
133795 case 201: /* nexprlist ::= expr */
133796 {yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr); /*A-overwrites-Y*/}
133797 break;
133798 case 202: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
 
 
 
 
133799 {
133800 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
133801 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
133802 &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
133803 }
133804 break;
133805 case 203: /* uniqueflag ::= UNIQUE */
133806 case 244: /* raisetype ::= ABORT */ yytestcase(yyruleno==244);
133807 {yymsp[0].minor.yy392 = OE_Abort;}
133808 break;
133809 case 204: /* uniqueflag ::= */
133810 {yymsp[1].minor.yy392 = OE_None;}
133811 break;
133812 case 206: /* eidlist_opt ::= LP eidlist RP */
133813 {yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;}
133814 break;
133815 case 207: /* eidlist ::= eidlist COMMA nm collate sortorder */
133816 {
133817 yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392);
133818 }
133819 break;
133820 case 208: /* eidlist ::= nm collate sortorder */
133821 {
133822 yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); /*A-overwrites-Y*/
133823 }
133824 break;
133825 case 211: /* cmd ::= DROP INDEX ifexists fullname */
133826 {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
133827 break;
133828 case 212: /* cmd ::= VACUUM */
133829 case 213: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==213);
133830 {sqlite3Vacuum(pParse);}
133831 break;
133832 case 214: /* cmd ::= PRAGMA nm dbnm */
133833 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
133834 break;
133835 case 215: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
133836 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
133837 break;
133838 case 216: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
133839 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
133840 break;
133841 case 217: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
133842 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
133843 break;
133844 case 218: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
133845 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
133846 break;
133847 case 221: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
133848 {
133849 Token all;
133850 all.z = yymsp[-3].minor.yy0.z;
133851 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
133852 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
133853 }
133854 break;
133855 case 222: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
133856 {
133857 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
133858 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
133859 }
133860 break;
133861 case 223: /* trigger_time ::= BEFORE */
133862 { yymsp[0].minor.yy392 = TK_BEFORE; }
133863 break;
133864 case 224: /* trigger_time ::= AFTER */
133865 { yymsp[0].minor.yy392 = TK_AFTER; }
133866 break;
133867 case 225: /* trigger_time ::= INSTEAD OF */
133868 { yymsp[-1].minor.yy392 = TK_INSTEAD;}
133869 break;
133870 case 226: /* trigger_time ::= */
133871 { yymsp[1].minor.yy392 = TK_BEFORE; }
133872 break;
133873 case 227: /* trigger_event ::= DELETE|INSERT */
133874 case 228: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==228);
133875 {yymsp[0].minor.yy410.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy410.b = 0;}
133876 break;
133877 case 229: /* trigger_event ::= UPDATE OF idlist */
133878 {yymsp[-2].minor.yy410.a = TK_UPDATE; yymsp[-2].minor.yy410.b = yymsp[0].minor.yy180;}
133879 break;
133880 case 230: /* when_clause ::= */
133881 case 249: /* key_opt ::= */ yytestcase(yyruleno==249);
133882 { yymsp[1].minor.yy122 = 0; }
133883 break;
133884 case 231: /* when_clause ::= WHEN expr */
133885 case 250: /* key_opt ::= KEY expr */ yytestcase(yyruleno==250);
133886 { yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr; }
133887 break;
133888 case 232: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
133889 {
133890 assert( yymsp[-2].minor.yy327!=0 );
133891 yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
133892 yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
133893 }
133894 break;
133895 case 233: /* trigger_cmd_list ::= trigger_cmd SEMI */
133896 {
133897 assert( yymsp[-1].minor.yy327!=0 );
133898 yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
133899 }
133900 break;
133901 case 234: /* trnm ::= nm DOT nm */
133902 {
133903 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
133904 sqlite3ErrorMsg(pParse,
133905 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
133906 "statements within triggers");
133907 }
133908 break;
133909 case 235: /* tridxby ::= INDEXED BY nm */
133910 {
133911 sqlite3ErrorMsg(pParse,
133912 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
133913 "within triggers");
133914 }
133915 break;
133916 case 236: /* tridxby ::= NOT INDEXED */
133917 {
133918 sqlite3ErrorMsg(pParse,
133919 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
133920 "within triggers");
133921 }
133922 break;
133923 case 237: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
133924 {yymsp[-6].minor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy392);}
133925 break;
133926 case 238: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
133927 {yymsp[-4].minor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy159, yymsp[-4].minor.yy392);/*A-overwrites-R*/}
133928 break;
133929 case 239: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
133930 {yymsp[-4].minor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
133931 break;
133932 case 240: /* trigger_cmd ::= select */
133933 {yymsp[0].minor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); /*A-overwrites-X*/}
133934 break;
133935 case 241: /* expr ::= RAISE LP IGNORE RP */
133936 {
133937 spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133938 yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
133939 if( yymsp[-3].minor.yy342.pExpr ){
133940 yymsp[-3].minor.yy342.pExpr->affinity = OE_Ignore;
133941 }
133942 }
133943 break;
133944 case 242: /* expr ::= RAISE LP raisetype COMMA nm RP */
133945 {
133946 spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133947 yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
133948 if( yymsp[-5].minor.yy342.pExpr ) {
133949 yymsp[-5].minor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
133950 }
133951 }
133952 break;
133953 case 243: /* raisetype ::= ROLLBACK */
133954 {yymsp[0].minor.yy392 = OE_Rollback;}
133955 break;
133956 case 245: /* raisetype ::= FAIL */
133957 {yymsp[0].minor.yy392 = OE_Fail;}
133958 break;
133959 case 246: /* cmd ::= DROP TRIGGER ifexists fullname */
133960 {
133961 sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
133962 }
133963 break;
133964 case 247: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
133965 {
133966 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
133967 }
133968 break;
133969 case 248: /* cmd ::= DETACH database_kw_opt expr */
133970 {
133971 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
133972 }
133973 break;
133974 case 251: /* cmd ::= REINDEX */
133975 {sqlite3Reindex(pParse, 0, 0);}
133976 break;
133977 case 252: /* cmd ::= REINDEX nm dbnm */
133978 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133979 break;
133980 case 253: /* cmd ::= ANALYZE */
133981 {sqlite3Analyze(pParse, 0, 0);}
133982 break;
133983 case 254: /* cmd ::= ANALYZE nm dbnm */
133984 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133985 break;
133986 case 255: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
133987 {
133988 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
133989 }
133990 break;
133991 case 256: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
133992 {
133993 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
133994 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
133995 }
133996 break;
133997 case 257: /* add_column_fullname ::= fullname */
133998 {
133999 disableLookaside(pParse);
134000 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
134001 }
134002 break;
134003 case 258: /* cmd ::= create_vtab */
134004 {sqlite3VtabFinishParse(pParse,0);}
134005 break;
134006 case 259: /* cmd ::= create_vtab LP vtabarglist RP */
134007 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134008 break;
134009 case 260: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134010 {
134011 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
134012 }
134013 break;
134014 case 261: /* vtabarg ::= */
134015 {sqlite3VtabArgInit(pParse);}
134016 break;
134017 case 262: /* vtabargtoken ::= ANY */
134018 case 263: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==263);
134019 case 264: /* lp ::= LP */ yytestcase(yyruleno==264);
134020 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134021 break;
134022 case 265: /* with ::= */
134023 {yymsp[1].minor.yy331 = 0;}
134024 break;
134025 case 266: /* with ::= WITH wqlist */
134026 { yymsp[-1].minor.yy331 = yymsp[0].minor.yy331; }
134027 break;
134028 case 267: /* with ::= WITH RECURSIVE wqlist */
134029 { yymsp[-2].minor.yy331 = yymsp[0].minor.yy331; }
134030 break;
134031 case 268: /* wqlist ::= nm eidlist_opt AS LP select RP */
134032 {
134033 yymsp[-5].minor.yy331 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159); /*A-overwrites-X*/
134034 }
134035 break;
134036 case 269: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134037 {
134038 yymsp[-7].minor.yy331 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy331, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159);
134039 }
134040 break;
134041 default:
134042 /* (270) input ::= cmdlist */ yytestcase(yyruleno==270);
134043 /* (271) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==271);
134044 /* (272) cmdlist ::= ecmd */ yytestcase(yyruleno==272);
134045 /* (273) ecmd ::= SEMI */ yytestcase(yyruleno==273);
134046 /* (274) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==274);
134047 /* (275) explain ::= */ yytestcase(yyruleno==275);
134048 /* (276) trans_opt ::= */ yytestcase(yyruleno==276);
134049 /* (277) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==277);
134050 /* (278) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==278);
134051 /* (279) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==279);
134052 /* (280) savepoint_opt ::= */ yytestcase(yyruleno==280);
134053 /* (281) cmd ::= create_table create_table_args */ yytestcase(yyruleno==281);
134054 /* (282) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==282);
134055 /* (283) columnlist ::= columnname carglist */ yytestcase(yyruleno==283);
134056 /* (284) nm ::= ID|INDEXED */ yytestcase(yyruleno==284);
134057 /* (285) nm ::= STRING */ yytestcase(yyruleno==285);
134058 /* (286) nm ::= JOIN_KW */ yytestcase(yyruleno==286);
134059 /* (287) typetoken ::= typename */ yytestcase(yyruleno==287);
134060 /* (288) typename ::= ID|STRING */ yytestcase(yyruleno==288);
134061 /* (289) signed ::= plus_num */ yytestcase(yyruleno==289);
134062 /* (290) signed ::= minus_num */ yytestcase(yyruleno==290);
134063 /* (291) carglist ::= carglist ccons */ yytestcase(yyruleno==291);
134064 /* (292) carglist ::= */ yytestcase(yyruleno==292);
134065 /* (293) ccons ::= NULL onconf */ yytestcase(yyruleno==293);
134066 /* (294) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==294);
134067 /* (295) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==295);
134068 /* (296) conslist ::= tcons */ yytestcase(yyruleno==296);
134069 /* (297) tconscomma ::= */ yytestcase(yyruleno==297);
134070 /* (298) defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==298);
134071 /* (299) resolvetype ::= raisetype */ yytestcase(yyruleno==299);
134072 /* (300) selectnowith ::= oneselect */ yytestcase(yyruleno==300);
134073 /* (301) oneselect ::= values */ yytestcase(yyruleno==301);
134074 /* (302) sclp ::= selcollist COMMA */ yytestcase(yyruleno==302);
134075 /* (303) as ::= ID|STRING */ yytestcase(yyruleno==303);
134076 /* (304) expr ::= term */ yytestcase(yyruleno==304);
134077 /* (305) exprlist ::= nexprlist */ yytestcase(yyruleno==305);
134078 /* (306) nmnum ::= plus_num */ yytestcase(yyruleno==306);
134079 /* (307) nmnum ::= nm */ yytestcase(yyruleno==307);
134080 /* (308) nmnum ::= ON */ yytestcase(yyruleno==308);
134081 /* (309) nmnum ::= DELETE */ yytestcase(yyruleno==309);
134082 /* (310) nmnum ::= DEFAULT */ yytestcase(yyruleno==310);
134083 /* (311) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==311);
134084 /* (312) foreach_clause ::= */ yytestcase(yyruleno==312);
134085 /* (313) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==313);
134086 /* (314) trnm ::= nm */ yytestcase(yyruleno==314);
134087 /* (315) tridxby ::= */ yytestcase(yyruleno==315);
134088 /* (316) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==316);
134089 /* (317) database_kw_opt ::= */ yytestcase(yyruleno==317);
134090 /* (318) kwcolumn_opt ::= */ yytestcase(yyruleno==318);
134091 /* (319) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==319);
134092 /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
134093 /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
134094 /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
134095 /* (323) anylist ::= */ yytestcase(yyruleno==323);
134096 /* (324) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==324);
134097 /* (325) anylist ::= anylist ANY */ yytestcase(yyruleno==325);
134098 break;
134099 /********** End reduce actions ************************************************/
134100 };
134101 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134102 yygoto = yyRuleInfo[yyruleno].lhs;
134103 yysize = yyRuleInfo[yyruleno].nrhs;
134104 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
134105 if( yyact <= YY_MAX_SHIFTREDUCE ){
134106 if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134107 yypParser->yyidx -= yysize - 1;
 
134108 yymsp -= yysize-1;
 
134109 yymsp->stateno = (YYACTIONTYPE)yyact;
134110 yymsp->major = (YYCODETYPE)yygoto;
134111 yyTraceShift(yypParser, yyact);
134112 }else{
134113 assert( yyact == YY_ACCEPT_ACTION );
134114 yypParser->yyidx -= yysize;
134115 yy_accept(yypParser);
134116 }
134117 }
134118
134119 /*
@@ -134127,11 +134765,11 @@
134127 #ifndef NDEBUG
134128 if( yyTraceFILE ){
134129 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
134130 }
134131 #endif
134132 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
134133 /* Here code is inserted which will be executed whenever the
134134 ** parser fails */
134135 /************ Begin %parse_failure code ***************************************/
134136 /************ End %parse_failure code *****************************************/
134137 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134167,11 +134805,14 @@
134167 #ifndef NDEBUG
134168 if( yyTraceFILE ){
134169 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
134170 }
134171 #endif
134172 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
 
 
 
134173 /* Here code is inserted which will be executed whenever the
134174 ** parser accepts */
134175 /*********** Begin %parse_accept code *****************************************/
134176 /*********** End %parse_accept code *******************************************/
134177 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134210,32 +134851,12 @@
134210 #ifdef YYERRORSYMBOL
134211 int yyerrorhit = 0; /* True if yymajor has invoked an error */
134212 #endif
134213 yyParser *yypParser; /* The parser */
134214
134215 /* (re)initialize the parser, if necessary */
134216 yypParser = (yyParser*)yyp;
134217 if( yypParser->yyidx<0 ){
134218 #if YYSTACKDEPTH<=0
134219 if( yypParser->yystksz <=0 ){
134220 yyStackOverflow(yypParser);
134221 return;
134222 }
134223 #endif
134224 yypParser->yyidx = 0;
134225 #ifndef YYNOERRORRECOVERY
134226 yypParser->yyerrcnt = -1;
134227 #endif
134228 yypParser->yystack[0].stateno = 0;
134229 yypParser->yystack[0].major = 0;
134230 #ifndef NDEBUG
134231 if( yyTraceFILE ){
134232 fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
134233 yyTracePrompt);
134234 }
134235 #endif
134236 }
134237 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
134238 yyendofinput = (yymajor==0);
134239 #endif
134240 sqlite3ParserARG_STORE;
134241
@@ -134246,11 +134867,10 @@
134246 #endif
134247
134248 do{
134249 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
134250 if( yyact <= YY_MAX_SHIFTREDUCE ){
134251 if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134252 yy_shift(yypParser,yyact,yymajor,yyminor);
134253 #ifndef YYNOERRORRECOVERY
134254 yypParser->yyerrcnt--;
134255 #endif
134256 yymajor = YYNOCODE;
@@ -134288,11 +134908,11 @@
134288 **
134289 */
134290 if( yypParser->yyerrcnt<0 ){
134291 yy_syntax_error(yypParser,yymajor,yyminor);
134292 }
134293 yymx = yypParser->yystack[yypParser->yyidx].major;
134294 if( yymx==YYERRORSYMBOL || yyerrorhit ){
134295 #ifndef NDEBUG
134296 if( yyTraceFILE ){
134297 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
134298 yyTracePrompt,yyTokenName[yymajor]);
@@ -134299,22 +134919,24 @@
134299 }
134300 #endif
134301 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
134302 yymajor = YYNOCODE;
134303 }else{
134304 while(
134305 yypParser->yyidx >= 0 &&
134306 yymx != YYERRORSYMBOL &&
134307 (yyact = yy_find_reduce_action(
134308 yypParser->yystack[yypParser->yyidx].stateno,
134309 YYERRORSYMBOL)) >= YY_MIN_REDUCE
134310 ){
134311 yy_pop_parser_stack(yypParser);
134312 }
134313 if( yypParser->yyidx < 0 || yymajor==0 ){
134314 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134315 yy_parse_failed(yypParser);
 
 
 
134316 yymajor = YYNOCODE;
134317 }else if( yymx!=YYERRORSYMBOL ){
134318 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
134319 }
134320 }
@@ -134347,22 +134969,27 @@
134347 }
134348 yypParser->yyerrcnt = 3;
134349 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134350 if( yyendofinput ){
134351 yy_parse_failed(yypParser);
 
 
 
134352 }
134353 yymajor = YYNOCODE;
134354 #endif
134355 }
134356 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
134357 #ifndef NDEBUG
134358 if( yyTraceFILE ){
134359 int i;
 
134360 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
134361 for(i=1; i<=yypParser->yyidx; i++)
134362 fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
134363 yyTokenName[yypParser->yystack[i].major]);
 
134364 fprintf(yyTraceFILE,"]\n");
134365 }
134366 #endif
134367 return;
134368 }
@@ -136680,10 +137307,13 @@
136680 }
136681 if( !sqlite3SafetyCheckSickOrOk(db) ){
136682 return SQLITE_MISUSE_BKPT;
136683 }
136684 sqlite3_mutex_enter(db->mutex);
 
 
 
136685
136686 /* Force xDisconnect calls on all virtual tables */
136687 disconnectAllVtab(db);
136688
136689 /* If a transaction is open, the disconnectAllVtab() call above
@@ -137448,11 +138078,12 @@
137448 **
137449 ** A NULL trace function means that no tracing is executes. A non-NULL
137450 ** trace is a pointer to a function that is invoked at the start of each
137451 ** SQL statement.
137452 */
137453 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
 
137454 void *pOld;
137455
137456 #ifdef SQLITE_ENABLE_API_ARMOR
137457 if( !sqlite3SafetyCheckOk(db) ){
137458 (void)SQLITE_MISUSE_BKPT;
@@ -137459,15 +138090,39 @@
137459 return 0;
137460 }
137461 #endif
137462 sqlite3_mutex_enter(db->mutex);
137463 pOld = db->pTraceArg;
137464 db->xTrace = xTrace;
 
137465 db->pTraceArg = pArg;
137466 sqlite3_mutex_leave(db->mutex);
137467 return pOld;
137468 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137469 /*
137470 ** Register a profile function. The pArg from the previously registered
137471 ** profile function is returned.
137472 **
137473 ** A NULL profile function means that no profiling is executes. A non-NULL
@@ -161881,10 +162536,57 @@
161881 }
161882 return f;
161883 }
161884 #endif /* !defined(SQLITE_RTREE_INT_ONLY) */
161885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161886
161887 /*
161888 ** The xUpdate method for rtree module virtual tables.
161889 */
161890 static int rtreeUpdate(
@@ -161931,11 +162633,11 @@
161931 if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
161932 for(ii=0; ii<nData-4; ii+=2){
161933 cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
161934 cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
161935 if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
161936 rc = SQLITE_CONSTRAINT;
161937 goto constraint;
161938 }
161939 }
161940 }else
161941 #endif
@@ -161942,11 +162644,11 @@
161942 {
161943 for(ii=0; ii<nData-4; ii+=2){
161944 cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
161945 cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
161946 if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
161947 rc = SQLITE_CONSTRAINT;
161948 goto constraint;
161949 }
161950 }
161951 }
161952
@@ -161963,11 +162665,11 @@
161963 rc = sqlite3_reset(pRtree->pReadRowid);
161964 if( SQLITE_ROW==steprc ){
161965 if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
161966 rc = rtreeDeleteRowid(pRtree, cell.iRowid);
161967 }else{
161968 rc = SQLITE_CONSTRAINT;
161969 goto constraint;
161970 }
161971 }
161972 }
161973 bHaveRowid = 1;
@@ -162046,10 +162748,15 @@
162046 char *zSql;
162047 sqlite3_stmt *p;
162048 int rc;
162049 i64 nRow = 0;
162050
 
 
 
 
 
162051 zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
162052 if( zSql==0 ){
162053 rc = SQLITE_NOMEM;
162054 }else{
162055 rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
@@ -163977,10 +164684,48 @@
163977 ** table exists but is not correctly populated, the value of the *pnOne
163978 ** output variable during stage 1 is undefined.
163979 */
163980 SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
163981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163982 /*
163983 ** Create an RBU VFS named zName that accesses the underlying file-system
163984 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
163985 ** then the new RBU VFS uses the default system VFS to access the file-system.
163986 ** The new object is registered as a non-default VFS with SQLite before
@@ -164872,16 +165617,18 @@
164872 */
164873 static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
164874 int rc;
164875 memset(pIter, 0, sizeof(RbuObjIter));
164876
164877 rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
 
164878 "SELECT rbu_target_name(name, type='view') AS target, name "
164879 "FROM sqlite_master "
164880 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
 
164881 "ORDER BY name"
164882 );
164883
164884 if( rc==SQLITE_OK ){
164885 rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
164886 "SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' "
164887 " FROM main.sqlite_master "
@@ -166456,13 +167203,13 @@
166456 #if SQLITE_ENABLE_8_3_NAMES<2
166457 if( sqlite3_uri_boolean(zBase, "8_3_names", 0) )
166458 #endif
166459 {
166460 int i, sz;
166461 sz = sqlite3Strlen30(z);
166462 for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
166463 if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
166464 }
166465 #endif
166466 }
166467
166468 /*
@@ -167504,34 +168251,11 @@
167504 }
167505
167506 if( p->rc==SQLITE_OK ){
167507 if( p->eStage==RBU_STAGE_OAL ){
167508 sqlite3 *db = p->dbMain;
167509
167510 if( pState->eStage==0 && rbuIsVacuum(p) ){
167511 rbuCopyPragma(p, "page_size");
167512 rbuCopyPragma(p, "auto_vacuum");
167513 }
167514
167515 /* Open transactions both databases. The *-oal file is opened or
167516 ** created at this point. */
167517 if( p->rc==SQLITE_OK ){
167518 p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
167519 }
167520 if( p->rc==SQLITE_OK ){
167521 p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
167522 }
167523
167524 /* Check if the main database is a zipvfs db. If it is, set the upper
167525 ** level pager to use "journal_mode=off". This prevents it from
167526 ** generating a large journal using a temp file. */
167527 if( p->rc==SQLITE_OK ){
167528 int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
167529 if( frc==SQLITE_OK ){
167530 p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
167531 }
167532 }
167533
167534 /* Point the object iterator at the first object */
167535 if( p->rc==SQLITE_OK ){
167536 p->rc = rbuObjIterFirst(p, &p->objiter);
167537 }
@@ -167538,16 +168262,38 @@
167538
167539 /* If the RBU database contains no data_xxx tables, declare the RBU
167540 ** update finished. */
167541 if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
167542 p->rc = SQLITE_DONE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167543 }
167544
167545 if( p->rc==SQLITE_OK ){
167546 rbuSetupOal(p, pState);
167547 }
167548
167549 }else if( p->eStage==RBU_STAGE_MOVE ){
167550 /* no-op */
167551 }else if( p->eStage==RBU_STAGE_CKPT ){
167552 rbuSetupCheckpoint(p, pState);
167553 }else if( p->eStage==RBU_STAGE_DONE ){
@@ -167709,14 +168455,44 @@
167709
167710 default:
167711 assert( 0 );
167712 }
167713 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167714
167715 SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){
167716 int rc = p->rc;
167717
167718 if( rc==SQLITE_DONE ) return SQLITE_OK;
167719
167720 assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
167721 if( p->eStage==RBU_STAGE_OAL ){
167722 assert( rc!=SQLITE_DONE );
@@ -168694,14 +169470,14 @@
168694 **
168695 ** '/1c2/000/' // Left-most child of 451st child of root
168696 */
168697 #define VTAB_SCHEMA \
168698 "CREATE TABLE xx( " \
168699 " name STRING, /* Name of table or index */" \
168700 " path INTEGER, /* Path to page from root */" \
168701 " pageno INTEGER, /* Page number */" \
168702 " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \
168703 " ncell INTEGER, /* Cells on page (0 for overflow) */" \
168704 " payload INTEGER, /* Bytes of payload on this page */" \
168705 " unused INTEGER, /* Bytes of unused space on this page */" \
168706 " mx_payload INTEGER, /* Largest payload size of all cells */" \
168707 " pgoffset INTEGER, /* Offset of page in file */" \
@@ -175195,10 +175971,29 @@
175195 #endif /* SQLITE_DEBUG */
175196
175197 /****************************************************************************
175198 ** Scalar SQL function implementations
175199 ****************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175200
175201 /*
175202 ** Implementation of the json_array(VALUE,...) function. Return a JSON
175203 ** array that contains all values given in arguments. Or if any argument
175204 ** is a BLOB, throw an error.
@@ -176109,10 +176904,11 @@
176109 { "json_array_length", 1, 0, jsonArrayLengthFunc },
176110 { "json_array_length", 2, 0, jsonArrayLengthFunc },
176111 { "json_extract", -1, 0, jsonExtractFunc },
176112 { "json_insert", -1, 0, jsonSetFunc },
176113 { "json_object", -1, 0, jsonObjectFunc },
 
176114 { "json_remove", -1, 0, jsonRemoveFunc },
176115 { "json_replace", -1, 0, jsonReplaceFunc },
176116 { "json_set", -1, 1, jsonSetFunc },
176117 { "json_type", 1, 0, jsonTypeFunc },
176118 { "json_type", 2, 0, jsonTypeFunc },
@@ -177458,11 +178254,10 @@
177458 static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
177459 static int sqlite3Fts5ExprPopulatePoslists(
177460 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
177461 );
177462 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
177463 static void sqlite3Fts5ExprClearEof(Fts5Expr*);
177464
177465 static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
177466
177467 static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
177468
@@ -177874,21 +178669,22 @@
177874 typedef struct fts5yyStackEntry fts5yyStackEntry;
177875
177876 /* The state of the parser is completely contained in an instance of
177877 ** the following structure */
177878 struct fts5yyParser {
177879 int fts5yyidx; /* Index of top element in stack */
177880 #ifdef fts5YYTRACKMAXSTACKDEPTH
177881 int fts5yyidxMax; /* Maximum value of fts5yyidx */
177882 #endif
177883 #ifndef fts5YYNOERRORRECOVERY
177884 int fts5yyerrcnt; /* Shifts left before out of the error */
177885 #endif
177886 sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
177887 #if fts5YYSTACKDEPTH<=0
177888 int fts5yystksz; /* Current side of the stack */
177889 fts5yyStackEntry *fts5yystack; /* The parser's stack */
 
177890 #else
177891 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
177892 #endif
177893 };
177894 typedef struct fts5yyParser fts5yyParser;
@@ -177971,28 +178767,38 @@
177971 #endif /* NDEBUG */
177972
177973
177974 #if fts5YYSTACKDEPTH<=0
177975 /*
177976 ** Try to increase the size of the parser stack.
 
177977 */
177978 static void fts5yyGrowStack(fts5yyParser *p){
177979 int newSize;
 
177980 fts5yyStackEntry *pNew;
177981
177982 newSize = p->fts5yystksz*2 + 100;
177983 pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
 
 
 
 
 
 
177984 if( pNew ){
177985 p->fts5yystack = pNew;
177986 p->fts5yystksz = newSize;
177987 #ifndef NDEBUG
177988 if( fts5yyTraceFILE ){
177989 fprintf(fts5yyTraceFILE,"%sStack grows to %d entries!\n",
177990 fts5yyTracePrompt, p->fts5yystksz);
177991 }
177992 #endif
 
177993 }
 
177994 }
177995 #endif
177996
177997 /* Datatype of the argument to the memory allocated passed as the
177998 ** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by
@@ -178017,19 +178823,28 @@
178017 */
178018 static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
178019 fts5yyParser *pParser;
178020 pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
178021 if( pParser ){
178022 pParser->fts5yyidx = -1;
178023 #ifdef fts5YYTRACKMAXSTACKDEPTH
178024 pParser->fts5yyidxMax = 0;
178025 #endif
178026 #if fts5YYSTACKDEPTH<=0
 
178027 pParser->fts5yystack = NULL;
178028 pParser->fts5yystksz = 0;
178029 fts5yyGrowStack(pParser);
 
 
 
178030 #endif
 
 
 
 
 
 
178031 }
178032 return pParser;
178033 }
178034
178035 /* The following function deletes the "minor type" or semantic value
@@ -178097,12 +178912,13 @@
178097 ** If there is a destructor routine associated with the token which
178098 ** is popped from the stack, then call it.
178099 */
178100 static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
178101 fts5yyStackEntry *fts5yytos;
178102 assert( pParser->fts5yyidx>=0 );
178103 fts5yytos = &pParser->fts5yystack[pParser->fts5yyidx--];
 
178104 #ifndef NDEBUG
178105 if( fts5yyTraceFILE ){
178106 fprintf(fts5yyTraceFILE,"%sPopping %s\n",
178107 fts5yyTracePrompt,
178108 fts5yyTokenName[fts5yytos->major]);
@@ -178125,13 +178941,13 @@
178125 ){
178126 fts5yyParser *pParser = (fts5yyParser*)p;
178127 #ifndef fts5YYPARSEFREENEVERNULL
178128 if( pParser==0 ) return;
178129 #endif
178130 while( pParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(pParser);
178131 #if fts5YYSTACKDEPTH<=0
178132 free(pParser->fts5yystack);
178133 #endif
178134 (*freeProc)((void*)pParser);
178135 }
178136
178137 /*
@@ -178138,11 +178954,11 @@
178138 ** Return the peak depth of the stack for a parser.
178139 */
178140 #ifdef fts5YYTRACKMAXSTACKDEPTH
178141 static int sqlite3Fts5ParserStackPeak(void *p){
178142 fts5yyParser *pParser = (fts5yyParser*)p;
178143 return pParser->fts5yyidxMax;
178144 }
178145 #endif
178146
178147 /*
178148 ** Find the appropriate action for a parser given the terminal
@@ -178151,11 +178967,11 @@
178151 static unsigned int fts5yy_find_shift_action(
178152 fts5yyParser *pParser, /* The parser */
178153 fts5YYCODETYPE iLookAhead /* The look-ahead token */
178154 ){
178155 int i;
178156 int stateno = pParser->fts5yystack[pParser->fts5yyidx].stateno;
178157
178158 if( stateno>=fts5YY_MIN_REDUCE ) return stateno;
178159 assert( stateno <= fts5YY_SHIFT_COUNT );
178160 do{
178161 i = fts5yy_shift_ofst[stateno];
@@ -178244,17 +179060,17 @@
178244 /*
178245 ** The following routine is called if the stack overflows.
178246 */
178247 static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
178248 sqlite3Fts5ParserARG_FETCH;
178249 fts5yypParser->fts5yyidx--;
178250 #ifndef NDEBUG
178251 if( fts5yyTraceFILE ){
178252 fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
178253 }
178254 #endif
178255 while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
178256 /* Here code is inserted which will execute if the parser
178257 ** stack every overflows */
178258 /******** Begin %stack_overflow code ******************************************/
178259
178260 sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
@@ -178268,15 +179084,15 @@
178268 #ifndef NDEBUG
178269 static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){
178270 if( fts5yyTraceFILE ){
178271 if( fts5yyNewState<fts5YYNSTATE ){
178272 fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n",
178273 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major],
178274 fts5yyNewState);
178275 }else{
178276 fprintf(fts5yyTraceFILE,"%sShift '%s'\n",
178277 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major]);
178278 }
178279 }
178280 }
178281 #else
178282 # define fts5yyTraceShift(X,Y)
@@ -178290,31 +179106,34 @@
178290 int fts5yyNewState, /* The new state to shift in */
178291 int fts5yyMajor, /* The major token to shift in */
178292 sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
178293 ){
178294 fts5yyStackEntry *fts5yytos;
178295 fts5yypParser->fts5yyidx++;
178296 #ifdef fts5YYTRACKMAXSTACKDEPTH
178297 if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178298 fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
 
178299 }
178300 #endif
178301 #if fts5YYSTACKDEPTH>0
178302 if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH ){
178303 fts5yyStackOverflow(fts5yypParser);
178304 return;
178305 }
178306 #else
178307 if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
178308 fts5yyGrowStack(fts5yypParser);
178309 if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
178310 fts5yyStackOverflow(fts5yypParser);
178311 return;
178312 }
178313 }
178314 #endif
178315 fts5yytos = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
 
 
 
178316 fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
178317 fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
178318 fts5yytos->minor.fts5yy0 = fts5yyMinor;
178319 fts5yyTraceShift(fts5yypParser, fts5yyNewState);
178320 }
@@ -178365,11 +179184,11 @@
178365 int fts5yygoto; /* The next state */
178366 int fts5yyact; /* The next action */
178367 fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
178368 int fts5yysize; /* Amount to pop the stack */
178369 sqlite3Fts5ParserARG_FETCH;
178370 fts5yymsp = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
178371 #ifndef NDEBUG
178372 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
178373 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178374 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
178375 fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
@@ -178379,26 +179198,27 @@
178379 /* Check that the stack is large enough to grow by a single entry
178380 ** if the RHS of the rule is empty. This ensures that there is room
178381 ** enough on the stack to push the LHS value */
178382 if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
178383 #ifdef fts5YYTRACKMAXSTACKDEPTH
178384 if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178385 fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
 
178386 }
178387 #endif
178388 #if fts5YYSTACKDEPTH>0
178389 if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH-1 ){
178390 fts5yyStackOverflow(fts5yypParser);
178391 return;
178392 }
178393 #else
178394 if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
178395 fts5yyGrowStack(fts5yypParser);
178396 if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
178397 fts5yyStackOverflow(fts5yypParser);
178398 return;
178399 }
 
178400 }
178401 #endif
178402 }
178403
178404 switch( fts5yyruleno ){
@@ -178535,19 +179355,21 @@
178535 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
178536 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
178537 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178538 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
178539 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178540 if( fts5yyact>fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178541 fts5yypParser->fts5yyidx -= fts5yysize - 1;
 
178542 fts5yymsp -= fts5yysize-1;
 
178543 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
178544 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
178545 fts5yyTraceShift(fts5yypParser, fts5yyact);
178546 }else{
178547 assert( fts5yyact == fts5YY_ACCEPT_ACTION );
178548 fts5yypParser->fts5yyidx -= fts5yysize;
178549 fts5yy_accept(fts5yypParser);
178550 }
178551 }
178552
178553 /*
@@ -178561,11 +179383,11 @@
178561 #ifndef NDEBUG
178562 if( fts5yyTraceFILE ){
178563 fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
178564 }
178565 #endif
178566 while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
178567 /* Here code is inserted which will be executed whenever the
178568 ** parser fails */
178569 /************ Begin %parse_failure code ***************************************/
178570 /************ End %parse_failure code *****************************************/
178571 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178602,11 +179424,14 @@
178602 #ifndef NDEBUG
178603 if( fts5yyTraceFILE ){
178604 fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
178605 }
178606 #endif
178607 while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
 
 
 
178608 /* Here code is inserted which will be executed whenever the
178609 ** parser accepts */
178610 /*********** Begin %parse_accept code *****************************************/
178611 /*********** End %parse_accept code *******************************************/
178612 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178645,32 +179470,12 @@
178645 #ifdef fts5YYERRORSYMBOL
178646 int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
178647 #endif
178648 fts5yyParser *fts5yypParser; /* The parser */
178649
178650 /* (re)initialize the parser, if necessary */
178651 fts5yypParser = (fts5yyParser*)fts5yyp;
178652 if( fts5yypParser->fts5yyidx<0 ){
178653 #if fts5YYSTACKDEPTH<=0
178654 if( fts5yypParser->fts5yystksz <=0 ){
178655 fts5yyStackOverflow(fts5yypParser);
178656 return;
178657 }
178658 #endif
178659 fts5yypParser->fts5yyidx = 0;
178660 #ifndef fts5YYNOERRORRECOVERY
178661 fts5yypParser->fts5yyerrcnt = -1;
178662 #endif
178663 fts5yypParser->fts5yystack[0].stateno = 0;
178664 fts5yypParser->fts5yystack[0].major = 0;
178665 #ifndef NDEBUG
178666 if( fts5yyTraceFILE ){
178667 fprintf(fts5yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
178668 fts5yyTracePrompt);
178669 }
178670 #endif
178671 }
178672 #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
178673 fts5yyendofinput = (fts5yymajor==0);
178674 #endif
178675 sqlite3Fts5ParserARG_STORE;
178676
@@ -178681,11 +179486,10 @@
178681 #endif
178682
178683 do{
178684 fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
178685 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178686 if( fts5yyact > fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178687 fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
178688 #ifndef fts5YYNOERRORRECOVERY
178689 fts5yypParser->fts5yyerrcnt--;
178690 #endif
178691 fts5yymajor = fts5YYNOCODE;
@@ -178723,11 +179527,11 @@
178723 **
178724 */
178725 if( fts5yypParser->fts5yyerrcnt<0 ){
178726 fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);
178727 }
178728 fts5yymx = fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major;
178729 if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){
178730 #ifndef NDEBUG
178731 if( fts5yyTraceFILE ){
178732 fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n",
178733 fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);
@@ -178734,22 +179538,24 @@
178734 }
178735 #endif
178736 fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);
178737 fts5yymajor = fts5YYNOCODE;
178738 }else{
178739 while(
178740 fts5yypParser->fts5yyidx >= 0 &&
178741 fts5yymx != fts5YYERRORSYMBOL &&
178742 (fts5yyact = fts5yy_find_reduce_action(
178743 fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].stateno,
178744 fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE
178745 ){
178746 fts5yy_pop_parser_stack(fts5yypParser);
178747 }
178748 if( fts5yypParser->fts5yyidx < 0 || fts5yymajor==0 ){
178749 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178750 fts5yy_parse_failed(fts5yypParser);
 
 
 
178751 fts5yymajor = fts5YYNOCODE;
178752 }else if( fts5yymx!=fts5YYERRORSYMBOL ){
178753 fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
178754 }
178755 }
@@ -178782,22 +179588,27 @@
178782 }
178783 fts5yypParser->fts5yyerrcnt = 3;
178784 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178785 if( fts5yyendofinput ){
178786 fts5yy_parse_failed(fts5yypParser);
 
 
 
178787 }
178788 fts5yymajor = fts5YYNOCODE;
178789 #endif
178790 }
178791 }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yyidx>=0 );
178792 #ifndef NDEBUG
178793 if( fts5yyTraceFILE ){
178794 int i;
 
178795 fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
178796 for(i=1; i<=fts5yypParser->fts5yyidx; i++)
178797 fprintf(fts5yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
178798 fts5yyTokenName[fts5yypParser->fts5yystack[i].major]);
 
178799 fprintf(fts5yyTraceFILE,"]\n");
178800 }
178801 #endif
178802 return;
178803 }
@@ -183337,21 +184148,10 @@
183337
183338 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
183339 fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
183340 }
183341
183342 static void fts5ExprClearEof(Fts5ExprNode *pNode){
183343 int i;
183344 for(i=0; i<pNode->nChild; i++){
183345 fts5ExprClearEof(pNode->apChild[i]);
183346 }
183347 pNode->bEof = 0;
183348 }
183349 static void sqlite3Fts5ExprClearEof(Fts5Expr *pExpr){
183350 fts5ExprClearEof(pExpr->pRoot);
183351 }
183352
183353 /*
183354 ** This function is only called for detail=columns tables.
183355 */
183356 static int sqlite3Fts5ExprPhraseCollist(
183357 Fts5Expr *pExpr,
@@ -191565,11 +192365,10 @@
191565 assert( pCsr->iLastRowid==LARGEST_INT64 );
191566 assert( pCsr->iFirstRowid==SMALLEST_INT64 );
191567 pCsr->ePlan = FTS5_PLAN_SOURCE;
191568 pCsr->pExpr = pTab->pSortCsr->pExpr;
191569 rc = fts5CursorFirst(pTab, pCsr, bDesc);
191570 sqlite3Fts5ExprClearEof(pCsr->pExpr);
191571 }else if( pMatch ){
191572 const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
191573 if( zExpr==0 ) zExpr = "";
191574
191575 rc = fts5CursorParseRank(pConfig, pCsr, pRank);
@@ -192994,11 +193793,11 @@
192994 int nArg, /* Number of args */
192995 sqlite3_value **apUnused /* Function arguments */
192996 ){
192997 assert( nArg==0 );
192998 UNUSED_PARAM2(nArg, apUnused);
192999 sqlite3_result_text(pCtx, "fts5: 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2", -1, SQLITE_TRANSIENT);
193000 }
193001
193002 static int fts5Init(sqlite3 *db){
193003 static const sqlite3_module fts5Mod = {
193004 /* iVersion */ 2,
@@ -193359,11 +194158,15 @@
193359 ){
193360 int rc;
193361 char *zErr = 0;
193362
193363 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
193364 pConfig->zDb, pConfig->zName, zPost, zDefn, bWithout?" WITHOUT ROWID":""
 
 
 
 
193365 );
193366 if( zErr ){
193367 *pzErr = sqlite3_mprintf(
193368 "fts5: error creating shadow table %q_%s: %s",
193369 pConfig->zName, zPost, zErr
193370
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.14.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -35,12 +35,12 @@
35 **
36 *************************************************************************
37 ** Internal interface definitions for SQLite.
38 **
39 */
40 #ifndef SQLITEINT_H
41 #define SQLITEINT_H
42
43 /* Special Comments:
44 **
45 ** Some comments have special meaning to the tools that measure test
46 ** coverage:
@@ -95,12 +95,12 @@
95 **
96 ******************************************************************************
97 **
98 ** This file contains code that is specific to MSVC.
99 */
100 #ifndef SQLITE_MSVC_H
101 #define SQLITE_MSVC_H
102
103 #if defined(_MSC_VER)
104 #pragma warning(disable : 4054)
105 #pragma warning(disable : 4055)
106 #pragma warning(disable : 4100)
@@ -116,11 +116,11 @@
116 #pragma warning(disable : 4306)
117 #pragma warning(disable : 4702)
118 #pragma warning(disable : 4706)
119 #endif /* defined(_MSC_VER) */
120
121 #endif /* SQLITE_MSVC_H */
122
123 /************** End of msvc.h ************************************************/
124 /************** Continuing where we left off in sqliteInt.h ******************/
125
126 /*
@@ -280,12 +280,12 @@
280 ** The name of this file under configuration management is "sqlite.h.in".
281 ** The makefile makes some minor changes to this file (such as inserting
282 ** the version number) and changes its name to "sqlite3.h" as
283 ** part of the build process.
284 */
285 #ifndef SQLITE3_H
286 #define SQLITE3_H
287 #include <stdarg.h> /* Needed for the definition of va_list */
288
289 /*
290 ** Make sure we can call this stuff from C++.
291 */
@@ -361,13 +361,13 @@
361 **
362 ** See also: [sqlite3_libversion()],
363 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
364 ** [sqlite_version()] and [sqlite_source_id()].
365 */
366 #define SQLITE_VERSION "3.14.0"
367 #define SQLITE_VERSION_NUMBER 3014000
368 #define SQLITE_SOURCE_ID "2016-07-23 20:27:41 c8e0539b970585cbb3619461a53abb0c3b308a17"
369
370 /*
371 ** CAPI3REF: Run-Time Library Version Numbers
372 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
373 **
@@ -756,10 +756,11 @@
756 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
757 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
758 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
759 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
760 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
761 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
762
763 /*
764 ** CAPI3REF: Flags For File Open Operations
765 **
766 ** These bit values are intended for use in the
@@ -3003,10 +3004,13 @@
3004 #define SQLITE_RECURSIVE 33 /* NULL NULL */
3005
3006 /*
3007 ** CAPI3REF: Tracing And Profiling Functions
3008 ** METHOD: sqlite3
3009 **
3010 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
3011 ** instead of the routines described here.
3012 **
3013 ** These routines register callback functions that can be used for
3014 ** tracing and profiling the execution of SQL statements.
3015 **
3016 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -3029,13 +3033,104 @@
3033 ** digits in the time are meaningless. Future versions of SQLite
3034 ** might provide greater resolution on the profiler callback. The
3035 ** sqlite3_profile() function is considered experimental and is
3036 ** subject to change in future versions of SQLite.
3037 */
3038 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
3039 void(*xTrace)(void*,const char*), void*);
3040 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
3041 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
3042
3043 /*
3044 ** CAPI3REF: SQL Trace Event Codes
3045 ** KEYWORDS: SQLITE_TRACE
3046 **
3047 ** These constants identify classes of events that can be monitored
3048 ** using the [sqlite3_trace_v2()] tracing logic. The third argument
3049 ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
3050 ** the following constants. ^The first argument to the trace callback
3051 ** is one of the following constants.
3052 **
3053 ** New tracing constants may be added in future releases.
3054 **
3055 ** ^A trace callback has four arguments: xCallback(T,C,P,X).
3056 ** ^The T argument is one of the integer type codes above.
3057 ** ^The C argument is a copy of the context pointer passed in as the
3058 ** fourth argument to [sqlite3_trace_v2()].
3059 ** The P and X arguments are pointers whose meanings depend on T.
3060 **
3061 ** <dl>
3062 ** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
3063 ** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
3064 ** first begins running and possibly at other times during the
3065 ** execution of the prepared statement, such as at the start of each
3066 ** trigger subprogram. ^The P argument is a pointer to the
3067 ** [prepared statement]. ^The X argument is a pointer to a string which
3068 ** is the expanded SQL text of the prepared statement or a comment that
3069 ** indicates the invocation of a trigger.
3070 **
3071 ** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
3072 ** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
3073 ** information as is provided by the [sqlite3_profile()] callback.
3074 ** ^The P argument is a pointer to the [prepared statement] and the
3075 ** X argument points to a 64-bit integer which is the estimated of
3076 ** the number of nanosecond that the prepared statement took to run.
3077 ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
3078 **
3079 ** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
3080 ** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
3081 ** statement generates a single row of result.
3082 ** ^The P argument is a pointer to the [prepared statement] and the
3083 ** X argument is unused.
3084 **
3085 ** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
3086 ** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
3087 ** connection closes.
3088 ** ^The P argument is a pointer to the [database connection] object
3089 ** and the X argument is unused.
3090 ** </dl>
3091 */
3092 #define SQLITE_TRACE_STMT 0x01
3093 #define SQLITE_TRACE_PROFILE 0x02
3094 #define SQLITE_TRACE_ROW 0x04
3095 #define SQLITE_TRACE_CLOSE 0x08
3096
3097 /*
3098 ** CAPI3REF: SQL Trace Hook
3099 ** METHOD: sqlite3
3100 **
3101 ** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
3102 ** function X against [database connection] D, using property mask M
3103 ** and context pointer P. ^If the X callback is
3104 ** NULL or if the M mask is zero, then tracing is disabled. The
3105 ** M argument should be the bitwise OR-ed combination of
3106 ** zero or more [SQLITE_TRACE] constants.
3107 **
3108 ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
3109 ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
3110 **
3111 ** ^The X callback is invoked whenever any of the events identified by
3112 ** mask M occur. ^The integer return value from the callback is currently
3113 ** ignored, though this may change in future releases. Callback
3114 ** implementations should return zero to ensure future compatibility.
3115 **
3116 ** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
3117 ** ^The T argument is one of the [SQLITE_TRACE]
3118 ** constants to indicate why the callback was invoked.
3119 ** ^The C argument is a copy of the context pointer.
3120 ** The P and X arguments are pointers whose meanings depend on T.
3121 **
3122 ** The sqlite3_trace_v2() interface is intended to replace the legacy
3123 ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
3124 ** are deprecated.
3125 */
3126 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
3127 sqlite3*,
3128 unsigned uMask,
3129 int(*xCallback)(unsigned,void*,void*,void*),
3130 void *pCtx
3131 );
3132
3133 /*
3134 ** CAPI3REF: Query Progress Callbacks
3135 ** METHOD: sqlite3
3136 **
@@ -3651,15 +3746,39 @@
3746
3747 /*
3748 ** CAPI3REF: Retrieving Statement SQL
3749 ** METHOD: sqlite3_stmt
3750 **
3751 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3752 ** SQL text used to create [prepared statement] P if P was
3753 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3754 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3755 ** string containing the SQL text of prepared statement P with
3756 ** [bound parameters] expanded.
3757 **
3758 ** ^(For example, if a prepared statement is created using the SQL
3759 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3760 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3761 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3762 ** will return "SELECT 2345,NULL".)^
3763 **
3764 ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3765 ** is available to hold the result, or if the result would exceed the
3766 ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3767 **
3768 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3769 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3770 ** option causes sqlite3_expanded_sql() to always return NULL.
3771 **
3772 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3773 ** automatically freed when the prepared statement is finalized.
3774 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3775 ** is obtained from [sqlite3_malloc()] and must be free by the application
3776 ** by passing it to [sqlite3_free()].
3777 */
3778 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3779 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3780
3781 /*
3782 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3783 ** METHOD: sqlite3_stmt
3784 **
@@ -7014,10 +7133,22 @@
7133 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
7134 ** <dd>This parameter returns the approximate number of bytes of heap
7135 ** memory used by all pager caches associated with the database connection.)^
7136 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
7137 **
7138 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
7139 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
7140 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
7141 ** pager cache is shared between two or more connections the bytes of heap
7142 ** memory used by that pager cache is divided evenly between the attached
7143 ** connections.)^ In other words, if none of the pager caches associated
7144 ** with the database connection are shared, this request returns the same
7145 ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
7146 ** shared, the value returned by this call will be smaller than that returned
7147 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
7148 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
7149 **
7150 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
7151 ** <dd>This parameter returns the approximate number of bytes of heap
7152 ** memory used to store the schema for all databases associated
7153 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
7154 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -7071,11 +7202,12 @@
7202 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
7203 #define SQLITE_DBSTATUS_CACHE_HIT 7
7204 #define SQLITE_DBSTATUS_CACHE_MISS 8
7205 #define SQLITE_DBSTATUS_CACHE_WRITE 9
7206 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
7207 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
7208 #define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
7209
7210
7211 /*
7212 ** CAPI3REF: Prepared Statement Status
7213 ** METHOD: sqlite3_stmt
@@ -8454,11 +8586,11 @@
8586 #endif
8587
8588 #if 0
8589 } /* End of the 'extern "C"' block */
8590 #endif
8591 #endif /* SQLITE3_H */
8592
8593 /******** Begin file sqlite3rtree.h *********/
8594 /*
8595 ** 2010 August 30
8596 **
@@ -11009,12 +11141,12 @@
11141 **
11142 *************************************************************************
11143 ** This is the header file for the generic hash-table implementation
11144 ** used in SQLite.
11145 */
11146 #ifndef SQLITE_HASH_H
11147 #define SQLITE_HASH_H
11148
11149 /* Forward declarations of structures. */
11150 typedef struct Hash Hash;
11151 typedef struct HashElem HashElem;
11152
@@ -11090,11 +11222,11 @@
11222 /*
11223 ** Number of entries in a hash table
11224 */
11225 /* #define sqliteHashCount(H) ((H)->count) // NOT USED */
11226
11227 #endif /* SQLITE_HASH_H */
11228
11229 /************** End of hash.h ************************************************/
11230 /************** Continuing where we left off in sqliteInt.h ******************/
11231 /************** Include parse.h in the middle of sqliteInt.h *****************/
11232 /************** Begin file parse.h *******************************************/
@@ -11838,12 +11970,12 @@
11970 *************************************************************************
11971 ** This header file defines the interface that the sqlite B-Tree file
11972 ** subsystem. See comments in the source code for a detailed description
11973 ** of what each interface routine does.
11974 */
11975 #ifndef SQLITE_BTREE_H
11976 #define SQLITE_BTREE_H
11977
11978 /* TODO: This definition is just included so other modules compile. It
11979 ** needs to be revisited.
11980 */
11981 #define SQLITE_N_BTREE_META 16
@@ -11864,10 +11996,11 @@
11996 ** Forward declarations of structure
11997 */
11998 typedef struct Btree Btree;
11999 typedef struct BtCursor BtCursor;
12000 typedef struct BtShared BtShared;
12001 typedef struct BtreePayload BtreePayload;
12002
12003
12004 SQLITE_PRIVATE int sqlite3BtreeOpen(
12005 sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
12006 const char *zFilename, /* Name of database file to open */
@@ -12075,23 +12208,47 @@
12208
12209 /* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
12210 #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
12211 #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
12212
12213 /* An instance of the BtreePayload object describes the content of a single
12214 ** entry in either an index or table btree.
12215 **
12216 ** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
12217 ** an arbitrary key and no data. These btrees have pKey,nKey set to their
12218 ** key and pData,nData,nZero set to zero.
12219 **
12220 ** Table btrees (used for rowid tables) contain an integer rowid used as
12221 ** the key and passed in the nKey field. The pKey field is zero.
12222 ** pData,nData hold the content of the new entry. nZero extra zero bytes
12223 ** are appended to the end of the content when constructing the entry.
12224 **
12225 ** This object is used to pass information into sqlite3BtreeInsert(). The
12226 ** same information used to be passed as five separate parameters. But placing
12227 ** the information into this object helps to keep the interface more
12228 ** organized and understandable, and it also helps the resulting code to
12229 ** run a little faster by using fewer registers for parameter passing.
12230 */
12231 struct BtreePayload {
12232 const void *pKey; /* Key content for indexes. NULL for tables */
12233 sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
12234 const void *pData; /* Data for tables. NULL for indexes */
12235 int nData; /* Size of pData. 0 if none. */
12236 int nZero; /* Extra zero data appended after pData,nData */
12237 };
12238
12239 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
12240 int bias, int seekResult);
12241 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
12242 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
12243 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
12244 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
12245 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12246 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
12247 SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
12248 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12249 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
 
12250 SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
12251
12252 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
12253 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
12254
@@ -12128,15 +12285,17 @@
12285 #ifndef SQLITE_OMIT_SHARED_CACHE
12286 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
12287 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
12288 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
12289 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
12290 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*);
12291 #else
12292 # define sqlite3BtreeEnter(X)
12293 # define sqlite3BtreeEnterAll(X)
12294 # define sqlite3BtreeSharable(X) 0
12295 # define sqlite3BtreeEnterCursor(X)
12296 # define sqlite3BtreeConnectionCount(X) 1
12297 #endif
12298
12299 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
12300 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
12301 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
@@ -12157,11 +12316,11 @@
12316 # define sqlite3BtreeHoldsAllMutexes(X) 1
12317 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
12318 #endif
12319
12320
12321 #endif /* SQLITE_BTREE_H */
12322
12323 /************** End of btree.h ***********************************************/
12324 /************** Continuing where we left off in sqliteInt.h ******************/
12325 /************** Include vdbe.h in the middle of sqliteInt.h ******************/
12326 /************** Begin file vdbe.h ********************************************/
@@ -12180,12 +12339,12 @@
12339 **
12340 ** This header defines the interface to the virtual database engine
12341 ** or VDBE. The VDBE implements an abstract machine that runs a
12342 ** simple program to access and modify the underlying database.
12343 */
12344 #ifndef SQLITE_VDBE_H
12345 #define SQLITE_VDBE_H
12346 /* #include <stdio.h> */
12347
12348 /*
12349 ** A single VDBE is an opaque structure named "Vdbe". Only routines
12350 ** in the source file sqliteVdbe.c are allowed to see the insides
@@ -12366,21 +12525,21 @@
12525 #define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
12526 #define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
12527 #define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */
12528 #define OP_NotFound 30 /* synopsis: key=r[P3@P4] */
12529 #define OP_Found 31 /* synopsis: key=r[P3@P4] */
12530 #define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12531 #define OP_NotExists 33 /* synopsis: intkey=r[P3] */
12532 #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
12533 #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12534 #define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
12535 #define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
12536 #define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
12537 #define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
12538 #define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
12539 #define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12540 #define OP_Last 42
12541 #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
12542 #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
12543 #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
12544 #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
12545 #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12387,118 +12546,119 @@
12546 #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
12547 #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
12548 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12549 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12550 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12551 #define OP_SorterSort 53
12552 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12553 #define OP_Sort 55
12554 #define OP_Rewind 56
12555 #define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12556 #define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12557 #define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12558 #define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12559 #define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12560 #define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12561 #define OP_Program 63
12562 #define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12563 #define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12564 #define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12565 #define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12566 #define OP_IncrVacuum 68
12567 #define OP_VNext 69
12568 #define OP_Init 70 /* synopsis: Start at P2 */
12569 #define OP_Return 71
12570 #define OP_EndCoroutine 72
12571 #define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12572 #define OP_Halt 74
12573 #define OP_Integer 75 /* synopsis: r[P2]=P1 */
12574 #define OP_Int64 76 /* synopsis: r[P2]=P4 */
12575 #define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12576 #define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12577 #define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12578 #define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12579 #define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12580 #define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12581 #define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12582 #define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12583 #define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12584 #define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12585 #define OP_CollSeq 87
12586 #define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12587 #define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12588 #define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12589 #define OP_RealAffinity 91
12590 #define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12591 #define OP_Permutation 93
12592 #define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12593 #define OP_Column 95 /* synopsis: r[P3]=PX */
12594 #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
12595 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12596 #define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12597 #define OP_Count 99 /* synopsis: r[P2]=count() */
12598 #define OP_ReadCookie 100
12599 #define OP_SetCookie 101
12600 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12601 #define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12602 #define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12603 #define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12604 #define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12605 #define OP_SorterOpen 107
12606 #define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12607 #define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12608 #define OP_Close 110
12609 #define OP_ColumnsUsed 111
12610 #define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12611 #define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12612 #define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12613 #define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12614 #define OP_Delete 116
12615 #define OP_ResetCount 117
12616 #define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12617 #define OP_SorterData 119 /* synopsis: r[P2]=data */
12618 #define OP_RowKey 120 /* synopsis: r[P2]=key */
12619 #define OP_RowData 121 /* synopsis: r[P2]=data */
12620 #define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12621 #define OP_NullRow 123
12622 #define OP_SorterInsert 124
12623 #define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12624 #define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12625 #define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12626 #define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12627 #define OP_Destroy 129
12628 #define OP_Clear 130
12629 #define OP_ResetSorter 131
12630 #define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
12631 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12632 #define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12633 #define OP_ParseSchema 135
12634 #define OP_LoadAnalysis 136
12635 #define OP_DropTable 137
12636 #define OP_DropIndex 138
12637 #define OP_DropTrigger 139
12638 #define OP_IntegrityCk 140
12639 #define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12640 #define OP_Param 142
12641 #define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12642 #define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12643 #define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12644 #define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12645 #define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12646 #define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12647 #define OP_Expire 149
12648 #define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12649 #define OP_VBegin 151
12650 #define OP_VCreate 152
12651 #define OP_VDestroy 153
12652 #define OP_VOpen 154
12653 #define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12654 #define OP_VRename 156
12655 #define OP_Pagecount 157
12656 #define OP_MaxPgcnt 158
12657 #define OP_CursorHint 159
12658 #define OP_Noop 160
12659 #define OP_Explain 161
12660
12661 /* Properties such as "out2" or "jump" that are specified in
12662 ** comments following the "case" for each opcode in the vdbe.c
12663 ** are encoded into bitvectors as follows:
12664 */
@@ -12511,35 +12671,35 @@
12671 #define OPFLG_INITIALIZER {\
12672 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
12673 /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
12674 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12675 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12676 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12677 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12678 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12679 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12680 /* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12681 /* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12682 /* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12683 /* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12684 /* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12685 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12686 /* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12687 /* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12688 /* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12689 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12690 /* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12691 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12692 /* 160 */ 0x00, 0x00,}
12693
12694 /* The sqlite3P2Values() routine is able to run faster if it knows
12695 ** the value of the largest JUMP opcode. The smaller the maximum
12696 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12697 ** generated this include file strives to group all JUMP opcodes
12698 ** together near the beginning of the list.
12699 */
12700 #define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
12701
12702 /************** End of opcodes.h *********************************************/
12703 /************** Continuing where we left off in vdbe.h ***********************/
12704
12705 /*
@@ -12682,11 +12842,11 @@
12842 SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
12843 #else
12844 # define sqlite3VdbeScanStatus(a,b,c,d,e)
12845 #endif
12846
12847 #endif /* SQLITE_VDBE_H */
12848
12849 /************** End of vdbe.h ************************************************/
12850 /************** Continuing where we left off in sqliteInt.h ******************/
12851 /************** Include pager.h in the middle of sqliteInt.h *****************/
12852 /************** Begin file pager.h *******************************************/
@@ -12704,12 +12864,12 @@
12864 ** This header file defines the interface that the sqlite page cache
12865 ** subsystem. The page cache subsystem reads and writes a file a page
12866 ** at a time and provides a journal for rollback.
12867 */
12868
12869 #ifndef SQLITE_PAGER_H
12870 #define SQLITE_PAGER_H
12871
12872 /*
12873 ** Default maximum size for persistent journal files. A negative
12874 ** value means no limit. This value may be overridden using the
12875 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
@@ -12893,11 +13053,10 @@
13053 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
13054 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
13055 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
13056 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
13057 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
 
13058 SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
13059
13060 /* Functions used to truncate the database file. */
13061 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
13062
@@ -12920,11 +13079,11 @@
13079 #else
13080 # define disable_simulated_io_errors()
13081 # define enable_simulated_io_errors()
13082 #endif
13083
13084 #endif /* SQLITE_PAGER_H */
13085
13086 /************** End of pager.h ***********************************************/
13087 /************** Continuing where we left off in sqliteInt.h ******************/
13088 /************** Include pcache.h in the middle of sqliteInt.h ****************/
13089 /************** Begin file pcache.h ******************************************/
@@ -13158,12 +13317,12 @@
13317 ******************************************************************************
13318 **
13319 ** This file contains pre-processor directives related to operating system
13320 ** detection and/or setup.
13321 */
13322 #ifndef SQLITE_OS_SETUP_H
13323 #define SQLITE_OS_SETUP_H
13324
13325 /*
13326 ** Figure out if we are dealing with Unix, Windows, or some other operating
13327 ** system.
13328 **
@@ -13199,11 +13358,11 @@
13358 # ifndef SQLITE_OS_WIN
13359 # define SQLITE_OS_WIN 0
13360 # endif
13361 #endif
13362
13363 #endif /* SQLITE_OS_SETUP_H */
13364
13365 /************** End of os_setup.h ********************************************/
13366 /************** Continuing where we left off in os.h *************************/
13367
13368 /* If the SET_FULLSYNC macro is not defined above, then make it
@@ -13656,10 +13815,19 @@
13815 #else
13816 typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
13817 const char*);
13818 #endif
13819
13820 #ifndef SQLITE_OMIT_DEPRECATED
13821 /* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
13822 ** in the style of sqlite3_trace()
13823 */
13824 #define SQLITE_TRACE_LEGACY 0x80
13825 #else
13826 #define SQLITE_TRACE_LEGACY 0
13827 #endif /* SQLITE_OMIT_DEPRECATED */
13828
13829
13830 /*
13831 ** Each database connection is an instance of the following structure.
13832 */
13833 struct sqlite3 {
@@ -13685,10 +13853,11 @@
13853 u8 dfltLockMode; /* Default locking-mode for attached dbs */
13854 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
13855 u8 suppressErr; /* Do not issue error messages if true */
13856 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
13857 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
13858 u8 mTrace; /* zero or more SQLITE_TRACE flags */
13859 int nextPagesize; /* Pagesize after VACUUM if >0 */
13860 u32 magic; /* Magic number for detect library misuse */
13861 int nChange; /* Value returned by sqlite3_changes() */
13862 int nTotalChange; /* Value returned by sqlite3_total_changes() */
13863 int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -13705,11 +13874,11 @@
13874 int nVdbeWrite; /* Number of active VDBEs that read and write */
13875 int nVdbeExec; /* Number of nested calls to VdbeExec() */
13876 int nVDestroy; /* Number of active OP_VDestroy operations */
13877 int nExtension; /* Number of loaded extensions */
13878 void **aExtension; /* Array of shared library handles */
13879 int (*xTrace)(u32,void*,void*,void*); /* Trace function */
13880 void *pTraceArg; /* Argument to the trace function */
13881 void (*xProfile)(void*,const char*,u64); /* Profiling function */
13882 void *pProfileArg; /* Argument to profile function */
13883 void *pCommitArg; /* Argument to xCommitCallback() */
13884 int (*xCommitCallback)(void*); /* Invoked at every commit. */
@@ -14900,11 +15069,11 @@
15069 Select *pSelect; /* A SELECT statement used in place of a table name */
15070 int addrFillSub; /* Address of subroutine to manifest a subquery */
15071 int regReturn; /* Register holding return address of addrFillSub */
15072 int regResult; /* Registers holding results of a co-routine */
15073 struct {
15074 u8 jointype; /* Type of join between this table and the previous */
15075 unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
15076 unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
15077 unsigned isTabFunc :1; /* True if table-valued-function syntax */
15078 unsigned isCorrelated :1; /* True if sub-query is correlated */
15079 unsigned viaCoroutine :1; /* Implemented as a co-routine */
@@ -14946,23 +15115,24 @@
15115 */
15116 #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
15117 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
15118 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
15119 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
15120 #define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */
15121 #define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */
15122 #define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of
15123 ** the OR optimization */
15124 #define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */
15125 #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */
15126 #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */
15127 #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */
15128 #define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
15129 #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
15130 /* 0x1000 not currently used */
15131 /* 0x2000 not currently used */
15132 #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
15133 /* 0x8000 not currently used */
15134
15135 /* Allowed return values from sqlite3WhereIsDistinct()
15136 */
15137 #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
15138 #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
@@ -16031,12 +16201,12 @@
16201 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
16202 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
16203 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
16204 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
16205 SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
16206 SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16207 Expr*, int, int, u8);
16208 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
16209 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
16210 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
16211 Expr*,ExprList*,u32,Expr*,Expr*);
16212 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -16051,10 +16221,11 @@
16221 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
16222 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
16223 SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
16224 SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
16225 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
16226 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
16227 SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
16228 SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
16229 SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
16230 SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
16231 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -16084,12 +16255,14 @@
16255 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
16256 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
16257 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
16258 SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
16259 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
16260 #define LOCATE_VIEW 0x01
16261 #define LOCATE_NOERR 0x02
16262 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
16263 SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
16264 SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
16265 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
16266 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16267 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
16268 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
@@ -16648,11 +16821,11 @@
16821
16822 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
16823 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
16824 #endif
16825
16826 #endif /* SQLITEINT_H */
16827
16828 /************** End of sqliteInt.h *******************************************/
16829 /************** Begin file global.c ******************************************/
16830 /*
16831 ** 2008 June 13
@@ -16983,10 +17156,17 @@
17156 "CASE_SENSITIVE_LIKE",
17157 #endif
17158 #if SQLITE_CHECK_PAGES
17159 "CHECK_PAGES",
17160 #endif
17161 #if defined(__clang__) && defined(__clang_version__)
17162 "COMPILER=clang-" __clang_version__,
17163 #elif defined(_MSC_VER)
17164 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17165 #elif defined(__GNUC__) && defined(__VERSION__)
17166 "COMPILER=gcc-" __VERSION__,
17167 #endif
17168 #if SQLITE_COVERAGE_TEST
17169 "COVERAGE_TEST",
17170 #endif
17171 #if SQLITE_DEBUG
17172 "DEBUG",
@@ -17002,11 +17182,11 @@
17182 #endif
17183 #if SQLITE_DISABLE_LFS
17184 "DISABLE_LFS",
17185 #endif
17186 #if SQLITE_ENABLE_8_3_NAMES
17187 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
17188 #endif
17189 #if SQLITE_ENABLE_API_ARMOR
17190 "ENABLE_API_ARMOR",
17191 #endif
17192 #if SQLITE_ENABLE_ATOMIC_WRITE
@@ -17416,12 +17596,12 @@
17596 ** VDBE. This information used to all be at the top of the single
17597 ** source code file "vdbe.c". When that file became too big (over
17598 ** 6000 lines long) it was split up into several smaller files and
17599 ** this header information was factored out.
17600 */
17601 #ifndef SQLITE_VDBEINT_H
17602 #define SQLITE_VDBEINT_H
17603
17604 /*
17605 ** The maximum number of times that a statement will try to reparse
17606 ** itself before giving up and returning SQLITE_SCHEMA.
17607 */
@@ -17959,11 +18139,11 @@
18139 #else
18140 #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
18141 #define ExpandBlob(P) SQLITE_OK
18142 #endif
18143
18144 #endif /* !defined(SQLITE_VDBEINT_H) */
18145
18146 /************** End of vdbeInt.h *********************************************/
18147 /************** Continuing where we left off in status.c *********************/
18148
18149 /*
@@ -18167,19 +18347,24 @@
18347 /*
18348 ** Return an approximation for the amount of memory currently used
18349 ** by all pagers associated with the given database connection. The
18350 ** highwater mark is meaningless and is returned as zero.
18351 */
18352 case SQLITE_DBSTATUS_CACHE_USED_SHARED:
18353 case SQLITE_DBSTATUS_CACHE_USED: {
18354 int totalUsed = 0;
18355 int i;
18356 sqlite3BtreeEnterAll(db);
18357 for(i=0; i<db->nDb; i++){
18358 Btree *pBt = db->aDb[i].pBt;
18359 if( pBt ){
18360 Pager *pPager = sqlite3BtreePager(pBt);
18361 int nByte = sqlite3PagerMemUsed(pPager);
18362 if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){
18363 nByte = nByte / sqlite3BtreeConnectionCount(pBt);
18364 }
18365 totalUsed += nByte;
18366 }
18367 }
18368 sqlite3BtreeLeaveAll(db);
18369 *pCurrent = totalUsed;
18370 *pHighwater = 0;
@@ -19478,13 +19663,11 @@
19663 ******************************************************************************
19664 **
19665 ** This file contains OS interface code that is common to all
19666 ** architectures.
19667 */
 
19668 /* #include "sqliteInt.h" */
 
19669
19670 /*
19671 ** If we compile with the SQLITE_TEST macro set, then the following block
19672 ** of code will give us the ability to simulate a disk I/O error. This
19673 ** is used for testing the I/O recovery logic.
@@ -22993,12 +23176,12 @@
23176 ******************************************************************************
23177 **
23178 ** This file contains inline asm code for retrieving "high-performance"
23179 ** counters for x86 class CPUs.
23180 */
23181 #ifndef SQLITE_HWTIME_H
23182 #define SQLITE_HWTIME_H
23183
23184 /*
23185 ** The following routine only works on pentium-class (or newer) processors.
23186 ** It uses the RDTSC opcode to read the cycle count value out of the
23187 ** processor and returns that value. This can be used for high-res
@@ -23062,11 +23245,11 @@
23245 */
23246 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
23247
23248 #endif
23249
23250 #endif /* !defined(SQLITE_HWTIME_H) */
23251
23252 /************** End of hwtime.h **********************************************/
23253 /************** Continuing where we left off in os_common.h ******************/
23254
23255 static sqlite_uint64 g_start;
@@ -23152,12 +23335,12 @@
23335 **
23336 ******************************************************************************
23337 **
23338 ** This file contains code that is specific to Windows.
23339 */
23340 #ifndef SQLITE_OS_WIN_H
23341 #define SQLITE_OS_WIN_H
23342
23343 /*
23344 ** Include the primary Windows SDK header file.
23345 */
23346 #include "windows.h"
@@ -23225,11 +23408,11 @@
23408 # define SQLITE_OS_WIN_THREADS 1
23409 #else
23410 # define SQLITE_OS_WIN_THREADS 0
23411 #endif
23412
23413 #endif /* SQLITE_OS_WIN_H */
23414
23415 /************** End of os_win.h **********************************************/
23416 /************** Continuing where we left off in mutex_w32.c ******************/
23417 #endif
23418
@@ -25976,10 +26159,16 @@
26159 }
26160 sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
26161 break;
26162 }
26163 #endif
26164 case TK_MATCH: {
26165 sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26166 pExpr->iTable, pExpr->iColumn, zFlgs);
26167 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26168 break;
26169 }
26170 default: {
26171 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
26172 break;
26173 }
26174 }
@@ -28759,21 +28948,21 @@
28948 /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
28949 /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
28950 /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
28951 /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
28952 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
28953 /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
28954 /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
28955 /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
28956 /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
28957 /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
28958 /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
28959 /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
28960 /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
28961 /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
28962 /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
28963 /* 42 */ "Last" OpHelp(""),
28964 /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
28965 /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
28966 /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
28967 /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
28968 /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -28780,118 +28969,119 @@
28969 /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
28970 /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
28971 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
28972 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
28973 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
28974 /* 53 */ "SorterSort" OpHelp(""),
28975 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
28976 /* 55 */ "Sort" OpHelp(""),
28977 /* 56 */ "Rewind" OpHelp(""),
28978 /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
28979 /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
28980 /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
28981 /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
28982 /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
28983 /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
28984 /* 63 */ "Program" OpHelp(""),
28985 /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
28986 /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
28987 /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
28988 /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
28989 /* 68 */ "IncrVacuum" OpHelp(""),
28990 /* 69 */ "VNext" OpHelp(""),
28991 /* 70 */ "Init" OpHelp("Start at P2"),
28992 /* 71 */ "Return" OpHelp(""),
28993 /* 72 */ "EndCoroutine" OpHelp(""),
28994 /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
28995 /* 74 */ "Halt" OpHelp(""),
28996 /* 75 */ "Integer" OpHelp("r[P2]=P1"),
28997 /* 76 */ "Int64" OpHelp("r[P2]=P4"),
28998 /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
28999 /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29000 /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29001 /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29002 /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29003 /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29004 /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29005 /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29006 /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29007 /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29008 /* 87 */ "CollSeq" OpHelp(""),
29009 /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29010 /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29011 /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29012 /* 91 */ "RealAffinity" OpHelp(""),
29013 /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29014 /* 93 */ "Permutation" OpHelp(""),
29015 /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29016 /* 95 */ "Column" OpHelp("r[P3]=PX"),
29017 /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29018 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29019 /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29020 /* 99 */ "Count" OpHelp("r[P2]=count()"),
29021 /* 100 */ "ReadCookie" OpHelp(""),
29022 /* 101 */ "SetCookie" OpHelp(""),
29023 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29024 /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29025 /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29026 /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29027 /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29028 /* 107 */ "SorterOpen" OpHelp(""),
29029 /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29030 /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29031 /* 110 */ "Close" OpHelp(""),
29032 /* 111 */ "ColumnsUsed" OpHelp(""),
29033 /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29034 /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29035 /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29036 /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29037 /* 116 */ "Delete" OpHelp(""),
29038 /* 117 */ "ResetCount" OpHelp(""),
29039 /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29040 /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29041 /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29042 /* 121 */ "RowData" OpHelp("r[P2]=data"),
29043 /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29044 /* 123 */ "NullRow" OpHelp(""),
29045 /* 124 */ "SorterInsert" OpHelp(""),
29046 /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29047 /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29048 /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29049 /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29050 /* 129 */ "Destroy" OpHelp(""),
29051 /* 130 */ "Clear" OpHelp(""),
29052 /* 131 */ "ResetSorter" OpHelp(""),
29053 /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29054 /* 133 */ "Real" OpHelp("r[P2]=P4"),
29055 /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29056 /* 135 */ "ParseSchema" OpHelp(""),
29057 /* 136 */ "LoadAnalysis" OpHelp(""),
29058 /* 137 */ "DropTable" OpHelp(""),
29059 /* 138 */ "DropIndex" OpHelp(""),
29060 /* 139 */ "DropTrigger" OpHelp(""),
29061 /* 140 */ "IntegrityCk" OpHelp(""),
29062 /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29063 /* 142 */ "Param" OpHelp(""),
29064 /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29065 /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29066 /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29067 /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29068 /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29069 /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29070 /* 149 */ "Expire" OpHelp(""),
29071 /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29072 /* 151 */ "VBegin" OpHelp(""),
29073 /* 152 */ "VCreate" OpHelp(""),
29074 /* 153 */ "VDestroy" OpHelp(""),
29075 /* 154 */ "VOpen" OpHelp(""),
29076 /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29077 /* 156 */ "VRename" OpHelp(""),
29078 /* 157 */ "Pagecount" OpHelp(""),
29079 /* 158 */ "MaxPgcnt" OpHelp(""),
29080 /* 159 */ "CursorHint" OpHelp(""),
29081 /* 160 */ "Noop" OpHelp(""),
29082 /* 161 */ "Explain" OpHelp(""),
29083 };
29084 return azName[i];
29085 }
29086 #endif
29087
@@ -29237,12 +29427,12 @@
29427 ******************************************************************************
29428 **
29429 ** This file contains inline asm code for retrieving "high-performance"
29430 ** counters for x86 class CPUs.
29431 */
29432 #ifndef SQLITE_HWTIME_H
29433 #define SQLITE_HWTIME_H
29434
29435 /*
29436 ** The following routine only works on pentium-class (or newer) processors.
29437 ** It uses the RDTSC opcode to read the cycle count value out of the
29438 ** processor and returns that value. This can be used for high-res
@@ -29306,11 +29496,11 @@
29496 */
29497 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
29498
29499 #endif
29500
29501 #endif /* !defined(SQLITE_HWTIME_H) */
29502
29503 /************** End of hwtime.h **********************************************/
29504 /************** Continuing where we left off in os_common.h ******************/
29505
29506 static sqlite_uint64 g_start;
@@ -36766,12 +36956,12 @@
36956 ******************************************************************************
36957 **
36958 ** This file contains inline asm code for retrieving "high-performance"
36959 ** counters for x86 class CPUs.
36960 */
36961 #ifndef SQLITE_HWTIME_H
36962 #define SQLITE_HWTIME_H
36963
36964 /*
36965 ** The following routine only works on pentium-class (or newer) processors.
36966 ** It uses the RDTSC opcode to read the cycle count value out of the
36967 ** processor and returns that value. This can be used for high-res
@@ -36835,11 +37025,11 @@
37025 */
37026 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
37027
37028 #endif
37029
37030 #endif /* !defined(SQLITE_HWTIME_H) */
37031
37032 /************** End of hwtime.h **********************************************/
37033 /************** Continuing where we left off in os_common.h ******************/
37034
37035 static sqlite_uint64 g_start;
@@ -37175,10 +37365,21 @@
37365 sqlite3_int64 mmapSize; /* Usable size of mapped region */
37366 sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */
37367 sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */
37368 #endif
37369 };
37370
37371 /*
37372 ** The winVfsAppData structure is used for the pAppData member for all of the
37373 ** Win32 VFS variants.
37374 */
37375 typedef struct winVfsAppData winVfsAppData;
37376 struct winVfsAppData {
37377 const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */
37378 void *pAppData; /* The extra pAppData, if any. */
37379 BOOL bNoLock; /* Non-zero if locking is disabled. */
37380 };
37381
37382 /*
37383 ** Allowed values for winFile.ctrlFlags
37384 */
37385 #define WINFILE_RDONLY 0x02 /* Connection is read only */
@@ -39497,11 +39698,16 @@
39698 rc = osCloseHandle(pFile->h);
39699 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
39700 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
39701 #if SQLITE_OS_WINCE
39702 #define WINCE_DELETION_ATTEMPTS 3
39703 {
39704 winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;
39705 if( pAppData==NULL || !pAppData->bNoLock ){
39706 winceDestroyLock(pFile);
39707 }
39708 }
39709 if( pFile->zDeleteOnClose ){
39710 int cnt = 0;
39711 while(
39712 osDeleteFileW(pFile->zDeleteOnClose)==0
39713 && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
@@ -40229,10 +40435,48 @@
40435 OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
40436 pFile->h, pFile->locktype, sqlite3ErrName(rc)));
40437 return rc;
40438 }
40439
40440 /******************************************************************************
40441 ****************************** No-op Locking **********************************
40442 **
40443 ** Of the various locking implementations available, this is by far the
40444 ** simplest: locking is ignored. No attempt is made to lock the database
40445 ** file for reading or writing.
40446 **
40447 ** This locking mode is appropriate for use on read-only databases
40448 ** (ex: databases that are burned into CD-ROM, for example.) It can
40449 ** also be used if the application employs some external mechanism to
40450 ** prevent simultaneous access of the same database by two or more
40451 ** database connections. But there is a serious risk of database
40452 ** corruption if this locking mode is used in situations where multiple
40453 ** database connections are accessing the same database file at the same
40454 ** time and one or more of those connections are writing.
40455 */
40456
40457 static int winNolockLock(sqlite3_file *id, int locktype){
40458 UNUSED_PARAMETER(id);
40459 UNUSED_PARAMETER(locktype);
40460 return SQLITE_OK;
40461 }
40462
40463 static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){
40464 UNUSED_PARAMETER(id);
40465 UNUSED_PARAMETER(pResOut);
40466 return SQLITE_OK;
40467 }
40468
40469 static int winNolockUnlock(sqlite3_file *id, int locktype){
40470 UNUSED_PARAMETER(id);
40471 UNUSED_PARAMETER(locktype);
40472 return SQLITE_OK;
40473 }
40474
40475 /******************* End of the no-op lock implementation *********************
40476 ******************************************************************************/
40477
40478 /*
40479 ** If *pArg is initially negative then this is a query. Set *pArg to
40480 ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
40481 **
40482 ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
@@ -40507,16 +40751,16 @@
40751 #define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
40752
40753 /*
40754 ** Apply advisory locks for all n bytes beginning at ofst.
40755 */
40756 #define WINSHM_UNLCK 1
40757 #define WINSHM_RDLCK 2
40758 #define WINSHM_WRLCK 3
40759 static int winShmSystemLock(
40760 winShmNode *pFile, /* Apply locks to this open shared-memory segment */
40761 int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */
40762 int ofst, /* Offset to first byte to be locked/unlocked */
40763 int nByte /* Number of bytes to lock or unlock */
40764 ){
40765 int rc = 0; /* Result code form Lock/UnlockFileEx() */
40766
@@ -40525,16 +40769,16 @@
40769
40770 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
40771 pFile->hFile.h, lockType, ofst, nByte));
40772
40773 /* Release/Acquire the system-level lock */
40774 if( lockType==WINSHM_UNLCK ){
40775 rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
40776 }else{
40777 /* Initialize the locking parameters */
40778 DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
40779 if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
40780 rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
40781 }
40782
40783 if( rc!= 0 ){
40784 rc = SQLITE_OK;
@@ -40542,11 +40786,11 @@
40786 pFile->lastErrno = osGetLastError();
40787 rc = SQLITE_BUSY;
40788 }
40789
40790 OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
40791 pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" :
40792 "winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
40793
40794 return rc;
40795 }
40796
@@ -40670,20 +40914,20 @@
40914 }
40915
40916 /* Check to see if another process is holding the dead-man switch.
40917 ** If not, truncate the file to zero length.
40918 */
40919 if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
40920 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
40921 if( rc!=SQLITE_OK ){
40922 rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
40923 "winOpenShm", pDbFd->zPath);
40924 }
40925 }
40926 if( rc==SQLITE_OK ){
40927 winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40928 rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);
40929 }
40930 if( rc ) goto shm_open_err;
40931 }
40932
40933 /* Make the new connection a child of the winShmNode */
@@ -40708,11 +40952,11 @@
40952 sqlite3_mutex_leave(pShmNode->mutex);
40953 return SQLITE_OK;
40954
40955 /* Jump here on any error */
40956 shm_open_err:
40957 winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40958 winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
40959 sqlite3_free(p);
40960 sqlite3_free(pNew);
40961 winShmLeaveMutex();
40962 return rc;
@@ -40797,11 +41041,11 @@
41041 allMask |= pX->sharedMask;
41042 }
41043
41044 /* Unlock the system-level locks */
41045 if( (mask & allMask)==0 ){
41046 rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);
41047 }else{
41048 rc = SQLITE_OK;
41049 }
41050
41051 /* Undo the local locks */
@@ -40825,11 +41069,11 @@
41069 }
41070
41071 /* Get shared locks at the system level, if necessary */
41072 if( rc==SQLITE_OK ){
41073 if( (allShared & mask)==0 ){
41074 rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);
41075 }else{
41076 rc = SQLITE_OK;
41077 }
41078 }
41079
@@ -40850,11 +41094,11 @@
41094
41095 /* Get the exclusive locks at the system level. Then if successful
41096 ** also mark the local connection as being locked.
41097 */
41098 if( rc==SQLITE_OK ){
41099 rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);
41100 if( rc==SQLITE_OK ){
41101 assert( (p->sharedMask & mask)==0 );
41102 p->exclMask |= mask;
41103 }
41104 }
@@ -41292,10 +41536,48 @@
41536 winShmBarrier, /* xShmBarrier */
41537 winShmUnmap, /* xShmUnmap */
41538 winFetch, /* xFetch */
41539 winUnfetch /* xUnfetch */
41540 };
41541
41542 /*
41543 ** This vector defines all the methods that can operate on an
41544 ** sqlite3_file for win32 without performing any locking.
41545 */
41546 static const sqlite3_io_methods winIoNolockMethod = {
41547 3, /* iVersion */
41548 winClose, /* xClose */
41549 winRead, /* xRead */
41550 winWrite, /* xWrite */
41551 winTruncate, /* xTruncate */
41552 winSync, /* xSync */
41553 winFileSize, /* xFileSize */
41554 winNolockLock, /* xLock */
41555 winNolockUnlock, /* xUnlock */
41556 winNolockCheckReservedLock, /* xCheckReservedLock */
41557 winFileControl, /* xFileControl */
41558 winSectorSize, /* xSectorSize */
41559 winDeviceCharacteristics, /* xDeviceCharacteristics */
41560 winShmMap, /* xShmMap */
41561 winShmLock, /* xShmLock */
41562 winShmBarrier, /* xShmBarrier */
41563 winShmUnmap, /* xShmUnmap */
41564 winFetch, /* xFetch */
41565 winUnfetch /* xUnfetch */
41566 };
41567
41568 static winVfsAppData winAppData = {
41569 &winIoMethod, /* pMethod */
41570 0, /* pAppData */
41571 0 /* bNoLock */
41572 };
41573
41574 static winVfsAppData winNolockAppData = {
41575 &winIoNolockMethod, /* pMethod */
41576 0, /* pAppData */
41577 1 /* bNoLock */
41578 };
41579
41580 /****************************************************************************
41581 **************************** sqlite3_vfs methods ****************************
41582 **
41583 ** This division contains the implementation of methods on the
@@ -41625,11 +41907,11 @@
41907
41908 /*
41909 ** Open a file.
41910 */
41911 static int winOpen(
41912 sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
41913 const char *zName, /* Name of the file (UTF-8) */
41914 sqlite3_file *id, /* Write the SQLite file handle here */
41915 int flags, /* Open mode flags */
41916 int *pOutFlags /* Status return flags */
41917 ){
@@ -41640,10 +41922,11 @@
41922 DWORD dwCreationDisposition;
41923 DWORD dwFlagsAndAttributes = 0;
41924 #if SQLITE_OS_WINCE
41925 int isTemp = 0;
41926 #endif
41927 winVfsAppData *pAppData;
41928 winFile *pFile = (winFile*)id;
41929 void *zConverted; /* Filename in OS encoding */
41930 const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
41931 int cnt = 0;
41932
@@ -41861,19 +42144,24 @@
42144
42145 OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
42146 "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
42147 *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
42148
42149 pAppData = (winVfsAppData*)pVfs->pAppData;
42150
42151 #if SQLITE_OS_WINCE
42152 {
42153 if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
42154 && ((pAppData==NULL) || !pAppData->bNoLock)
42155 && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
42156 ){
42157 osCloseHandle(h);
42158 sqlite3_free(zConverted);
42159 sqlite3_free(zTmpname);
42160 OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
42161 return rc;
42162 }
42163 }
42164 if( isTemp ){
42165 pFile->zDeleteOnClose = zConverted;
42166 }else
42167 #endif
@@ -41880,11 +42168,11 @@
42168 {
42169 sqlite3_free(zConverted);
42170 }
42171
42172 sqlite3_free(zTmpname);
42173 pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;
42174 pFile->pVfs = pVfs;
42175 pFile->h = h;
42176 if( isReadonly ){
42177 pFile->ctrlFlags |= WINFILE_RDONLY;
42178 }
@@ -42155,10 +42443,22 @@
42443 sqlite3_vfs *pVfs, /* Pointer to vfs object */
42444 const char *zRelative, /* Possibly relative input path */
42445 int nFull, /* Size of output buffer in bytes */
42446 char *zFull /* Output buffer */
42447 ){
42448 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42449 DWORD nByte;
42450 void *zConverted;
42451 char *zOut;
42452 #endif
42453
42454 /* If this path name begins with "/X:", where "X" is any alphabetic
42455 ** character, discard the initial "/" from the pathname.
42456 */
42457 if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42458 zRelative++;
42459 }
42460
42461 #if defined(__CYGWIN__)
42462 SimulateIOError( return SQLITE_ERROR );
42463 UNUSED_PARAMETER(nFull);
42464 assert( nFull>=pVfs->mxPathname );
@@ -42233,21 +42533,10 @@
42533 }
42534 return SQLITE_OK;
42535 #endif
42536
42537 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
 
 
 
 
 
 
 
 
 
 
 
42538 /* It's odd to simulate an io-error here, but really this is just
42539 ** using the io-error infrastructure to test that SQLite handles this
42540 ** function failing. This function could fail if, for example, the
42541 ** current working directory has been unlinked.
42542 */
@@ -42602,57 +42891,107 @@
42891 /*
42892 ** Initialize and deinitialize the operating system interface.
42893 */
42894 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
42895 static sqlite3_vfs winVfs = {
42896 3, /* iVersion */
42897 sizeof(winFile), /* szOsFile */
42898 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42899 0, /* pNext */
42900 "win32", /* zName */
42901 &winAppData, /* pAppData */
42902 winOpen, /* xOpen */
42903 winDelete, /* xDelete */
42904 winAccess, /* xAccess */
42905 winFullPathname, /* xFullPathname */
42906 winDlOpen, /* xDlOpen */
42907 winDlError, /* xDlError */
42908 winDlSym, /* xDlSym */
42909 winDlClose, /* xDlClose */
42910 winRandomness, /* xRandomness */
42911 winSleep, /* xSleep */
42912 winCurrentTime, /* xCurrentTime */
42913 winGetLastError, /* xGetLastError */
42914 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42915 winSetSystemCall, /* xSetSystemCall */
42916 winGetSystemCall, /* xGetSystemCall */
42917 winNextSystemCall, /* xNextSystemCall */
42918 };
42919 #if defined(SQLITE_WIN32_HAS_WIDE)
42920 static sqlite3_vfs winLongPathVfs = {
42921 3, /* iVersion */
42922 sizeof(winFile), /* szOsFile */
42923 SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42924 0, /* pNext */
42925 "win32-longpath", /* zName */
42926 &winAppData, /* pAppData */
42927 winOpen, /* xOpen */
42928 winDelete, /* xDelete */
42929 winAccess, /* xAccess */
42930 winFullPathname, /* xFullPathname */
42931 winDlOpen, /* xDlOpen */
42932 winDlError, /* xDlError */
42933 winDlSym, /* xDlSym */
42934 winDlClose, /* xDlClose */
42935 winRandomness, /* xRandomness */
42936 winSleep, /* xSleep */
42937 winCurrentTime, /* xCurrentTime */
42938 winGetLastError, /* xGetLastError */
42939 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42940 winSetSystemCall, /* xSetSystemCall */
42941 winGetSystemCall, /* xGetSystemCall */
42942 winNextSystemCall, /* xNextSystemCall */
42943 };
42944 #endif
42945 static sqlite3_vfs winNolockVfs = {
42946 3, /* iVersion */
42947 sizeof(winFile), /* szOsFile */
42948 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42949 0, /* pNext */
42950 "win32-none", /* zName */
42951 &winNolockAppData, /* pAppData */
42952 winOpen, /* xOpen */
42953 winDelete, /* xDelete */
42954 winAccess, /* xAccess */
42955 winFullPathname, /* xFullPathname */
42956 winDlOpen, /* xDlOpen */
42957 winDlError, /* xDlError */
42958 winDlSym, /* xDlSym */
42959 winDlClose, /* xDlClose */
42960 winRandomness, /* xRandomness */
42961 winSleep, /* xSleep */
42962 winCurrentTime, /* xCurrentTime */
42963 winGetLastError, /* xGetLastError */
42964 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42965 winSetSystemCall, /* xSetSystemCall */
42966 winGetSystemCall, /* xGetSystemCall */
42967 winNextSystemCall, /* xNextSystemCall */
42968 };
42969 #if defined(SQLITE_WIN32_HAS_WIDE)
42970 static sqlite3_vfs winLongPathNolockVfs = {
42971 3, /* iVersion */
42972 sizeof(winFile), /* szOsFile */
42973 SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42974 0, /* pNext */
42975 "win32-longpath-none", /* zName */
42976 &winNolockAppData, /* pAppData */
42977 winOpen, /* xOpen */
42978 winDelete, /* xDelete */
42979 winAccess, /* xAccess */
42980 winFullPathname, /* xFullPathname */
42981 winDlOpen, /* xDlOpen */
42982 winDlError, /* xDlError */
42983 winDlSym, /* xDlSym */
42984 winDlClose, /* xDlClose */
42985 winRandomness, /* xRandomness */
42986 winSleep, /* xSleep */
42987 winCurrentTime, /* xCurrentTime */
42988 winGetLastError, /* xGetLastError */
42989 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42990 winSetSystemCall, /* xSetSystemCall */
42991 winGetSystemCall, /* xGetSystemCall */
42992 winNextSystemCall, /* xNextSystemCall */
42993 };
42994 #endif
42995
42996 /* Double-check that the aSyscall[] array has been constructed
42997 ** correctly. See ticket [bb3a86e890c8e96ab] */
@@ -42671,10 +43010,16 @@
43010 sqlite3_vfs_register(&winVfs, 1);
43011
43012 #if defined(SQLITE_WIN32_HAS_WIDE)
43013 sqlite3_vfs_register(&winLongPathVfs, 0);
43014 #endif
43015
43016 sqlite3_vfs_register(&winNolockVfs, 0);
43017
43018 #if defined(SQLITE_WIN32_HAS_WIDE)
43019 sqlite3_vfs_register(&winLongPathNolockVfs, 0);
43020 #endif
43021
43022 return SQLITE_OK;
43023 }
43024
43025 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
@@ -43792,32 +44137,34 @@
44137 sqlite3PcacheTruncate(pCache, 0);
44138 }
44139
44140 /*
44141 ** Merge two lists of pages connected by pDirty and in pgno order.
44142 ** Do not bother fixing the pDirtyPrev pointers.
44143 */
44144 static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
44145 PgHdr result, *pTail;
44146 pTail = &result;
44147 assert( pA!=0 && pB!=0 );
44148 for(;;){
44149 if( pA->pgno<pB->pgno ){
44150 pTail->pDirty = pA;
44151 pTail = pA;
44152 pA = pA->pDirty;
44153 if( pA==0 ){
44154 pTail->pDirty = pB;
44155 break;
44156 }
44157 }else{
44158 pTail->pDirty = pB;
44159 pTail = pB;
44160 pB = pB->pDirty;
44161 if( pB==0 ){
44162 pTail->pDirty = pA;
44163 break;
44164 }
44165 }
 
 
 
44166 }
44167 return result.pDirty;
44168 }
44169
44170 /*
@@ -43855,11 +44202,12 @@
44202 a[i] = pcacheMergeDirtyList(a[i], p);
44203 }
44204 }
44205 p = a[0];
44206 for(i=1; i<N_SORT_BUCKET; i++){
44207 if( a[i]==0 ) continue;
44208 p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
44209 }
44210 return p;
44211 }
44212
44213 /*
@@ -45460,31 +45808,29 @@
45808 ){
45809 struct RowSetEntry head;
45810 struct RowSetEntry *pTail;
45811
45812 pTail = &head;
45813 assert( pA!=0 && pB!=0 );
45814 for(;;){
45815 assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45816 assert( pB->pRight==0 || pB->v<=pB->pRight->v );
45817 if( pA->v<=pB->v ){
45818 if( pA->v<pB->v ) pTail = pTail->pRight = pA;
45819 pA = pA->pRight;
45820 if( pA==0 ){
45821 pTail->pRight = pB;
45822 break;
45823 }
45824 }else{
45825 pTail = pTail->pRight = pB;
45826 pB = pB->pRight;
45827 if( pB==0 ){
45828 pTail->pRight = pA;
45829 break;
45830 }
45831 }
 
 
 
 
 
 
45832 }
45833 return head.pRight;
45834 }
45835
45836 /*
@@ -45504,13 +45850,14 @@
45850 aBucket[i] = 0;
45851 }
45852 aBucket[i] = pIn;
45853 pIn = pNext;
45854 }
45855 pIn = aBucket[0];
45856 for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45857 if( aBucket[i]==0 ) continue;
45858 pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];
45859 }
45860 return pIn;
45861 }
45862
45863
@@ -45758,12 +46105,12 @@
46105 ** This header file defines the interface to the write-ahead logging
46106 ** system. Refer to the comments below and the header comment attached to
46107 ** the implementation of each function in log.c for further details.
46108 */
46109
46110 #ifndef SQLITE_WAL_H
46111 #define SQLITE_WAL_H
46112
46113 /* #include "sqliteInt.h" */
46114
46115 /* Additional values that can be added to the sync_flags argument of
46116 ** sqlite3WalFrames():
@@ -45887,11 +46234,11 @@
46234
46235 /* Return the sqlite3_file object for the WAL file */
46236 SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);
46237
46238 #endif /* ifndef SQLITE_OMIT_WAL */
46239 #endif /* SQLITE_WAL_H */
46240
46241 /************** End of wal.h *************************************************/
46242 /************** Continuing where we left off in pager.c **********************/
46243
46244
@@ -53027,20 +53374,10 @@
53374 */
53375 SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
53376 return &pPager->pBackup;
53377 }
53378
 
 
 
 
 
 
 
 
 
 
53379 #ifndef SQLITE_OMIT_WAL
53380 /*
53381 ** This function is called when the user invokes "PRAGMA wal_checkpoint",
53382 ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
53383 ** or wal_blocking_checkpoint() API functions.
@@ -56378,20 +56715,25 @@
56715 ** boundary is crossed. Only the part of the WAL prior to the last
56716 ** sector boundary is synced; the part of the last frame that extends
56717 ** past the sector boundary is written after the sync.
56718 */
56719 if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
56720 int bSync = 1;
56721 if( pWal->padToSectorBoundary ){
56722 int sectorSize = sqlite3SectorSize(pWal->pWalFd);
56723 w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
56724 bSync = (w.iSyncPoint==iOffset);
56725 testcase( bSync );
56726 while( iOffset<w.iSyncPoint ){
56727 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
56728 if( rc ) return rc;
56729 iOffset += szFrame;
56730 nExtra++;
56731 }
56732 }
56733 if( bSync ){
56734 assert( rc==SQLITE_OK );
56735 rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);
56736 }
56737 }
56738
56739 /* If this frame set completes the first transaction in the WAL and
@@ -58174,10 +58516,19 @@
58516 */
58517 #ifdef SQLITE_DEBUG
58518 static int cursorHoldsMutex(BtCursor *p){
58519 return sqlite3_mutex_held(p->pBt->mutex);
58520 }
58521
58522 /* Verify that the cursor and the BtShared agree about what is the current
58523 ** database connetion. This is important in shared-cache mode. If the database
58524 ** connection pointers get out-of-sync, it is possible for routines like
58525 ** btreeInitPage() to reference an stale connection pointer that references a
58526 ** a connection that has already closed. This routine is used inside assert()
58527 ** statements only and for the purpose of double-checking that the btree code
58528 ** does keep the database connection pointers up-to-date.
58529 */
58530 static int cursorOwnsBtShared(BtCursor *p){
58531 assert( cursorHoldsMutex(p) );
58532 return (p->pBtree->db==p->pBt->db);
58533 }
58534 #endif
@@ -58333,25 +58684,23 @@
58684 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
58685 ** set to point to a malloced buffer pCur->nKey bytes in size containing
58686 ** the key.
58687 */
58688 static int saveCursorKey(BtCursor *pCur){
58689 int rc = SQLITE_OK;
58690 assert( CURSOR_VALID==pCur->eState );
58691 assert( 0==pCur->pKey );
58692 assert( cursorHoldsMutex(pCur) );
58693
58694 if( pCur->curIntKey ){
58695 /* Only the rowid is required for a table btree */
58696 pCur->nKey = sqlite3BtreeIntegerKey(pCur);
58697 }else{
58698 /* For an index btree, save the complete key content */
58699 void *pKey;
58700 pCur->nKey = sqlite3BtreePayloadSize(pCur);
58701 pKey = sqlite3Malloc( pCur->nKey );
 
 
58702 if( pKey ){
58703 rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
58704 if( rc==SQLITE_OK ){
58705 pCur->pKey = pKey;
58706 }else{
@@ -60054,13 +60403,13 @@
60403 assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
60404
60405 #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
60406 /* Add the new BtShared object to the linked list sharable BtShareds.
60407 */
60408 pBt->nRef = 1;
60409 if( p->sharable ){
60410 MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
 
60411 MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
60412 if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
60413 pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
60414 if( pBt->mutex==0 ){
60415 rc = SQLITE_NOMEM_BKPT;
@@ -60127,10 +60476,11 @@
60476 }
60477 if( mutexOpen ){
60478 assert( sqlite3_mutex_held(mutexOpen) );
60479 sqlite3_mutex_leave(mutexOpen);
60480 }
60481 assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );
60482 return rc;
60483 }
60484
60485 /*
60486 ** Decrement the BtShared.nRef counter. When it reaches zero,
@@ -61986,50 +62336,37 @@
62336 return pCur && pCur->eState==CURSOR_VALID;
62337 }
62338 #endif /* NDEBUG */
62339
62340 /*
62341 ** Return the value of the integer key or "rowid" for a table btree.
62342 ** This routine is only valid for a cursor that is pointing into a
62343 ** ordinary table btree. If the cursor points to an index btree or
62344 ** is invalid, the result of this routine is undefined.
 
 
 
 
 
 
62345 */
62346 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
62347 assert( cursorHoldsMutex(pCur) );
62348 assert( pCur->eState==CURSOR_VALID );
62349 assert( pCur->curIntKey );
62350 getCellInfo(pCur);
62351 return pCur->info.nKey;
 
62352 }
62353
62354 /*
62355 ** Return the number of bytes of payload for the entry that pCur is
62356 ** currently pointing to. For table btrees, this will be the amount
62357 ** of data. For index btrees, this will be the size of the key.
62358 **
62359 ** The caller must guarantee that the cursor is pointing to a non-NULL
62360 ** valid entry. In other words, the calling procedure must guarantee
62361 ** that the cursor has Cursor.eState==CURSOR_VALID.
 
 
 
 
62362 */
62363 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){
62364 assert( cursorHoldsMutex(pCur) );
62365 assert( pCur->eState==CURSOR_VALID );
 
 
 
62366 getCellInfo(pCur);
62367 return pCur->info.nPayload;
 
62368 }
62369
62370 /*
62371 ** Given the page number of an overflow page in the database (parameter
62372 ** ovfl), this function finds the page number of the next page in the
@@ -62467,14 +62804,11 @@
62804 ** this routine.
62805 **
62806 ** These routines is used to get quick access to key and data
62807 ** in the common case where no overflow pages are used.
62808 */
62809 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){
 
 
 
62810 return fetchPayload(pCur, pAmt);
62811 }
62812
62813
62814 /*
@@ -62803,15 +63137,16 @@
63137
63138 assert( cursorOwnsBtShared(pCur) );
63139 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
63140 assert( pRes );
63141 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
63142 assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
63143
63144 /* If the cursor is already positioned at the point we are trying
63145 ** to move to, then just return without doing any work */
63146 if( pIdxKey==0
63147 && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
63148 ){
63149 if( pCur->info.nKey==intKey ){
63150 *pRes = 0;
63151 return SQLITE_OK;
63152 }
@@ -63796,13 +64131,11 @@
64131 ** later.
64132 */
64133 static int fillInCell(
64134 MemPage *pPage, /* The page that contains the cell */
64135 unsigned char *pCell, /* Complete text of the cell */
64136 const BtreePayload *pX, /* Payload with which to construct the cell */
 
 
64137 int *pnSize /* Write cell size here */
64138 ){
64139 int nPayload;
64140 const u8 *pSrc;
64141 int nSrc, n, rc;
@@ -63822,30 +64155,27 @@
64155 assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
64156 || sqlite3PagerIswriteable(pPage->pDbPage) );
64157
64158 /* Fill in the header. */
64159 nHeader = pPage->childPtrSize;
 
 
 
 
 
 
 
 
 
 
64160 if( pPage->intKey ){
64161 nPayload = pX->nData + pX->nZero;
64162 pSrc = pX->pData;
64163 nSrc = pX->nData;
64164 assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */
64165 nHeader += putVarint32(&pCell[nHeader], nPayload);
64166 nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);
64167 }else{
64168 assert( pX->nData==0 );
64169 assert( pX->nZero==0 );
64170 assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );
64171 nSrc = nPayload = (int)pX->nKey;
64172 pSrc = pX->pKey;
64173 nHeader += putVarint32(&pCell[nHeader], nPayload);
64174 }
64175
64176 /* Fill in the payload */
64177 if( nPayload<=pPage->maxLocal ){
64178 n = nHeader + nPayload;
64179 testcase( n==3 );
64180 testcase( n==4 );
64181 if( n<4 ) n = 4;
@@ -63879,11 +64209,11 @@
64209 #if SQLITE_DEBUG
64210 {
64211 CellInfo info;
64212 pPage->xParseCell(pPage, pCell, &info);
64213 assert( nHeader==(int)(info.pPayload - pCell) );
64214 assert( info.nKey==pX->nKey );
64215 assert( *pnSize == info.nSize );
64216 assert( spaceLeft == info.nLocal );
64217 }
64218 #endif
64219
@@ -63964,14 +64294,10 @@
64294 nPayload -= n;
64295 pPayload += n;
64296 pSrc += n;
64297 nSrc -= n;
64298 spaceLeft -= n;
 
 
 
 
64299 }
64300 releasePage(pToRelease);
64301 return SQLITE_OK;
64302 }
64303
@@ -64034,10 +64360,12 @@
64360 ** pTemp is not null. Regardless of pTemp, allocate a new entry
64361 ** in pPage->apOvfl[] and make it point to the cell content (either
64362 ** in pTemp or the original pCell) and also record its index.
64363 ** Allocating a new entry in pPage->aCell[] implies that
64364 ** pPage->nOverflow is incremented.
64365 **
64366 ** *pRC must be SQLITE_OK when this routine is called.
64367 */
64368 static void insertCell(
64369 MemPage *pPage, /* Page into which we are copying */
64370 int i, /* New cell becomes the i-th cell of the page */
64371 u8 *pCell, /* Content of the new cell */
@@ -64049,12 +64377,11 @@
64377 int idx = 0; /* Where to write new cell content in data[] */
64378 int j; /* Loop counter */
64379 u8 *data; /* The content of the whole page */
64380 u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
64381
64382 assert( *pRC==SQLITE_OK );
 
64383 assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
64384 assert( MX_CELL(pPage->pBt)<=10921 );
64385 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
64386 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
64387 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
@@ -64556,12 +64883,14 @@
64883 while( (*(pCell++)&0x80) && pCell<pStop );
64884 pStop = &pCell[9];
64885 while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );
64886
64887 /* Insert the new divider cell into pParent. */
64888 if( rc==SQLITE_OK ){
64889 insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64890 0, pPage->pgno, &rc);
64891 }
64892
64893 /* Set the right-child pointer of pParent to point to the new page. */
64894 put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
64895
64896 /* Release the reference to the new page. */
@@ -65077,11 +65406,11 @@
65406 do{
65407 assert( d<nMaxCells );
65408 assert( r<nMaxCells );
65409 (void)cachedCellSize(&b, r);
65410 if( szRight!=0
65411 && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){
65412 break;
65413 }
65414 szRight += b.szCell[d] + 2;
65415 szLeft -= b.szCell[r] + 2;
65416 cntNew[i-1] = r;
@@ -65649,17 +65978,23 @@
65978 return rc;
65979 }
65980
65981
65982 /*
65983 ** Insert a new record into the BTree. The content of the new record
65984 ** is described by the pX object. The pCur cursor is used only to
65985 ** define what table the record should be inserted into, and is left
65986 ** pointing at a random location.
65987 **
65988 ** For a table btree (used for rowid tables), only the pX.nKey value of
65989 ** the key is used. The pX.pKey value must be NULL. The pX.nKey is the
65990 ** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields
65991 ** hold the content of the row.
65992 **
65993 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
65994 ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
65995 ** pX.pData,nData,nZero fields must be zero.
65996 **
65997 ** If the seekResult parameter is non-zero, then a successful call to
65998 ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
65999 ** been performed. seekResult is the search result returned (a negative
66000 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
@@ -65672,13 +66007,11 @@
66007 ** point to any entry or to no entry at all and so this function has to seek
66008 ** the cursor before the new key can be inserted.
66009 */
66010 SQLITE_PRIVATE int sqlite3BtreeInsert(
66011 BtCursor *pCur, /* Insert data into the table of this cursor */
66012 const BtreePayload *pX, /* Content of the row to be inserted */
 
 
66013 int appendBias, /* True if this is likely an append */
66014 int seekResult /* Result of prior MovetoUnpacked() call */
66015 ){
66016 int rc;
66017 int loc = seekResult; /* -1: before desired location +1: after */
@@ -65704,11 +66037,11 @@
66037 /* Assert that the caller has been consistent. If this cursor was opened
66038 ** expecting an index b-tree, then the caller should be inserting blob
66039 ** keys with no associated data. If the cursor was opened expecting an
66040 ** intkey table, the caller should be inserting integer keys with a
66041 ** blob of associated data. */
66042 assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );
66043
66044 /* Save the positions of any other cursors open on this table.
66045 **
66046 ** In some cases, the call to btreeMoveto() below is a no-op. For
66047 ** example, when inserting data into a table with auto-generated integer
@@ -65723,42 +66056,42 @@
66056 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
66057 if( rc ) return rc;
66058 }
66059
66060 if( pCur->pKeyInfo==0 ){
66061 assert( pX->pKey==0 );
66062 /* If this is an insert into a table b-tree, invalidate any incrblob
66063 ** cursors open on the row being replaced */
66064 invalidateIncrblobCursors(p, pX->nKey, 0);
66065
66066 /* If the cursor is currently on the last row and we are appending a
66067 ** new row onto the end, set the "loc" to avoid an unnecessary
66068 ** btreeMoveto() call */
66069 if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0
66070 && pCur->info.nKey==pX->nKey-1 ){
66071 loc = -1;
66072 }else if( loc==0 ){
66073 rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc);
66074 if( rc ) return rc;
66075 }
66076 }else if( loc==0 ){
66077 rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc);
66078 if( rc ) return rc;
66079 }
66080 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
66081
66082 pPage = pCur->apPage[pCur->iPage];
66083 assert( pPage->intKey || pX->nKey>=0 );
66084 assert( pPage->leaf || !pPage->intKey );
66085
66086 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
66087 pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,
66088 loc==0 ? "overwrite" : "new entry"));
66089 assert( pPage->isInit );
66090 newCell = pBt->pTmpSpace;
66091 assert( newCell!=0 );
66092 rc = fillInCell(pPage, newCell, pX, &szNew);
66093 if( rc ) goto end_insert;
66094 assert( szNew==pPage->xCellSize(pPage, newCell) );
66095 assert( szNew <= MX_CELL_SIZE(pBt) );
66096 idx = pCur->aiIdx[pCur->iPage];
66097 if( loc==0 ){
@@ -65780,10 +66113,11 @@
66113 idx = ++pCur->aiIdx[pCur->iPage];
66114 }else{
66115 assert( pPage->leaf );
66116 }
66117 insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
66118 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
66119 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
66120
66121 /* If no error has occurred and pPage has an overflow cell, call balance()
66122 ** to redistribute the cells within the tree. Since balance() may move
66123 ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey
@@ -65803,11 +66137,12 @@
66137 ** entry in the table, and the next row inserted has an integer key
66138 ** larger than the largest existing key, it is possible to insert the
66139 ** row without seeking the cursor. This can be a big performance boost.
66140 */
66141 pCur->info.nSize = 0;
66142 if( pPage->nOverflow ){
66143 assert( rc==SQLITE_OK );
66144 pCur->curFlags &= ~(BTCF_ValidNKey);
66145 rc = balance(pCur);
66146
66147 /* Must make sure nOverflow is reset to zero even if the balance()
66148 ** fails. Internal data structure corruption will result otherwise.
@@ -65939,11 +66274,13 @@
66274 nCell = pLeaf->xCellSize(pLeaf, pCell);
66275 assert( MX_CELL_SIZE(pBt) >= nCell );
66276 pTmp = pBt->pTmpSpace;
66277 assert( pTmp!=0 );
66278 rc = sqlite3PagerWrite(pLeaf->pDbPage);
66279 if( rc==SQLITE_OK ){
66280 insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66281 }
66282 dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
66283 if( rc ) return rc;
66284 }
66285
66286 /* Balance the tree. If the entry deleted was located on a leaf page,
@@ -67428,10 +67765,20 @@
67765 ** Return true if the Btree passed as the only argument is sharable.
67766 */
67767 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
67768 return p->sharable;
67769 }
67770
67771 /*
67772 ** Return the number of connections to the BtShared object accessed by
67773 ** the Btree handle passed as the only argument. For private caches
67774 ** this is always 1. For shared caches it may be 1 or greater.
67775 */
67776 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){
67777 testcase( p->sharable );
67778 return p->pBt->nRef;
67779 }
67780 #endif
67781
67782 /************** End of btree.c ***********************************************/
67783 /************** Begin file backup.c ******************************************/
67784 /*
@@ -68218,12 +68565,10 @@
68565 sqlite3_backup_step(&b, 0x7FFFFFFF);
68566 assert( b.rc!=SQLITE_OK );
68567 rc = sqlite3_backup_finish(&b);
68568 if( rc==SQLITE_OK ){
68569 pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;
 
 
68570 }
68571
68572 assert( sqlite3BtreeIsInTrans(pTo)==0 );
68573 copy_finished:
68574 sqlite3BtreeLeave(pFrom);
@@ -69225,15 +69570,11 @@
69570 assert( !VdbeMemDynamic(pMem) );
69571
69572 /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert()
69573 ** that both the BtShared and database handle mutexes are held. */
69574 assert( (pMem->flags & MEM_RowSet)==0 );
69575 zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);
 
 
 
 
69576 assert( zData!=0 );
69577
69578 if( offset+amt<=available ){
69579 pMem->z = &zData[offset];
69580 pMem->flags = MEM_Blob|MEM_Ephem;
@@ -70009,18 +70350,10 @@
70350 assert( p->zSql==0 );
70351 p->zSql = sqlite3DbStrNDup(p->db, z, n);
70352 p->isPrepareV2 = (u8)isPrepareV2;
70353 }
70354
 
 
 
 
 
 
 
 
70355 /*
70356 ** Swap all content between two VDBE structures.
70357 */
70358 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
70359 Vdbe tmp, *pTmp;
@@ -70736,26 +71069,34 @@
71069 /*
71070 ** If the input FuncDef structure is ephemeral, then free it. If
71071 ** the FuncDef is not ephermal, then do nothing.
71072 */
71073 static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
71074 if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
71075 sqlite3DbFree(db, pDef);
71076 }
71077 }
71078
71079 static void vdbeFreeOpArray(sqlite3 *, Op *, int);
71080
71081 /*
71082 ** Delete a P4 value if necessary.
71083 */
71084 static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
71085 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
71086 sqlite3DbFree(db, p);
71087 }
71088 static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
71089 freeEphemeralFunction(db, p->pFunc);
71090 sqlite3DbFree(db, p);
71091 }
71092 static void freeP4(sqlite3 *db, int p4type, void *p4){
71093 assert( db );
71094 switch( p4type ){
71095 case P4_FUNCCTX: {
71096 freeP4FuncCtx(db, (sqlite3_context*)p4);
71097 break;
71098 }
71099 case P4_REAL:
71100 case P4_INT64:
71101 case P4_DYNAMIC:
71102 case P4_INTARRAY: {
@@ -70782,13 +71123,11 @@
71123 }
71124 case P4_MEM: {
71125 if( db->pnBytesFreed==0 ){
71126 sqlite3ValueFree((sqlite3_value*)p4);
71127 }else{
71128 freeP4Mem(db, (Mem*)p4);
 
 
71129 }
71130 break;
71131 }
71132 case P4_VTAB : {
71133 if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
@@ -74254,12 +74593,11 @@
74593 ** than 2GiB are support - anything large must be database corruption.
74594 ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
74595 ** this code can safely assume that nCellKey is 32-bits
74596 */
74597 assert( sqlite3BtreeCursorIsValid(pCur) );
74598 nCellKey = sqlite3BtreePayloadSize(pCur);
 
74599 assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
74600
74601 /* Read in the complete content of the index entry */
74602 sqlite3VdbeMemInit(&m, db, 0);
74603 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
@@ -74332,12 +74670,11 @@
74670 Mem m;
74671
74672 assert( pC->eCurType==CURTYPE_BTREE );
74673 pCur = pC->uc.pCursor;
74674 assert( sqlite3BtreeCursorIsValid(pCur) );
74675 nCellKey = sqlite3BtreePayloadSize(pCur);
 
74676 /* nCellKey will always be between 0 and 0xffffffff because of the way
74677 ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
74678 if( nCellKey<=0 || nCellKey>0x7fffffff ){
74679 *res = 0;
74680 return SQLITE_CORRUPT_BKPT;
@@ -74595,16 +74932,23 @@
74932 ** Invoke the profile callback. This routine is only called if we already
74933 ** know that the profile callback is defined and needs to be invoked.
74934 */
74935 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
74936 sqlite3_int64 iNow;
74937 sqlite3_int64 iElapse;
74938 assert( p->startTime>0 );
74939 assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
74940 assert( db->init.busy==0 );
74941 assert( p->zSql!=0 );
74942 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
74943 iElapse = (iNow - p->startTime)*1000000;
74944 if( db->xProfile ){
74945 db->xProfile(db->pProfileArg, p->zSql, iElapse);
74946 }
74947 if( db->mTrace & SQLITE_TRACE_PROFILE ){
74948 db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
74949 }
74950 p->startTime = 0;
74951 }
74952 /*
74953 ** The checkProfileCallback(DB,P) macro checks to see if a profile callback
74954 ** is needed, and it invokes the callback if it is needed.
@@ -75104,11 +75448,12 @@
75448 assert( db->nVdbeWrite>0 || db->autoCommit==0
75449 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
75450 );
75451
75452 #ifndef SQLITE_OMIT_TRACE
75453 if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
75454 && !db->init.busy && p->zSql ){
75455 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
75456 }else{
75457 assert( p->startTime==0 );
75458 }
75459 #endif
@@ -76138,10 +76483,43 @@
76483 #endif
76484 v = pVdbe->aCounter[op];
76485 if( resetFlag ) pVdbe->aCounter[op] = 0;
76486 return (int)v;
76487 }
76488
76489 /*
76490 ** Return the SQL associated with a prepared statement
76491 */
76492 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
76493 Vdbe *p = (Vdbe *)pStmt;
76494 return p ? p->zSql : 0;
76495 }
76496
76497 /*
76498 ** Return the SQL associated with a prepared statement with
76499 ** bound parameters expanded. Space to hold the returned string is
76500 ** obtained from sqlite3_malloc(). The caller is responsible for
76501 ** freeing the returned string by passing it to sqlite3_free().
76502 **
76503 ** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
76504 ** expanded bound parameters.
76505 */
76506 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt){
76507 #ifdef SQLITE_OMIT_TRACE
76508 return 0;
76509 #else
76510 char *z = 0;
76511 const char *zSql = sqlite3_sql(pStmt);
76512 if( zSql ){
76513 Vdbe *p = (Vdbe *)pStmt;
76514 sqlite3_mutex_enter(p->db->mutex);
76515 z = sqlite3VdbeExpandSql(p, zSql);
76516 sqlite3_mutex_leave(p->db->mutex);
76517 }
76518 return z;
76519 #endif
76520 }
76521
76522 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
76523 /*
76524 ** Allocate and populate an UnpackedRecord structure based on the serialized
76525 ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
@@ -76185,12 +76563,11 @@
76563 /* If the old.* record has not yet been loaded into memory, do so now. */
76564 if( p->pUnpacked==0 ){
76565 u32 nRec;
76566 u8 *aRec;
76567
76568 nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
 
76569 aRec = sqlite3DbMallocRaw(db, nRec);
76570 if( !aRec ) goto preupdate_old_out;
76571 rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
76572 if( rc==SQLITE_OK ){
76573 p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
@@ -76474,14 +76851,17 @@
76851 int n; /* Length of a token prefix */
76852 int nToken; /* Length of the parameter token */
76853 int i; /* Loop counter */
76854 Mem *pVar; /* Value of a host parameter */
76855 StrAccum out; /* Accumulate the output here */
76856 #ifndef SQLITE_OMIT_UTF16
76857 Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */
76858 #endif
76859 char zBase[100]; /* Initial working space */
76860
76861 db = p->db;
76862 sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase),
76863 db->aLimit[SQLITE_LIMIT_LENGTH]);
76864 if( db->nVdbeExec>1 ){
76865 while( *zRawSql ){
76866 const char *zStart = zRawSql;
76867 while( *(zRawSql++)!='\n' && *zRawSql );
@@ -76528,16 +76908,18 @@
76908 sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
76909 }else if( pVar->flags & MEM_Str ){
76910 int nOut; /* Number of bytes of the string text to include in output */
76911 #ifndef SQLITE_OMIT_UTF16
76912 u8 enc = ENC(db);
 
76913 if( enc!=SQLITE_UTF8 ){
76914 memset(&utf8, 0, sizeof(utf8));
76915 utf8.db = db;
76916 sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
76917 if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
76918 out.accError = STRACCUM_NOMEM;
76919 out.nAlloc = 0;
76920 }
76921 pVar = &utf8;
76922 }
76923 #endif
76924 nOut = pVar->n;
76925 #ifdef SQLITE_TRACE_SIZE_LIMIT
@@ -76575,10 +76957,11 @@
76957 }
76958 #endif
76959 }
76960 }
76961 }
76962 if( out.accError ) sqlite3StrAccumReset(&out);
76963 return sqlite3StrAccumFinish(&out);
76964 }
76965
76966 #endif /* #ifndef SQLITE_OMIT_TRACE */
76967
@@ -77107,12 +77490,12 @@
77490 ******************************************************************************
77491 **
77492 ** This file contains inline asm code for retrieving "high-performance"
77493 ** counters for x86 class CPUs.
77494 */
77495 #ifndef SQLITE_HWTIME_H
77496 #define SQLITE_HWTIME_H
77497
77498 /*
77499 ** The following routine only works on pentium-class (or newer) processors.
77500 ** It uses the RDTSC opcode to read the cycle count value out of the
77501 ** processor and returns that value. This can be used for high-res
@@ -77176,11 +77559,11 @@
77559 */
77560 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
77561
77562 #endif
77563
77564 #endif /* !defined(SQLITE_HWTIME_H) */
77565
77566 /************** End of hwtime.h **********************************************/
77567 /************** Continuing where we left off in vdbe.c ***********************/
77568
77569 #endif
@@ -78055,10 +78438,14 @@
78438 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
78439 sqlite3VdbeMemNulTerminate(&pMem[i]);
78440 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
78441 }
78442 if( db->mallocFailed ) goto no_mem;
78443
78444 if( db->mTrace & SQLITE_TRACE_ROW ){
78445 db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);
78446 }
78447
78448 /* Return SQLITE_ROW
78449 */
78450 p->pc = (int)(pOp - aOp) + 1;
78451 rc = SQLITE_ROW;
@@ -78689,10 +79076,11 @@
79076 affinity = pOp->p5 & SQLITE_AFF_MASK;
79077 if( affinity>=SQLITE_AFF_NUMERIC ){
79078 if( (flags1 | flags3)&MEM_Str ){
79079 if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
79080 applyNumericAffinity(pIn1,0);
79081 flags3 = pIn3->flags;
79082 }
79083 if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
79084 applyNumericAffinity(pIn3,0);
79085 }
79086 }
@@ -78701,10 +79089,11 @@
79089 testcase( pIn1->flags & MEM_Int );
79090 testcase( pIn1->flags & MEM_Real );
79091 sqlite3VdbeMemStringify(pIn1, encoding, 1);
79092 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
79093 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
79094 flags3 = pIn3->flags;
79095 }
79096 if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
79097 testcase( pIn3->flags & MEM_Int );
79098 testcase( pIn3->flags & MEM_Real );
79099 sqlite3VdbeMemStringify(pIn3, encoding, 1);
@@ -79053,11 +79442,10 @@
79442 ** the result is guaranteed to only be used as the argument of a length()
79443 ** or typeof() function, respectively. The loading of large blobs can be
79444 ** skipped for length() and all content loading can be skipped for typeof().
79445 */
79446 case OP_Column: {
 
79447 int p2; /* column number to retrieve */
79448 VdbeCursor *pC; /* The VDBE cursor */
79449 BtCursor *pCrsr; /* The BTree cursor */
79450 u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
79451 int len; /* The length of the serialized data for the column */
@@ -79076,10 +79464,11 @@
79464 pC = p->apCsr[pOp->p1];
79465 p2 = pOp->p2;
79466
79467 /* If the cursor cache is stale, bring it up-to-date */
79468 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
79469 if( rc ) goto abort_due_to_error;
79470
79471 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
79472 pDest = &aMem[pOp->p3];
79473 memAboutToChange(p, pDest);
79474 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -79089,12 +79478,11 @@
79478 assert( pC->eCurType!=CURTYPE_VTAB );
79479 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
79480 assert( pC->eCurType!=CURTYPE_SORTER );
79481 pCrsr = pC->uc.pCursor;
79482
79483 if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/
 
79484 if( pC->nullRow ){
79485 if( pC->eCurType==CURTYPE_PSEUDO ){
79486 assert( pC->uc.pseudoTableReg>0 );
79487 pReg = &aMem[pC->uc.pseudoTableReg];
79488 assert( pReg->flags & MEM_Blob );
@@ -79106,26 +79494,13 @@
79494 goto op_column_out;
79495 }
79496 }else{
79497 assert( pC->eCurType==CURTYPE_BTREE );
79498 assert( pCrsr );
79499 assert( sqlite3BtreeCursorIsValid(pCrsr) );
79500 pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
79501 pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
 
 
 
 
 
 
 
 
 
 
 
 
 
79502 assert( avail<=65536 ); /* Maximum page size is 64KiB */
79503 if( pC->payloadSize <= (u32)avail ){
79504 pC->szRow = pC->payloadSize;
79505 }else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
79506 goto too_big;
@@ -79137,11 +79512,11 @@
79512 pC->iHdrOffset = getVarint32(pC->aRow, offset);
79513 pC->nHdrParsed = 0;
79514 aOffset[0] = offset;
79515
79516
79517 if( avail<offset ){ /*OPTIMIZATION-IF-FALSE*/
79518 /* pC->aRow does not have to hold the entire row, but it does at least
79519 ** need to cover the header of the record. If pC->aRow does not contain
79520 ** the complete header, then set it to zero, forcing the header to be
79521 ** dynamically allocated. */
79522 pC->aRow = 0;
@@ -79158,28 +79533,28 @@
79533 */
79534 if( offset > 98307 || offset > pC->payloadSize ){
79535 rc = SQLITE_CORRUPT_BKPT;
79536 goto abort_due_to_error;
79537 }
79538 }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/
79539 /* The following goto is an optimization. It can be omitted and
79540 ** everything will still work. But OP_Column is measurably faster
79541 ** by skipping the subsequent conditional, which is always true.
79542 */
79543 zData = pC->aRow;
79544 assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79545 goto op_column_read_header;
79546 }
79547 }
79548
79549 /* Make sure at least the first p2+1 entries of the header have been
79550 ** parsed and valid information is in aOffset[] and pC->aType[].
79551 */
79552 if( pC->nHdrParsed<=p2 ){
79553 /* If there is more header available for parsing in the record, try
79554 ** to extract additional fields up through the p2+1-th field
79555 */
 
79556 if( pC->iHdrOffset<aOffset[0] ){
79557 /* Make sure zData points to enough of the record to cover the header. */
79558 if( pC->aRow==0 ){
79559 memset(&sMem, 0, sizeof(sMem));
79560 rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
@@ -79188,15 +79563,15 @@
79563 }else{
79564 zData = pC->aRow;
79565 }
79566
79567 /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
79568 op_column_read_header:
79569 i = pC->nHdrParsed;
79570 offset64 = aOffset[i];
79571 zHdr = zData + pC->iHdrOffset;
79572 zEndHdr = zData + aOffset[0];
 
79573 do{
79574 if( (t = zHdr[0])<0x80 ){
79575 zHdr++;
79576 offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
79577 }else{
@@ -79204,13 +79579,11 @@
79579 offset64 += sqlite3VdbeSerialTypeLen(t);
79580 }
79581 pC->aType[i++] = t;
79582 aOffset[i] = (u32)(offset64 & 0xffffffff);
79583 }while( i<=p2 && zHdr<zEndHdr );
79584
 
 
79585 /* The record is corrupt if any of the following are true:
79586 ** (1) the bytes of the header extend past the declared header size
79587 ** (2) the entire header was used but not all data was used
79588 ** (3) the end of the data extends beyond the end of the record.
79589 */
@@ -79219,12 +79592,14 @@
79592 ){
79593 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79594 rc = SQLITE_CORRUPT_BKPT;
79595 goto abort_due_to_error;
79596 }
79597
79598 pC->nHdrParsed = i;
79599 pC->iHdrOffset = (u32)(zHdr - zData);
79600 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
 
79601 }else{
79602 t = 0;
79603 }
79604
79605 /* If after trying to extract new entries from the header, nHdrParsed is
@@ -79248,13 +79623,14 @@
79623 ** all valid.
79624 */
79625 assert( p2<pC->nHdrParsed );
79626 assert( rc==SQLITE_OK );
79627 assert( sqlite3VdbeCheckMemInvariants(pDest) );
79628 if( VdbeMemDynamic(pDest) ){
79629 sqlite3VdbeMemSetNull(pDest);
79630 }
79631 assert( t==pC->aType[p2] );
 
79632 if( pC->szRow>=aOffset[p2+1] ){
79633 /* This is the common case where the desired content fits on the original
79634 ** page - where the content is not on an overflow page */
79635 zData = pC->aRow + aOffset[p2];
79636 if( t<12 ){
@@ -79264,10 +79640,11 @@
79640 ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent
79641 ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().
79642 */
79643 static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
79644 pDest->n = len = (t-12)/2;
79645 pDest->enc = encoding;
79646 if( pDest->szMalloc < len+2 ){
79647 pDest->flags = MEM_Null;
79648 if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
79649 }else{
79650 pDest->z = pDest->zMalloc;
@@ -79276,10 +79653,11 @@
79653 pDest->z[len] = 0;
79654 pDest->z[len+1] = 0;
79655 pDest->flags = aFlag[t&1];
79656 }
79657 }else{
79658 pDest->enc = encoding;
79659 /* This branch happens only when content is on overflow pages */
79660 if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
79661 && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))
79662 || (len = sqlite3VdbeSerialTypeLen(t))==0
79663 ){
@@ -80693,10 +81071,34 @@
81071 if( takeJump || !alreadyExists ) goto jump_to_p2;
81072 }
81073 break;
81074 }
81075
81076 /* Opcode: SeekRowid P1 P2 P3 * *
81077 ** Synopsis: intkey=r[P3]
81078 **
81079 ** P1 is the index of a cursor open on an SQL table btree (with integer
81080 ** keys). If register P3 does not contain an integer or if P1 does not
81081 ** contain a record with rowid P3 then jump immediately to P2.
81082 ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain
81083 ** a record with rowid P3 then
81084 ** leave the cursor pointing at that record and fall through to the next
81085 ** instruction.
81086 **
81087 ** The OP_NotExists opcode performs the same operation, but with OP_NotExists
81088 ** the P3 register must be guaranteed to contain an integer value. With this
81089 ** opcode, register P3 might not contain an integer.
81090 **
81091 ** The OP_NotFound opcode performs the same operation on index btrees
81092 ** (with arbitrary multi-value keys).
81093 **
81094 ** This opcode leaves the cursor in a state where it cannot be advanced
81095 ** in either direction. In other words, the Next and Prev opcodes will
81096 ** not work following this opcode.
81097 **
81098 ** See also: Found, NotFound, NoConflict, SeekRowid
81099 */
81100 /* Opcode: NotExists P1 P2 P3 * *
81101 ** Synopsis: intkey=r[P3]
81102 **
81103 ** P1 is the index of a cursor open on an SQL table btree (with integer
81104 ** keys). P3 is an integer rowid. If P1 does not contain a record with
@@ -80703,26 +81105,37 @@
81105 ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an
81106 ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then
81107 ** leave the cursor pointing at that record and fall through to the next
81108 ** instruction.
81109 **
81110 ** The OP_SeekRowid opcode performs the same operation but also allows the
81111 ** P3 register to contain a non-integer value, in which case the jump is
81112 ** always taken. This opcode requires that P3 always contain an integer.
81113 **
81114 ** The OP_NotFound opcode performs the same operation on index btrees
81115 ** (with arbitrary multi-value keys).
81116 **
81117 ** This opcode leaves the cursor in a state where it cannot be advanced
81118 ** in either direction. In other words, the Next and Prev opcodes will
81119 ** not work following this opcode.
81120 **
81121 ** See also: Found, NotFound, NoConflict, SeekRowid
81122 */
81123 case OP_SeekRowid: { /* jump, in3 */
81124 VdbeCursor *pC;
81125 BtCursor *pCrsr;
81126 int res;
81127 u64 iKey;
81128
81129 pIn3 = &aMem[pOp->p3];
81130 if( (pIn3->flags & MEM_Int)==0 ){
81131 applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
81132 if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;
81133 }
81134 /* Fall through into OP_NotExists */
81135 case OP_NotExists: /* jump, in3 */
81136 pIn3 = &aMem[pOp->p3];
81137 assert( pIn3->flags & MEM_Int );
81138 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
81139 pC = p->apCsr[pOp->p1];
81140 assert( pC!=0 );
81141 #ifdef SQLITE_DEBUG
@@ -80836,12 +81249,11 @@
81249 }
81250 if( res ){
81251 v = 1; /* IMP: R-61914-48074 */
81252 }else{
81253 assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );
81254 v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81255 if( v>=MAX_ROWID ){
81256 pC->useRandomRowid = 1;
81257 }else{
81258 v++; /* IMP: R-29538-34987 */
81259 }
@@ -80920,14 +81332,16 @@
81332 ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
81333 ** then rowid is stored for subsequent return by the
81334 ** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
81335 **
81336 ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
81337 ** the last seek operation (OP_NotExists or OP_SeekRowid) was a success,
81338 ** then this
81339 ** operation will not attempt to find the appropriate row before doing
81340 ** the insert but will instead overwrite the row that the cursor is
81341 ** currently pointing to. Presumably, the prior OP_NotExists or
81342 ** OP_SeekRowid opcode
81343 ** has already positioned the cursor correctly. This is an optimization
81344 ** that boosts performance by avoiding redundant seeks.
81345 **
81346 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
81347 ** UPDATE operation. Otherwise (if the flag is clear) then this opcode
@@ -80955,17 +81369,16 @@
81369 */
81370 case OP_Insert:
81371 case OP_InsertInt: {
81372 Mem *pData; /* MEM cell holding data for the record to be inserted */
81373 Mem *pKey; /* MEM cell holding key for the record */
 
81374 VdbeCursor *pC; /* Cursor to table into which insert is written */
 
81375 int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
81376 const char *zDb; /* database name - used by the update hook */
81377 Table *pTab; /* Table structure - used by update and pre-update hooks */
81378 int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
81379 BtreePayload x; /* Payload to be inserted */
81380
81381 op = 0;
81382 pData = &aMem[pOp->p2];
81383 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
81384 assert( memIsValid(pData) );
@@ -80980,14 +81393,14 @@
81393 if( pOp->opcode==OP_Insert ){
81394 pKey = &aMem[pOp->p3];
81395 assert( pKey->flags & MEM_Int );
81396 assert( memIsValid(pKey) );
81397 REGISTER_TRACE(pOp->p3, pKey);
81398 x.nKey = pKey->u.i;
81399 }else{
81400 assert( pOp->opcode==OP_InsertInt );
81401 x.nKey = pOp->p3;
81402 }
81403
81404 if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
81405 assert( pC->isTable );
81406 assert( pC->iDb>=0 );
@@ -81004,39 +81417,41 @@
81417 /* Invoke the pre-update hook, if any */
81418 if( db->xPreUpdateCallback
81419 && pOp->p4type==P4_TABLE
81420 && !(pOp->p5 & OPFLAG_ISUPDATE)
81421 ){
81422 sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);
81423 }
81424 #endif
81425
81426 if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
81427 if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey;
81428 if( pData->flags & MEM_Null ){
81429 x.pData = 0;
81430 x.nData = 0;
81431 }else{
81432 assert( pData->flags & (MEM_Blob|MEM_Str) );
81433 x.pData = pData->z;
81434 x.nData = pData->n;
81435 }
81436 seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);
81437 if( pData->flags & MEM_Zero ){
81438 x.nZero = pData->u.nZero;
81439 }else{
81440 x.nZero = 0;
81441 }
81442 x.pKey = 0;
81443 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
81444 (pOp->p5 & OPFLAG_APPEND)!=0, seekResult
81445 );
81446 pC->deferredMoveto = 0;
81447 pC->cacheStatus = CACHE_STALE;
81448
81449 /* Invoke the update-hook if required. */
81450 if( rc ) goto abort_due_to_error;
81451 if( db->xUpdateCallback && op ){
81452 db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);
81453 }
81454 break;
81455 }
81456
81457 /* Opcode: Delete P1 P2 P3 P4 P5
@@ -81091,12 +81506,11 @@
81506 #ifdef SQLITE_DEBUG
81507 if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
81508 /* If p5 is zero, the seek operation that positioned the cursor prior to
81509 ** OP_Delete will have also set the pC->movetoTarget field to the rowid of
81510 ** the row that is being deleted */
81511 i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81512 assert( pC->movetoTarget==iKey );
81513 }
81514 #endif
81515
81516 /* If the update-hook or pre-update-hook will be invoked, set zDb to
@@ -81108,11 +81522,11 @@
81522 assert( pC->iDb>=0 );
81523 assert( pOp->p4.pTab!=0 );
81524 zDb = db->aDb[pC->iDb].zName;
81525 pTab = pOp->p4.pTab;
81526 if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
81527 pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
81528 }
81529 }else{
81530 zDb = 0; /* Not needed. Silence a compiler warning. */
81531 pTab = 0; /* Not needed. Silence a compiler warning. */
81532 }
@@ -81262,11 +81676,10 @@
81676 case OP_RowKey:
81677 case OP_RowData: {
81678 VdbeCursor *pC;
81679 BtCursor *pCrsr;
81680 u32 n;
 
81681
81682 pOut = &aMem[pOp->p2];
81683 memAboutToChange(p, pOut);
81684
81685 /* Note that RowKey and RowData are really exactly the same instruction */
@@ -81280,12 +81693,13 @@
81693 assert( pC->nullRow==0 );
81694 assert( pC->uc.pCursor!=0 );
81695 pCrsr = pC->uc.pCursor;
81696
81697 /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
81698 ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions
81699 ** that might invalidate the cursor.
81700 ** If this where not the case, on of the following assert()s
81701 ** would fail. Should this ever change (because of changes in the code
81702 ** generator) then the fix would be to insert a call to
81703 ** sqlite3VdbeCursorMoveto().
81704 */
81705 assert( pC->deferredMoveto==0 );
@@ -81293,24 +81707,13 @@
81707 #if 0 /* Not required due to the previous to assert() statements */
81708 rc = sqlite3VdbeCursorMoveto(pC);
81709 if( rc!=SQLITE_OK ) goto abort_due_to_error;
81710 #endif
81711
81712 n = sqlite3BtreePayloadSize(pCrsr);
81713 if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81714 goto too_big;
 
 
 
 
 
 
 
 
 
 
 
81715 }
81716 testcase( n==0 );
81717 if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
81718 goto no_mem;
81719 }
@@ -81371,12 +81774,11 @@
81774 if( rc ) goto abort_due_to_error;
81775 if( pC->nullRow ){
81776 pOut->flags = MEM_Null;
81777 break;
81778 }
81779 v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81780 }
81781 pOut->u.i = v;
81782 break;
81783 }
81784
@@ -81647,12 +82049,11 @@
82049 ** for tables is OP_Insert.
82050 */
82051 case OP_SorterInsert: /* in2 */
82052 case OP_IdxInsert: { /* in2 */
82053 VdbeCursor *pC;
82054 BtreePayload x;
 
82055
82056 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
82057 pC = p->apCsr[pOp->p1];
82058 assert( pC!=0 );
82059 assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
@@ -81664,13 +82065,16 @@
82065 rc = ExpandBlob(pIn2);
82066 if( rc ) goto abort_due_to_error;
82067 if( pOp->opcode==OP_SorterInsert ){
82068 rc = sqlite3VdbeSorterWrite(pC, pIn2);
82069 }else{
82070 x.nKey = pIn2->n;
82071 x.pKey = pIn2->z;
82072 x.nData = 0;
82073 x.nZero = 0;
82074 x.pData = 0;
82075 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3,
82076 ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
82077 );
82078 assert( pC->deferredMoveto==0 );
82079 pC->cacheStatus = CACHE_STALE;
82080 }
@@ -83437,17 +83841,25 @@
83841 case OP_Init: { /* jump */
83842 char *zTrace;
83843 char *z;
83844
83845 #ifndef SQLITE_OMIT_TRACE
83846 if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
83847 && !p->doingRerun
83848 && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
83849 ){
83850 z = sqlite3VdbeExpandSql(p, zTrace);
83851 #ifndef SQLITE_OMIT_DEPRECATED
83852 if( db->mTrace & SQLITE_TRACE_LEGACY ){
83853 void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
83854 x(db->pTraceArg, z);
83855 }else
83856 #endif
83857 {
83858 (void)db->xTrace(SQLITE_TRACE_STMT,db->pTraceArg,p,z);
83859 }
83860 sqlite3_free(z);
83861 }
83862 #ifdef SQLITE_USE_FCNTL_TRACE
83863 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
83864 if( zTrace ){
83865 int i;
@@ -84026,11 +84438,11 @@
84438 ** slightly more efficient). Since you cannot write to a PK column
84439 ** using the incremental-blob API, this works. For the sessions module
84440 ** anyhow.
84441 */
84442 sqlite3_int64 iKey;
84443 iKey = sqlite3BtreeIntegerKey(p->pCsr);
84444 sqlite3VdbePreUpdateHook(
84445 v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
84446 );
84447 }
84448 #endif
@@ -85461,41 +85873,47 @@
85873 }
85874
85875
85876 /*
85877 ** Merge the two sorted lists p1 and p2 into a single list.
 
85878 */
85879 static SorterRecord *vdbeSorterMerge(
85880 SortSubtask *pTask, /* Calling thread context */
85881 SorterRecord *p1, /* First list to merge */
85882 SorterRecord *p2 /* Second list to merge */
 
85883 ){
85884 SorterRecord *pFinal = 0;
85885 SorterRecord **pp = &pFinal;
85886 int bCached = 0;
85887
85888 assert( p1!=0 && p2!=0 );
85889 for(;;){
85890 int res;
85891 res = pTask->xCompare(
85892 pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
85893 );
85894
85895 if( res<=0 ){
85896 *pp = p1;
85897 pp = &p1->u.pNext;
85898 p1 = p1->u.pNext;
85899 if( p1==0 ){
85900 *pp = p2;
85901 break;
85902 }
85903 }else{
85904 *pp = p2;
85905 pp = &p2->u.pNext;
85906 p2 = p2->u.pNext;
85907 bCached = 0;
85908 if( p2==0 ){
85909 *pp = p1;
85910 break;
85911 }
85912 }
85913 }
85914 return pFinal;
 
85915 }
85916
85917 /*
85918 ** Return the SorterCompare function to compare values collected by the
85919 ** sorter object passed as the only argument.
@@ -85544,20 +85962,21 @@
85962 pNext = p->u.pNext;
85963 }
85964
85965 p->u.pNext = 0;
85966 for(i=0; aSlot[i]; i++){
85967 p = vdbeSorterMerge(pTask, p, aSlot[i]);
85968 aSlot[i] = 0;
85969 }
85970 aSlot[i] = p;
85971 p = pNext;
85972 }
85973
85974 p = 0;
85975 for(i=0; i<64; i++){
85976 if( aSlot[i]==0 ) continue;
85977 p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
85978 }
85979 pList->pList = p;
85980
85981 sqlite3_free(aSlot);
85982 assert( pTask->pUnpacked->errCode==SQLITE_OK
@@ -90773,10 +91192,15 @@
91192 VdbeComment((v, "%s", pIdx->zName));
91193 assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91194 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91195
91196 if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91197 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91198 const i64 sOne = 1;
91199 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91200 iTab, 0, 0, (u8*)&sOne, P4_INT64);
91201 #endif
91202 *prRhsHasNull = ++pParse->nMem;
91203 sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91204 }
91205 sqlite3VdbeJumpHere(v, iAddr);
91206 }
@@ -90785,11 +91209,11 @@
91209 }
91210
91211 /* If no preexisting index is available for the IN clause
91212 ** and IN_INDEX_NOOP is an allowed reply
91213 ** and the RHS of the IN operator is a list, not a subquery
91214 ** and the RHS is not constant or has two or fewer terms,
91215 ** then it is not worth creating an ephemeral table to evaluate
91216 ** the IN operator so return IN_INDEX_NOOP.
91217 */
91218 if( eType==0
91219 && (inFlags & IN_INDEX_NOOP_OK)
@@ -91177,12 +91601,11 @@
91601 }
91602
91603 if( eType==IN_INDEX_ROWID ){
91604 /* In this case, the RHS is the ROWID of table b-tree
91605 */
91606 sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
 
91607 VdbeCoverage(v);
91608 }else{
91609 /* In this case, the RHS is an index b-tree.
91610 */
91611 sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
@@ -91491,11 +91914,11 @@
91914 if( iCol<0 || iCol==pTab->iPKey ){
91915 sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
91916 }else{
91917 int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
91918 int x = iCol;
91919 if( !HasRowid(pTab) && !IsVirtual(pTab) ){
91920 x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
91921 }
91922 sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
91923 }
91924 if( iCol>=0 ){
@@ -93870,10 +94293,11 @@
94293 char *zCol; /* Null-terminated column definition */
94294 Column *pCol; /* The new column */
94295 Expr *pDflt; /* Default value for the new column */
94296 sqlite3 *db; /* The database connection; */
94297 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
94298 int r1; /* Temporary registers */
94299
94300 db = pParse->db;
94301 if( pParse->nErr || db->mallocFailed ) return;
94302 assert( v!=0 );
94303 pNew = pParse->pNewTable;
@@ -93964,20 +94388,22 @@
94388 );
94389 sqlite3DbFree(db, zCol);
94390 db->flags = savedDbFlags;
94391 }
94392
94393 /* Make sure the schema version is at least 3. But do not upgrade
94394 ** from less than 3 to 4, as that will corrupt any preexisting DESC
94395 ** index.
 
 
 
 
94396 */
94397 r1 = sqlite3GetTempReg(pParse);
94398 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
94399 sqlite3VdbeUsesBtree(v, iDb);
94400 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
94401 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
94402 VdbeCoverage(v);
94403 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
94404 sqlite3ReleaseTempReg(pParse, r1);
94405
94406 /* Reload the schema of the modified table. */
94407 reloadTableSchema(pParse, pTab, pTab->zName);
94408 }
94409
@@ -97152,11 +97578,11 @@
97578 ** routine leaves an error message in pParse->zErrMsg where
97579 ** sqlite3FindTable() does not.
97580 */
97581 SQLITE_PRIVATE Table *sqlite3LocateTable(
97582 Parse *pParse, /* context in which to report errors */
97583 u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */
97584 const char *zName, /* Name of the table we are looking for */
97585 const char *zDbase /* Name of the database. Might be NULL */
97586 ){
97587 Table *p;
97588
@@ -97166,11 +97592,11 @@
97592 return 0;
97593 }
97594
97595 p = sqlite3FindTable(pParse->db, zName, zDbase);
97596 if( p==0 ){
97597 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
97598 #ifndef SQLITE_OMIT_VIRTUALTABLE
97599 if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
97600 /* If zName is the not the name of a table in the schema created using
97601 ** CREATE, then check to see if it is the name of an virtual table that
97602 ** can be an eponymous virtual table. */
@@ -97178,16 +97604,18 @@
97604 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
97605 return pMod->pEpoTab;
97606 }
97607 }
97608 #endif
97609 if( (flags & LOCATE_NOERR)==0 ){
97610 if( zDbase ){
97611 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97612 }else{
97613 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97614 }
97615 pParse->checkSchema = 1;
97616 }
 
97617 }
97618
97619 return p;
97620 }
97621
@@ -97200,11 +97628,11 @@
97628 ** non-NULL if it is part of a view or trigger program definition. See
97629 ** sqlite3FixSrcList() for details.
97630 */
97631 SQLITE_PRIVATE Table *sqlite3LocateTableItem(
97632 Parse *pParse,
97633 u32 flags,
97634 struct SrcList_item *p
97635 ){
97636 const char *zDb;
97637 assert( p->pSchema==0 || p->zDatabase==0 );
97638 if( p->pSchema ){
@@ -97211,11 +97639,11 @@
97639 int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
97640 zDb = pParse->db->aDb[iDb].zName;
97641 }else{
97642 zDb = p->zDatabase;
97643 }
97644 return sqlite3LocateTable(pParse, flags, p->zName, zDb);
97645 }
97646
97647 /*
97648 ** Locate the in-memory structure that describes
97649 ** a particular index given the name of that index
@@ -97419,12 +97847,13 @@
97847 db->lookaside.nOut : 0 );
97848
97849 /* Delete all indices associated with this table. */
97850 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
97851 pNext = pIndex->pNext;
97852 assert( pIndex->pSchema==pTable->pSchema
97853 || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );
97854 if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
97855 char *zName = pIndex->zName;
97856 TESTONLY ( Index *pOld = ) sqlite3HashInsert(
97857 &pIndex->pSchema->idxHash, zName, 0
97858 );
97859 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
@@ -98102,11 +98531,11 @@
98531 ){
98532 Table *pTab = pParse->pNewTable;
98533 Column *pCol = 0;
98534 int iCol = -1, i;
98535 int nTerm;
98536 if( pTab==0 ) goto primary_key_exit;
98537 if( pTab->tabFlags & TF_HasPrimaryKey ){
98538 sqlite3ErrorMsg(pParse,
98539 "table \"%s\" has more than one primary key", pTab->zName);
98540 goto primary_key_exit;
98541 }
@@ -98148,16 +98577,12 @@
98577 #ifndef SQLITE_OMIT_AUTOINCREMENT
98578 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
98579 "INTEGER PRIMARY KEY");
98580 #endif
98581 }else{
98582 sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98583 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);
 
 
 
 
98584 pList = 0;
98585 }
98586
98587 primary_key_exit:
98588 sqlite3ExprListDelete(pParse->db, pList);
@@ -98470,33 +98895,49 @@
98895 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
98896 ** internal schema data structures and the generated VDBE code so that they
98897 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
98898 ** Changes include:
98899 **
98900 ** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
98901 ** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is
98902 ** no rowid btree for a WITHOUT ROWID. Instead, the canonical
98903 ** data storage is a covering index btree.
98904 ** (3) Bypass the creation of the sqlite_master table entry
98905 ** for the PRIMARY KEY as the primary key index is now
98906 ** identified by the sqlite_master table entry of the table itself.
98907 ** (4) Set the Index.tnum of the PRIMARY KEY Index object in the
98908 ** schema to the rootpage from the main table.
 
98909 ** (5) Add all table columns to the PRIMARY KEY Index object
98910 ** so that the PRIMARY KEY is a covering index. The surplus
98911 ** columns are part of KeyInfo.nXField and are not used for
98912 ** sorting or lookup or uniqueness checks.
98913 ** (6) Replace the rowid tail on all automatically generated UNIQUE
98914 ** indices with the PRIMARY KEY columns.
98915 **
98916 ** For virtual tables, only (1) is performed.
98917 */
98918 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
98919 Index *pIdx;
98920 Index *pPk;
98921 int nPk;
98922 int i, j;
98923 sqlite3 *db = pParse->db;
98924 Vdbe *v = pParse->pVdbe;
98925
98926 /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
98927 */
98928 if( !db->init.imposterTable ){
98929 for(i=0; i<pTab->nCol; i++){
98930 if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
98931 pTab->aCol[i].notNull = OE_Abort;
98932 }
98933 }
98934 }
98935
98936 /* The remaining transformations only apply to b-tree tables, not to
98937 ** virtual tables */
98938 if( IN_DECLARE_VTAB ) return;
98939
98940 /* Convert the OP_CreateTable opcode that would normally create the
98941 ** root-page for the table into an OP_CreateIndex opcode. The index
98942 ** created will become the PRIMARY KEY index.
98943 */
@@ -98515,13 +98956,14 @@
98956 pList = sqlite3ExprListAppend(pParse, 0,
98957 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
98958 if( pList==0 ) return;
98959 pList->a[0].sortOrder = pParse->iPkSortOrder;
98960 assert( pParse->pNewTable==pTab );
98961 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
98962 SQLITE_IDXTYPE_PRIMARYKEY);
98963 if( db->mallocFailed ) return;
98964 pPk = sqlite3PrimaryKeyIndex(pTab);
98965 pTab->iPKey = -1;
98966 }else{
98967 pPk = sqlite3PrimaryKeyIndex(pTab);
98968
98969 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
@@ -98545,23 +98987,15 @@
98987 pPk->aiColumn[j++] = pPk->aiColumn[i];
98988 }
98989 }
98990 pPk->nKeyCol = j;
98991 }
 
98992 assert( pPk!=0 );
98993 pPk->isCovering = 1;
98994 if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
98995 nPk = pPk->nKeyCol;
98996
 
 
 
 
 
 
 
 
 
98997 /* The root page of the PRIMARY KEY is the table root page */
98998 pPk->tnum = pTab->tnum;
98999
99000 /* Update the in-memory representation of all UNIQUE indices by converting
99001 ** the final rowid column into one or more columns of the PRIMARY KEY.
@@ -99312,10 +99746,11 @@
99746 }
99747 assert( pParse->nErr==0 );
99748 assert( pName->nSrc==1 );
99749 if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
99750 if( noErr ) db->suppressErr++;
99751 assert( isView==0 || isView==LOCATE_VIEW );
99752 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
99753 if( noErr ) db->suppressErr--;
99754
99755 if( pTab==0 ){
99756 if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
@@ -99682,28 +100117,24 @@
100117 ** currently being constructed by a CREATE TABLE statement.
100118 **
100119 ** pList is a list of columns to be indexed. pList will be NULL if this
100120 ** is a primary key or unique-constraint on the most recent column added
100121 ** to the table currently under construction.
 
 
 
 
100122 */
100123 SQLITE_PRIVATE void sqlite3CreateIndex(
100124 Parse *pParse, /* All information about this parse */
100125 Token *pName1, /* First part of index name. May be NULL */
100126 Token *pName2, /* Second part of index name. May be NULL */
100127 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
100128 ExprList *pList, /* A list of columns to be indexed */
100129 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
100130 Token *pStart, /* The CREATE token that begins this statement */
100131 Expr *pPIWhere, /* WHERE clause for partial indices */
100132 int sortOrder, /* Sort order of primary key when pList==NULL */
100133 int ifNotExist, /* Omit error if index already exists */
100134 u8 idxType /* The index type */
100135 ){
 
100136 Table *pTab = 0; /* Table to be indexed */
100137 Index *pIndex = 0; /* The index to be created */
100138 char *zName = 0; /* Name of the index */
100139 int nName; /* Number of characters in zName */
100140 int i, j;
@@ -99717,11 +100148,14 @@
100148 int nExtra = 0; /* Space allocated for zExtra[] */
100149 int nExtraCol; /* Number of extra columns needed */
100150 char *zExtra = 0; /* Extra space after the Index object */
100151 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
100152
100153 if( db->mallocFailed || pParse->nErr>0 ){
100154 goto exit_create_index;
100155 }
100156 if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
100157 goto exit_create_index;
100158 }
100159 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
100160 goto exit_create_index;
100161 }
@@ -99906,11 +100340,11 @@
100340 zExtra += nName + 1;
100341 memcpy(pIndex->zName, zName, nName+1);
100342 pIndex->pTable = pTab;
100343 pIndex->onError = (u8)onError;
100344 pIndex->uniqNotNull = onError!=OE_None;
100345 pIndex->idxType = idxType;
100346 pIndex->pSchema = db->aDb[iDb].pSchema;
100347 pIndex->nKeyCol = pList->nExpr;
100348 if( pPIWhere ){
100349 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
100350 pIndex->pPartIdxWhere = pPIWhere;
@@ -100086,11 +100520,11 @@
100520 }
100521 if( pIdx->onError==OE_Default ){
100522 pIdx->onError = pIndex->onError;
100523 }
100524 }
100525 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
100526 goto exit_create_index;
100527 }
100528 }
100529 }
100530
@@ -100098,10 +100532,11 @@
100532 ** in-memory database structures.
100533 */
100534 assert( pParse->nErr==0 );
100535 if( db->init.busy ){
100536 Index *p;
100537 assert( !IN_DECLARE_VTAB );
100538 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
100539 p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
100540 pIndex->zName, pIndex);
100541 if( p ){
100542 assert( p==pIndex ); /* Malloc must have failed */
@@ -100179,11 +100614,11 @@
100614 if( pTblName ){
100615 sqlite3RefillIndex(pParse, pIndex, iMem);
100616 sqlite3ChangeCookie(pParse, iDb);
100617 sqlite3VdbeAddParseSchemaOp(v, iDb,
100618 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
100619 sqlite3VdbeAddOp0(v, OP_Expire);
100620 }
100621
100622 sqlite3VdbeJumpHere(v, pIndex->tnum);
100623 }
100624
@@ -100204,11 +100639,10 @@
100639 pOther = pOther->pNext;
100640 }
100641 pIndex->pNext = pOther->pNext;
100642 pOther->pNext = pIndex;
100643 }
 
100644 pIndex = 0;
100645 }
100646
100647 /* Clean up before exiting */
100648 exit_create_index:
@@ -100215,11 +100649,10 @@
100649 if( pIndex ) freeIndex(db, pIndex);
100650 sqlite3ExprDelete(db, pPIWhere);
100651 sqlite3ExprListDelete(db, pList);
100652 sqlite3SrcListDelete(db, pTblName);
100653 sqlite3DbFree(db, zName);
 
100654 }
100655
100656 /*
100657 ** Fill the Index.aiRowEst[] array with default information - information
100658 ** to be used when we have not run the ANALYZE command.
@@ -100244,14 +100677,15 @@
100677 LogEst *a = pIdx->aiRowLogEst;
100678 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
100679 int i;
100680
100681 /* Set the first entry (number of rows in the index) to the estimated
100682 ** number of rows in the table, or half the number of rows in the table
100683 ** for a partial index. But do not let the estimate drop below 10. */
100684 a[0] = pIdx->pTable->nRowLogEst;
100685 if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
100686 if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100687
100688 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
100689 ** 6 and each subsequent value (if any) is 5. */
100690 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
100691 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
@@ -101129,14 +101563,10 @@
101563 #endif
101564
101565 /*
101566 ** Return a KeyInfo structure that is appropriate for the given Index.
101567 **
 
 
 
 
101568 ** The caller should invoke sqlite3KeyInfoUnref() on the returned object
101569 ** when it has finished using it.
101570 */
101571 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
101572 int i;
@@ -103364,11 +103794,11 @@
103794 continue;
103795 }
103796 }
103797 c2 = Utf8Read(zString);
103798 if( c==c2 ) continue;
103799 if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){
103800 continue;
103801 }
103802 if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
103803 return 0;
103804 }
@@ -105823,11 +106253,12 @@
106253 */
106254 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
106255 FKey *pFKey; /* Iterator variable */
106256 FKey *pNext; /* Copy of pFKey->pNextFrom */
106257
106258 assert( db==0 || IsVirtual(pTab)
106259 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
106260 for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
106261
106262 /* Remove the FK from the fkeyHash hash table. */
106263 if( !db || db->pnBytesFreed==0 ){
106264 if( pFKey->pPrevTo ){
@@ -108233,12 +108664,12 @@
108664 ** shared libraries that want to be imported as extensions into
108665 ** an SQLite instance. Shared libraries that intend to be loaded
108666 ** as extensions by SQLite should #include this file instead of
108667 ** sqlite3.h.
108668 */
108669 #ifndef SQLITE3EXT_H
108670 #define SQLITE3EXT_H
108671 /* #include "sqlite3.h" */
108672
108673 typedef struct sqlite3_api_routines sqlite3_api_routines;
108674
108675 /*
@@ -108499,10 +108930,13 @@
108930 int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
108931 int (*strlike)(const char*,const char*,unsigned int);
108932 int (*db_cacheflush)(sqlite3*);
108933 /* Version 3.12.0 and later */
108934 int (*system_errno)(sqlite3*);
108935 /* Version 3.14.0 and later */
108936 int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
108937 char *(*expanded_sql)(sqlite3_stmt*);
108938 };
108939
108940 /*
108941 ** The following macros redefine the API routines so that they are
108942 ** redirected through the global sqlite3_api structure.
@@ -108744,10 +109178,13 @@
109178 #define sqlite3_status64 sqlite3_api->status64
109179 #define sqlite3_strlike sqlite3_api->strlike
109180 #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
109181 /* Version 3.12.0 and later */
109182 #define sqlite3_system_errno sqlite3_api->system_errno
109183 /* Version 3.14.0 and later */
109184 #define sqlite3_trace_v2 sqlite3_api->trace_v2
109185 #define sqlite3_expanded_sql sqlite3_api->expanded_sql
109186 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
109187
109188 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
109189 /* This case when the file really is being compiled as a loadable
109190 ** extension */
@@ -108761,11 +109198,11 @@
109198 # define SQLITE_EXTENSION_INIT1 /*no-op*/
109199 # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
109200 # define SQLITE_EXTENSION_INIT3 /*no-op*/
109201 #endif
109202
109203 #endif /* SQLITE3EXT_H */
109204
109205 /************** End of sqlite3ext.h ******************************************/
109206 /************** Continuing where we left off in loadext.c ********************/
109207 /* #include "sqliteInt.h" */
109208 /* #include <string.h> */
@@ -109194,10 +109631,11 @@
109631 const char *zEntry;
109632 char *zAltEntry = 0;
109633 void **aHandle;
109634 u64 nMsg = 300 + sqlite3Strlen30(zFile);
109635 int ii;
109636 int rc;
109637
109638 /* Shared library endings to try if zFile cannot be loaded as written */
109639 static const char *azEndings[] = {
109640 #if SQLITE_OS_WIN
109641 "dll"
@@ -109296,11 +109734,13 @@
109734 sqlite3OsDlClose(pVfs, handle);
109735 sqlite3_free(zAltEntry);
109736 return SQLITE_ERROR;
109737 }
109738 sqlite3_free(zAltEntry);
109739 rc = xInit(db, &zErrmsg, &sqlite3Apis);
109740 if( rc ){
109741 if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
109742 if( pzErrMsg ){
109743 *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
109744 }
109745 sqlite3_free(zErrmsg);
109746 sqlite3OsDlClose(pVfs, handle);
@@ -111034,11 +111474,11 @@
111474
111475 /* Many of the flag-pragmas modify the code generated by the SQL
111476 ** compiler (eg. count_changes). So add an opcode to expire all
111477 ** compiled SQL statements after modifying a pragma value.
111478 */
111479 sqlite3VdbeAddOp0(v, OP_Expire);
111480 setAllPagerFlags(db);
111481 }
111482 break;
111483 }
111484 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -111056,11 +111496,11 @@
111496 ** notnull: True if 'NOT NULL' is part of column declaration
111497 ** dflt_value: The default value for the column, if any.
111498 */
111499 case PragTyp_TABLE_INFO: if( zRight ){
111500 Table *pTab;
111501 pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
111502 if( pTab ){
111503 static const char *azCol[] = {
111504 "cid", "name", "type", "notnull", "dflt_value", "pk"
111505 };
111506 int i, k;
@@ -111338,16 +111778,14 @@
111778 assert( iKey>=0 && iKey<pTab->nCol );
111779 if( iKey!=pTab->iPKey ){
111780 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
111781 sqlite3ColumnDefault(v, pTab, iKey, regRow);
111782 sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v);
 
 
111783 }else{
111784 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
111785 }
111786 sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v);
111787 sqlite3VdbeGoto(v, addrOk);
111788 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
111789 }else{
111790 for(j=0; j<pFK->nCol; j++){
111791 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
@@ -112914,10 +113352,11 @@
113352 int regReturn; /* Register holding block-output return address */
113353 int labelBkOut; /* Start label for the block-output subroutine */
113354 int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
113355 int labelDone; /* Jump here when done, ex: LIMIT reached */
113356 u8 sortFlags; /* Zero or more SORTFLAG_* bits */
113357 u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
113358 };
113359 #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
113360
113361 /*
113362 ** Delete all the content of a Select structure. Deallocate the structure
@@ -113447,13 +113886,34 @@
113886 op = OP_IdxInsert;
113887 }
113888 sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
113889 if( iLimit ){
113890 int addr;
113891 int r1 = 0;
113892 /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit
113893 ** register is initialized with value of LIMIT+OFFSET.) After the sorter
113894 ** fills up, delete the least entry in the sorter after each insert.
113895 ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
113896 addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
113897 sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
113898 if( pSort->bOrderedInnerLoop ){
113899 r1 = ++pParse->nMem;
113900 sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
113901 VdbeComment((v, "seq"));
113902 }
113903 sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
113904 if( pSort->bOrderedInnerLoop ){
113905 /* If the inner loop is driven by an index such that values from
113906 ** the same iteration of the inner loop are in sorted order, then
113907 ** immediately jump to the next iteration of an inner loop if the
113908 ** entry from the current iteration does not fit into the top
113909 ** LIMIT+OFFSET entries of the sorter. */
113910 int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
113911 sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
113912 sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
113913 VdbeCoverage(v);
113914 }
113915 sqlite3VdbeJumpHere(v, addr);
113916 }
113917 }
113918
113919 /*
@@ -113864,11 +114324,11 @@
114324 ** Allocate a KeyInfo object sufficient for an index of N key columns and
114325 ** X extra columns.
114326 */
114327 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
114328 int nExtra = (N+X)*(sizeof(CollSeq*)+1);
114329 KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra);
114330 if( p ){
114331 p->aSortOrder = (u8*)&p->aColl[N+X];
114332 p->nField = (u16)N;
114333 p->nXField = (u16)X;
114334 p->enc = ENC(db);
@@ -113886,11 +114346,11 @@
114346 */
114347 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){
114348 if( p ){
114349 assert( p->nRef>0 );
114350 p->nRef--;
114351 if( p->nRef==0 ) sqlite3DbFree(p->db, p);
114352 }
114353 }
114354
114355 /*
114356 ** Make a new pointer to a KeyInfo object
@@ -118034,10 +118494,11 @@
118494 if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
118495 sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
118496 }
118497 if( sSort.pOrderBy ){
118498 sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
118499 sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
118500 if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
118501 sSort.pOrderBy = 0;
118502 }
118503 }
118504
@@ -120803,11 +121264,11 @@
121264 Btree *pTemp; /* The temporary database we vacuum into */
121265 char *zSql = 0; /* SQL statements */
121266 int saved_flags; /* Saved value of the db->flags */
121267 int saved_nChange; /* Saved value of db->nChange */
121268 int saved_nTotalChange; /* Saved value of db->nTotalChange */
121269 u8 saved_mTrace; /* Saved trace settings */
121270 Db *pDb = 0; /* Database to detach at end of vacuum */
121271 int isMemDb; /* True if vacuuming a :memory: database */
121272 int nRes; /* Bytes of reserved space at the end of each page */
121273 int nDb; /* Number of attached databases */
121274
@@ -120824,14 +121285,14 @@
121285 ** restored before returning. Then set the writable-schema flag, and
121286 ** disable CHECK and foreign key constraints. */
121287 saved_flags = db->flags;
121288 saved_nChange = db->nChange;
121289 saved_nTotalChange = db->nTotalChange;
121290 saved_mTrace = db->mTrace;
121291 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
121292 db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
121293 db->mTrace = 0;
121294
121295 pMain = db->aDb[0].pBt;
121296 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
121297
121298 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -121027,11 +121488,11 @@
121488 end_of_vacuum:
121489 /* Restore the original value of db->flags */
121490 db->flags = saved_flags;
121491 db->nChange = saved_nChange;
121492 db->nTotalChange = saved_nTotalChange;
121493 db->mTrace = saved_mTrace;
121494 sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
121495
121496 /* Currently there is an SQL level transaction open on the vacuum
121497 ** database. No locks are held on any other files (since the main file
121498 ** was committed at the btree level). So it safe to end the transaction
@@ -121476,11 +121937,11 @@
121937 );
121938 sqlite3DbFree(db, zStmt);
121939 v = sqlite3GetVdbe(pParse);
121940 sqlite3ChangeCookie(pParse, iDb);
121941
121942 sqlite3VdbeAddOp0(v, OP_Expire);
121943 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
121944 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
121945
121946 iReg = ++pParse->nMem;
121947 sqlite3VdbeLoadString(v, iReg, pTab->zName);
@@ -121812,14 +122273,28 @@
122273 && !db->mallocFailed
122274 && !pParse->pNewTable->pSelect
122275 && (pParse->pNewTable->tabFlags & TF_Virtual)==0
122276 ){
122277 if( !pTab->aCol ){
122278 Table *pNew = pParse->pNewTable;
122279 Index *pIdx;
122280 pTab->aCol = pNew->aCol;
122281 pTab->nCol = pNew->nCol;
122282 pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
122283 pNew->nCol = 0;
122284 pNew->aCol = 0;
122285 assert( pTab->pIndex==0 );
122286 if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){
122287 rc = SQLITE_ERROR;
122288 }
122289 pIdx = pNew->pIndex;
122290 if( pIdx ){
122291 assert( pIdx->pNext==0 );
122292 pTab->pIndex = pIdx;
122293 pNew->pIndex = 0;
122294 pIdx->pTable = pTab;
122295 }
122296 }
122297 pCtx->bDeclared = 1;
122298 }else{
122299 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
122300 sqlite3DbFree(db, zErr);
@@ -122145,11 +122620,11 @@
122620 sqlite3OomFault(pToplevel->db);
122621 }
122622 }
122623
122624 /*
122625 ** Check to see if virtual table module pMod can be have an eponymous
122626 ** virtual table instance. If it can, create one if one does not already
122627 ** exist. Return non-zero if the eponymous virtual table instance exists
122628 ** when this routine returns, and return zero if it does not exist.
122629 **
122630 ** An eponymous virtual table instance is one that is named after its
@@ -122162,21 +122637,22 @@
122637 */
122638 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
122639 const sqlite3_module *pModule = pMod->pModule;
122640 Table *pTab;
122641 char *zErr = 0;
 
122642 int rc;
122643 sqlite3 *db = pParse->db;
122644 if( pMod->pEpoTab ) return 1;
122645 if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;
122646 pTab = sqlite3DbMallocZero(db, sizeof(Table));
 
122647 if( pTab==0 ) return 0;
122648 pTab->zName = sqlite3DbStrDup(db, pMod->zName);
122649 if( pTab->zName==0 ){
122650 sqlite3DbFree(db, pTab);
122651 return 0;
122652 }
122653 pMod->pEpoTab = pTab;
 
 
122654 pTab->nRef = 1;
122655 pTab->pSchema = db->aDb[0].pSchema;
122656 pTab->tabFlags |= TF_Virtual;
122657 pTab->nModuleArg = 0;
122658 pTab->iPKey = -1;
@@ -122198,13 +122674,15 @@
122674 ** virtual table module pMod, if it exists.
122675 */
122676 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){
122677 Table *pTab = pMod->pEpoTab;
122678 if( pTab!=0 ){
122679 /* Mark the table as Ephemeral prior to deleting it, so that the
122680 ** sqlite3DeleteTable() routine will know that it is not stored in
122681 ** the schema. */
122682 pTab->tabFlags |= TF_Ephemeral;
122683 sqlite3DeleteTable(db, pTab);
122684 pMod->pEpoTab = 0;
122685 }
122686 }
122687
122688 /*
@@ -122707,12 +123185,13 @@
123185 u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
123186 i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
123187 u8 sorted; /* True if really sorted (not just grouped) */
123188 u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
123189 u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
123190 u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
123191 u8 nLevel; /* Number of nested loop */
123192 u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */
123193 int iTop; /* The very beginning of the WHERE loop */
123194 int iContinue; /* Jump here to continue with next record */
123195 int iBreak; /* Jump here to break out of the loop */
123196 int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
123197 int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
@@ -122725,10 +123204,13 @@
123204 ** Private interfaces - callable only by other where.c routines.
123205 **
123206 ** where.c:
123207 */
123208 SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
123209 #ifdef WHERETRACE_ENABLED
123210 SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);
123211 #endif
123212 SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(
123213 WhereClause *pWC, /* The WHERE clause to be searched */
123214 int iCur, /* Cursor number of LHS */
123215 int iColumn, /* Column number of LHS */
123216 Bitmask notReady, /* RHS must not overlap with this mask */
@@ -122941,11 +123423,11 @@
123423 StrAccum str; /* EQP output string */
123424 char zBuf[100]; /* Initial space for EQP output string */
123425
123426 pLoop = pLevel->pWLoop;
123427 flags = pLoop->wsFlags;
123428 if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;
123429
123430 isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
123431 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
123432 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
123433
@@ -123384,11 +123866,11 @@
123866 **
123867 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
123868 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
123869 ** scan loop run twice, once for strings and a second time for BLOBs.
123870 ** The OP_String opcodes on the second pass convert the upper and lower
123871 ** bound string constants to blobs. This routine makes the necessary changes
123872 ** to the OP_String opcodes for that to happen.
123873 **
123874 ** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then
123875 ** only the one pass through the string space is required, so this routine
123876 ** becomes a no-op.
@@ -123441,10 +123923,42 @@
123923 pWalker->eCode = 1;
123924 }
123925 return WRC_Continue;
123926 }
123927
123928 /*
123929 ** Test whether or not expression pExpr, which was part of a WHERE clause,
123930 ** should be included in the cursor-hint for a table that is on the rhs
123931 ** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the
123932 ** expression is not suitable.
123933 **
123934 ** An expression is unsuitable if it might evaluate to non NULL even if
123935 ** a TK_COLUMN node that does affect the value of the expression is set
123936 ** to NULL. For example:
123937 **
123938 ** col IS NULL
123939 ** col IS NOT NULL
123940 ** coalesce(col, 1)
123941 ** CASE WHEN col THEN 0 ELSE 1 END
123942 */
123943 static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
123944 if( pExpr->op==TK_IS
123945 || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT
123946 || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE
123947 ){
123948 pWalker->eCode = 1;
123949 }else if( pExpr->op==TK_FUNCTION ){
123950 int d1;
123951 char d2[3];
123952 if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){
123953 pWalker->eCode = 1;
123954 }
123955 }
123956
123957 return WRC_Continue;
123958 }
123959
123960
123961 /*
123962 ** This function is called on every node of an expression tree used as an
123963 ** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN
123964 ** that accesses any table other than the one identified by
@@ -123493,10 +124007,11 @@
124007
124008 /*
124009 ** Insert an OP_CursorHint instruction if it is appropriate to do so.
124010 */
124011 static void codeCursorHint(
124012 struct SrcList_item *pTabItem, /* FROM clause item */
124013 WhereInfo *pWInfo, /* The where clause */
124014 WhereLevel *pLevel, /* Which loop to provide hints for */
124015 WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
124016 ){
124017 Parse *pParse = pWInfo->pParse;
@@ -123523,11 +124038,46 @@
124038 pWC = &pWInfo->sWC;
124039 for(i=0; i<pWC->nTerm; i++){
124040 pTerm = &pWC->a[i];
124041 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
124042 if( pTerm->prereqAll & pLevel->notReady ) continue;
124043
124044 /* Any terms specified as part of the ON(...) clause for any LEFT
124045 ** JOIN for which the current table is not the rhs are omitted
124046 ** from the cursor-hint.
124047 **
124048 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
124049 ** that were specified as part of the WHERE clause must be excluded.
124050 ** This is to address the following:
124051 **
124052 ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;
124053 **
124054 ** Say there is a single row in t2 that matches (t1.a=t2.b), but its
124055 ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is
124056 ** pushed down to the cursor, this row is filtered out, causing
124057 ** SQLite to synthesize a row of NULL values. Which does match the
124058 ** WHERE clause, and so the query returns a row. Which is incorrect.
124059 **
124060 ** For the same reason, WHERE terms such as:
124061 **
124062 ** WHERE 1 = (t2.c IS NULL)
124063 **
124064 ** are also excluded. See codeCursorHintIsOrFunction() for details.
124065 */
124066 if( pTabItem->fg.jointype & JT_LEFT ){
124067 Expr *pExpr = pTerm->pExpr;
124068 if( !ExprHasProperty(pExpr, EP_FromJoin)
124069 || pExpr->iRightJoinTable!=pTabItem->iCursor
124070 ){
124071 sWalker.eCode = 0;
124072 sWalker.xExprCallback = codeCursorHintIsOrFunction;
124073 sqlite3WalkExpr(&sWalker, pTerm->pExpr);
124074 if( sWalker.eCode ) continue;
124075 }
124076 }else{
124077 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124078 }
124079
124080 /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize
124081 ** the cursor. These terms are not needed as hints for a pure range
124082 ** scan (that has no == terms) so omit them. */
124083 if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
@@ -123557,11 +124107,11 @@
124107 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
124108 (const char*)pExpr, P4_EXPR);
124109 }
124110 }
124111 #else
124112 # define codeCursorHint(A,B,C,D) /* No-op */
124113 #endif /* SQLITE_ENABLE_CURSOR_HINTS */
124114
124115 /*
124116 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
124117 ** a rowid value just read from cursor iIdxCur, open on index pIdx. This
@@ -123591,11 +124141,11 @@
124141
124142 assert( iIdxCur>0 );
124143 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
124144
124145 sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
124146 if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
124147 && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
124148 ){
124149 int i;
124150 Table *pTab = pIdx->pTable;
124151 int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
@@ -123646,11 +124196,11 @@
124196 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
124197 iCur = pTabItem->iCursor;
124198 pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
124199 bRev = (pWInfo->revMask>>iLevel)&1;
124200 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
124201 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
124202 VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
124203
124204 /* Create labels for the "break" and "continue" instructions
124205 ** for the current loop. Jump to addrBrk to break out of a loop.
124206 ** Jump to cont to go immediately to the next iteration of the
@@ -123786,12 +124336,11 @@
124336 testcase( pTerm->wtFlags & TERM_VIRTUAL );
124337 iReleaseReg = ++pParse->nMem;
124338 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
124339 if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
124340 addrNxt = pLevel->addrNxt;
124341 sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
 
124342 VdbeCoverage(v);
124343 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
124344 sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
124345 VdbeComment((v, "pk"));
124346 pLevel->op = OP_Noop;
@@ -123814,11 +124363,11 @@
124363 if( bRev ){
124364 pTerm = pStart;
124365 pStart = pEnd;
124366 pEnd = pTerm;
124367 }
124368 codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
124369 if( pStart ){
124370 Expr *pX; /* The expression that defines the start bound */
124371 int r1, rTemp; /* Registers for holding the start boundary */
124372
124373 /* The following constant maps TK_xx codes into corresponding
@@ -124028,11 +124577,11 @@
124577
124578 /* Generate code to evaluate all constraint terms using == or IN
124579 ** and store the values of those terms in an array of registers
124580 ** starting at regBase.
124581 */
124582 codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124583 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124584 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124585 if( zStartAff ) cEndAff = zStartAff[nEq];
124586 addrNxt = pLevel->addrNxt;
124587
@@ -124332,15 +124881,11 @@
124881
124882 /* Run a separate WHERE clause for each term of the OR clause. After
124883 ** eliminating duplicates from other WHERE clauses, the action for each
124884 ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
124885 */
124886 wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
 
 
 
 
124887 for(ii=0; ii<pOrWc->nTerm; ii++){
124888 WhereTerm *pOrTerm = &pOrWc->a[ii];
124889 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
124890 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
124891 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -124444,11 +124989,10 @@
124989 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
124990 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
124991 ){
124992 assert( pSubWInfo->a[0].iIdxCur==iCovCur );
124993 pCov = pSubLoop->u.btree.pIndex;
 
124994 }else{
124995 pCov = 0;
124996 }
124997
124998 /* Finish the loop through table entries that match term pOrTerm. */
@@ -124481,11 +125025,11 @@
125025 if( pTabItem->fg.isRecursive ){
125026 /* Tables marked isRecursive have only a single row that is stored in
125027 ** a pseudo-cursor. No need to Rewind or Next such cursors. */
125028 pLevel->op = OP_Noop;
125029 }else{
125030 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
125031 pLevel->op = aStep[bRev];
125032 pLevel->p1 = iCur;
125033 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
125034 VdbeCoverageIf(v, bRev==0);
125035 VdbeCoverageIf(v, bRev!=0);
@@ -124506,11 +125050,11 @@
125050 testcase( pTerm->wtFlags & TERM_VIRTUAL );
125051 testcase( pTerm->wtFlags & TERM_CODED );
125052 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
125053 if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
125054 testcase( pWInfo->untestedTerms==0
125055 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
125056 pWInfo->untestedTerms = 1;
125057 continue;
125058 }
125059 pE = pTerm->pExpr;
125060 assert( pE!=0 );
@@ -125168,11 +125712,13 @@
125712 sqlite3WhereExprAnalyze(pSrc, pAndWC);
125713 pAndWC->pOuter = pWC;
125714 if( !db->mallocFailed ){
125715 for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
125716 assert( pAndTerm->pExpr );
125717 if( allowedOp(pAndTerm->pExpr->op)
125718 || pAndTerm->eOperator==WO_MATCH
125719 ){
125720 b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);
125721 }
125722 }
125723 }
125724 indexable &= b;
@@ -125383,16 +125929,14 @@
125929 return 0;
125930 }
125931 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
125932 if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
125933 pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
125934 zColl1 = pColl ? pColl->zName : 0;
 
 
125935 pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
125936 zColl2 = pColl ? pColl->zName : 0;
125937 return sqlite3_stricmp(zColl1, zColl2)==0;
125938 }
125939
125940 /*
125941 ** Recursively walk the expressions of a SELECT statement and generate
125942 ** a bitmask indicating which tables are used in that expression
@@ -125722,11 +126266,11 @@
126266 ** current expression is of the form: column MATCH expr.
126267 ** This information is used by the xBestIndex methods of
126268 ** virtual tables. The native query optimizer does not attempt
126269 ** to do anything with MATCH functions.
126270 */
126271 if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){
126272 int idxNew;
126273 Expr *pRight, *pLeft;
126274 WhereTerm *pNewTerm;
126275 Bitmask prereqColumn, prereqExpr;
126276
@@ -126014,10 +126558,22 @@
126558 ** Return FALSE if the output needs to be sorted.
126559 */
126560 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
126561 return pWInfo->nOBSat;
126562 }
126563
126564 /*
126565 ** Return TRUE if the innermost loop of the WHERE clause implementation
126566 ** returns rows in ORDER BY order for complete run of the inner loop.
126567 **
126568 ** Across multiple iterations of outer loops, the output rows need not be
126569 ** sorted. As long as rows are sorted for just the innermost loop, this
126570 ** routine can return TRUE.
126571 */
126572 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
126573 return pWInfo->bOrderedInnerLoop;
126574 }
126575
126576 /*
126577 ** Return the VDBE address or label to jump to in order to continue
126578 ** immediately with the next row of a WHERE clause.
126579 */
@@ -127600,20 +128156,42 @@
128156 static void whereTermPrint(WhereTerm *pTerm, int iTerm){
128157 if( pTerm==0 ){
128158 sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
128159 }else{
128160 char zType[4];
128161 char zLeft[50];
128162 memcpy(zType, "...", 4);
128163 if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
128164 if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
128165 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
128166 if( pTerm->eOperator & WO_SINGLE ){
128167 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
128168 pTerm->leftCursor, pTerm->u.leftColumn);
128169 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
128170 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
128171 pTerm->u.pOrInfo->indexable);
128172 }else{
128173 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128174 }
128175 sqlite3DebugPrintf(
128176 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
128177 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
128178 pTerm->eOperator, pTerm->wtFlags);
128179 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
128180 }
128181 }
128182 #endif
128183
128184 #ifdef WHERETRACE_ENABLED
128185 /*
128186 ** Show the complete content of a WhereClause
128187 */
128188 SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){
128189 int i;
128190 for(i=0; i<pWC->nTerm; i++){
128191 whereTermPrint(&pWC->a[i], i);
128192 }
128193 }
128194 #endif
128195
128196 #ifdef WHERETRACE_ENABLED
128197 /*
@@ -128599,11 +129177,11 @@
129177 rLogSize = estLog(rSize);
129178
129179 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
129180 /* Automatic indexes */
129181 if( !pBuilder->pOrSet /* Not part of an OR optimization */
129182 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
129183 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
129184 && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */
129185 && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
129186 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
129187 && !pSrc->fg.isCorrelated /* Not a correlated subquery */
@@ -128631,10 +129209,11 @@
129209 pNew->rSetup = rLogSize + rSize + 4;
129210 if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
129211 pNew->rSetup += 24;
129212 }
129213 ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
129214 if( pNew->rSetup<0 ) pNew->rSetup = 0;
129215 /* TUNING: Each index lookup yields 20 rows in the table. This
129216 ** is more than the usual guess of 10 rows, since we have no way
129217 ** of knowing how selective the index will ultimately be. It would
129218 ** not be unreasonable to make this value much larger. */
129219 pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
@@ -128691,10 +129270,11 @@
129270 }
129271
129272 /* Full scan via index */
129273 if( b
129274 || !HasRowid(pTab)
129275 || pProbe->pPartIdxWhere!=0
129276 || ( m==0
129277 && pProbe->bUnordered==0
129278 && (pProbe->szIdxRow<pTab->szTabRow)
129279 && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
129280 && sqlite3GlobalConfig.bUseCis
@@ -129076,13 +129656,11 @@
129656 sCur.n = 0;
129657 #ifdef WHERETRACE_ENABLED
129658 WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
129659 (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
129660 if( sqlite3WhereTrace & 0x400 ){
129661 sqlite3WhereClausePrint(sSubBuild.pWC);
 
 
129662 }
129663 #endif
129664 #ifndef SQLITE_OMIT_VIRTUALTABLE
129665 if( IsVirtual(pItem->pTab) ){
129666 rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
@@ -129171,19 +129749,22 @@
129749 /* This condition is true when pItem is the FROM clause term on the
129750 ** right-hand-side of a LEFT or CROSS JOIN. */
129751 mPrereq = mPrior;
129752 }
129753 priorJointype = pItem->fg.jointype;
129754 #ifndef SQLITE_OMIT_VIRTUALTABLE
129755 if( IsVirtual(pItem->pTab) ){
129756 struct SrcList_item *p;
129757 for(p=&pItem[1]; p<pEnd; p++){
129758 if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){
129759 mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
129760 }
129761 }
129762 rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
129763 }else
129764 #endif /* SQLITE_OMIT_VIRTUALTABLE */
129765 {
129766 rc = whereLoopAddBtree(pBuilder, mPrereq);
129767 }
129768 if( rc==SQLITE_OK ){
129769 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
129770 }
@@ -129214,11 +129795,11 @@
129795 */
129796 static i8 wherePathSatisfiesOrderBy(
129797 WhereInfo *pWInfo, /* The WHERE clause */
129798 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
129799 WherePath *pPath, /* The WherePath to check */
129800 u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */
129801 u16 nLoop, /* Number of entries in pPath->aLoop[] */
129802 WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
129803 Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */
129804 ){
129805 u8 revSet; /* True if rev is known */
@@ -129225,10 +129806,11 @@
129806 u8 rev; /* Composite sort order */
129807 u8 revIdx; /* Index sort order */
129808 u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */
129809 u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */
129810 u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
129811 u16 eqOpMask; /* Allowed equality operators */
129812 u16 nKeyCol; /* Number of key columns in pIndex */
129813 u16 nColumn; /* Total number of ordered columns in the index */
129814 u16 nOrderBy; /* Number terms in the ORDER BY clause */
129815 int iLoop; /* Index of WhereLoop in pPath being processed */
129816 int i, j; /* Loop counters */
@@ -129275,13 +129857,20 @@
129857 if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
129858 isOrderDistinct = 1;
129859 obDone = MASKBIT(nOrderBy)-1;
129860 orderDistinctMask = 0;
129861 ready = 0;
129862 eqOpMask = WO_EQ | WO_IS | WO_ISNULL;
129863 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;
129864 for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
129865 if( iLoop>0 ) ready |= pLoop->maskSelf;
129866 if( iLoop<nLoop ){
129867 pLoop = pPath->aLoop[iLoop];
129868 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
129869 }else{
129870 pLoop = pLast;
129871 }
129872 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
129873 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
129874 break;
129875 }
129876 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -129295,11 +129884,11 @@
129884 if( MASKBIT(i) & obSat ) continue;
129885 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
129886 if( pOBExpr->op!=TK_COLUMN ) continue;
129887 if( pOBExpr->iTable!=iCur ) continue;
129888 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
129889 ~ready, eqOpMask, 0);
129890 if( pTerm==0 ) continue;
129891 if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
129892 const char *z1, *z2;
129893 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
129894 if( !pColl ) pColl = db->pDfltColl;
@@ -129335,14 +129924,16 @@
129924 rev = revSet = 0;
129925 distinctColumns = 0;
129926 for(j=0; j<nColumn; j++){
129927 u8 bOnce; /* True to run the ORDER BY search loop */
129928
129929 /* Skip over == and IS and ISNULL terms.
129930 ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
129931 */
129932 if( j<pLoop->u.btree.nEq
129933 && pLoop->nSkip==0
129934 && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
129935 ){
129936 if( i & WO_ISNULL ){
129937 testcase( isOrderDistinct );
129938 isOrderDistinct = 0;
129939 }
@@ -129862,12 +130453,23 @@
130453 if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
130454 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
130455 }
130456 }else{
130457 pWInfo->nOBSat = pFrom->isOrdered;
 
130458 pWInfo->revMask = pFrom->revLoop;
130459 if( pWInfo->nOBSat<=0 ){
130460 pWInfo->nOBSat = 0;
130461 if( nLoop>0 ){
130462 Bitmask m;
130463 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
130464 WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
130465 if( rc==pWInfo->pOrderBy->nExpr ){
130466 pWInfo->bOrderedInnerLoop = 1;
130467 pWInfo->revMask = m;
130468 }
130469 }
130470 }
130471 }
130472 if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
130473 && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
130474 ){
130475 Bitmask revMask = 0;
@@ -129911,11 +130513,11 @@
130513 int j;
130514 Table *pTab;
130515 Index *pIdx;
130516
130517 pWInfo = pBuilder->pWInfo;
130518 if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
130519 assert( pWInfo->pTabList->nSrc>=1 );
130520 pItem = pWInfo->pTabList->a;
130521 pTab = pItem->pTab;
130522 if( IsVirtual(pTab) ) return 0;
130523 if( pItem->fg.isIndexedBy ) return 0;
@@ -130058,11 +130660,11 @@
130660 ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
130661 ** if there is one. If there is no ORDER BY clause or if this routine
130662 ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
130663 **
130664 ** The iIdxCur parameter is the cursor number of an index. If
130665 ** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
130666 ** to use for OR clause processing. The WHERE clause should use this
130667 ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
130668 ** the first cursor in an array of cursors for all indices. iIdxCur should
130669 ** be used to compute the appropriate cursor depending on which index is
130670 ** used.
@@ -130072,11 +130674,11 @@
130674 SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
130675 Expr *pWhere, /* The WHERE clause */
130676 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
130677 ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
130678 u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
130679 int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
130680 ** If WHERE_USE_LIMIT, then the limit amount */
130681 ){
130682 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
130683 int nTabList; /* Number of elements in pTabList */
130684 WhereInfo *pWInfo; /* Will become the return value of this function */
@@ -130091,15 +130693,15 @@
130693 int rc; /* Return code */
130694 u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */
130695
130696 assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (
130697 (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
130698 && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130699 ));
130700
130701 /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */
130702 assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130703 || (wctrlFlags & WHERE_USE_LIMIT)==0 );
130704
130705 /* Variable initialization */
130706 db = pParse->db;
130707 memset(&sWLB, 0, sizeof(sWLB));
@@ -130123,15 +130725,15 @@
130725 sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
130726 return 0;
130727 }
130728
130729 /* This function normally generates a nested loop for all tables in
130730 ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should
130731 ** only generate code for the first table in pTabList and assume that
130732 ** any cursors associated with subsequent tables are uninitialized.
130733 */
130734 nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;
130735
130736 /* Allocate and initialize the WhereInfo structure that will become the
130737 ** return value. A single allocation is used to store the WhereInfo
130738 ** struct, the contents of WhereInfo.a[], the WhereClause structure
130739 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
@@ -130203,11 +130805,11 @@
130805 ** important. Ticket #3015.
130806 **
130807 ** Note that bitmasks are created for all pTabList->nSrc tables in
130808 ** pTabList, not just the first nTabList tables. nTabList is normally
130809 ** equal to pTabList->nSrc but might be shortened to 1 if the
130810 ** WHERE_OR_SUBCLAUSE flag is set.
130811 */
130812 for(ii=0; ii<pTabList->nSrc; ii++){
130813 createMask(pMaskSet, pTabList->a[ii].iCursor);
130814 sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
130815 }
@@ -130241,14 +130843,11 @@
130843 sqlite3DebugPrintf(", limit: %d", iAuxArg);
130844 }
130845 sqlite3DebugPrintf(")\n");
130846 }
130847 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
130848 sqlite3WhereClausePrint(sWLB.pWC);
 
 
 
130849 }
130850 #endif
130851
130852 if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
130853 rc = whereLoopAddAll(&sWLB);
@@ -130386,11 +130985,11 @@
130985 }else if( IsVirtual(pTab) ){
130986 /* noop */
130987 }else
130988 #endif
130989 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
130990 && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
130991 int op = OP_OpenRead;
130992 if( pWInfo->eOnePass!=ONEPASS_OFF ){
130993 op = OP_OpenWrite;
130994 pWInfo->aiCurOnePass[0] = pTabItem->iCursor;
130995 };
@@ -130425,11 +131024,11 @@
131024 int iIndexCur;
131025 int op = OP_OpenRead;
131026 /* iAuxArg is always set if to a positive value if ONEPASS is possible */
131027 assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );
131028 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)
131029 && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0
131030 ){
131031 /* This is one term of an OR-optimization using the PRIMARY KEY of a
131032 ** WITHOUT ROWID table. No need for a separate index */
131033 iIndexCur = pLevel->iTabCur;
131034 op = 0;
@@ -130441,13 +131040,13 @@
131040 iIndexCur++;
131041 pJ = pJ->pNext;
131042 }
131043 op = OP_OpenWrite;
131044 pWInfo->aiCurOnePass[1] = iIndexCur;
131045 }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){
131046 iIndexCur = iAuxArg;
131047 op = OP_ReopenIdx;
131048 }else{
131049 iIndexCur = pParse->nTab++;
131050 }
131051 pLevel->iIdxCur = iIndexCur;
131052 assert( pIx->pSchema==pTab->pSchema );
@@ -130505,11 +131104,11 @@
131104 pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
131105 );
131106 pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
131107 notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
131108 pWInfo->iContinue = pLevel->addrCont;
131109 if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
131110 sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
131111 }
131112 }
131113
131114 /* Done. */
@@ -130628,16 +131227,16 @@
131227 continue;
131228 }
131229
131230 /* Close all of the cursors that were opened by sqlite3WhereBegin.
131231 ** Except, do not close cursors that will be reused by the OR optimization
131232 ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
131233 ** created for the ONEPASS optimization.
131234 */
131235 if( (pTab->tabFlags & TF_Ephemeral)==0
131236 && pTab->pSelect==0
131237 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
131238 ){
131239 int ws = pLoop->wsFlags;
131240 if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
131241 sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
131242 }
@@ -130980,49 +131579,49 @@
131579 #ifndef INTERFACE
131580 # define INTERFACE 1
131581 #endif
131582 /************* Begin control #defines *****************************************/
131583 #define YYCODETYPE unsigned char
131584 #define YYNOCODE 252
131585 #define YYACTIONTYPE unsigned short int
131586 #define YYWILDCARD 96
131587 #define sqlite3ParserTOKENTYPE Token
131588 typedef union {
131589 int yyinit;
131590 sqlite3ParserTOKENTYPE yy0;
131591 Expr* yy72;
131592 TriggerStep* yy145;
131593 ExprList* yy148;
131594 SrcList* yy185;
131595 ExprSpan yy190;
131596 int yy194;
131597 Select* yy243;
131598 IdList* yy254;
131599 With* yy285;
131600 struct TrigEvent yy332;
131601 struct LimitVal yy354;
131602 struct LikeOp yy392;
131603 struct {int value; int mask;} yy497;
131604 } YYMINORTYPE;
131605 #ifndef YYSTACKDEPTH
131606 #define YYSTACKDEPTH 100
131607 #endif
131608 #define sqlite3ParserARG_SDECL Parse *pParse;
131609 #define sqlite3ParserARG_PDECL ,Parse *pParse
131610 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131611 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
131612 #define YYFALLBACK 1
131613 #define YYNSTATE 443
131614 #define YYNRULE 328
131615 #define YY_MAX_SHIFT 442
131616 #define YY_MIN_SHIFTREDUCE 653
131617 #define YY_MAX_SHIFTREDUCE 980
131618 #define YY_MIN_REDUCE 981
131619 #define YY_MAX_REDUCE 1308
131620 #define YY_ERROR_ACTION 1309
131621 #define YY_ACCEPT_ACTION 1310
131622 #define YY_NO_ACTION 1311
131623 /************* End control #defines *******************************************/
131624
131625 /* Define the yytestcase() macro to be a no-op if is not already defined
131626 ** otherwise.
131627 **
@@ -131086,450 +131685,452 @@
131685 ** yy_reduce_ofst[] For each state, the offset into yy_action for
131686 ** shifting non-terminals after a reduce.
131687 ** yy_default[] Default action for each state.
131688 **
131689 *********** Begin parsing tables **********************************************/
131690 #define YY_ACTTAB_COUNT (1507)
131691 static const YYACTIONTYPE yy_action[] = {
131692 /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131693 /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131694 /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131695 /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131696 /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131697 /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131698 /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131699 /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131700 /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131701 /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131702 /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131703 /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131704 /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131705 /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131706 /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131707 /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131708 /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131709 /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131710 /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131711 /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131712 /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131713 /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131714 /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131715 /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131716 /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131717 /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131718 /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131719 /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131720 /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131721 /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131722 /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131723 /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131724 /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131725 /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131726 /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131727 /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131728 /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131729 /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131730 /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131731 /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131732 /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131733 /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131734 /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131735 /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131736 /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131737 /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131738 /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131739 /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131740 /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131741 /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131742 /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131743 /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131744 /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131745 /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131746 /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131747 /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131748 /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131749 /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131750 /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131751 /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131752 /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131753 /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131754 /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131755 /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131756 /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131757 /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131758 /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131759 /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131760 /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
131761 /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
131762 /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
131763 /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
131764 /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
131765 /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
131766 /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
131767 /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
131768 /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
131769 /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
131770 /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
131771 /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
131772 /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
131773 /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131774 /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
131775 /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
131776 /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
131777 /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
131778 /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
131779 /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
131780 /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
131781 /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
131782 /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
131783 /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
131784 /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
131785 /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
131786 /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
131787 /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
131788 /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
131789 /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
131790 /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
131791 /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
131792 /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
131793 /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
131794 /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
131795 /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
131796 /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
131797 /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
131798 /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
131799 /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
131800 /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
131801 /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
131802 /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
131803 /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
131804 /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
131805 /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
131806 /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
131807 /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
131808 /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
131809 /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
131810 /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
131811 /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
131812 /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
131813 /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
131814 /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
131815 /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
131816 /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
131817 /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
131818 /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
131819 /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
131820 /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
131821 /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
131822 /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
131823 /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
131824 /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
131825 /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
131826 /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
131827 /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
131828 /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
131829 /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
131830 /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
131831 /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
131832 /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
131833 /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
131834 /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
131835 /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
131836 /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
131837 /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
131838 /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
131839 /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
131840 /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
131841 /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
131842 /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
131843 };
131844 static const YYCODETYPE yy_lookahead[] = {
131845 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
131846 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131847 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131848 /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
131849 /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
131850 /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43,
131851 /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131852 /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
131853 /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
131854 /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131855 /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131856 /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
131857 /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
131858 /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
131859 /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
131860 /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
131861 /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
131862 /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
131863 /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131864 /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
131865 /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131866 /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131867 /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
131868 /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
131869 /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131870 /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131871 /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
131872 /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131873 /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
131874 /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
131875 /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
131876 /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
131877 /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131878 /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
131879 /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131880 /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
131881 /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
131882 /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
131883 /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
131884 /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131885 /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
131886 /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131887 /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131888 /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
131889 /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
131890 /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
131891 /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
131892 /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
131893 /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
131894 /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131895 /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
131896 /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
131897 /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
131898 /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
131899 /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
131900 /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
131901 /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131902 /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
131903 /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
131904 /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
131905 /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
131906 /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
131907 /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
131908 /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
131909 /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
131910 /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
131911 /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
131912 /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
131913 /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
131914 /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
131915 /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
131916 /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
131917 /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
131918 /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
131919 /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
131920 /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
131921 /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
131922 /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
131923 /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
131924 /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
131925 /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
131926 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131927 /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
131928 /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
131929 /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
131930 /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
131931 /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
131932 /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
131933 /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
131934 /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
131935 /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
131936 /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
131937 /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
131938 /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
131939 /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
131940 /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
131941 /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
131942 /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
131943 /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
131944 /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
131945 /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
131946 /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
131947 /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
131948 /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
131949 /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
131950 /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
131951 /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
131952 /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
131953 /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
131954 /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
131955 /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
131956 /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
131957 /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
131958 /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
131959 /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
131960 /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
131961 /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
131962 /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
131963 /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
131964 /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
131965 /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
131966 /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
131967 /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
131968 /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
131969 /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
131970 /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
131971 /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
131972 /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
131973 /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
131974 /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
131975 /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
131976 /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
131977 /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
131978 /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
131979 /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
131980 /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
131981 /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
131982 /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
131983 /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
131984 /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
131985 /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
131986 /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
131987 /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
131988 /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
131989 /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
131990 /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
131991 /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
131992 /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
131993 /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
131994 /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
131995 /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
131996 };
131997 #define YY_SHIFT_USE_DFLT (-95)
131998 #define YY_SHIFT_COUNT (442)
131999 #define YY_SHIFT_MIN (-94)
132000 #define YY_SHIFT_MAX (1491)
132001 static const short yy_shift_ofst[] = {
132002 /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132003 /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132004 /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132005 /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132006 /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132007 /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
132008 /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132009 /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132010 /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132011 /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132012 /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132013 /* 110 */ 837, 837, 924, 73, 183, -51, -95, -95, -95, 501,
132014 /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132015 /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132016 /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132017 /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, -95, -95,
132018 /* 160 */ -95, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132019 /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132020 /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132021 /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132022 /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132023 /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132024 /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132025 /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132026 /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132027 /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132028 /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132029 /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132030 /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132031 /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132032 /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, -95,
132033 /* 310 */ -95, -95, -95, -95, -95, -95, -95, 451, 936, 816,
132034 /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132035 /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132036 /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132037 /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132038 /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132039 /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132040 /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132041 /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132042 /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132043 /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132044 /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132045 /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132046 /* 440 */ 1482, 1491, 1490,
132047 };
132048 #define YY_REDUCE_USE_DFLT (-130)
132049 #define YY_REDUCE_COUNT (316)
132050 #define YY_REDUCE_MIN (-129)
132051 #define YY_REDUCE_MAX (1243)
132052 static const short yy_reduce_ofst[] = {
132053 /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132054 /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132055 /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
132056 /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132057 /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132058 /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132059 /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132060 /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132061 /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132062 /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132063 /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132064 /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132065 /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132066 /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132067 /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132068 /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132069 /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132070 /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132071 /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132072 /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132073 /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132074 /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132075 /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132076 /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132077 /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132078 /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132079 /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132080 /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132081 /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132082 /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132083 /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132084 /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
132085 };
132086 static const YYACTIONTYPE yy_default[] = {
132087 /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132088 /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132089 /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132090 /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132091 /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132092 /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132093 /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132094 /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132095 /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132096 /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132097 /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132098 /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132099 /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132100 /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132101 /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132102 /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132103 /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132104 /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132105 /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132106 /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132107 /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132108 /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132109 /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132110 /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132111 /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132112 /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132113 /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132114 /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132115 /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132116 /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132117 /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132118 /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132119 /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132120 /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132121 /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132122 /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132123 /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132124 /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132125 /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132126 /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132127 /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132128 /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132129 /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132130 /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132131 /* 440 */ 1309, 991, 1309,
132132 };
132133 /********** End of lemon-generated parsing tables *****************************/
132134
132135 /* The next table maps tokens (terminal symbols) into fallback tokens.
132136 ** If a construct like the following:
@@ -131672,21 +132273,22 @@
132273 typedef struct yyStackEntry yyStackEntry;
132274
132275 /* The state of the parser is completely contained in an instance of
132276 ** the following structure */
132277 struct yyParser {
132278 yyStackEntry *yytos; /* Pointer to top element of the stack */
132279 #ifdef YYTRACKMAXSTACKDEPTH
132280 int yyhwm; /* High-water mark of the stack */
132281 #endif
132282 #ifndef YYNOERRORRECOVERY
132283 int yyerrcnt; /* Shifts left before out of the error */
132284 #endif
132285 sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
132286 #if YYSTACKDEPTH<=0
132287 int yystksz; /* Current side of the stack */
132288 yyStackEntry *yystack; /* The parser's stack */
132289 yyStackEntry yystk0; /* First stack entry */
132290 #else
132291 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
132292 #endif
132293 };
132294 typedef struct yyParser yyParser;
@@ -131781,17 +132383,17 @@
132383 "orderby_opt", "limit_opt", "values", "nexprlist",
132384 "exprlist", "sclp", "as", "seltablist",
132385 "stl_prefix", "joinop", "indexed_opt", "on_opt",
132386 "using_opt", "idlist", "setlist", "insert_cmd",
132387 "idlist_opt", "likeop", "between_op", "in_op",
132388 "paren_exprlist", "case_operand", "case_exprlist", "case_else",
132389 "uniqueflag", "collate", "nmnum", "trigger_decl",
132390 "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause",
132391 "when_clause", "trigger_cmd", "trnm", "tridxby",
132392 "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt",
132393 "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken",
132394 "lp", "anylist", "wqlist",
132395 };
132396 #endif /* NDEBUG */
132397
132398 #ifndef NDEBUG
132399 /* For tracing reduce actions, the names of all rules are required.
@@ -131985,11 +132587,11 @@
132587 /* 185 */ "in_op ::= IN",
132588 /* 186 */ "in_op ::= NOT IN",
132589 /* 187 */ "expr ::= expr in_op LP exprlist RP",
132590 /* 188 */ "expr ::= LP select RP",
132591 /* 189 */ "expr ::= expr in_op LP select RP",
132592 /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
132593 /* 191 */ "expr ::= EXISTS LP select RP",
132594 /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
132595 /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
132596 /* 194 */ "case_exprlist ::= WHEN expr THEN expr",
132597 /* 195 */ "case_else ::= ELSE expr",
@@ -131997,158 +132599,170 @@
132599 /* 197 */ "case_operand ::= expr",
132600 /* 198 */ "case_operand ::=",
132601 /* 199 */ "exprlist ::=",
132602 /* 200 */ "nexprlist ::= nexprlist COMMA expr",
132603 /* 201 */ "nexprlist ::= expr",
132604 /* 202 */ "paren_exprlist ::=",
132605 /* 203 */ "paren_exprlist ::= LP exprlist RP",
132606 /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132607 /* 205 */ "uniqueflag ::= UNIQUE",
132608 /* 206 */ "uniqueflag ::=",
132609 /* 207 */ "eidlist_opt ::=",
132610 /* 208 */ "eidlist_opt ::= LP eidlist RP",
132611 /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132612 /* 210 */ "eidlist ::= nm collate sortorder",
132613 /* 211 */ "collate ::=",
132614 /* 212 */ "collate ::= COLLATE ID|STRING",
132615 /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132616 /* 214 */ "cmd ::= VACUUM",
132617 /* 215 */ "cmd ::= VACUUM nm",
132618 /* 216 */ "cmd ::= PRAGMA nm dbnm",
132619 /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132620 /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132621 /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132622 /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132623 /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132624 /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132625 /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132626 /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132627 /* 225 */ "trigger_time ::= BEFORE",
132628 /* 226 */ "trigger_time ::= AFTER",
132629 /* 227 */ "trigger_time ::= INSTEAD OF",
132630 /* 228 */ "trigger_time ::=",
132631 /* 229 */ "trigger_event ::= DELETE|INSERT",
132632 /* 230 */ "trigger_event ::= UPDATE",
132633 /* 231 */ "trigger_event ::= UPDATE OF idlist",
132634 /* 232 */ "when_clause ::=",
132635 /* 233 */ "when_clause ::= WHEN expr",
132636 /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132637 /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132638 /* 236 */ "trnm ::= nm DOT nm",
132639 /* 237 */ "tridxby ::= INDEXED BY nm",
132640 /* 238 */ "tridxby ::= NOT INDEXED",
132641 /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132642 /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132643 /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132644 /* 242 */ "trigger_cmd ::= select",
132645 /* 243 */ "expr ::= RAISE LP IGNORE RP",
132646 /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132647 /* 245 */ "raisetype ::= ROLLBACK",
132648 /* 246 */ "raisetype ::= ABORT",
132649 /* 247 */ "raisetype ::= FAIL",
132650 /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132651 /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132652 /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132653 /* 251 */ "key_opt ::=",
132654 /* 252 */ "key_opt ::= KEY expr",
132655 /* 253 */ "cmd ::= REINDEX",
132656 /* 254 */ "cmd ::= REINDEX nm dbnm",
132657 /* 255 */ "cmd ::= ANALYZE",
132658 /* 256 */ "cmd ::= ANALYZE nm dbnm",
132659 /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132660 /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132661 /* 259 */ "add_column_fullname ::= fullname",
132662 /* 260 */ "cmd ::= create_vtab",
132663 /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132664 /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132665 /* 263 */ "vtabarg ::=",
132666 /* 264 */ "vtabargtoken ::= ANY",
132667 /* 265 */ "vtabargtoken ::= lp anylist RP",
132668 /* 266 */ "lp ::= LP",
132669 /* 267 */ "with ::=",
132670 /* 268 */ "with ::= WITH wqlist",
132671 /* 269 */ "with ::= WITH RECURSIVE wqlist",
132672 /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132673 /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132674 /* 272 */ "input ::= cmdlist",
132675 /* 273 */ "cmdlist ::= cmdlist ecmd",
132676 /* 274 */ "cmdlist ::= ecmd",
132677 /* 275 */ "ecmd ::= SEMI",
132678 /* 276 */ "ecmd ::= explain cmdx SEMI",
132679 /* 277 */ "explain ::=",
132680 /* 278 */ "trans_opt ::=",
132681 /* 279 */ "trans_opt ::= TRANSACTION",
132682 /* 280 */ "trans_opt ::= TRANSACTION nm",
132683 /* 281 */ "savepoint_opt ::= SAVEPOINT",
132684 /* 282 */ "savepoint_opt ::=",
132685 /* 283 */ "cmd ::= create_table create_table_args",
132686 /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132687 /* 285 */ "columnlist ::= columnname carglist",
132688 /* 286 */ "nm ::= ID|INDEXED",
132689 /* 287 */ "nm ::= STRING",
132690 /* 288 */ "nm ::= JOIN_KW",
132691 /* 289 */ "typetoken ::= typename",
132692 /* 290 */ "typename ::= ID|STRING",
132693 /* 291 */ "signed ::= plus_num",
132694 /* 292 */ "signed ::= minus_num",
132695 /* 293 */ "carglist ::= carglist ccons",
132696 /* 294 */ "carglist ::=",
132697 /* 295 */ "ccons ::= NULL onconf",
132698 /* 296 */ "conslist_opt ::= COMMA conslist",
132699 /* 297 */ "conslist ::= conslist tconscomma tcons",
132700 /* 298 */ "conslist ::= tcons",
132701 /* 299 */ "tconscomma ::=",
132702 /* 300 */ "defer_subclause_opt ::= defer_subclause",
132703 /* 301 */ "resolvetype ::= raisetype",
132704 /* 302 */ "selectnowith ::= oneselect",
132705 /* 303 */ "oneselect ::= values",
132706 /* 304 */ "sclp ::= selcollist COMMA",
132707 /* 305 */ "as ::= ID|STRING",
132708 /* 306 */ "expr ::= term",
132709 /* 307 */ "exprlist ::= nexprlist",
132710 /* 308 */ "nmnum ::= plus_num",
132711 /* 309 */ "nmnum ::= nm",
132712 /* 310 */ "nmnum ::= ON",
132713 /* 311 */ "nmnum ::= DELETE",
132714 /* 312 */ "nmnum ::= DEFAULT",
132715 /* 313 */ "plus_num ::= INTEGER|FLOAT",
132716 /* 314 */ "foreach_clause ::=",
132717 /* 315 */ "foreach_clause ::= FOR EACH ROW",
132718 /* 316 */ "trnm ::= nm",
132719 /* 317 */ "tridxby ::=",
132720 /* 318 */ "database_kw_opt ::= DATABASE",
132721 /* 319 */ "database_kw_opt ::=",
132722 /* 320 */ "kwcolumn_opt ::=",
132723 /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132724 /* 322 */ "vtabarglist ::= vtabarg",
132725 /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132726 /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132727 /* 325 */ "anylist ::=",
132728 /* 326 */ "anylist ::= anylist LP anylist RP",
132729 /* 327 */ "anylist ::= anylist ANY",
132730 };
132731 #endif /* NDEBUG */
132732
132733
132734 #if YYSTACKDEPTH<=0
132735 /*
132736 ** Try to increase the size of the parser stack. Return the number
132737 ** of errors. Return 0 on success.
132738 */
132739 static int yyGrowStack(yyParser *p){
132740 int newSize;
132741 int idx;
132742 yyStackEntry *pNew;
132743
132744 newSize = p->yystksz*2 + 100;
132745 idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
132746 if( p->yystack==&p->yystk0 ){
132747 pNew = malloc(newSize*sizeof(pNew[0]));
132748 if( pNew ) pNew[0] = p->yystk0;
132749 }else{
132750 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132751 }
132752 if( pNew ){
132753 p->yystack = pNew;
132754 p->yytos = &p->yystack[idx];
132755 #ifndef NDEBUG
132756 if( yyTraceFILE ){
132757 fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
132758 yyTracePrompt, p->yystksz, newSize);
132759 }
132760 #endif
132761 p->yystksz = newSize;
132762 }
132763 return pNew==0;
132764 }
132765 #endif
132766
132767 /* Datatype of the argument to the memory allocated passed as the
132768 ** second argument to sqlite3ParserAlloc() below. This can be changed by
@@ -132173,19 +132787,28 @@
132787 */
132788 SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
132789 yyParser *pParser;
132790 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
132791 if( pParser ){
 
132792 #ifdef YYTRACKMAXSTACKDEPTH
132793 pParser->yyhwm = 0;
132794 #endif
132795 #if YYSTACKDEPTH<=0
132796 pParser->yytos = NULL;
132797 pParser->yystack = NULL;
132798 pParser->yystksz = 0;
132799 if( yyGrowStack(pParser) ){
132800 pParser->yystack = &pParser->yystk0;
132801 pParser->yystksz = 1;
132802 }
132803 #endif
132804 #ifndef YYNOERRORRECOVERY
132805 pParser->yyerrcnt = -1;
132806 #endif
132807 pParser->yytos = pParser->yystack;
132808 pParser->yystack[0].stateno = 0;
132809 pParser->yystack[0].major = 0;
132810 }
132811 return pParser;
132812 }
132813
132814 /* The following function deletes the "minor type" or semantic value
@@ -132216,17 +132839,17 @@
132839 case 163: /* select */
132840 case 194: /* selectnowith */
132841 case 195: /* oneselect */
132842 case 206: /* values */
132843 {
132844 sqlite3SelectDelete(pParse->db, (yypminor->yy243));
132845 }
132846 break;
132847 case 172: /* term */
132848 case 173: /* expr */
132849 {
132850 sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);
132851 }
132852 break;
132853 case 177: /* eidlist_opt */
132854 case 186: /* sortlist */
132855 case 187: /* eidlist */
@@ -132235,56 +132858,57 @@
132858 case 204: /* orderby_opt */
132859 case 207: /* nexprlist */
132860 case 208: /* exprlist */
132861 case 209: /* sclp */
132862 case 218: /* setlist */
132863 case 224: /* paren_exprlist */
132864 case 226: /* case_exprlist */
132865 {
132866 sqlite3ExprListDelete(pParse->db, (yypminor->yy148));
132867 }
132868 break;
132869 case 193: /* fullname */
132870 case 200: /* from */
132871 case 211: /* seltablist */
132872 case 212: /* stl_prefix */
132873 {
132874 sqlite3SrcListDelete(pParse->db, (yypminor->yy185));
132875 }
132876 break;
132877 case 196: /* with */
132878 case 250: /* wqlist */
132879 {
132880 sqlite3WithDelete(pParse->db, (yypminor->yy285));
132881 }
132882 break;
132883 case 201: /* where_opt */
132884 case 203: /* having_opt */
132885 case 215: /* on_opt */
132886 case 225: /* case_operand */
132887 case 227: /* case_else */
132888 case 236: /* when_clause */
132889 case 241: /* key_opt */
132890 {
132891 sqlite3ExprDelete(pParse->db, (yypminor->yy72));
132892 }
132893 break;
132894 case 216: /* using_opt */
132895 case 217: /* idlist */
132896 case 220: /* idlist_opt */
132897 {
132898 sqlite3IdListDelete(pParse->db, (yypminor->yy254));
132899 }
132900 break;
132901 case 232: /* trigger_cmd_list */
132902 case 237: /* trigger_cmd */
132903 {
132904 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145));
132905 }
132906 break;
132907 case 234: /* trigger_event */
132908 {
132909 sqlite3IdListDelete(pParse->db, (yypminor->yy332).b);
132910 }
132911 break;
132912 /********* End destructor definitions *****************************************/
132913 default: break; /* If no destructor action specified: do nothing */
132914 }
@@ -132296,12 +132920,13 @@
132920 ** If there is a destructor routine associated with the token which
132921 ** is popped from the stack, then call it.
132922 */
132923 static void yy_pop_parser_stack(yyParser *pParser){
132924 yyStackEntry *yytos;
132925 assert( pParser->yytos!=0 );
132926 assert( pParser->yytos > pParser->yystack );
132927 yytos = pParser->yytos--;
132928 #ifndef NDEBUG
132929 if( yyTraceFILE ){
132930 fprintf(yyTraceFILE,"%sPopping %s\n",
132931 yyTracePrompt,
132932 yyTokenName[yytos->major]);
@@ -132324,13 +132949,13 @@
132949 ){
132950 yyParser *pParser = (yyParser*)p;
132951 #ifndef YYPARSEFREENEVERNULL
132952 if( pParser==0 ) return;
132953 #endif
132954 while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
132955 #if YYSTACKDEPTH<=0
132956 if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
132957 #endif
132958 (*freeProc)((void*)pParser);
132959 }
132960
132961 /*
@@ -132337,11 +132962,11 @@
132962 ** Return the peak depth of the stack for a parser.
132963 */
132964 #ifdef YYTRACKMAXSTACKDEPTH
132965 SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){
132966 yyParser *pParser = (yyParser*)p;
132967 return pParser->yyhwm;
132968 }
132969 #endif
132970
132971 /*
132972 ** Find the appropriate action for a parser given the terminal
@@ -132350,11 +132975,11 @@
132975 static unsigned int yy_find_shift_action(
132976 yyParser *pParser, /* The parser */
132977 YYCODETYPE iLookAhead /* The look-ahead token */
132978 ){
132979 int i;
132980 int stateno = pParser->yytos->stateno;
132981
132982 if( stateno>=YY_MIN_REDUCE ) return stateno;
132983 assert( stateno <= YY_SHIFT_COUNT );
132984 do{
132985 i = yy_shift_ofst[stateno];
@@ -132443,17 +133068,17 @@
133068 /*
133069 ** The following routine is called if the stack overflows.
133070 */
133071 static void yyStackOverflow(yyParser *yypParser){
133072 sqlite3ParserARG_FETCH;
133073 yypParser->yytos--;
133074 #ifndef NDEBUG
133075 if( yyTraceFILE ){
133076 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
133077 }
133078 #endif
133079 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
133080 /* Here code is inserted which will execute if the parser
133081 ** stack every overflows */
133082 /******** Begin %stack_overflow code ******************************************/
133083
133084 sqlite3ErrorMsg(pParse, "parser stack overflow");
@@ -132467,15 +133092,15 @@
133092 #ifndef NDEBUG
133093 static void yyTraceShift(yyParser *yypParser, int yyNewState){
133094 if( yyTraceFILE ){
133095 if( yyNewState<YYNSTATE ){
133096 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
133097 yyTracePrompt,yyTokenName[yypParser->yytos->major],
133098 yyNewState);
133099 }else{
133100 fprintf(yyTraceFILE,"%sShift '%s'\n",
133101 yyTracePrompt,yyTokenName[yypParser->yytos->major]);
133102 }
133103 }
133104 }
133105 #else
133106 # define yyTraceShift(X,Y)
@@ -132489,31 +133114,34 @@
133114 int yyNewState, /* The new state to shift in */
133115 int yyMajor, /* The major token to shift in */
133116 sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
133117 ){
133118 yyStackEntry *yytos;
133119 yypParser->yytos++;
133120 #ifdef YYTRACKMAXSTACKDEPTH
133121 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133122 yypParser->yyhwm++;
133123 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
133124 }
133125 #endif
133126 #if YYSTACKDEPTH>0
133127 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
133128 yyStackOverflow(yypParser);
133129 return;
133130 }
133131 #else
133132 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
133133 if( yyGrowStack(yypParser) ){
 
133134 yyStackOverflow(yypParser);
133135 return;
133136 }
133137 }
133138 #endif
133139 if( yyNewState > YY_MAX_SHIFT ){
133140 yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
133141 }
133142 yytos = yypParser->yytos;
133143 yytos->stateno = (YYACTIONTYPE)yyNewState;
133144 yytos->major = (YYCODETYPE)yyMajor;
133145 yytos->minor.yy0 = yyMinor;
133146 yyTraceShift(yypParser, yyNewState);
133147 }
@@ -132713,31 +133341,33 @@
133341 { 223, 1 },
133342 { 223, 2 },
133343 { 173, 5 },
133344 { 173, 3 },
133345 { 173, 5 },
133346 { 173, 5 },
133347 { 173, 4 },
133348 { 173, 5 },
133349 { 226, 5 },
133350 { 226, 4 },
133351 { 227, 2 },
133352 { 227, 0 },
133353 { 225, 1 },
133354 { 225, 0 },
133355 { 208, 0 },
133356 { 207, 3 },
133357 { 207, 1 },
133358 { 224, 0 },
133359 { 224, 3 },
133360 { 149, 12 },
133361 { 228, 1 },
133362 { 228, 0 },
133363 { 177, 0 },
133364 { 177, 3 },
133365 { 187, 5 },
133366 { 187, 3 },
133367 { 229, 0 },
133368 { 229, 2 },
133369 { 149, 4 },
133370 { 149, 1 },
133371 { 149, 2 },
133372 { 149, 3 },
133373 { 149, 5 },
@@ -132745,58 +133375,58 @@
133375 { 149, 5 },
133376 { 149, 6 },
133377 { 169, 2 },
133378 { 170, 2 },
133379 { 149, 5 },
133380 { 231, 11 },
 
 
 
 
133381 { 233, 1 },
133382 { 233, 1 },
133383 { 233, 2 },
133384 { 233, 0 },
133385 { 234, 1 },
133386 { 234, 1 },
133387 { 234, 3 },
133388 { 236, 0 },
133389 { 236, 2 },
133390 { 232, 3 },
133391 { 232, 2 },
133392 { 238, 3 },
133393 { 239, 3 },
133394 { 239, 2 },
133395 { 237, 7 },
133396 { 237, 5 },
133397 { 237, 5 },
133398 { 237, 1 },
133399 { 173, 4 },
133400 { 173, 6 },
133401 { 191, 1 },
133402 { 191, 1 },
133403 { 191, 1 },
133404 { 149, 4 },
133405 { 149, 6 },
133406 { 149, 3 },
133407 { 241, 0 },
133408 { 241, 2 },
133409 { 149, 1 },
133410 { 149, 3 },
133411 { 149, 1 },
133412 { 149, 3 },
133413 { 149, 6 },
133414 { 149, 7 },
133415 { 242, 1 },
133416 { 149, 1 },
133417 { 149, 4 },
133418 { 244, 8 },
133419 { 246, 0 },
 
 
133420 { 247, 1 },
133421 { 247, 3 },
133422 { 248, 1 },
133423 { 196, 0 },
133424 { 196, 2 },
133425 { 196, 3 },
133426 { 250, 6 },
133427 { 250, 8 },
133428 { 144, 1 },
133429 { 145, 2 },
133430 { 145, 1 },
133431 { 146, 1 },
133432 { 146, 3 },
@@ -132829,30 +133459,30 @@
133459 { 195, 1 },
133460 { 209, 2 },
133461 { 210, 1 },
133462 { 173, 1 },
133463 { 208, 1 },
133464 { 230, 1 },
133465 { 230, 1 },
133466 { 230, 1 },
133467 { 230, 1 },
133468 { 230, 1 },
133469 { 169, 1 },
133470 { 235, 0 },
133471 { 235, 3 },
133472 { 238, 1 },
 
 
133473 { 239, 0 },
133474 { 240, 1 },
133475 { 240, 0 },
133476 { 243, 0 },
133477 { 243, 1 },
133478 { 245, 1 },
133479 { 245, 3 },
133480 { 246, 2 },
133481 { 249, 0 },
133482 { 249, 4 },
133483 { 249, 2 },
133484 };
133485
133486 static void yy_accept(yyParser*); /* Forward Declaration */
133487
133488 /*
@@ -132866,11 +133496,11 @@
133496 int yygoto; /* The next state */
133497 int yyact; /* The next action */
133498 yyStackEntry *yymsp; /* The top of the parser's stack */
133499 int yysize; /* Amount to pop the stack */
133500 sqlite3ParserARG_FETCH;
133501 yymsp = yypParser->yytos;
133502 #ifndef NDEBUG
133503 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
133504 yysize = yyRuleInfo[yyruleno].nrhs;
133505 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
133506 yyRuleName[yyruleno], yymsp[-yysize].stateno);
@@ -132880,26 +133510,27 @@
133510 /* Check that the stack is large enough to grow by a single entry
133511 ** if the RHS of the rule is empty. This ensures that there is room
133512 ** enough on the stack to push the LHS value */
133513 if( yyRuleInfo[yyruleno].nrhs==0 ){
133514 #ifdef YYTRACKMAXSTACKDEPTH
133515 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133516 yypParser->yyhwm++;
133517 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
133518 }
133519 #endif
133520 #if YYSTACKDEPTH>0
133521 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
133522 yyStackOverflow(yypParser);
133523 return;
133524 }
133525 #else
133526 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
133527 if( yyGrowStack(yypParser) ){
 
133528 yyStackOverflow(yypParser);
133529 return;
133530 }
133531 yymsp = yypParser->yytos;
133532 }
133533 #endif
133534 }
133535
133536 switch( yyruleno ){
@@ -132921,19 +133552,19 @@
133552 break;
133553 case 2: /* cmdx ::= cmd */
133554 { sqlite3FinishCoding(pParse); }
133555 break;
133556 case 3: /* cmd ::= BEGIN transtype trans_opt */
133557 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);}
133558 break;
133559 case 4: /* transtype ::= */
133560 {yymsp[1].minor.yy194 = TK_DEFERRED;}
133561 break;
133562 case 5: /* transtype ::= DEFERRED */
133563 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
133564 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
133565 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
133566 break;
133567 case 8: /* cmd ::= COMMIT trans_opt */
133568 case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
133569 {sqlite3CommitTransaction(pParse);}
133570 break;
@@ -132955,11 +133586,11 @@
133586 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
133587 }
133588 break;
133589 case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
133590 {
133591 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
133592 }
133593 break;
133594 case 15: /* createkw ::= CREATE */
133595 {disableLookaside(pParse);}
133596 break;
@@ -132969,37 +133600,37 @@
133600 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
133601 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
133602 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
133603 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
133604 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
133605 case 211: /* collate ::= */ yytestcase(yyruleno==211);
133606 {yymsp[1].minor.yy194 = 0;}
133607 break;
133608 case 17: /* ifnotexists ::= IF NOT EXISTS */
133609 {yymsp[-2].minor.yy194 = 1;}
133610 break;
133611 case 18: /* temp ::= TEMP */
133612 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
133613 {yymsp[0].minor.yy194 = 1;}
133614 break;
133615 case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
133616 {
133617 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
133618 }
133619 break;
133620 case 21: /* create_table_args ::= AS select */
133621 {
133622 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
133623 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
133624 }
133625 break;
133626 case 23: /* table_options ::= WITHOUT nm */
133627 {
133628 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
133629 yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
133630 }else{
133631 yymsp[-1].minor.yy194 = 0;
133632 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
133633 }
133634 }
133635 break;
133636 case 24: /* columnname ::= nm typetoken */
@@ -133027,21 +133658,21 @@
133658 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
133659 {pParse->constraintName = yymsp[0].minor.yy0;}
133660 break;
133661 case 30: /* ccons ::= DEFAULT term */
133662 case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
133663 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
133664 break;
133665 case 31: /* ccons ::= DEFAULT LP expr RP */
133666 {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
133667 break;
133668 case 33: /* ccons ::= DEFAULT MINUS term */
133669 {
133670 ExprSpan v;
133671 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0, 0);
133672 v.zStart = yymsp[-1].minor.yy0.z;
133673 v.zEnd = yymsp[0].minor.yy190.zEnd;
133674 sqlite3AddDefaultValue(pParse,&v);
133675 }
133676 break;
133677 case 34: /* ccons ::= DEFAULT ID|INDEXED */
133678 {
@@ -133049,184 +133680,186 @@
133680 spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
133681 sqlite3AddDefaultValue(pParse,&v);
133682 }
133683 break;
133684 case 35: /* ccons ::= NOT NULL onconf */
133685 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
133686 break;
133687 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
133688 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
133689 break;
133690 case 37: /* ccons ::= UNIQUE onconf */
133691 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
133692 SQLITE_IDXTYPE_UNIQUE);}
133693 break;
133694 case 38: /* ccons ::= CHECK LP expr RP */
133695 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
133696 break;
133697 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
133698 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
133699 break;
133700 case 40: /* ccons ::= defer_subclause */
133701 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
133702 break;
133703 case 41: /* ccons ::= COLLATE ID|STRING */
133704 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
133705 break;
133706 case 44: /* refargs ::= */
133707 { yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
133708 break;
133709 case 45: /* refargs ::= refargs refarg */
133710 { yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
133711 break;
133712 case 46: /* refarg ::= MATCH nm */
133713 { yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
133714 break;
133715 case 47: /* refarg ::= ON INSERT refact */
133716 { yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
133717 break;
133718 case 48: /* refarg ::= ON DELETE refact */
133719 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
133720 break;
133721 case 49: /* refarg ::= ON UPDATE refact */
133722 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
133723 break;
133724 case 50: /* refact ::= SET NULL */
133725 { yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
133726 break;
133727 case 51: /* refact ::= SET DEFAULT */
133728 { yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
133729 break;
133730 case 52: /* refact ::= CASCADE */
133731 { yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
133732 break;
133733 case 53: /* refact ::= RESTRICT */
133734 { yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
133735 break;
133736 case 54: /* refact ::= NO ACTION */
133737 { yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
133738 break;
133739 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133740 {yymsp[-2].minor.yy194 = 0;}
133741 break;
133742 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133743 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133744 case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133745 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133746 break;
133747 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133748 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133749 case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133750 case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133751 case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
133752 {yymsp[-1].minor.yy194 = 1;}
133753 break;
133754 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133755 {yymsp[-1].minor.yy194 = 0;}
133756 break;
133757 case 61: /* tconscomma ::= COMMA */
133758 {pParse->constraintName.n = 0;}
133759 break;
133760 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
133761 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
133762 break;
133763 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
133764 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
133765 SQLITE_IDXTYPE_UNIQUE);}
133766 break;
133767 case 65: /* tcons ::= CHECK LP expr RP onconf */
133768 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
133769 break;
133770 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
133771 {
133772 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
133773 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
133774 }
133775 break;
133776 case 68: /* onconf ::= */
133777 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
133778 {yymsp[1].minor.yy194 = OE_Default;}
133779 break;
133780 case 69: /* onconf ::= ON CONFLICT resolvetype */
133781 {yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
133782 break;
133783 case 72: /* resolvetype ::= IGNORE */
133784 {yymsp[0].minor.yy194 = OE_Ignore;}
133785 break;
133786 case 73: /* resolvetype ::= REPLACE */
133787 case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
133788 {yymsp[0].minor.yy194 = OE_Replace;}
133789 break;
133790 case 74: /* cmd ::= DROP TABLE ifexists fullname */
133791 {
133792 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
133793 }
133794 break;
133795 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
133796 {
133797 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
133798 }
133799 break;
133800 case 78: /* cmd ::= DROP VIEW ifexists fullname */
133801 {
133802 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
133803 }
133804 break;
133805 case 79: /* cmd ::= select */
133806 {
133807 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
133808 sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
133809 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
133810 }
133811 break;
133812 case 80: /* select ::= with selectnowith */
133813 {
133814 Select *p = yymsp[0].minor.yy243;
133815 if( p ){
133816 p->pWith = yymsp[-1].minor.yy285;
133817 parserDoubleLinkSelect(pParse, p);
133818 }else{
133819 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
133820 }
133821 yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
133822 }
133823 break;
133824 case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
133825 {
133826 Select *pRhs = yymsp[0].minor.yy243;
133827 Select *pLhs = yymsp[-2].minor.yy243;
133828 if( pRhs && pRhs->pPrior ){
133829 SrcList *pFrom;
133830 Token x;
133831 x.n = 0;
133832 parserDoubleLinkSelect(pParse, pRhs);
133833 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
133834 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
133835 }
133836 if( pRhs ){
133837 pRhs->op = (u8)yymsp[-1].minor.yy194;
133838 pRhs->pPrior = pLhs;
133839 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
133840 pRhs->selFlags &= ~SF_MultiValue;
133841 if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1;
133842 }else{
133843 sqlite3SelectDelete(pParse->db, pLhs);
133844 }
133845 yymsp[-2].minor.yy243 = pRhs;
133846 }
133847 break;
133848 case 82: /* multiselect_op ::= UNION */
133849 case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
133850 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
133851 break;
133852 case 83: /* multiselect_op ::= UNION ALL */
133853 {yymsp[-1].minor.yy194 = TK_ALL;}
133854 break;
133855 case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
133856 {
133857 #if SELECTTRACE_ENABLED
133858 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
133859 #endif
133860 yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
133861 #if SELECTTRACE_ENABLED
133862 /* Populate the Select.zSelName[] string that is used to help with
133863 ** query planner debugging, to differentiate between multiple Select
133864 ** objects in a complex query.
133865 **
@@ -133233,464 +133866,465 @@
133866 ** If the SELECT keyword is immediately followed by a C-style comment
133867 ** then extract the first few alphanumeric characters from within that
133868 ** comment to be the zSelName value. Otherwise, the label is #N where
133869 ** is an integer that is incremented with each SELECT statement seen.
133870 */
133871 if( yymsp[-8].minor.yy243!=0 ){
133872 const char *z = s.z+6;
133873 int i;
133874 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "#%d",
133875 ++pParse->nSelect);
133876 while( z[0]==' ' ) z++;
133877 if( z[0]=='/' && z[1]=='*' ){
133878 z += 2;
133879 while( z[0]==' ' ) z++;
133880 for(i=0; sqlite3Isalnum(z[i]); i++){}
133881 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "%.*s", i, z);
133882 }
133883 }
133884 #endif /* SELECTRACE_ENABLED */
133885 }
133886 break;
133887 case 86: /* values ::= VALUES LP nexprlist RP */
133888 {
133889 yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
133890 }
133891 break;
133892 case 87: /* values ::= values COMMA LP exprlist RP */
133893 {
133894 Select *pRight, *pLeft = yymsp[-4].minor.yy243;
133895 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
133896 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
133897 if( pRight ){
133898 pRight->op = TK_ALL;
133899 pRight->pPrior = pLeft;
133900 yymsp[-4].minor.yy243 = pRight;
133901 }else{
133902 yymsp[-4].minor.yy243 = pLeft;
133903 }
133904 }
133905 break;
133906 case 88: /* distinct ::= DISTINCT */
133907 {yymsp[0].minor.yy194 = SF_Distinct;}
133908 break;
133909 case 89: /* distinct ::= ALL */
133910 {yymsp[0].minor.yy194 = SF_All;}
133911 break;
133912 case 91: /* sclp ::= */
133913 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
133914 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
133915 case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
133916 case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
133917 case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
133918 {yymsp[1].minor.yy148 = 0;}
133919 break;
133920 case 92: /* selcollist ::= sclp expr as */
133921 {
133922 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
133923 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
133924 sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
133925 }
133926 break;
133927 case 93: /* selcollist ::= sclp STAR */
133928 {
133929 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
133930 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
133931 }
133932 break;
133933 case 94: /* selcollist ::= sclp nm DOT STAR */
133934 {
133935 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0);
133936 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133937 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
133938 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
133939 }
133940 break;
133941 case 95: /* as ::= AS nm */
133942 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
133943 case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
133944 case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
133945 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
133946 break;
133947 case 97: /* from ::= */
133948 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
133949 break;
133950 case 98: /* from ::= FROM seltablist */
133951 {
133952 yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
133953 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
133954 }
133955 break;
133956 case 99: /* stl_prefix ::= seltablist joinop */
133957 {
133958 if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
133959 }
133960 break;
133961 case 100: /* stl_prefix ::= */
133962 {yymsp[1].minor.yy185 = 0;}
133963 break;
133964 case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
133965 {
133966 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133967 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
133968 }
133969 break;
133970 case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
133971 {
133972 yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133973 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
133974 }
133975 break;
133976 case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
133977 {
133978 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133979 }
133980 break;
133981 case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
133982 {
133983 if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
133984 yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
133985 }else if( yymsp[-4].minor.yy185->nSrc==1 ){
133986 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133987 if( yymsp[-6].minor.yy185 ){
133988 struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1];
133989 struct SrcList_item *pOld = yymsp[-4].minor.yy185->a;
133990 pNew->zName = pOld->zName;
133991 pNew->zDatabase = pOld->zDatabase;
133992 pNew->pSelect = pOld->pSelect;
133993 pOld->zName = pOld->zDatabase = 0;
133994 pOld->pSelect = 0;
133995 }
133996 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185);
133997 }else{
133998 Select *pSubquery;
133999 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185);
134000 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
134001 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134002 }
134003 }
134004 break;
134005 case 105: /* dbnm ::= */
134006 case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
134007 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
134008 break;
134009 case 107: /* fullname ::= nm dbnm */
134010 {yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
134011 break;
134012 case 108: /* joinop ::= COMMA|JOIN */
134013 { yymsp[0].minor.yy194 = JT_INNER; }
134014 break;
134015 case 109: /* joinop ::= JOIN_KW JOIN */
134016 {yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
134017 break;
134018 case 110: /* joinop ::= JOIN_KW nm JOIN */
134019 {yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
134020 break;
134021 case 111: /* joinop ::= JOIN_KW nm nm JOIN */
134022 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134023 break;
134024 case 112: /* on_opt ::= ON expr */
134025 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
134026 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
134027 case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
134028 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
134029 break;
134030 case 113: /* on_opt ::= */
134031 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
134032 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
134033 case 196: /* case_else ::= */ yytestcase(yyruleno==196);
134034 case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
134035 {yymsp[1].minor.yy72 = 0;}
134036 break;
134037 case 115: /* indexed_opt ::= INDEXED BY nm */
134038 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
134039 break;
134040 case 116: /* indexed_opt ::= NOT INDEXED */
134041 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
134042 break;
134043 case 117: /* using_opt ::= USING LP idlist RP */
134044 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
134045 break;
134046 case 118: /* using_opt ::= */
134047 case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
134048 {yymsp[1].minor.yy254 = 0;}
134049 break;
134050 case 120: /* orderby_opt ::= ORDER BY sortlist */
134051 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
134052 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
134053 break;
134054 case 121: /* sortlist ::= sortlist COMMA expr sortorder */
134055 {
134056 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
134057 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
134058 }
134059 break;
134060 case 122: /* sortlist ::= expr sortorder */
134061 {
134062 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
134063 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
134064 }
134065 break;
134066 case 123: /* sortorder ::= ASC */
134067 {yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
134068 break;
134069 case 124: /* sortorder ::= DESC */
134070 {yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
134071 break;
134072 case 125: /* sortorder ::= */
134073 {yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
134074 break;
134075 case 130: /* limit_opt ::= */
134076 {yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
134077 break;
134078 case 131: /* limit_opt ::= LIMIT expr */
134079 {yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
134080 break;
134081 case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
134082 {yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
134083 break;
134084 case 133: /* limit_opt ::= LIMIT expr COMMA expr */
134085 {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
134086 break;
134087 case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
134088 {
134089 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134090 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
134091 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
134092 }
134093 break;
134094 case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
134095 {
134096 sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
134097 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
134098 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
134099 sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
134100 }
134101 break;
134102 case 138: /* setlist ::= setlist COMMA nm EQ expr */
134103 {
134104 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134105 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
134106 }
134107 break;
134108 case 139: /* setlist ::= nm EQ expr */
134109 {
134110 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134111 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
134112 }
134113 yymsp[-2].minor.yy148 = yylhsminor.yy148;
134114 break;
134115 case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
134116 {
134117 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134118 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
134119 }
134120 break;
134121 case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
134122 {
134123 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134124 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
134125 }
134126 break;
134127 case 145: /* idlist_opt ::= LP idlist RP */
134128 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
134129 break;
134130 case 146: /* idlist ::= idlist COMMA nm */
134131 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
134132 break;
134133 case 147: /* idlist ::= nm */
134134 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134135 break;
134136 case 148: /* expr ::= LP expr RP */
134137 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
134138 break;
134139 case 149: /* term ::= NULL */
134140 case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
134141 case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
134142 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134143 break;
134144 case 150: /* expr ::= ID|INDEXED */
134145 case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
134146 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134147 break;
134148 case 152: /* expr ::= nm DOT nm */
134149 {
134150 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134151 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134152 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134153 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134154 }
134155 break;
134156 case 153: /* expr ::= nm DOT nm DOT nm */
134157 {
134158 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
134159 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134160 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134161 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
134162 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134163 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134164 }
134165 break;
134166 case 156: /* expr ::= VARIABLE */
134167 {
134168 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
134169 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134170 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
134171 }else{
134172 /* When doing a nested parse, one can include terms in an expression
134173 ** that look like this: #1 #2 ... These terms refer to registers
134174 ** in the virtual machine. #N is the N-th register. */
134175 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
134176 assert( t.n>=2 );
134177 spanSet(&yymsp[0].minor.yy190, &t, &t);
134178 if( pParse->nested==0 ){
134179 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
134180 yymsp[0].minor.yy190.pExpr = 0;
134181 }else{
134182 yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
134183 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
134184 }
134185 }
134186 }
134187 break;
134188 case 157: /* expr ::= expr COLLATE ID|STRING */
134189 {
134190 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134191 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134192 }
134193 break;
134194 case 158: /* expr ::= CAST LP expr AS typetoken RP */
134195 {
134196 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134197 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
134198 }
134199 break;
134200 case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
134201 {
134202 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134203 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
134204 }
134205 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
134206 spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
134207 if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){
134208 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
134209 }
134210 }
134211 yymsp[-4].minor.yy190 = yylhsminor.yy190;
134212 break;
134213 case 160: /* expr ::= ID|INDEXED LP STAR RP */
134214 {
134215 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134216 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134217 }
134218 yymsp[-3].minor.yy190 = yylhsminor.yy190;
134219 break;
134220 case 161: /* term ::= CTIME_KW */
134221 {
134222 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134223 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134224 }
134225 yymsp[0].minor.yy190 = yylhsminor.yy190;
134226 break;
134227 case 162: /* expr ::= expr AND expr */
134228 case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
134229 case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
134230 case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
134231 case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
134232 case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
134233 case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
134234 case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
134235 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
134236 break;
134237 case 170: /* likeop ::= LIKE_KW|MATCH */
134238 {yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
134239 break;
134240 case 171: /* likeop ::= NOT LIKE_KW|MATCH */
134241 {yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
134242 break;
134243 case 172: /* expr ::= expr likeop expr */
134244 {
134245 ExprList *pList;
134246 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134247 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134248 yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
134249 exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134250 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134251 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
134252 }
134253 break;
134254 case 173: /* expr ::= expr likeop expr ESCAPE expr */
134255 {
134256 ExprList *pList;
134257 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134258 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134259 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134260 yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy392.eOperator);
134261 exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134262 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134263 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
134264 }
134265 break;
134266 case 174: /* expr ::= expr ISNULL|NOTNULL */
134267 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
134268 break;
134269 case 175: /* expr ::= expr NOT NULL */
134270 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
134271 break;
134272 case 176: /* expr ::= expr IS expr */
134273 {
134274 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134275 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
134276 }
134277 break;
134278 case 177: /* expr ::= expr IS NOT expr */
134279 {
134280 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134281 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
134282 }
134283 break;
134284 case 178: /* expr ::= NOT expr */
134285 case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
134286 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134287 break;
134288 case 180: /* expr ::= MINUS expr */
134289 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134290 break;
134291 case 181: /* expr ::= PLUS expr */
134292 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134293 break;
134294 case 182: /* between_op ::= BETWEEN */
134295 case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
134296 {yymsp[0].minor.yy194 = 0;}
134297 break;
134298 case 184: /* expr ::= expr between_op expr AND expr */
134299 {
134300 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134301 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134302 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134303 if( yymsp[-4].minor.yy190.pExpr ){
134304 yymsp[-4].minor.yy190.pExpr->x.pList = pList;
134305 }else{
134306 sqlite3ExprListDelete(pParse->db, pList);
134307 }
134308 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134309 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134310 }
134311 break;
134312 case 187: /* expr ::= expr in_op LP exprlist RP */
134313 {
134314 if( yymsp[-1].minor.yy148==0 ){
134315 /* Expressions of the form
134316 **
134317 ** expr1 IN ()
134318 ** expr1 NOT IN ()
134319 **
134320 ** simplify to constants 0 (false) and 1 (true), respectively,
134321 ** regardless of the value of expr1.
134322 */
134323 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);
134324 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy194]);
134325 }else if( yymsp[-1].minor.yy148->nExpr==1 ){
134326 /* Expressions of the form:
134327 **
134328 ** expr1 IN (?1)
134329 ** expr1 NOT IN (?2)
134330 **
@@ -133703,417 +134337,421 @@
134337 ** But, the RHS of the == or <> is marked with the EP_Generic flag
134338 ** so that it may not contribute to the computation of comparison
134339 ** affinity or the collating sequence to use for comparison. Otherwise,
134340 ** the semantics would be subtly different from IN or NOT IN.
134341 */
134342 Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;
134343 yymsp[-1].minor.yy148->a[0].pExpr = 0;
134344 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134345 /* pRHS cannot be NULL because a malloc error would have been detected
134346 ** before now and control would have never reached this point */
134347 if( ALWAYS(pRHS) ){
134348 pRHS->flags &= ~EP_Collate;
134349 pRHS->flags |= EP_Generic;
134350 }
134351 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS, 0);
134352 }else{
134353 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134354 if( yymsp[-4].minor.yy190.pExpr ){
134355 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;
134356 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134357 }else{
134358 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134359 }
134360 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134361 }
134362 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134363 }
134364 break;
134365 case 188: /* expr ::= LP select RP */
134366 {
134367 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134368 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134369 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134370 }
134371 break;
134372 case 189: /* expr ::= expr in_op LP select RP */
134373 {
134374 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134375 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134376 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134377 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134378 }
134379 break;
134380 case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
134381 {
134382 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
134383 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
134384 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134385 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134386 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134387 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134388 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
134389 }
134390 break;
134391 case 191: /* expr ::= EXISTS LP select RP */
134392 {
134393 Expr *p;
134394 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134395 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134396 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
134397 }
134398 break;
134399 case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
134400 {
134401 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134402 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134403 if( yymsp[-4].minor.yy190.pExpr ){
134404 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
134405 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134406 }else{
134407 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134408 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
134409 }
134410 }
134411 break;
134412 case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
134413 {
134414 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134415 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134416 }
134417 break;
134418 case 194: /* case_exprlist ::= WHEN expr THEN expr */
134419 {
134420 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134421 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
134422 }
134423 break;
134424 case 197: /* case_operand ::= expr */
134425 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
134426 break;
134427 case 200: /* nexprlist ::= nexprlist COMMA expr */
134428 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
134429 break;
134430 case 201: /* nexprlist ::= expr */
134431 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
134432 break;
134433 case 203: /* paren_exprlist ::= LP exprlist RP */
134434 case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
134435 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134436 break;
134437 case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134438 {
134439 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
134440 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134441 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134442 }
134443 break;
134444 case 205: /* uniqueflag ::= UNIQUE */
134445 case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
134446 {yymsp[0].minor.yy194 = OE_Abort;}
134447 break;
134448 case 206: /* uniqueflag ::= */
134449 {yymsp[1].minor.yy194 = OE_None;}
134450 break;
134451 case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
134452 {
134453 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134454 }
134455 break;
134456 case 210: /* eidlist ::= nm collate sortorder */
134457 {
134458 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134459 }
134460 break;
134461 case 213: /* cmd ::= DROP INDEX ifexists fullname */
134462 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134463 break;
134464 case 214: /* cmd ::= VACUUM */
134465 case 215: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==215);
 
 
 
134466 {sqlite3Vacuum(pParse);}
134467 break;
134468 case 216: /* cmd ::= PRAGMA nm dbnm */
134469 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
134470 break;
134471 case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134472 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
134473 break;
134474 case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134475 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
134476 break;
134477 case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134478 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
134479 break;
134480 case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134481 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
134482 break;
134483 case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134484 {
134485 Token all;
134486 all.z = yymsp[-3].minor.yy0.z;
134487 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
134488 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
134489 }
134490 break;
134491 case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134492 {
134493 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);
134494 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
134495 }
134496 break;
134497 case 225: /* trigger_time ::= BEFORE */
134498 { yymsp[0].minor.yy194 = TK_BEFORE; }
134499 break;
134500 case 226: /* trigger_time ::= AFTER */
134501 { yymsp[0].minor.yy194 = TK_AFTER; }
134502 break;
134503 case 227: /* trigger_time ::= INSTEAD OF */
134504 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
134505 break;
134506 case 228: /* trigger_time ::= */
134507 { yymsp[1].minor.yy194 = TK_BEFORE; }
134508 break;
134509 case 229: /* trigger_event ::= DELETE|INSERT */
134510 case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
134511 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134512 break;
134513 case 231: /* trigger_event ::= UPDATE OF idlist */
134514 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134515 break;
134516 case 232: /* when_clause ::= */
134517 case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
134518 { yymsp[1].minor.yy72 = 0; }
134519 break;
134520 case 233: /* when_clause ::= WHEN expr */
134521 case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
134522 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134523 break;
134524 case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134525 {
134526 assert( yymsp[-2].minor.yy145!=0 );
134527 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134528 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134529 }
134530 break;
134531 case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
134532 {
134533 assert( yymsp[-1].minor.yy145!=0 );
134534 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134535 }
134536 break;
134537 case 236: /* trnm ::= nm DOT nm */
134538 {
134539 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
134540 sqlite3ErrorMsg(pParse,
134541 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
134542 "statements within triggers");
134543 }
134544 break;
134545 case 237: /* tridxby ::= INDEXED BY nm */
134546 {
134547 sqlite3ErrorMsg(pParse,
134548 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
134549 "within triggers");
134550 }
134551 break;
134552 case 238: /* tridxby ::= NOT INDEXED */
134553 {
134554 sqlite3ErrorMsg(pParse,
134555 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
134556 "within triggers");
134557 }
134558 break;
134559 case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134560 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134561 break;
134562 case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134563 {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*/}
134564 break;
134565 case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134566 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134567 break;
134568 case 242: /* trigger_cmd ::= select */
134569 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134570 break;
134571 case 243: /* expr ::= RAISE LP IGNORE RP */
134572 {
134573 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134574 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134575 if( yymsp[-3].minor.yy190.pExpr ){
134576 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134577 }
134578 }
134579 break;
134580 case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
134581 {
134582 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134583 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134584 if( yymsp[-5].minor.yy190.pExpr ) {
134585 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134586 }
134587 }
134588 break;
134589 case 245: /* raisetype ::= ROLLBACK */
134590 {yymsp[0].minor.yy194 = OE_Rollback;}
134591 break;
134592 case 247: /* raisetype ::= FAIL */
134593 {yymsp[0].minor.yy194 = OE_Fail;}
134594 break;
134595 case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
134596 {
134597 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134598 }
134599 break;
134600 case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134601 {
134602 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134603 }
134604 break;
134605 case 250: /* cmd ::= DETACH database_kw_opt expr */
134606 {
134607 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134608 }
134609 break;
134610 case 253: /* cmd ::= REINDEX */
134611 {sqlite3Reindex(pParse, 0, 0);}
134612 break;
134613 case 254: /* cmd ::= REINDEX nm dbnm */
134614 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134615 break;
134616 case 255: /* cmd ::= ANALYZE */
134617 {sqlite3Analyze(pParse, 0, 0);}
134618 break;
134619 case 256: /* cmd ::= ANALYZE nm dbnm */
134620 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134621 break;
134622 case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134623 {
134624 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
134625 }
134626 break;
134627 case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134628 {
134629 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
134630 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
134631 }
134632 break;
134633 case 259: /* add_column_fullname ::= fullname */
134634 {
134635 disableLookaside(pParse);
134636 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134637 }
134638 break;
134639 case 260: /* cmd ::= create_vtab */
134640 {sqlite3VtabFinishParse(pParse,0);}
134641 break;
134642 case 261: /* cmd ::= create_vtab LP vtabarglist RP */
134643 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134644 break;
134645 case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134646 {
134647 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134648 }
134649 break;
134650 case 263: /* vtabarg ::= */
134651 {sqlite3VtabArgInit(pParse);}
134652 break;
134653 case 264: /* vtabargtoken ::= ANY */
134654 case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134655 case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
134656 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134657 break;
134658 case 267: /* with ::= */
134659 {yymsp[1].minor.yy285 = 0;}
134660 break;
134661 case 268: /* with ::= WITH wqlist */
134662 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134663 break;
134664 case 269: /* with ::= WITH RECURSIVE wqlist */
134665 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134666 break;
134667 case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
134668 {
134669 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134670 }
134671 break;
134672 case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134673 {
134674 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134675 }
134676 break;
134677 default:
134678 /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134679 /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134680 /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134681 /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134682 /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134683 /* (277) explain ::= */ yytestcase(yyruleno==277);
134684 /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134685 /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134686 /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134687 /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134688 /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134689 /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134690 /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134691 /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134692 /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134693 /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134694 /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134695 /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134696 /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134697 /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134698 /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134699 /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134700 /* (294) carglist ::= */ yytestcase(yyruleno==294);
134701 /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134702 /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134703 /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134704 /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134705 /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134706 /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134707 /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134708 /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134709 /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134710 /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134711 /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134712 /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134713 /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134714 /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134715 /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134716 /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134717 /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134718 /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134719 /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134720 /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134721 /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134722 /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134723 /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134724 /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134725 /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134726 /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134727 /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134728 /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134729 /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134730 /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134731 /* (325) anylist ::= */ yytestcase(yyruleno==325);
134732 /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134733 /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
134734 break;
134735 /********** End reduce actions ************************************************/
134736 };
134737 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134738 yygoto = yyRuleInfo[yyruleno].lhs;
134739 yysize = yyRuleInfo[yyruleno].nrhs;
134740 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
134741 if( yyact <= YY_MAX_SHIFTREDUCE ){
134742 if( yyact>YY_MAX_SHIFT ){
134743 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134744 }
134745 yymsp -= yysize-1;
134746 yypParser->yytos = yymsp;
134747 yymsp->stateno = (YYACTIONTYPE)yyact;
134748 yymsp->major = (YYCODETYPE)yygoto;
134749 yyTraceShift(yypParser, yyact);
134750 }else{
134751 assert( yyact == YY_ACCEPT_ACTION );
134752 yypParser->yytos -= yysize;
134753 yy_accept(yypParser);
134754 }
134755 }
134756
134757 /*
@@ -134127,11 +134765,11 @@
134765 #ifndef NDEBUG
134766 if( yyTraceFILE ){
134767 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
134768 }
134769 #endif
134770 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
134771 /* Here code is inserted which will be executed whenever the
134772 ** parser fails */
134773 /************ Begin %parse_failure code ***************************************/
134774 /************ End %parse_failure code *****************************************/
134775 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134167,11 +134805,14 @@
134805 #ifndef NDEBUG
134806 if( yyTraceFILE ){
134807 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
134808 }
134809 #endif
134810 #ifndef YYNOERRORRECOVERY
134811 yypParser->yyerrcnt = -1;
134812 #endif
134813 assert( yypParser->yytos==yypParser->yystack );
134814 /* Here code is inserted which will be executed whenever the
134815 ** parser accepts */
134816 /*********** Begin %parse_accept code *****************************************/
134817 /*********** End %parse_accept code *******************************************/
134818 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134210,32 +134851,12 @@
134851 #ifdef YYERRORSYMBOL
134852 int yyerrorhit = 0; /* True if yymajor has invoked an error */
134853 #endif
134854 yyParser *yypParser; /* The parser */
134855
 
134856 yypParser = (yyParser*)yyp;
134857 assert( yypParser->yytos!=0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134858 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
134859 yyendofinput = (yymajor==0);
134860 #endif
134861 sqlite3ParserARG_STORE;
134862
@@ -134246,11 +134867,10 @@
134867 #endif
134868
134869 do{
134870 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
134871 if( yyact <= YY_MAX_SHIFTREDUCE ){
 
134872 yy_shift(yypParser,yyact,yymajor,yyminor);
134873 #ifndef YYNOERRORRECOVERY
134874 yypParser->yyerrcnt--;
134875 #endif
134876 yymajor = YYNOCODE;
@@ -134288,11 +134908,11 @@
134908 **
134909 */
134910 if( yypParser->yyerrcnt<0 ){
134911 yy_syntax_error(yypParser,yymajor,yyminor);
134912 }
134913 yymx = yypParser->yytos->major;
134914 if( yymx==YYERRORSYMBOL || yyerrorhit ){
134915 #ifndef NDEBUG
134916 if( yyTraceFILE ){
134917 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
134918 yyTracePrompt,yyTokenName[yymajor]);
@@ -134299,22 +134919,24 @@
134919 }
134920 #endif
134921 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
134922 yymajor = YYNOCODE;
134923 }else{
134924 while( yypParser->yytos >= &yypParser->yystack
134925 && yymx != YYERRORSYMBOL
134926 && (yyact = yy_find_reduce_action(
134927 yypParser->yytos->stateno,
 
134928 YYERRORSYMBOL)) >= YY_MIN_REDUCE
134929 ){
134930 yy_pop_parser_stack(yypParser);
134931 }
134932 if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
134933 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134934 yy_parse_failed(yypParser);
134935 #ifndef YYNOERRORRECOVERY
134936 yypParser->yyerrcnt = -1;
134937 #endif
134938 yymajor = YYNOCODE;
134939 }else if( yymx!=YYERRORSYMBOL ){
134940 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
134941 }
134942 }
@@ -134347,22 +134969,27 @@
134969 }
134970 yypParser->yyerrcnt = 3;
134971 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134972 if( yyendofinput ){
134973 yy_parse_failed(yypParser);
134974 #ifndef YYNOERRORRECOVERY
134975 yypParser->yyerrcnt = -1;
134976 #endif
134977 }
134978 yymajor = YYNOCODE;
134979 #endif
134980 }
134981 }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
134982 #ifndef NDEBUG
134983 if( yyTraceFILE ){
134984 yyStackEntry *i;
134985 char cDiv = '[';
134986 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
134987 for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
134988 fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
134989 cDiv = ' ';
134990 }
134991 fprintf(yyTraceFILE,"]\n");
134992 }
134993 #endif
134994 return;
134995 }
@@ -136680,10 +137307,13 @@
137307 }
137308 if( !sqlite3SafetyCheckSickOrOk(db) ){
137309 return SQLITE_MISUSE_BKPT;
137310 }
137311 sqlite3_mutex_enter(db->mutex);
137312 if( db->mTrace & SQLITE_TRACE_CLOSE ){
137313 db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);
137314 }
137315
137316 /* Force xDisconnect calls on all virtual tables */
137317 disconnectAllVtab(db);
137318
137319 /* If a transaction is open, the disconnectAllVtab() call above
@@ -137448,11 +138078,12 @@
138078 **
138079 ** A NULL trace function means that no tracing is executes. A non-NULL
138080 ** trace is a pointer to a function that is invoked at the start of each
138081 ** SQL statement.
138082 */
138083 #ifndef SQLITE_OMIT_DEPRECATED
138084 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){
138085 void *pOld;
138086
138087 #ifdef SQLITE_ENABLE_API_ARMOR
138088 if( !sqlite3SafetyCheckOk(db) ){
138089 (void)SQLITE_MISUSE_BKPT;
@@ -137459,15 +138090,39 @@
138090 return 0;
138091 }
138092 #endif
138093 sqlite3_mutex_enter(db->mutex);
138094 pOld = db->pTraceArg;
138095 db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;
138096 db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;
138097 db->pTraceArg = pArg;
138098 sqlite3_mutex_leave(db->mutex);
138099 return pOld;
138100 }
138101 #endif /* SQLITE_OMIT_DEPRECATED */
138102
138103 /* Register a trace callback using the version-2 interface.
138104 */
138105 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
138106 sqlite3 *db, /* Trace this connection */
138107 unsigned mTrace, /* Mask of events to be traced */
138108 int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */
138109 void *pArg /* Context */
138110 ){
138111 #ifdef SQLITE_ENABLE_API_ARMOR
138112 if( !sqlite3SafetyCheckOk(db) ){
138113 return SQLITE_MISUSE_BKPT;
138114 }
138115 #endif
138116 sqlite3_mutex_enter(db->mutex);
138117 db->mTrace = mTrace;
138118 db->xTrace = xTrace;
138119 db->pTraceArg = pArg;
138120 sqlite3_mutex_leave(db->mutex);
138121 return SQLITE_OK;
138122 }
138123
138124 /*
138125 ** Register a profile function. The pArg from the previously registered
138126 ** profile function is returned.
138127 **
138128 ** A NULL profile function means that no profiling is executes. A non-NULL
@@ -161881,10 +162536,57 @@
162536 }
162537 return f;
162538 }
162539 #endif /* !defined(SQLITE_RTREE_INT_ONLY) */
162540
162541 /*
162542 ** A constraint has failed while inserting a row into an rtree table.
162543 ** Assuming no OOM error occurs, this function sets the error message
162544 ** (at pRtree->base.zErrMsg) to an appropriate value and returns
162545 ** SQLITE_CONSTRAINT.
162546 **
162547 ** Parameter iCol is the index of the leftmost column involved in the
162548 ** constraint failure. If it is 0, then the constraint that failed is
162549 ** the unique constraint on the id column. Otherwise, it is the rtree
162550 ** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.
162551 **
162552 ** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.
162553 */
162554 static int rtreeConstraintError(Rtree *pRtree, int iCol){
162555 sqlite3_stmt *pStmt = 0;
162556 char *zSql;
162557 int rc;
162558
162559 assert( iCol==0 || iCol%2 );
162560 zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName);
162561 if( zSql ){
162562 rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);
162563 }else{
162564 rc = SQLITE_NOMEM;
162565 }
162566 sqlite3_free(zSql);
162567
162568 if( rc==SQLITE_OK ){
162569 if( iCol==0 ){
162570 const char *zCol = sqlite3_column_name(pStmt, 0);
162571 pRtree->base.zErrMsg = sqlite3_mprintf(
162572 "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol
162573 );
162574 }else{
162575 const char *zCol1 = sqlite3_column_name(pStmt, iCol);
162576 const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);
162577 pRtree->base.zErrMsg = sqlite3_mprintf(
162578 "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2
162579 );
162580 }
162581 }
162582
162583 sqlite3_finalize(pStmt);
162584 return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);
162585 }
162586
162587
162588
162589 /*
162590 ** The xUpdate method for rtree module virtual tables.
162591 */
162592 static int rtreeUpdate(
@@ -161931,11 +162633,11 @@
162633 if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
162634 for(ii=0; ii<nData-4; ii+=2){
162635 cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
162636 cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
162637 if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
162638 rc = rtreeConstraintError(pRtree, ii+1);
162639 goto constraint;
162640 }
162641 }
162642 }else
162643 #endif
@@ -161942,11 +162644,11 @@
162644 {
162645 for(ii=0; ii<nData-4; ii+=2){
162646 cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
162647 cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
162648 if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
162649 rc = rtreeConstraintError(pRtree, ii+1);
162650 goto constraint;
162651 }
162652 }
162653 }
162654
@@ -161963,11 +162665,11 @@
162665 rc = sqlite3_reset(pRtree->pReadRowid);
162666 if( SQLITE_ROW==steprc ){
162667 if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
162668 rc = rtreeDeleteRowid(pRtree, cell.iRowid);
162669 }else{
162670 rc = rtreeConstraintError(pRtree, 0);
162671 goto constraint;
162672 }
162673 }
162674 }
162675 bHaveRowid = 1;
@@ -162046,10 +162748,15 @@
162748 char *zSql;
162749 sqlite3_stmt *p;
162750 int rc;
162751 i64 nRow = 0;
162752
162753 if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1",
162754 0,0,0,0,0,0)==SQLITE_ERROR ){
162755 pRtree->nRowEst = RTREE_DEFAULT_ROWEST;
162756 return SQLITE_OK;
162757 }
162758 zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
162759 if( zSql==0 ){
162760 rc = SQLITE_NOMEM;
162761 }else{
162762 rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
@@ -163977,10 +164684,48 @@
164684 ** table exists but is not correctly populated, the value of the *pnOne
164685 ** output variable during stage 1 is undefined.
164686 */
164687 SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
164688
164689 /*
164690 ** Obtain an indication as to the current stage of an RBU update or vacuum.
164691 ** This function always returns one of the SQLITE_RBU_STATE_XXX constants
164692 ** defined in this file. Return values should be interpreted as follows:
164693 **
164694 ** SQLITE_RBU_STATE_OAL:
164695 ** RBU is currently building a *-oal file. The next call to sqlite3rbu_step()
164696 ** may either add further data to the *-oal file, or compute data that will
164697 ** be added by a subsequent call.
164698 **
164699 ** SQLITE_RBU_STATE_MOVE:
164700 ** RBU has finished building the *-oal file. The next call to sqlite3rbu_step()
164701 ** will move the *-oal file to the equivalent *-wal path. If the current
164702 ** operation is an RBU update, then the updated version of the database
164703 ** file will become visible to ordinary SQLite clients following the next
164704 ** call to sqlite3rbu_step().
164705 **
164706 ** SQLITE_RBU_STATE_CHECKPOINT:
164707 ** RBU is currently performing an incremental checkpoint. The next call to
164708 ** sqlite3rbu_step() will copy a page of data from the *-wal file into
164709 ** the target database file.
164710 **
164711 ** SQLITE_RBU_STATE_DONE:
164712 ** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()
164713 ** will immediately return SQLITE_DONE.
164714 **
164715 ** SQLITE_RBU_STATE_ERROR:
164716 ** An error has occurred. Any subsequent calls to sqlite3rbu_step() will
164717 ** immediately return the SQLite error code associated with the error.
164718 */
164719 #define SQLITE_RBU_STATE_OAL 1
164720 #define SQLITE_RBU_STATE_MOVE 2
164721 #define SQLITE_RBU_STATE_CHECKPOINT 3
164722 #define SQLITE_RBU_STATE_DONE 4
164723 #define SQLITE_RBU_STATE_ERROR 5
164724
164725 SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *pRbu);
164726
164727 /*
164728 ** Create an RBU VFS named zName that accesses the underlying file-system
164729 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
164730 ** then the new RBU VFS uses the default system VFS to access the file-system.
164731 ** The new object is registered as a non-default VFS with SQLite before
@@ -164872,16 +165617,18 @@
165617 */
165618 static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
165619 int rc;
165620 memset(pIter, 0, sizeof(RbuObjIter));
165621
165622 rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165623 sqlite3_mprintf(
165624 "SELECT rbu_target_name(name, type='view') AS target, name "
165625 "FROM sqlite_master "
165626 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
165627 " %s "
165628 "ORDER BY name"
165629 , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : ""));
165630
165631 if( rc==SQLITE_OK ){
165632 rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
165633 "SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' "
165634 " FROM main.sqlite_master "
@@ -166456,13 +167203,13 @@
167203 #if SQLITE_ENABLE_8_3_NAMES<2
167204 if( sqlite3_uri_boolean(zBase, "8_3_names", 0) )
167205 #endif
167206 {
167207 int i, sz;
167208 sz = (int)strlen(z)&0xffffff;
167209 for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
167210 if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);
167211 }
167212 #endif
167213 }
167214
167215 /*
@@ -167504,34 +168251,11 @@
168251 }
168252
168253 if( p->rc==SQLITE_OK ){
168254 if( p->eStage==RBU_STAGE_OAL ){
168255 sqlite3 *db = p->dbMain;
168256 p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168257
168258 /* Point the object iterator at the first object */
168259 if( p->rc==SQLITE_OK ){
168260 p->rc = rbuObjIterFirst(p, &p->objiter);
168261 }
@@ -167538,16 +168262,38 @@
168262
168263 /* If the RBU database contains no data_xxx tables, declare the RBU
168264 ** update finished. */
168265 if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
168266 p->rc = SQLITE_DONE;
168267 p->eStage = RBU_STAGE_DONE;
168268 }else{
168269 if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){
168270 rbuCopyPragma(p, "page_size");
168271 rbuCopyPragma(p, "auto_vacuum");
168272 }
168273
168274 /* Open transactions both databases. The *-oal file is opened or
168275 ** created at this point. */
168276 if( p->rc==SQLITE_OK ){
168277 p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
168278 }
168279
168280 /* Check if the main database is a zipvfs db. If it is, set the upper
168281 ** level pager to use "journal_mode=off". This prevents it from
168282 ** generating a large journal using a temp file. */
168283 if( p->rc==SQLITE_OK ){
168284 int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
168285 if( frc==SQLITE_OK ){
168286 p->rc = sqlite3_exec(
168287 db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
168288 }
168289 }
168290
168291 if( p->rc==SQLITE_OK ){
168292 rbuSetupOal(p, pState);
168293 }
168294 }
 
 
 
 
 
168295 }else if( p->eStage==RBU_STAGE_MOVE ){
168296 /* no-op */
168297 }else if( p->eStage==RBU_STAGE_CKPT ){
168298 rbuSetupCheckpoint(p, pState);
168299 }else if( p->eStage==RBU_STAGE_DONE ){
@@ -167709,14 +168455,44 @@
168455
168456 default:
168457 assert( 0 );
168458 }
168459 }
168460
168461 /*
168462 ** Return the current state of the RBU vacuum or update operation.
168463 */
168464 SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *p){
168465 int aRes[] = {
168466 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,
168467 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE
168468 };
168469
168470 assert( RBU_STAGE_OAL==1 );
168471 assert( RBU_STAGE_MOVE==2 );
168472 assert( RBU_STAGE_CKPT==4 );
168473 assert( RBU_STAGE_DONE==5 );
168474 assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );
168475 assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );
168476 assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );
168477 assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );
168478
168479 if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){
168480 return SQLITE_RBU_STATE_ERROR;
168481 }else{
168482 assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );
168483 assert( p->eStage==RBU_STAGE_OAL
168484 || p->eStage==RBU_STAGE_MOVE
168485 || p->eStage==RBU_STAGE_CKPT
168486 || p->eStage==RBU_STAGE_DONE
168487 );
168488 return aRes[p->eStage];
168489 }
168490 }
168491
168492 SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){
168493 int rc = p->rc;
 
168494 if( rc==SQLITE_DONE ) return SQLITE_OK;
168495
168496 assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
168497 if( p->eStage==RBU_STAGE_OAL ){
168498 assert( rc!=SQLITE_DONE );
@@ -168694,14 +169470,14 @@
169470 **
169471 ** '/1c2/000/' // Left-most child of 451st child of root
169472 */
169473 #define VTAB_SCHEMA \
169474 "CREATE TABLE xx( " \
169475 " name TEXT, /* Name of table or index */" \
169476 " path TEXT, /* Path to page from root */" \
169477 " pageno INTEGER, /* Page number */" \
169478 " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
169479 " ncell INTEGER, /* Cells on page (0 for overflow) */" \
169480 " payload INTEGER, /* Bytes of payload on this page */" \
169481 " unused INTEGER, /* Bytes of unused space on this page */" \
169482 " mx_payload INTEGER, /* Largest payload size of all cells */" \
169483 " pgoffset INTEGER, /* Offset of page in file */" \
@@ -175195,10 +175971,29 @@
175971 #endif /* SQLITE_DEBUG */
175972
175973 /****************************************************************************
175974 ** Scalar SQL function implementations
175975 ****************************************************************************/
175976
175977 /*
175978 ** Implementation of the json_QUOTE(VALUE) function. Return a JSON value
175979 ** corresponding to the SQL value input. Mostly this means putting
175980 ** double-quotes around strings and returning the unquoted string "null"
175981 ** when given a NULL input.
175982 */
175983 static void jsonQuoteFunc(
175984 sqlite3_context *ctx,
175985 int argc,
175986 sqlite3_value **argv
175987 ){
175988 JsonString jx;
175989
175990 jsonInit(&jx, ctx);
175991 jsonAppendValue(&jx, argv[0]);
175992 jsonResult(&jx);
175993 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
175994 }
175995
175996 /*
175997 ** Implementation of the json_array(VALUE,...) function. Return a JSON
175998 ** array that contains all values given in arguments. Or if any argument
175999 ** is a BLOB, throw an error.
@@ -176109,10 +176904,11 @@
176904 { "json_array_length", 1, 0, jsonArrayLengthFunc },
176905 { "json_array_length", 2, 0, jsonArrayLengthFunc },
176906 { "json_extract", -1, 0, jsonExtractFunc },
176907 { "json_insert", -1, 0, jsonSetFunc },
176908 { "json_object", -1, 0, jsonObjectFunc },
176909 { "json_quote", 1, 0, jsonQuoteFunc },
176910 { "json_remove", -1, 0, jsonRemoveFunc },
176911 { "json_replace", -1, 0, jsonReplaceFunc },
176912 { "json_set", -1, 1, jsonSetFunc },
176913 { "json_type", 1, 0, jsonTypeFunc },
176914 { "json_type", 2, 0, jsonTypeFunc },
@@ -177458,11 +178254,10 @@
178254 static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
178255 static int sqlite3Fts5ExprPopulatePoslists(
178256 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
178257 );
178258 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
 
178259
178260 static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
178261
178262 static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
178263
@@ -177874,21 +178669,22 @@
178669 typedef struct fts5yyStackEntry fts5yyStackEntry;
178670
178671 /* The state of the parser is completely contained in an instance of
178672 ** the following structure */
178673 struct fts5yyParser {
178674 fts5yyStackEntry *fts5yytos; /* Pointer to top element of the stack */
178675 #ifdef fts5YYTRACKMAXSTACKDEPTH
178676 int fts5yyhwm; /* High-water mark of the stack */
178677 #endif
178678 #ifndef fts5YYNOERRORRECOVERY
178679 int fts5yyerrcnt; /* Shifts left before out of the error */
178680 #endif
178681 sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
178682 #if fts5YYSTACKDEPTH<=0
178683 int fts5yystksz; /* Current side of the stack */
178684 fts5yyStackEntry *fts5yystack; /* The parser's stack */
178685 fts5yyStackEntry fts5yystk0; /* First stack entry */
178686 #else
178687 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
178688 #endif
178689 };
178690 typedef struct fts5yyParser fts5yyParser;
@@ -177971,28 +178767,38 @@
178767 #endif /* NDEBUG */
178768
178769
178770 #if fts5YYSTACKDEPTH<=0
178771 /*
178772 ** Try to increase the size of the parser stack. Return the number
178773 ** of errors. Return 0 on success.
178774 */
178775 static int fts5yyGrowStack(fts5yyParser *p){
178776 int newSize;
178777 int idx;
178778 fts5yyStackEntry *pNew;
178779
178780 newSize = p->fts5yystksz*2 + 100;
178781 idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;
178782 if( p->fts5yystack==&p->fts5yystk0 ){
178783 pNew = malloc(newSize*sizeof(pNew[0]));
178784 if( pNew ) pNew[0] = p->fts5yystk0;
178785 }else{
178786 pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
178787 }
178788 if( pNew ){
178789 p->fts5yystack = pNew;
178790 p->fts5yytos = &p->fts5yystack[idx];
178791 #ifndef NDEBUG
178792 if( fts5yyTraceFILE ){
178793 fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
178794 fts5yyTracePrompt, p->fts5yystksz, newSize);
178795 }
178796 #endif
178797 p->fts5yystksz = newSize;
178798 }
178799 return pNew==0;
178800 }
178801 #endif
178802
178803 /* Datatype of the argument to the memory allocated passed as the
178804 ** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by
@@ -178017,19 +178823,28 @@
178823 */
178824 static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
178825 fts5yyParser *pParser;
178826 pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
178827 if( pParser ){
 
178828 #ifdef fts5YYTRACKMAXSTACKDEPTH
178829 pParser->fts5yyhwm = 0;
178830 #endif
178831 #if fts5YYSTACKDEPTH<=0
178832 pParser->fts5yytos = NULL;
178833 pParser->fts5yystack = NULL;
178834 pParser->fts5yystksz = 0;
178835 if( fts5yyGrowStack(pParser) ){
178836 pParser->fts5yystack = &pParser->fts5yystk0;
178837 pParser->fts5yystksz = 1;
178838 }
178839 #endif
178840 #ifndef fts5YYNOERRORRECOVERY
178841 pParser->fts5yyerrcnt = -1;
178842 #endif
178843 pParser->fts5yytos = pParser->fts5yystack;
178844 pParser->fts5yystack[0].stateno = 0;
178845 pParser->fts5yystack[0].major = 0;
178846 }
178847 return pParser;
178848 }
178849
178850 /* The following function deletes the "minor type" or semantic value
@@ -178097,12 +178912,13 @@
178912 ** If there is a destructor routine associated with the token which
178913 ** is popped from the stack, then call it.
178914 */
178915 static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
178916 fts5yyStackEntry *fts5yytos;
178917 assert( pParser->fts5yytos!=0 );
178918 assert( pParser->fts5yytos > pParser->fts5yystack );
178919 fts5yytos = pParser->fts5yytos--;
178920 #ifndef NDEBUG
178921 if( fts5yyTraceFILE ){
178922 fprintf(fts5yyTraceFILE,"%sPopping %s\n",
178923 fts5yyTracePrompt,
178924 fts5yyTokenName[fts5yytos->major]);
@@ -178125,13 +178941,13 @@
178941 ){
178942 fts5yyParser *pParser = (fts5yyParser*)p;
178943 #ifndef fts5YYPARSEFREENEVERNULL
178944 if( pParser==0 ) return;
178945 #endif
178946 while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);
178947 #if fts5YYSTACKDEPTH<=0
178948 if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);
178949 #endif
178950 (*freeProc)((void*)pParser);
178951 }
178952
178953 /*
@@ -178138,11 +178954,11 @@
178954 ** Return the peak depth of the stack for a parser.
178955 */
178956 #ifdef fts5YYTRACKMAXSTACKDEPTH
178957 static int sqlite3Fts5ParserStackPeak(void *p){
178958 fts5yyParser *pParser = (fts5yyParser*)p;
178959 return pParser->fts5yyhwm;
178960 }
178961 #endif
178962
178963 /*
178964 ** Find the appropriate action for a parser given the terminal
@@ -178151,11 +178967,11 @@
178967 static unsigned int fts5yy_find_shift_action(
178968 fts5yyParser *pParser, /* The parser */
178969 fts5YYCODETYPE iLookAhead /* The look-ahead token */
178970 ){
178971 int i;
178972 int stateno = pParser->fts5yytos->stateno;
178973
178974 if( stateno>=fts5YY_MIN_REDUCE ) return stateno;
178975 assert( stateno <= fts5YY_SHIFT_COUNT );
178976 do{
178977 i = fts5yy_shift_ofst[stateno];
@@ -178244,17 +179060,17 @@
179060 /*
179061 ** The following routine is called if the stack overflows.
179062 */
179063 static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
179064 sqlite3Fts5ParserARG_FETCH;
179065 fts5yypParser->fts5yytos--;
179066 #ifndef NDEBUG
179067 if( fts5yyTraceFILE ){
179068 fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
179069 }
179070 #endif
179071 while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
179072 /* Here code is inserted which will execute if the parser
179073 ** stack every overflows */
179074 /******** Begin %stack_overflow code ******************************************/
179075
179076 sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
@@ -178268,15 +179084,15 @@
179084 #ifndef NDEBUG
179085 static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){
179086 if( fts5yyTraceFILE ){
179087 if( fts5yyNewState<fts5YYNSTATE ){
179088 fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n",
179089 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major],
179090 fts5yyNewState);
179091 }else{
179092 fprintf(fts5yyTraceFILE,"%sShift '%s'\n",
179093 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]);
179094 }
179095 }
179096 }
179097 #else
179098 # define fts5yyTraceShift(X,Y)
@@ -178290,31 +179106,34 @@
179106 int fts5yyNewState, /* The new state to shift in */
179107 int fts5yyMajor, /* The major token to shift in */
179108 sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
179109 ){
179110 fts5yyStackEntry *fts5yytos;
179111 fts5yypParser->fts5yytos++;
179112 #ifdef fts5YYTRACKMAXSTACKDEPTH
179113 if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179114 fts5yypParser->fts5yyhwm++;
179115 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
179116 }
179117 #endif
179118 #if fts5YYSTACKDEPTH>0
179119 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
179120 fts5yyStackOverflow(fts5yypParser);
179121 return;
179122 }
179123 #else
179124 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){
179125 if( fts5yyGrowStack(fts5yypParser) ){
 
179126 fts5yyStackOverflow(fts5yypParser);
179127 return;
179128 }
179129 }
179130 #endif
179131 if( fts5yyNewState > fts5YY_MAX_SHIFT ){
179132 fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179133 }
179134 fts5yytos = fts5yypParser->fts5yytos;
179135 fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
179136 fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
179137 fts5yytos->minor.fts5yy0 = fts5yyMinor;
179138 fts5yyTraceShift(fts5yypParser, fts5yyNewState);
179139 }
@@ -178365,11 +179184,11 @@
179184 int fts5yygoto; /* The next state */
179185 int fts5yyact; /* The next action */
179186 fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
179187 int fts5yysize; /* Amount to pop the stack */
179188 sqlite3Fts5ParserARG_FETCH;
179189 fts5yymsp = fts5yypParser->fts5yytos;
179190 #ifndef NDEBUG
179191 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
179192 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
179193 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
179194 fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
@@ -178379,26 +179198,27 @@
179198 /* Check that the stack is large enough to grow by a single entry
179199 ** if the RHS of the rule is empty. This ensures that there is room
179200 ** enough on the stack to push the LHS value */
179201 if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
179202 #ifdef fts5YYTRACKMAXSTACKDEPTH
179203 if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179204 fts5yypParser->fts5yyhwm++;
179205 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
179206 }
179207 #endif
179208 #if fts5YYSTACKDEPTH>0
179209 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
179210 fts5yyStackOverflow(fts5yypParser);
179211 return;
179212 }
179213 #else
179214 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
179215 if( fts5yyGrowStack(fts5yypParser) ){
 
179216 fts5yyStackOverflow(fts5yypParser);
179217 return;
179218 }
179219 fts5yymsp = fts5yypParser->fts5yytos;
179220 }
179221 #endif
179222 }
179223
179224 switch( fts5yyruleno ){
@@ -178535,19 +179355,21 @@
179355 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
179356 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
179357 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
179358 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
179359 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
179360 if( fts5yyact>fts5YY_MAX_SHIFT ){
179361 fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179362 }
179363 fts5yymsp -= fts5yysize-1;
179364 fts5yypParser->fts5yytos = fts5yymsp;
179365 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
179366 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
179367 fts5yyTraceShift(fts5yypParser, fts5yyact);
179368 }else{
179369 assert( fts5yyact == fts5YY_ACCEPT_ACTION );
179370 fts5yypParser->fts5yytos -= fts5yysize;
179371 fts5yy_accept(fts5yypParser);
179372 }
179373 }
179374
179375 /*
@@ -178561,11 +179383,11 @@
179383 #ifndef NDEBUG
179384 if( fts5yyTraceFILE ){
179385 fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
179386 }
179387 #endif
179388 while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
179389 /* Here code is inserted which will be executed whenever the
179390 ** parser fails */
179391 /************ Begin %parse_failure code ***************************************/
179392 /************ End %parse_failure code *****************************************/
179393 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178602,11 +179424,14 @@
179424 #ifndef NDEBUG
179425 if( fts5yyTraceFILE ){
179426 fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
179427 }
179428 #endif
179429 #ifndef fts5YYNOERRORRECOVERY
179430 fts5yypParser->fts5yyerrcnt = -1;
179431 #endif
179432 assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
179433 /* Here code is inserted which will be executed whenever the
179434 ** parser accepts */
179435 /*********** Begin %parse_accept code *****************************************/
179436 /*********** End %parse_accept code *******************************************/
179437 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178645,32 +179470,12 @@
179470 #ifdef fts5YYERRORSYMBOL
179471 int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
179472 #endif
179473 fts5yyParser *fts5yypParser; /* The parser */
179474
 
179475 fts5yypParser = (fts5yyParser*)fts5yyp;
179476 assert( fts5yypParser->fts5yytos!=0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179477 #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
179478 fts5yyendofinput = (fts5yymajor==0);
179479 #endif
179480 sqlite3Fts5ParserARG_STORE;
179481
@@ -178681,11 +179486,10 @@
179486 #endif
179487
179488 do{
179489 fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
179490 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
 
179491 fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
179492 #ifndef fts5YYNOERRORRECOVERY
179493 fts5yypParser->fts5yyerrcnt--;
179494 #endif
179495 fts5yymajor = fts5YYNOCODE;
@@ -178723,11 +179527,11 @@
179527 **
179528 */
179529 if( fts5yypParser->fts5yyerrcnt<0 ){
179530 fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);
179531 }
179532 fts5yymx = fts5yypParser->fts5yytos->major;
179533 if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){
179534 #ifndef NDEBUG
179535 if( fts5yyTraceFILE ){
179536 fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n",
179537 fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);
@@ -178734,22 +179538,24 @@
179538 }
179539 #endif
179540 fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);
179541 fts5yymajor = fts5YYNOCODE;
179542 }else{
179543 while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack
179544 && fts5yymx != fts5YYERRORSYMBOL
179545 && (fts5yyact = fts5yy_find_reduce_action(
179546 fts5yypParser->fts5yytos->stateno,
 
179547 fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE
179548 ){
179549 fts5yy_pop_parser_stack(fts5yypParser);
179550 }
179551 if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){
179552 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
179553 fts5yy_parse_failed(fts5yypParser);
179554 #ifndef fts5YYNOERRORRECOVERY
179555 fts5yypParser->fts5yyerrcnt = -1;
179556 #endif
179557 fts5yymajor = fts5YYNOCODE;
179558 }else if( fts5yymx!=fts5YYERRORSYMBOL ){
179559 fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
179560 }
179561 }
@@ -178782,22 +179588,27 @@
179588 }
179589 fts5yypParser->fts5yyerrcnt = 3;
179590 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
179591 if( fts5yyendofinput ){
179592 fts5yy_parse_failed(fts5yypParser);
179593 #ifndef fts5YYNOERRORRECOVERY
179594 fts5yypParser->fts5yyerrcnt = -1;
179595 #endif
179596 }
179597 fts5yymajor = fts5YYNOCODE;
179598 #endif
179599 }
179600 }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
179601 #ifndef NDEBUG
179602 if( fts5yyTraceFILE ){
179603 fts5yyStackEntry *i;
179604 char cDiv = '[';
179605 fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
179606 for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
179607 fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
179608 cDiv = ' ';
179609 }
179610 fprintf(fts5yyTraceFILE,"]\n");
179611 }
179612 #endif
179613 return;
179614 }
@@ -183337,21 +184148,10 @@
184148
184149 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
184150 fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
184151 }
184152
 
 
 
 
 
 
 
 
 
 
 
184153 /*
184154 ** This function is only called for detail=columns tables.
184155 */
184156 static int sqlite3Fts5ExprPhraseCollist(
184157 Fts5Expr *pExpr,
@@ -191565,11 +192365,10 @@
192365 assert( pCsr->iLastRowid==LARGEST_INT64 );
192366 assert( pCsr->iFirstRowid==SMALLEST_INT64 );
192367 pCsr->ePlan = FTS5_PLAN_SOURCE;
192368 pCsr->pExpr = pTab->pSortCsr->pExpr;
192369 rc = fts5CursorFirst(pTab, pCsr, bDesc);
 
192370 }else if( pMatch ){
192371 const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
192372 if( zExpr==0 ) zExpr = "";
192373
192374 rc = fts5CursorParseRank(pConfig, pCsr, pRank);
@@ -192994,11 +193793,11 @@
193793 int nArg, /* Number of args */
193794 sqlite3_value **apUnused /* Function arguments */
193795 ){
193796 assert( nArg==0 );
193797 UNUSED_PARAM2(nArg, apUnused);
193798 sqlite3_result_text(pCtx, "fts5: 2016-07-22 21:35:38 f50a3fd6606c14b82c9b938bfca284d54b6c650f", -1, SQLITE_TRANSIENT);
193799 }
193800
193801 static int fts5Init(sqlite3 *db){
193802 static const sqlite3_module fts5Mod = {
193803 /* iVersion */ 2,
@@ -193359,11 +194158,15 @@
194158 ){
194159 int rc;
194160 char *zErr = 0;
194161
194162 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
194163 pConfig->zDb, pConfig->zName, zPost, zDefn,
194164 #ifndef SQLITE_FTS5_NO_WITHOUT_ROWID
194165 bWithout?" WITHOUT ROWID":
194166 #endif
194167 ""
194168 );
194169 if( zErr ){
194170 *pzErr = sqlite3_mprintf(
194171 "fts5: error creating shadow table %q_%s: %s",
194172 pConfig->zName, zPost, zErr
194173
+144 -12
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -28,12 +28,12 @@
2828
** The name of this file under configuration management is "sqlite.h.in".
2929
** The makefile makes some minor changes to this file (such as inserting
3030
** the version number) and changes its name to "sqlite3.h" as
3131
** part of the build process.
3232
*/
33
-#ifndef _SQLITE3_H_
34
-#define _SQLITE3_H_
33
+#ifndef SQLITE3_H
34
+#define SQLITE3_H
3535
#include <stdarg.h> /* Needed for the definition of va_list */
3636
3737
/*
3838
** Make sure we can call this stuff from C++.
3939
*/
@@ -109,13 +109,13 @@
109109
**
110110
** See also: [sqlite3_libversion()],
111111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112112
** [sqlite_version()] and [sqlite_source_id()].
113113
*/
114
-#define SQLITE_VERSION "3.13.0"
115
-#define SQLITE_VERSION_NUMBER 3013000
116
-#define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
114
+#define SQLITE_VERSION "3.14.0"
115
+#define SQLITE_VERSION_NUMBER 3014000
116
+#define SQLITE_SOURCE_ID "2016-07-23 20:27:41 c8e0539b970585cbb3619461a53abb0c3b308a17"
117117
118118
/*
119119
** CAPI3REF: Run-Time Library Version Numbers
120120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121121
**
@@ -504,10 +504,11 @@
504504
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
505505
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
506506
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
507507
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
508508
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
509
+#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
509510
510511
/*
511512
** CAPI3REF: Flags For File Open Operations
512513
**
513514
** These bit values are intended for use in the
@@ -2751,10 +2752,13 @@
27512752
#define SQLITE_RECURSIVE 33 /* NULL NULL */
27522753
27532754
/*
27542755
** CAPI3REF: Tracing And Profiling Functions
27552756
** METHOD: sqlite3
2757
+**
2758
+** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
2759
+** instead of the routines described here.
27562760
**
27572761
** These routines register callback functions that can be used for
27582762
** tracing and profiling the execution of SQL statements.
27592763
**
27602764
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2777,13 +2781,104 @@
27772781
** digits in the time are meaningless. Future versions of SQLite
27782782
** might provide greater resolution on the profiler callback. The
27792783
** sqlite3_profile() function is considered experimental and is
27802784
** subject to change in future versions of SQLite.
27812785
*/
2782
-SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2783
-SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2786
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
2787
+ void(*xTrace)(void*,const char*), void*);
2788
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
27842789
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2790
+
2791
+/*
2792
+** CAPI3REF: SQL Trace Event Codes
2793
+** KEYWORDS: SQLITE_TRACE
2794
+**
2795
+** These constants identify classes of events that can be monitored
2796
+** using the [sqlite3_trace_v2()] tracing logic. The third argument
2797
+** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
2798
+** the following constants. ^The first argument to the trace callback
2799
+** is one of the following constants.
2800
+**
2801
+** New tracing constants may be added in future releases.
2802
+**
2803
+** ^A trace callback has four arguments: xCallback(T,C,P,X).
2804
+** ^The T argument is one of the integer type codes above.
2805
+** ^The C argument is a copy of the context pointer passed in as the
2806
+** fourth argument to [sqlite3_trace_v2()].
2807
+** The P and X arguments are pointers whose meanings depend on T.
2808
+**
2809
+** <dl>
2810
+** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
2811
+** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
2812
+** first begins running and possibly at other times during the
2813
+** execution of the prepared statement, such as at the start of each
2814
+** trigger subprogram. ^The P argument is a pointer to the
2815
+** [prepared statement]. ^The X argument is a pointer to a string which
2816
+** is the expanded SQL text of the prepared statement or a comment that
2817
+** indicates the invocation of a trigger.
2818
+**
2819
+** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
2820
+** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
2821
+** information as is provided by the [sqlite3_profile()] callback.
2822
+** ^The P argument is a pointer to the [prepared statement] and the
2823
+** X argument points to a 64-bit integer which is the estimated of
2824
+** the number of nanosecond that the prepared statement took to run.
2825
+** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
2826
+**
2827
+** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
2828
+** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
2829
+** statement generates a single row of result.
2830
+** ^The P argument is a pointer to the [prepared statement] and the
2831
+** X argument is unused.
2832
+**
2833
+** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
2834
+** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
2835
+** connection closes.
2836
+** ^The P argument is a pointer to the [database connection] object
2837
+** and the X argument is unused.
2838
+** </dl>
2839
+*/
2840
+#define SQLITE_TRACE_STMT 0x01
2841
+#define SQLITE_TRACE_PROFILE 0x02
2842
+#define SQLITE_TRACE_ROW 0x04
2843
+#define SQLITE_TRACE_CLOSE 0x08
2844
+
2845
+/*
2846
+** CAPI3REF: SQL Trace Hook
2847
+** METHOD: sqlite3
2848
+**
2849
+** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
2850
+** function X against [database connection] D, using property mask M
2851
+** and context pointer P. ^If the X callback is
2852
+** NULL or if the M mask is zero, then tracing is disabled. The
2853
+** M argument should be the bitwise OR-ed combination of
2854
+** zero or more [SQLITE_TRACE] constants.
2855
+**
2856
+** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
2857
+** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
2858
+**
2859
+** ^The X callback is invoked whenever any of the events identified by
2860
+** mask M occur. ^The integer return value from the callback is currently
2861
+** ignored, though this may change in future releases. Callback
2862
+** implementations should return zero to ensure future compatibility.
2863
+**
2864
+** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
2865
+** ^The T argument is one of the [SQLITE_TRACE]
2866
+** constants to indicate why the callback was invoked.
2867
+** ^The C argument is a copy of the context pointer.
2868
+** The P and X arguments are pointers whose meanings depend on T.
2869
+**
2870
+** The sqlite3_trace_v2() interface is intended to replace the legacy
2871
+** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
2872
+** are deprecated.
2873
+*/
2874
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
2875
+ sqlite3*,
2876
+ unsigned uMask,
2877
+ int(*xCallback)(unsigned,void*,void*,void*),
2878
+ void *pCtx
2879
+);
27852880
27862881
/*
27872882
** CAPI3REF: Query Progress Callbacks
27882883
** METHOD: sqlite3
27892884
**
@@ -3399,15 +3494,39 @@
33993494
34003495
/*
34013496
** CAPI3REF: Retrieving Statement SQL
34023497
** METHOD: sqlite3_stmt
34033498
**
3404
-** ^This interface can be used to retrieve a saved copy of the original
3405
-** SQL text used to create a [prepared statement] if that statement was
3406
-** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3499
+** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3500
+** SQL text used to create [prepared statement] P if P was
3501
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3502
+** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3503
+** string containing the SQL text of prepared statement P with
3504
+** [bound parameters] expanded.
3505
+**
3506
+** ^(For example, if a prepared statement is created using the SQL
3507
+** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3508
+** and parameter :xyz is unbound, then sqlite3_sql() will return
3509
+** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3510
+** will return "SELECT 2345,NULL".)^
3511
+**
3512
+** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3513
+** is available to hold the result, or if the result would exceed the
3514
+** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3515
+**
3516
+** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3517
+** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3518
+** option causes sqlite3_expanded_sql() to always return NULL.
3519
+**
3520
+** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3521
+** automatically freed when the prepared statement is finalized.
3522
+** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3523
+** is obtained from [sqlite3_malloc()] and must be free by the application
3524
+** by passing it to [sqlite3_free()].
34073525
*/
34083526
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3527
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
34093528
34103529
/*
34113530
** CAPI3REF: Determine If An SQL Statement Writes The Database
34123531
** METHOD: sqlite3_stmt
34133532
**
@@ -6762,10 +6881,22 @@
67626881
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
67636882
** <dd>This parameter returns the approximate number of bytes of heap
67646883
** memory used by all pager caches associated with the database connection.)^
67656884
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
67666885
**
6886
+** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
6887
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
6888
+** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
6889
+** pager cache is shared between two or more connections the bytes of heap
6890
+** memory used by that pager cache is divided evenly between the attached
6891
+** connections.)^ In other words, if none of the pager caches associated
6892
+** with the database connection are shared, this request returns the same
6893
+** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
6894
+** shared, the value returned by this call will be smaller than that returned
6895
+** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
6896
+** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
6897
+**
67676898
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
67686899
** <dd>This parameter returns the approximate number of bytes of heap
67696900
** memory used to store the schema for all databases associated
67706901
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
67716902
** ^The full amount of memory used by the schemas is reported, even if the
@@ -6819,11 +6950,12 @@
68196950
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
68206951
#define SQLITE_DBSTATUS_CACHE_HIT 7
68216952
#define SQLITE_DBSTATUS_CACHE_MISS 8
68226953
#define SQLITE_DBSTATUS_CACHE_WRITE 9
68236954
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
6824
-#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6955
+#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
6956
+#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
68256957
68266958
68276959
/*
68286960
** CAPI3REF: Prepared Statement Status
68296961
** METHOD: sqlite3_stmt
@@ -8202,11 +8334,11 @@
82028334
#endif
82038335
82048336
#ifdef __cplusplus
82058337
} /* End of the 'extern "C"' block */
82068338
#endif
8207
-#endif /* _SQLITE3_H_ */
8339
+#endif /* SQLITE3_H */
82088340
82098341
/******** Begin file sqlite3rtree.h *********/
82108342
/*
82118343
** 2010 August 30
82128344
**
82138345
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -28,12 +28,12 @@
28 ** The name of this file under configuration management is "sqlite.h.in".
29 ** The makefile makes some minor changes to this file (such as inserting
30 ** the version number) and changes its name to "sqlite3.h" as
31 ** part of the build process.
32 */
33 #ifndef _SQLITE3_H_
34 #define _SQLITE3_H_
35 #include <stdarg.h> /* Needed for the definition of va_list */
36
37 /*
38 ** Make sure we can call this stuff from C++.
39 */
@@ -109,13 +109,13 @@
109 **
110 ** See also: [sqlite3_libversion()],
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.13.0"
115 #define SQLITE_VERSION_NUMBER 3013000
116 #define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
@@ -504,10 +504,11 @@
504 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
505 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
506 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
507 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
508 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
 
509
510 /*
511 ** CAPI3REF: Flags For File Open Operations
512 **
513 ** These bit values are intended for use in the
@@ -2751,10 +2752,13 @@
2751 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2752
2753 /*
2754 ** CAPI3REF: Tracing And Profiling Functions
2755 ** METHOD: sqlite3
 
 
 
2756 **
2757 ** These routines register callback functions that can be used for
2758 ** tracing and profiling the execution of SQL statements.
2759 **
2760 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2777,13 +2781,104 @@
2777 ** digits in the time are meaningless. Future versions of SQLite
2778 ** might provide greater resolution on the profiler callback. The
2779 ** sqlite3_profile() function is considered experimental and is
2780 ** subject to change in future versions of SQLite.
2781 */
2782 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2783 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
 
2784 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2785
2786 /*
2787 ** CAPI3REF: Query Progress Callbacks
2788 ** METHOD: sqlite3
2789 **
@@ -3399,15 +3494,39 @@
3399
3400 /*
3401 ** CAPI3REF: Retrieving Statement SQL
3402 ** METHOD: sqlite3_stmt
3403 **
3404 ** ^This interface can be used to retrieve a saved copy of the original
3405 ** SQL text used to create a [prepared statement] if that statement was
3406 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3407 */
3408 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
 
3409
3410 /*
3411 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3412 ** METHOD: sqlite3_stmt
3413 **
@@ -6762,10 +6881,22 @@
6762 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
6763 ** <dd>This parameter returns the approximate number of bytes of heap
6764 ** memory used by all pager caches associated with the database connection.)^
6765 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
6766 **
 
 
 
 
 
 
 
 
 
 
 
 
6767 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
6768 ** <dd>This parameter returns the approximate number of bytes of heap
6769 ** memory used to store the schema for all databases associated
6770 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
6771 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -6819,11 +6950,12 @@
6819 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6820 #define SQLITE_DBSTATUS_CACHE_HIT 7
6821 #define SQLITE_DBSTATUS_CACHE_MISS 8
6822 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6823 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
6824 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
 
6825
6826
6827 /*
6828 ** CAPI3REF: Prepared Statement Status
6829 ** METHOD: sqlite3_stmt
@@ -8202,11 +8334,11 @@
8202 #endif
8203
8204 #ifdef __cplusplus
8205 } /* End of the 'extern "C"' block */
8206 #endif
8207 #endif /* _SQLITE3_H_ */
8208
8209 /******** Begin file sqlite3rtree.h *********/
8210 /*
8211 ** 2010 August 30
8212 **
8213
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -28,12 +28,12 @@
28 ** The name of this file under configuration management is "sqlite.h.in".
29 ** The makefile makes some minor changes to this file (such as inserting
30 ** the version number) and changes its name to "sqlite3.h" as
31 ** part of the build process.
32 */
33 #ifndef SQLITE3_H
34 #define SQLITE3_H
35 #include <stdarg.h> /* Needed for the definition of va_list */
36
37 /*
38 ** Make sure we can call this stuff from C++.
39 */
@@ -109,13 +109,13 @@
109 **
110 ** See also: [sqlite3_libversion()],
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.14.0"
115 #define SQLITE_VERSION_NUMBER 3014000
116 #define SQLITE_SOURCE_ID "2016-07-23 20:27:41 c8e0539b970585cbb3619461a53abb0c3b308a17"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
@@ -504,10 +504,11 @@
504 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
505 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
506 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
507 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
508 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
509 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
510
511 /*
512 ** CAPI3REF: Flags For File Open Operations
513 **
514 ** These bit values are intended for use in the
@@ -2751,10 +2752,13 @@
2752 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2753
2754 /*
2755 ** CAPI3REF: Tracing And Profiling Functions
2756 ** METHOD: sqlite3
2757 **
2758 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
2759 ** instead of the routines described here.
2760 **
2761 ** These routines register callback functions that can be used for
2762 ** tracing and profiling the execution of SQL statements.
2763 **
2764 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2777,13 +2781,104 @@
2781 ** digits in the time are meaningless. Future versions of SQLite
2782 ** might provide greater resolution on the profiler callback. The
2783 ** sqlite3_profile() function is considered experimental and is
2784 ** subject to change in future versions of SQLite.
2785 */
2786 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
2787 void(*xTrace)(void*,const char*), void*);
2788 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2789 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2790
2791 /*
2792 ** CAPI3REF: SQL Trace Event Codes
2793 ** KEYWORDS: SQLITE_TRACE
2794 **
2795 ** These constants identify classes of events that can be monitored
2796 ** using the [sqlite3_trace_v2()] tracing logic. The third argument
2797 ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
2798 ** the following constants. ^The first argument to the trace callback
2799 ** is one of the following constants.
2800 **
2801 ** New tracing constants may be added in future releases.
2802 **
2803 ** ^A trace callback has four arguments: xCallback(T,C,P,X).
2804 ** ^The T argument is one of the integer type codes above.
2805 ** ^The C argument is a copy of the context pointer passed in as the
2806 ** fourth argument to [sqlite3_trace_v2()].
2807 ** The P and X arguments are pointers whose meanings depend on T.
2808 **
2809 ** <dl>
2810 ** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
2811 ** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
2812 ** first begins running and possibly at other times during the
2813 ** execution of the prepared statement, such as at the start of each
2814 ** trigger subprogram. ^The P argument is a pointer to the
2815 ** [prepared statement]. ^The X argument is a pointer to a string which
2816 ** is the expanded SQL text of the prepared statement or a comment that
2817 ** indicates the invocation of a trigger.
2818 **
2819 ** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
2820 ** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
2821 ** information as is provided by the [sqlite3_profile()] callback.
2822 ** ^The P argument is a pointer to the [prepared statement] and the
2823 ** X argument points to a 64-bit integer which is the estimated of
2824 ** the number of nanosecond that the prepared statement took to run.
2825 ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
2826 **
2827 ** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
2828 ** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
2829 ** statement generates a single row of result.
2830 ** ^The P argument is a pointer to the [prepared statement] and the
2831 ** X argument is unused.
2832 **
2833 ** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
2834 ** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
2835 ** connection closes.
2836 ** ^The P argument is a pointer to the [database connection] object
2837 ** and the X argument is unused.
2838 ** </dl>
2839 */
2840 #define SQLITE_TRACE_STMT 0x01
2841 #define SQLITE_TRACE_PROFILE 0x02
2842 #define SQLITE_TRACE_ROW 0x04
2843 #define SQLITE_TRACE_CLOSE 0x08
2844
2845 /*
2846 ** CAPI3REF: SQL Trace Hook
2847 ** METHOD: sqlite3
2848 **
2849 ** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
2850 ** function X against [database connection] D, using property mask M
2851 ** and context pointer P. ^If the X callback is
2852 ** NULL or if the M mask is zero, then tracing is disabled. The
2853 ** M argument should be the bitwise OR-ed combination of
2854 ** zero or more [SQLITE_TRACE] constants.
2855 **
2856 ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
2857 ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
2858 **
2859 ** ^The X callback is invoked whenever any of the events identified by
2860 ** mask M occur. ^The integer return value from the callback is currently
2861 ** ignored, though this may change in future releases. Callback
2862 ** implementations should return zero to ensure future compatibility.
2863 **
2864 ** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
2865 ** ^The T argument is one of the [SQLITE_TRACE]
2866 ** constants to indicate why the callback was invoked.
2867 ** ^The C argument is a copy of the context pointer.
2868 ** The P and X arguments are pointers whose meanings depend on T.
2869 **
2870 ** The sqlite3_trace_v2() interface is intended to replace the legacy
2871 ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
2872 ** are deprecated.
2873 */
2874 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
2875 sqlite3*,
2876 unsigned uMask,
2877 int(*xCallback)(unsigned,void*,void*,void*),
2878 void *pCtx
2879 );
2880
2881 /*
2882 ** CAPI3REF: Query Progress Callbacks
2883 ** METHOD: sqlite3
2884 **
@@ -3399,15 +3494,39 @@
3494
3495 /*
3496 ** CAPI3REF: Retrieving Statement SQL
3497 ** METHOD: sqlite3_stmt
3498 **
3499 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3500 ** SQL text used to create [prepared statement] P if P was
3501 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3502 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3503 ** string containing the SQL text of prepared statement P with
3504 ** [bound parameters] expanded.
3505 **
3506 ** ^(For example, if a prepared statement is created using the SQL
3507 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3508 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3509 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3510 ** will return "SELECT 2345,NULL".)^
3511 **
3512 ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3513 ** is available to hold the result, or if the result would exceed the
3514 ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3515 **
3516 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3517 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3518 ** option causes sqlite3_expanded_sql() to always return NULL.
3519 **
3520 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3521 ** automatically freed when the prepared statement is finalized.
3522 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3523 ** is obtained from [sqlite3_malloc()] and must be free by the application
3524 ** by passing it to [sqlite3_free()].
3525 */
3526 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3527 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3528
3529 /*
3530 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3531 ** METHOD: sqlite3_stmt
3532 **
@@ -6762,10 +6881,22 @@
6881 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
6882 ** <dd>This parameter returns the approximate number of bytes of heap
6883 ** memory used by all pager caches associated with the database connection.)^
6884 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
6885 **
6886 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
6887 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
6888 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
6889 ** pager cache is shared between two or more connections the bytes of heap
6890 ** memory used by that pager cache is divided evenly between the attached
6891 ** connections.)^ In other words, if none of the pager caches associated
6892 ** with the database connection are shared, this request returns the same
6893 ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
6894 ** shared, the value returned by this call will be smaller than that returned
6895 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
6896 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
6897 **
6898 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
6899 ** <dd>This parameter returns the approximate number of bytes of heap
6900 ** memory used to store the schema for all databases associated
6901 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
6902 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -6819,11 +6950,12 @@
6950 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6951 #define SQLITE_DBSTATUS_CACHE_HIT 7
6952 #define SQLITE_DBSTATUS_CACHE_MISS 8
6953 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6954 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
6955 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
6956 #define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
6957
6958
6959 /*
6960 ** CAPI3REF: Prepared Statement Status
6961 ** METHOD: sqlite3_stmt
@@ -8202,11 +8334,11 @@
8334 #endif
8335
8336 #ifdef __cplusplus
8337 } /* End of the 'extern "C"' block */
8338 #endif
8339 #endif /* SQLITE3_H */
8340
8341 /******** Begin file sqlite3rtree.h *********/
8342 /*
8343 ** 2010 August 30
8344 **
8345

Keyboard Shortcuts

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