Fossil SCM

Update the built-in SQLite to version 3.14.1

jan.nijtmans 2016-08-15 11:58 UTC branch-1.35
Commit 8078930932ddbf503fbd8c039445362e0fffd60e
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-1.35
1
+1.35.1
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.35
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.35.1
2
--- src/main.mk
+++ src/main.mk
@@ -485,11 +485,10 @@
485485
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
486486
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
487487
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
488488
-DSQLITE_THREADSAFE=0 \
489489
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
490
- -DSQLITE_OMIT_DEPRECATED \
491490
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
492491
-DSQLITE_ENABLE_FTS4 \
493492
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
494493
-DSQLITE_ENABLE_DBSTAT_VTAB \
495494
-DSQLITE_ENABLE_JSON1 \
496495
--- src/main.mk
+++ src/main.mk
@@ -485,11 +485,10 @@
485 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
486 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
487 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
488 -DSQLITE_THREADSAFE=0 \
489 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
490 -DSQLITE_OMIT_DEPRECATED \
491 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
492 -DSQLITE_ENABLE_FTS4 \
493 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
494 -DSQLITE_ENABLE_DBSTAT_VTAB \
495 -DSQLITE_ENABLE_JSON1 \
496
--- src/main.mk
+++ src/main.mk
@@ -485,11 +485,10 @@
485 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
486 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
487 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
488 -DSQLITE_THREADSAFE=0 \
489 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
490 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
491 -DSQLITE_ENABLE_FTS4 \
492 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
493 -DSQLITE_ENABLE_DBSTAT_VTAB \
494 -DSQLITE_ENABLE_JSON1 \
495
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -157,11 +157,10 @@
157157
-DSQLITE_OMIT_LOAD_EXTENSION=1
158158
-DSQLITE_ENABLE_LOCKING_STYLE=0
159159
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1
160160
-DSQLITE_THREADSAFE=0
161161
-DSQLITE_DEFAULT_FILE_FORMAT=4
162
- -DSQLITE_OMIT_DEPRECATED
163162
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
164163
-DSQLITE_ENABLE_FTS4
165164
-DSQLITE_ENABLE_FTS3_PARENTHESIS
166165
-DSQLITE_ENABLE_DBSTAT_VTAB
167166
-DSQLITE_ENABLE_JSON1
168167
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -157,11 +157,10 @@
157 -DSQLITE_OMIT_LOAD_EXTENSION=1
158 -DSQLITE_ENABLE_LOCKING_STYLE=0
159 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1
160 -DSQLITE_THREADSAFE=0
161 -DSQLITE_DEFAULT_FILE_FORMAT=4
162 -DSQLITE_OMIT_DEPRECATED
163 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
164 -DSQLITE_ENABLE_FTS4
165 -DSQLITE_ENABLE_FTS3_PARENTHESIS
166 -DSQLITE_ENABLE_DBSTAT_VTAB
167 -DSQLITE_ENABLE_JSON1
168
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -157,11 +157,10 @@
157 -DSQLITE_OMIT_LOAD_EXTENSION=1
158 -DSQLITE_ENABLE_LOCKING_STYLE=0
159 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1
160 -DSQLITE_THREADSAFE=0
161 -DSQLITE_DEFAULT_FILE_FORMAT=4
 
162 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
163 -DSQLITE_ENABLE_FTS4
164 -DSQLITE_ENABLE_FTS3_PARENTHESIS
165 -DSQLITE_ENABLE_DBSTAT_VTAB
166 -DSQLITE_ENABLE_JSON1
167
+3199 -2171
--- 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.1. 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:
@@ -65,10 +65,18 @@
6565
** In all cases, the special comment must be enclosed in the usual
6666
** slash-asterisk...asterisk-slash comment marks, with no spaces between the
6767
** asterisks and the comment text.
6868
*/
6969
70
+/*
71
+** Make sure the Tcl calling convention macro is defined. This macro is
72
+** only used by test code and Tcl integration code.
73
+*/
74
+#ifndef SQLITE_TCLAPI
75
+# define SQLITE_TCLAPI
76
+#endif
77
+
7078
/*
7179
** Make sure that rand_s() is available on Windows systems with MSVC 2005
7280
** or higher.
7381
*/
7482
#if defined(_MSC_VER) && _MSC_VER>=1400
@@ -95,12 +103,12 @@
95103
**
96104
******************************************************************************
97105
**
98106
** This file contains code that is specific to MSVC.
99107
*/
100
-#ifndef _MSVC_H_
101
-#define _MSVC_H_
108
+#ifndef SQLITE_MSVC_H
109
+#define SQLITE_MSVC_H
102110
103111
#if defined(_MSC_VER)
104112
#pragma warning(disable : 4054)
105113
#pragma warning(disable : 4055)
106114
#pragma warning(disable : 4100)
@@ -116,11 +124,11 @@
116124
#pragma warning(disable : 4306)
117125
#pragma warning(disable : 4702)
118126
#pragma warning(disable : 4706)
119127
#endif /* defined(_MSC_VER) */
120128
121
-#endif /* _MSVC_H_ */
129
+#endif /* SQLITE_MSVC_H */
122130
123131
/************** End of msvc.h ************************************************/
124132
/************** Continuing where we left off in sqliteInt.h ******************/
125133
126134
/*
@@ -280,12 +288,12 @@
280288
** The name of this file under configuration management is "sqlite.h.in".
281289
** The makefile makes some minor changes to this file (such as inserting
282290
** the version number) and changes its name to "sqlite3.h" as
283291
** part of the build process.
284292
*/
285
-#ifndef _SQLITE3_H_
286
-#define _SQLITE3_H_
293
+#ifndef SQLITE3_H
294
+#define SQLITE3_H
287295
#include <stdarg.h> /* Needed for the definition of va_list */
288296
289297
/*
290298
** Make sure we can call this stuff from C++.
291299
*/
@@ -304,12 +312,21 @@
304312
# define SQLITE_API
305313
#endif
306314
#ifndef SQLITE_CDECL
307315
# define SQLITE_CDECL
308316
#endif
317
+#ifndef SQLITE_APICALL
318
+# define SQLITE_APICALL
319
+#endif
309320
#ifndef SQLITE_STDCALL
310
-# define SQLITE_STDCALL
321
+# define SQLITE_STDCALL SQLITE_APICALL
322
+#endif
323
+#ifndef SQLITE_CALLBACK
324
+# define SQLITE_CALLBACK
325
+#endif
326
+#ifndef SQLITE_SYSAPI
327
+# define SQLITE_SYSAPI
311328
#endif
312329
313330
/*
314331
** These no-op macros are used in front of interfaces to mark those
315332
** interfaces as either deprecated or experimental. New applications
@@ -361,13 +378,13 @@
361378
**
362379
** See also: [sqlite3_libversion()],
363380
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
364381
** [sqlite_version()] and [sqlite_source_id()].
365382
*/
366
-#define SQLITE_VERSION "3.13.0"
367
-#define SQLITE_VERSION_NUMBER 3013000
368
-#define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
383
+#define SQLITE_VERSION "3.14.1"
384
+#define SQLITE_VERSION_NUMBER 3014001
385
+#define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
369386
370387
/*
371388
** CAPI3REF: Run-Time Library Version Numbers
372389
** KEYWORDS: sqlite3_version, sqlite3_sourceid
373390
**
@@ -756,10 +773,11 @@
756773
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
757774
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
758775
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
759776
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
760777
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
778
+#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
761779
762780
/*
763781
** CAPI3REF: Flags For File Open Operations
764782
**
765783
** These bit values are intended for use in the
@@ -1285,10 +1303,20 @@
12851303
**
12861304
** Mutexes are created using [sqlite3_mutex_alloc()].
12871305
*/
12881306
typedef struct sqlite3_mutex sqlite3_mutex;
12891307
1308
+/*
1309
+** CAPI3REF: Loadable Extension Thunk
1310
+**
1311
+** A pointer to the opaque sqlite3_api_routines structure is passed as
1312
+** the third parameter to entry points of [loadable extensions]. This
1313
+** structure must be typedefed in order to work around compiler warnings
1314
+** on some platforms.
1315
+*/
1316
+typedef struct sqlite3_api_routines sqlite3_api_routines;
1317
+
12901318
/*
12911319
** CAPI3REF: OS Interface Object
12921320
**
12931321
** An instance of the sqlite3_vfs object defines the interface between
12941322
** the SQLite core and the underlying operating system. The "vfs"
@@ -2189,11 +2217,11 @@
21892217
** interface independently of the [load_extension()] SQL function.
21902218
** The [sqlite3_enable_load_extension()] API enables or disables both the
21912219
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
21922220
** There should be two additional arguments.
21932221
** When the first argument to this interface is 1, then only the C-API is
2194
-** enabled and the SQL function remains disabled. If the first argment to
2222
+** enabled and the SQL function remains disabled. If the first argument to
21952223
** this interface is 0, then both the C-API and the SQL function are disabled.
21962224
** If the first argument is -1, then no changes are made to state of either the
21972225
** C-API or the SQL function.
21982226
** The second parameter is a pointer to an integer into which
21992227
** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2482,11 +2510,11 @@
24822510
** result in undefined behavior.
24832511
**
24842512
** A busy handler must not close the database connection
24852513
** or [prepared statement] that invoked the busy handler.
24862514
*/
2487
-SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2515
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
24882516
24892517
/*
24902518
** CAPI3REF: Set A Busy Timeout
24912519
** METHOD: sqlite3
24922520
**
@@ -3003,10 +3031,13 @@
30033031
#define SQLITE_RECURSIVE 33 /* NULL NULL */
30043032
30053033
/*
30063034
** CAPI3REF: Tracing And Profiling Functions
30073035
** METHOD: sqlite3
3036
+**
3037
+** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
3038
+** instead of the routines described here.
30083039
**
30093040
** These routines register callback functions that can be used for
30103041
** tracing and profiling the execution of SQL statements.
30113042
**
30123043
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -3029,13 +3060,107 @@
30293060
** digits in the time are meaningless. Future versions of SQLite
30303061
** might provide greater resolution on the profiler callback. The
30313062
** sqlite3_profile() function is considered experimental and is
30323063
** subject to change in future versions of SQLite.
30333064
*/
3034
-SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
3035
-SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
3065
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
3066
+ void(*xTrace)(void*,const char*), void*);
3067
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
30363068
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
3069
+
3070
+/*
3071
+** CAPI3REF: SQL Trace Event Codes
3072
+** KEYWORDS: SQLITE_TRACE
3073
+**
3074
+** These constants identify classes of events that can be monitored
3075
+** using the [sqlite3_trace_v2()] tracing logic. The third argument
3076
+** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
3077
+** the following constants. ^The first argument to the trace callback
3078
+** is one of the following constants.
3079
+**
3080
+** New tracing constants may be added in future releases.
3081
+**
3082
+** ^A trace callback has four arguments: xCallback(T,C,P,X).
3083
+** ^The T argument is one of the integer type codes above.
3084
+** ^The C argument is a copy of the context pointer passed in as the
3085
+** fourth argument to [sqlite3_trace_v2()].
3086
+** The P and X arguments are pointers whose meanings depend on T.
3087
+**
3088
+** <dl>
3089
+** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
3090
+** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
3091
+** first begins running and possibly at other times during the
3092
+** execution of the prepared statement, such as at the start of each
3093
+** trigger subprogram. ^The P argument is a pointer to the
3094
+** [prepared statement]. ^The X argument is a pointer to a string which
3095
+** is the unexpanded SQL text of the prepared statement or an SQL comment
3096
+** that indicates the invocation of a trigger. ^The callback can compute
3097
+** the same text that would have been returned by the legacy [sqlite3_trace()]
3098
+** interface by using the X argument when X begins with "--" and invoking
3099
+** [sqlite3_expanded_sql(P)] otherwise.
3100
+**
3101
+** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
3102
+** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
3103
+** information as is provided by the [sqlite3_profile()] callback.
3104
+** ^The P argument is a pointer to the [prepared statement] and the
3105
+** X argument points to a 64-bit integer which is the estimated of
3106
+** the number of nanosecond that the prepared statement took to run.
3107
+** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
3108
+**
3109
+** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
3110
+** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
3111
+** statement generates a single row of result.
3112
+** ^The P argument is a pointer to the [prepared statement] and the
3113
+** X argument is unused.
3114
+**
3115
+** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
3116
+** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
3117
+** connection closes.
3118
+** ^The P argument is a pointer to the [database connection] object
3119
+** and the X argument is unused.
3120
+** </dl>
3121
+*/
3122
+#define SQLITE_TRACE_STMT 0x01
3123
+#define SQLITE_TRACE_PROFILE 0x02
3124
+#define SQLITE_TRACE_ROW 0x04
3125
+#define SQLITE_TRACE_CLOSE 0x08
3126
+
3127
+/*
3128
+** CAPI3REF: SQL Trace Hook
3129
+** METHOD: sqlite3
3130
+**
3131
+** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
3132
+** function X against [database connection] D, using property mask M
3133
+** and context pointer P. ^If the X callback is
3134
+** NULL or if the M mask is zero, then tracing is disabled. The
3135
+** M argument should be the bitwise OR-ed combination of
3136
+** zero or more [SQLITE_TRACE] constants.
3137
+**
3138
+** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
3139
+** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
3140
+**
3141
+** ^The X callback is invoked whenever any of the events identified by
3142
+** mask M occur. ^The integer return value from the callback is currently
3143
+** ignored, though this may change in future releases. Callback
3144
+** implementations should return zero to ensure future compatibility.
3145
+**
3146
+** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
3147
+** ^The T argument is one of the [SQLITE_TRACE]
3148
+** constants to indicate why the callback was invoked.
3149
+** ^The C argument is a copy of the context pointer.
3150
+** The P and X arguments are pointers whose meanings depend on T.
3151
+**
3152
+** The sqlite3_trace_v2() interface is intended to replace the legacy
3153
+** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
3154
+** are deprecated.
3155
+*/
3156
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
3157
+ sqlite3*,
3158
+ unsigned uMask,
3159
+ int(*xCallback)(unsigned,void*,void*,void*),
3160
+ void *pCtx
3161
+);
30373162
30383163
/*
30393164
** CAPI3REF: Query Progress Callbacks
30403165
** METHOD: sqlite3
30413166
**
@@ -3651,15 +3776,39 @@
36513776
36523777
/*
36533778
** CAPI3REF: Retrieving Statement SQL
36543779
** METHOD: sqlite3_stmt
36553780
**
3656
-** ^This interface can be used to retrieve a saved copy of the original
3657
-** SQL text used to create a [prepared statement] if that statement was
3658
-** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3781
+** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3782
+** SQL text used to create [prepared statement] P if P was
3783
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3784
+** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3785
+** string containing the SQL text of prepared statement P with
3786
+** [bound parameters] expanded.
3787
+**
3788
+** ^(For example, if a prepared statement is created using the SQL
3789
+** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3790
+** and parameter :xyz is unbound, then sqlite3_sql() will return
3791
+** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3792
+** will return "SELECT 2345,NULL".)^
3793
+**
3794
+** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3795
+** is available to hold the result, or if the result would exceed the
3796
+** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3797
+**
3798
+** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3799
+** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3800
+** option causes sqlite3_expanded_sql() to always return NULL.
3801
+**
3802
+** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3803
+** automatically freed when the prepared statement is finalized.
3804
+** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3805
+** is obtained from [sqlite3_malloc()] and must be free by the application
3806
+** by passing it to [sqlite3_free()].
36593807
*/
36603808
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3809
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
36613810
36623811
/*
36633812
** CAPI3REF: Determine If An SQL Statement Writes The Database
36643813
** METHOD: sqlite3_stmt
36653814
**
@@ -4813,16 +4962,17 @@
48134962
** NULL if the metadata has been discarded.
48144963
** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
48154964
** SQLite will invoke the destructor function X with parameter P exactly
48164965
** once, when the metadata is discarded.
48174966
** SQLite is free to discard the metadata at any time, including: <ul>
4818
-** <li> when the corresponding function parameter changes, or
4819
-** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4820
-** SQL statement, or
4821
-** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4822
-** <li> during the original sqlite3_set_auxdata() call when a memory
4823
-** allocation error occurs. </ul>)^
4967
+** <li> ^(when the corresponding function parameter changes)^, or
4968
+** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4969
+** SQL statement)^, or
4970
+** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
4971
+** parameter)^, or
4972
+** <li> ^(during the original sqlite3_set_auxdata() call when a memory
4973
+** allocation error occurs.)^ </ul>
48244974
**
48254975
** Note the last bullet in particular. The destructor X in
48264976
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
48274977
** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
48284978
** should be called near the end of the function implementation and the
@@ -5645,11 +5795,11 @@
56455795
** interface returns SQLITE_OK and fills in the non-NULL pointers in
56465796
** the final five arguments with appropriate values if the specified
56475797
** column exists. ^The sqlite3_table_column_metadata() interface returns
56485798
** SQLITE_ERROR and if the specified column does not exist.
56495799
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5650
-** NULL pointer, then this routine simply checks for the existance of the
5800
+** NULL pointer, then this routine simply checks for the existence of the
56515801
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
56525802
** does not.
56535803
**
56545804
** ^The column is identified by the second, third and fourth parameters to
56555805
** this function. ^(The second parameter is either the name of the database
@@ -5779,12 +5929,12 @@
57795929
** to turn extension loading on and call it with onoff==0 to turn
57805930
** it back off again.
57815931
**
57825932
** ^This interface enables or disables both the C-API
57835933
** [sqlite3_load_extension()] and the SQL function [load_extension()].
5784
-** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5785
-** to enable or disable only the C-API.
5934
+** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5935
+** to enable or disable only the C-API.)^
57865936
**
57875937
** <b>Security warning:</b> It is recommended that extension loading
57885938
** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
57895939
** rather than this interface, so the [load_extension()] SQL function
57905940
** remains disabled. This will prevent SQL injections from giving attackers
@@ -5800,11 +5950,11 @@
58005950
** xEntryPoint() is the entry point for a statically linked [SQLite extension]
58015951
** that is to be automatically loaded into all new database connections.
58025952
**
58035953
** ^(Even though the function prototype shows that xEntryPoint() takes
58045954
** no arguments and returns void, SQLite invokes xEntryPoint() with three
5805
-** arguments and expects and integer result as if the signature of the
5955
+** arguments and expects an integer result as if the signature of the
58065956
** entry point where as follows:
58075957
**
58085958
** <blockquote><pre>
58095959
** &nbsp; int xEntryPoint(
58105960
** &nbsp; sqlite3 *db,
@@ -5826,11 +5976,11 @@
58265976
** will be called more than once for each database connection that is opened.
58275977
**
58285978
** See also: [sqlite3_reset_auto_extension()]
58295979
** and [sqlite3_cancel_auto_extension()]
58305980
*/
5831
-SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5981
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
58325982
58335983
/*
58345984
** CAPI3REF: Cancel Automatic Extension Loading
58355985
**
58365986
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5838,11 +5988,11 @@
58385988
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
58395989
** routine returns 1 if initialization routine X was successfully
58405990
** unregistered and it returns 0 if X was not on the list of initialization
58415991
** routines.
58425992
*/
5843
-SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5993
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
58445994
58455995
/*
58465996
** CAPI3REF: Reset Automatic Extension Loading
58475997
**
58485998
** ^This interface disables all automatic extensions previously
@@ -7014,10 +7164,22 @@
70147164
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
70157165
** <dd>This parameter returns the approximate number of bytes of heap
70167166
** memory used by all pager caches associated with the database connection.)^
70177167
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
70187168
**
7169
+** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
7170
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
7171
+** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
7172
+** pager cache is shared between two or more connections the bytes of heap
7173
+** memory used by that pager cache is divided evenly between the attached
7174
+** connections.)^ In other words, if none of the pager caches associated
7175
+** with the database connection are shared, this request returns the same
7176
+** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
7177
+** shared, the value returned by this call will be smaller than that returned
7178
+** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
7179
+** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
7180
+**
70197181
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
70207182
** <dd>This parameter returns the approximate number of bytes of heap
70217183
** memory used to store the schema for all databases associated
70227184
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
70237185
** ^The full amount of memory used by the schemas is reported, even if the
@@ -7071,11 +7233,12 @@
70717233
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
70727234
#define SQLITE_DBSTATUS_CACHE_HIT 7
70737235
#define SQLITE_DBSTATUS_CACHE_MISS 8
70747236
#define SQLITE_DBSTATUS_CACHE_WRITE 9
70757237
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
7076
-#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
7238
+#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
7239
+#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
70777240
70787241
70797242
/*
70807243
** CAPI3REF: Prepared Statement Status
70817244
** METHOD: sqlite3_stmt
@@ -8227,11 +8390,11 @@
82278390
** tables.
82288391
**
82298392
** ^The second parameter to the preupdate callback is a pointer to
82308393
** the [database connection] that registered the preupdate hook.
82318394
** ^The third parameter to the preupdate callback is one of the constants
8232
-** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
8395
+** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
82338396
** kind of update operation that is about to occur.
82348397
** ^(The fourth parameter to the preupdate callback is the name of the
82358398
** database within the database connection that is being modified. This
82368399
** will be "main" for the main database or "temp" for TEMP tables or
82378400
** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8454,11 +8617,11 @@
84548617
#endif
84558618
84568619
#if 0
84578620
} /* End of the 'extern "C"' block */
84588621
#endif
8459
-#endif /* _SQLITE3_H_ */
8622
+#endif /* SQLITE3_H */
84608623
84618624
/******** Begin file sqlite3rtree.h *********/
84628625
/*
84638626
** 2010 August 30
84648627
**
@@ -10174,11 +10337,11 @@
1017410337
** following structure. All structure methods must be defined, setting
1017510338
** any member of the fts5_tokenizer struct to NULL leads to undefined
1017610339
** behaviour. The structure methods are expected to function as follows:
1017710340
**
1017810341
** xCreate:
10179
-** This function is used to allocate and inititalize a tokenizer instance.
10342
+** This function is used to allocate and initialize a tokenizer instance.
1018010343
** A tokenizer instance is required to actually tokenize text.
1018110344
**
1018210345
** The first argument passed to this function is a copy of the (void*)
1018310346
** pointer provided by the application when the fts5_tokenizer object
1018410347
** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10433,11 +10596,10 @@
1043310596
#if 0
1043410597
} /* end of the 'extern "C"' block */
1043510598
#endif
1043610599
1043710600
#endif /* _FTS5_H */
10438
-
1043910601
1044010602
/******** End of fts5.h *********/
1044110603
1044210604
/************** End of sqlite3.h *********************************************/
1044310605
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -10732,11 +10894,11 @@
1073210894
** Make sure that the compiler intrinsics we desire are enabled when
1073310895
** compiling with an appropriate version of MSVC unless prevented by
1073410896
** the SQLITE_DISABLE_INTRINSIC define.
1073510897
*/
1073610898
#if !defined(SQLITE_DISABLE_INTRINSIC)
10737
-# if defined(_MSC_VER) && _MSC_VER>=1300
10899
+# if defined(_MSC_VER) && _MSC_VER>=1400
1073810900
# if !defined(_WIN32_WCE)
1073910901
# include <intrin.h>
1074010902
# pragma intrinsic(_byteswap_ushort)
1074110903
# pragma intrinsic(_byteswap_ulong)
1074210904
# pragma intrinsic(_ReadWriteBarrier)
@@ -11009,12 +11171,12 @@
1100911171
**
1101011172
*************************************************************************
1101111173
** This is the header file for the generic hash-table implementation
1101211174
** used in SQLite.
1101311175
*/
11014
-#ifndef _SQLITE_HASH_H_
11015
-#define _SQLITE_HASH_H_
11176
+#ifndef SQLITE_HASH_H
11177
+#define SQLITE_HASH_H
1101611178
1101711179
/* Forward declarations of structures. */
1101811180
typedef struct Hash Hash;
1101911181
typedef struct HashElem HashElem;
1102011182
@@ -11090,11 +11252,11 @@
1109011252
/*
1109111253
** Number of entries in a hash table
1109211254
*/
1109311255
/* #define sqliteHashCount(H) ((H)->count) // NOT USED */
1109411256
11095
-#endif /* _SQLITE_HASH_H_ */
11257
+#endif /* SQLITE_HASH_H */
1109611258
1109711259
/************** End of hash.h ************************************************/
1109811260
/************** Continuing where we left off in sqliteInt.h ******************/
1109911261
/************** Include parse.h in the middle of sqliteInt.h *****************/
1110011262
/************** Begin file parse.h *******************************************/
@@ -11838,12 +12000,12 @@
1183812000
*************************************************************************
1183912001
** This header file defines the interface that the sqlite B-Tree file
1184012002
** subsystem. See comments in the source code for a detailed description
1184112003
** of what each interface routine does.
1184212004
*/
11843
-#ifndef _BTREE_H_
11844
-#define _BTREE_H_
12005
+#ifndef SQLITE_BTREE_H
12006
+#define SQLITE_BTREE_H
1184512007
1184612008
/* TODO: This definition is just included so other modules compile. It
1184712009
** needs to be revisited.
1184812010
*/
1184912011
#define SQLITE_N_BTREE_META 16
@@ -11864,10 +12026,11 @@
1186412026
** Forward declarations of structure
1186512027
*/
1186612028
typedef struct Btree Btree;
1186712029
typedef struct BtCursor BtCursor;
1186812030
typedef struct BtShared BtShared;
12031
+typedef struct BtreePayload BtreePayload;
1186912032
1187012033
1187112034
SQLITE_PRIVATE int sqlite3BtreeOpen(
1187212035
sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
1187312036
const char *zFilename, /* Name of database file to open */
@@ -12075,23 +12238,47 @@
1207512238
1207612239
/* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
1207712240
#define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
1207812241
#define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
1207912242
12080
-SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
12081
- const void *pData, int nData,
12082
- int nZero, int bias, int seekResult);
12243
+/* An instance of the BtreePayload object describes the content of a single
12244
+** entry in either an index or table btree.
12245
+**
12246
+** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
12247
+** an arbitrary key and no data. These btrees have pKey,nKey set to their
12248
+** key and pData,nData,nZero set to zero.
12249
+**
12250
+** Table btrees (used for rowid tables) contain an integer rowid used as
12251
+** the key and passed in the nKey field. The pKey field is zero.
12252
+** pData,nData hold the content of the new entry. nZero extra zero bytes
12253
+** are appended to the end of the content when constructing the entry.
12254
+**
12255
+** This object is used to pass information into sqlite3BtreeInsert(). The
12256
+** same information used to be passed as five separate parameters. But placing
12257
+** the information into this object helps to keep the interface more
12258
+** organized and understandable, and it also helps the resulting code to
12259
+** run a little faster by using fewer registers for parameter passing.
12260
+*/
12261
+struct BtreePayload {
12262
+ const void *pKey; /* Key content for indexes. NULL for tables */
12263
+ sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
12264
+ const void *pData; /* Data for tables. NULL for indexes */
12265
+ int nData; /* Size of pData. 0 if none. */
12266
+ int nZero; /* Extra zero data appended after pData,nData */
12267
+};
12268
+
12269
+SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
12270
+ int bias, int seekResult);
1208312271
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
1208412272
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
1208512273
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
1208612274
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
1208712275
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12088
-SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
12276
+SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
1208912277
SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
12090
-SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
12091
-SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
12092
-SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
12278
+SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12279
+SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
1209312280
SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
1209412281
1209512282
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
1209612283
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
1209712284
@@ -12128,15 +12315,17 @@
1212812315
#ifndef SQLITE_OMIT_SHARED_CACHE
1212912316
SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
1213012317
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
1213112318
SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
1213212319
SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
12320
+SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*);
1213312321
#else
1213412322
# define sqlite3BtreeEnter(X)
1213512323
# define sqlite3BtreeEnterAll(X)
1213612324
# define sqlite3BtreeSharable(X) 0
1213712325
# define sqlite3BtreeEnterCursor(X)
12326
+# define sqlite3BtreeConnectionCount(X) 1
1213812327
#endif
1213912328
1214012329
#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
1214112330
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
1214212331
SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
@@ -12157,11 +12346,11 @@
1215712346
# define sqlite3BtreeHoldsAllMutexes(X) 1
1215812347
# define sqlite3SchemaMutexHeld(X,Y,Z) 1
1215912348
#endif
1216012349
1216112350
12162
-#endif /* _BTREE_H_ */
12351
+#endif /* SQLITE_BTREE_H */
1216312352
1216412353
/************** End of btree.h ***********************************************/
1216512354
/************** Continuing where we left off in sqliteInt.h ******************/
1216612355
/************** Include vdbe.h in the middle of sqliteInt.h ******************/
1216712356
/************** Begin file vdbe.h ********************************************/
@@ -12180,12 +12369,12 @@
1218012369
**
1218112370
** This header defines the interface to the virtual database engine
1218212371
** or VDBE. The VDBE implements an abstract machine that runs a
1218312372
** simple program to access and modify the underlying database.
1218412373
*/
12185
-#ifndef _SQLITE_VDBE_H_
12186
-#define _SQLITE_VDBE_H_
12374
+#ifndef SQLITE_VDBE_H
12375
+#define SQLITE_VDBE_H
1218712376
/* #include <stdio.h> */
1218812377
1218912378
/*
1219012379
** A single VDBE is an opaque structure named "Vdbe". Only routines
1219112380
** in the source file sqliteVdbe.c are allowed to see the insides
@@ -12366,21 +12555,21 @@
1236612555
#define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1236712556
#define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
1236812557
#define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */
1236912558
#define OP_NotFound 30 /* synopsis: key=r[P3@P4] */
1237012559
#define OP_Found 31 /* synopsis: key=r[P3@P4] */
12371
-#define OP_NotExists 32 /* synopsis: intkey=r[P3] */
12372
-#define OP_Last 33
12560
+#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12561
+#define OP_NotExists 33 /* synopsis: intkey=r[P3] */
1237312562
#define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1237412563
#define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1237512564
#define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
1237612565
#define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
1237712566
#define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
1237812567
#define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
1237912568
#define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
1238012569
#define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12381
-#define OP_SorterSort 42
12570
+#define OP_Last 42
1238212571
#define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1238312572
#define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1238412573
#define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1238512574
#define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1238612575
#define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12387,118 +12576,119 @@
1238712576
#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1238812577
#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1238912578
#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1239012579
#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1239112580
#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12392
-#define OP_Sort 53
12581
+#define OP_SorterSort 53
1239312582
#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12394
-#define OP_Rewind 55
12395
-#define OP_IdxLE 56 /* synopsis: key=r[P3@P4] */
12396
-#define OP_IdxGT 57 /* synopsis: key=r[P3@P4] */
12397
-#define OP_IdxLT 58 /* synopsis: key=r[P3@P4] */
12398
-#define OP_IdxGE 59 /* synopsis: key=r[P3@P4] */
12399
-#define OP_RowSetRead 60 /* synopsis: r[P3]=rowset(P1) */
12400
-#define OP_RowSetTest 61 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12401
-#define OP_Program 62
12402
-#define OP_FkIfZero 63 /* synopsis: if fkctr[P1]==0 goto P2 */
12403
-#define OP_IfPos 64 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12404
-#define OP_IfNotZero 65 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12405
-#define OP_DecrJumpZero 66 /* synopsis: if (--r[P1])==0 goto P2 */
12406
-#define OP_IncrVacuum 67
12407
-#define OP_VNext 68
12408
-#define OP_Init 69 /* synopsis: Start at P2 */
12409
-#define OP_Return 70
12410
-#define OP_EndCoroutine 71
12411
-#define OP_HaltIfNull 72 /* synopsis: if r[P3]=null halt */
12412
-#define OP_Halt 73
12413
-#define OP_Integer 74 /* synopsis: r[P2]=P1 */
12414
-#define OP_Int64 75 /* synopsis: r[P2]=P4 */
12415
-#define OP_String 76 /* synopsis: r[P2]='P4' (len=P1) */
12416
-#define OP_Null 77 /* synopsis: r[P2..P3]=NULL */
12417
-#define OP_SoftNull 78 /* synopsis: r[P1]=NULL */
12418
-#define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */
12419
-#define OP_Variable 80 /* synopsis: r[P2]=parameter(P1,P4) */
12420
-#define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */
12421
-#define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12422
-#define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */
12423
-#define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */
12424
-#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
12425
-#define OP_CollSeq 86
12426
-#define OP_Function0 87 /* synopsis: r[P3]=func(r[P2@P5]) */
12427
-#define OP_Function 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12428
-#define OP_AddImm 89 /* synopsis: r[P1]=r[P1]+P2 */
12429
-#define OP_RealAffinity 90
12430
-#define OP_Cast 91 /* synopsis: affinity(r[P1]) */
12431
-#define OP_Permutation 92
12432
-#define OP_Compare 93 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12433
-#define OP_Column 94 /* synopsis: r[P3]=PX */
12434
-#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
12435
-#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12583
+#define OP_Sort 55
12584
+#define OP_Rewind 56
12585
+#define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12586
+#define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12587
+#define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12588
+#define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12589
+#define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12590
+#define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12591
+#define OP_Program 63
12592
+#define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12593
+#define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12594
+#define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12595
+#define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12596
+#define OP_IncrVacuum 68
12597
+#define OP_VNext 69
12598
+#define OP_Init 70 /* synopsis: Start at P2 */
12599
+#define OP_Return 71
12600
+#define OP_EndCoroutine 72
12601
+#define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12602
+#define OP_Halt 74
12603
+#define OP_Integer 75 /* synopsis: r[P2]=P1 */
12604
+#define OP_Int64 76 /* synopsis: r[P2]=P4 */
12605
+#define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12606
+#define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12607
+#define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12608
+#define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12609
+#define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12610
+#define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12611
+#define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12612
+#define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12613
+#define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12614
+#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12615
+#define OP_CollSeq 87
12616
+#define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12617
+#define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12618
+#define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12619
+#define OP_RealAffinity 91
12620
+#define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12621
+#define OP_Permutation 93
12622
+#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12623
+#define OP_Column 95 /* synopsis: r[P3]=PX */
12624
+#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
1243612625
#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12437
-#define OP_Count 98 /* synopsis: r[P2]=count() */
12438
-#define OP_ReadCookie 99
12439
-#define OP_SetCookie 100
12440
-#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
12441
-#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */
12442
-#define OP_OpenWrite 103 /* synopsis: root=P2 iDb=P3 */
12443
-#define OP_OpenAutoindex 104 /* synopsis: nColumn=P2 */
12444
-#define OP_OpenEphemeral 105 /* synopsis: nColumn=P2 */
12445
-#define OP_SorterOpen 106
12446
-#define OP_SequenceTest 107 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12447
-#define OP_OpenPseudo 108 /* synopsis: P3 columns in r[P2] */
12448
-#define OP_Close 109
12449
-#define OP_ColumnsUsed 110
12450
-#define OP_Sequence 111 /* synopsis: r[P2]=cursor[P1].ctr++ */
12451
-#define OP_NewRowid 112 /* synopsis: r[P2]=rowid */
12452
-#define OP_Insert 113 /* synopsis: intkey=r[P3] data=r[P2] */
12453
-#define OP_InsertInt 114 /* synopsis: intkey=P3 data=r[P2] */
12454
-#define OP_Delete 115
12455
-#define OP_ResetCount 116
12456
-#define OP_SorterCompare 117 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12457
-#define OP_SorterData 118 /* synopsis: r[P2]=data */
12458
-#define OP_RowKey 119 /* synopsis: r[P2]=key */
12459
-#define OP_RowData 120 /* synopsis: r[P2]=data */
12460
-#define OP_Rowid 121 /* synopsis: r[P2]=rowid */
12461
-#define OP_NullRow 122
12462
-#define OP_SorterInsert 123
12463
-#define OP_IdxInsert 124 /* synopsis: key=r[P2] */
12464
-#define OP_IdxDelete 125 /* synopsis: key=r[P2@P3] */
12465
-#define OP_Seek 126 /* synopsis: Move P3 to P1.rowid */
12466
-#define OP_IdxRowid 127 /* synopsis: r[P2]=rowid */
12467
-#define OP_Destroy 128
12468
-#define OP_Clear 129
12469
-#define OP_ResetSorter 130
12470
-#define OP_CreateIndex 131 /* synopsis: r[P2]=root iDb=P1 */
12471
-#define OP_CreateTable 132 /* synopsis: r[P2]=root iDb=P1 */
12626
+#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12627
+#define OP_Count 99 /* synopsis: r[P2]=count() */
12628
+#define OP_ReadCookie 100
12629
+#define OP_SetCookie 101
12630
+#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12631
+#define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12632
+#define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12633
+#define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12634
+#define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12635
+#define OP_SorterOpen 107
12636
+#define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12637
+#define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12638
+#define OP_Close 110
12639
+#define OP_ColumnsUsed 111
12640
+#define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12641
+#define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12642
+#define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12643
+#define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12644
+#define OP_Delete 116
12645
+#define OP_ResetCount 117
12646
+#define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12647
+#define OP_SorterData 119 /* synopsis: r[P2]=data */
12648
+#define OP_RowKey 120 /* synopsis: r[P2]=key */
12649
+#define OP_RowData 121 /* synopsis: r[P2]=data */
12650
+#define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12651
+#define OP_NullRow 123
12652
+#define OP_SorterInsert 124
12653
+#define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12654
+#define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12655
+#define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12656
+#define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12657
+#define OP_Destroy 129
12658
+#define OP_Clear 130
12659
+#define OP_ResetSorter 131
12660
+#define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
1247212661
#define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12473
-#define OP_ParseSchema 134
12474
-#define OP_LoadAnalysis 135
12475
-#define OP_DropTable 136
12476
-#define OP_DropIndex 137
12477
-#define OP_DropTrigger 138
12478
-#define OP_IntegrityCk 139
12479
-#define OP_RowSetAdd 140 /* synopsis: rowset(P1)=r[P2] */
12480
-#define OP_Param 141
12481
-#define OP_FkCounter 142 /* synopsis: fkctr[P1]+=P2 */
12482
-#define OP_MemMax 143 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12483
-#define OP_OffsetLimit 144 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12484
-#define OP_AggStep0 145 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12485
-#define OP_AggStep 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12486
-#define OP_AggFinal 147 /* synopsis: accum=r[P1] N=P2 */
12487
-#define OP_Expire 148
12488
-#define OP_TableLock 149 /* synopsis: iDb=P1 root=P2 write=P3 */
12489
-#define OP_VBegin 150
12490
-#define OP_VCreate 151
12491
-#define OP_VDestroy 152
12492
-#define OP_VOpen 153
12493
-#define OP_VColumn 154 /* synopsis: r[P3]=vcolumn(P2) */
12494
-#define OP_VRename 155
12495
-#define OP_Pagecount 156
12496
-#define OP_MaxPgcnt 157
12497
-#define OP_CursorHint 158
12498
-#define OP_Noop 159
12499
-#define OP_Explain 160
12662
+#define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12663
+#define OP_ParseSchema 135
12664
+#define OP_LoadAnalysis 136
12665
+#define OP_DropTable 137
12666
+#define OP_DropIndex 138
12667
+#define OP_DropTrigger 139
12668
+#define OP_IntegrityCk 140
12669
+#define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12670
+#define OP_Param 142
12671
+#define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12672
+#define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12673
+#define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12674
+#define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12675
+#define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12676
+#define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12677
+#define OP_Expire 149
12678
+#define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12679
+#define OP_VBegin 151
12680
+#define OP_VCreate 152
12681
+#define OP_VDestroy 153
12682
+#define OP_VOpen 154
12683
+#define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12684
+#define OP_VRename 156
12685
+#define OP_Pagecount 157
12686
+#define OP_MaxPgcnt 158
12687
+#define OP_CursorHint 159
12688
+#define OP_Noop 160
12689
+#define OP_Explain 161
1250012690
1250112691
/* Properties such as "out2" or "jump" that are specified in
1250212692
** comments following the "case" for each opcode in the vdbe.c
1250312693
** are encoded into bitvectors as follows:
1250412694
*/
@@ -12511,35 +12701,35 @@
1251112701
#define OPFLG_INITIALIZER {\
1251212702
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
1251312703
/* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
1251412704
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
1251512705
/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12516
-/* 32 */ 0x09, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12706
+/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1251712707
/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
1251812708
/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12519
-/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01,\
12520
-/* 64 */ 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02, 0x02,\
12521
-/* 72 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
12522
-/* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12523
-/* 88 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\
12524
-/* 96 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
12525
-/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
12526
-/* 112 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12527
-/* 120 */ 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
12528
-/* 128 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\
12529
-/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
12530
-/* 144 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12531
-/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12532
-/* 160 */ 0x00,}
12709
+/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12710
+/* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12711
+/* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12712
+/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12713
+/* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12714
+/* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12715
+/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12716
+/* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12717
+/* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12718
+/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12719
+/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12720
+/* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12721
+/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12722
+/* 160 */ 0x00, 0x00,}
1253312723
1253412724
/* The sqlite3P2Values() routine is able to run faster if it knows
1253512725
** the value of the largest JUMP opcode. The smaller the maximum
1253612726
** JUMP opcode the better, so the mkopcodeh.tcl script that
1253712727
** generated this include file strives to group all JUMP opcodes
1253812728
** together near the beginning of the list.
1253912729
*/
12540
-#define SQLITE_MX_JUMP_OPCODE 69 /* Maximum JUMP opcode */
12730
+#define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
1254112731
1254212732
/************** End of opcodes.h *********************************************/
1254312733
/************** Continuing where we left off in vdbe.h ***********************/
1254412734
1254512735
/*
@@ -12682,11 +12872,11 @@
1268212872
SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
1268312873
#else
1268412874
# define sqlite3VdbeScanStatus(a,b,c,d,e)
1268512875
#endif
1268612876
12687
-#endif
12877
+#endif /* SQLITE_VDBE_H */
1268812878
1268912879
/************** End of vdbe.h ************************************************/
1269012880
/************** Continuing where we left off in sqliteInt.h ******************/
1269112881
/************** Include pager.h in the middle of sqliteInt.h *****************/
1269212882
/************** Begin file pager.h *******************************************/
@@ -12704,12 +12894,12 @@
1270412894
** This header file defines the interface that the sqlite page cache
1270512895
** subsystem. The page cache subsystem reads and writes a file a page
1270612896
** at a time and provides a journal for rollback.
1270712897
*/
1270812898
12709
-#ifndef _PAGER_H_
12710
-#define _PAGER_H_
12899
+#ifndef SQLITE_PAGER_H
12900
+#define SQLITE_PAGER_H
1271112901
1271212902
/*
1271312903
** Default maximum size for persistent journal files. A negative
1271412904
** value means no limit. This value may be overridden using the
1271512905
** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
@@ -12893,11 +13083,11 @@
1289313083
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
1289413084
SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
1289513085
SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
1289613086
SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
1289713087
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
12898
-SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
13088
+SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);
1289913089
SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
1290013090
1290113091
/* Functions used to truncate the database file. */
1290213092
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
1290313093
@@ -12920,11 +13110,11 @@
1292013110
#else
1292113111
# define disable_simulated_io_errors()
1292213112
# define enable_simulated_io_errors()
1292313113
#endif
1292413114
12925
-#endif /* _PAGER_H_ */
13115
+#endif /* SQLITE_PAGER_H */
1292613116
1292713117
/************** End of pager.h ***********************************************/
1292813118
/************** Continuing where we left off in sqliteInt.h ******************/
1292913119
/************** Include pcache.h in the middle of sqliteInt.h ****************/
1293013120
/************** Begin file pcache.h ******************************************/
@@ -13158,12 +13348,12 @@
1315813348
******************************************************************************
1315913349
**
1316013350
** This file contains pre-processor directives related to operating system
1316113351
** detection and/or setup.
1316213352
*/
13163
-#ifndef _OS_SETUP_H_
13164
-#define _OS_SETUP_H_
13353
+#ifndef SQLITE_OS_SETUP_H
13354
+#define SQLITE_OS_SETUP_H
1316513355
1316613356
/*
1316713357
** Figure out if we are dealing with Unix, Windows, or some other operating
1316813358
** system.
1316913359
**
@@ -13199,11 +13389,11 @@
1319913389
# ifndef SQLITE_OS_WIN
1320013390
# define SQLITE_OS_WIN 0
1320113391
# endif
1320213392
#endif
1320313393
13204
-#endif /* _OS_SETUP_H_ */
13394
+#endif /* SQLITE_OS_SETUP_H */
1320513395
1320613396
/************** End of os_setup.h ********************************************/
1320713397
/************** Continuing where we left off in os.h *************************/
1320813398
1320913399
/* If the SET_FULLSYNC macro is not defined above, then make it
@@ -13656,10 +13846,19 @@
1365613846
#else
1365713847
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
1365813848
const char*);
1365913849
#endif
1366013850
13851
+#ifndef SQLITE_OMIT_DEPRECATED
13852
+/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
13853
+** in the style of sqlite3_trace()
13854
+*/
13855
+#define SQLITE_TRACE_LEGACY 0x80
13856
+#else
13857
+#define SQLITE_TRACE_LEGACY 0
13858
+#endif /* SQLITE_OMIT_DEPRECATED */
13859
+
1366113860
1366213861
/*
1366313862
** Each database connection is an instance of the following structure.
1366413863
*/
1366513864
struct sqlite3 {
@@ -13685,10 +13884,11 @@
1368513884
u8 dfltLockMode; /* Default locking-mode for attached dbs */
1368613885
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
1368713886
u8 suppressErr; /* Do not issue error messages if true */
1368813887
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
1368913888
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
13889
+ u8 mTrace; /* zero or more SQLITE_TRACE flags */
1369013890
int nextPagesize; /* Pagesize after VACUUM if >0 */
1369113891
u32 magic; /* Magic number for detect library misuse */
1369213892
int nChange; /* Value returned by sqlite3_changes() */
1369313893
int nTotalChange; /* Value returned by sqlite3_total_changes() */
1369413894
int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -13705,11 +13905,11 @@
1370513905
int nVdbeWrite; /* Number of active VDBEs that read and write */
1370613906
int nVdbeExec; /* Number of nested calls to VdbeExec() */
1370713907
int nVDestroy; /* Number of active OP_VDestroy operations */
1370813908
int nExtension; /* Number of loaded extensions */
1370913909
void **aExtension; /* Array of shared library handles */
13710
- void (*xTrace)(void*,const char*); /* Trace function */
13910
+ int (*xTrace)(u32,void*,void*,void*); /* Trace function */
1371113911
void *pTraceArg; /* Argument to the trace function */
1371213912
void (*xProfile)(void*,const char*,u64); /* Profiling function */
1371313913
void *pProfileArg; /* Argument to profile function */
1371413914
void *pCommitArg; /* Argument to xCommitCallback() */
1371513915
int (*xCommitCallback)(void*); /* Invoked at every commit. */
@@ -14900,11 +15100,11 @@
1490015100
Select *pSelect; /* A SELECT statement used in place of a table name */
1490115101
int addrFillSub; /* Address of subroutine to manifest a subquery */
1490215102
int regReturn; /* Register holding return address of addrFillSub */
1490315103
int regResult; /* Registers holding results of a co-routine */
1490415104
struct {
14905
- u8 jointype; /* Type of join between this able and the previous */
15105
+ u8 jointype; /* Type of join between this table and the previous */
1490615106
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
1490715107
unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
1490815108
unsigned isTabFunc :1; /* True if table-valued-function syntax */
1490915109
unsigned isCorrelated :1; /* True if sub-query is correlated */
1491015110
unsigned viaCoroutine :1; /* Implemented as a co-routine */
@@ -14946,23 +15146,24 @@
1494615146
*/
1494715147
#define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
1494815148
#define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
1494915149
#define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
1495015150
#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
14951
-#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
14952
-#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
14953
-#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
14954
-#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
14955
-#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
14956
-#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
14957
-#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
14958
-#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
14959
-#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */
14960
-#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */
14961
-#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
14962
-#define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */
14963
-#define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */
15151
+#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */
15152
+#define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */
15153
+#define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of
15154
+ ** the OR optimization */
15155
+#define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */
15156
+#define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */
15157
+#define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */
15158
+#define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */
15159
+#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
15160
+#define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
15161
+ /* 0x1000 not currently used */
15162
+ /* 0x2000 not currently used */
15163
+#define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
15164
+ /* 0x8000 not currently used */
1496415165
1496515166
/* Allowed return values from sqlite3WhereIsDistinct()
1496615167
*/
1496715168
#define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
1496815169
#define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
@@ -15661,10 +15862,11 @@
1566115862
int iCur; /* A cursor number */
1566215863
SrcList *pSrcList; /* FROM clause */
1566315864
struct SrcCount *pSrcCount; /* Counting column references */
1566415865
struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
1566515866
int *aiCol; /* array of column indexes */
15867
+ struct IdxCover *pIdxCover; /* Check for index coverage */
1566615868
} u;
1566715869
};
1566815870
1566915871
/* Forward declarations */
1567015872
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -15844,15 +16046,19 @@
1584416046
# define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N)
1584516047
# define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N)
1584616048
# define sqlite3StackFree(D,P) sqlite3DbFree(D,P)
1584716049
#endif
1584816050
15849
-#ifdef SQLITE_ENABLE_MEMSYS3
15850
-SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
15851
-#endif
16051
+/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together. If they
16052
+** are, disable MEMSYS3
16053
+*/
1585216054
#ifdef SQLITE_ENABLE_MEMSYS5
1585316055
SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
16056
+#undef SQLITE_ENABLE_MEMSYS3
16057
+#endif
16058
+#ifdef SQLITE_ENABLE_MEMSYS3
16059
+SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
1585416060
#endif
1585516061
1585616062
1585716063
#ifndef SQLITE_MUTEX_OMIT
1585816064
SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
@@ -16031,12 +16237,12 @@
1603116237
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1603216238
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1603316239
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1603416240
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
1603516241
SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
16036
-SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16037
- Expr*, int, int);
16242
+SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16243
+ Expr*, int, int, u8);
1603816244
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1603916245
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1604016246
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1604116247
Expr*,ExprList*,u32,Expr*,Expr*);
1604216248
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -16051,10 +16257,11 @@
1605116257
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
1605216258
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
1605316259
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
1605416260
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
1605516261
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
16262
+SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
1605616263
SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
1605716264
SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
1605816265
SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
1605916266
SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
1606016267
#define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -16084,12 +16291,14 @@
1608416291
#define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
1608516292
SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
1608616293
SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
1608716294
SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
1608816295
SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
16089
-SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
16090
-SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
16296
+#define LOCATE_VIEW 0x01
16297
+#define LOCATE_NOERR 0x02
16298
+SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
16299
+SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
1609116300
SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
1609216301
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1609316302
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1609416303
SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
1609516304
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
@@ -16097,10 +16306,11 @@
1609716306
SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
1609816307
SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
1609916308
SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1610016309
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1610116310
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
16311
+SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
1610216312
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1610316313
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
1610416314
#ifndef SQLITE_OMIT_BUILTIN_TEST
1610516315
SQLITE_PRIVATE void sqlite3PrngSaveState(void);
1610616316
SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
@@ -16648,11 +16858,11 @@
1664816858
1664916859
#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
1665016860
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
1665116861
#endif
1665216862
16653
-#endif /* _SQLITEINT_H_ */
16863
+#endif /* SQLITEINT_H */
1665416864
1665516865
/************** End of sqliteInt.h *******************************************/
1665616866
/************** Begin file global.c ******************************************/
1665716867
/*
1665816868
** 2008 June 13
@@ -16983,10 +17193,19 @@
1698317193
"CASE_SENSITIVE_LIKE",
1698417194
#endif
1698517195
#if SQLITE_CHECK_PAGES
1698617196
"CHECK_PAGES",
1698717197
#endif
17198
+#if defined(__clang__) && defined(__clang_major__)
17199
+ "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
17200
+ CTIMEOPT_VAL(__clang_minor__) "."
17201
+ CTIMEOPT_VAL(__clang_patchlevel__),
17202
+#elif defined(_MSC_VER)
17203
+ "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17204
+#elif defined(__GNUC__) && defined(__VERSION__)
17205
+ "COMPILER=gcc-" __VERSION__,
17206
+#endif
1698817207
#if SQLITE_COVERAGE_TEST
1698917208
"COVERAGE_TEST",
1699017209
#endif
1699117210
#if SQLITE_DEBUG
1699217211
"DEBUG",
@@ -17002,11 +17221,11 @@
1700217221
#endif
1700317222
#if SQLITE_DISABLE_LFS
1700417223
"DISABLE_LFS",
1700517224
#endif
1700617225
#if SQLITE_ENABLE_8_3_NAMES
17007
- "ENABLE_8_3_NAMES",
17226
+ "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
1700817227
#endif
1700917228
#if SQLITE_ENABLE_API_ARMOR
1701017229
"ENABLE_API_ARMOR",
1701117230
#endif
1701217231
#if SQLITE_ENABLE_ATOMIC_WRITE
@@ -17416,12 +17635,12 @@
1741617635
** VDBE. This information used to all be at the top of the single
1741717636
** source code file "vdbe.c". When that file became too big (over
1741817637
** 6000 lines long) it was split up into several smaller files and
1741917638
** this header information was factored out.
1742017639
*/
17421
-#ifndef _VDBEINT_H_
17422
-#define _VDBEINT_H_
17640
+#ifndef SQLITE_VDBEINT_H
17641
+#define SQLITE_VDBEINT_H
1742317642
1742417643
/*
1742517644
** The maximum number of times that a statement will try to reparse
1742617645
** itself before giving up and returning SQLITE_SCHEMA.
1742717646
*/
@@ -17959,11 +18178,11 @@
1795918178
#else
1796018179
#define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
1796118180
#define ExpandBlob(P) SQLITE_OK
1796218181
#endif
1796318182
17964
-#endif /* !defined(_VDBEINT_H_) */
18183
+#endif /* !defined(SQLITE_VDBEINT_H) */
1796518184
1796618185
/************** End of vdbeInt.h *********************************************/
1796718186
/************** Continuing where we left off in status.c *********************/
1796818187
1796918188
/*
@@ -18106,11 +18325,11 @@
1810618325
sqlite3_mutex_leave(pMutex);
1810718326
(void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
1810818327
return SQLITE_OK;
1810918328
}
1811018329
SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
18111
- sqlite3_int64 iCur, iHwtr;
18330
+ sqlite3_int64 iCur = 0, iHwtr = 0;
1811218331
int rc;
1811318332
#ifdef SQLITE_ENABLE_API_ARMOR
1811418333
if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
1811518334
#endif
1811618335
rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
@@ -18167,19 +18386,24 @@
1816718386
/*
1816818387
** Return an approximation for the amount of memory currently used
1816918388
** by all pagers associated with the given database connection. The
1817018389
** highwater mark is meaningless and is returned as zero.
1817118390
*/
18391
+ case SQLITE_DBSTATUS_CACHE_USED_SHARED:
1817218392
case SQLITE_DBSTATUS_CACHE_USED: {
1817318393
int totalUsed = 0;
1817418394
int i;
1817518395
sqlite3BtreeEnterAll(db);
1817618396
for(i=0; i<db->nDb; i++){
1817718397
Btree *pBt = db->aDb[i].pBt;
1817818398
if( pBt ){
1817918399
Pager *pPager = sqlite3BtreePager(pBt);
18180
- totalUsed += sqlite3PagerMemUsed(pPager);
18400
+ int nByte = sqlite3PagerMemUsed(pPager);
18401
+ if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){
18402
+ nByte = nByte / sqlite3BtreeConnectionCount(pBt);
18403
+ }
18404
+ totalUsed += nByte;
1818118405
}
1818218406
}
1818318407
sqlite3BtreeLeaveAll(db);
1818418408
*pCurrent = totalUsed;
1818518409
*pHighwater = 0;
@@ -19409,11 +19633,10 @@
1940919633
int argc,
1941019634
sqlite3_value **argv
1941119635
){
1941219636
time_t t;
1941319637
char *zFormat = (char *)sqlite3_user_data(context);
19414
- sqlite3 *db;
1941519638
sqlite3_int64 iT;
1941619639
struct tm *pTm;
1941719640
struct tm sNow;
1941819641
char zBuf[20];
1941919642
@@ -19478,13 +19701,11 @@
1947819701
******************************************************************************
1947919702
**
1948019703
** This file contains OS interface code that is common to all
1948119704
** architectures.
1948219705
*/
19483
-#define _SQLITE_OS_C_ 1
1948419706
/* #include "sqliteInt.h" */
19485
-#undef _SQLITE_OS_C_
1948619707
1948719708
/*
1948819709
** If we compile with the SQLITE_TEST macro set, then the following block
1948919710
** of code will give us the ability to simulate a disk I/O error. This
1949019711
** is used for testing the I/O recovery logic.
@@ -22993,12 +23214,12 @@
2299323214
******************************************************************************
2299423215
**
2299523216
** This file contains inline asm code for retrieving "high-performance"
2299623217
** counters for x86 class CPUs.
2299723218
*/
22998
-#ifndef _HWTIME_H_
22999
-#define _HWTIME_H_
23219
+#ifndef SQLITE_HWTIME_H
23220
+#define SQLITE_HWTIME_H
2300023221
2300123222
/*
2300223223
** The following routine only works on pentium-class (or newer) processors.
2300323224
** It uses the RDTSC opcode to read the cycle count value out of the
2300423225
** processor and returns that value. This can be used for high-res
@@ -23062,11 +23283,11 @@
2306223283
*/
2306323284
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
2306423285
2306523286
#endif
2306623287
23067
-#endif /* !defined(_HWTIME_H_) */
23288
+#endif /* !defined(SQLITE_HWTIME_H) */
2306823289
2306923290
/************** End of hwtime.h **********************************************/
2307023291
/************** Continuing where we left off in os_common.h ******************/
2307123292
2307223293
static sqlite_uint64 g_start;
@@ -23152,12 +23373,12 @@
2315223373
**
2315323374
******************************************************************************
2315423375
**
2315523376
** This file contains code that is specific to Windows.
2315623377
*/
23157
-#ifndef _OS_WIN_H_
23158
-#define _OS_WIN_H_
23378
+#ifndef SQLITE_OS_WIN_H
23379
+#define SQLITE_OS_WIN_H
2315923380
2316023381
/*
2316123382
** Include the primary Windows SDK header file.
2316223383
*/
2316323384
#include "windows.h"
@@ -23225,11 +23446,11 @@
2322523446
# define SQLITE_OS_WIN_THREADS 1
2322623447
#else
2322723448
# define SQLITE_OS_WIN_THREADS 0
2322823449
#endif
2322923450
23230
-#endif /* _OS_WIN_H_ */
23451
+#endif /* SQLITE_OS_WIN_H */
2323123452
2323223453
/************** End of os_win.h **********************************************/
2323323454
/************** Continuing where we left off in mutex_w32.c ******************/
2323423455
#endif
2323523456
@@ -25976,10 +26197,16 @@
2597626197
}
2597726198
sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
2597826199
break;
2597926200
}
2598026201
#endif
26202
+ case TK_MATCH: {
26203
+ sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26204
+ pExpr->iTable, pExpr->iColumn, zFlgs);
26205
+ sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26206
+ break;
26207
+ }
2598126208
default: {
2598226209
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
2598326210
break;
2598426211
}
2598526212
}
@@ -28759,21 +28986,21 @@
2875928986
/* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
2876028987
/* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
2876128988
/* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
2876228989
/* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
2876328990
/* 31 */ "Found" OpHelp("key=r[P3@P4]"),
28764
- /* 32 */ "NotExists" OpHelp("intkey=r[P3]"),
28765
- /* 33 */ "Last" OpHelp(""),
28991
+ /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
28992
+ /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
2876628993
/* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
2876728994
/* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
2876828995
/* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
2876928996
/* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
2877028997
/* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
2877128998
/* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
2877228999
/* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
2877329000
/* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
28774
- /* 42 */ "SorterSort" OpHelp(""),
29001
+ /* 42 */ "Last" OpHelp(""),
2877529002
/* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
2877629003
/* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
2877729004
/* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
2877829005
/* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
2877929006
/* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -28780,118 +29007,119 @@
2878029007
/* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
2878129008
/* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
2878229009
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
2878329010
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
2878429011
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
28785
- /* 53 */ "Sort" OpHelp(""),
29012
+ /* 53 */ "SorterSort" OpHelp(""),
2878629013
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
28787
- /* 55 */ "Rewind" OpHelp(""),
28788
- /* 56 */ "IdxLE" OpHelp("key=r[P3@P4]"),
28789
- /* 57 */ "IdxGT" OpHelp("key=r[P3@P4]"),
28790
- /* 58 */ "IdxLT" OpHelp("key=r[P3@P4]"),
28791
- /* 59 */ "IdxGE" OpHelp("key=r[P3@P4]"),
28792
- /* 60 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
28793
- /* 61 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
28794
- /* 62 */ "Program" OpHelp(""),
28795
- /* 63 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
28796
- /* 64 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
28797
- /* 65 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
28798
- /* 66 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
28799
- /* 67 */ "IncrVacuum" OpHelp(""),
28800
- /* 68 */ "VNext" OpHelp(""),
28801
- /* 69 */ "Init" OpHelp("Start at P2"),
28802
- /* 70 */ "Return" OpHelp(""),
28803
- /* 71 */ "EndCoroutine" OpHelp(""),
28804
- /* 72 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
28805
- /* 73 */ "Halt" OpHelp(""),
28806
- /* 74 */ "Integer" OpHelp("r[P2]=P1"),
28807
- /* 75 */ "Int64" OpHelp("r[P2]=P4"),
28808
- /* 76 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
28809
- /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"),
28810
- /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"),
28811
- /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
28812
- /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
28813
- /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
28814
- /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
28815
- /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"),
28816
- /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
28817
- /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
28818
- /* 86 */ "CollSeq" OpHelp(""),
28819
- /* 87 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
28820
- /* 88 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
28821
- /* 89 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
28822
- /* 90 */ "RealAffinity" OpHelp(""),
28823
- /* 91 */ "Cast" OpHelp("affinity(r[P1])"),
28824
- /* 92 */ "Permutation" OpHelp(""),
28825
- /* 93 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
28826
- /* 94 */ "Column" OpHelp("r[P3]=PX"),
28827
- /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
28828
- /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29014
+ /* 55 */ "Sort" OpHelp(""),
29015
+ /* 56 */ "Rewind" OpHelp(""),
29016
+ /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29017
+ /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29018
+ /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29019
+ /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29020
+ /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29021
+ /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29022
+ /* 63 */ "Program" OpHelp(""),
29023
+ /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29024
+ /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29025
+ /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29026
+ /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29027
+ /* 68 */ "IncrVacuum" OpHelp(""),
29028
+ /* 69 */ "VNext" OpHelp(""),
29029
+ /* 70 */ "Init" OpHelp("Start at P2"),
29030
+ /* 71 */ "Return" OpHelp(""),
29031
+ /* 72 */ "EndCoroutine" OpHelp(""),
29032
+ /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29033
+ /* 74 */ "Halt" OpHelp(""),
29034
+ /* 75 */ "Integer" OpHelp("r[P2]=P1"),
29035
+ /* 76 */ "Int64" OpHelp("r[P2]=P4"),
29036
+ /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29037
+ /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29038
+ /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29039
+ /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29040
+ /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29041
+ /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29042
+ /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29043
+ /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29044
+ /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29045
+ /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29046
+ /* 87 */ "CollSeq" OpHelp(""),
29047
+ /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29048
+ /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29049
+ /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29050
+ /* 91 */ "RealAffinity" OpHelp(""),
29051
+ /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29052
+ /* 93 */ "Permutation" OpHelp(""),
29053
+ /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29054
+ /* 95 */ "Column" OpHelp("r[P3]=PX"),
29055
+ /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
2882929056
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
28830
- /* 98 */ "Count" OpHelp("r[P2]=count()"),
28831
- /* 99 */ "ReadCookie" OpHelp(""),
28832
- /* 100 */ "SetCookie" OpHelp(""),
28833
- /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
28834
- /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
28835
- /* 103 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
28836
- /* 104 */ "OpenAutoindex" OpHelp("nColumn=P2"),
28837
- /* 105 */ "OpenEphemeral" OpHelp("nColumn=P2"),
28838
- /* 106 */ "SorterOpen" OpHelp(""),
28839
- /* 107 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
28840
- /* 108 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
28841
- /* 109 */ "Close" OpHelp(""),
28842
- /* 110 */ "ColumnsUsed" OpHelp(""),
28843
- /* 111 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
28844
- /* 112 */ "NewRowid" OpHelp("r[P2]=rowid"),
28845
- /* 113 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
28846
- /* 114 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
28847
- /* 115 */ "Delete" OpHelp(""),
28848
- /* 116 */ "ResetCount" OpHelp(""),
28849
- /* 117 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
28850
- /* 118 */ "SorterData" OpHelp("r[P2]=data"),
28851
- /* 119 */ "RowKey" OpHelp("r[P2]=key"),
28852
- /* 120 */ "RowData" OpHelp("r[P2]=data"),
28853
- /* 121 */ "Rowid" OpHelp("r[P2]=rowid"),
28854
- /* 122 */ "NullRow" OpHelp(""),
28855
- /* 123 */ "SorterInsert" OpHelp(""),
28856
- /* 124 */ "IdxInsert" OpHelp("key=r[P2]"),
28857
- /* 125 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
28858
- /* 126 */ "Seek" OpHelp("Move P3 to P1.rowid"),
28859
- /* 127 */ "IdxRowid" OpHelp("r[P2]=rowid"),
28860
- /* 128 */ "Destroy" OpHelp(""),
28861
- /* 129 */ "Clear" OpHelp(""),
28862
- /* 130 */ "ResetSorter" OpHelp(""),
28863
- /* 131 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
28864
- /* 132 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29057
+ /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29058
+ /* 99 */ "Count" OpHelp("r[P2]=count()"),
29059
+ /* 100 */ "ReadCookie" OpHelp(""),
29060
+ /* 101 */ "SetCookie" OpHelp(""),
29061
+ /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29062
+ /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29063
+ /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29064
+ /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29065
+ /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29066
+ /* 107 */ "SorterOpen" OpHelp(""),
29067
+ /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29068
+ /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29069
+ /* 110 */ "Close" OpHelp(""),
29070
+ /* 111 */ "ColumnsUsed" OpHelp(""),
29071
+ /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29072
+ /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29073
+ /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29074
+ /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29075
+ /* 116 */ "Delete" OpHelp(""),
29076
+ /* 117 */ "ResetCount" OpHelp(""),
29077
+ /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29078
+ /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29079
+ /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29080
+ /* 121 */ "RowData" OpHelp("r[P2]=data"),
29081
+ /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29082
+ /* 123 */ "NullRow" OpHelp(""),
29083
+ /* 124 */ "SorterInsert" OpHelp(""),
29084
+ /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29085
+ /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29086
+ /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29087
+ /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29088
+ /* 129 */ "Destroy" OpHelp(""),
29089
+ /* 130 */ "Clear" OpHelp(""),
29090
+ /* 131 */ "ResetSorter" OpHelp(""),
29091
+ /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
2886529092
/* 133 */ "Real" OpHelp("r[P2]=P4"),
28866
- /* 134 */ "ParseSchema" OpHelp(""),
28867
- /* 135 */ "LoadAnalysis" OpHelp(""),
28868
- /* 136 */ "DropTable" OpHelp(""),
28869
- /* 137 */ "DropIndex" OpHelp(""),
28870
- /* 138 */ "DropTrigger" OpHelp(""),
28871
- /* 139 */ "IntegrityCk" OpHelp(""),
28872
- /* 140 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
28873
- /* 141 */ "Param" OpHelp(""),
28874
- /* 142 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
28875
- /* 143 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
28876
- /* 144 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
28877
- /* 145 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
28878
- /* 146 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
28879
- /* 147 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
28880
- /* 148 */ "Expire" OpHelp(""),
28881
- /* 149 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
28882
- /* 150 */ "VBegin" OpHelp(""),
28883
- /* 151 */ "VCreate" OpHelp(""),
28884
- /* 152 */ "VDestroy" OpHelp(""),
28885
- /* 153 */ "VOpen" OpHelp(""),
28886
- /* 154 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
28887
- /* 155 */ "VRename" OpHelp(""),
28888
- /* 156 */ "Pagecount" OpHelp(""),
28889
- /* 157 */ "MaxPgcnt" OpHelp(""),
28890
- /* 158 */ "CursorHint" OpHelp(""),
28891
- /* 159 */ "Noop" OpHelp(""),
28892
- /* 160 */ "Explain" OpHelp(""),
29093
+ /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29094
+ /* 135 */ "ParseSchema" OpHelp(""),
29095
+ /* 136 */ "LoadAnalysis" OpHelp(""),
29096
+ /* 137 */ "DropTable" OpHelp(""),
29097
+ /* 138 */ "DropIndex" OpHelp(""),
29098
+ /* 139 */ "DropTrigger" OpHelp(""),
29099
+ /* 140 */ "IntegrityCk" OpHelp(""),
29100
+ /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29101
+ /* 142 */ "Param" OpHelp(""),
29102
+ /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29103
+ /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29104
+ /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29105
+ /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29106
+ /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29107
+ /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29108
+ /* 149 */ "Expire" OpHelp(""),
29109
+ /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29110
+ /* 151 */ "VBegin" OpHelp(""),
29111
+ /* 152 */ "VCreate" OpHelp(""),
29112
+ /* 153 */ "VDestroy" OpHelp(""),
29113
+ /* 154 */ "VOpen" OpHelp(""),
29114
+ /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29115
+ /* 156 */ "VRename" OpHelp(""),
29116
+ /* 157 */ "Pagecount" OpHelp(""),
29117
+ /* 158 */ "MaxPgcnt" OpHelp(""),
29118
+ /* 159 */ "CursorHint" OpHelp(""),
29119
+ /* 160 */ "Noop" OpHelp(""),
29120
+ /* 161 */ "Explain" OpHelp(""),
2889329121
};
2889429122
return azName[i];
2889529123
}
2889629124
#endif
2889729125
@@ -29237,12 +29465,12 @@
2923729465
******************************************************************************
2923829466
**
2923929467
** This file contains inline asm code for retrieving "high-performance"
2924029468
** counters for x86 class CPUs.
2924129469
*/
29242
-#ifndef _HWTIME_H_
29243
-#define _HWTIME_H_
29470
+#ifndef SQLITE_HWTIME_H
29471
+#define SQLITE_HWTIME_H
2924429472
2924529473
/*
2924629474
** The following routine only works on pentium-class (or newer) processors.
2924729475
** It uses the RDTSC opcode to read the cycle count value out of the
2924829476
** processor and returns that value. This can be used for high-res
@@ -29306,11 +29534,11 @@
2930629534
*/
2930729535
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
2930829536
2930929537
#endif
2931029538
29311
-#endif /* !defined(_HWTIME_H_) */
29539
+#endif /* !defined(SQLITE_HWTIME_H) */
2931229540
2931329541
/************** End of hwtime.h **********************************************/
2931429542
/************** Continuing where we left off in os_common.h ******************/
2931529543
2931629544
static sqlite_uint64 g_start;
@@ -36766,12 +36994,12 @@
3676636994
******************************************************************************
3676736995
**
3676836996
** This file contains inline asm code for retrieving "high-performance"
3676936997
** counters for x86 class CPUs.
3677036998
*/
36771
-#ifndef _HWTIME_H_
36772
-#define _HWTIME_H_
36999
+#ifndef SQLITE_HWTIME_H
37000
+#define SQLITE_HWTIME_H
3677337001
3677437002
/*
3677537003
** The following routine only works on pentium-class (or newer) processors.
3677637004
** It uses the RDTSC opcode to read the cycle count value out of the
3677737005
** processor and returns that value. This can be used for high-res
@@ -36835,11 +37063,11 @@
3683537063
*/
3683637064
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
3683737065
3683837066
#endif
3683937067
36840
-#endif /* !defined(_HWTIME_H_) */
37068
+#endif /* !defined(SQLITE_HWTIME_H) */
3684137069
3684237070
/************** End of hwtime.h **********************************************/
3684337071
/************** Continuing where we left off in os_common.h ******************/
3684437072
3684537073
static sqlite_uint64 g_start;
@@ -37175,10 +37403,21 @@
3717537403
sqlite3_int64 mmapSize; /* Usable size of mapped region */
3717637404
sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */
3717737405
sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */
3717837406
#endif
3717937407
};
37408
+
37409
+/*
37410
+** The winVfsAppData structure is used for the pAppData member for all of the
37411
+** Win32 VFS variants.
37412
+*/
37413
+typedef struct winVfsAppData winVfsAppData;
37414
+struct winVfsAppData {
37415
+ const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */
37416
+ void *pAppData; /* The extra pAppData, if any. */
37417
+ BOOL bNoLock; /* Non-zero if locking is disabled. */
37418
+};
3718037419
3718137420
/*
3718237421
** Allowed values for winFile.ctrlFlags
3718337422
*/
3718437423
#define WINFILE_RDONLY 0x02 /* Connection is read only */
@@ -39497,11 +39736,16 @@
3949739736
rc = osCloseHandle(pFile->h);
3949839737
/* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
3949939738
}while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
3950039739
#if SQLITE_OS_WINCE
3950139740
#define WINCE_DELETION_ATTEMPTS 3
39502
- winceDestroyLock(pFile);
39741
+ {
39742
+ winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;
39743
+ if( pAppData==NULL || !pAppData->bNoLock ){
39744
+ winceDestroyLock(pFile);
39745
+ }
39746
+ }
3950339747
if( pFile->zDeleteOnClose ){
3950439748
int cnt = 0;
3950539749
while(
3950639750
osDeleteFileW(pFile->zDeleteOnClose)==0
3950739751
&& osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
@@ -40229,10 +40473,48 @@
4022940473
OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
4023040474
pFile->h, pFile->locktype, sqlite3ErrName(rc)));
4023140475
return rc;
4023240476
}
4023340477
40478
+/******************************************************************************
40479
+****************************** No-op Locking **********************************
40480
+**
40481
+** Of the various locking implementations available, this is by far the
40482
+** simplest: locking is ignored. No attempt is made to lock the database
40483
+** file for reading or writing.
40484
+**
40485
+** This locking mode is appropriate for use on read-only databases
40486
+** (ex: databases that are burned into CD-ROM, for example.) It can
40487
+** also be used if the application employs some external mechanism to
40488
+** prevent simultaneous access of the same database by two or more
40489
+** database connections. But there is a serious risk of database
40490
+** corruption if this locking mode is used in situations where multiple
40491
+** database connections are accessing the same database file at the same
40492
+** time and one or more of those connections are writing.
40493
+*/
40494
+
40495
+static int winNolockLock(sqlite3_file *id, int locktype){
40496
+ UNUSED_PARAMETER(id);
40497
+ UNUSED_PARAMETER(locktype);
40498
+ return SQLITE_OK;
40499
+}
40500
+
40501
+static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){
40502
+ UNUSED_PARAMETER(id);
40503
+ UNUSED_PARAMETER(pResOut);
40504
+ return SQLITE_OK;
40505
+}
40506
+
40507
+static int winNolockUnlock(sqlite3_file *id, int locktype){
40508
+ UNUSED_PARAMETER(id);
40509
+ UNUSED_PARAMETER(locktype);
40510
+ return SQLITE_OK;
40511
+}
40512
+
40513
+/******************* End of the no-op lock implementation *********************
40514
+******************************************************************************/
40515
+
4023440516
/*
4023540517
** If *pArg is initially negative then this is a query. Set *pArg to
4023640518
** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
4023740519
**
4023840520
** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
@@ -40507,16 +40789,16 @@
4050740789
#define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
4050840790
4050940791
/*
4051040792
** Apply advisory locks for all n bytes beginning at ofst.
4051140793
*/
40512
-#define _SHM_UNLCK 1
40513
-#define _SHM_RDLCK 2
40514
-#define _SHM_WRLCK 3
40794
+#define WINSHM_UNLCK 1
40795
+#define WINSHM_RDLCK 2
40796
+#define WINSHM_WRLCK 3
4051540797
static int winShmSystemLock(
4051640798
winShmNode *pFile, /* Apply locks to this open shared-memory segment */
40517
- int lockType, /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */
40799
+ int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */
4051840800
int ofst, /* Offset to first byte to be locked/unlocked */
4051940801
int nByte /* Number of bytes to lock or unlock */
4052040802
){
4052140803
int rc = 0; /* Result code form Lock/UnlockFileEx() */
4052240804
@@ -40525,16 +40807,16 @@
4052540807
4052640808
OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
4052740809
pFile->hFile.h, lockType, ofst, nByte));
4052840810
4052940811
/* Release/Acquire the system-level lock */
40530
- if( lockType==_SHM_UNLCK ){
40812
+ if( lockType==WINSHM_UNLCK ){
4053140813
rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
4053240814
}else{
4053340815
/* Initialize the locking parameters */
4053440816
DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
40535
- if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
40817
+ if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
4053640818
rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
4053740819
}
4053840820
4053940821
if( rc!= 0 ){
4054040822
rc = SQLITE_OK;
@@ -40542,11 +40824,11 @@
4054240824
pFile->lastErrno = osGetLastError();
4054340825
rc = SQLITE_BUSY;
4054440826
}
4054540827
4054640828
OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
40547
- pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" :
40829
+ pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" :
4054840830
"winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
4054940831
4055040832
return rc;
4055140833
}
4055240834
@@ -40670,20 +40952,20 @@
4067040952
}
4067140953
4067240954
/* Check to see if another process is holding the dead-man switch.
4067340955
** If not, truncate the file to zero length.
4067440956
*/
40675
- if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
40957
+ if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
4067640958
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
4067740959
if( rc!=SQLITE_OK ){
4067840960
rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
4067940961
"winOpenShm", pDbFd->zPath);
4068040962
}
4068140963
}
4068240964
if( rc==SQLITE_OK ){
40683
- winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40684
- rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
40965
+ winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40966
+ rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);
4068540967
}
4068640968
if( rc ) goto shm_open_err;
4068740969
}
4068840970
4068940971
/* Make the new connection a child of the winShmNode */
@@ -40708,11 +40990,11 @@
4070840990
sqlite3_mutex_leave(pShmNode->mutex);
4070940991
return SQLITE_OK;
4071040992
4071140993
/* Jump here on any error */
4071240994
shm_open_err:
40713
- winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
40995
+ winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
4071440996
winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
4071540997
sqlite3_free(p);
4071640998
sqlite3_free(pNew);
4071740999
winShmLeaveMutex();
4071841000
return rc;
@@ -40797,11 +41079,11 @@
4079741079
allMask |= pX->sharedMask;
4079841080
}
4079941081
4080041082
/* Unlock the system-level locks */
4080141083
if( (mask & allMask)==0 ){
40802
- rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n);
41084
+ rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);
4080341085
}else{
4080441086
rc = SQLITE_OK;
4080541087
}
4080641088
4080741089
/* Undo the local locks */
@@ -40825,11 +41107,11 @@
4082541107
}
4082641108
4082741109
/* Get shared locks at the system level, if necessary */
4082841110
if( rc==SQLITE_OK ){
4082941111
if( (allShared & mask)==0 ){
40830
- rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n);
41112
+ rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);
4083141113
}else{
4083241114
rc = SQLITE_OK;
4083341115
}
4083441116
}
4083541117
@@ -40850,11 +41132,11 @@
4085041132
4085141133
/* Get the exclusive locks at the system level. Then if successful
4085241134
** also mark the local connection as being locked.
4085341135
*/
4085441136
if( rc==SQLITE_OK ){
40855
- rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
41137
+ rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);
4085641138
if( rc==SQLITE_OK ){
4085741139
assert( (p->sharedMask & mask)==0 );
4085841140
p->exclMask |= mask;
4085941141
}
4086041142
}
@@ -41292,10 +41574,48 @@
4129241574
winShmBarrier, /* xShmBarrier */
4129341575
winShmUnmap, /* xShmUnmap */
4129441576
winFetch, /* xFetch */
4129541577
winUnfetch /* xUnfetch */
4129641578
};
41579
+
41580
+/*
41581
+** This vector defines all the methods that can operate on an
41582
+** sqlite3_file for win32 without performing any locking.
41583
+*/
41584
+static const sqlite3_io_methods winIoNolockMethod = {
41585
+ 3, /* iVersion */
41586
+ winClose, /* xClose */
41587
+ winRead, /* xRead */
41588
+ winWrite, /* xWrite */
41589
+ winTruncate, /* xTruncate */
41590
+ winSync, /* xSync */
41591
+ winFileSize, /* xFileSize */
41592
+ winNolockLock, /* xLock */
41593
+ winNolockUnlock, /* xUnlock */
41594
+ winNolockCheckReservedLock, /* xCheckReservedLock */
41595
+ winFileControl, /* xFileControl */
41596
+ winSectorSize, /* xSectorSize */
41597
+ winDeviceCharacteristics, /* xDeviceCharacteristics */
41598
+ winShmMap, /* xShmMap */
41599
+ winShmLock, /* xShmLock */
41600
+ winShmBarrier, /* xShmBarrier */
41601
+ winShmUnmap, /* xShmUnmap */
41602
+ winFetch, /* xFetch */
41603
+ winUnfetch /* xUnfetch */
41604
+};
41605
+
41606
+static winVfsAppData winAppData = {
41607
+ &winIoMethod, /* pMethod */
41608
+ 0, /* pAppData */
41609
+ 0 /* bNoLock */
41610
+};
41611
+
41612
+static winVfsAppData winNolockAppData = {
41613
+ &winIoNolockMethod, /* pMethod */
41614
+ 0, /* pAppData */
41615
+ 1 /* bNoLock */
41616
+};
4129741617
4129841618
/****************************************************************************
4129941619
**************************** sqlite3_vfs methods ****************************
4130041620
**
4130141621
** This division contains the implementation of methods on the
@@ -41625,11 +41945,11 @@
4162541945
4162641946
/*
4162741947
** Open a file.
4162841948
*/
4162941949
static int winOpen(
41630
- sqlite3_vfs *pVfs, /* Used to get maximum path name length */
41950
+ sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
4163141951
const char *zName, /* Name of the file (UTF-8) */
4163241952
sqlite3_file *id, /* Write the SQLite file handle here */
4163341953
int flags, /* Open mode flags */
4163441954
int *pOutFlags /* Status return flags */
4163541955
){
@@ -41640,10 +41960,11 @@
4164041960
DWORD dwCreationDisposition;
4164141961
DWORD dwFlagsAndAttributes = 0;
4164241962
#if SQLITE_OS_WINCE
4164341963
int isTemp = 0;
4164441964
#endif
41965
+ winVfsAppData *pAppData;
4164541966
winFile *pFile = (winFile*)id;
4164641967
void *zConverted; /* Filename in OS encoding */
4164741968
const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
4164841969
int cnt = 0;
4164941970
@@ -41861,19 +42182,24 @@
4186142182
4186242183
OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
4186342184
"rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
4186442185
*pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
4186542186
42187
+ pAppData = (winVfsAppData*)pVfs->pAppData;
42188
+
4186642189
#if SQLITE_OS_WINCE
41867
- if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
41868
- && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
41869
- ){
41870
- osCloseHandle(h);
41871
- sqlite3_free(zConverted);
41872
- sqlite3_free(zTmpname);
41873
- OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
41874
- return rc;
42190
+ {
42191
+ if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
42192
+ && ((pAppData==NULL) || !pAppData->bNoLock)
42193
+ && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
42194
+ ){
42195
+ osCloseHandle(h);
42196
+ sqlite3_free(zConverted);
42197
+ sqlite3_free(zTmpname);
42198
+ OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
42199
+ return rc;
42200
+ }
4187542201
}
4187642202
if( isTemp ){
4187742203
pFile->zDeleteOnClose = zConverted;
4187842204
}else
4187942205
#endif
@@ -41880,11 +42206,11 @@
4188042206
{
4188142207
sqlite3_free(zConverted);
4188242208
}
4188342209
4188442210
sqlite3_free(zTmpname);
41885
- pFile->pMethod = &winIoMethod;
42211
+ pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;
4188642212
pFile->pVfs = pVfs;
4188742213
pFile->h = h;
4188842214
if( isReadonly ){
4188942215
pFile->ctrlFlags |= WINFILE_RDONLY;
4189042216
}
@@ -42155,10 +42481,22 @@
4215542481
sqlite3_vfs *pVfs, /* Pointer to vfs object */
4215642482
const char *zRelative, /* Possibly relative input path */
4215742483
int nFull, /* Size of output buffer in bytes */
4215842484
char *zFull /* Output buffer */
4215942485
){
42486
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42487
+ DWORD nByte;
42488
+ void *zConverted;
42489
+ char *zOut;
42490
+#endif
42491
+
42492
+ /* If this path name begins with "/X:", where "X" is any alphabetic
42493
+ ** character, discard the initial "/" from the pathname.
42494
+ */
42495
+ if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42496
+ zRelative++;
42497
+ }
4216042498
4216142499
#if defined(__CYGWIN__)
4216242500
SimulateIOError( return SQLITE_ERROR );
4216342501
UNUSED_PARAMETER(nFull);
4216442502
assert( nFull>=pVfs->mxPathname );
@@ -42233,21 +42571,10 @@
4223342571
}
4223442572
return SQLITE_OK;
4223542573
#endif
4223642574
4223742575
#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
-
4224942576
/* It's odd to simulate an io-error here, but really this is just
4225042577
** using the io-error infrastructure to test that SQLite handles this
4225142578
** function failing. This function could fail if, for example, the
4225242579
** current working directory has been unlinked.
4225342580
*/
@@ -42602,57 +42929,107 @@
4260242929
/*
4260342930
** Initialize and deinitialize the operating system interface.
4260442931
*/
4260542932
SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
4260642933
static sqlite3_vfs winVfs = {
42607
- 3, /* iVersion */
42608
- sizeof(winFile), /* szOsFile */
42934
+ 3, /* iVersion */
42935
+ sizeof(winFile), /* szOsFile */
4260942936
SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42610
- 0, /* pNext */
42611
- "win32", /* zName */
42612
- 0, /* pAppData */
42613
- winOpen, /* xOpen */
42614
- winDelete, /* xDelete */
42615
- winAccess, /* xAccess */
42616
- winFullPathname, /* xFullPathname */
42617
- winDlOpen, /* xDlOpen */
42618
- winDlError, /* xDlError */
42619
- winDlSym, /* xDlSym */
42620
- winDlClose, /* xDlClose */
42621
- winRandomness, /* xRandomness */
42622
- winSleep, /* xSleep */
42623
- winCurrentTime, /* xCurrentTime */
42624
- winGetLastError, /* xGetLastError */
42625
- winCurrentTimeInt64, /* xCurrentTimeInt64 */
42626
- winSetSystemCall, /* xSetSystemCall */
42627
- winGetSystemCall, /* xGetSystemCall */
42628
- winNextSystemCall, /* xNextSystemCall */
42937
+ 0, /* pNext */
42938
+ "win32", /* zName */
42939
+ &winAppData, /* pAppData */
42940
+ winOpen, /* xOpen */
42941
+ winDelete, /* xDelete */
42942
+ winAccess, /* xAccess */
42943
+ winFullPathname, /* xFullPathname */
42944
+ winDlOpen, /* xDlOpen */
42945
+ winDlError, /* xDlError */
42946
+ winDlSym, /* xDlSym */
42947
+ winDlClose, /* xDlClose */
42948
+ winRandomness, /* xRandomness */
42949
+ winSleep, /* xSleep */
42950
+ winCurrentTime, /* xCurrentTime */
42951
+ winGetLastError, /* xGetLastError */
42952
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42953
+ winSetSystemCall, /* xSetSystemCall */
42954
+ winGetSystemCall, /* xGetSystemCall */
42955
+ winNextSystemCall, /* xNextSystemCall */
4262942956
};
4263042957
#if defined(SQLITE_WIN32_HAS_WIDE)
4263142958
static sqlite3_vfs winLongPathVfs = {
42632
- 3, /* iVersion */
42633
- sizeof(winFile), /* szOsFile */
42959
+ 3, /* iVersion */
42960
+ sizeof(winFile), /* szOsFile */
42961
+ SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42962
+ 0, /* pNext */
42963
+ "win32-longpath", /* zName */
42964
+ &winAppData, /* pAppData */
42965
+ winOpen, /* xOpen */
42966
+ winDelete, /* xDelete */
42967
+ winAccess, /* xAccess */
42968
+ winFullPathname, /* xFullPathname */
42969
+ winDlOpen, /* xDlOpen */
42970
+ winDlError, /* xDlError */
42971
+ winDlSym, /* xDlSym */
42972
+ winDlClose, /* xDlClose */
42973
+ winRandomness, /* xRandomness */
42974
+ winSleep, /* xSleep */
42975
+ winCurrentTime, /* xCurrentTime */
42976
+ winGetLastError, /* xGetLastError */
42977
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
42978
+ winSetSystemCall, /* xSetSystemCall */
42979
+ winGetSystemCall, /* xGetSystemCall */
42980
+ winNextSystemCall, /* xNextSystemCall */
42981
+ };
42982
+#endif
42983
+ static sqlite3_vfs winNolockVfs = {
42984
+ 3, /* iVersion */
42985
+ sizeof(winFile), /* szOsFile */
42986
+ SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42987
+ 0, /* pNext */
42988
+ "win32-none", /* zName */
42989
+ &winNolockAppData, /* pAppData */
42990
+ winOpen, /* xOpen */
42991
+ winDelete, /* xDelete */
42992
+ winAccess, /* xAccess */
42993
+ winFullPathname, /* xFullPathname */
42994
+ winDlOpen, /* xDlOpen */
42995
+ winDlError, /* xDlError */
42996
+ winDlSym, /* xDlSym */
42997
+ winDlClose, /* xDlClose */
42998
+ winRandomness, /* xRandomness */
42999
+ winSleep, /* xSleep */
43000
+ winCurrentTime, /* xCurrentTime */
43001
+ winGetLastError, /* xGetLastError */
43002
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
43003
+ winSetSystemCall, /* xSetSystemCall */
43004
+ winGetSystemCall, /* xGetSystemCall */
43005
+ winNextSystemCall, /* xNextSystemCall */
43006
+ };
43007
+#if defined(SQLITE_WIN32_HAS_WIDE)
43008
+ static sqlite3_vfs winLongPathNolockVfs = {
43009
+ 3, /* iVersion */
43010
+ sizeof(winFile), /* szOsFile */
4263443011
SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42635
- 0, /* pNext */
42636
- "win32-longpath", /* zName */
42637
- 0, /* pAppData */
42638
- winOpen, /* xOpen */
42639
- winDelete, /* xDelete */
42640
- winAccess, /* xAccess */
42641
- winFullPathname, /* xFullPathname */
42642
- winDlOpen, /* xDlOpen */
42643
- winDlError, /* xDlError */
42644
- winDlSym, /* xDlSym */
42645
- winDlClose, /* xDlClose */
42646
- winRandomness, /* xRandomness */
42647
- winSleep, /* xSleep */
42648
- winCurrentTime, /* xCurrentTime */
42649
- winGetLastError, /* xGetLastError */
42650
- winCurrentTimeInt64, /* xCurrentTimeInt64 */
42651
- winSetSystemCall, /* xSetSystemCall */
42652
- winGetSystemCall, /* xGetSystemCall */
42653
- winNextSystemCall, /* xNextSystemCall */
43012
+ 0, /* pNext */
43013
+ "win32-longpath-none", /* zName */
43014
+ &winNolockAppData, /* pAppData */
43015
+ winOpen, /* xOpen */
43016
+ winDelete, /* xDelete */
43017
+ winAccess, /* xAccess */
43018
+ winFullPathname, /* xFullPathname */
43019
+ winDlOpen, /* xDlOpen */
43020
+ winDlError, /* xDlError */
43021
+ winDlSym, /* xDlSym */
43022
+ winDlClose, /* xDlClose */
43023
+ winRandomness, /* xRandomness */
43024
+ winSleep, /* xSleep */
43025
+ winCurrentTime, /* xCurrentTime */
43026
+ winGetLastError, /* xGetLastError */
43027
+ winCurrentTimeInt64, /* xCurrentTimeInt64 */
43028
+ winSetSystemCall, /* xSetSystemCall */
43029
+ winGetSystemCall, /* xGetSystemCall */
43030
+ winNextSystemCall, /* xNextSystemCall */
4265443031
};
4265543032
#endif
4265643033
4265743034
/* Double-check that the aSyscall[] array has been constructed
4265843035
** correctly. See ticket [bb3a86e890c8e96ab] */
@@ -42671,10 +43048,16 @@
4267143048
sqlite3_vfs_register(&winVfs, 1);
4267243049
4267343050
#if defined(SQLITE_WIN32_HAS_WIDE)
4267443051
sqlite3_vfs_register(&winLongPathVfs, 0);
4267543052
#endif
43053
+
43054
+ sqlite3_vfs_register(&winNolockVfs, 0);
43055
+
43056
+#if defined(SQLITE_WIN32_HAS_WIDE)
43057
+ sqlite3_vfs_register(&winLongPathNolockVfs, 0);
43058
+#endif
4267643059
4267743060
return SQLITE_OK;
4267843061
}
4267943062
4268043063
SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
@@ -43792,32 +44175,34 @@
4379244175
sqlite3PcacheTruncate(pCache, 0);
4379344176
}
4379444177
4379544178
/*
4379644179
** Merge two lists of pages connected by pDirty and in pgno order.
43797
-** Do not both fixing the pDirtyPrev pointers.
44180
+** Do not bother fixing the pDirtyPrev pointers.
4379844181
*/
4379944182
static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
4380044183
PgHdr result, *pTail;
4380144184
pTail = &result;
43802
- while( pA && pB ){
44185
+ assert( pA!=0 && pB!=0 );
44186
+ for(;;){
4380344187
if( pA->pgno<pB->pgno ){
4380444188
pTail->pDirty = pA;
4380544189
pTail = pA;
4380644190
pA = pA->pDirty;
44191
+ if( pA==0 ){
44192
+ pTail->pDirty = pB;
44193
+ break;
44194
+ }
4380744195
}else{
4380844196
pTail->pDirty = pB;
4380944197
pTail = pB;
4381044198
pB = pB->pDirty;
43811
- }
43812
- }
43813
- if( pA ){
43814
- pTail->pDirty = pA;
43815
- }else if( pB ){
43816
- pTail->pDirty = pB;
43817
- }else{
43818
- pTail->pDirty = 0;
44199
+ if( pB==0 ){
44200
+ pTail->pDirty = pA;
44201
+ break;
44202
+ }
44203
+ }
4381944204
}
4382044205
return result.pDirty;
4382144206
}
4382244207
4382344208
/*
@@ -43855,11 +44240,12 @@
4385544240
a[i] = pcacheMergeDirtyList(a[i], p);
4385644241
}
4385744242
}
4385844243
p = a[0];
4385944244
for(i=1; i<N_SORT_BUCKET; i++){
43860
- p = pcacheMergeDirtyList(p, a[i]);
44245
+ if( a[i]==0 ) continue;
44246
+ p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
4386144247
}
4386244248
return p;
4386344249
}
4386444250
4386544251
/*
@@ -44610,29 +44996,49 @@
4461044996
*/
4461144997
static void pcache1TruncateUnsafe(
4461244998
PCache1 *pCache, /* The cache to truncate */
4461344999
unsigned int iLimit /* Drop pages with this pgno or larger */
4461445000
){
44615
- TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */
44616
- unsigned int h;
45001
+ TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */
45002
+ unsigned int h, iStop;
4461745003
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
44618
- for(h=0; h<pCache->nHash; h++){
44619
- PgHdr1 **pp = &pCache->apHash[h];
45004
+ assert( pCache->iMaxKey >= iLimit );
45005
+ assert( pCache->nHash > 0 );
45006
+ if( pCache->iMaxKey - iLimit < pCache->nHash ){
45007
+ /* If we are just shaving the last few pages off the end of the
45008
+ ** cache, then there is no point in scanning the entire hash table.
45009
+ ** Only scan those hash slots that might contain pages that need to
45010
+ ** be removed. */
45011
+ h = iLimit % pCache->nHash;
45012
+ iStop = pCache->iMaxKey % pCache->nHash;
45013
+ TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */
45014
+ }else{
45015
+ /* This is the general case where many pages are being removed.
45016
+ ** It is necessary to scan the entire hash table */
45017
+ h = pCache->nHash/2;
45018
+ iStop = h - 1;
45019
+ }
45020
+ for(;;){
45021
+ PgHdr1 **pp;
4462045022
PgHdr1 *pPage;
45023
+ assert( h<pCache->nHash );
45024
+ pp = &pCache->apHash[h];
4462145025
while( (pPage = *pp)!=0 ){
4462245026
if( pPage->iKey>=iLimit ){
4462345027
pCache->nPage--;
4462445028
*pp = pPage->pNext;
4462545029
if( !pPage->isPinned ) pcache1PinPage(pPage);
4462645030
pcache1FreePage(pPage);
4462745031
}else{
4462845032
pp = &pPage->pNext;
44629
- TESTONLY( nPage++; )
45033
+ TESTONLY( if( nPage>=0 ) nPage++; )
4463045034
}
4463145035
}
45036
+ if( h==iStop ) break;
45037
+ h = (h+1) % pCache->nHash;
4463245038
}
44633
- assert( pCache->nPage==nPage );
45039
+ assert( nPage<0 || pCache->nPage==(unsigned)nPage );
4463445040
}
4463545041
4463645042
/******************************************************************************/
4463745043
/******** sqlite3_pcache Methods **********************************************/
4463845044
@@ -45105,11 +45511,11 @@
4510545511
static void pcache1Destroy(sqlite3_pcache *p){
4510645512
PCache1 *pCache = (PCache1 *)p;
4510745513
PGroup *pGroup = pCache->pGroup;
4510845514
assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
4510945515
pcache1EnterMutex(pGroup);
45110
- pcache1TruncateUnsafe(pCache, 0);
45516
+ if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
4511145517
assert( pGroup->nMaxPage >= pCache->nMax );
4511245518
pGroup->nMaxPage -= pCache->nMax;
4511345519
assert( pGroup->nMinPage >= pCache->nMin );
4511445520
pGroup->nMinPage -= pCache->nMin;
4511545521
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
@@ -45460,31 +45866,29 @@
4546045866
){
4546145867
struct RowSetEntry head;
4546245868
struct RowSetEntry *pTail;
4546345869
4546445870
pTail = &head;
45465
- while( pA && pB ){
45871
+ assert( pA!=0 && pB!=0 );
45872
+ for(;;){
4546645873
assert( pA->pRight==0 || pA->v<=pA->pRight->v );
4546745874
assert( pB->pRight==0 || pB->v<=pB->pRight->v );
45468
- if( pA->v<pB->v ){
45469
- pTail->pRight = pA;
45875
+ if( pA->v<=pB->v ){
45876
+ if( pA->v<pB->v ) pTail = pTail->pRight = pA;
4547045877
pA = pA->pRight;
45471
- pTail = pTail->pRight;
45472
- }else if( pB->v<pA->v ){
45473
- pTail->pRight = pB;
45878
+ if( pA==0 ){
45879
+ pTail->pRight = pB;
45880
+ break;
45881
+ }
45882
+ }else{
45883
+ pTail = pTail->pRight = pB;
4547445884
pB = pB->pRight;
45475
- pTail = pTail->pRight;
45476
- }else{
45477
- pA = pA->pRight;
45478
- }
45479
- }
45480
- if( pA ){
45481
- assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45482
- pTail->pRight = pA;
45483
- }else{
45484
- assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v );
45485
- pTail->pRight = pB;
45885
+ if( pB==0 ){
45886
+ pTail->pRight = pA;
45887
+ break;
45888
+ }
45889
+ }
4548645890
}
4548745891
return head.pRight;
4548845892
}
4548945893
4549045894
/*
@@ -45504,13 +45908,14 @@
4550445908
aBucket[i] = 0;
4550545909
}
4550645910
aBucket[i] = pIn;
4550745911
pIn = pNext;
4550845912
}
45509
- pIn = 0;
45510
- for(i=0; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45511
- pIn = rowSetEntryMerge(pIn, aBucket[i]);
45913
+ pIn = aBucket[0];
45914
+ for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45915
+ if( aBucket[i]==0 ) continue;
45916
+ pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];
4551245917
}
4551345918
return pIn;
4551445919
}
4551545920
4551645921
@@ -45758,12 +46163,12 @@
4575846163
** This header file defines the interface to the write-ahead logging
4575946164
** system. Refer to the comments below and the header comment attached to
4576046165
** the implementation of each function in log.c for further details.
4576146166
*/
4576246167
45763
-#ifndef _WAL_H_
45764
-#define _WAL_H_
46168
+#ifndef SQLITE_WAL_H
46169
+#define SQLITE_WAL_H
4576546170
4576646171
/* #include "sqliteInt.h" */
4576746172
4576846173
/* Additional values that can be added to the sync_flags argument of
4576946174
** sqlite3WalFrames():
@@ -45887,11 +46292,11 @@
4588746292
4588846293
/* Return the sqlite3_file object for the WAL file */
4588946294
SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);
4589046295
4589146296
#endif /* ifndef SQLITE_OMIT_WAL */
45892
-#endif /* _WAL_H_ */
46297
+#endif /* SQLITE_WAL_H */
4589346298
4589446299
/************** End of wal.h *************************************************/
4589546300
/************** Continuing where we left off in pager.c **********************/
4589646301
4589746302
@@ -53036,10 +53441,11 @@
5303653441
SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
5303753442
assert( MEMDB==0 || pPager->tempFile );
5303853443
if( pPager->tempFile==0 ) pager_reset(pPager);
5303953444
}
5304053445
#endif
53446
+
5304153447
5304253448
#ifndef SQLITE_OMIT_WAL
5304353449
/*
5304453450
** This function is called when the user invokes "PRAGMA wal_checkpoint",
5304553451
** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
@@ -53261,11 +53667,10 @@
5326153667
SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
5326253668
assert( pPager->eState>=PAGER_READER );
5326353669
return sqlite3WalFramesize(pPager->pWal);
5326453670
}
5326553671
#endif
53266
-
5326753672
5326853673
#endif /* SQLITE_OMIT_DISKIO */
5326953674
5327053675
/************** End of pager.c ***********************************************/
5327153676
/************** Begin file wal.c *********************************************/
@@ -56378,20 +56783,25 @@
5637856783
** boundary is crossed. Only the part of the WAL prior to the last
5637956784
** sector boundary is synced; the part of the last frame that extends
5638056785
** past the sector boundary is written after the sync.
5638156786
*/
5638256787
if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
56788
+ int bSync = 1;
5638356789
if( pWal->padToSectorBoundary ){
5638456790
int sectorSize = sqlite3SectorSize(pWal->pWalFd);
5638556791
w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
56792
+ bSync = (w.iSyncPoint==iOffset);
56793
+ testcase( bSync );
5638656794
while( iOffset<w.iSyncPoint ){
5638756795
rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
5638856796
if( rc ) return rc;
5638956797
iOffset += szFrame;
5639056798
nExtra++;
5639156799
}
56392
- }else{
56800
+ }
56801
+ if( bSync ){
56802
+ assert( rc==SQLITE_OK );
5639356803
rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);
5639456804
}
5639556805
}
5639656806
5639756807
/* If this frame set completes the first transaction in the WAL and
@@ -58174,10 +58584,19 @@
5817458584
*/
5817558585
#ifdef SQLITE_DEBUG
5817658586
static int cursorHoldsMutex(BtCursor *p){
5817758587
return sqlite3_mutex_held(p->pBt->mutex);
5817858588
}
58589
+
58590
+/* Verify that the cursor and the BtShared agree about what is the current
58591
+** database connetion. This is important in shared-cache mode. If the database
58592
+** connection pointers get out-of-sync, it is possible for routines like
58593
+** btreeInitPage() to reference an stale connection pointer that references a
58594
+** a connection that has already closed. This routine is used inside assert()
58595
+** statements only and for the purpose of double-checking that the btree code
58596
+** does keep the database connection pointers up-to-date.
58597
+*/
5817958598
static int cursorOwnsBtShared(BtCursor *p){
5818058599
assert( cursorHoldsMutex(p) );
5818158600
return (p->pBtree->db==p->pBt->db);
5818258601
}
5818358602
#endif
@@ -58333,25 +58752,23 @@
5833358752
** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
5833458753
** set to point to a malloced buffer pCur->nKey bytes in size containing
5833558754
** the key.
5833658755
*/
5833758756
static int saveCursorKey(BtCursor *pCur){
58338
- int rc;
58757
+ int rc = SQLITE_OK;
5833958758
assert( CURSOR_VALID==pCur->eState );
5834058759
assert( 0==pCur->pKey );
5834158760
assert( cursorHoldsMutex(pCur) );
5834258761
58343
- rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
58344
- assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
58345
-
58346
- /* If this is an intKey table, then the above call to BtreeKeySize()
58347
- ** stores the integer key in pCur->nKey. In this case this value is
58348
- ** all that is required. Otherwise, if pCur is not open on an intKey
58349
- ** table, then malloc space for and store the pCur->nKey bytes of key
58350
- ** data. */
58351
- if( 0==pCur->curIntKey ){
58352
- void *pKey = sqlite3Malloc( pCur->nKey );
58762
+ if( pCur->curIntKey ){
58763
+ /* Only the rowid is required for a table btree */
58764
+ pCur->nKey = sqlite3BtreeIntegerKey(pCur);
58765
+ }else{
58766
+ /* For an index btree, save the complete key content */
58767
+ void *pKey;
58768
+ pCur->nKey = sqlite3BtreePayloadSize(pCur);
58769
+ pKey = sqlite3Malloc( pCur->nKey );
5835358770
if( pKey ){
5835458771
rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
5835558772
if( rc==SQLITE_OK ){
5835658773
pCur->pKey = pKey;
5835758774
}else{
@@ -60054,13 +60471,13 @@
6005460471
assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
6005560472
6005660473
#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
6005760474
/* Add the new BtShared object to the linked list sharable BtShareds.
6005860475
*/
60476
+ pBt->nRef = 1;
6005960477
if( p->sharable ){
6006060478
MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
60061
- pBt->nRef = 1;
6006260479
MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
6006360480
if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
6006460481
pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
6006560482
if( pBt->mutex==0 ){
6006660483
rc = SQLITE_NOMEM_BKPT;
@@ -60127,10 +60544,11 @@
6012760544
}
6012860545
if( mutexOpen ){
6012960546
assert( sqlite3_mutex_held(mutexOpen) );
6013060547
sqlite3_mutex_leave(mutexOpen);
6013160548
}
60549
+ assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );
6013260550
return rc;
6013360551
}
6013460552
6013560553
/*
6013660554
** Decrement the BtShared.nRef counter. When it reaches zero,
@@ -61986,50 +62404,37 @@
6198662404
return pCur && pCur->eState==CURSOR_VALID;
6198762405
}
6198862406
#endif /* NDEBUG */
6198962407
6199062408
/*
61991
-** Set *pSize to the size of the buffer needed to hold the value of
61992
-** the key for the current entry. If the cursor is not pointing
61993
-** to a valid entry, *pSize is set to 0.
61994
-**
61995
-** For a table with the INTKEY flag set, this routine returns the key
61996
-** itself, not the number of bytes in the key.
61997
-**
61998
-** The caller must position the cursor prior to invoking this routine.
61999
-**
62000
-** This routine cannot fail. It always returns SQLITE_OK.
62409
+** Return the value of the integer key or "rowid" for a table btree.
62410
+** This routine is only valid for a cursor that is pointing into a
62411
+** ordinary table btree. If the cursor points to an index btree or
62412
+** is invalid, the result of this routine is undefined.
6200162413
*/
62002
-SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
62414
+SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
6200362415
assert( cursorHoldsMutex(pCur) );
6200462416
assert( pCur->eState==CURSOR_VALID );
62417
+ assert( pCur->curIntKey );
6200562418
getCellInfo(pCur);
62006
- *pSize = pCur->info.nKey;
62007
- return SQLITE_OK;
62419
+ return pCur->info.nKey;
6200862420
}
6200962421
6201062422
/*
62011
-** Set *pSize to the number of bytes of data in the entry the
62012
-** cursor currently points to.
62423
+** Return the number of bytes of payload for the entry that pCur is
62424
+** currently pointing to. For table btrees, this will be the amount
62425
+** of data. For index btrees, this will be the size of the key.
6201362426
**
6201462427
** The caller must guarantee that the cursor is pointing to a non-NULL
6201562428
** valid entry. In other words, the calling procedure must guarantee
6201662429
** 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.
6202162430
*/
62022
-SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
62023
- assert( cursorOwnsBtShared(pCur) );
62431
+SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){
62432
+ assert( cursorHoldsMutex(pCur) );
6202462433
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 );
6202862434
getCellInfo(pCur);
62029
- *pSize = pCur->info.nPayload;
62030
- return SQLITE_OK;
62435
+ return pCur->info.nPayload;
6203162436
}
6203262437
6203362438
/*
6203462439
** Given the page number of an overflow page in the database (parameter
6203562440
** ovfl), this function finds the page number of the next page in the
@@ -62467,14 +62872,11 @@
6246762872
** this routine.
6246862873
**
6246962874
** These routines is used to get quick access to key and data
6247062875
** in the common case where no overflow pages are used.
6247162876
*/
62472
-SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
62473
- return fetchPayload(pCur, pAmt);
62474
-}
62475
-SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){
62877
+SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){
6247662878
return fetchPayload(pCur, pAmt);
6247762879
}
6247862880
6247962881
6248062882
/*
@@ -62803,15 +63205,16 @@
6280363205
6280463206
assert( cursorOwnsBtShared(pCur) );
6280563207
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
6280663208
assert( pRes );
6280763209
assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
63210
+ assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
6280863211
6280963212
/* If the cursor is already positioned at the point we are trying
6281063213
** to move to, then just return without doing any work */
62811
- if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
62812
- && pCur->curIntKey
63214
+ if( pIdxKey==0
63215
+ && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
6281363216
){
6281463217
if( pCur->info.nKey==intKey ){
6281563218
*pRes = 0;
6281663219
return SQLITE_OK;
6281763220
}
@@ -63796,13 +64199,11 @@
6379664199
** later.
6379764200
*/
6379864201
static int fillInCell(
6379964202
MemPage *pPage, /* The page that contains the cell */
6380064203
unsigned char *pCell, /* Complete text of the cell */
63801
- const void *pKey, i64 nKey, /* The key */
63802
- const void *pData,int nData, /* The data */
63803
- int nZero, /* Extra zero bytes to append to pData */
64204
+ const BtreePayload *pX, /* Payload with which to construct the cell */
6380464205
int *pnSize /* Write cell size here */
6380564206
){
6380664207
int nPayload;
6380764208
const u8 *pSrc;
6380864209
int nSrc, n, rc;
@@ -63822,30 +64223,27 @@
6382264223
assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
6382364224
|| sqlite3PagerIswriteable(pPage->pDbPage) );
6382464225
6382564226
/* Fill in the header. */
6382664227
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 */
6383764228
if( pPage->intKey ){
63838
- pSrc = pData;
63839
- nSrc = nData;
63840
- nData = 0;
63841
- }else{
63842
- assert( nKey<=0x7fffffff && pKey!=0 );
63843
- nPayload = (int)nKey;
63844
- pSrc = pKey;
63845
- nSrc = (int)nKey;
63846
- }
64229
+ nPayload = pX->nData + pX->nZero;
64230
+ pSrc = pX->pData;
64231
+ nSrc = pX->nData;
64232
+ assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */
64233
+ nHeader += putVarint32(&pCell[nHeader], nPayload);
64234
+ nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);
64235
+ }else{
64236
+ assert( pX->nData==0 );
64237
+ assert( pX->nZero==0 );
64238
+ assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );
64239
+ nSrc = nPayload = (int)pX->nKey;
64240
+ pSrc = pX->pKey;
64241
+ nHeader += putVarint32(&pCell[nHeader], nPayload);
64242
+ }
64243
+
64244
+ /* Fill in the payload */
6384764245
if( nPayload<=pPage->maxLocal ){
6384864246
n = nHeader + nPayload;
6384964247
testcase( n==3 );
6385064248
testcase( n==4 );
6385164249
if( n<4 ) n = 4;
@@ -63879,11 +64277,11 @@
6387964277
#if SQLITE_DEBUG
6388064278
{
6388164279
CellInfo info;
6388264280
pPage->xParseCell(pPage, pCell, &info);
6388364281
assert( nHeader==(int)(info.pPayload - pCell) );
63884
- assert( info.nKey==nKey );
64282
+ assert( info.nKey==pX->nKey );
6388564283
assert( *pnSize == info.nSize );
6388664284
assert( spaceLeft == info.nLocal );
6388764285
}
6388864286
#endif
6388964287
@@ -63964,14 +64362,10 @@
6396464362
nPayload -= n;
6396564363
pPayload += n;
6396664364
pSrc += n;
6396764365
nSrc -= n;
6396864366
spaceLeft -= n;
63969
- if( nSrc==0 ){
63970
- nSrc = nData;
63971
- pSrc = pData;
63972
- }
6397364367
}
6397464368
releasePage(pToRelease);
6397564369
return SQLITE_OK;
6397664370
}
6397764371
@@ -64034,10 +64428,12 @@
6403464428
** pTemp is not null. Regardless of pTemp, allocate a new entry
6403564429
** in pPage->apOvfl[] and make it point to the cell content (either
6403664430
** in pTemp or the original pCell) and also record its index.
6403764431
** Allocating a new entry in pPage->aCell[] implies that
6403864432
** pPage->nOverflow is incremented.
64433
+**
64434
+** *pRC must be SQLITE_OK when this routine is called.
6403964435
*/
6404064436
static void insertCell(
6404164437
MemPage *pPage, /* Page into which we are copying */
6404264438
int i, /* New cell becomes the i-th cell of the page */
6404364439
u8 *pCell, /* Content of the new cell */
@@ -64049,12 +64445,11 @@
6404964445
int idx = 0; /* Where to write new cell content in data[] */
6405064446
int j; /* Loop counter */
6405164447
u8 *data; /* The content of the whole page */
6405264448
u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
6405364449
64054
- if( *pRC ) return;
64055
-
64450
+ assert( *pRC==SQLITE_OK );
6405664451
assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
6405764452
assert( MX_CELL(pPage->pBt)<=10921 );
6405864453
assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
6405964454
assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
6406064455
assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
@@ -64124,11 +64519,11 @@
6412464519
}
6412564520
}
6412664521
6412764522
/*
6412864523
** A CellArray object contains a cache of pointers and sizes for a
64129
-** consecutive sequence of cells that might be held multiple pages.
64524
+** consecutive sequence of cells that might be held on multiple pages.
6413064525
*/
6413164526
typedef struct CellArray CellArray;
6413264527
struct CellArray {
6413364528
int nCell; /* Number of cells in apCell[] */
6413464529
MemPage *pRef; /* Reference page */
@@ -64556,12 +64951,14 @@
6455664951
while( (*(pCell++)&0x80) && pCell<pStop );
6455764952
pStop = &pCell[9];
6455864953
while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );
6455964954
6456064955
/* Insert the new divider cell into pParent. */
64561
- insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64562
- 0, pPage->pgno, &rc);
64956
+ if( rc==SQLITE_OK ){
64957
+ insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64958
+ 0, pPage->pgno, &rc);
64959
+ }
6456364960
6456464961
/* Set the right-child pointer of pParent to point to the new page. */
6456564962
put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
6456664963
6456764964
/* Release the reference to the new page. */
@@ -65077,11 +65474,11 @@
6507765474
do{
6507865475
assert( d<nMaxCells );
6507965476
assert( r<nMaxCells );
6508065477
(void)cachedCellSize(&b, r);
6508165478
if( szRight!=0
65082
- && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){
65479
+ && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){
6508365480
break;
6508465481
}
6508565482
szRight += b.szCell[d] + 2;
6508665483
szLeft -= b.szCell[r] + 2;
6508765484
cntNew[i-1] = r;
@@ -65649,17 +66046,23 @@
6564966046
return rc;
6565066047
}
6565166048
6565266049
6565366050
/*
65654
-** Insert a new record into the BTree. The key is given by (pKey,nKey)
65655
-** and the data is given by (pData,nData). The cursor is used only to
65656
-** define what table the record should be inserted into. The cursor
65657
-** is left pointing at a random location.
66051
+** Insert a new record into the BTree. The content of the new record
66052
+** is described by the pX object. The pCur cursor is used only to
66053
+** define what table the record should be inserted into, and is left
66054
+** pointing at a random location.
6565866055
**
65659
-** For an INTKEY table, only the nKey value of the key is used. pKey is
65660
-** ignored. For a ZERODATA table, the pData and nData are both ignored.
66056
+** For a table btree (used for rowid tables), only the pX.nKey value of
66057
+** the key is used. The pX.pKey value must be NULL. The pX.nKey is the
66058
+** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields
66059
+** hold the content of the row.
66060
+**
66061
+** For an index btree (used for indexes and WITHOUT ROWID tables), the
66062
+** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
66063
+** pX.pData,nData,nZero fields must be zero.
6566166064
**
6566266065
** If the seekResult parameter is non-zero, then a successful call to
6566366066
** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
6566466067
** been performed. seekResult is the search result returned (a negative
6566566068
** number if pCur points at an entry that is smaller than (pKey, nKey), or
@@ -65672,13 +66075,11 @@
6567266075
** point to any entry or to no entry at all and so this function has to seek
6567366076
** the cursor before the new key can be inserted.
6567466077
*/
6567566078
SQLITE_PRIVATE int sqlite3BtreeInsert(
6567666079
BtCursor *pCur, /* Insert data into the table of this cursor */
65677
- const void *pKey, i64 nKey, /* The key of the new record */
65678
- const void *pData, int nData, /* The data of the new record */
65679
- int nZero, /* Number of extra 0 bytes to append to data */
66080
+ const BtreePayload *pX, /* Content of the row to be inserted */
6568066081
int appendBias, /* True if this is likely an append */
6568166082
int seekResult /* Result of prior MovetoUnpacked() call */
6568266083
){
6568366084
int rc;
6568466085
int loc = seekResult; /* -1: before desired location +1: after */
@@ -65704,11 +66105,11 @@
6570466105
/* Assert that the caller has been consistent. If this cursor was opened
6570566106
** expecting an index b-tree, then the caller should be inserting blob
6570666107
** keys with no associated data. If the cursor was opened expecting an
6570766108
** intkey table, the caller should be inserting integer keys with a
6570866109
** blob of associated data. */
65709
- assert( (pKey==0)==(pCur->pKeyInfo==0) );
66110
+ assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );
6571066111
6571166112
/* Save the positions of any other cursors open on this table.
6571266113
**
6571366114
** In some cases, the call to btreeMoveto() below is a no-op. For
6571466115
** example, when inserting data into a table with auto-generated integer
@@ -65723,42 +66124,42 @@
6572366124
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
6572466125
if( rc ) return rc;
6572566126
}
6572666127
6572766128
if( pCur->pKeyInfo==0 ){
65728
- assert( pKey==0 );
66129
+ assert( pX->pKey==0 );
6572966130
/* If this is an insert into a table b-tree, invalidate any incrblob
6573066131
** cursors open on the row being replaced */
65731
- invalidateIncrblobCursors(p, nKey, 0);
66132
+ invalidateIncrblobCursors(p, pX->nKey, 0);
6573266133
6573366134
/* If the cursor is currently on the last row and we are appending a
6573466135
** new row onto the end, set the "loc" to avoid an unnecessary
6573566136
** btreeMoveto() call */
65736
- if( (pCur->curFlags&BTCF_ValidNKey)!=0 && nKey>0
65737
- && pCur->info.nKey==nKey-1 ){
66137
+ if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0
66138
+ && pCur->info.nKey==pX->nKey-1 ){
6573866139
loc = -1;
6573966140
}else if( loc==0 ){
65740
- rc = sqlite3BtreeMovetoUnpacked(pCur, 0, nKey, appendBias, &loc);
66141
+ rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc);
6574166142
if( rc ) return rc;
6574266143
}
6574366144
}else if( loc==0 ){
65744
- rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
66145
+ rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc);
6574566146
if( rc ) return rc;
6574666147
}
6574766148
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
6574866149
6574966150
pPage = pCur->apPage[pCur->iPage];
65750
- assert( pPage->intKey || nKey>=0 );
66151
+ assert( pPage->intKey || pX->nKey>=0 );
6575166152
assert( pPage->leaf || !pPage->intKey );
6575266153
6575366154
TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
65754
- pCur->pgnoRoot, nKey, nData, pPage->pgno,
66155
+ pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,
6575566156
loc==0 ? "overwrite" : "new entry"));
6575666157
assert( pPage->isInit );
6575766158
newCell = pBt->pTmpSpace;
6575866159
assert( newCell!=0 );
65759
- rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew);
66160
+ rc = fillInCell(pPage, newCell, pX, &szNew);
6576066161
if( rc ) goto end_insert;
6576166162
assert( szNew==pPage->xCellSize(pPage, newCell) );
6576266163
assert( szNew <= MX_CELL_SIZE(pBt) );
6576366164
idx = pCur->aiIdx[pCur->iPage];
6576466165
if( loc==0 ){
@@ -65780,10 +66181,11 @@
6578066181
idx = ++pCur->aiIdx[pCur->iPage];
6578166182
}else{
6578266183
assert( pPage->leaf );
6578366184
}
6578466185
insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
66186
+ assert( pPage->nOverflow==0 || rc==SQLITE_OK );
6578566187
assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
6578666188
6578766189
/* If no error has occurred and pPage has an overflow cell, call balance()
6578866190
** to redistribute the cells within the tree. Since balance() may move
6578966191
** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey
@@ -65803,11 +66205,12 @@
6580366205
** entry in the table, and the next row inserted has an integer key
6580466206
** larger than the largest existing key, it is possible to insert the
6580566207
** row without seeking the cursor. This can be a big performance boost.
6580666208
*/
6580766209
pCur->info.nSize = 0;
65808
- if( rc==SQLITE_OK && pPage->nOverflow ){
66210
+ if( pPage->nOverflow ){
66211
+ assert( rc==SQLITE_OK );
6580966212
pCur->curFlags &= ~(BTCF_ValidNKey);
6581066213
rc = balance(pCur);
6581166214
6581266215
/* Must make sure nOverflow is reset to zero even if the balance()
6581366216
** fails. Internal data structure corruption will result otherwise.
@@ -65939,11 +66342,13 @@
6593966342
nCell = pLeaf->xCellSize(pLeaf, pCell);
6594066343
assert( MX_CELL_SIZE(pBt) >= nCell );
6594166344
pTmp = pBt->pTmpSpace;
6594266345
assert( pTmp!=0 );
6594366346
rc = sqlite3PagerWrite(pLeaf->pDbPage);
65944
- insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66347
+ if( rc==SQLITE_OK ){
66348
+ insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66349
+ }
6594566350
dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
6594666351
if( rc ) return rc;
6594766352
}
6594866353
6594966354
/* Balance the tree. If the entry deleted was located on a leaf page,
@@ -67428,10 +67833,20 @@
6742867833
** Return true if the Btree passed as the only argument is sharable.
6742967834
*/
6743067835
SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
6743167836
return p->sharable;
6743267837
}
67838
+
67839
+/*
67840
+** Return the number of connections to the BtShared object accessed by
67841
+** the Btree handle passed as the only argument. For private caches
67842
+** this is always 1. For shared caches it may be 1 or greater.
67843
+*/
67844
+SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){
67845
+ testcase( p->sharable );
67846
+ return p->pBt->nRef;
67847
+}
6743367848
#endif
6743467849
6743567850
/************** End of btree.c ***********************************************/
6743667851
/************** Begin file backup.c ******************************************/
6743767852
/*
@@ -68211,14 +68626,14 @@
6821168626
/* 0x7FFFFFFF is the hard limit for the number of pages in a database
6821268627
** file. By passing this as the number of pages to copy to
6821368628
** sqlite3_backup_step(), we can guarantee that the copy finishes
6821468629
** within a single call (unless an error occurs). The assert() statement
6821568630
** checks this assumption - (p->rc) should be set to either SQLITE_DONE
68216
- ** or an error code.
68217
- */
68631
+ ** or an error code. */
6821868632
sqlite3_backup_step(&b, 0x7FFFFFFF);
6821968633
assert( b.rc!=SQLITE_OK );
68634
+
6822068635
rc = sqlite3_backup_finish(&b);
6822168636
if( rc==SQLITE_OK ){
6822268637
pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;
6822368638
}else{
6822468639
sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
@@ -69225,15 +69640,11 @@
6922569640
assert( !VdbeMemDynamic(pMem) );
6922669641
6922769642
/* Note: the calls to BtreeKeyFetch() and DataFetch() below assert()
6922869643
** that both the BtShared and database handle mutexes are held. */
6922969644
assert( (pMem->flags & MEM_RowSet)==0 );
69230
- if( key ){
69231
- zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
69232
- }else{
69233
- zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
69234
- }
69645
+ zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);
6923569646
assert( zData!=0 );
6923669647
6923769648
if( offset+amt<=available ){
6923869649
pMem->z = &zData[offset];
6923969650
pMem->flags = MEM_Blob|MEM_Ephem;
@@ -70009,18 +70420,10 @@
7000970420
assert( p->zSql==0 );
7001070421
p->zSql = sqlite3DbStrNDup(p->db, z, n);
7001170422
p->isPrepareV2 = (u8)isPrepareV2;
7001270423
}
7001370424
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
-
7002270425
/*
7002370426
** Swap all content between two VDBE structures.
7002470427
*/
7002570428
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
7002670429
Vdbe tmp, *pTmp;
@@ -70736,26 +71139,34 @@
7073671139
/*
7073771140
** If the input FuncDef structure is ephemeral, then free it. If
7073871141
** the FuncDef is not ephermal, then do nothing.
7073971142
*/
7074071143
static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
70741
- if( ALWAYS(pDef) && (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
71144
+ if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
7074271145
sqlite3DbFree(db, pDef);
7074371146
}
7074471147
}
7074571148
7074671149
static void vdbeFreeOpArray(sqlite3 *, Op *, int);
7074771150
7074871151
/*
7074971152
** Delete a P4 value if necessary.
7075071153
*/
71154
+static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
71155
+ if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
71156
+ sqlite3DbFree(db, p);
71157
+}
71158
+static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
71159
+ freeEphemeralFunction(db, p->pFunc);
71160
+ sqlite3DbFree(db, p);
71161
+}
7075171162
static void freeP4(sqlite3 *db, int p4type, void *p4){
7075271163
assert( db );
7075371164
switch( p4type ){
7075471165
case P4_FUNCCTX: {
70755
- freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc);
70756
- /* Fall through into the next case */
71166
+ freeP4FuncCtx(db, (sqlite3_context*)p4);
71167
+ break;
7075771168
}
7075871169
case P4_REAL:
7075971170
case P4_INT64:
7076071171
case P4_DYNAMIC:
7076171172
case P4_INTARRAY: {
@@ -70782,13 +71193,11 @@
7078271193
}
7078371194
case P4_MEM: {
7078471195
if( db->pnBytesFreed==0 ){
7078571196
sqlite3ValueFree((sqlite3_value*)p4);
7078671197
}else{
70787
- Mem *p = (Mem*)p4;
70788
- if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
70789
- sqlite3DbFree(db, p);
71198
+ freeP4Mem(db, (Mem*)p4);
7079071199
}
7079171200
break;
7079271201
}
7079371202
case P4_VTAB : {
7079471203
if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
@@ -74254,12 +74663,11 @@
7425474663
** than 2GiB are support - anything large must be database corruption.
7425574664
** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
7425674665
** this code can safely assume that nCellKey is 32-bits
7425774666
*/
7425874667
assert( sqlite3BtreeCursorIsValid(pCur) );
74259
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74260
- assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74668
+ nCellKey = sqlite3BtreePayloadSize(pCur);
7426174669
assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
7426274670
7426374671
/* Read in the complete content of the index entry */
7426474672
sqlite3VdbeMemInit(&m, db, 0);
7426574673
rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
@@ -74332,12 +74740,11 @@
7433274740
Mem m;
7433374741
7433474742
assert( pC->eCurType==CURTYPE_BTREE );
7433574743
pCur = pC->uc.pCursor;
7433674744
assert( sqlite3BtreeCursorIsValid(pCur) );
74337
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);
74338
- assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */
74745
+ nCellKey = sqlite3BtreePayloadSize(pCur);
7433974746
/* nCellKey will always be between 0 and 0xffffffff because of the way
7434074747
** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
7434174748
if( nCellKey<=0 || nCellKey>0x7fffffff ){
7434274749
*res = 0;
7434374750
return SQLITE_CORRUPT_BKPT;
@@ -74595,16 +75002,23 @@
7459575002
** Invoke the profile callback. This routine is only called if we already
7459675003
** know that the profile callback is defined and needs to be invoked.
7459775004
*/
7459875005
static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
7459975006
sqlite3_int64 iNow;
75007
+ sqlite3_int64 iElapse;
7460075008
assert( p->startTime>0 );
74601
- assert( db->xProfile!=0 );
75009
+ assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
7460275010
assert( db->init.busy==0 );
7460375011
assert( p->zSql!=0 );
7460475012
sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
74605
- db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
75013
+ iElapse = (iNow - p->startTime)*1000000;
75014
+ if( db->xProfile ){
75015
+ db->xProfile(db->pProfileArg, p->zSql, iElapse);
75016
+ }
75017
+ if( db->mTrace & SQLITE_TRACE_PROFILE ){
75018
+ db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
75019
+ }
7460675020
p->startTime = 0;
7460775021
}
7460875022
/*
7460975023
** The checkProfileCallback(DB,P) macro checks to see if a profile callback
7461075024
** is needed, and it invokes the callback if it is needed.
@@ -75104,11 +75518,12 @@
7510475518
assert( db->nVdbeWrite>0 || db->autoCommit==0
7510575519
|| (db->nDeferredCons==0 && db->nDeferredImmCons==0)
7510675520
);
7510775521
7510875522
#ifndef SQLITE_OMIT_TRACE
75109
- if( db->xProfile && !db->init.busy && p->zSql ){
75523
+ if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
75524
+ && !db->init.busy && p->zSql ){
7511075525
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
7511175526
}else{
7511275527
assert( p->startTime==0 );
7511375528
}
7511475529
#endif
@@ -76138,10 +76553,43 @@
7613876553
#endif
7613976554
v = pVdbe->aCounter[op];
7614076555
if( resetFlag ) pVdbe->aCounter[op] = 0;
7614176556
return (int)v;
7614276557
}
76558
+
76559
+/*
76560
+** Return the SQL associated with a prepared statement
76561
+*/
76562
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
76563
+ Vdbe *p = (Vdbe *)pStmt;
76564
+ return p ? p->zSql : 0;
76565
+}
76566
+
76567
+/*
76568
+** Return the SQL associated with a prepared statement with
76569
+** bound parameters expanded. Space to hold the returned string is
76570
+** obtained from sqlite3_malloc(). The caller is responsible for
76571
+** freeing the returned string by passing it to sqlite3_free().
76572
+**
76573
+** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
76574
+** expanded bound parameters.
76575
+*/
76576
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt){
76577
+#ifdef SQLITE_OMIT_TRACE
76578
+ return 0;
76579
+#else
76580
+ char *z = 0;
76581
+ const char *zSql = sqlite3_sql(pStmt);
76582
+ if( zSql ){
76583
+ Vdbe *p = (Vdbe *)pStmt;
76584
+ sqlite3_mutex_enter(p->db->mutex);
76585
+ z = sqlite3VdbeExpandSql(p, zSql);
76586
+ sqlite3_mutex_leave(p->db->mutex);
76587
+ }
76588
+ return z;
76589
+#endif
76590
+}
7614376591
7614476592
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
7614576593
/*
7614676594
** Allocate and populate an UnpackedRecord structure based on the serialized
7614776595
** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
@@ -76185,12 +76633,11 @@
7618576633
/* If the old.* record has not yet been loaded into memory, do so now. */
7618676634
if( p->pUnpacked==0 ){
7618776635
u32 nRec;
7618876636
u8 *aRec;
7618976637
76190
- rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec);
76191
- if( rc!=SQLITE_OK ) goto preupdate_old_out;
76638
+ nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
7619276639
aRec = sqlite3DbMallocRaw(db, nRec);
7619376640
if( !aRec ) goto preupdate_old_out;
7619476641
rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
7619576642
if( rc==SQLITE_OK ){
7619676643
p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
@@ -76474,14 +76921,17 @@
7647476921
int n; /* Length of a token prefix */
7647576922
int nToken; /* Length of the parameter token */
7647676923
int i; /* Loop counter */
7647776924
Mem *pVar; /* Value of a host parameter */
7647876925
StrAccum out; /* Accumulate the output here */
76926
+#ifndef SQLITE_OMIT_UTF16
76927
+ Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */
76928
+#endif
7647976929
char zBase[100]; /* Initial working space */
7648076930
7648176931
db = p->db;
76482
- sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase),
76932
+ sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase),
7648376933
db->aLimit[SQLITE_LIMIT_LENGTH]);
7648476934
if( db->nVdbeExec>1 ){
7648576935
while( *zRawSql ){
7648676936
const char *zStart = zRawSql;
7648776937
while( *(zRawSql++)!='\n' && *zRawSql );
@@ -76528,16 +76978,18 @@
7652876978
sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
7652976979
}else if( pVar->flags & MEM_Str ){
7653076980
int nOut; /* Number of bytes of the string text to include in output */
7653176981
#ifndef SQLITE_OMIT_UTF16
7653276982
u8 enc = ENC(db);
76533
- Mem utf8;
7653476983
if( enc!=SQLITE_UTF8 ){
7653576984
memset(&utf8, 0, sizeof(utf8));
7653676985
utf8.db = db;
7653776986
sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
76538
- sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
76987
+ if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
76988
+ out.accError = STRACCUM_NOMEM;
76989
+ out.nAlloc = 0;
76990
+ }
7653976991
pVar = &utf8;
7654076992
}
7654176993
#endif
7654276994
nOut = pVar->n;
7654376995
#ifdef SQLITE_TRACE_SIZE_LIMIT
@@ -76575,10 +77027,11 @@
7657577027
}
7657677028
#endif
7657777029
}
7657877030
}
7657977031
}
77032
+ if( out.accError ) sqlite3StrAccumReset(&out);
7658077033
return sqlite3StrAccumFinish(&out);
7658177034
}
7658277035
7658377036
#endif /* #ifndef SQLITE_OMIT_TRACE */
7658477037
@@ -77107,12 +77560,12 @@
7710777560
******************************************************************************
7710877561
**
7710977562
** This file contains inline asm code for retrieving "high-performance"
7711077563
** counters for x86 class CPUs.
7711177564
*/
77112
-#ifndef _HWTIME_H_
77113
-#define _HWTIME_H_
77565
+#ifndef SQLITE_HWTIME_H
77566
+#define SQLITE_HWTIME_H
7711477567
7711577568
/*
7711677569
** The following routine only works on pentium-class (or newer) processors.
7711777570
** It uses the RDTSC opcode to read the cycle count value out of the
7711877571
** processor and returns that value. This can be used for high-res
@@ -77176,11 +77629,11 @@
7717677629
*/
7717777630
SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
7717877631
7717977632
#endif
7718077633
77181
-#endif /* !defined(_HWTIME_H_) */
77634
+#endif /* !defined(SQLITE_HWTIME_H) */
7718277635
7718377636
/************** End of hwtime.h **********************************************/
7718477637
/************** Continuing where we left off in vdbe.c ***********************/
7718577638
7718677639
#endif
@@ -78055,10 +78508,14 @@
7805578508
|| (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
7805678509
sqlite3VdbeMemNulTerminate(&pMem[i]);
7805778510
REGISTER_TRACE(pOp->p1+i, &pMem[i]);
7805878511
}
7805978512
if( db->mallocFailed ) goto no_mem;
78513
+
78514
+ if( db->mTrace & SQLITE_TRACE_ROW ){
78515
+ db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);
78516
+ }
7806078517
7806178518
/* Return SQLITE_ROW
7806278519
*/
7806378520
p->pc = (int)(pOp - aOp) + 1;
7806478521
rc = SQLITE_ROW;
@@ -78689,10 +79146,11 @@
7868979146
affinity = pOp->p5 & SQLITE_AFF_MASK;
7869079147
if( affinity>=SQLITE_AFF_NUMERIC ){
7869179148
if( (flags1 | flags3)&MEM_Str ){
7869279149
if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7869379150
applyNumericAffinity(pIn1,0);
79151
+ flags3 = pIn3->flags;
7869479152
}
7869579153
if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7869679154
applyNumericAffinity(pIn3,0);
7869779155
}
7869879156
}
@@ -78701,10 +79159,11 @@
7870179159
testcase( pIn1->flags & MEM_Int );
7870279160
testcase( pIn1->flags & MEM_Real );
7870379161
sqlite3VdbeMemStringify(pIn1, encoding, 1);
7870479162
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
7870579163
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
79164
+ flags3 = pIn3->flags;
7870679165
}
7870779166
if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
7870879167
testcase( pIn3->flags & MEM_Int );
7870979168
testcase( pIn3->flags & MEM_Real );
7871079169
sqlite3VdbeMemStringify(pIn3, encoding, 1);
@@ -79053,11 +79512,10 @@
7905379512
** the result is guaranteed to only be used as the argument of a length()
7905479513
** or typeof() function, respectively. The loading of large blobs can be
7905579514
** skipped for length() and all content loading can be skipped for typeof().
7905679515
*/
7905779516
case OP_Column: {
79058
- i64 payloadSize64; /* Number of bytes in the record */
7905979517
int p2; /* column number to retrieve */
7906079518
VdbeCursor *pC; /* The VDBE cursor */
7906179519
BtCursor *pCrsr; /* The BTree cursor */
7906279520
u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
7906379521
int len; /* The length of the serialized data for the column */
@@ -79076,10 +79534,11 @@
7907679534
pC = p->apCsr[pOp->p1];
7907779535
p2 = pOp->p2;
7907879536
7907979537
/* If the cursor cache is stale, bring it up-to-date */
7908079538
rc = sqlite3VdbeCursorMoveto(&pC, &p2);
79539
+ if( rc ) goto abort_due_to_error;
7908179540
7908279541
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
7908379542
pDest = &aMem[pOp->p3];
7908479543
memAboutToChange(p, pDest);
7908579544
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -79089,12 +79548,11 @@
7908979548
assert( pC->eCurType!=CURTYPE_VTAB );
7909079549
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
7909179550
assert( pC->eCurType!=CURTYPE_SORTER );
7909279551
pCrsr = pC->uc.pCursor;
7909379552
79094
- if( rc ) goto abort_due_to_error;
79095
- if( pC->cacheStatus!=p->cacheCtr ){
79553
+ if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/
7909679554
if( pC->nullRow ){
7909779555
if( pC->eCurType==CURTYPE_PSEUDO ){
7909879556
assert( pC->uc.pseudoTableReg>0 );
7909979557
pReg = &aMem[pC->uc.pseudoTableReg];
7910079558
assert( pReg->flags & MEM_Blob );
@@ -79106,26 +79564,13 @@
7910679564
goto op_column_out;
7910779565
}
7910879566
}else{
7910979567
assert( pC->eCurType==CURTYPE_BTREE );
7911079568
assert( pCrsr );
79111
- if( pC->isTable==0 ){
79112
- assert( sqlite3BtreeCursorIsValid(pCrsr) );
79113
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64);
79114
- assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
79115
- /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the
79116
- ** payload size, so it is impossible for payloadSize64 to be
79117
- ** larger than 32 bits. */
79118
- assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 );
79119
- pC->aRow = sqlite3BtreeKeyFetch(pCrsr, &avail);
79120
- pC->payloadSize = (u32)payloadSize64;
79121
- }else{
79122
- assert( sqlite3BtreeCursorIsValid(pCrsr) );
79123
- VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &pC->payloadSize);
79124
- assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
79125
- pC->aRow = sqlite3BtreeDataFetch(pCrsr, &avail);
79126
- }
79569
+ assert( sqlite3BtreeCursorIsValid(pCrsr) );
79570
+ pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
79571
+ pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
7912779572
assert( avail<=65536 ); /* Maximum page size is 64KiB */
7912879573
if( pC->payloadSize <= (u32)avail ){
7912979574
pC->szRow = pC->payloadSize;
7913079575
}else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
7913179576
goto too_big;
@@ -79137,11 +79582,11 @@
7913779582
pC->iHdrOffset = getVarint32(pC->aRow, offset);
7913879583
pC->nHdrParsed = 0;
7913979584
aOffset[0] = offset;
7914079585
7914179586
79142
- if( avail<offset ){
79587
+ if( avail<offset ){ /*OPTIMIZATION-IF-FALSE*/
7914379588
/* pC->aRow does not have to hold the entire row, but it does at least
7914479589
** need to cover the header of the record. If pC->aRow does not contain
7914579590
** the complete header, then set it to zero, forcing the header to be
7914679591
** dynamically allocated. */
7914779592
pC->aRow = 0;
@@ -79158,28 +79603,28 @@
7915879603
*/
7915979604
if( offset > 98307 || offset > pC->payloadSize ){
7916079605
rc = SQLITE_CORRUPT_BKPT;
7916179606
goto abort_due_to_error;
7916279607
}
79163
- }
79164
-
79165
- /* The following goto is an optimization. It can be omitted and
79166
- ** everything will still work. But OP_Column is measurably faster
79167
- ** by skipping the subsequent conditional, which is always true.
79168
- */
79169
- assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79170
- goto op_column_read_header;
79608
+ }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/
79609
+ /* The following goto is an optimization. It can be omitted and
79610
+ ** everything will still work. But OP_Column is measurably faster
79611
+ ** by skipping the subsequent conditional, which is always true.
79612
+ */
79613
+ zData = pC->aRow;
79614
+ assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79615
+ goto op_column_read_header;
79616
+ }
7917179617
}
7917279618
7917379619
/* Make sure at least the first p2+1 entries of the header have been
7917479620
** parsed and valid information is in aOffset[] and pC->aType[].
7917579621
*/
7917679622
if( pC->nHdrParsed<=p2 ){
7917779623
/* If there is more header available for parsing in the record, try
7917879624
** to extract additional fields up through the p2+1-th field
7917979625
*/
79180
- op_column_read_header:
7918179626
if( pC->iHdrOffset<aOffset[0] ){
7918279627
/* Make sure zData points to enough of the record to cover the header. */
7918379628
if( pC->aRow==0 ){
7918479629
memset(&sMem, 0, sizeof(sMem));
7918579630
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
@@ -79188,15 +79633,15 @@
7918879633
}else{
7918979634
zData = pC->aRow;
7919079635
}
7919179636
7919279637
/* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
79638
+ op_column_read_header:
7919379639
i = pC->nHdrParsed;
7919479640
offset64 = aOffset[i];
7919579641
zHdr = zData + pC->iHdrOffset;
7919679642
zEndHdr = zData + aOffset[0];
79197
- assert( i<=p2 && zHdr<zEndHdr );
7919879643
do{
7919979644
if( (t = zHdr[0])<0x80 ){
7920079645
zHdr++;
7920179646
offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
7920279647
}else{
@@ -79204,13 +79649,11 @@
7920479649
offset64 += sqlite3VdbeSerialTypeLen(t);
7920579650
}
7920679651
pC->aType[i++] = t;
7920779652
aOffset[i] = (u32)(offset64 & 0xffffffff);
7920879653
}while( i<=p2 && zHdr<zEndHdr );
79209
- pC->nHdrParsed = i;
79210
- pC->iHdrOffset = (u32)(zHdr - zData);
79211
-
79654
+
7921279655
/* The record is corrupt if any of the following are true:
7921379656
** (1) the bytes of the header extend past the declared header size
7921479657
** (2) the entire header was used but not all data was used
7921579658
** (3) the end of the data extends beyond the end of the record.
7921679659
*/
@@ -79219,12 +79662,14 @@
7921979662
){
7922079663
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
7922179664
rc = SQLITE_CORRUPT_BKPT;
7922279665
goto abort_due_to_error;
7922379666
}
79667
+
79668
+ pC->nHdrParsed = i;
79669
+ pC->iHdrOffset = (u32)(zHdr - zData);
7922479670
if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79225
-
7922679671
}else{
7922779672
t = 0;
7922879673
}
7922979674
7923079675
/* If after trying to extract new entries from the header, nHdrParsed is
@@ -79248,13 +79693,14 @@
7924879693
** all valid.
7924979694
*/
7925079695
assert( p2<pC->nHdrParsed );
7925179696
assert( rc==SQLITE_OK );
7925279697
assert( sqlite3VdbeCheckMemInvariants(pDest) );
79253
- if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest);
79698
+ if( VdbeMemDynamic(pDest) ){
79699
+ sqlite3VdbeMemSetNull(pDest);
79700
+ }
7925479701
assert( t==pC->aType[p2] );
79255
- pDest->enc = encoding;
7925679702
if( pC->szRow>=aOffset[p2+1] ){
7925779703
/* This is the common case where the desired content fits on the original
7925879704
** page - where the content is not on an overflow page */
7925979705
zData = pC->aRow + aOffset[p2];
7926079706
if( t<12 ){
@@ -79264,10 +79710,11 @@
7926479710
** a MEM_Ephem value. This branch is a fast short-cut that is equivalent
7926579711
** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().
7926679712
*/
7926779713
static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
7926879714
pDest->n = len = (t-12)/2;
79715
+ pDest->enc = encoding;
7926979716
if( pDest->szMalloc < len+2 ){
7927079717
pDest->flags = MEM_Null;
7927179718
if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
7927279719
}else{
7927379720
pDest->z = pDest->zMalloc;
@@ -79276,10 +79723,11 @@
7927679723
pDest->z[len] = 0;
7927779724
pDest->z[len+1] = 0;
7927879725
pDest->flags = aFlag[t&1];
7927979726
}
7928079727
}else{
79728
+ pDest->enc = encoding;
7928179729
/* This branch happens only when content is on overflow pages */
7928279730
if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
7928379731
&& ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))
7928479732
|| (len = sqlite3VdbeSerialTypeLen(t))==0
7928579733
){
@@ -80693,10 +81141,34 @@
8069381141
if( takeJump || !alreadyExists ) goto jump_to_p2;
8069481142
}
8069581143
break;
8069681144
}
8069781145
81146
+/* Opcode: SeekRowid P1 P2 P3 * *
81147
+** Synopsis: intkey=r[P3]
81148
+**
81149
+** P1 is the index of a cursor open on an SQL table btree (with integer
81150
+** keys). If register P3 does not contain an integer or if P1 does not
81151
+** contain a record with rowid P3 then jump immediately to P2.
81152
+** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain
81153
+** a record with rowid P3 then
81154
+** leave the cursor pointing at that record and fall through to the next
81155
+** instruction.
81156
+**
81157
+** The OP_NotExists opcode performs the same operation, but with OP_NotExists
81158
+** the P3 register must be guaranteed to contain an integer value. With this
81159
+** opcode, register P3 might not contain an integer.
81160
+**
81161
+** The OP_NotFound opcode performs the same operation on index btrees
81162
+** (with arbitrary multi-value keys).
81163
+**
81164
+** This opcode leaves the cursor in a state where it cannot be advanced
81165
+** in either direction. In other words, the Next and Prev opcodes will
81166
+** not work following this opcode.
81167
+**
81168
+** See also: Found, NotFound, NoConflict, SeekRowid
81169
+*/
8069881170
/* Opcode: NotExists P1 P2 P3 * *
8069981171
** Synopsis: intkey=r[P3]
8070081172
**
8070181173
** P1 is the index of a cursor open on an SQL table btree (with integer
8070281174
** keys). P3 is an integer rowid. If P1 does not contain a record with
@@ -80703,26 +81175,37 @@
8070381175
** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an
8070481176
** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then
8070581177
** leave the cursor pointing at that record and fall through to the next
8070681178
** instruction.
8070781179
**
81180
+** The OP_SeekRowid opcode performs the same operation but also allows the
81181
+** P3 register to contain a non-integer value, in which case the jump is
81182
+** always taken. This opcode requires that P3 always contain an integer.
81183
+**
8070881184
** The OP_NotFound opcode performs the same operation on index btrees
8070981185
** (with arbitrary multi-value keys).
8071081186
**
8071181187
** This opcode leaves the cursor in a state where it cannot be advanced
8071281188
** in either direction. In other words, the Next and Prev opcodes will
8071381189
** not work following this opcode.
8071481190
**
80715
-** See also: Found, NotFound, NoConflict
81191
+** See also: Found, NotFound, NoConflict, SeekRowid
8071681192
*/
80717
-case OP_NotExists: { /* jump, in3 */
81193
+case OP_SeekRowid: { /* jump, in3 */
8071881194
VdbeCursor *pC;
8071981195
BtCursor *pCrsr;
8072081196
int res;
8072181197
u64 iKey;
8072281198
8072381199
pIn3 = &aMem[pOp->p3];
81200
+ if( (pIn3->flags & MEM_Int)==0 ){
81201
+ applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
81202
+ if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;
81203
+ }
81204
+ /* Fall through into OP_NotExists */
81205
+case OP_NotExists: /* jump, in3 */
81206
+ pIn3 = &aMem[pOp->p3];
8072481207
assert( pIn3->flags & MEM_Int );
8072581208
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8072681209
pC = p->apCsr[pOp->p1];
8072781210
assert( pC!=0 );
8072881211
#ifdef SQLITE_DEBUG
@@ -80836,12 +81319,11 @@
8083681319
}
8083781320
if( res ){
8083881321
v = 1; /* IMP: R-61914-48074 */
8083981322
}else{
8084081323
assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );
80841
- rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
80842
- assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
81324
+ v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8084381325
if( v>=MAX_ROWID ){
8084481326
pC->useRandomRowid = 1;
8084581327
}else{
8084681328
v++; /* IMP: R-29538-34987 */
8084781329
}
@@ -80920,14 +81402,16 @@
8092081402
** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
8092181403
** then rowid is stored for subsequent return by the
8092281404
** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
8092381405
**
8092481406
** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
80925
-** the last seek operation (OP_NotExists) was a success, then this
81407
+** the last seek operation (OP_NotExists or OP_SeekRowid) was a success,
81408
+** then this
8092681409
** operation will not attempt to find the appropriate row before doing
8092781410
** the insert but will instead overwrite the row that the cursor is
80928
-** currently pointing to. Presumably, the prior OP_NotExists opcode
81411
+** currently pointing to. Presumably, the prior OP_NotExists or
81412
+** OP_SeekRowid opcode
8092981413
** has already positioned the cursor correctly. This is an optimization
8093081414
** that boosts performance by avoiding redundant seeks.
8093181415
**
8093281416
** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
8093381417
** UPDATE operation. Otherwise (if the flag is clear) then this opcode
@@ -80955,17 +81439,16 @@
8095581439
*/
8095681440
case OP_Insert:
8095781441
case OP_InsertInt: {
8095881442
Mem *pData; /* MEM cell holding data for the record to be inserted */
8095981443
Mem *pKey; /* MEM cell holding key for the record */
80960
- i64 iKey; /* The integer ROWID or key for the record to be inserted */
8096181444
VdbeCursor *pC; /* Cursor to table into which insert is written */
80962
- int nZero; /* Number of zero-bytes to append */
8096381445
int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
8096481446
const char *zDb; /* database name - used by the update hook */
8096581447
Table *pTab; /* Table structure - used by update and pre-update hooks */
8096681448
int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
81449
+ BtreePayload x; /* Payload to be inserted */
8096781450
8096881451
op = 0;
8096981452
pData = &aMem[pOp->p2];
8097081453
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8097181454
assert( memIsValid(pData) );
@@ -80980,14 +81463,14 @@
8098081463
if( pOp->opcode==OP_Insert ){
8098181464
pKey = &aMem[pOp->p3];
8098281465
assert( pKey->flags & MEM_Int );
8098381466
assert( memIsValid(pKey) );
8098481467
REGISTER_TRACE(pOp->p3, pKey);
80985
- iKey = pKey->u.i;
81468
+ x.nKey = pKey->u.i;
8098681469
}else{
8098781470
assert( pOp->opcode==OP_InsertInt );
80988
- iKey = pOp->p3;
81471
+ x.nKey = pOp->p3;
8098981472
}
8099081473
8099181474
if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
8099281475
assert( pC->isTable );
8099381476
assert( pC->iDb>=0 );
@@ -81004,39 +81487,41 @@
8100481487
/* Invoke the pre-update hook, if any */
8100581488
if( db->xPreUpdateCallback
8100681489
&& pOp->p4type==P4_TABLE
8100781490
&& !(pOp->p5 & OPFLAG_ISUPDATE)
8100881491
){
81009
- sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2);
81492
+ sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);
8101081493
}
8101181494
#endif
8101281495
8101381496
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
81014
- if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey;
81497
+ if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey;
8101581498
if( pData->flags & MEM_Null ){
81016
- pData->z = 0;
81017
- pData->n = 0;
81499
+ x.pData = 0;
81500
+ x.nData = 0;
8101881501
}else{
8101981502
assert( pData->flags & (MEM_Blob|MEM_Str) );
81503
+ x.pData = pData->z;
81504
+ x.nData = pData->n;
8102081505
}
8102181506
seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);
8102281507
if( pData->flags & MEM_Zero ){
81023
- nZero = pData->u.nZero;
81508
+ x.nZero = pData->u.nZero;
8102481509
}else{
81025
- nZero = 0;
81510
+ x.nZero = 0;
8102681511
}
81027
- rc = sqlite3BtreeInsert(pC->uc.pCursor, 0, iKey,
81028
- pData->z, pData->n, nZero,
81512
+ x.pKey = 0;
81513
+ rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
8102981514
(pOp->p5 & OPFLAG_APPEND)!=0, seekResult
8103081515
);
8103181516
pC->deferredMoveto = 0;
8103281517
pC->cacheStatus = CACHE_STALE;
8103381518
8103481519
/* Invoke the update-hook if required. */
8103581520
if( rc ) goto abort_due_to_error;
8103681521
if( db->xUpdateCallback && op ){
81037
- db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
81522
+ db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);
8103881523
}
8103981524
break;
8104081525
}
8104181526
8104281527
/* Opcode: Delete P1 P2 P3 P4 P5
@@ -81091,12 +81576,11 @@
8109181576
#ifdef SQLITE_DEBUG
8109281577
if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
8109381578
/* If p5 is zero, the seek operation that positioned the cursor prior to
8109481579
** OP_Delete will have also set the pC->movetoTarget field to the rowid of
8109581580
** the row that is being deleted */
81096
- i64 iKey = 0;
81097
- sqlite3BtreeKeySize(pC->uc.pCursor, &iKey);
81581
+ i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8109881582
assert( pC->movetoTarget==iKey );
8109981583
}
8110081584
#endif
8110181585
8110281586
/* If the update-hook or pre-update-hook will be invoked, set zDb to
@@ -81108,11 +81592,11 @@
8110881592
assert( pC->iDb>=0 );
8110981593
assert( pOp->p4.pTab!=0 );
8111081594
zDb = db->aDb[pC->iDb].zName;
8111181595
pTab = pOp->p4.pTab;
8111281596
if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
81113
- sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget);
81597
+ pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8111481598
}
8111581599
}else{
8111681600
zDb = 0; /* Not needed. Silence a compiler warning. */
8111781601
pTab = 0; /* Not needed. Silence a compiler warning. */
8111881602
}
@@ -81262,11 +81746,10 @@
8126281746
case OP_RowKey:
8126381747
case OP_RowData: {
8126481748
VdbeCursor *pC;
8126581749
BtCursor *pCrsr;
8126681750
u32 n;
81267
- i64 n64;
8126881751
8126981752
pOut = &aMem[pOp->p2];
8127081753
memAboutToChange(p, pOut);
8127181754
8127281755
/* Note that RowKey and RowData are really exactly the same instruction */
@@ -81280,12 +81763,13 @@
8128081763
assert( pC->nullRow==0 );
8128181764
assert( pC->uc.pCursor!=0 );
8128281765
pCrsr = pC->uc.pCursor;
8128381766
8128481767
/* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
81285
- ** OP_Rewind/Op_Next with no intervening instructions that might invalidate
81286
- ** the cursor. If this where not the case, on of the following assert()s
81768
+ ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions
81769
+ ** that might invalidate the cursor.
81770
+ ** If this where not the case, on of the following assert()s
8128781771
** would fail. Should this ever change (because of changes in the code
8128881772
** generator) then the fix would be to insert a call to
8128981773
** sqlite3VdbeCursorMoveto().
8129081774
*/
8129181775
assert( pC->deferredMoveto==0 );
@@ -81293,24 +81777,13 @@
8129381777
#if 0 /* Not required due to the previous to assert() statements */
8129481778
rc = sqlite3VdbeCursorMoveto(pC);
8129581779
if( rc!=SQLITE_OK ) goto abort_due_to_error;
8129681780
#endif
8129781781
81298
- if( pC->isTable==0 ){
81299
- assert( !pC->isTable );
81300
- VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64);
81301
- assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */
81302
- if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
81303
- goto too_big;
81304
- }
81305
- n = (u32)n64;
81306
- }else{
81307
- VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n);
81308
- assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
81309
- if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81310
- goto too_big;
81311
- }
81782
+ n = sqlite3BtreePayloadSize(pCrsr);
81783
+ if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81784
+ goto too_big;
8131281785
}
8131381786
testcase( n==0 );
8131481787
if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
8131581788
goto no_mem;
8131681789
}
@@ -81371,12 +81844,11 @@
8137181844
if( rc ) goto abort_due_to_error;
8137281845
if( pC->nullRow ){
8137381846
pOut->flags = MEM_Null;
8137481847
break;
8137581848
}
81376
- rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v);
81377
- assert( rc==SQLITE_OK ); /* Always so because of CursorRestore() above */
81849
+ v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
8137881850
}
8137981851
pOut->u.i = v;
8138081852
break;
8138181853
}
8138281854
@@ -81647,12 +82119,11 @@
8164782119
** for tables is OP_Insert.
8164882120
*/
8164982121
case OP_SorterInsert: /* in2 */
8165082122
case OP_IdxInsert: { /* in2 */
8165182123
VdbeCursor *pC;
81652
- int nKey;
81653
- const char *zKey;
82124
+ BtreePayload x;
8165482125
8165582126
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8165682127
pC = p->apCsr[pOp->p1];
8165782128
assert( pC!=0 );
8165882129
assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
@@ -81664,13 +82135,16 @@
8166482135
rc = ExpandBlob(pIn2);
8166582136
if( rc ) goto abort_due_to_error;
8166682137
if( pOp->opcode==OP_SorterInsert ){
8166782138
rc = sqlite3VdbeSorterWrite(pC, pIn2);
8166882139
}else{
81669
- nKey = pIn2->n;
81670
- zKey = pIn2->z;
81671
- rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3,
82140
+ x.nKey = pIn2->n;
82141
+ x.pKey = pIn2->z;
82142
+ x.nData = 0;
82143
+ x.nZero = 0;
82144
+ x.pData = 0;
82145
+ rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3,
8167282146
((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
8167382147
);
8167482148
assert( pC->deferredMoveto==0 );
8167582149
pC->cacheStatus = CACHE_STALE;
8167682150
}
@@ -83434,20 +83908,38 @@
8343483908
**
8343583909
** If P2 is not zero, jump to instruction P2.
8343683910
*/
8343783911
case OP_Init: { /* jump */
8343883912
char *zTrace;
83439
- char *z;
83913
+
83914
+ /* If the P4 argument is not NULL, then it must be an SQL comment string.
83915
+ ** The "--" string is broken up to prevent false-positives with srcck1.c.
83916
+ **
83917
+ ** This assert() provides evidence for:
83918
+ ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that
83919
+ ** would have been returned by the legacy sqlite3_trace() interface by
83920
+ ** using the X argument when X begins with "--" and invoking
83921
+ ** sqlite3_expanded_sql(P) otherwise.
83922
+ */
83923
+ assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 );
8344083924
8344183925
#ifndef SQLITE_OMIT_TRACE
83442
- if( db->xTrace
83926
+ if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
8344383927
&& !p->doingRerun
8344483928
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
8344583929
){
83446
- z = sqlite3VdbeExpandSql(p, zTrace);
83447
- db->xTrace(db->pTraceArg, z);
83448
- sqlite3DbFree(db, z);
83930
+#ifndef SQLITE_OMIT_DEPRECATED
83931
+ if( db->mTrace & SQLITE_TRACE_LEGACY ){
83932
+ void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
83933
+ char *z = sqlite3VdbeExpandSql(p, zTrace);
83934
+ x(db->pTraceArg, z);
83935
+ sqlite3_free(z);
83936
+ }else
83937
+#endif
83938
+ {
83939
+ (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
83940
+ }
8344983941
}
8345083942
#ifdef SQLITE_USE_FCNTL_TRACE
8345183943
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
8345283944
if( zTrace ){
8345383945
int i;
@@ -84026,11 +84518,11 @@
8402684518
** slightly more efficient). Since you cannot write to a PK column
8402784519
** using the incremental-blob API, this works. For the sessions module
8402884520
** anyhow.
8402984521
*/
8403084522
sqlite3_int64 iKey;
84031
- sqlite3BtreeKeySize(p->pCsr, &iKey);
84523
+ iKey = sqlite3BtreeIntegerKey(p->pCsr);
8403284524
sqlite3VdbePreUpdateHook(
8403384525
v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
8403484526
);
8403584527
}
8403684528
#endif
@@ -85461,41 +85953,47 @@
8546185953
}
8546285954
8546385955
8546485956
/*
8546585957
** Merge the two sorted lists p1 and p2 into a single list.
85466
-** Set *ppOut to the head of the new list.
8546785958
*/
85468
-static void vdbeSorterMerge(
85959
+static SorterRecord *vdbeSorterMerge(
8546985960
SortSubtask *pTask, /* Calling thread context */
8547085961
SorterRecord *p1, /* First list to merge */
85471
- SorterRecord *p2, /* Second list to merge */
85472
- SorterRecord **ppOut /* OUT: Head of merged list */
85962
+ SorterRecord *p2 /* Second list to merge */
8547385963
){
8547485964
SorterRecord *pFinal = 0;
8547585965
SorterRecord **pp = &pFinal;
8547685966
int bCached = 0;
8547785967
85478
- while( p1 && p2 ){
85968
+ assert( p1!=0 && p2!=0 );
85969
+ for(;;){
8547985970
int res;
8548085971
res = pTask->xCompare(
8548185972
pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
8548285973
);
8548385974
8548485975
if( res<=0 ){
8548585976
*pp = p1;
8548685977
pp = &p1->u.pNext;
8548785978
p1 = p1->u.pNext;
85979
+ if( p1==0 ){
85980
+ *pp = p2;
85981
+ break;
85982
+ }
8548885983
}else{
8548985984
*pp = p2;
8549085985
pp = &p2->u.pNext;
8549185986
p2 = p2->u.pNext;
8549285987
bCached = 0;
85988
+ if( p2==0 ){
85989
+ *pp = p1;
85990
+ break;
85991
+ }
8549385992
}
8549485993
}
85495
- *pp = p1 ? p1 : p2;
85496
- *ppOut = pFinal;
85994
+ return pFinal;
8549785995
}
8549885996
8549985997
/*
8550085998
** Return the SorterCompare function to compare values collected by the
8550185999
** sorter object passed as the only argument.
@@ -85544,20 +86042,21 @@
8554486042
pNext = p->u.pNext;
8554586043
}
8554686044
8554786045
p->u.pNext = 0;
8554886046
for(i=0; aSlot[i]; i++){
85549
- vdbeSorterMerge(pTask, p, aSlot[i], &p);
86047
+ p = vdbeSorterMerge(pTask, p, aSlot[i]);
8555086048
aSlot[i] = 0;
8555186049
}
8555286050
aSlot[i] = p;
8555386051
p = pNext;
8555486052
}
8555586053
8555686054
p = 0;
8555786055
for(i=0; i<64; i++){
85558
- vdbeSorterMerge(pTask, p, aSlot[i], &p);
86056
+ if( aSlot[i]==0 ) continue;
86057
+ p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
8555986058
}
8556086059
pList->pList = p;
8556186060
8556286061
sqlite3_free(aSlot);
8556386062
assert( pTask->pUnpacked->errCode==SQLITE_OK
@@ -88173,11 +88672,15 @@
8817388672
}
8817488673
if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
8817588674
sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
8817688675
pNC->nErr++;
8817788676
is_agg = 0;
88178
- }else if( no_such_func && pParse->db->init.busy==0 ){
88677
+ }else if( no_such_func && pParse->db->init.busy==0
88678
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
88679
+ && pParse->explain==0
88680
+#endif
88681
+ ){
8817988682
sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
8818088683
pNC->nErr++;
8818188684
}else if( wrong_num_args ){
8818288685
sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
8818388686
nId, zId);
@@ -90773,10 +91276,15 @@
9077391276
VdbeComment((v, "%s", pIdx->zName));
9077491277
assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
9077591278
eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
9077691279
9077791280
if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91281
+#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91282
+ const i64 sOne = 1;
91283
+ sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91284
+ iTab, 0, 0, (u8*)&sOne, P4_INT64);
91285
+#endif
9077891286
*prRhsHasNull = ++pParse->nMem;
9077991287
sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
9078091288
}
9078191289
sqlite3VdbeJumpHere(v, iAddr);
9078291290
}
@@ -90785,11 +91293,11 @@
9078591293
}
9078691294
9078791295
/* If no preexisting index is available for the IN clause
9078891296
** and IN_INDEX_NOOP is an allowed reply
9078991297
** and the RHS of the IN operator is a list, not a subquery
90790
- ** and the RHS is not contant or has two or fewer terms,
91298
+ ** and the RHS is not constant or has two or fewer terms,
9079191299
** then it is not worth creating an ephemeral table to evaluate
9079291300
** the IN operator so return IN_INDEX_NOOP.
9079391301
*/
9079491302
if( eType==0
9079591303
&& (inFlags & IN_INDEX_NOOP_OK)
@@ -91177,12 +91685,11 @@
9117791685
}
9117891686
9117991687
if( eType==IN_INDEX_ROWID ){
9118091688
/* In this case, the RHS is the ROWID of table b-tree
9118191689
*/
91182
- sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); VdbeCoverage(v);
91183
- sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);
91690
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
9118491691
VdbeCoverage(v);
9118591692
}else{
9118691693
/* In this case, the RHS is an index b-tree.
9118791694
*/
9118891695
sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
@@ -91491,11 +91998,11 @@
9149191998
if( iCol<0 || iCol==pTab->iPKey ){
9149291999
sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
9149392000
}else{
9149492001
int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
9149592002
int x = iCol;
91496
- if( !HasRowid(pTab) ){
92003
+ if( !HasRowid(pTab) && !IsVirtual(pTab) ){
9149792004
x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
9149892005
}
9149992006
sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
9150092007
}
9150192008
if( iCol>=0 ){
@@ -91894,10 +92401,15 @@
9189492401
}
9189592402
nFarg = pFarg ? pFarg->nExpr : 0;
9189692403
assert( !ExprHasProperty(pExpr, EP_IntValue) );
9189792404
zId = pExpr->u.zToken;
9189892405
pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);
92406
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
92407
+ if( pDef==0 && pParse->explain ){
92408
+ pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0);
92409
+ }
92410
+#endif
9189992411
if( pDef==0 || pDef->xFinalize!=0 ){
9190092412
sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
9190192413
break;
9190292414
}
9190392415
@@ -92915,10 +93427,65 @@
9291593427
){
9291693428
return 1;
9291793429
}
9291893430
return 0;
9291993431
}
93432
+
93433
+/*
93434
+** An instance of the following structure is used by the tree walker
93435
+** to determine if an expression can be evaluated by reference to the
93436
+** index only, without having to do a search for the corresponding
93437
+** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
93438
+** is the cursor for the table.
93439
+*/
93440
+struct IdxCover {
93441
+ Index *pIdx; /* The index to be tested for coverage */
93442
+ int iCur; /* Cursor number for the table corresponding to the index */
93443
+};
93444
+
93445
+/*
93446
+** Check to see if there are references to columns in table
93447
+** pWalker->u.pIdxCover->iCur can be satisfied using the index
93448
+** pWalker->u.pIdxCover->pIdx.
93449
+*/
93450
+static int exprIdxCover(Walker *pWalker, Expr *pExpr){
93451
+ if( pExpr->op==TK_COLUMN
93452
+ && pExpr->iTable==pWalker->u.pIdxCover->iCur
93453
+ && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
93454
+ ){
93455
+ pWalker->eCode = 1;
93456
+ return WRC_Abort;
93457
+ }
93458
+ return WRC_Continue;
93459
+}
93460
+
93461
+/*
93462
+** Determine if an index pIdx on table with cursor iCur contains will
93463
+** the expression pExpr. Return true if the index does cover the
93464
+** expression and false if the pExpr expression references table columns
93465
+** that are not found in the index pIdx.
93466
+**
93467
+** An index covering an expression means that the expression can be
93468
+** evaluated using only the index and without having to lookup the
93469
+** corresponding table entry.
93470
+*/
93471
+SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(
93472
+ Expr *pExpr, /* The index to be tested */
93473
+ int iCur, /* The cursor number for the corresponding table */
93474
+ Index *pIdx /* The index that might be used for coverage */
93475
+){
93476
+ Walker w;
93477
+ struct IdxCover xcov;
93478
+ memset(&w, 0, sizeof(w));
93479
+ xcov.iCur = iCur;
93480
+ xcov.pIdx = pIdx;
93481
+ w.xExprCallback = exprIdxCover;
93482
+ w.u.pIdxCover = &xcov;
93483
+ sqlite3WalkExpr(&w, pExpr);
93484
+ return !w.eCode;
93485
+}
93486
+
9292093487
9292193488
/*
9292293489
** An instance of the following structure is used by the tree walker
9292393490
** to count references to table columns in the arguments of an
9292493491
** aggregate function, in order to implement the
@@ -93870,10 +94437,11 @@
9387094437
char *zCol; /* Null-terminated column definition */
9387194438
Column *pCol; /* The new column */
9387294439
Expr *pDflt; /* Default value for the new column */
9387394440
sqlite3 *db; /* The database connection; */
9387494441
Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
94442
+ int r1; /* Temporary registers */
9387594443
9387694444
db = pParse->db;
9387794445
if( pParse->nErr || db->mallocFailed ) return;
9387894446
assert( v!=0 );
9387994447
pNew = pParse->pNewTable;
@@ -93964,20 +94532,22 @@
9396494532
);
9396594533
sqlite3DbFree(db, zCol);
9396694534
db->flags = savedDbFlags;
9396794535
}
9396894536
93969
- /* If the default value of the new column is NULL, then the file
93970
- ** format to 2. If the default value of the new column is not NULL,
93971
- ** the file format be 3. Back when this feature was first added
93972
- ** in 2006, we went to the trouble to upgrade the file format to the
93973
- ** minimum support values. But 10-years on, we can assume that all
93974
- ** extent versions of SQLite support file-format 4, so we always and
93975
- ** unconditionally upgrade to 4.
94537
+ /* Make sure the schema version is at least 3. But do not upgrade
94538
+ ** from less than 3 to 4, as that will corrupt any preexisting DESC
94539
+ ** index.
9397694540
*/
93977
- sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT,
93978
- SQLITE_MAX_FILE_FORMAT);
94541
+ r1 = sqlite3GetTempReg(pParse);
94542
+ sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
94543
+ sqlite3VdbeUsesBtree(v, iDb);
94544
+ sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
94545
+ sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
94546
+ VdbeCoverage(v);
94547
+ sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
94548
+ sqlite3ReleaseTempReg(pParse, r1);
9397994549
9398094550
/* Reload the schema of the modified table. */
9398194551
reloadTableSchema(pParse, pTab, pTab->zName);
9398294552
}
9398394553
@@ -96662,10 +97232,11 @@
9666297232
){
9666397233
sqlite3 *db = pParse->db; /* Database handle */
9666497234
char *zDb = db->aDb[iDb].zName; /* Name of attached database */
9666597235
int rc; /* Auth callback return code */
9666697236
97237
+ if( db->init.busy ) return SQLITE_OK;
9666797238
rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext
9666897239
#ifdef SQLITE_USER_AUTHENTICATION
9666997240
,db->auth.zAuthUser
9667097241
#endif
9667197242
);
@@ -97152,11 +97723,11 @@
9715297723
** routine leaves an error message in pParse->zErrMsg where
9715397724
** sqlite3FindTable() does not.
9715497725
*/
9715597726
SQLITE_PRIVATE Table *sqlite3LocateTable(
9715697727
Parse *pParse, /* context in which to report errors */
97157
- int isView, /* True if looking for a VIEW rather than a TABLE */
97728
+ u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */
9715897729
const char *zName, /* Name of the table we are looking for */
9715997730
const char *zDbase /* Name of the database. Might be NULL */
9716097731
){
9716197732
Table *p;
9716297733
@@ -97166,11 +97737,11 @@
9716697737
return 0;
9716797738
}
9716897739
9716997740
p = sqlite3FindTable(pParse->db, zName, zDbase);
9717097741
if( p==0 ){
97171
- const char *zMsg = isView ? "no such view" : "no such table";
97742
+ const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
9717297743
#ifndef SQLITE_OMIT_VIRTUALTABLE
9717397744
if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
9717497745
/* If zName is the not the name of a table in the schema created using
9717597746
** CREATE, then check to see if it is the name of an virtual table that
9717697747
** can be an eponymous virtual table. */
@@ -97178,16 +97749,18 @@
9717897749
if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
9717997750
return pMod->pEpoTab;
9718097751
}
9718197752
}
9718297753
#endif
97183
- if( zDbase ){
97184
- sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97185
- }else{
97186
- sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97754
+ if( (flags & LOCATE_NOERR)==0 ){
97755
+ if( zDbase ){
97756
+ sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97757
+ }else{
97758
+ sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97759
+ }
97760
+ pParse->checkSchema = 1;
9718797761
}
97188
- pParse->checkSchema = 1;
9718997762
}
9719097763
9719197764
return p;
9719297765
}
9719397766
@@ -97200,11 +97773,11 @@
9720097773
** non-NULL if it is part of a view or trigger program definition. See
9720197774
** sqlite3FixSrcList() for details.
9720297775
*/
9720397776
SQLITE_PRIVATE Table *sqlite3LocateTableItem(
9720497777
Parse *pParse,
97205
- int isView,
97778
+ u32 flags,
9720697779
struct SrcList_item *p
9720797780
){
9720897781
const char *zDb;
9720997782
assert( p->pSchema==0 || p->zDatabase==0 );
9721097783
if( p->pSchema ){
@@ -97211,11 +97784,11 @@
9721197784
int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
9721297785
zDb = pParse->db->aDb[iDb].zName;
9721397786
}else{
9721497787
zDb = p->zDatabase;
9721597788
}
97216
- return sqlite3LocateTable(pParse, isView, p->zName, zDb);
97789
+ return sqlite3LocateTable(pParse, flags, p->zName, zDb);
9721797790
}
9721897791
9721997792
/*
9722097793
** Locate the in-memory structure that describes
9722197794
** a particular index given the name of that index
@@ -97419,12 +97992,13 @@
9741997992
db->lookaside.nOut : 0 );
9742097993
9742197994
/* Delete all indices associated with this table. */
9742297995
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
9742397996
pNext = pIndex->pNext;
97424
- assert( pIndex->pSchema==pTable->pSchema );
97425
- if( !db || db->pnBytesFreed==0 ){
97997
+ assert( pIndex->pSchema==pTable->pSchema
97998
+ || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );
97999
+ if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
9742698000
char *zName = pIndex->zName;
9742798001
TESTONLY ( Index *pOld = ) sqlite3HashInsert(
9742898002
&pIndex->pSchema->idxHash, zName, 0
9742998003
);
9743098004
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
@@ -98102,11 +98676,11 @@
9810298676
){
9810398677
Table *pTab = pParse->pNewTable;
9810498678
Column *pCol = 0;
9810598679
int iCol = -1, i;
9810698680
int nTerm;
98107
- if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;
98681
+ if( pTab==0 ) goto primary_key_exit;
9810898682
if( pTab->tabFlags & TF_HasPrimaryKey ){
9810998683
sqlite3ErrorMsg(pParse,
9811098684
"table \"%s\" has more than one primary key", pTab->zName);
9811198685
goto primary_key_exit;
9811298686
}
@@ -98148,16 +98722,12 @@
9814898722
#ifndef SQLITE_OMIT_AUTOINCREMENT
9814998723
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
9815098724
"INTEGER PRIMARY KEY");
9815198725
#endif
9815298726
}else{
98153
- Index *p;
98154
- p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98155
- 0, sortOrder, 0);
98156
- if( p ){
98157
- p->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
98158
- }
98727
+ sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98728
+ 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);
9815998729
pList = 0;
9816098730
}
9816198731
9816298732
primary_key_exit:
9816398733
sqlite3ExprListDelete(pParse->db, pList);
@@ -98470,33 +99040,49 @@
9847099040
** has a WITHOUT ROWID clause. The job of this routine is to convert both
9847199041
** internal schema data structures and the generated VDBE code so that they
9847299042
** are appropriate for a WITHOUT ROWID table instead of a rowid table.
9847399043
** Changes include:
9847499044
**
98475
-** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is
99045
+** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
99046
+** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is
9847699047
** no rowid btree for a WITHOUT ROWID. Instead, the canonical
9847799048
** data storage is a covering index btree.
98478
-** (2) Bypass the creation of the sqlite_master table entry
99049
+** (3) Bypass the creation of the sqlite_master table entry
9847999050
** for the PRIMARY KEY as the primary key index is now
9848099051
** identified by the sqlite_master table entry of the table itself.
98481
-** (3) Set the Index.tnum of the PRIMARY KEY Index object in the
99052
+** (4) Set the Index.tnum of the PRIMARY KEY Index object in the
9848299053
** schema to the rootpage from the main table.
98483
-** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
9848499054
** (5) Add all table columns to the PRIMARY KEY Index object
9848599055
** so that the PRIMARY KEY is a covering index. The surplus
9848699056
** columns are part of KeyInfo.nXField and are not used for
9848799057
** sorting or lookup or uniqueness checks.
9848899058
** (6) Replace the rowid tail on all automatically generated UNIQUE
9848999059
** indices with the PRIMARY KEY columns.
99060
+**
99061
+** For virtual tables, only (1) is performed.
9849099062
*/
9849199063
static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
9849299064
Index *pIdx;
9849399065
Index *pPk;
9849499066
int nPk;
9849599067
int i, j;
9849699068
sqlite3 *db = pParse->db;
9849799069
Vdbe *v = pParse->pVdbe;
99070
+
99071
+ /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
99072
+ */
99073
+ if( !db->init.imposterTable ){
99074
+ for(i=0; i<pTab->nCol; i++){
99075
+ if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
99076
+ pTab->aCol[i].notNull = OE_Abort;
99077
+ }
99078
+ }
99079
+ }
99080
+
99081
+ /* The remaining transformations only apply to b-tree tables, not to
99082
+ ** virtual tables */
99083
+ if( IN_DECLARE_VTAB ) return;
9849899084
9849999085
/* Convert the OP_CreateTable opcode that would normally create the
9850099086
** root-page for the table into an OP_CreateIndex opcode. The index
9850199087
** created will become the PRIMARY KEY index.
9850299088
*/
@@ -98515,13 +99101,14 @@
9851599101
pList = sqlite3ExprListAppend(pParse, 0,
9851699102
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
9851799103
if( pList==0 ) return;
9851899104
pList->a[0].sortOrder = pParse->iPkSortOrder;
9851999105
assert( pParse->pNewTable==pTab );
98520
- pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0);
98521
- if( pPk==0 ) return;
98522
- pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY;
99106
+ sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
99107
+ SQLITE_IDXTYPE_PRIMARYKEY);
99108
+ if( db->mallocFailed ) return;
99109
+ pPk = sqlite3PrimaryKeyIndex(pTab);
9852399110
pTab->iPKey = -1;
9852499111
}else{
9852599112
pPk = sqlite3PrimaryKeyIndex(pTab);
9852699113
9852799114
/* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
@@ -98545,23 +99132,15 @@
9854599132
pPk->aiColumn[j++] = pPk->aiColumn[i];
9854699133
}
9854799134
}
9854899135
pPk->nKeyCol = j;
9854999136
}
98550
- pPk->isCovering = 1;
9855199137
assert( pPk!=0 );
99138
+ pPk->isCovering = 1;
99139
+ if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
9855299140
nPk = pPk->nKeyCol;
9855399141
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
-
9856399142
/* The root page of the PRIMARY KEY is the table root page */
9856499143
pPk->tnum = pTab->tnum;
9856599144
9856699145
/* Update the in-memory representation of all UNIQUE indices by converting
9856799146
** the final rowid column into one or more columns of the PRIMARY KEY.
@@ -99312,10 +99891,11 @@
9931299891
}
9931399892
assert( pParse->nErr==0 );
9931499893
assert( pName->nSrc==1 );
9931599894
if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
9931699895
if( noErr ) db->suppressErr++;
99896
+ assert( isView==0 || isView==LOCATE_VIEW );
9931799897
pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
9931899898
if( noErr ) db->suppressErr--;
9931999899
9932099900
if( pTab==0 ){
9932199901
if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
@@ -99682,28 +100262,24 @@
99682100262
** currently being constructed by a CREATE TABLE statement.
99683100263
**
99684100264
** pList is a list of columns to be indexed. pList will be NULL if this
99685100265
** is a primary key or unique-constraint on the most recent column added
99686100266
** 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)
99691100267
*/
99692
-SQLITE_PRIVATE Index *sqlite3CreateIndex(
100268
+SQLITE_PRIVATE void sqlite3CreateIndex(
99693100269
Parse *pParse, /* All information about this parse */
99694100270
Token *pName1, /* First part of index name. May be NULL */
99695100271
Token *pName2, /* Second part of index name. May be NULL */
99696100272
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
99697100273
ExprList *pList, /* A list of columns to be indexed */
99698100274
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
99699100275
Token *pStart, /* The CREATE token that begins this statement */
99700100276
Expr *pPIWhere, /* WHERE clause for partial indices */
99701100277
int sortOrder, /* Sort order of primary key when pList==NULL */
99702
- int ifNotExist /* Omit error if index already exists */
100278
+ int ifNotExist, /* Omit error if index already exists */
100279
+ u8 idxType /* The index type */
99703100280
){
99704
- Index *pRet = 0; /* Pointer to return */
99705100281
Table *pTab = 0; /* Table to be indexed */
99706100282
Index *pIndex = 0; /* The index to be created */
99707100283
char *zName = 0; /* Name of the index */
99708100284
int nName; /* Number of characters in zName */
99709100285
int i, j;
@@ -99717,11 +100293,14 @@
99717100293
int nExtra = 0; /* Space allocated for zExtra[] */
99718100294
int nExtraCol; /* Number of extra columns needed */
99719100295
char *zExtra = 0; /* Extra space after the Index object */
99720100296
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
99721100297
99722
- if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){
100298
+ if( db->mallocFailed || pParse->nErr>0 ){
100299
+ goto exit_create_index;
100300
+ }
100301
+ if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
99723100302
goto exit_create_index;
99724100303
}
99725100304
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
99726100305
goto exit_create_index;
99727100306
}
@@ -99843,10 +100422,17 @@
99843100422
for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
99844100423
zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
99845100424
if( zName==0 ){
99846100425
goto exit_create_index;
99847100426
}
100427
+
100428
+ /* Automatic index names generated from within sqlite3_declare_vtab()
100429
+ ** must have names that are distinct from normal automatic index names.
100430
+ ** The following statement converts "sqlite3_autoindex..." into
100431
+ ** "sqlite3_butoindex..." in order to make the names distinct.
100432
+ ** The "vtab_err.test" test demonstrates the need of this statement. */
100433
+ if( IN_DECLARE_VTAB ) zName[7]++;
99848100434
}
99849100435
99850100436
/* Check for authorization to create an index.
99851100437
*/
99852100438
#ifndef SQLITE_OMIT_AUTHORIZATION
@@ -99906,11 +100492,11 @@
99906100492
zExtra += nName + 1;
99907100493
memcpy(pIndex->zName, zName, nName+1);
99908100494
pIndex->pTable = pTab;
99909100495
pIndex->onError = (u8)onError;
99910100496
pIndex->uniqNotNull = onError!=OE_None;
99911
- pIndex->idxType = pName ? SQLITE_IDXTYPE_APPDEF : SQLITE_IDXTYPE_UNIQUE;
100497
+ pIndex->idxType = idxType;
99912100498
pIndex->pSchema = db->aDb[iDb].pSchema;
99913100499
pIndex->nKeyCol = pList->nExpr;
99914100500
if( pPIWhere ){
99915100501
sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
99916100502
pIndex->pPartIdxWhere = pPIWhere;
@@ -100086,11 +100672,11 @@
100086100672
}
100087100673
if( pIdx->onError==OE_Default ){
100088100674
pIdx->onError = pIndex->onError;
100089100675
}
100090100676
}
100091
- pRet = pIdx;
100677
+ if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
100092100678
goto exit_create_index;
100093100679
}
100094100680
}
100095100681
}
100096100682
@@ -100098,10 +100684,11 @@
100098100684
** in-memory database structures.
100099100685
*/
100100100686
assert( pParse->nErr==0 );
100101100687
if( db->init.busy ){
100102100688
Index *p;
100689
+ assert( !IN_DECLARE_VTAB );
100103100690
assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
100104100691
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
100105100692
pIndex->zName, pIndex);
100106100693
if( p ){
100107100694
assert( p==pIndex ); /* Malloc must have failed */
@@ -100179,11 +100766,11 @@
100179100766
if( pTblName ){
100180100767
sqlite3RefillIndex(pParse, pIndex, iMem);
100181100768
sqlite3ChangeCookie(pParse, iDb);
100182100769
sqlite3VdbeAddParseSchemaOp(v, iDb,
100183100770
sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
100184
- sqlite3VdbeAddOp1(v, OP_Expire, 0);
100771
+ sqlite3VdbeAddOp0(v, OP_Expire);
100185100772
}
100186100773
100187100774
sqlite3VdbeJumpHere(v, pIndex->tnum);
100188100775
}
100189100776
@@ -100204,11 +100791,10 @@
100204100791
pOther = pOther->pNext;
100205100792
}
100206100793
pIndex->pNext = pOther->pNext;
100207100794
pOther->pNext = pIndex;
100208100795
}
100209
- pRet = pIndex;
100210100796
pIndex = 0;
100211100797
}
100212100798
100213100799
/* Clean up before exiting */
100214100800
exit_create_index:
@@ -100215,11 +100801,10 @@
100215100801
if( pIndex ) freeIndex(db, pIndex);
100216100802
sqlite3ExprDelete(db, pPIWhere);
100217100803
sqlite3ExprListDelete(db, pList);
100218100804
sqlite3SrcListDelete(db, pTblName);
100219100805
sqlite3DbFree(db, zName);
100220
- return pRet;
100221100806
}
100222100807
100223100808
/*
100224100809
** Fill the Index.aiRowEst[] array with default information - information
100225100810
** to be used when we have not run the ANALYZE command.
@@ -100244,14 +100829,15 @@
100244100829
LogEst *a = pIdx->aiRowLogEst;
100245100830
int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
100246100831
int i;
100247100832
100248100833
/* Set the first entry (number of rows in the index) to the estimated
100249
- ** number of rows in the table. Or 10, if the estimated number of rows
100250
- ** in the table is less than that. */
100834
+ ** number of rows in the table, or half the number of rows in the table
100835
+ ** for a partial index. But do not let the estimate drop below 10. */
100251100836
a[0] = pIdx->pTable->nRowLogEst;
100252
- if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100837
+ if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
100838
+ if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100253100839
100254100840
/* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
100255100841
** 6 and each subsequent value (if any) is 5. */
100256100842
memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
100257100843
for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
@@ -101129,14 +101715,10 @@
101129101715
#endif
101130101716
101131101717
/*
101132101718
** Return a KeyInfo structure that is appropriate for the given Index.
101133101719
**
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
-**
101138101720
** The caller should invoke sqlite3KeyInfoUnref() on the returned object
101139101721
** when it has finished using it.
101140101722
*/
101141101723
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
101142101724
int i;
@@ -103364,11 +103946,11 @@
103364103946
continue;
103365103947
}
103366103948
}
103367103949
c2 = Utf8Read(zString);
103368103950
if( c==c2 ) continue;
103369
- if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
103951
+ if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){
103370103952
continue;
103371103953
}
103372103954
if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
103373103955
return 0;
103374103956
}
@@ -103939,10 +104521,30 @@
103939104521
}
103940104522
}
103941104523
sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
103942104524
}
103943104525
104526
+
104527
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
104528
+/*
104529
+** The "unknown" function is automatically substituted in place of
104530
+** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN
104531
+** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.
104532
+** When the "sqlite3" command-line shell is built using this functionality,
104533
+** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries
104534
+** involving application-defined functions to be examined in a generic
104535
+** sqlite3 shell.
104536
+*/
104537
+static void unknownFunc(
104538
+ sqlite3_context *context,
104539
+ int argc,
104540
+ sqlite3_value **argv
104541
+){
104542
+ /* no-op */
104543
+}
104544
+#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/
104545
+
103944104546
103945104547
/* IMP: R-25361-16150 This function is omitted from SQLite by default. It
103946104548
** is only available if the SQLITE_SOUNDEX compile-time option is used
103947104549
** when SQLite is built.
103948104550
*/
@@ -104410,17 +105012,20 @@
104410105012
AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
104411105013
AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
104412105014
AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
104413105015
104414105016
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104415
- #ifdef SQLITE_CASE_SENSITIVE_LIKE
105017
+#ifdef SQLITE_CASE_SENSITIVE_LIKE
104416105018
LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104417105019
LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104418
- #else
105020
+#else
104419105021
LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
104420105022
LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
104421
- #endif
105023
+#endif
105024
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
105025
+ FUNCTION(unknown, -1, 0, 0, unknownFunc ),
105026
+#endif
104422105027
FUNCTION(coalesce, 1, 0, 0, 0 ),
104423105028
FUNCTION(coalesce, 0, 0, 0, 0 ),
104424105029
FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
104425105030
};
104426105031
#ifndef SQLITE_OMIT_ALTERTABLE
@@ -105823,11 +106428,12 @@
105823106428
*/
105824106429
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
105825106430
FKey *pFKey; /* Iterator variable */
105826106431
FKey *pNext; /* Copy of pFKey->pNextFrom */
105827106432
105828
- assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
106433
+ assert( db==0 || IsVirtual(pTab)
106434
+ || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
105829106435
for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
105830106436
105831106437
/* Remove the FK from the fkeyHash hash table. */
105832106438
if( !db || db->pnBytesFreed==0 ){
105833106439
if( pFKey->pPrevTo ){
@@ -108233,16 +108839,14 @@
108233108839
** shared libraries that want to be imported as extensions into
108234108840
** an SQLite instance. Shared libraries that intend to be loaded
108235108841
** as extensions by SQLite should #include this file instead of
108236108842
** sqlite3.h.
108237108843
*/
108238
-#ifndef _SQLITE3EXT_H_
108239
-#define _SQLITE3EXT_H_
108844
+#ifndef SQLITE3EXT_H
108845
+#define SQLITE3EXT_H
108240108846
/* #include "sqlite3.h" */
108241108847
108242
-typedef struct sqlite3_api_routines sqlite3_api_routines;
108243
-
108244108848
/*
108245108849
** The following structure holds pointers to all of the SQLite API
108246108850
** routines.
108247108851
**
108248108852
** WARNING: In order to maintain backwards compatibility, add new
@@ -108499,11 +109103,24 @@
108499109103
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
108500109104
int (*strlike)(const char*,const char*,unsigned int);
108501109105
int (*db_cacheflush)(sqlite3*);
108502109106
/* Version 3.12.0 and later */
108503109107
int (*system_errno)(sqlite3*);
109108
+ /* Version 3.14.0 and later */
109109
+ int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
109110
+ char *(*expanded_sql)(sqlite3_stmt*);
108504109111
};
109112
+
109113
+/*
109114
+** This is the function signature used for all extension entry points. It
109115
+** is also defined in the file "loadext.c".
109116
+*/
109117
+typedef int (*sqlite3_loadext_entry)(
109118
+ sqlite3 *db, /* Handle to the database. */
109119
+ char **pzErrMsg, /* Used to set error string on failure. */
109120
+ const sqlite3_api_routines *pThunk /* Extension API function pointers. */
109121
+);
108505109122
108506109123
/*
108507109124
** The following macros redefine the API routines so that they are
108508109125
** redirected through the global sqlite3_api structure.
108509109126
**
@@ -108744,10 +109361,13 @@
108744109361
#define sqlite3_status64 sqlite3_api->status64
108745109362
#define sqlite3_strlike sqlite3_api->strlike
108746109363
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
108747109364
/* Version 3.12.0 and later */
108748109365
#define sqlite3_system_errno sqlite3_api->system_errno
109366
+/* Version 3.14.0 and later */
109367
+#define sqlite3_trace_v2 sqlite3_api->trace_v2
109368
+#define sqlite3_expanded_sql sqlite3_api->expanded_sql
108749109369
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
108750109370
108751109371
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
108752109372
/* This case when the file really is being compiled as a loadable
108753109373
** extension */
@@ -108761,19 +109381,18 @@
108761109381
# define SQLITE_EXTENSION_INIT1 /*no-op*/
108762109382
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
108763109383
# define SQLITE_EXTENSION_INIT3 /*no-op*/
108764109384
#endif
108765109385
108766
-#endif /* _SQLITE3EXT_H_ */
109386
+#endif /* SQLITE3EXT_H */
108767109387
108768109388
/************** End of sqlite3ext.h ******************************************/
108769109389
/************** Continuing where we left off in loadext.c ********************/
108770109390
/* #include "sqliteInt.h" */
108771109391
/* #include <string.h> */
108772109392
108773109393
#ifndef SQLITE_OMIT_LOAD_EXTENSION
108774
-
108775109394
/*
108776109395
** Some API routines are omitted when various features are
108777109396
** excluded from a build of SQLite. Substitute a NULL pointer
108778109397
** for any missing APIs.
108779109398
*/
@@ -108839,11 +109458,11 @@
108839109458
108840109459
#ifdef SQLITE_OMIT_SHARED_CACHE
108841109460
# define sqlite3_enable_shared_cache 0
108842109461
#endif
108843109462
108844
-#ifdef SQLITE_OMIT_TRACE
109463
+#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)
108845109464
# define sqlite3_profile 0
108846109465
# define sqlite3_trace 0
108847109466
#endif
108848109467
108849109468
#ifdef SQLITE_OMIT_GET_TABLE
@@ -108858,10 +109477,14 @@
108858109477
#define sqlite3_blob_open 0
108859109478
#define sqlite3_blob_read 0
108860109479
#define sqlite3_blob_write 0
108861109480
#define sqlite3_blob_reopen 0
108862109481
#endif
109482
+
109483
+#if defined(SQLITE_OMIT_TRACE)
109484
+# define sqlite3_trace_v2 0
109485
+#endif
108863109486
108864109487
/*
108865109488
** The following structure contains pointers to all SQLite API routines.
108866109489
** A pointer to this structure is passed into extensions when they are
108867109490
** loaded so that the extension can make calls back into the SQLite
@@ -109164,11 +109787,14 @@
109164109787
/* Version 3.10.0 and later */
109165109788
sqlite3_status64,
109166109789
sqlite3_strlike,
109167109790
sqlite3_db_cacheflush,
109168109791
/* Version 3.12.0 and later */
109169
- sqlite3_system_errno
109792
+ sqlite3_system_errno,
109793
+ /* Version 3.14.0 and later */
109794
+ sqlite3_trace_v2,
109795
+ sqlite3_expanded_sql
109170109796
};
109171109797
109172109798
/*
109173109799
** Attempt to load an SQLite extension library contained in the file
109174109800
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -109187,17 +109813,18 @@
109187109813
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
109188109814
char **pzErrMsg /* Put error message here if not 0 */
109189109815
){
109190109816
sqlite3_vfs *pVfs = db->pVfs;
109191109817
void *handle;
109192
- int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
109818
+ sqlite3_loadext_entry xInit;
109193109819
char *zErrmsg = 0;
109194109820
const char *zEntry;
109195109821
char *zAltEntry = 0;
109196109822
void **aHandle;
109197109823
u64 nMsg = 300 + sqlite3Strlen30(zFile);
109198109824
int ii;
109825
+ int rc;
109199109826
109200109827
/* Shared library endings to try if zFile cannot be loaded as written */
109201109828
static const char *azEndings[] = {
109202109829
#if SQLITE_OS_WIN
109203109830
"dll"
@@ -109245,12 +109872,11 @@
109245109872
sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
109246109873
}
109247109874
}
109248109875
return SQLITE_ERROR;
109249109876
}
109250
- xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109251
- sqlite3OsDlSym(pVfs, handle, zEntry);
109877
+ xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
109252109878
109253109879
/* If no entry point was specified and the default legacy
109254109880
** entry point name "sqlite3_extension_init" was not found, then
109255109881
** construct an entry point name "sqlite3_X_init" where the X is
109256109882
** replaced by the lowercase value of every ASCII alphabetic
@@ -109278,12 +109904,11 @@
109278109904
zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
109279109905
}
109280109906
}
109281109907
memcpy(zAltEntry+iEntry, "_init", 6);
109282109908
zEntry = zAltEntry;
109283
- xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109284
- sqlite3OsDlSym(pVfs, handle, zEntry);
109909
+ xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
109285109910
}
109286109911
if( xInit==0 ){
109287109912
if( pzErrMsg ){
109288109913
nMsg += sqlite3Strlen30(zEntry);
109289109914
*pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
@@ -109296,11 +109921,13 @@
109296109921
sqlite3OsDlClose(pVfs, handle);
109297109922
sqlite3_free(zAltEntry);
109298109923
return SQLITE_ERROR;
109299109924
}
109300109925
sqlite3_free(zAltEntry);
109301
- if( xInit(db, &zErrmsg, &sqlite3Apis) ){
109926
+ rc = xInit(db, &zErrmsg, &sqlite3Apis);
109927
+ if( rc ){
109928
+ if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
109302109929
if( pzErrMsg ){
109303109930
*pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
109304109931
}
109305109932
sqlite3_free(zErrmsg);
109306109933
sqlite3OsDlClose(pVfs, handle);
@@ -109407,11 +110034,13 @@
109407110034
109408110035
/*
109409110036
** Register a statically linked extension that is automatically
109410110037
** loaded by every new database connection.
109411110038
*/
109412
-SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
110039
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(
110040
+ void (*xInit)(void)
110041
+){
109413110042
int rc = SQLITE_OK;
109414110043
#ifndef SQLITE_OMIT_AUTOINIT
109415110044
rc = sqlite3_initialize();
109416110045
if( rc ){
109417110046
return rc;
@@ -109452,11 +110081,13 @@
109452110081
** routine is a no-op.
109453110082
**
109454110083
** Return 1 if xInit was found on the list and removed. Return 0 if xInit
109455110084
** was not on the list.
109456110085
*/
109457
-SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
110086
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(
110087
+ void (*xInit)(void)
110088
+){
109458110089
#if SQLITE_THREADSAFE
109459110090
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
109460110091
#endif
109461110092
int i;
109462110093
int n = 0;
@@ -109501,11 +110132,11 @@
109501110132
*/
109502110133
SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
109503110134
u32 i;
109504110135
int go = 1;
109505110136
int rc;
109506
- int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
110137
+ sqlite3_loadext_entry xInit;
109507110138
109508110139
wsdAutoextInit;
109509110140
if( wsdAutoext.nExt==0 ){
109510110141
/* Common case: early out without every having to acquire a mutex */
109511110142
return;
@@ -109518,12 +110149,11 @@
109518110149
sqlite3_mutex_enter(mutex);
109519110150
if( i>=wsdAutoext.nExt ){
109520110151
xInit = 0;
109521110152
go = 0;
109522110153
}else{
109523
- xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109524
- wsdAutoext.aExt[i];
110154
+ xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i];
109525110155
}
109526110156
sqlite3_mutex_leave(mutex);
109527110157
zErrmsg = 0;
109528110158
if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){
109529110159
sqlite3ErrorWithMsg(db, rc,
@@ -111034,11 +111664,11 @@
111034111664
111035111665
/* Many of the flag-pragmas modify the code generated by the SQL
111036111666
** compiler (eg. count_changes). So add an opcode to expire all
111037111667
** compiled SQL statements after modifying a pragma value.
111038111668
*/
111039
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
111669
+ sqlite3VdbeAddOp0(v, OP_Expire);
111040111670
setAllPagerFlags(db);
111041111671
}
111042111672
break;
111043111673
}
111044111674
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -111056,11 +111686,11 @@
111056111686
** notnull: True if 'NOT NULL' is part of column declaration
111057111687
** dflt_value: The default value for the column, if any.
111058111688
*/
111059111689
case PragTyp_TABLE_INFO: if( zRight ){
111060111690
Table *pTab;
111061
- pTab = sqlite3FindTable(db, zRight, zDb);
111691
+ pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
111062111692
if( pTab ){
111063111693
static const char *azCol[] = {
111064111694
"cid", "name", "type", "notnull", "dflt_value", "pk"
111065111695
};
111066111696
int i, k;
@@ -111338,16 +111968,14 @@
111338111968
assert( iKey>=0 && iKey<pTab->nCol );
111339111969
if( iKey!=pTab->iPKey ){
111340111970
sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
111341111971
sqlite3ColumnDefault(v, pTab, iKey, regRow);
111342111972
sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v);
111343
- sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow,
111344
- sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v);
111345111973
}else{
111346111974
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
111347111975
}
111348
- sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v);
111976
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v);
111349111977
sqlite3VdbeGoto(v, addrOk);
111350111978
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
111351111979
}else{
111352111980
for(j=0; j<pFK->nCol; j++){
111353111981
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
@@ -112914,10 +113542,11 @@
112914113542
int regReturn; /* Register holding block-output return address */
112915113543
int labelBkOut; /* Start label for the block-output subroutine */
112916113544
int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
112917113545
int labelDone; /* Jump here when done, ex: LIMIT reached */
112918113546
u8 sortFlags; /* Zero or more SORTFLAG_* bits */
113547
+ u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
112919113548
};
112920113549
#define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
112921113550
112922113551
/*
112923113552
** Delete all the content of a Select structure. Deallocate the structure
@@ -113447,13 +114076,34 @@
113447114076
op = OP_IdxInsert;
113448114077
}
113449114078
sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
113450114079
if( iLimit ){
113451114080
int addr;
114081
+ int r1 = 0;
114082
+ /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit
114083
+ ** register is initialized with value of LIMIT+OFFSET.) After the sorter
114084
+ ** fills up, delete the least entry in the sorter after each insert.
114085
+ ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
113452114086
addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
113453114087
sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
114088
+ if( pSort->bOrderedInnerLoop ){
114089
+ r1 = ++pParse->nMem;
114090
+ sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
114091
+ VdbeComment((v, "seq"));
114092
+ }
113454114093
sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
114094
+ if( pSort->bOrderedInnerLoop ){
114095
+ /* If the inner loop is driven by an index such that values from
114096
+ ** the same iteration of the inner loop are in sorted order, then
114097
+ ** immediately jump to the next iteration of an inner loop if the
114098
+ ** entry from the current iteration does not fit into the top
114099
+ ** LIMIT+OFFSET entries of the sorter. */
114100
+ int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
114101
+ sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
114102
+ sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
114103
+ VdbeCoverage(v);
114104
+ }
113455114105
sqlite3VdbeJumpHere(v, addr);
113456114106
}
113457114107
}
113458114108
113459114109
/*
@@ -113864,11 +114514,11 @@
113864114514
** Allocate a KeyInfo object sufficient for an index of N key columns and
113865114515
** X extra columns.
113866114516
*/
113867114517
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
113868114518
int nExtra = (N+X)*(sizeof(CollSeq*)+1);
113869
- KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra);
114519
+ KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra);
113870114520
if( p ){
113871114521
p->aSortOrder = (u8*)&p->aColl[N+X];
113872114522
p->nField = (u16)N;
113873114523
p->nXField = (u16)X;
113874114524
p->enc = ENC(db);
@@ -113886,11 +114536,11 @@
113886114536
*/
113887114537
SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){
113888114538
if( p ){
113889114539
assert( p->nRef>0 );
113890114540
p->nRef--;
113891
- if( p->nRef==0 ) sqlite3DbFree(0, p);
114541
+ if( p->nRef==0 ) sqlite3DbFree(p->db, p);
113892114542
}
113893114543
}
113894114544
113895114545
/*
113896114546
** Make a new pointer to a KeyInfo object
@@ -118034,10 +118684,11 @@
118034118684
if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
118035118685
sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
118036118686
}
118037118687
if( sSort.pOrderBy ){
118038118688
sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
118689
+ sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
118039118690
if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
118040118691
sSort.pOrderBy = 0;
118041118692
}
118042118693
}
118043118694
@@ -120803,11 +121454,11 @@
120803121454
Btree *pTemp; /* The temporary database we vacuum into */
120804121455
char *zSql = 0; /* SQL statements */
120805121456
int saved_flags; /* Saved value of the db->flags */
120806121457
int saved_nChange; /* Saved value of db->nChange */
120807121458
int saved_nTotalChange; /* Saved value of db->nTotalChange */
120808
- void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */
121459
+ u8 saved_mTrace; /* Saved trace settings */
120809121460
Db *pDb = 0; /* Database to detach at end of vacuum */
120810121461
int isMemDb; /* True if vacuuming a :memory: database */
120811121462
int nRes; /* Bytes of reserved space at the end of each page */
120812121463
int nDb; /* Number of attached databases */
120813121464
@@ -120824,14 +121475,14 @@
120824121475
** restored before returning. Then set the writable-schema flag, and
120825121476
** disable CHECK and foreign key constraints. */
120826121477
saved_flags = db->flags;
120827121478
saved_nChange = db->nChange;
120828121479
saved_nTotalChange = db->nTotalChange;
120829
- saved_xTrace = db->xTrace;
121480
+ saved_mTrace = db->mTrace;
120830121481
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
120831121482
db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
120832
- db->xTrace = 0;
121483
+ db->mTrace = 0;
120833121484
120834121485
pMain = db->aDb[0].pBt;
120835121486
isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
120836121487
120837121488
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -120879,10 +121530,12 @@
120879121530
sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
120880121531
if( nKey ) db->nextPagesize = 0;
120881121532
}
120882121533
#endif
120883121534
121535
+ sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size);
121536
+ sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
120884121537
rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF");
120885121538
if( rc!=SQLITE_OK ) goto end_of_vacuum;
120886121539
120887121540
/* Begin a transaction and take an exclusive lock on the main database
120888121541
** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
@@ -121027,11 +121680,11 @@
121027121680
end_of_vacuum:
121028121681
/* Restore the original value of db->flags */
121029121682
db->flags = saved_flags;
121030121683
db->nChange = saved_nChange;
121031121684
db->nTotalChange = saved_nTotalChange;
121032
- db->xTrace = saved_xTrace;
121685
+ db->mTrace = saved_mTrace;
121033121686
sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
121034121687
121035121688
/* Currently there is an SQL level transaction open on the vacuum
121036121689
** database. No locks are held on any other files (since the main file
121037121690
** was committed at the btree level). So it safe to end the transaction
@@ -121476,11 +122129,11 @@
121476122129
);
121477122130
sqlite3DbFree(db, zStmt);
121478122131
v = sqlite3GetVdbe(pParse);
121479122132
sqlite3ChangeCookie(pParse, iDb);
121480122133
121481
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
122134
+ sqlite3VdbeAddOp0(v, OP_Expire);
121482122135
zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
121483122136
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
121484122137
121485122138
iReg = ++pParse->nMem;
121486122139
sqlite3VdbeLoadString(v, iReg, pTab->zName);
@@ -121812,14 +122465,28 @@
121812122465
&& !db->mallocFailed
121813122466
&& !pParse->pNewTable->pSelect
121814122467
&& (pParse->pNewTable->tabFlags & TF_Virtual)==0
121815122468
){
121816122469
if( !pTab->aCol ){
121817
- pTab->aCol = pParse->pNewTable->aCol;
121818
- pTab->nCol = pParse->pNewTable->nCol;
121819
- pParse->pNewTable->nCol = 0;
121820
- pParse->pNewTable->aCol = 0;
122470
+ Table *pNew = pParse->pNewTable;
122471
+ Index *pIdx;
122472
+ pTab->aCol = pNew->aCol;
122473
+ pTab->nCol = pNew->nCol;
122474
+ pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
122475
+ pNew->nCol = 0;
122476
+ pNew->aCol = 0;
122477
+ assert( pTab->pIndex==0 );
122478
+ if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){
122479
+ rc = SQLITE_ERROR;
122480
+ }
122481
+ pIdx = pNew->pIndex;
122482
+ if( pIdx ){
122483
+ assert( pIdx->pNext==0 );
122484
+ pTab->pIndex = pIdx;
122485
+ pNew->pIndex = 0;
122486
+ pIdx->pTable = pTab;
122487
+ }
121821122488
}
121822122489
pCtx->bDeclared = 1;
121823122490
}else{
121824122491
sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
121825122492
sqlite3DbFree(db, zErr);
@@ -121851,11 +122518,11 @@
121851122518
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
121852122519
int rc = SQLITE_OK;
121853122520
Table *pTab;
121854122521
121855122522
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
121856
- if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
122523
+ if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){
121857122524
VTable *p;
121858122525
int (*xDestroy)(sqlite3_vtab *);
121859122526
for(p=pTab->pVTable; p; p=p->pNext){
121860122527
assert( p->pVtab );
121861122528
if( p->pVtab->nRef>0 ){
@@ -121991,11 +122658,14 @@
121991122658
if( rc==SQLITE_OK ){
121992122659
rc = pModule->xBegin(pVTab->pVtab);
121993122660
if( rc==SQLITE_OK ){
121994122661
int iSvpt = db->nStatement + db->nSavepoint;
121995122662
addToVTrans(db, pVTab);
121996
- if( iSvpt ) rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, iSvpt-1);
122663
+ if( iSvpt && pModule->xSavepoint ){
122664
+ pVTab->iSavepoint = iSvpt;
122665
+ rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);
122666
+ }
121997122667
}
121998122668
}
121999122669
}
122000122670
return rc;
122001122671
}
@@ -122145,11 +122815,11 @@
122145122815
sqlite3OomFault(pToplevel->db);
122146122816
}
122147122817
}
122148122818
122149122819
/*
122150
-** Check to see if virtual tale module pMod can be have an eponymous
122820
+** Check to see if virtual table module pMod can be have an eponymous
122151122821
** virtual table instance. If it can, create one if one does not already
122152122822
** exist. Return non-zero if the eponymous virtual table instance exists
122153122823
** when this routine returns, and return zero if it does not exist.
122154122824
**
122155122825
** An eponymous virtual table instance is one that is named after its
@@ -122162,21 +122832,22 @@
122162122832
*/
122163122833
SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
122164122834
const sqlite3_module *pModule = pMod->pModule;
122165122835
Table *pTab;
122166122836
char *zErr = 0;
122167
- int nName;
122168122837
int rc;
122169122838
sqlite3 *db = pParse->db;
122170122839
if( pMod->pEpoTab ) return 1;
122171122840
if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;
122172
- nName = sqlite3Strlen30(pMod->zName) + 1;
122173
- pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName);
122841
+ pTab = sqlite3DbMallocZero(db, sizeof(Table));
122174122842
if( pTab==0 ) return 0;
122843
+ pTab->zName = sqlite3DbStrDup(db, pMod->zName);
122844
+ if( pTab->zName==0 ){
122845
+ sqlite3DbFree(db, pTab);
122846
+ return 0;
122847
+ }
122175122848
pMod->pEpoTab = pTab;
122176
- pTab->zName = (char*)&pTab[1];
122177
- memcpy(pTab->zName, pMod->zName, nName);
122178122849
pTab->nRef = 1;
122179122850
pTab->pSchema = db->aDb[0].pSchema;
122180122851
pTab->tabFlags |= TF_Virtual;
122181122852
pTab->nModuleArg = 0;
122182122853
pTab->iPKey = -1;
@@ -122198,13 +122869,15 @@
122198122869
** virtual table module pMod, if it exists.
122199122870
*/
122200122871
SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){
122201122872
Table *pTab = pMod->pEpoTab;
122202122873
if( pTab!=0 ){
122203
- sqlite3DeleteColumnNames(db, pTab);
122204
- sqlite3VtabClear(db, pTab);
122205
- sqlite3DbFree(db, pTab);
122874
+ /* Mark the table as Ephemeral prior to deleting it, so that the
122875
+ ** sqlite3DeleteTable() routine will know that it is not stored in
122876
+ ** the schema. */
122877
+ pTab->tabFlags |= TF_Ephemeral;
122878
+ sqlite3DeleteTable(db, pTab);
122206122879
pMod->pEpoTab = 0;
122207122880
}
122208122881
}
122209122882
122210122883
/*
@@ -122707,12 +123380,13 @@
122707123380
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
122708123381
i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
122709123382
u8 sorted; /* True if really sorted (not just grouped) */
122710123383
u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
122711123384
u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
122712
- u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */
123385
+ u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
122713123386
u8 nLevel; /* Number of nested loop */
123387
+ u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */
122714123388
int iTop; /* The very beginning of the WHERE loop */
122715123389
int iContinue; /* Jump here to continue with next record */
122716123390
int iBreak; /* Jump here to break out of the loop */
122717123391
int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
122718123392
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
@@ -122725,10 +123399,13 @@
122725123399
** Private interfaces - callable only by other where.c routines.
122726123400
**
122727123401
** where.c:
122728123402
*/
122729123403
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
123404
+#ifdef WHERETRACE_ENABLED
123405
+SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);
123406
+#endif
122730123407
SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(
122731123408
WhereClause *pWC, /* The WHERE clause to be searched */
122732123409
int iCur, /* Cursor number of LHS */
122733123410
int iColumn, /* Column number of LHS */
122734123411
Bitmask notReady, /* RHS must not overlap with this mask */
@@ -122941,11 +123618,11 @@
122941123618
StrAccum str; /* EQP output string */
122942123619
char zBuf[100]; /* Initial space for EQP output string */
122943123620
122944123621
pLoop = pLevel->pWLoop;
122945123622
flags = pLoop->wsFlags;
122946
- if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0;
123623
+ if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;
122947123624
122948123625
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
122949123626
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
122950123627
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
122951123628
@@ -123384,11 +124061,11 @@
123384124061
**
123385124062
** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
123386124063
** expression: "x>='ABC' AND x<'abd'". But this requires that the range
123387124064
** scan loop run twice, once for strings and a second time for BLOBs.
123388124065
** The OP_String opcodes on the second pass convert the upper and lower
123389
-** bound string contants to blobs. This routine makes the necessary changes
124066
+** bound string constants to blobs. This routine makes the necessary changes
123390124067
** to the OP_String opcodes for that to happen.
123391124068
**
123392124069
** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then
123393124070
** only the one pass through the string space is required, so this routine
123394124071
** becomes a no-op.
@@ -123441,10 +124118,42 @@
123441124118
pWalker->eCode = 1;
123442124119
}
123443124120
return WRC_Continue;
123444124121
}
123445124122
124123
+/*
124124
+** Test whether or not expression pExpr, which was part of a WHERE clause,
124125
+** should be included in the cursor-hint for a table that is on the rhs
124126
+** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the
124127
+** expression is not suitable.
124128
+**
124129
+** An expression is unsuitable if it might evaluate to non NULL even if
124130
+** a TK_COLUMN node that does affect the value of the expression is set
124131
+** to NULL. For example:
124132
+**
124133
+** col IS NULL
124134
+** col IS NOT NULL
124135
+** coalesce(col, 1)
124136
+** CASE WHEN col THEN 0 ELSE 1 END
124137
+*/
124138
+static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
124139
+ if( pExpr->op==TK_IS
124140
+ || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT
124141
+ || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE
124142
+ ){
124143
+ pWalker->eCode = 1;
124144
+ }else if( pExpr->op==TK_FUNCTION ){
124145
+ int d1;
124146
+ char d2[3];
124147
+ if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){
124148
+ pWalker->eCode = 1;
124149
+ }
124150
+ }
124151
+
124152
+ return WRC_Continue;
124153
+}
124154
+
123446124155
123447124156
/*
123448124157
** This function is called on every node of an expression tree used as an
123449124158
** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN
123450124159
** that accesses any table other than the one identified by
@@ -123493,10 +124202,11 @@
123493124202
123494124203
/*
123495124204
** Insert an OP_CursorHint instruction if it is appropriate to do so.
123496124205
*/
123497124206
static void codeCursorHint(
124207
+ struct SrcList_item *pTabItem, /* FROM clause item */
123498124208
WhereInfo *pWInfo, /* The where clause */
123499124209
WhereLevel *pLevel, /* Which loop to provide hints for */
123500124210
WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
123501124211
){
123502124212
Parse *pParse = pWInfo->pParse;
@@ -123523,11 +124233,46 @@
123523124233
pWC = &pWInfo->sWC;
123524124234
for(i=0; i<pWC->nTerm; i++){
123525124235
pTerm = &pWC->a[i];
123526124236
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
123527124237
if( pTerm->prereqAll & pLevel->notReady ) continue;
123528
- if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124238
+
124239
+ /* Any terms specified as part of the ON(...) clause for any LEFT
124240
+ ** JOIN for which the current table is not the rhs are omitted
124241
+ ** from the cursor-hint.
124242
+ **
124243
+ ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
124244
+ ** that were specified as part of the WHERE clause must be excluded.
124245
+ ** This is to address the following:
124246
+ **
124247
+ ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;
124248
+ **
124249
+ ** Say there is a single row in t2 that matches (t1.a=t2.b), but its
124250
+ ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is
124251
+ ** pushed down to the cursor, this row is filtered out, causing
124252
+ ** SQLite to synthesize a row of NULL values. Which does match the
124253
+ ** WHERE clause, and so the query returns a row. Which is incorrect.
124254
+ **
124255
+ ** For the same reason, WHERE terms such as:
124256
+ **
124257
+ ** WHERE 1 = (t2.c IS NULL)
124258
+ **
124259
+ ** are also excluded. See codeCursorHintIsOrFunction() for details.
124260
+ */
124261
+ if( pTabItem->fg.jointype & JT_LEFT ){
124262
+ Expr *pExpr = pTerm->pExpr;
124263
+ if( !ExprHasProperty(pExpr, EP_FromJoin)
124264
+ || pExpr->iRightJoinTable!=pTabItem->iCursor
124265
+ ){
124266
+ sWalker.eCode = 0;
124267
+ sWalker.xExprCallback = codeCursorHintIsOrFunction;
124268
+ sqlite3WalkExpr(&sWalker, pTerm->pExpr);
124269
+ if( sWalker.eCode ) continue;
124270
+ }
124271
+ }else{
124272
+ if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124273
+ }
123529124274
123530124275
/* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize
123531124276
** the cursor. These terms are not needed as hints for a pure range
123532124277
** scan (that has no == terms) so omit them. */
123533124278
if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
@@ -123557,11 +124302,11 @@
123557124302
(sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
123558124303
(const char*)pExpr, P4_EXPR);
123559124304
}
123560124305
}
123561124306
#else
123562
-# define codeCursorHint(A,B,C) /* No-op */
124307
+# define codeCursorHint(A,B,C,D) /* No-op */
123563124308
#endif /* SQLITE_ENABLE_CURSOR_HINTS */
123564124309
123565124310
/*
123566124311
** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
123567124312
** a rowid value just read from cursor iIdxCur, open on index pIdx. This
@@ -123591,11 +124336,11 @@
123591124336
123592124337
assert( iIdxCur>0 );
123593124338
assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
123594124339
123595124340
sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
123596
- if( (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)
124341
+ if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
123597124342
&& DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
123598124343
){
123599124344
int i;
123600124345
Table *pTab = pIdx->pTable;
123601124346
int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
@@ -123646,11 +124391,11 @@
123646124391
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
123647124392
iCur = pTabItem->iCursor;
123648124393
pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
123649124394
bRev = (pWInfo->revMask>>iLevel)&1;
123650124395
omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
123651
- && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0;
124396
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
123652124397
VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
123653124398
123654124399
/* Create labels for the "break" and "continue" instructions
123655124400
** for the current loop. Jump to addrBrk to break out of a loop.
123656124401
** Jump to cont to go immediately to the next iteration of the
@@ -123786,12 +124531,11 @@
123786124531
testcase( pTerm->wtFlags & TERM_VIRTUAL );
123787124532
iReleaseReg = ++pParse->nMem;
123788124533
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
123789124534
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
123790124535
addrNxt = pLevel->addrNxt;
123791
- sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); VdbeCoverage(v);
123792
- sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
124536
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
123793124537
VdbeCoverage(v);
123794124538
sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
123795124539
sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
123796124540
VdbeComment((v, "pk"));
123797124541
pLevel->op = OP_Noop;
@@ -123814,11 +124558,11 @@
123814124558
if( bRev ){
123815124559
pTerm = pStart;
123816124560
pStart = pEnd;
123817124561
pEnd = pTerm;
123818124562
}
123819
- codeCursorHint(pWInfo, pLevel, pEnd);
124563
+ codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
123820124564
if( pStart ){
123821124565
Expr *pX; /* The expression that defines the start bound */
123822124566
int r1, rTemp; /* Registers for holding the start boundary */
123823124567
123824124568
/* The following constant maps TK_xx codes into corresponding
@@ -124028,11 +124772,11 @@
124028124772
124029124773
/* Generate code to evaluate all constraint terms using == or IN
124030124774
** and store the values of those terms in an array of registers
124031124775
** starting at regBase.
124032124776
*/
124033
- codeCursorHint(pWInfo, pLevel, pRangeEnd);
124777
+ codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124034124778
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124035124779
assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124036124780
if( zStartAff ) cEndAff = zStartAff[nEq];
124037124781
addrNxt = pLevel->addrNxt;
124038124782
@@ -124067,10 +124811,11 @@
124067124811
zStartAff[nEq] = SQLITE_AFF_BLOB;
124068124812
}
124069124813
}
124070124814
nConstraint++;
124071124815
testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
124816
+ bSeekPastNull = 0;
124072124817
}else if( bSeekPastNull ){
124073124818
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124074124819
nConstraint++;
124075124820
startEq = 0;
124076124821
start_constraints = 1;
@@ -124332,15 +125077,11 @@
124332125077
124333125078
/* Run a separate WHERE clause for each term of the OR clause. After
124334125079
** eliminating duplicates from other WHERE clauses, the action for each
124335125080
** sub-WHERE clause is to to invoke the main loop body as a subroutine.
124336125081
*/
124337
- wctrlFlags = WHERE_OMIT_OPEN_CLOSE
124338
- | WHERE_FORCE_TABLE
124339
- | WHERE_ONETABLE_ONLY
124340
- | WHERE_NO_AUTOINDEX
124341
- | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
125082
+ wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
124342125083
for(ii=0; ii<pOrWc->nTerm; ii++){
124343125084
WhereTerm *pOrTerm = &pOrWc->a[ii];
124344125085
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
124345125086
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
124346125087
Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -124444,11 +125185,10 @@
124444125185
&& (ii==0 || pSubLoop->u.btree.pIndex==pCov)
124445125186
&& (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
124446125187
){
124447125188
assert( pSubWInfo->a[0].iIdxCur==iCovCur );
124448125189
pCov = pSubLoop->u.btree.pIndex;
124449
- wctrlFlags |= WHERE_REOPEN_IDX;
124450125190
}else{
124451125191
pCov = 0;
124452125192
}
124453125193
124454125194
/* Finish the loop through table entries that match term pOrTerm. */
@@ -124481,11 +125221,11 @@
124481125221
if( pTabItem->fg.isRecursive ){
124482125222
/* Tables marked isRecursive have only a single row that is stored in
124483125223
** a pseudo-cursor. No need to Rewind or Next such cursors. */
124484125224
pLevel->op = OP_Noop;
124485125225
}else{
124486
- codeCursorHint(pWInfo, pLevel, 0);
125226
+ codeCursorHint(pTabItem, pWInfo, pLevel, 0);
124487125227
pLevel->op = aStep[bRev];
124488125228
pLevel->p1 = iCur;
124489125229
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
124490125230
VdbeCoverageIf(v, bRev==0);
124491125231
VdbeCoverageIf(v, bRev!=0);
@@ -124506,11 +125246,11 @@
124506125246
testcase( pTerm->wtFlags & TERM_VIRTUAL );
124507125247
testcase( pTerm->wtFlags & TERM_CODED );
124508125248
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
124509125249
if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
124510125250
testcase( pWInfo->untestedTerms==0
124511
- && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
125251
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
124512125252
pWInfo->untestedTerms = 1;
124513125253
continue;
124514125254
}
124515125255
pE = pTerm->pExpr;
124516125256
assert( pE!=0 );
@@ -125168,11 +125908,13 @@
125168125908
sqlite3WhereExprAnalyze(pSrc, pAndWC);
125169125909
pAndWC->pOuter = pWC;
125170125910
if( !db->mallocFailed ){
125171125911
for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
125172125912
assert( pAndTerm->pExpr );
125173
- if( allowedOp(pAndTerm->pExpr->op) ){
125913
+ if( allowedOp(pAndTerm->pExpr->op)
125914
+ || pAndTerm->eOperator==WO_MATCH
125915
+ ){
125174125916
b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);
125175125917
}
125176125918
}
125177125919
}
125178125920
indexable &= b;
@@ -125383,16 +126125,14 @@
125383126125
return 0;
125384126126
}
125385126127
pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
125386126128
if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
125387126129
pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
125388
- /* Since pLeft and pRight are both a column references, their collating
125389
- ** sequence should always be defined. */
125390
- zColl1 = ALWAYS(pColl) ? pColl->zName : 0;
126130
+ zColl1 = pColl ? pColl->zName : 0;
125391126131
pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
125392
- zColl2 = ALWAYS(pColl) ? pColl->zName : 0;
125393
- return sqlite3StrICmp(zColl1, zColl2)==0;
126132
+ zColl2 = pColl ? pColl->zName : 0;
126133
+ return sqlite3_stricmp(zColl1, zColl2)==0;
125394126134
}
125395126135
125396126136
/*
125397126137
** Recursively walk the expressions of a SELECT statement and generate
125398126138
** a bitmask indicating which tables are used in that expression
@@ -125722,11 +126462,11 @@
125722126462
** current expression is of the form: column MATCH expr.
125723126463
** This information is used by the xBestIndex methods of
125724126464
** virtual tables. The native query optimizer does not attempt
125725126465
** to do anything with MATCH functions.
125726126466
*/
125727
- if( isMatchOfColumn(pExpr, &eOp2) ){
126467
+ if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){
125728126468
int idxNew;
125729126469
Expr *pRight, *pLeft;
125730126470
WhereTerm *pNewTerm;
125731126471
Bitmask prereqColumn, prereqExpr;
125732126472
@@ -126014,10 +126754,22 @@
126014126754
** Return FALSE if the output needs to be sorted.
126015126755
*/
126016126756
SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
126017126757
return pWInfo->nOBSat;
126018126758
}
126759
+
126760
+/*
126761
+** Return TRUE if the innermost loop of the WHERE clause implementation
126762
+** returns rows in ORDER BY order for complete run of the inner loop.
126763
+**
126764
+** Across multiple iterations of outer loops, the output rows need not be
126765
+** sorted. As long as rows are sorted for just the innermost loop, this
126766
+** routine can return TRUE.
126767
+*/
126768
+SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
126769
+ return pWInfo->bOrderedInnerLoop;
126770
+}
126019126771
126020126772
/*
126021126773
** Return the VDBE address or label to jump to in order to continue
126022126774
** immediately with the next row of a WHERE clause.
126023126775
*/
@@ -127600,20 +128352,42 @@
127600128352
static void whereTermPrint(WhereTerm *pTerm, int iTerm){
127601128353
if( pTerm==0 ){
127602128354
sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
127603128355
}else{
127604128356
char zType[4];
128357
+ char zLeft[50];
127605128358
memcpy(zType, "...", 4);
127606128359
if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
127607128360
if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
127608128361
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
128362
+ if( pTerm->eOperator & WO_SINGLE ){
128363
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
128364
+ pTerm->leftCursor, pTerm->u.leftColumn);
128365
+ }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
128366
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
128367
+ pTerm->u.pOrInfo->indexable);
128368
+ }else{
128369
+ sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128370
+ }
127609128371
sqlite3DebugPrintf(
127610
- "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n",
127611
- iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb,
128372
+ "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
128373
+ iTerm, pTerm, zType, zLeft, pTerm->truthProb,
127612128374
pTerm->eOperator, pTerm->wtFlags);
127613128375
sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
127614128376
}
128377
+}
128378
+#endif
128379
+
128380
+#ifdef WHERETRACE_ENABLED
128381
+/*
128382
+** Show the complete content of a WhereClause
128383
+*/
128384
+SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){
128385
+ int i;
128386
+ for(i=0; i<pWC->nTerm; i++){
128387
+ whereTermPrint(&pWC->a[i], i);
128388
+ }
127615128389
}
127616128390
#endif
127617128391
127618128392
#ifdef WHERETRACE_ENABLED
127619128393
/*
@@ -128599,11 +129373,11 @@
128599129373
rLogSize = estLog(rSize);
128600129374
128601129375
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
128602129376
/* Automatic indexes */
128603129377
if( !pBuilder->pOrSet /* Not part of an OR optimization */
128604
- && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
129378
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
128605129379
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
128606129380
&& pSrc->pIBIndex==0 /* Has no INDEXED BY clause */
128607129381
&& !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
128608129382
&& HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
128609129383
&& !pSrc->fg.isCorrelated /* Not a correlated subquery */
@@ -128631,10 +129405,11 @@
128631129405
pNew->rSetup = rLogSize + rSize + 4;
128632129406
if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
128633129407
pNew->rSetup += 24;
128634129408
}
128635129409
ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
129410
+ if( pNew->rSetup<0 ) pNew->rSetup = 0;
128636129411
/* TUNING: Each index lookup yields 20 rows in the table. This
128637129412
** is more than the usual guess of 10 rows, since we have no way
128638129413
** of knowing how selective the index will ultimately be. It would
128639129414
** not be unreasonable to make this value much larger. */
128640129415
pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
@@ -128691,10 +129466,11 @@
128691129466
}
128692129467
128693129468
/* Full scan via index */
128694129469
if( b
128695129470
|| !HasRowid(pTab)
129471
+ || pProbe->pPartIdxWhere!=0
128696129472
|| ( m==0
128697129473
&& pProbe->bUnordered==0
128698129474
&& (pProbe->szIdxRow<pTab->szTabRow)
128699129475
&& (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
128700129476
&& sqlite3GlobalConfig.bUseCis
@@ -128703,15 +129479,38 @@
128703129479
){
128704129480
pNew->iSortIdx = b ? iSortIdx : 0;
128705129481
128706129482
/* The cost of visiting the index rows is N*K, where K is
128707129483
** between 1.1 and 3.0, depending on the relative sizes of the
128708
- ** index and table rows. If this is a non-covering index scan,
128709
- ** also add the cost of visiting table rows (N*3.0). */
129484
+ ** index and table rows. */
128710129485
pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;
128711129486
if( m!=0 ){
128712
- pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16);
129487
+ /* If this is a non-covering index scan, add in the cost of
129488
+ ** doing table lookups. The cost will be 3x the number of
129489
+ ** lookups. Take into account WHERE clause terms that can be
129490
+ ** satisfied using just the index, and that do not require a
129491
+ ** table lookup. */
129492
+ LogEst nLookup = rSize + 16; /* Base cost: N*3 */
129493
+ int ii;
129494
+ int iCur = pSrc->iCursor;
129495
+ WhereClause *pWC2 = &pWInfo->sWC;
129496
+ for(ii=0; ii<pWC2->nTerm; ii++){
129497
+ WhereTerm *pTerm = &pWC2->a[ii];
129498
+ if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){
129499
+ break;
129500
+ }
129501
+ /* pTerm can be evaluated using just the index. So reduce
129502
+ ** the expected number of table lookups accordingly */
129503
+ if( pTerm->truthProb<=0 ){
129504
+ nLookup += pTerm->truthProb;
129505
+ }else{
129506
+ nLookup--;
129507
+ if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19;
129508
+ }
129509
+ }
129510
+
129511
+ pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup);
128713129512
}
128714129513
ApplyCostMultiplier(pNew->rRun, pTab->costMult);
128715129514
whereLoopOutputAdjust(pWC, pNew, rSize);
128716129515
rc = whereLoopInsert(pBuilder, pNew);
128717129516
pNew->nOut = rSize;
@@ -129076,13 +129875,11 @@
129076129875
sCur.n = 0;
129077129876
#ifdef WHERETRACE_ENABLED
129078129877
WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
129079129878
(int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
129080129879
if( sqlite3WhereTrace & 0x400 ){
129081
- for(i=0; i<sSubBuild.pWC->nTerm; i++){
129082
- whereTermPrint(&sSubBuild.pWC->a[i], i);
129083
- }
129880
+ sqlite3WhereClausePrint(sSubBuild.pWC);
129084129881
}
129085129882
#endif
129086129883
#ifndef SQLITE_OMIT_VIRTUALTABLE
129087129884
if( IsVirtual(pItem->pTab) ){
129088129885
rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
@@ -129171,19 +129968,22 @@
129171129968
/* This condition is true when pItem is the FROM clause term on the
129172129969
** right-hand-side of a LEFT or CROSS JOIN. */
129173129970
mPrereq = mPrior;
129174129971
}
129175129972
priorJointype = pItem->fg.jointype;
129973
+#ifndef SQLITE_OMIT_VIRTUALTABLE
129176129974
if( IsVirtual(pItem->pTab) ){
129177129975
struct SrcList_item *p;
129178129976
for(p=&pItem[1]; p<pEnd; p++){
129179129977
if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){
129180129978
mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
129181129979
}
129182129980
}
129183129981
rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
129184
- }else{
129982
+ }else
129983
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
129984
+ {
129185129985
rc = whereLoopAddBtree(pBuilder, mPrereq);
129186129986
}
129187129987
if( rc==SQLITE_OK ){
129188129988
rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
129189129989
}
@@ -129214,11 +130014,11 @@
129214130014
*/
129215130015
static i8 wherePathSatisfiesOrderBy(
129216130016
WhereInfo *pWInfo, /* The WHERE clause */
129217130017
ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
129218130018
WherePath *pPath, /* The WherePath to check */
129219
- u16 wctrlFlags, /* Might contain WHERE_GROUPBY or WHERE_DISTINCTBY */
130019
+ u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */
129220130020
u16 nLoop, /* Number of entries in pPath->aLoop[] */
129221130021
WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
129222130022
Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */
129223130023
){
129224130024
u8 revSet; /* True if rev is known */
@@ -129225,10 +130025,11 @@
129225130025
u8 rev; /* Composite sort order */
129226130026
u8 revIdx; /* Index sort order */
129227130027
u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */
129228130028
u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */
129229130029
u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
130030
+ u16 eqOpMask; /* Allowed equality operators */
129230130031
u16 nKeyCol; /* Number of key columns in pIndex */
129231130032
u16 nColumn; /* Total number of ordered columns in the index */
129232130033
u16 nOrderBy; /* Number terms in the ORDER BY clause */
129233130034
int iLoop; /* Index of WhereLoop in pPath being processed */
129234130035
int i, j; /* Loop counters */
@@ -129275,13 +130076,20 @@
129275130076
if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
129276130077
isOrderDistinct = 1;
129277130078
obDone = MASKBIT(nOrderBy)-1;
129278130079
orderDistinctMask = 0;
129279130080
ready = 0;
130081
+ eqOpMask = WO_EQ | WO_IS | WO_ISNULL;
130082
+ if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;
129280130083
for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
129281130084
if( iLoop>0 ) ready |= pLoop->maskSelf;
129282
- pLoop = iLoop<nLoop ? pPath->aLoop[iLoop] : pLast;
130085
+ if( iLoop<nLoop ){
130086
+ pLoop = pPath->aLoop[iLoop];
130087
+ if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
130088
+ }else{
130089
+ pLoop = pLast;
130090
+ }
129283130091
if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
129284130092
if( pLoop->u.vtab.isOrdered ) obSat = obDone;
129285130093
break;
129286130094
}
129287130095
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -129295,11 +130103,11 @@
129295130103
if( MASKBIT(i) & obSat ) continue;
129296130104
pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
129297130105
if( pOBExpr->op!=TK_COLUMN ) continue;
129298130106
if( pOBExpr->iTable!=iCur ) continue;
129299130107
pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
129300
- ~ready, WO_EQ|WO_ISNULL|WO_IS, 0);
130108
+ ~ready, eqOpMask, 0);
129301130109
if( pTerm==0 ) continue;
129302130110
if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
129303130111
const char *z1, *z2;
129304130112
pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
129305130113
if( !pColl ) pColl = db->pDfltColl;
@@ -129335,14 +130143,16 @@
129335130143
rev = revSet = 0;
129336130144
distinctColumns = 0;
129337130145
for(j=0; j<nColumn; j++){
129338130146
u8 bOnce; /* True to run the ORDER BY search loop */
129339130147
129340
- /* Skip over == and IS NULL terms */
130148
+ /* Skip over == and IS and ISNULL terms.
130149
+ ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
130150
+ */
129341130151
if( j<pLoop->u.btree.nEq
129342130152
&& pLoop->nSkip==0
129343
- && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0
130153
+ && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
129344130154
){
129345130155
if( i & WO_ISNULL ){
129346130156
testcase( isOrderDistinct );
129347130157
isOrderDistinct = 0;
129348130158
}
@@ -129862,12 +130672,23 @@
129862130672
if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
129863130673
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
129864130674
}
129865130675
}else{
129866130676
pWInfo->nOBSat = pFrom->isOrdered;
129867
- if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
129868130677
pWInfo->revMask = pFrom->revLoop;
130678
+ if( pWInfo->nOBSat<=0 ){
130679
+ pWInfo->nOBSat = 0;
130680
+ if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){
130681
+ Bitmask m = 0;
130682
+ int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
130683
+ WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
130684
+ if( rc==pWInfo->pOrderBy->nExpr ){
130685
+ pWInfo->bOrderedInnerLoop = 1;
130686
+ pWInfo->revMask = m;
130687
+ }
130688
+ }
130689
+ }
129869130690
}
129870130691
if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
129871130692
&& pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
129872130693
){
129873130694
Bitmask revMask = 0;
@@ -129911,11 +130732,11 @@
129911130732
int j;
129912130733
Table *pTab;
129913130734
Index *pIdx;
129914130735
129915130736
pWInfo = pBuilder->pWInfo;
129916
- if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0;
130737
+ if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
129917130738
assert( pWInfo->pTabList->nSrc>=1 );
129918130739
pItem = pWInfo->pTabList->a;
129919130740
pTab = pItem->pTab;
129920130741
if( IsVirtual(pTab) ) return 0;
129921130742
if( pItem->fg.isIndexedBy ) return 0;
@@ -130058,11 +130879,11 @@
130058130879
** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
130059130880
** if there is one. If there is no ORDER BY clause or if this routine
130060130881
** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
130061130882
**
130062130883
** The iIdxCur parameter is the cursor number of an index. If
130063
-** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index
130884
+** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
130064130885
** to use for OR clause processing. The WHERE clause should use this
130065130886
** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
130066130887
** the first cursor in an array of cursors for all indices. iIdxCur should
130067130888
** be used to compute the appropriate cursor depending on which index is
130068130889
** used.
@@ -130072,11 +130893,11 @@
130072130893
SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
130073130894
Expr *pWhere, /* The WHERE clause */
130074130895
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
130075130896
ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
130076130897
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
130077
- int iAuxArg /* If WHERE_ONETABLE_ONLY is set, index cursor number
130898
+ int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
130078130899
** If WHERE_USE_LIMIT, then the limit amount */
130079130900
){
130080130901
int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
130081130902
int nTabList; /* Number of elements in pTabList */
130082130903
WhereInfo *pWInfo; /* Will become the return value of this function */
@@ -130091,15 +130912,15 @@
130091130912
int rc; /* Return code */
130092130913
u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */
130093130914
130094130915
assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (
130095130916
(wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
130096
- && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
130917
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130097130918
));
130098130919
130099
- /* Only one of WHERE_ONETABLE_ONLY or WHERE_USE_LIMIT */
130100
- assert( (wctrlFlags & WHERE_ONETABLE_ONLY)==0
130920
+ /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */
130921
+ assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130101130922
|| (wctrlFlags & WHERE_USE_LIMIT)==0 );
130102130923
130103130924
/* Variable initialization */
130104130925
db = pParse->db;
130105130926
memset(&sWLB, 0, sizeof(sWLB));
@@ -130123,15 +130944,15 @@
130123130944
sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
130124130945
return 0;
130125130946
}
130126130947
130127130948
/* This function normally generates a nested loop for all tables in
130128
- ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should
130949
+ ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should
130129130950
** only generate code for the first table in pTabList and assume that
130130130951
** any cursors associated with subsequent tables are uninitialized.
130131130952
*/
130132
- nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
130953
+ nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;
130133130954
130134130955
/* Allocate and initialize the WhereInfo structure that will become the
130135130956
** return value. A single allocation is used to store the WhereInfo
130136130957
** struct, the contents of WhereInfo.a[], the WhereClause structure
130137130958
** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
@@ -130203,11 +131024,11 @@
130203131024
** important. Ticket #3015.
130204131025
**
130205131026
** Note that bitmasks are created for all pTabList->nSrc tables in
130206131027
** pTabList, not just the first nTabList tables. nTabList is normally
130207131028
** equal to pTabList->nSrc but might be shortened to 1 if the
130208
- ** WHERE_ONETABLE_ONLY flag is set.
131029
+ ** WHERE_OR_SUBCLAUSE flag is set.
130209131030
*/
130210131031
for(ii=0; ii<pTabList->nSrc; ii++){
130211131032
createMask(pMaskSet, pTabList->a[ii].iCursor);
130212131033
sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
130213131034
}
@@ -130241,14 +131062,11 @@
130241131062
sqlite3DebugPrintf(", limit: %d", iAuxArg);
130242131063
}
130243131064
sqlite3DebugPrintf(")\n");
130244131065
}
130245131066
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
130246
- int i;
130247
- for(i=0; i<sWLB.pWC->nTerm; i++){
130248
- whereTermPrint(&sWLB.pWC->a[i], i);
130249
- }
131067
+ sqlite3WhereClausePrint(sWLB.pWC);
130250131068
}
130251131069
#endif
130252131070
130253131071
if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
130254131072
rc = whereLoopAddAll(&sWLB);
@@ -130386,11 +131204,11 @@
130386131204
}else if( IsVirtual(pTab) ){
130387131205
/* noop */
130388131206
}else
130389131207
#endif
130390131208
if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
130391
- && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){
131209
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
130392131210
int op = OP_OpenRead;
130393131211
if( pWInfo->eOnePass!=ONEPASS_OFF ){
130394131212
op = OP_OpenWrite;
130395131213
pWInfo->aiCurOnePass[0] = pTabItem->iCursor;
130396131214
};
@@ -130425,11 +131243,11 @@
130425131243
int iIndexCur;
130426131244
int op = OP_OpenRead;
130427131245
/* iAuxArg is always set if to a positive value if ONEPASS is possible */
130428131246
assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );
130429131247
if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)
130430
- && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0
131248
+ && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0
130431131249
){
130432131250
/* This is one term of an OR-optimization using the PRIMARY KEY of a
130433131251
** WITHOUT ROWID table. No need for a separate index */
130434131252
iIndexCur = pLevel->iTabCur;
130435131253
op = 0;
@@ -130441,13 +131259,13 @@
130441131259
iIndexCur++;
130442131260
pJ = pJ->pNext;
130443131261
}
130444131262
op = OP_OpenWrite;
130445131263
pWInfo->aiCurOnePass[1] = iIndexCur;
130446
- }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){
131264
+ }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){
130447131265
iIndexCur = iAuxArg;
130448
- if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx;
131266
+ op = OP_ReopenIdx;
130449131267
}else{
130450131268
iIndexCur = pParse->nTab++;
130451131269
}
130452131270
pLevel->iIdxCur = iIndexCur;
130453131271
assert( pIx->pSchema==pTab->pSchema );
@@ -130505,11 +131323,11 @@
130505131323
pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
130506131324
);
130507131325
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
130508131326
notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
130509131327
pWInfo->iContinue = pLevel->addrCont;
130510
- if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){
131328
+ if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
130511131329
sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
130512131330
}
130513131331
}
130514131332
130515131333
/* Done. */
@@ -130628,16 +131446,16 @@
130628131446
continue;
130629131447
}
130630131448
130631131449
/* Close all of the cursors that were opened by sqlite3WhereBegin.
130632131450
** Except, do not close cursors that will be reused by the OR optimization
130633
- ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors
131451
+ ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
130634131452
** created for the ONEPASS optimization.
130635131453
*/
130636131454
if( (pTab->tabFlags & TF_Ephemeral)==0
130637131455
&& pTab->pSelect==0
130638
- && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
131456
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130639131457
){
130640131458
int ws = pLoop->wsFlags;
130641131459
if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
130642131460
sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
130643131461
}
@@ -130980,49 +131798,49 @@
130980131798
#ifndef INTERFACE
130981131799
# define INTERFACE 1
130982131800
#endif
130983131801
/************* Begin control #defines *****************************************/
130984131802
#define YYCODETYPE unsigned char
130985
-#define YYNOCODE 251
131803
+#define YYNOCODE 252
130986131804
#define YYACTIONTYPE unsigned short int
130987131805
#define YYWILDCARD 96
130988131806
#define sqlite3ParserTOKENTYPE Token
130989131807
typedef union {
130990131808
int yyinit;
130991131809
sqlite3ParserTOKENTYPE yy0;
130992
- struct LimitVal yy64;
130993
- Expr* yy122;
130994
- Select* yy159;
130995
- IdList* yy180;
130996
- struct {int value; int mask;} yy207;
130997
- struct LikeOp yy318;
130998
- TriggerStep* yy327;
130999
- With* yy331;
131000
- ExprSpan yy342;
131001
- SrcList* yy347;
131002
- int yy392;
131003
- struct TrigEvent yy410;
131004
- ExprList* yy442;
131810
+ Expr* yy72;
131811
+ TriggerStep* yy145;
131812
+ ExprList* yy148;
131813
+ SrcList* yy185;
131814
+ ExprSpan yy190;
131815
+ int yy194;
131816
+ Select* yy243;
131817
+ IdList* yy254;
131818
+ With* yy285;
131819
+ struct TrigEvent yy332;
131820
+ struct LimitVal yy354;
131821
+ struct LikeOp yy392;
131822
+ struct {int value; int mask;} yy497;
131005131823
} YYMINORTYPE;
131006131824
#ifndef YYSTACKDEPTH
131007131825
#define YYSTACKDEPTH 100
131008131826
#endif
131009131827
#define sqlite3ParserARG_SDECL Parse *pParse;
131010131828
#define sqlite3ParserARG_PDECL ,Parse *pParse
131011131829
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131012131830
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
131013131831
#define YYFALLBACK 1
131014
-#define YYNSTATE 440
131015
-#define YYNRULE 326
131016
-#define YY_MAX_SHIFT 439
131017
-#define YY_MIN_SHIFTREDUCE 649
131018
-#define YY_MAX_SHIFTREDUCE 974
131019
-#define YY_MIN_REDUCE 975
131020
-#define YY_MAX_REDUCE 1300
131021
-#define YY_ERROR_ACTION 1301
131022
-#define YY_ACCEPT_ACTION 1302
131023
-#define YY_NO_ACTION 1303
131832
+#define YYNSTATE 443
131833
+#define YYNRULE 328
131834
+#define YY_MAX_SHIFT 442
131835
+#define YY_MIN_SHIFTREDUCE 653
131836
+#define YY_MAX_SHIFTREDUCE 980
131837
+#define YY_MIN_REDUCE 981
131838
+#define YY_MAX_REDUCE 1308
131839
+#define YY_ERROR_ACTION 1309
131840
+#define YY_ACCEPT_ACTION 1310
131841
+#define YY_NO_ACTION 1311
131024131842
/************* End control #defines *******************************************/
131025131843
131026131844
/* Define the yytestcase() macro to be a no-op if is not already defined
131027131845
** otherwise.
131028131846
**
@@ -131086,450 +131904,452 @@
131086131904
** yy_reduce_ofst[] For each state, the offset into yy_action for
131087131905
** shifting non-terminals after a reduce.
131088131906
** yy_default[] Default action for each state.
131089131907
**
131090131908
*********** Begin parsing tables **********************************************/
131091
-#define YY_ACTTAB_COUNT (1501)
131909
+#define YY_ACTTAB_COUNT (1507)
131092131910
static const YYACTIONTYPE yy_action[] = {
131093
- /* 0 */ 315, 810, 339, 804, 5, 194, 194, 798, 92, 93,
131094
- /* 10 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131095
- /* 20 */ 91, 91, 91, 290, 89, 89, 89, 89, 88, 88,
131096
- /* 30 */ 87, 87, 87, 86, 339, 315, 952, 952, 803, 803,
131097
- /* 40 */ 803, 922, 342, 92, 93, 83, 819, 819, 831, 834,
131098
- /* 50 */ 823, 823, 90, 90, 91, 91, 91, 91, 123, 89,
131099
- /* 60 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131100
- /* 70 */ 88, 88, 87, 87, 87, 86, 339, 772, 952, 952,
131101
- /* 80 */ 315, 87, 87, 87, 86, 339, 773, 68, 92, 93,
131102
- /* 90 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91,
131103
- /* 100 */ 91, 91, 91, 434, 89, 89, 89, 89, 88, 88,
131104
- /* 110 */ 87, 87, 87, 86, 339, 1302, 146, 921, 2, 315,
131105
- /* 120 */ 427, 24, 679, 953, 48, 86, 339, 92, 93, 83,
131106
- /* 130 */ 819, 819, 831, 834, 823, 823, 90, 90, 91, 91,
131107
- /* 140 */ 91, 91, 94, 89, 89, 89, 89, 88, 88, 87,
131108
- /* 150 */ 87, 87, 86, 339, 933, 933, 315, 259, 412, 398,
131109
- /* 160 */ 396, 57, 733, 733, 92, 93, 83, 819, 819, 831,
131110
- /* 170 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 56,
131111
- /* 180 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131112
- /* 190 */ 339, 315, 1245, 922, 342, 268, 934, 935, 241, 92,
131113
- /* 200 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131114
- /* 210 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131115
- /* 220 */ 88, 87, 87, 87, 86, 339, 315, 913, 1295, 682,
131116
- /* 230 */ 687, 1295, 233, 397, 92, 93, 83, 819, 819, 831,
131117
- /* 240 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 326,
131118
- /* 250 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131119
- /* 260 */ 339, 315, 85, 82, 168, 680, 431, 938, 939, 92,
131120
- /* 270 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131121
- /* 280 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88,
131122
- /* 290 */ 88, 87, 87, 87, 86, 339, 315, 319, 913, 1296,
131123
- /* 300 */ 797, 911, 1296, 681, 92, 93, 83, 819, 819, 831,
131124
- /* 310 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 335,
131125
- /* 320 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131126
- /* 330 */ 339, 315, 876, 876, 373, 85, 82, 168, 944, 92,
131127
- /* 340 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131128
- /* 350 */ 91, 91, 91, 91, 896, 89, 89, 89, 89, 88,
131129
- /* 360 */ 88, 87, 87, 87, 86, 339, 315, 370, 307, 973,
131130
- /* 370 */ 367, 1, 911, 433, 92, 93, 83, 819, 819, 831,
131131
- /* 380 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 189,
131132
- /* 390 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86,
131133
- /* 400 */ 339, 315, 720, 948, 933, 933, 149, 718, 948, 92,
131134
- /* 410 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90,
131135
- /* 420 */ 91, 91, 91, 91, 434, 89, 89, 89, 89, 88,
131136
- /* 430 */ 88, 87, 87, 87, 86, 339, 338, 938, 939, 947,
131137
- /* 440 */ 694, 940, 974, 315, 953, 48, 934, 935, 715, 689,
131138
- /* 450 */ 71, 92, 93, 83, 819, 819, 831, 834, 823, 823,
131139
- /* 460 */ 90, 90, 91, 91, 91, 91, 320, 89, 89, 89,
131140
- /* 470 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 412,
131141
- /* 480 */ 403, 820, 820, 832, 835, 74, 92, 81, 83, 819,
131142
- /* 490 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131143
- /* 500 */ 91, 698, 89, 89, 89, 89, 88, 88, 87, 87,
131144
- /* 510 */ 87, 86, 339, 315, 259, 654, 655, 656, 393, 111,
131145
- /* 520 */ 331, 153, 93, 83, 819, 819, 831, 834, 823, 823,
131146
- /* 530 */ 90, 90, 91, 91, 91, 91, 434, 89, 89, 89,
131147
- /* 540 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 188,
131148
- /* 550 */ 187, 186, 824, 937, 328, 219, 953, 48, 83, 819,
131149
- /* 560 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91,
131150
- /* 570 */ 91, 956, 89, 89, 89, 89, 88, 88, 87, 87,
131151
- /* 580 */ 87, 86, 339, 79, 429, 738, 3, 1174, 955, 348,
131152
- /* 590 */ 737, 332, 792, 933, 933, 937, 79, 429, 730, 3,
131153
- /* 600 */ 203, 160, 278, 391, 273, 390, 190, 892, 434, 400,
131154
- /* 610 */ 741, 76, 77, 271, 287, 253, 353, 242, 78, 340,
131155
- /* 620 */ 340, 85, 82, 168, 76, 77, 233, 397, 953, 48,
131156
- /* 630 */ 432, 78, 340, 340, 277, 934, 935, 185, 439, 651,
131157
- /* 640 */ 388, 385, 384, 432, 234, 276, 107, 418, 349, 337,
131158
- /* 650 */ 336, 383, 893, 728, 215, 949, 123, 971, 308, 810,
131159
- /* 660 */ 418, 436, 435, 412, 394, 798, 400, 873, 894, 123,
131160
- /* 670 */ 721, 872, 810, 889, 436, 435, 215, 949, 798, 351,
131161
- /* 680 */ 722, 697, 380, 434, 771, 371, 22, 434, 400, 79,
131162
- /* 690 */ 429, 232, 3, 189, 413, 870, 803, 803, 803, 805,
131163
- /* 700 */ 18, 54, 148, 953, 48, 956, 113, 953, 9, 803,
131164
- /* 710 */ 803, 803, 805, 18, 310, 123, 748, 76, 77, 742,
131165
- /* 720 */ 123, 325, 955, 866, 78, 340, 340, 113, 350, 359,
131166
- /* 730 */ 85, 82, 168, 343, 960, 960, 432, 770, 412, 414,
131167
- /* 740 */ 407, 23, 1240, 1240, 79, 429, 357, 3, 166, 91,
131168
- /* 750 */ 91, 91, 91, 418, 89, 89, 89, 89, 88, 88,
131169
- /* 760 */ 87, 87, 87, 86, 339, 810, 434, 436, 435, 792,
131170
- /* 770 */ 320, 798, 76, 77, 789, 271, 123, 434, 360, 78,
131171
- /* 780 */ 340, 340, 864, 85, 82, 168, 953, 9, 395, 743,
131172
- /* 790 */ 360, 432, 253, 358, 252, 933, 933, 953, 30, 889,
131173
- /* 800 */ 327, 216, 803, 803, 803, 805, 18, 113, 418, 89,
131174
- /* 810 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339,
131175
- /* 820 */ 810, 113, 436, 435, 792, 185, 798, 288, 388, 385,
131176
- /* 830 */ 384, 123, 113, 920, 2, 796, 696, 934, 935, 383,
131177
- /* 840 */ 69, 429, 434, 3, 218, 110, 738, 253, 358, 252,
131178
- /* 850 */ 434, 737, 933, 933, 892, 359, 222, 803, 803, 803,
131179
- /* 860 */ 805, 18, 953, 47, 933, 933, 933, 933, 76, 77,
131180
- /* 870 */ 953, 9, 366, 904, 217, 78, 340, 340, 677, 305,
131181
- /* 880 */ 304, 303, 206, 301, 224, 259, 664, 432, 337, 336,
131182
- /* 890 */ 434, 228, 247, 144, 934, 935, 933, 933, 667, 893,
131183
- /* 900 */ 324, 1259, 96, 434, 418, 796, 934, 935, 934, 935,
131184
- /* 910 */ 953, 48, 401, 148, 289, 894, 810, 417, 436, 435,
131185
- /* 920 */ 677, 759, 798, 953, 9, 314, 220, 162, 161, 170,
131186
- /* 930 */ 402, 239, 953, 8, 194, 683, 683, 410, 934, 935,
131187
- /* 940 */ 238, 959, 933, 933, 225, 408, 945, 365, 957, 212,
131188
- /* 950 */ 958, 172, 757, 803, 803, 803, 805, 18, 173, 365,
131189
- /* 960 */ 176, 123, 171, 113, 244, 952, 246, 434, 356, 796,
131190
- /* 970 */ 372, 365, 236, 960, 960, 810, 290, 804, 191, 165,
131191
- /* 980 */ 852, 798, 259, 316, 934, 935, 237, 953, 34, 404,
131192
- /* 990 */ 91, 91, 91, 91, 84, 89, 89, 89, 89, 88,
131193
- /* 1000 */ 88, 87, 87, 87, 86, 339, 701, 952, 434, 240,
131194
- /* 1010 */ 347, 758, 803, 803, 803, 434, 245, 1179, 434, 389,
131195
- /* 1020 */ 434, 376, 434, 895, 167, 434, 405, 702, 953, 35,
131196
- /* 1030 */ 673, 321, 221, 434, 333, 953, 11, 434, 953, 26,
131197
- /* 1040 */ 953, 36, 953, 37, 251, 953, 38, 434, 259, 434,
131198
- /* 1050 */ 757, 434, 329, 953, 27, 434, 223, 953, 28, 434,
131199
- /* 1060 */ 690, 434, 67, 434, 65, 434, 862, 953, 39, 953,
131200
- /* 1070 */ 40, 953, 41, 423, 434, 953, 10, 434, 772, 953,
131201
- /* 1080 */ 42, 953, 98, 953, 43, 953, 44, 773, 434, 346,
131202
- /* 1090 */ 434, 75, 434, 73, 953, 31, 434, 953, 45, 434,
131203
- /* 1100 */ 259, 434, 690, 434, 757, 434, 887, 434, 953, 46,
131204
- /* 1110 */ 953, 32, 953, 115, 434, 266, 953, 116, 951, 953,
131205
- /* 1120 */ 117, 953, 52, 953, 33, 953, 99, 953, 49, 726,
131206
- /* 1130 */ 434, 909, 434, 19, 953, 100, 434, 344, 434, 113,
131207
- /* 1140 */ 434, 258, 692, 434, 259, 434, 670, 434, 20, 434,
131208
- /* 1150 */ 953, 101, 953, 97, 434, 259, 953, 114, 953, 112,
131209
- /* 1160 */ 953, 105, 113, 953, 104, 953, 102, 953, 103, 953,
131210
- /* 1170 */ 51, 434, 148, 434, 953, 53, 167, 434, 259, 113,
131211
- /* 1180 */ 300, 307, 912, 363, 311, 860, 248, 261, 209, 264,
131212
- /* 1190 */ 416, 953, 50, 953, 25, 420, 727, 953, 29, 430,
131213
- /* 1200 */ 321, 424, 757, 428, 322, 124, 1269, 214, 165, 710,
131214
- /* 1210 */ 859, 908, 806, 794, 309, 158, 193, 361, 254, 723,
131215
- /* 1220 */ 364, 67, 381, 269, 735, 199, 67, 70, 113, 700,
131216
- /* 1230 */ 699, 707, 708, 884, 113, 766, 113, 855, 193, 883,
131217
- /* 1240 */ 199, 869, 869, 675, 868, 868, 109, 368, 255, 260,
131218
- /* 1250 */ 263, 280, 859, 265, 806, 974, 267, 711, 695, 272,
131219
- /* 1260 */ 764, 282, 795, 284, 150, 744, 755, 415, 292, 293,
131220
- /* 1270 */ 802, 678, 672, 661, 660, 662, 927, 6, 306, 386,
131221
- /* 1280 */ 352, 786, 243, 250, 886, 362, 163, 286, 419, 298,
131222
- /* 1290 */ 930, 159, 968, 196, 126, 903, 901, 965, 55, 58,
131223
- /* 1300 */ 323, 275, 857, 136, 147, 694, 856, 121, 65, 354,
131224
- /* 1310 */ 355, 379, 175, 61, 151, 369, 180, 871, 375, 129,
131225
- /* 1320 */ 257, 756, 210, 181, 145, 131, 132, 377, 262, 663,
131226
- /* 1330 */ 133, 134, 139, 783, 791, 182, 392, 183, 312, 330,
131227
- /* 1340 */ 714, 888, 713, 851, 692, 195, 712, 406, 686, 705,
131228
- /* 1350 */ 313, 685, 64, 839, 274, 72, 684, 334, 942, 95,
131229
- /* 1360 */ 752, 279, 281, 704, 753, 751, 422, 283, 411, 750,
131230
- /* 1370 */ 426, 66, 204, 409, 21, 285, 928, 669, 437, 205,
131231
- /* 1380 */ 207, 208, 438, 658, 657, 652, 118, 108, 119, 226,
131232
- /* 1390 */ 650, 341, 157, 235, 169, 345, 106, 734, 790, 296,
131233
- /* 1400 */ 294, 295, 120, 297, 867, 865, 127, 128, 130, 724,
131234
- /* 1410 */ 229, 174, 249, 882, 137, 230, 138, 135, 885, 231,
131235
- /* 1420 */ 59, 60, 177, 881, 7, 178, 12, 179, 256, 874,
131236
- /* 1430 */ 140, 193, 962, 374, 141, 152, 666, 378, 276, 184,
131237
- /* 1440 */ 270, 122, 142, 382, 387, 62, 13, 14, 703, 63,
131238
- /* 1450 */ 125, 317, 318, 227, 809, 808, 837, 732, 15, 164,
131239
- /* 1460 */ 736, 4, 765, 211, 399, 213, 192, 143, 760, 70,
131240
- /* 1470 */ 67, 16, 17, 838, 836, 891, 841, 890, 198, 197,
131241
- /* 1480 */ 917, 154, 421, 923, 918, 155, 200, 977, 425, 840,
131242
- /* 1490 */ 156, 201, 807, 676, 80, 302, 299, 977, 202, 1261,
131243
- /* 1500 */ 1260,
131911
+ /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131912
+ /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131913
+ /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131914
+ /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131915
+ /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131916
+ /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131917
+ /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131918
+ /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131919
+ /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131920
+ /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131921
+ /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131922
+ /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131923
+ /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131924
+ /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131925
+ /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131926
+ /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131927
+ /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131928
+ /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131929
+ /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131930
+ /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131931
+ /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131932
+ /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131933
+ /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131934
+ /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131935
+ /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131936
+ /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131937
+ /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131938
+ /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131939
+ /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131940
+ /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131941
+ /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131942
+ /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131943
+ /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131944
+ /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131945
+ /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131946
+ /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131947
+ /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131948
+ /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131949
+ /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131950
+ /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131951
+ /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131952
+ /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131953
+ /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131954
+ /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131955
+ /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131956
+ /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131957
+ /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131958
+ /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131959
+ /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131960
+ /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131961
+ /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131962
+ /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131963
+ /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131964
+ /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131965
+ /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131966
+ /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131967
+ /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131968
+ /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131969
+ /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131970
+ /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131971
+ /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131972
+ /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131973
+ /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131974
+ /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131975
+ /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131976
+ /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131977
+ /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131978
+ /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131979
+ /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
131980
+ /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
131981
+ /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
131982
+ /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
131983
+ /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
131984
+ /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
131985
+ /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
131986
+ /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
131987
+ /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
131988
+ /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
131989
+ /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
131990
+ /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
131991
+ /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
131992
+ /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131993
+ /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
131994
+ /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
131995
+ /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
131996
+ /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
131997
+ /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
131998
+ /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
131999
+ /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
132000
+ /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
132001
+ /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
132002
+ /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
132003
+ /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
132004
+ /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
132005
+ /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
132006
+ /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
132007
+ /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
132008
+ /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
132009
+ /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
132010
+ /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
132011
+ /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
132012
+ /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
132013
+ /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
132014
+ /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
132015
+ /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
132016
+ /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
132017
+ /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
132018
+ /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
132019
+ /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
132020
+ /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
132021
+ /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
132022
+ /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
132023
+ /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
132024
+ /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
132025
+ /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
132026
+ /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
132027
+ /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
132028
+ /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
132029
+ /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
132030
+ /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
132031
+ /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
132032
+ /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
132033
+ /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
132034
+ /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
132035
+ /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
132036
+ /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
132037
+ /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
132038
+ /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
132039
+ /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
132040
+ /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
132041
+ /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
132042
+ /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
132043
+ /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
132044
+ /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
132045
+ /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
132046
+ /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
132047
+ /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
132048
+ /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
132049
+ /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
132050
+ /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
132051
+ /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
132052
+ /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
132053
+ /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
132054
+ /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
132055
+ /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
132056
+ /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
132057
+ /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
132058
+ /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
132059
+ /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
132060
+ /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
132061
+ /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
131244132062
};
131245132063
static const YYCODETYPE yy_lookahead[] = {
131246132064
/* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
131247132065
/* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131248132066
/* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131249132067
/* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
131250132068
/* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
131251
- /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 92, 43,
132069
+ /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43,
131252132070
/* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131253132071
/* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
131254132072
/* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
131255132073
/* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
131256132074
/* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
131257132075
/* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
131258
- /* 120 */ 249, 22, 172, 172, 173, 52, 53, 27, 28, 29,
132076
+ /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
131259132077
/* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
131260132078
/* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
131261132079
/* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
131262132080
/* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
131263132081
/* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
131264132082
/* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131265132083
/* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
131266132084
/* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131267132085
/* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131268
- /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172,
131269
- /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32,
132086
+ /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
132087
+ /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
131270132088
/* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
131271132089
/* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131272
- /* 260 */ 53, 19, 221, 222, 223, 23, 168, 169, 170, 27,
132090
+ /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
131273132091
/* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131274
- /* 280 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131275
- /* 290 */ 48, 49, 50, 51, 52, 53, 19, 157, 22, 23,
131276
- /* 300 */ 23, 96, 26, 172, 27, 28, 29, 30, 31, 32,
131277
- /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
132092
+ /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
132093
+ /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
132094
+ /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
132095
+ /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
131278132096
/* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131279
- /* 330 */ 53, 19, 108, 109, 110, 221, 222, 223, 185, 27,
132097
+ /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
131280132098
/* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131281
- /* 350 */ 38, 39, 40, 41, 240, 43, 44, 45, 46, 47,
131282
- /* 360 */ 48, 49, 50, 51, 52, 53, 19, 227, 22, 23,
131283
- /* 370 */ 230, 22, 96, 152, 27, 28, 29, 30, 31, 32,
132099
+ /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
132100
+ /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
132101
+ /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
131284132102
/* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
131285132103
/* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
131286
- /* 400 */ 53, 19, 190, 191, 55, 56, 24, 190, 191, 27,
132104
+ /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
131287132105
/* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
131288132106
/* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
131289
- /* 430 */ 48, 49, 50, 51, 52, 53, 168, 169, 170, 179,
131290
- /* 440 */ 180, 171, 96, 19, 172, 173, 97, 98, 188, 179,
132107
+ /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
132108
+ /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
131291132109
/* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
131292132110
/* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
131293132111
/* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
131294132112
/* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
131295132113
/* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131296
- /* 500 */ 41, 181, 43, 44, 45, 46, 47, 48, 49, 50,
131297
- /* 510 */ 51, 52, 53, 19, 152, 7, 8, 9, 49, 22,
131298
- /* 520 */ 19, 24, 28, 29, 30, 31, 32, 33, 34, 35,
132114
+ /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
132115
+ /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
132116
+ /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
131299132117
/* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
131300132118
/* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
131301
- /* 550 */ 109, 110, 101, 55, 53, 193, 172, 173, 29, 30,
132119
+ /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
131302132120
/* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
131303132121
/* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
131304132122
/* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
131305
- /* 590 */ 121, 207, 85, 55, 56, 97, 19, 20, 195, 22,
131306
- /* 600 */ 99, 100, 101, 102, 103, 104, 105, 12, 152, 206,
132123
+ /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
132124
+ /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
131307132125
/* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
131308132126
/* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
131309
- /* 630 */ 66, 54, 55, 56, 101, 97, 98, 99, 148, 149,
131310
- /* 640 */ 102, 103, 104, 66, 154, 112, 156, 83, 229, 47,
131311
- /* 650 */ 48, 113, 57, 163, 194, 195, 92, 246, 247, 95,
131312
- /* 660 */ 83, 97, 98, 207, 208, 101, 206, 59, 73, 92,
131313
- /* 670 */ 75, 63, 95, 163, 97, 98, 194, 195, 101, 219,
131314
- /* 680 */ 85, 181, 19, 152, 175, 77, 196, 152, 206, 19,
131315
- /* 690 */ 20, 199, 22, 30, 163, 11, 132, 133, 134, 135,
131316
- /* 700 */ 136, 209, 152, 172, 173, 152, 196, 172, 173, 132,
131317
- /* 710 */ 133, 134, 135, 136, 164, 92, 213, 47, 48, 49,
131318
- /* 720 */ 92, 186, 169, 170, 54, 55, 56, 196, 100, 219,
131319
- /* 730 */ 221, 222, 223, 243, 132, 133, 66, 175, 207, 208,
131320
- /* 740 */ 152, 231, 119, 120, 19, 20, 236, 22, 152, 38,
132127
+ /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
132128
+ /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
132129
+ /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
132130
+ /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
132131
+ /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
132132
+ /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
132133
+ /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
132134
+ /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
132135
+ /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
132136
+ /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
132137
+ /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
132138
+ /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
131321132139
/* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
131322
- /* 760 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 85,
131323
- /* 770 */ 107, 101, 47, 48, 163, 112, 92, 152, 152, 54,
131324
- /* 780 */ 55, 56, 229, 221, 222, 223, 172, 173, 163, 49,
131325
- /* 790 */ 152, 66, 108, 109, 110, 55, 56, 172, 173, 163,
131326
- /* 800 */ 186, 22, 132, 133, 134, 135, 136, 196, 83, 43,
132140
+ /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
132141
+ /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
132142
+ /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
132143
+ /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
132144
+ /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
131327132145
/* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
131328
- /* 820 */ 95, 196, 97, 98, 85, 99, 101, 152, 102, 103,
131329
- /* 830 */ 104, 92, 196, 146, 147, 152, 181, 97, 98, 113,
131330
- /* 840 */ 19, 20, 152, 22, 218, 22, 116, 108, 109, 110,
131331
- /* 850 */ 152, 121, 55, 56, 12, 219, 218, 132, 133, 134,
131332
- /* 860 */ 135, 136, 172, 173, 55, 56, 55, 56, 47, 48,
131333
- /* 870 */ 172, 173, 236, 152, 5, 54, 55, 56, 55, 10,
131334
- /* 880 */ 11, 12, 13, 14, 186, 152, 17, 66, 47, 48,
131335
- /* 890 */ 152, 210, 16, 84, 97, 98, 55, 56, 21, 57,
131336
- /* 900 */ 217, 122, 22, 152, 83, 152, 97, 98, 97, 98,
131337
- /* 910 */ 172, 173, 152, 152, 224, 73, 95, 75, 97, 98,
131338
- /* 920 */ 97, 124, 101, 172, 173, 164, 193, 47, 48, 60,
131339
- /* 930 */ 163, 62, 172, 173, 24, 55, 56, 186, 97, 98,
131340
- /* 940 */ 71, 100, 55, 56, 183, 207, 185, 152, 107, 23,
131341
- /* 950 */ 109, 82, 26, 132, 133, 134, 135, 136, 89, 152,
131342
- /* 960 */ 26, 92, 93, 196, 88, 55, 90, 152, 91, 152,
131343
- /* 970 */ 217, 152, 152, 132, 133, 95, 152, 97, 211, 212,
131344
- /* 980 */ 103, 101, 152, 114, 97, 98, 152, 172, 173, 19,
132146
+ /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
132147
+ /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
132148
+ /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
132149
+ /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
132150
+ /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
132151
+ /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
132152
+ /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
132153
+ /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
132154
+ /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
132155
+ /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
132156
+ /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
132157
+ /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
132158
+ /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
132159
+ /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
132160
+ /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
132161
+ /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
132162
+ /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
131345132163
/* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
131346
- /* 1000 */ 48, 49, 50, 51, 52, 53, 65, 97, 152, 152,
131347
- /* 1010 */ 141, 124, 132, 133, 134, 152, 140, 140, 152, 78,
131348
- /* 1020 */ 152, 233, 152, 193, 98, 152, 56, 86, 172, 173,
131349
- /* 1030 */ 166, 167, 237, 152, 217, 172, 173, 152, 172, 173,
131350
- /* 1040 */ 172, 173, 172, 173, 237, 172, 173, 152, 152, 152,
131351
- /* 1050 */ 124, 152, 111, 172, 173, 152, 237, 172, 173, 152,
131352
- /* 1060 */ 55, 152, 26, 152, 130, 152, 152, 172, 173, 172,
131353
- /* 1070 */ 173, 172, 173, 249, 152, 172, 173, 152, 61, 172,
131354
- /* 1080 */ 173, 172, 173, 172, 173, 172, 173, 70, 152, 193,
131355
- /* 1090 */ 152, 137, 152, 139, 172, 173, 152, 172, 173, 152,
131356
- /* 1100 */ 152, 152, 97, 152, 26, 152, 163, 152, 172, 173,
131357
- /* 1110 */ 172, 173, 172, 173, 152, 16, 172, 173, 26, 172,
131358
- /* 1120 */ 173, 172, 173, 172, 173, 172, 173, 172, 173, 163,
131359
- /* 1130 */ 152, 152, 152, 22, 172, 173, 152, 241, 152, 196,
131360
- /* 1140 */ 152, 193, 106, 152, 152, 152, 163, 152, 37, 152,
131361
- /* 1150 */ 172, 173, 172, 173, 152, 152, 172, 173, 172, 173,
131362
- /* 1160 */ 172, 173, 196, 172, 173, 172, 173, 172, 173, 172,
131363
- /* 1170 */ 173, 152, 152, 152, 172, 173, 98, 152, 152, 196,
131364
- /* 1180 */ 160, 22, 23, 19, 164, 193, 152, 88, 232, 90,
131365
- /* 1190 */ 191, 172, 173, 172, 173, 163, 193, 172, 173, 166,
131366
- /* 1200 */ 167, 163, 124, 163, 244, 245, 23, 211, 212, 26,
131367
- /* 1210 */ 55, 23, 55, 23, 26, 123, 26, 152, 23, 193,
131368
- /* 1220 */ 56, 26, 23, 23, 23, 26, 26, 26, 196, 100,
131369
- /* 1230 */ 101, 7, 8, 152, 196, 23, 196, 23, 26, 152,
131370
- /* 1240 */ 26, 132, 133, 23, 132, 133, 26, 152, 152, 152,
131371
- /* 1250 */ 152, 210, 97, 152, 97, 96, 152, 152, 152, 152,
131372
- /* 1260 */ 152, 210, 152, 210, 197, 152, 152, 152, 152, 152,
131373
- /* 1270 */ 152, 152, 152, 152, 152, 152, 152, 198, 150, 176,
131374
- /* 1280 */ 214, 201, 214, 238, 201, 238, 184, 214, 226, 200,
131375
- /* 1290 */ 155, 198, 67, 122, 242, 159, 159, 69, 239, 239,
131376
- /* 1300 */ 159, 175, 175, 22, 220, 180, 175, 27, 130, 18,
131377
- /* 1310 */ 159, 18, 158, 137, 220, 159, 158, 235, 74, 189,
131378
- /* 1320 */ 234, 159, 159, 158, 22, 192, 192, 177, 159, 159,
131379
- /* 1330 */ 192, 192, 189, 201, 189, 158, 107, 158, 177, 76,
131380
- /* 1340 */ 174, 201, 174, 201, 106, 159, 174, 125, 174, 182,
131381
- /* 1350 */ 177, 176, 107, 159, 174, 137, 174, 53, 174, 129,
131382
- /* 1360 */ 216, 215, 215, 182, 216, 216, 177, 215, 126, 216,
131383
- /* 1370 */ 177, 128, 25, 127, 26, 215, 13, 162, 161, 153,
131384
- /* 1380 */ 153, 6, 151, 151, 151, 151, 165, 178, 165, 178,
131385
- /* 1390 */ 4, 3, 22, 142, 15, 94, 16, 205, 120, 202,
131386
- /* 1400 */ 204, 203, 165, 201, 23, 23, 131, 111, 123, 20,
131387
- /* 1410 */ 225, 125, 16, 1, 131, 228, 111, 123, 56, 228,
131388
- /* 1420 */ 37, 37, 64, 1, 5, 122, 22, 107, 140, 80,
131389
- /* 1430 */ 80, 26, 87, 72, 107, 24, 20, 19, 112, 105,
131390
- /* 1440 */ 23, 68, 22, 79, 79, 22, 22, 22, 58, 22,
131391
- /* 1450 */ 245, 248, 248, 79, 23, 23, 23, 116, 22, 122,
131392
- /* 1460 */ 23, 22, 56, 23, 26, 23, 64, 22, 124, 26,
131393
- /* 1470 */ 26, 64, 64, 23, 23, 23, 11, 23, 22, 26,
131394
- /* 1480 */ 23, 22, 24, 1, 23, 22, 26, 250, 24, 23,
131395
- /* 1490 */ 22, 122, 23, 23, 22, 15, 23, 250, 122, 122,
131396
- /* 1500 */ 122,
132164
+ /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
132165
+ /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
132166
+ /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
132167
+ /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
132168
+ /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
132169
+ /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
132170
+ /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
132171
+ /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
132172
+ /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
132173
+ /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
132174
+ /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
132175
+ /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
132176
+ /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
132177
+ /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
132178
+ /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
132179
+ /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
132180
+ /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
132181
+ /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
132182
+ /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
132183
+ /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
132184
+ /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
132185
+ /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
132186
+ /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
132187
+ /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
132188
+ /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
132189
+ /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
132190
+ /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
132191
+ /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
132192
+ /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
132193
+ /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
132194
+ /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
132195
+ /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
132196
+ /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
132197
+ /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
132198
+ /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
132199
+ /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
132200
+ /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
132201
+ /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
132202
+ /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
132203
+ /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
132204
+ /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
132205
+ /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
132206
+ /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
132207
+ /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
132208
+ /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
132209
+ /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
132210
+ /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
132211
+ /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
132212
+ /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
132213
+ /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
132214
+ /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
131397132215
};
131398132216
#define YY_SHIFT_USE_DFLT (-95)
131399
-#define YY_SHIFT_COUNT (439)
132217
+#define YY_SHIFT_COUNT (442)
131400132218
#define YY_SHIFT_MIN (-94)
131401
-#define YY_SHIFT_MAX (1482)
132219
+#define YY_SHIFT_MAX (1491)
131402132220
static const short yy_shift_ofst[] = {
131403
- /* 0 */ 40, 564, 869, 577, 725, 725, 725, 739, -19, 16,
131404
- /* 10 */ 16, 100, 725, 725, 725, 725, 725, 725, 725, 841,
131405
- /* 20 */ 841, 538, 507, 684, 623, 61, 137, 172, 207, 242,
131406
- /* 30 */ 277, 312, 347, 382, 424, 424, 424, 424, 424, 424,
131407
- /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 459,
131408
- /* 50 */ 424, 494, 529, 529, 670, 725, 725, 725, 725, 725,
132221
+ /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132222
+ /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132223
+ /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132224
+ /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132225
+ /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132226
+ /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
131409132227
/* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131410132228
/* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
131411
- /* 80 */ 725, 725, 725, 821, 725, 725, 725, 725, 725, 725,
131412
- /* 90 */ 725, 725, 725, 725, 725, 725, 725, 952, 711, 711,
131413
- /* 100 */ 711, 711, 711, 766, 23, 32, 811, 877, 663, 602,
131414
- /* 110 */ 602, 811, 73, 113, -51, -95, -95, -95, 501, 501,
131415
- /* 120 */ 501, 595, 595, 809, 205, 276, 811, 811, 811, 811,
131416
- /* 130 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131417
- /* 140 */ 811, 811, 811, 811, 811, 811, 192, 628, 498, 498,
131418
- /* 150 */ 113, -34, -34, -34, -34, -34, -34, -95, -95, -95,
131419
- /* 160 */ 880, -94, -94, 726, 740, 99, 797, 887, 349, 811,
131420
- /* 170 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811,
131421
- /* 180 */ 811, 811, 811, 811, 811, 811, 941, 941, 941, 811,
131422
- /* 190 */ 811, 926, 811, 811, 811, -18, 811, 811, 842, 811,
131423
- /* 200 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 224,
131424
- /* 210 */ 608, 910, 910, 910, 1078, 45, 469, 508, 934, 970,
131425
- /* 220 */ 970, 1164, 934, 1164, 1036, 1183, 359, 1017, 970, 954,
131426
- /* 230 */ 1017, 1017, 1092, 730, 497, 1225, 1171, 1171, 1228, 1228,
131427
- /* 240 */ 1171, 1281, 1280, 1178, 1291, 1291, 1291, 1291, 1171, 1293,
131428
- /* 250 */ 1178, 1281, 1280, 1280, 1178, 1171, 1293, 1176, 1244, 1171,
131429
- /* 260 */ 1171, 1293, 1302, 1171, 1293, 1171, 1293, 1302, 1229, 1229,
131430
- /* 270 */ 1229, 1263, 1302, 1229, 1238, 1229, 1263, 1229, 1229, 1222,
131431
- /* 280 */ 1245, 1222, 1245, 1222, 1245, 1222, 1245, 1171, 1171, 1218,
131432
- /* 290 */ 1302, 1304, 1304, 1302, 1230, 1242, 1243, 1246, 1178, 1347,
131433
- /* 300 */ 1348, 1363, 1363, 1375, 1375, 1375, 1375, -95, -95, -95,
131434
- /* 310 */ -95, -95, -95, -95, -95, 451, 876, 346, 1159, 1099,
131435
- /* 320 */ 441, 823, 1188, 1111, 1190, 1195, 1199, 1200, 1005, 1129,
131436
- /* 330 */ 1224, 533, 1201, 1212, 1155, 1214, 1109, 1112, 1220, 1157,
131437
- /* 340 */ 779, 1386, 1388, 1370, 1251, 1379, 1301, 1380, 1381, 1382,
131438
- /* 350 */ 1278, 1275, 1296, 1285, 1389, 1286, 1396, 1412, 1294, 1283,
131439
- /* 360 */ 1383, 1384, 1305, 1362, 1358, 1303, 1422, 1419, 1404, 1320,
131440
- /* 370 */ 1288, 1349, 1405, 1350, 1345, 1361, 1327, 1411, 1416, 1418,
131441
- /* 380 */ 1326, 1334, 1420, 1364, 1423, 1424, 1417, 1425, 1365, 1390,
131442
- /* 390 */ 1427, 1374, 1373, 1431, 1432, 1433, 1341, 1436, 1437, 1439,
131443
- /* 400 */ 1438, 1337, 1440, 1442, 1406, 1402, 1445, 1344, 1443, 1407,
131444
- /* 410 */ 1444, 1408, 1443, 1450, 1451, 1452, 1453, 1454, 1456, 1465,
131445
- /* 420 */ 1457, 1459, 1458, 1460, 1461, 1463, 1464, 1460, 1466, 1468,
131446
- /* 430 */ 1469, 1470, 1472, 1369, 1376, 1377, 1378, 1473, 1480, 1482,
132229
+ /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132230
+ /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132231
+ /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132232
+ /* 110 */ 837, 837, 924, 73, 183, -51, -95, -95, -95, 501,
132233
+ /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132234
+ /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132235
+ /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132236
+ /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, -95, -95,
132237
+ /* 160 */ -95, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132238
+ /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132239
+ /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132240
+ /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132241
+ /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132242
+ /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132243
+ /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132244
+ /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132245
+ /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132246
+ /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132247
+ /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132248
+ /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132249
+ /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132250
+ /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132251
+ /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, -95,
132252
+ /* 310 */ -95, -95, -95, -95, -95, -95, -95, 451, 936, 816,
132253
+ /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132254
+ /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132255
+ /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132256
+ /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132257
+ /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132258
+ /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132259
+ /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132260
+ /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132261
+ /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132262
+ /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132263
+ /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132264
+ /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132265
+ /* 440 */ 1482, 1491, 1490,
131447132266
};
131448132267
#define YY_REDUCE_USE_DFLT (-130)
131449
-#define YY_REDUCE_COUNT (314)
132268
+#define YY_REDUCE_COUNT (316)
131450132269
#define YY_REDUCE_MIN (-129)
131451
-#define YY_REDUCE_MAX (1237)
132270
+#define YY_REDUCE_MAX (1243)
131452132271
static const short yy_reduce_ofst[] = {
131453
- /* 0 */ -29, 531, 490, 625, -49, 272, 456, 510, 400, 509,
131454
- /* 10 */ 562, 114, 535, 614, 698, 384, 738, 751, 690, 419,
131455
- /* 20 */ 553, 761, 460, 636, 767, 41, 41, 41, 41, 41,
131456
- /* 30 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131457
- /* 40 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
131458
- /* 50 */ 41, 41, 41, 41, 760, 815, 856, 863, 866, 868,
131459
- /* 60 */ 870, 873, 881, 885, 895, 897, 899, 903, 907, 909,
131460
- /* 70 */ 911, 913, 922, 925, 936, 938, 940, 944, 947, 949,
131461
- /* 80 */ 951, 953, 955, 962, 978, 980, 984, 986, 988, 991,
131462
- /* 90 */ 993, 995, 997, 1002, 1019, 1021, 1025, 41, 41, 41,
131463
- /* 100 */ 41, 41, 41, 41, 41, 41, 896, 140, 260, 98,
131464
- /* 110 */ 268, 1020, 41, 482, 41, 41, 41, 41, 270, 270,
131465
- /* 120 */ 270, 212, 217, -129, 411, 411, 550, 5, 626, 362,
131466
- /* 130 */ 733, 830, 992, 1003, 1026, 795, 683, 807, 638, 819,
131467
- /* 140 */ 753, 948, 62, 817, 824, 132, 687, 611, 864, 1033,
131468
- /* 150 */ 403, 943, 966, 983, 1032, 1038, 1040, 960, 996, 492,
131469
- /* 160 */ -50, 57, 131, 153, 221, 462, 588, 596, 675, 721,
131470
- /* 170 */ 820, 834, 857, 914, 979, 1034, 1065, 1081, 1087, 1095,
131471
- /* 180 */ 1096, 1097, 1098, 1101, 1104, 1105, 320, 500, 655, 1106,
131472
- /* 190 */ 1107, 503, 1108, 1110, 1113, 681, 1114, 1115, 999, 1116,
131473
- /* 200 */ 1117, 1118, 221, 1119, 1120, 1121, 1122, 1123, 1124, 788,
131474
- /* 210 */ 956, 1041, 1051, 1053, 503, 1067, 1079, 1128, 1080, 1066,
131475
- /* 220 */ 1068, 1045, 1083, 1047, 1103, 1102, 1125, 1126, 1073, 1062,
131476
- /* 230 */ 1127, 1131, 1089, 1093, 1135, 1052, 1136, 1137, 1059, 1060,
131477
- /* 240 */ 1141, 1084, 1130, 1132, 1133, 1134, 1138, 1139, 1151, 1154,
131478
- /* 250 */ 1140, 1094, 1143, 1145, 1142, 1156, 1158, 1082, 1086, 1162,
131479
- /* 260 */ 1163, 1165, 1150, 1169, 1177, 1170, 1179, 1161, 1166, 1168,
131480
- /* 270 */ 1172, 1167, 1173, 1174, 1175, 1180, 1181, 1182, 1184, 1144,
131481
- /* 280 */ 1146, 1148, 1147, 1149, 1152, 1153, 1160, 1186, 1194, 1185,
131482
- /* 290 */ 1189, 1187, 1191, 1193, 1192, 1196, 1198, 1197, 1202, 1215,
131483
- /* 300 */ 1217, 1226, 1227, 1231, 1232, 1233, 1234, 1203, 1204, 1205,
131484
- /* 310 */ 1221, 1223, 1209, 1211, 1237,
132272
+ /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132273
+ /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132274
+ /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
132275
+ /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132276
+ /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132277
+ /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132278
+ /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132279
+ /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132280
+ /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132281
+ /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132282
+ /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132283
+ /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132284
+ /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132285
+ /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132286
+ /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132287
+ /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132288
+ /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132289
+ /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132290
+ /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132291
+ /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132292
+ /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132293
+ /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132294
+ /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132295
+ /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132296
+ /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132297
+ /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132298
+ /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132299
+ /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132300
+ /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132301
+ /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132302
+ /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132303
+ /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
131485132304
};
131486132305
static const YYACTIONTYPE yy_default[] = {
131487
- /* 0 */ 1250, 1240, 1240, 1240, 1174, 1174, 1174, 1240, 1071, 1100,
131488
- /* 10 */ 1100, 1224, 1301, 1301, 1301, 1301, 1301, 1301, 1173, 1301,
131489
- /* 20 */ 1301, 1301, 1301, 1240, 1075, 1106, 1301, 1301, 1301, 1301,
131490
- /* 30 */ 1301, 1301, 1301, 1301, 1223, 1225, 1114, 1113, 1206, 1087,
131491
- /* 40 */ 1111, 1104, 1108, 1175, 1169, 1170, 1168, 1172, 1176, 1301,
131492
- /* 50 */ 1107, 1138, 1153, 1137, 1301, 1301, 1301, 1301, 1301, 1301,
131493
- /* 60 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131494
- /* 70 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131495
- /* 80 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131496
- /* 90 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1147, 1152, 1159,
131497
- /* 100 */ 1151, 1148, 1140, 1139, 1141, 1142, 1301, 994, 1042, 1301,
131498
- /* 110 */ 1301, 1301, 1143, 1301, 1144, 1156, 1155, 1154, 1231, 1258,
131499
- /* 120 */ 1257, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131500
- /* 130 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131501
- /* 140 */ 1301, 1301, 1301, 1301, 1301, 1301, 1250, 1240, 1000, 1000,
131502
- /* 150 */ 1301, 1240, 1240, 1240, 1240, 1240, 1240, 1236, 1075, 1066,
131503
- /* 160 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131504
- /* 170 */ 1228, 1226, 1301, 1187, 1301, 1301, 1301, 1301, 1301, 1301,
131505
- /* 180 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131506
- /* 190 */ 1301, 1301, 1301, 1301, 1301, 1071, 1301, 1301, 1301, 1301,
131507
- /* 200 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1252, 1301,
131508
- /* 210 */ 1201, 1071, 1071, 1071, 1073, 1055, 1065, 979, 1110, 1089,
131509
- /* 220 */ 1089, 1290, 1110, 1290, 1017, 1272, 1014, 1100, 1089, 1171,
131510
- /* 230 */ 1100, 1100, 1072, 1065, 1301, 1293, 1080, 1080, 1292, 1292,
131511
- /* 240 */ 1080, 1119, 1045, 1110, 1051, 1051, 1051, 1051, 1080, 991,
131512
- /* 250 */ 1110, 1119, 1045, 1045, 1110, 1080, 991, 1205, 1287, 1080,
131513
- /* 260 */ 1080, 991, 1180, 1080, 991, 1080, 991, 1180, 1043, 1043,
131514
- /* 270 */ 1043, 1032, 1180, 1043, 1017, 1043, 1032, 1043, 1043, 1093,
131515
- /* 280 */ 1088, 1093, 1088, 1093, 1088, 1093, 1088, 1080, 1080, 1301,
131516
- /* 290 */ 1180, 1184, 1184, 1180, 1105, 1094, 1103, 1101, 1110, 997,
131517
- /* 300 */ 1035, 1255, 1255, 1251, 1251, 1251, 1251, 1298, 1298, 1236,
131518
- /* 310 */ 1267, 1267, 1019, 1019, 1267, 1301, 1301, 1301, 1301, 1301,
131519
- /* 320 */ 1301, 1262, 1301, 1189, 1301, 1301, 1301, 1301, 1301, 1301,
131520
- /* 330 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131521
- /* 340 */ 1125, 1301, 975, 1233, 1301, 1301, 1232, 1301, 1301, 1301,
131522
- /* 350 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131523
- /* 360 */ 1301, 1301, 1301, 1301, 1301, 1289, 1301, 1301, 1301, 1301,
131524
- /* 370 */ 1301, 1301, 1204, 1203, 1301, 1301, 1301, 1301, 1301, 1301,
131525
- /* 380 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131526
- /* 390 */ 1301, 1301, 1301, 1301, 1301, 1301, 1057, 1301, 1301, 1301,
131527
- /* 400 */ 1276, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1102, 1301,
131528
- /* 410 */ 1095, 1301, 1280, 1301, 1301, 1301, 1301, 1301, 1301, 1301,
131529
- /* 420 */ 1301, 1301, 1301, 1242, 1301, 1301, 1301, 1241, 1301, 1301,
131530
- /* 430 */ 1301, 1301, 1301, 1127, 1301, 1126, 1130, 1301, 985, 1301,
132306
+ /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132307
+ /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132308
+ /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132309
+ /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132310
+ /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132311
+ /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132312
+ /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132313
+ /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132314
+ /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132315
+ /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132316
+ /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132317
+ /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132318
+ /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132319
+ /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132320
+ /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132321
+ /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132322
+ /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132323
+ /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132324
+ /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132325
+ /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132326
+ /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132327
+ /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132328
+ /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132329
+ /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132330
+ /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132331
+ /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132332
+ /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132333
+ /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132334
+ /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132335
+ /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132336
+ /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132337
+ /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132338
+ /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132339
+ /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132340
+ /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132341
+ /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132342
+ /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132343
+ /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132344
+ /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132345
+ /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132346
+ /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132347
+ /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132348
+ /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132349
+ /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132350
+ /* 440 */ 1309, 991, 1309,
131531132351
};
131532132352
/********** End of lemon-generated parsing tables *****************************/
131533132353
131534132354
/* The next table maps tokens (terminal symbols) into fallback tokens.
131535132355
** If a construct like the following:
@@ -131672,21 +132492,22 @@
131672132492
typedef struct yyStackEntry yyStackEntry;
131673132493
131674132494
/* The state of the parser is completely contained in an instance of
131675132495
** the following structure */
131676132496
struct yyParser {
131677
- int yyidx; /* Index of top element in stack */
132497
+ yyStackEntry *yytos; /* Pointer to top element of the stack */
131678132498
#ifdef YYTRACKMAXSTACKDEPTH
131679
- int yyidxMax; /* Maximum value of yyidx */
132499
+ int yyhwm; /* High-water mark of the stack */
131680132500
#endif
131681132501
#ifndef YYNOERRORRECOVERY
131682132502
int yyerrcnt; /* Shifts left before out of the error */
131683132503
#endif
131684132504
sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
131685132505
#if YYSTACKDEPTH<=0
131686132506
int yystksz; /* Current side of the stack */
131687132507
yyStackEntry *yystack; /* The parser's stack */
132508
+ yyStackEntry yystk0; /* First stack entry */
131688132509
#else
131689132510
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
131690132511
#endif
131691132512
};
131692132513
typedef struct yyParser yyParser;
@@ -131781,17 +132602,17 @@
131781132602
"orderby_opt", "limit_opt", "values", "nexprlist",
131782132603
"exprlist", "sclp", "as", "seltablist",
131783132604
"stl_prefix", "joinop", "indexed_opt", "on_opt",
131784132605
"using_opt", "idlist", "setlist", "insert_cmd",
131785132606
"idlist_opt", "likeop", "between_op", "in_op",
131786
- "case_operand", "case_exprlist", "case_else", "uniqueflag",
131787
- "collate", "nmnum", "trigger_decl", "trigger_cmd_list",
131788
- "trigger_time", "trigger_event", "foreach_clause", "when_clause",
131789
- "trigger_cmd", "trnm", "tridxby", "database_kw_opt",
131790
- "key_opt", "add_column_fullname", "kwcolumn_opt", "create_vtab",
131791
- "vtabarglist", "vtabarg", "vtabargtoken", "lp",
131792
- "anylist", "wqlist",
132607
+ "paren_exprlist", "case_operand", "case_exprlist", "case_else",
132608
+ "uniqueflag", "collate", "nmnum", "trigger_decl",
132609
+ "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause",
132610
+ "when_clause", "trigger_cmd", "trnm", "tridxby",
132611
+ "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt",
132612
+ "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken",
132613
+ "lp", "anylist", "wqlist",
131793132614
};
131794132615
#endif /* NDEBUG */
131795132616
131796132617
#ifndef NDEBUG
131797132618
/* For tracing reduce actions, the names of all rules are required.
@@ -131985,11 +132806,11 @@
131985132806
/* 185 */ "in_op ::= IN",
131986132807
/* 186 */ "in_op ::= NOT IN",
131987132808
/* 187 */ "expr ::= expr in_op LP exprlist RP",
131988132809
/* 188 */ "expr ::= LP select RP",
131989132810
/* 189 */ "expr ::= expr in_op LP select RP",
131990
- /* 190 */ "expr ::= expr in_op nm dbnm",
132811
+ /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
131991132812
/* 191 */ "expr ::= EXISTS LP select RP",
131992132813
/* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
131993132814
/* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
131994132815
/* 194 */ "case_exprlist ::= WHEN expr THEN expr",
131995132816
/* 195 */ "case_else ::= ELSE expr",
@@ -131997,158 +132818,170 @@
131997132818
/* 197 */ "case_operand ::= expr",
131998132819
/* 198 */ "case_operand ::=",
131999132820
/* 199 */ "exprlist ::=",
132000132821
/* 200 */ "nexprlist ::= nexprlist COMMA expr",
132001132822
/* 201 */ "nexprlist ::= expr",
132002
- /* 202 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132003
- /* 203 */ "uniqueflag ::= UNIQUE",
132004
- /* 204 */ "uniqueflag ::=",
132005
- /* 205 */ "eidlist_opt ::=",
132006
- /* 206 */ "eidlist_opt ::= LP eidlist RP",
132007
- /* 207 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132008
- /* 208 */ "eidlist ::= nm collate sortorder",
132009
- /* 209 */ "collate ::=",
132010
- /* 210 */ "collate ::= COLLATE ID|STRING",
132011
- /* 211 */ "cmd ::= DROP INDEX ifexists fullname",
132012
- /* 212 */ "cmd ::= VACUUM",
132013
- /* 213 */ "cmd ::= VACUUM nm",
132014
- /* 214 */ "cmd ::= PRAGMA nm dbnm",
132015
- /* 215 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132016
- /* 216 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132017
- /* 217 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132018
- /* 218 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132019
- /* 219 */ "plus_num ::= PLUS INTEGER|FLOAT",
132020
- /* 220 */ "minus_num ::= MINUS INTEGER|FLOAT",
132021
- /* 221 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132022
- /* 222 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132023
- /* 223 */ "trigger_time ::= BEFORE",
132024
- /* 224 */ "trigger_time ::= AFTER",
132025
- /* 225 */ "trigger_time ::= INSTEAD OF",
132026
- /* 226 */ "trigger_time ::=",
132027
- /* 227 */ "trigger_event ::= DELETE|INSERT",
132028
- /* 228 */ "trigger_event ::= UPDATE",
132029
- /* 229 */ "trigger_event ::= UPDATE OF idlist",
132030
- /* 230 */ "when_clause ::=",
132031
- /* 231 */ "when_clause ::= WHEN expr",
132032
- /* 232 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132033
- /* 233 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132034
- /* 234 */ "trnm ::= nm DOT nm",
132035
- /* 235 */ "tridxby ::= INDEXED BY nm",
132036
- /* 236 */ "tridxby ::= NOT INDEXED",
132037
- /* 237 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132038
- /* 238 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132039
- /* 239 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132040
- /* 240 */ "trigger_cmd ::= select",
132041
- /* 241 */ "expr ::= RAISE LP IGNORE RP",
132042
- /* 242 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132043
- /* 243 */ "raisetype ::= ROLLBACK",
132044
- /* 244 */ "raisetype ::= ABORT",
132045
- /* 245 */ "raisetype ::= FAIL",
132046
- /* 246 */ "cmd ::= DROP TRIGGER ifexists fullname",
132047
- /* 247 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132048
- /* 248 */ "cmd ::= DETACH database_kw_opt expr",
132049
- /* 249 */ "key_opt ::=",
132050
- /* 250 */ "key_opt ::= KEY expr",
132051
- /* 251 */ "cmd ::= REINDEX",
132052
- /* 252 */ "cmd ::= REINDEX nm dbnm",
132053
- /* 253 */ "cmd ::= ANALYZE",
132054
- /* 254 */ "cmd ::= ANALYZE nm dbnm",
132055
- /* 255 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132056
- /* 256 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132057
- /* 257 */ "add_column_fullname ::= fullname",
132058
- /* 258 */ "cmd ::= create_vtab",
132059
- /* 259 */ "cmd ::= create_vtab LP vtabarglist RP",
132060
- /* 260 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132061
- /* 261 */ "vtabarg ::=",
132062
- /* 262 */ "vtabargtoken ::= ANY",
132063
- /* 263 */ "vtabargtoken ::= lp anylist RP",
132064
- /* 264 */ "lp ::= LP",
132065
- /* 265 */ "with ::=",
132066
- /* 266 */ "with ::= WITH wqlist",
132067
- /* 267 */ "with ::= WITH RECURSIVE wqlist",
132068
- /* 268 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132069
- /* 269 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132070
- /* 270 */ "input ::= cmdlist",
132071
- /* 271 */ "cmdlist ::= cmdlist ecmd",
132072
- /* 272 */ "cmdlist ::= ecmd",
132073
- /* 273 */ "ecmd ::= SEMI",
132074
- /* 274 */ "ecmd ::= explain cmdx SEMI",
132075
- /* 275 */ "explain ::=",
132076
- /* 276 */ "trans_opt ::=",
132077
- /* 277 */ "trans_opt ::= TRANSACTION",
132078
- /* 278 */ "trans_opt ::= TRANSACTION nm",
132079
- /* 279 */ "savepoint_opt ::= SAVEPOINT",
132080
- /* 280 */ "savepoint_opt ::=",
132081
- /* 281 */ "cmd ::= create_table create_table_args",
132082
- /* 282 */ "columnlist ::= columnlist COMMA columnname carglist",
132083
- /* 283 */ "columnlist ::= columnname carglist",
132084
- /* 284 */ "nm ::= ID|INDEXED",
132085
- /* 285 */ "nm ::= STRING",
132086
- /* 286 */ "nm ::= JOIN_KW",
132087
- /* 287 */ "typetoken ::= typename",
132088
- /* 288 */ "typename ::= ID|STRING",
132089
- /* 289 */ "signed ::= plus_num",
132090
- /* 290 */ "signed ::= minus_num",
132091
- /* 291 */ "carglist ::= carglist ccons",
132092
- /* 292 */ "carglist ::=",
132093
- /* 293 */ "ccons ::= NULL onconf",
132094
- /* 294 */ "conslist_opt ::= COMMA conslist",
132095
- /* 295 */ "conslist ::= conslist tconscomma tcons",
132096
- /* 296 */ "conslist ::= tcons",
132097
- /* 297 */ "tconscomma ::=",
132098
- /* 298 */ "defer_subclause_opt ::= defer_subclause",
132099
- /* 299 */ "resolvetype ::= raisetype",
132100
- /* 300 */ "selectnowith ::= oneselect",
132101
- /* 301 */ "oneselect ::= values",
132102
- /* 302 */ "sclp ::= selcollist COMMA",
132103
- /* 303 */ "as ::= ID|STRING",
132104
- /* 304 */ "expr ::= term",
132105
- /* 305 */ "exprlist ::= nexprlist",
132106
- /* 306 */ "nmnum ::= plus_num",
132107
- /* 307 */ "nmnum ::= nm",
132108
- /* 308 */ "nmnum ::= ON",
132109
- /* 309 */ "nmnum ::= DELETE",
132110
- /* 310 */ "nmnum ::= DEFAULT",
132111
- /* 311 */ "plus_num ::= INTEGER|FLOAT",
132112
- /* 312 */ "foreach_clause ::=",
132113
- /* 313 */ "foreach_clause ::= FOR EACH ROW",
132114
- /* 314 */ "trnm ::= nm",
132115
- /* 315 */ "tridxby ::=",
132116
- /* 316 */ "database_kw_opt ::= DATABASE",
132117
- /* 317 */ "database_kw_opt ::=",
132118
- /* 318 */ "kwcolumn_opt ::=",
132119
- /* 319 */ "kwcolumn_opt ::= COLUMNKW",
132120
- /* 320 */ "vtabarglist ::= vtabarg",
132121
- /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132122
- /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
132123
- /* 323 */ "anylist ::=",
132124
- /* 324 */ "anylist ::= anylist LP anylist RP",
132125
- /* 325 */ "anylist ::= anylist ANY",
132823
+ /* 202 */ "paren_exprlist ::=",
132824
+ /* 203 */ "paren_exprlist ::= LP exprlist RP",
132825
+ /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132826
+ /* 205 */ "uniqueflag ::= UNIQUE",
132827
+ /* 206 */ "uniqueflag ::=",
132828
+ /* 207 */ "eidlist_opt ::=",
132829
+ /* 208 */ "eidlist_opt ::= LP eidlist RP",
132830
+ /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132831
+ /* 210 */ "eidlist ::= nm collate sortorder",
132832
+ /* 211 */ "collate ::=",
132833
+ /* 212 */ "collate ::= COLLATE ID|STRING",
132834
+ /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132835
+ /* 214 */ "cmd ::= VACUUM",
132836
+ /* 215 */ "cmd ::= VACUUM nm",
132837
+ /* 216 */ "cmd ::= PRAGMA nm dbnm",
132838
+ /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132839
+ /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132840
+ /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132841
+ /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132842
+ /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132843
+ /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132844
+ /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132845
+ /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132846
+ /* 225 */ "trigger_time ::= BEFORE",
132847
+ /* 226 */ "trigger_time ::= AFTER",
132848
+ /* 227 */ "trigger_time ::= INSTEAD OF",
132849
+ /* 228 */ "trigger_time ::=",
132850
+ /* 229 */ "trigger_event ::= DELETE|INSERT",
132851
+ /* 230 */ "trigger_event ::= UPDATE",
132852
+ /* 231 */ "trigger_event ::= UPDATE OF idlist",
132853
+ /* 232 */ "when_clause ::=",
132854
+ /* 233 */ "when_clause ::= WHEN expr",
132855
+ /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132856
+ /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132857
+ /* 236 */ "trnm ::= nm DOT nm",
132858
+ /* 237 */ "tridxby ::= INDEXED BY nm",
132859
+ /* 238 */ "tridxby ::= NOT INDEXED",
132860
+ /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132861
+ /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132862
+ /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132863
+ /* 242 */ "trigger_cmd ::= select",
132864
+ /* 243 */ "expr ::= RAISE LP IGNORE RP",
132865
+ /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132866
+ /* 245 */ "raisetype ::= ROLLBACK",
132867
+ /* 246 */ "raisetype ::= ABORT",
132868
+ /* 247 */ "raisetype ::= FAIL",
132869
+ /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132870
+ /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132871
+ /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132872
+ /* 251 */ "key_opt ::=",
132873
+ /* 252 */ "key_opt ::= KEY expr",
132874
+ /* 253 */ "cmd ::= REINDEX",
132875
+ /* 254 */ "cmd ::= REINDEX nm dbnm",
132876
+ /* 255 */ "cmd ::= ANALYZE",
132877
+ /* 256 */ "cmd ::= ANALYZE nm dbnm",
132878
+ /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132879
+ /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132880
+ /* 259 */ "add_column_fullname ::= fullname",
132881
+ /* 260 */ "cmd ::= create_vtab",
132882
+ /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132883
+ /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132884
+ /* 263 */ "vtabarg ::=",
132885
+ /* 264 */ "vtabargtoken ::= ANY",
132886
+ /* 265 */ "vtabargtoken ::= lp anylist RP",
132887
+ /* 266 */ "lp ::= LP",
132888
+ /* 267 */ "with ::=",
132889
+ /* 268 */ "with ::= WITH wqlist",
132890
+ /* 269 */ "with ::= WITH RECURSIVE wqlist",
132891
+ /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132892
+ /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132893
+ /* 272 */ "input ::= cmdlist",
132894
+ /* 273 */ "cmdlist ::= cmdlist ecmd",
132895
+ /* 274 */ "cmdlist ::= ecmd",
132896
+ /* 275 */ "ecmd ::= SEMI",
132897
+ /* 276 */ "ecmd ::= explain cmdx SEMI",
132898
+ /* 277 */ "explain ::=",
132899
+ /* 278 */ "trans_opt ::=",
132900
+ /* 279 */ "trans_opt ::= TRANSACTION",
132901
+ /* 280 */ "trans_opt ::= TRANSACTION nm",
132902
+ /* 281 */ "savepoint_opt ::= SAVEPOINT",
132903
+ /* 282 */ "savepoint_opt ::=",
132904
+ /* 283 */ "cmd ::= create_table create_table_args",
132905
+ /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132906
+ /* 285 */ "columnlist ::= columnname carglist",
132907
+ /* 286 */ "nm ::= ID|INDEXED",
132908
+ /* 287 */ "nm ::= STRING",
132909
+ /* 288 */ "nm ::= JOIN_KW",
132910
+ /* 289 */ "typetoken ::= typename",
132911
+ /* 290 */ "typename ::= ID|STRING",
132912
+ /* 291 */ "signed ::= plus_num",
132913
+ /* 292 */ "signed ::= minus_num",
132914
+ /* 293 */ "carglist ::= carglist ccons",
132915
+ /* 294 */ "carglist ::=",
132916
+ /* 295 */ "ccons ::= NULL onconf",
132917
+ /* 296 */ "conslist_opt ::= COMMA conslist",
132918
+ /* 297 */ "conslist ::= conslist tconscomma tcons",
132919
+ /* 298 */ "conslist ::= tcons",
132920
+ /* 299 */ "tconscomma ::=",
132921
+ /* 300 */ "defer_subclause_opt ::= defer_subclause",
132922
+ /* 301 */ "resolvetype ::= raisetype",
132923
+ /* 302 */ "selectnowith ::= oneselect",
132924
+ /* 303 */ "oneselect ::= values",
132925
+ /* 304 */ "sclp ::= selcollist COMMA",
132926
+ /* 305 */ "as ::= ID|STRING",
132927
+ /* 306 */ "expr ::= term",
132928
+ /* 307 */ "exprlist ::= nexprlist",
132929
+ /* 308 */ "nmnum ::= plus_num",
132930
+ /* 309 */ "nmnum ::= nm",
132931
+ /* 310 */ "nmnum ::= ON",
132932
+ /* 311 */ "nmnum ::= DELETE",
132933
+ /* 312 */ "nmnum ::= DEFAULT",
132934
+ /* 313 */ "plus_num ::= INTEGER|FLOAT",
132935
+ /* 314 */ "foreach_clause ::=",
132936
+ /* 315 */ "foreach_clause ::= FOR EACH ROW",
132937
+ /* 316 */ "trnm ::= nm",
132938
+ /* 317 */ "tridxby ::=",
132939
+ /* 318 */ "database_kw_opt ::= DATABASE",
132940
+ /* 319 */ "database_kw_opt ::=",
132941
+ /* 320 */ "kwcolumn_opt ::=",
132942
+ /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132943
+ /* 322 */ "vtabarglist ::= vtabarg",
132944
+ /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132945
+ /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132946
+ /* 325 */ "anylist ::=",
132947
+ /* 326 */ "anylist ::= anylist LP anylist RP",
132948
+ /* 327 */ "anylist ::= anylist ANY",
132126132949
};
132127132950
#endif /* NDEBUG */
132128132951
132129132952
132130132953
#if YYSTACKDEPTH<=0
132131132954
/*
132132
-** Try to increase the size of the parser stack.
132955
+** Try to increase the size of the parser stack. Return the number
132956
+** of errors. Return 0 on success.
132133132957
*/
132134
-static void yyGrowStack(yyParser *p){
132958
+static int yyGrowStack(yyParser *p){
132135132959
int newSize;
132960
+ int idx;
132136132961
yyStackEntry *pNew;
132137132962
132138132963
newSize = p->yystksz*2 + 100;
132139
- pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132964
+ idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
132965
+ if( p->yystack==&p->yystk0 ){
132966
+ pNew = malloc(newSize*sizeof(pNew[0]));
132967
+ if( pNew ) pNew[0] = p->yystk0;
132968
+ }else{
132969
+ pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132970
+ }
132140132971
if( pNew ){
132141132972
p->yystack = pNew;
132142
- p->yystksz = newSize;
132973
+ p->yytos = &p->yystack[idx];
132143132974
#ifndef NDEBUG
132144132975
if( yyTraceFILE ){
132145
- fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
132146
- yyTracePrompt, p->yystksz);
132976
+ fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
132977
+ yyTracePrompt, p->yystksz, newSize);
132147132978
}
132148132979
#endif
132980
+ p->yystksz = newSize;
132149132981
}
132982
+ return pNew==0;
132150132983
}
132151132984
#endif
132152132985
132153132986
/* Datatype of the argument to the memory allocated passed as the
132154132987
** second argument to sqlite3ParserAlloc() below. This can be changed by
@@ -132173,19 +133006,28 @@
132173133006
*/
132174133007
SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
132175133008
yyParser *pParser;
132176133009
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
132177133010
if( pParser ){
132178
- pParser->yyidx = -1;
132179133011
#ifdef YYTRACKMAXSTACKDEPTH
132180
- pParser->yyidxMax = 0;
133012
+ pParser->yyhwm = 0;
132181133013
#endif
132182133014
#if YYSTACKDEPTH<=0
133015
+ pParser->yytos = NULL;
132183133016
pParser->yystack = NULL;
132184133017
pParser->yystksz = 0;
132185
- yyGrowStack(pParser);
133018
+ if( yyGrowStack(pParser) ){
133019
+ pParser->yystack = &pParser->yystk0;
133020
+ pParser->yystksz = 1;
133021
+ }
132186133022
#endif
133023
+#ifndef YYNOERRORRECOVERY
133024
+ pParser->yyerrcnt = -1;
133025
+#endif
133026
+ pParser->yytos = pParser->yystack;
133027
+ pParser->yystack[0].stateno = 0;
133028
+ pParser->yystack[0].major = 0;
132187133029
}
132188133030
return pParser;
132189133031
}
132190133032
132191133033
/* The following function deletes the "minor type" or semantic value
@@ -132216,17 +133058,17 @@
132216133058
case 163: /* select */
132217133059
case 194: /* selectnowith */
132218133060
case 195: /* oneselect */
132219133061
case 206: /* values */
132220133062
{
132221
-sqlite3SelectDelete(pParse->db, (yypminor->yy159));
133063
+sqlite3SelectDelete(pParse->db, (yypminor->yy243));
132222133064
}
132223133065
break;
132224133066
case 172: /* term */
132225133067
case 173: /* expr */
132226133068
{
132227
-sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);
133069
+sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);
132228133070
}
132229133071
break;
132230133072
case 177: /* eidlist_opt */
132231133073
case 186: /* sortlist */
132232133074
case 187: /* eidlist */
@@ -132235,56 +133077,57 @@
132235133077
case 204: /* orderby_opt */
132236133078
case 207: /* nexprlist */
132237133079
case 208: /* exprlist */
132238133080
case 209: /* sclp */
132239133081
case 218: /* setlist */
132240
- case 225: /* case_exprlist */
133082
+ case 224: /* paren_exprlist */
133083
+ case 226: /* case_exprlist */
132241133084
{
132242
-sqlite3ExprListDelete(pParse->db, (yypminor->yy442));
133085
+sqlite3ExprListDelete(pParse->db, (yypminor->yy148));
132243133086
}
132244133087
break;
132245133088
case 193: /* fullname */
132246133089
case 200: /* from */
132247133090
case 211: /* seltablist */
132248133091
case 212: /* stl_prefix */
132249133092
{
132250
-sqlite3SrcListDelete(pParse->db, (yypminor->yy347));
133093
+sqlite3SrcListDelete(pParse->db, (yypminor->yy185));
132251133094
}
132252133095
break;
132253133096
case 196: /* with */
132254
- case 249: /* wqlist */
133097
+ case 250: /* wqlist */
132255133098
{
132256
-sqlite3WithDelete(pParse->db, (yypminor->yy331));
133099
+sqlite3WithDelete(pParse->db, (yypminor->yy285));
132257133100
}
132258133101
break;
132259133102
case 201: /* where_opt */
132260133103
case 203: /* having_opt */
132261133104
case 215: /* on_opt */
132262
- case 224: /* case_operand */
132263
- case 226: /* case_else */
132264
- case 235: /* when_clause */
132265
- case 240: /* key_opt */
133105
+ case 225: /* case_operand */
133106
+ case 227: /* case_else */
133107
+ case 236: /* when_clause */
133108
+ case 241: /* key_opt */
132266133109
{
132267
-sqlite3ExprDelete(pParse->db, (yypminor->yy122));
133110
+sqlite3ExprDelete(pParse->db, (yypminor->yy72));
132268133111
}
132269133112
break;
132270133113
case 216: /* using_opt */
132271133114
case 217: /* idlist */
132272133115
case 220: /* idlist_opt */
132273133116
{
132274
-sqlite3IdListDelete(pParse->db, (yypminor->yy180));
133117
+sqlite3IdListDelete(pParse->db, (yypminor->yy254));
132275133118
}
132276133119
break;
132277
- case 231: /* trigger_cmd_list */
132278
- case 236: /* trigger_cmd */
133120
+ case 232: /* trigger_cmd_list */
133121
+ case 237: /* trigger_cmd */
132279133122
{
132280
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327));
133123
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145));
132281133124
}
132282133125
break;
132283
- case 233: /* trigger_event */
133126
+ case 234: /* trigger_event */
132284133127
{
132285
-sqlite3IdListDelete(pParse->db, (yypminor->yy410).b);
133128
+sqlite3IdListDelete(pParse->db, (yypminor->yy332).b);
132286133129
}
132287133130
break;
132288133131
/********* End destructor definitions *****************************************/
132289133132
default: break; /* If no destructor action specified: do nothing */
132290133133
}
@@ -132296,12 +133139,13 @@
132296133139
** If there is a destructor routine associated with the token which
132297133140
** is popped from the stack, then call it.
132298133141
*/
132299133142
static void yy_pop_parser_stack(yyParser *pParser){
132300133143
yyStackEntry *yytos;
132301
- assert( pParser->yyidx>=0 );
132302
- yytos = &pParser->yystack[pParser->yyidx--];
133144
+ assert( pParser->yytos!=0 );
133145
+ assert( pParser->yytos > pParser->yystack );
133146
+ yytos = pParser->yytos--;
132303133147
#ifndef NDEBUG
132304133148
if( yyTraceFILE ){
132305133149
fprintf(yyTraceFILE,"%sPopping %s\n",
132306133150
yyTracePrompt,
132307133151
yyTokenName[yytos->major]);
@@ -132324,13 +133168,13 @@
132324133168
){
132325133169
yyParser *pParser = (yyParser*)p;
132326133170
#ifndef YYPARSEFREENEVERNULL
132327133171
if( pParser==0 ) return;
132328133172
#endif
132329
- while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
133173
+ while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
132330133174
#if YYSTACKDEPTH<=0
132331
- free(pParser->yystack);
133175
+ if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
132332133176
#endif
132333133177
(*freeProc)((void*)pParser);
132334133178
}
132335133179
132336133180
/*
@@ -132337,11 +133181,11 @@
132337133181
** Return the peak depth of the stack for a parser.
132338133182
*/
132339133183
#ifdef YYTRACKMAXSTACKDEPTH
132340133184
SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){
132341133185
yyParser *pParser = (yyParser*)p;
132342
- return pParser->yyidxMax;
133186
+ return pParser->yyhwm;
132343133187
}
132344133188
#endif
132345133189
132346133190
/*
132347133191
** Find the appropriate action for a parser given the terminal
@@ -132350,11 +133194,11 @@
132350133194
static unsigned int yy_find_shift_action(
132351133195
yyParser *pParser, /* The parser */
132352133196
YYCODETYPE iLookAhead /* The look-ahead token */
132353133197
){
132354133198
int i;
132355
- int stateno = pParser->yystack[pParser->yyidx].stateno;
133199
+ int stateno = pParser->yytos->stateno;
132356133200
132357133201
if( stateno>=YY_MIN_REDUCE ) return stateno;
132358133202
assert( stateno <= YY_SHIFT_COUNT );
132359133203
do{
132360133204
i = yy_shift_ofst[stateno];
@@ -132443,17 +133287,17 @@
132443133287
/*
132444133288
** The following routine is called if the stack overflows.
132445133289
*/
132446133290
static void yyStackOverflow(yyParser *yypParser){
132447133291
sqlite3ParserARG_FETCH;
132448
- yypParser->yyidx--;
133292
+ yypParser->yytos--;
132449133293
#ifndef NDEBUG
132450133294
if( yyTraceFILE ){
132451133295
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
132452133296
}
132453133297
#endif
132454
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
133298
+ while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
132455133299
/* Here code is inserted which will execute if the parser
132456133300
** stack every overflows */
132457133301
/******** Begin %stack_overflow code ******************************************/
132458133302
132459133303
sqlite3ErrorMsg(pParse, "parser stack overflow");
@@ -132467,15 +133311,15 @@
132467133311
#ifndef NDEBUG
132468133312
static void yyTraceShift(yyParser *yypParser, int yyNewState){
132469133313
if( yyTraceFILE ){
132470133314
if( yyNewState<YYNSTATE ){
132471133315
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
132472
- yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
133316
+ yyTracePrompt,yyTokenName[yypParser->yytos->major],
132473133317
yyNewState);
132474133318
}else{
132475133319
fprintf(yyTraceFILE,"%sShift '%s'\n",
132476
- yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
133320
+ yyTracePrompt,yyTokenName[yypParser->yytos->major]);
132477133321
}
132478133322
}
132479133323
}
132480133324
#else
132481133325
# define yyTraceShift(X,Y)
@@ -132489,31 +133333,34 @@
132489133333
int yyNewState, /* The new state to shift in */
132490133334
int yyMajor, /* The major token to shift in */
132491133335
sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
132492133336
){
132493133337
yyStackEntry *yytos;
132494
- yypParser->yyidx++;
133338
+ yypParser->yytos++;
132495133339
#ifdef YYTRACKMAXSTACKDEPTH
132496
- if( yypParser->yyidx>yypParser->yyidxMax ){
132497
- yypParser->yyidxMax = yypParser->yyidx;
133340
+ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133341
+ yypParser->yyhwm++;
133342
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
132498133343
}
132499133344
#endif
132500133345
#if YYSTACKDEPTH>0
132501
- if( yypParser->yyidx>=YYSTACKDEPTH ){
133346
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
132502133347
yyStackOverflow(yypParser);
132503133348
return;
132504133349
}
132505133350
#else
132506
- if( yypParser->yyidx>=yypParser->yystksz ){
132507
- yyGrowStack(yypParser);
132508
- if( yypParser->yyidx>=yypParser->yystksz ){
133351
+ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
133352
+ if( yyGrowStack(yypParser) ){
132509133353
yyStackOverflow(yypParser);
132510133354
return;
132511133355
}
132512133356
}
132513133357
#endif
132514
- yytos = &yypParser->yystack[yypParser->yyidx];
133358
+ if( yyNewState > YY_MAX_SHIFT ){
133359
+ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
133360
+ }
133361
+ yytos = yypParser->yytos;
132515133362
yytos->stateno = (YYACTIONTYPE)yyNewState;
132516133363
yytos->major = (YYCODETYPE)yyMajor;
132517133364
yytos->minor.yy0 = yyMinor;
132518133365
yyTraceShift(yypParser, yyNewState);
132519133366
}
@@ -132713,31 +133560,33 @@
132713133560
{ 223, 1 },
132714133561
{ 223, 2 },
132715133562
{ 173, 5 },
132716133563
{ 173, 3 },
132717133564
{ 173, 5 },
132718
- { 173, 4 },
133565
+ { 173, 5 },
132719133566
{ 173, 4 },
132720133567
{ 173, 5 },
132721
- { 225, 5 },
132722
- { 225, 4 },
132723
- { 226, 2 },
132724
- { 226, 0 },
132725
- { 224, 1 },
132726
- { 224, 0 },
133568
+ { 226, 5 },
133569
+ { 226, 4 },
133570
+ { 227, 2 },
133571
+ { 227, 0 },
133572
+ { 225, 1 },
133573
+ { 225, 0 },
132727133574
{ 208, 0 },
132728133575
{ 207, 3 },
132729133576
{ 207, 1 },
133577
+ { 224, 0 },
133578
+ { 224, 3 },
132730133579
{ 149, 12 },
132731
- { 227, 1 },
132732
- { 227, 0 },
133580
+ { 228, 1 },
133581
+ { 228, 0 },
132733133582
{ 177, 0 },
132734133583
{ 177, 3 },
132735133584
{ 187, 5 },
132736133585
{ 187, 3 },
132737
- { 228, 0 },
132738
- { 228, 2 },
133586
+ { 229, 0 },
133587
+ { 229, 2 },
132739133588
{ 149, 4 },
132740133589
{ 149, 1 },
132741133590
{ 149, 2 },
132742133591
{ 149, 3 },
132743133592
{ 149, 5 },
@@ -132745,58 +133594,58 @@
132745133594
{ 149, 5 },
132746133595
{ 149, 6 },
132747133596
{ 169, 2 },
132748133597
{ 170, 2 },
132749133598
{ 149, 5 },
132750
- { 230, 11 },
132751
- { 232, 1 },
132752
- { 232, 1 },
132753
- { 232, 2 },
132754
- { 232, 0 },
133599
+ { 231, 11 },
132755133600
{ 233, 1 },
132756133601
{ 233, 1 },
132757
- { 233, 3 },
132758
- { 235, 0 },
132759
- { 235, 2 },
132760
- { 231, 3 },
132761
- { 231, 2 },
132762
- { 237, 3 },
133602
+ { 233, 2 },
133603
+ { 233, 0 },
133604
+ { 234, 1 },
133605
+ { 234, 1 },
133606
+ { 234, 3 },
133607
+ { 236, 0 },
133608
+ { 236, 2 },
133609
+ { 232, 3 },
133610
+ { 232, 2 },
132763133611
{ 238, 3 },
132764
- { 238, 2 },
132765
- { 236, 7 },
132766
- { 236, 5 },
132767
- { 236, 5 },
132768
- { 236, 1 },
133612
+ { 239, 3 },
133613
+ { 239, 2 },
133614
+ { 237, 7 },
133615
+ { 237, 5 },
133616
+ { 237, 5 },
133617
+ { 237, 1 },
132769133618
{ 173, 4 },
132770133619
{ 173, 6 },
132771133620
{ 191, 1 },
132772133621
{ 191, 1 },
132773133622
{ 191, 1 },
132774133623
{ 149, 4 },
132775133624
{ 149, 6 },
132776133625
{ 149, 3 },
132777
- { 240, 0 },
132778
- { 240, 2 },
133626
+ { 241, 0 },
133627
+ { 241, 2 },
132779133628
{ 149, 1 },
132780133629
{ 149, 3 },
132781133630
{ 149, 1 },
132782133631
{ 149, 3 },
132783133632
{ 149, 6 },
132784133633
{ 149, 7 },
132785
- { 241, 1 },
133634
+ { 242, 1 },
132786133635
{ 149, 1 },
132787133636
{ 149, 4 },
132788
- { 243, 8 },
132789
- { 245, 0 },
132790
- { 246, 1 },
132791
- { 246, 3 },
133637
+ { 244, 8 },
133638
+ { 246, 0 },
132792133639
{ 247, 1 },
133640
+ { 247, 3 },
133641
+ { 248, 1 },
132793133642
{ 196, 0 },
132794133643
{ 196, 2 },
132795133644
{ 196, 3 },
132796
- { 249, 6 },
132797
- { 249, 8 },
133645
+ { 250, 6 },
133646
+ { 250, 8 },
132798133647
{ 144, 1 },
132799133648
{ 145, 2 },
132800133649
{ 145, 1 },
132801133650
{ 146, 1 },
132802133651
{ 146, 3 },
@@ -132829,30 +133678,30 @@
132829133678
{ 195, 1 },
132830133679
{ 209, 2 },
132831133680
{ 210, 1 },
132832133681
{ 173, 1 },
132833133682
{ 208, 1 },
132834
- { 229, 1 },
132835
- { 229, 1 },
132836
- { 229, 1 },
132837
- { 229, 1 },
132838
- { 229, 1 },
133683
+ { 230, 1 },
133684
+ { 230, 1 },
133685
+ { 230, 1 },
133686
+ { 230, 1 },
133687
+ { 230, 1 },
132839133688
{ 169, 1 },
132840
- { 234, 0 },
132841
- { 234, 3 },
132842
- { 237, 1 },
132843
- { 238, 0 },
132844
- { 239, 1 },
133689
+ { 235, 0 },
133690
+ { 235, 3 },
133691
+ { 238, 1 },
132845133692
{ 239, 0 },
132846
- { 242, 0 },
132847
- { 242, 1 },
132848
- { 244, 1 },
132849
- { 244, 3 },
132850
- { 245, 2 },
132851
- { 248, 0 },
132852
- { 248, 4 },
132853
- { 248, 2 },
133693
+ { 240, 1 },
133694
+ { 240, 0 },
133695
+ { 243, 0 },
133696
+ { 243, 1 },
133697
+ { 245, 1 },
133698
+ { 245, 3 },
133699
+ { 246, 2 },
133700
+ { 249, 0 },
133701
+ { 249, 4 },
133702
+ { 249, 2 },
132854133703
};
132855133704
132856133705
static void yy_accept(yyParser*); /* Forward Declaration */
132857133706
132858133707
/*
@@ -132866,11 +133715,11 @@
132866133715
int yygoto; /* The next state */
132867133716
int yyact; /* The next action */
132868133717
yyStackEntry *yymsp; /* The top of the parser's stack */
132869133718
int yysize; /* Amount to pop the stack */
132870133719
sqlite3ParserARG_FETCH;
132871
- yymsp = &yypParser->yystack[yypParser->yyidx];
133720
+ yymsp = yypParser->yytos;
132872133721
#ifndef NDEBUG
132873133722
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
132874133723
yysize = yyRuleInfo[yyruleno].nrhs;
132875133724
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
132876133725
yyRuleName[yyruleno], yymsp[-yysize].stateno);
@@ -132880,26 +133729,27 @@
132880133729
/* Check that the stack is large enough to grow by a single entry
132881133730
** if the RHS of the rule is empty. This ensures that there is room
132882133731
** enough on the stack to push the LHS value */
132883133732
if( yyRuleInfo[yyruleno].nrhs==0 ){
132884133733
#ifdef YYTRACKMAXSTACKDEPTH
132885
- if( yypParser->yyidx>yypParser->yyidxMax ){
132886
- yypParser->yyidxMax = yypParser->yyidx;
133734
+ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133735
+ yypParser->yyhwm++;
133736
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
132887133737
}
132888133738
#endif
132889133739
#if YYSTACKDEPTH>0
132890
- if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
133740
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
132891133741
yyStackOverflow(yypParser);
132892133742
return;
132893133743
}
132894133744
#else
132895
- if( yypParser->yyidx>=yypParser->yystksz-1 ){
132896
- yyGrowStack(yypParser);
132897
- if( yypParser->yyidx>=yypParser->yystksz-1 ){
133745
+ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
133746
+ if( yyGrowStack(yypParser) ){
132898133747
yyStackOverflow(yypParser);
132899133748
return;
132900133749
}
133750
+ yymsp = yypParser->yytos;
132901133751
}
132902133752
#endif
132903133753
}
132904133754
132905133755
switch( yyruleno ){
@@ -132921,19 +133771,19 @@
132921133771
break;
132922133772
case 2: /* cmdx ::= cmd */
132923133773
{ sqlite3FinishCoding(pParse); }
132924133774
break;
132925133775
case 3: /* cmd ::= BEGIN transtype trans_opt */
132926
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);}
133776
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);}
132927133777
break;
132928133778
case 4: /* transtype ::= */
132929
-{yymsp[1].minor.yy392 = TK_DEFERRED;}
133779
+{yymsp[1].minor.yy194 = TK_DEFERRED;}
132930133780
break;
132931133781
case 5: /* transtype ::= DEFERRED */
132932133782
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
132933133783
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
132934
-{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-X*/}
133784
+{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
132935133785
break;
132936133786
case 8: /* cmd ::= COMMIT trans_opt */
132937133787
case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
132938133788
{sqlite3CommitTransaction(pParse);}
132939133789
break;
@@ -132955,11 +133805,11 @@
132955133805
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
132956133806
}
132957133807
break;
132958133808
case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
132959133809
{
132960
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392);
133810
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
132961133811
}
132962133812
break;
132963133813
case 15: /* createkw ::= CREATE */
132964133814
{disableLookaside(pParse);}
132965133815
break;
@@ -132969,37 +133819,37 @@
132969133819
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
132970133820
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
132971133821
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
132972133822
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
132973133823
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
132974
- case 209: /* collate ::= */ yytestcase(yyruleno==209);
132975
-{yymsp[1].minor.yy392 = 0;}
133824
+ case 211: /* collate ::= */ yytestcase(yyruleno==211);
133825
+{yymsp[1].minor.yy194 = 0;}
132976133826
break;
132977133827
case 17: /* ifnotexists ::= IF NOT EXISTS */
132978
-{yymsp[-2].minor.yy392 = 1;}
133828
+{yymsp[-2].minor.yy194 = 1;}
132979133829
break;
132980133830
case 18: /* temp ::= TEMP */
132981133831
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
132982
-{yymsp[0].minor.yy392 = 1;}
133832
+{yymsp[0].minor.yy194 = 1;}
132983133833
break;
132984133834
case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
132985133835
{
132986
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy392,0);
133836
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
132987133837
}
132988133838
break;
132989133839
case 21: /* create_table_args ::= AS select */
132990133840
{
132991
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy159);
132992
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
133841
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
133842
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
132993133843
}
132994133844
break;
132995133845
case 23: /* table_options ::= WITHOUT nm */
132996133846
{
132997133847
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
132998
- yymsp[-1].minor.yy392 = TF_WithoutRowid | TF_NoVisibleRowid;
133848
+ yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
132999133849
}else{
133000
- yymsp[-1].minor.yy392 = 0;
133850
+ yymsp[-1].minor.yy194 = 0;
133001133851
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
133002133852
}
133003133853
}
133004133854
break;
133005133855
case 24: /* columnname ::= nm typetoken */
@@ -133027,21 +133877,21 @@
133027133877
case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
133028133878
{pParse->constraintName = yymsp[0].minor.yy0;}
133029133879
break;
133030133880
case 30: /* ccons ::= DEFAULT term */
133031133881
case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
133032
-{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
133882
+{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
133033133883
break;
133034133884
case 31: /* ccons ::= DEFAULT LP expr RP */
133035
-{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);}
133885
+{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
133036133886
break;
133037133887
case 33: /* ccons ::= DEFAULT MINUS term */
133038133888
{
133039133889
ExprSpan v;
133040
- v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);
133890
+ v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0, 0);
133041133891
v.zStart = yymsp[-1].minor.yy0.z;
133042
- v.zEnd = yymsp[0].minor.yy342.zEnd;
133892
+ v.zEnd = yymsp[0].minor.yy190.zEnd;
133043133893
sqlite3AddDefaultValue(pParse,&v);
133044133894
}
133045133895
break;
133046133896
case 34: /* ccons ::= DEFAULT ID|INDEXED */
133047133897
{
@@ -133049,184 +133899,186 @@
133049133899
spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
133050133900
sqlite3AddDefaultValue(pParse,&v);
133051133901
}
133052133902
break;
133053133903
case 35: /* ccons ::= NOT NULL onconf */
133054
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);}
133904
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
133055133905
break;
133056133906
case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
133057
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);}
133907
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
133058133908
break;
133059133909
case 37: /* ccons ::= UNIQUE onconf */
133060
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);}
133910
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
133911
+ SQLITE_IDXTYPE_UNIQUE);}
133061133912
break;
133062133913
case 38: /* ccons ::= CHECK LP expr RP */
133063
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}
133914
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
133064133915
break;
133065133916
case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
133066
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);}
133917
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
133067133918
break;
133068133919
case 40: /* ccons ::= defer_subclause */
133069
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);}
133920
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
133070133921
break;
133071133922
case 41: /* ccons ::= COLLATE ID|STRING */
133072133923
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
133073133924
break;
133074133925
case 44: /* refargs ::= */
133075
-{ yymsp[1].minor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */}
133926
+{ yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
133076133927
break;
133077133928
case 45: /* refargs ::= refargs refarg */
133078
-{ yymsp[-1].minor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }
133929
+{ yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
133079133930
break;
133080133931
case 46: /* refarg ::= MATCH nm */
133081
-{ yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; }
133932
+{ yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
133082133933
break;
133083133934
case 47: /* refarg ::= ON INSERT refact */
133084
-{ yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; }
133935
+{ yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
133085133936
break;
133086133937
case 48: /* refarg ::= ON DELETE refact */
133087
-{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392; yymsp[-2].minor.yy207.mask = 0x0000ff; }
133938
+{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
133088133939
break;
133089133940
case 49: /* refarg ::= ON UPDATE refact */
133090
-{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; }
133941
+{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
133091133942
break;
133092133943
case 50: /* refact ::= SET NULL */
133093
-{ yymsp[-1].minor.yy392 = OE_SetNull; /* EV: R-33326-45252 */}
133944
+{ yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
133094133945
break;
133095133946
case 51: /* refact ::= SET DEFAULT */
133096
-{ yymsp[-1].minor.yy392 = OE_SetDflt; /* EV: R-33326-45252 */}
133947
+{ yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
133097133948
break;
133098133949
case 52: /* refact ::= CASCADE */
133099
-{ yymsp[0].minor.yy392 = OE_Cascade; /* EV: R-33326-45252 */}
133950
+{ yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
133100133951
break;
133101133952
case 53: /* refact ::= RESTRICT */
133102
-{ yymsp[0].minor.yy392 = OE_Restrict; /* EV: R-33326-45252 */}
133953
+{ yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
133103133954
break;
133104133955
case 54: /* refact ::= NO ACTION */
133105
-{ yymsp[-1].minor.yy392 = OE_None; /* EV: R-33326-45252 */}
133956
+{ yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
133106133957
break;
133107133958
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133108
-{yymsp[-2].minor.yy392 = 0;}
133959
+{yymsp[-2].minor.yy194 = 0;}
133109133960
break;
133110133961
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133111133962
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133112133963
case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133113
-{yymsp[-1].minor.yy392 = yymsp[0].minor.yy392;}
133964
+{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133114133965
break;
133115133966
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133116133967
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133117133968
case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133118133969
case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133119
- case 210: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==210);
133120
-{yymsp[-1].minor.yy392 = 1;}
133970
+ case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
133971
+{yymsp[-1].minor.yy194 = 1;}
133121133972
break;
133122133973
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133123
-{yymsp[-1].minor.yy392 = 0;}
133974
+{yymsp[-1].minor.yy194 = 0;}
133124133975
break;
133125133976
case 61: /* tconscomma ::= COMMA */
133126133977
{pParse->constraintName.n = 0;}
133127133978
break;
133128133979
case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
133129
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
133980
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
133130133981
break;
133131133982
case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
133132
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
133983
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
133984
+ SQLITE_IDXTYPE_UNIQUE);}
133133133985
break;
133134133986
case 65: /* tcons ::= CHECK LP expr RP onconf */
133135
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
133987
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
133136133988
break;
133137133989
case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
133138133990
{
133139
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
133140
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
133991
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
133992
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
133141133993
}
133142133994
break;
133143133995
case 68: /* onconf ::= */
133144133996
case 70: /* orconf ::= */ yytestcase(yyruleno==70);
133145
-{yymsp[1].minor.yy392 = OE_Default;}
133997
+{yymsp[1].minor.yy194 = OE_Default;}
133146133998
break;
133147133999
case 69: /* onconf ::= ON CONFLICT resolvetype */
133148
-{yymsp[-2].minor.yy392 = yymsp[0].minor.yy392;}
134000
+{yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
133149134001
break;
133150134002
case 72: /* resolvetype ::= IGNORE */
133151
-{yymsp[0].minor.yy392 = OE_Ignore;}
134003
+{yymsp[0].minor.yy194 = OE_Ignore;}
133152134004
break;
133153134005
case 73: /* resolvetype ::= REPLACE */
133154134006
case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
133155
-{yymsp[0].minor.yy392 = OE_Replace;}
134007
+{yymsp[0].minor.yy194 = OE_Replace;}
133156134008
break;
133157134009
case 74: /* cmd ::= DROP TABLE ifexists fullname */
133158134010
{
133159
- sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
134011
+ sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
133160134012
}
133161134013
break;
133162134014
case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
133163134015
{
133164
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy159, yymsp[-7].minor.yy392, yymsp[-5].minor.yy392);
134016
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
133165134017
}
133166134018
break;
133167134019
case 78: /* cmd ::= DROP VIEW ifexists fullname */
133168134020
{
133169
- sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
134021
+ sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
133170134022
}
133171134023
break;
133172134024
case 79: /* cmd ::= select */
133173134025
{
133174134026
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
133175
- sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
133176
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
134027
+ sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
134028
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
133177134029
}
133178134030
break;
133179134031
case 80: /* select ::= with selectnowith */
133180134032
{
133181
- Select *p = yymsp[0].minor.yy159;
134033
+ Select *p = yymsp[0].minor.yy243;
133182134034
if( p ){
133183
- p->pWith = yymsp[-1].minor.yy331;
134035
+ p->pWith = yymsp[-1].minor.yy285;
133184134036
parserDoubleLinkSelect(pParse, p);
133185134037
}else{
133186
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy331);
134038
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
133187134039
}
133188
- yymsp[-1].minor.yy159 = p; /*A-overwrites-W*/
134040
+ yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
133189134041
}
133190134042
break;
133191134043
case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
133192134044
{
133193
- Select *pRhs = yymsp[0].minor.yy159;
133194
- Select *pLhs = yymsp[-2].minor.yy159;
134045
+ Select *pRhs = yymsp[0].minor.yy243;
134046
+ Select *pLhs = yymsp[-2].minor.yy243;
133195134047
if( pRhs && pRhs->pPrior ){
133196134048
SrcList *pFrom;
133197134049
Token x;
133198134050
x.n = 0;
133199134051
parserDoubleLinkSelect(pParse, pRhs);
133200134052
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
133201134053
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
133202134054
}
133203134055
if( pRhs ){
133204
- pRhs->op = (u8)yymsp[-1].minor.yy392;
134056
+ pRhs->op = (u8)yymsp[-1].minor.yy194;
133205134057
pRhs->pPrior = pLhs;
133206134058
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
133207134059
pRhs->selFlags &= ~SF_MultiValue;
133208
- if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
134060
+ if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1;
133209134061
}else{
133210134062
sqlite3SelectDelete(pParse->db, pLhs);
133211134063
}
133212
- yymsp[-2].minor.yy159 = pRhs;
134064
+ yymsp[-2].minor.yy243 = pRhs;
133213134065
}
133214134066
break;
133215134067
case 82: /* multiselect_op ::= UNION */
133216134068
case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
133217
-{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-OP*/}
134069
+{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
133218134070
break;
133219134071
case 83: /* multiselect_op ::= UNION ALL */
133220
-{yymsp[-1].minor.yy392 = TK_ALL;}
134072
+{yymsp[-1].minor.yy194 = TK_ALL;}
133221134073
break;
133222134074
case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
133223134075
{
133224134076
#if SELECTTRACE_ENABLED
133225134077
Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
133226134078
#endif
133227
- yymsp[-8].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
134079
+ yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
133228134080
#if SELECTTRACE_ENABLED
133229134081
/* Populate the Select.zSelName[] string that is used to help with
133230134082
** query planner debugging, to differentiate between multiple Select
133231134083
** objects in a complex query.
133232134084
**
@@ -133233,464 +134085,465 @@
133233134085
** If the SELECT keyword is immediately followed by a C-style comment
133234134086
** then extract the first few alphanumeric characters from within that
133235134087
** comment to be the zSelName value. Otherwise, the label is #N where
133236134088
** is an integer that is incremented with each SELECT statement seen.
133237134089
*/
133238
- if( yymsp[-8].minor.yy159!=0 ){
134090
+ if( yymsp[-8].minor.yy243!=0 ){
133239134091
const char *z = s.z+6;
133240134092
int i;
133241
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "#%d",
134093
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "#%d",
133242134094
++pParse->nSelect);
133243134095
while( z[0]==' ' ) z++;
133244134096
if( z[0]=='/' && z[1]=='*' ){
133245134097
z += 2;
133246134098
while( z[0]==' ' ) z++;
133247134099
for(i=0; sqlite3Isalnum(z[i]); i++){}
133248
- sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "%.*s", i, z);
134100
+ sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "%.*s", i, z);
133249134101
}
133250134102
}
133251134103
#endif /* SELECTRACE_ENABLED */
133252134104
}
133253134105
break;
133254134106
case 86: /* values ::= VALUES LP nexprlist RP */
133255134107
{
133256
- yymsp[-3].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0,0);
134108
+ yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
133257134109
}
133258134110
break;
133259134111
case 87: /* values ::= values COMMA LP exprlist RP */
133260134112
{
133261
- Select *pRight, *pLeft = yymsp[-4].minor.yy159;
133262
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
134113
+ Select *pRight, *pLeft = yymsp[-4].minor.yy243;
134114
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
133263134115
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
133264134116
if( pRight ){
133265134117
pRight->op = TK_ALL;
133266134118
pRight->pPrior = pLeft;
133267
- yymsp[-4].minor.yy159 = pRight;
134119
+ yymsp[-4].minor.yy243 = pRight;
133268134120
}else{
133269
- yymsp[-4].minor.yy159 = pLeft;
134121
+ yymsp[-4].minor.yy243 = pLeft;
133270134122
}
133271134123
}
133272134124
break;
133273134125
case 88: /* distinct ::= DISTINCT */
133274
-{yymsp[0].minor.yy392 = SF_Distinct;}
134126
+{yymsp[0].minor.yy194 = SF_Distinct;}
133275134127
break;
133276134128
case 89: /* distinct ::= ALL */
133277
-{yymsp[0].minor.yy392 = SF_All;}
134129
+{yymsp[0].minor.yy194 = SF_All;}
133278134130
break;
133279134131
case 91: /* sclp ::= */
133280134132
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
133281134133
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
133282134134
case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
133283
- case 205: /* eidlist_opt ::= */ yytestcase(yyruleno==205);
133284
-{yymsp[1].minor.yy442 = 0;}
134135
+ case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
134136
+ case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
134137
+{yymsp[1].minor.yy148 = 0;}
133285134138
break;
133286134139
case 92: /* selcollist ::= sclp expr as */
133287134140
{
133288
- yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
133289
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0, 1);
133290
- sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy442,&yymsp[-1].minor.yy342);
134141
+ yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
134142
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
134143
+ sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
133291134144
}
133292134145
break;
133293134146
case 93: /* selcollist ::= sclp STAR */
133294134147
{
133295134148
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
133296
- yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
134149
+ yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
133297134150
}
133298134151
break;
133299134152
case 94: /* selcollist ::= sclp nm DOT STAR */
133300134153
{
133301134154
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0);
133302134155
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133303134156
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
133304
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
134157
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
133305134158
}
133306134159
break;
133307134160
case 95: /* as ::= AS nm */
133308134161
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
133309
- case 219: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==219);
133310
- case 220: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==220);
134162
+ case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
134163
+ case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
133311134164
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
133312134165
break;
133313134166
case 97: /* from ::= */
133314
-{yymsp[1].minor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy347));}
134167
+{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
133315134168
break;
133316134169
case 98: /* from ::= FROM seltablist */
133317134170
{
133318
- yymsp[-1].minor.yy347 = yymsp[0].minor.yy347;
133319
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy347);
134171
+ yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
134172
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
133320134173
}
133321134174
break;
133322134175
case 99: /* stl_prefix ::= seltablist joinop */
133323134176
{
133324
- if( ALWAYS(yymsp[-1].minor.yy347 && yymsp[-1].minor.yy347->nSrc>0) ) yymsp[-1].minor.yy347->a[yymsp[-1].minor.yy347->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy392;
134177
+ if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
133325134178
}
133326134179
break;
133327134180
case 100: /* stl_prefix ::= */
133328
-{yymsp[1].minor.yy347 = 0;}
134181
+{yymsp[1].minor.yy185 = 0;}
133329134182
break;
133330134183
case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
133331134184
{
133332
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133333
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy347, &yymsp[-2].minor.yy0);
134185
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134186
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
133334134187
}
133335134188
break;
133336134189
case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
133337134190
{
133338
- yymsp[-8].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy347,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133339
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy347, yymsp[-4].minor.yy442);
134191
+ yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134192
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
133340134193
}
133341134194
break;
133342134195
case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
133343134196
{
133344
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
134197
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133345134198
}
133346134199
break;
133347134200
case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
133348134201
{
133349
- if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
133350
- yymsp[-6].minor.yy347 = yymsp[-4].minor.yy347;
133351
- }else if( yymsp[-4].minor.yy347->nSrc==1 ){
133352
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
133353
- if( yymsp[-6].minor.yy347 ){
133354
- struct SrcList_item *pNew = &yymsp[-6].minor.yy347->a[yymsp[-6].minor.yy347->nSrc-1];
133355
- struct SrcList_item *pOld = yymsp[-4].minor.yy347->a;
134202
+ if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
134203
+ yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
134204
+ }else if( yymsp[-4].minor.yy185->nSrc==1 ){
134205
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134206
+ if( yymsp[-6].minor.yy185 ){
134207
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1];
134208
+ struct SrcList_item *pOld = yymsp[-4].minor.yy185->a;
133356134209
pNew->zName = pOld->zName;
133357134210
pNew->zDatabase = pOld->zDatabase;
133358134211
pNew->pSelect = pOld->pSelect;
133359134212
pOld->zName = pOld->zDatabase = 0;
133360134213
pOld->pSelect = 0;
133361134214
}
133362
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347);
134215
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185);
133363134216
}else{
133364134217
Select *pSubquery;
133365
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347);
133366
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0);
133367
- yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
134218
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185);
134219
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
134220
+ yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
133368134221
}
133369134222
}
133370134223
break;
133371134224
case 105: /* dbnm ::= */
133372134225
case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
133373134226
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
133374134227
break;
133375134228
case 107: /* fullname ::= nm dbnm */
133376
-{yymsp[-1].minor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
134229
+{yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
133377134230
break;
133378134231
case 108: /* joinop ::= COMMA|JOIN */
133379
-{ yymsp[0].minor.yy392 = JT_INNER; }
134232
+{ yymsp[0].minor.yy194 = JT_INNER; }
133380134233
break;
133381134234
case 109: /* joinop ::= JOIN_KW JOIN */
133382
-{yymsp[-1].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
134235
+{yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
133383134236
break;
133384134237
case 110: /* joinop ::= JOIN_KW nm JOIN */
133385
-{yymsp[-2].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
134238
+{yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
133386134239
break;
133387134240
case 111: /* joinop ::= JOIN_KW nm nm JOIN */
133388
-{yymsp[-3].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134241
+{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
133389134242
break;
133390134243
case 112: /* on_opt ::= ON expr */
133391134244
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
133392134245
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
133393134246
case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
133394
-{yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr;}
134247
+{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
133395134248
break;
133396134249
case 113: /* on_opt ::= */
133397134250
case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
133398134251
case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
133399134252
case 196: /* case_else ::= */ yytestcase(yyruleno==196);
133400134253
case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
133401
-{yymsp[1].minor.yy122 = 0;}
134254
+{yymsp[1].minor.yy72 = 0;}
133402134255
break;
133403134256
case 115: /* indexed_opt ::= INDEXED BY nm */
133404134257
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
133405134258
break;
133406134259
case 116: /* indexed_opt ::= NOT INDEXED */
133407134260
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
133408134261
break;
133409134262
case 117: /* using_opt ::= USING LP idlist RP */
133410
-{yymsp[-3].minor.yy180 = yymsp[-1].minor.yy180;}
134263
+{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
133411134264
break;
133412134265
case 118: /* using_opt ::= */
133413134266
case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
133414
-{yymsp[1].minor.yy180 = 0;}
134267
+{yymsp[1].minor.yy254 = 0;}
133415134268
break;
133416134269
case 120: /* orderby_opt ::= ORDER BY sortlist */
133417134270
case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
133418
-{yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;}
134271
+{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
133419134272
break;
133420134273
case 121: /* sortlist ::= sortlist COMMA expr sortorder */
133421134274
{
133422
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
133423
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy392);
134275
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
134276
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
133424134277
}
133425134278
break;
133426134279
case 122: /* sortlist ::= expr sortorder */
133427134280
{
133428
- yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); /*A-overwrites-Y*/
133429
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy392);
134281
+ yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
134282
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
133430134283
}
133431134284
break;
133432134285
case 123: /* sortorder ::= ASC */
133433
-{yymsp[0].minor.yy392 = SQLITE_SO_ASC;}
134286
+{yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
133434134287
break;
133435134288
case 124: /* sortorder ::= DESC */
133436
-{yymsp[0].minor.yy392 = SQLITE_SO_DESC;}
134289
+{yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
133437134290
break;
133438134291
case 125: /* sortorder ::= */
133439
-{yymsp[1].minor.yy392 = SQLITE_SO_UNDEFINED;}
134292
+{yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
133440134293
break;
133441134294
case 130: /* limit_opt ::= */
133442
-{yymsp[1].minor.yy64.pLimit = 0; yymsp[1].minor.yy64.pOffset = 0;}
134295
+{yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
133443134296
break;
133444134297
case 131: /* limit_opt ::= LIMIT expr */
133445
-{yymsp[-1].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yymsp[-1].minor.yy64.pOffset = 0;}
134298
+{yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
133446134299
break;
133447134300
case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
133448
-{yymsp[-3].minor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
134301
+{yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
133449134302
break;
133450134303
case 133: /* limit_opt ::= LIMIT expr COMMA expr */
133451
-{yymsp[-3].minor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
134304
+{yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
133452134305
break;
133453134306
case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
133454134307
{
133455
- sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133456
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
133457
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
134308
+ sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134309
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
134310
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
133458134311
}
133459134312
break;
133460134313
case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
133461134314
{
133462
- sqlite3WithPush(pParse, yymsp[-7].minor.yy331, 1);
133463
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
133464
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
133465
- sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy392);
134315
+ sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
134316
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
134317
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
134318
+ sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
133466134319
}
133467134320
break;
133468134321
case 138: /* setlist ::= setlist COMMA nm EQ expr */
133469134322
{
133470
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
133471
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1);
134323
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134324
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
133472134325
}
133473134326
break;
133474134327
case 139: /* setlist ::= nm EQ expr */
133475134328
{
133476
- yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
133477
- sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1);
134329
+ yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134330
+ sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
133478134331
}
133479
- yymsp[-2].minor.yy442 = yylhsminor.yy442;
134332
+ yymsp[-2].minor.yy148 = yylhsminor.yy148;
133480134333
break;
133481134334
case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
133482134335
{
133483
- sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1);
133484
- sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy392);
134336
+ sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134337
+ sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
133485134338
}
133486134339
break;
133487134340
case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
133488134341
{
133489
- sqlite3WithPush(pParse, yymsp[-6].minor.yy331, 1);
133490
- sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy392);
134342
+ sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134343
+ sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
133491134344
}
133492134345
break;
133493134346
case 145: /* idlist_opt ::= LP idlist RP */
133494
-{yymsp[-2].minor.yy180 = yymsp[-1].minor.yy180;}
134347
+{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
133495134348
break;
133496134349
case 146: /* idlist ::= idlist COMMA nm */
133497
-{yymsp[-2].minor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
134350
+{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
133498134351
break;
133499134352
case 147: /* idlist ::= nm */
133500
-{yymsp[0].minor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134353
+{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
133501134354
break;
133502134355
case 148: /* expr ::= LP expr RP */
133503
-{spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr;}
134356
+{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
133504134357
break;
133505134358
case 149: /* term ::= NULL */
133506134359
case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
133507134360
case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
133508
-{spanExpr(&yymsp[0].minor.yy342,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134361
+{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
133509134362
break;
133510134363
case 150: /* expr ::= ID|INDEXED */
133511134364
case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
133512
-{spanExpr(&yymsp[0].minor.yy342,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134365
+{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
133513134366
break;
133514134367
case 152: /* expr ::= nm DOT nm */
133515134368
{
133516134369
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133517134370
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133518
- spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133519
- yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134371
+ spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134372
+ yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
133520134373
}
133521134374
break;
133522134375
case 153: /* expr ::= nm DOT nm DOT nm */
133523134376
{
133524134377
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
133525134378
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
133526134379
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
133527134380
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
133528
- spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133529
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134381
+ spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134382
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
133530134383
}
133531134384
break;
133532134385
case 156: /* expr ::= VARIABLE */
133533134386
{
133534134387
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
133535
- spanExpr(&yymsp[0].minor.yy342, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
133536
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy342.pExpr);
134388
+ spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134389
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
133537134390
}else{
133538134391
/* When doing a nested parse, one can include terms in an expression
133539134392
** that look like this: #1 #2 ... These terms refer to registers
133540134393
** in the virtual machine. #N is the N-th register. */
133541134394
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
133542134395
assert( t.n>=2 );
133543
- spanSet(&yymsp[0].minor.yy342, &t, &t);
134396
+ spanSet(&yymsp[0].minor.yy190, &t, &t);
133544134397
if( pParse->nested==0 ){
133545134398
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
133546
- yymsp[0].minor.yy342.pExpr = 0;
134399
+ yymsp[0].minor.yy190.pExpr = 0;
133547134400
}else{
133548
- yymsp[0].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
133549
- if( yymsp[0].minor.yy342.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy342.pExpr->iTable);
134401
+ yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
134402
+ if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
133550134403
}
133551134404
}
133552134405
}
133553134406
break;
133554134407
case 157: /* expr ::= expr COLLATE ID|STRING */
133555134408
{
133556
- yymsp[-2].minor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0, 1);
133557
- yymsp[-2].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134409
+ yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134410
+ yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133558134411
}
133559134412
break;
133560134413
case 158: /* expr ::= CAST LP expr AS typetoken RP */
133561134414
{
133562
- spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133563
- yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
134415
+ spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134416
+ yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
133564134417
}
133565134418
break;
133566134419
case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
133567134420
{
133568
- if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134421
+ if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
133569134422
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
133570134423
}
133571
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
133572
- spanSet(&yylhsminor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
133573
- if( yymsp[-2].minor.yy392==SF_Distinct && yylhsminor.yy342.pExpr ){
133574
- yylhsminor.yy342.pExpr->flags |= EP_Distinct;
134424
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
134425
+ spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
134426
+ if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){
134427
+ yylhsminor.yy190.pExpr->flags |= EP_Distinct;
133575134428
}
133576134429
}
133577
- yymsp[-4].minor.yy342 = yylhsminor.yy342;
134430
+ yymsp[-4].minor.yy190 = yylhsminor.yy190;
133578134431
break;
133579134432
case 160: /* expr ::= ID|INDEXED LP STAR RP */
133580134433
{
133581
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
133582
- spanSet(&yylhsminor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134434
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134435
+ spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
133583134436
}
133584
- yymsp[-3].minor.yy342 = yylhsminor.yy342;
134437
+ yymsp[-3].minor.yy190 = yylhsminor.yy190;
133585134438
break;
133586134439
case 161: /* term ::= CTIME_KW */
133587134440
{
133588
- yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
133589
- spanSet(&yylhsminor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134441
+ yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134442
+ spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
133590134443
}
133591
- yymsp[0].minor.yy342 = yylhsminor.yy342;
134444
+ yymsp[0].minor.yy190 = yylhsminor.yy190;
133592134445
break;
133593134446
case 162: /* expr ::= expr AND expr */
133594134447
case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
133595134448
case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
133596134449
case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
133597134450
case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
133598134451
case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
133599134452
case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
133600134453
case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
133601
-{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
134454
+{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
133602134455
break;
133603134456
case 170: /* likeop ::= LIKE_KW|MATCH */
133604
-{yymsp[0].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy318.bNot = 0;/*A-overwrites-X*/}
134457
+{yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
133605134458
break;
133606134459
case 171: /* likeop ::= NOT LIKE_KW|MATCH */
133607
-{yymsp[-1].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy318.bNot = 1;}
134460
+{yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
133608134461
break;
133609134462
case 172: /* expr ::= expr likeop expr */
133610134463
{
133611134464
ExprList *pList;
133612
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
133613
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
133614
- yymsp[-2].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
133615
- exprNot(pParse, yymsp[-1].minor.yy318.bNot, &yymsp[-2].minor.yy342);
133616
- yymsp[-2].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133617
- if( yymsp[-2].minor.yy342.pExpr ) yymsp[-2].minor.yy342.pExpr->flags |= EP_InfixFunc;
134465
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134466
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134467
+ yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
134468
+ exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134469
+ yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134470
+ if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
133618134471
}
133619134472
break;
133620134473
case 173: /* expr ::= expr likeop expr ESCAPE expr */
133621134474
{
133622134475
ExprList *pList;
133623
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133624
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
133625
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133626
- yymsp[-4].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
133627
- exprNot(pParse, yymsp[-3].minor.yy318.bNot, &yymsp[-4].minor.yy342);
133628
- yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
133629
- if( yymsp[-4].minor.yy342.pExpr ) yymsp[-4].minor.yy342.pExpr->flags |= EP_InfixFunc;
134476
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134477
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134478
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134479
+ yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy392.eOperator);
134480
+ exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134481
+ yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134482
+ if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
133630134483
}
133631134484
break;
133632134485
case 174: /* expr ::= expr ISNULL|NOTNULL */
133633
-{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
134486
+{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
133634134487
break;
133635134488
case 175: /* expr ::= expr NOT NULL */
133636
-{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
134489
+{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
133637134490
break;
133638134491
case 176: /* expr ::= expr IS expr */
133639134492
{
133640
- spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
133641
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-2].minor.yy342.pExpr, TK_ISNULL);
134493
+ spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134494
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
133642134495
}
133643134496
break;
133644134497
case 177: /* expr ::= expr IS NOT expr */
133645134498
{
133646
- spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
133647
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-3].minor.yy342.pExpr, TK_NOTNULL);
134499
+ spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134500
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
133648134501
}
133649134502
break;
133650134503
case 178: /* expr ::= NOT expr */
133651134504
case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
133652
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134505
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133653134506
break;
133654134507
case 180: /* expr ::= MINUS expr */
133655
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134508
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133656134509
break;
133657134510
case 181: /* expr ::= PLUS expr */
133658
-{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134511
+{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
133659134512
break;
133660134513
case 182: /* between_op ::= BETWEEN */
133661134514
case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
133662
-{yymsp[0].minor.yy392 = 0;}
134515
+{yymsp[0].minor.yy194 = 0;}
133663134516
break;
133664134517
case 184: /* expr ::= expr between_op expr AND expr */
133665134518
{
133666
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133667
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
133668
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133669
- if( yymsp[-4].minor.yy342.pExpr ){
133670
- yymsp[-4].minor.yy342.pExpr->x.pList = pList;
134519
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134520
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134521
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134522
+ if( yymsp[-4].minor.yy190.pExpr ){
134523
+ yymsp[-4].minor.yy190.pExpr->x.pList = pList;
133671134524
}else{
133672134525
sqlite3ExprListDelete(pParse->db, pList);
133673134526
}
133674
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133675
- yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
134527
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134528
+ yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
133676134529
}
133677134530
break;
133678134531
case 187: /* expr ::= expr in_op LP exprlist RP */
133679134532
{
133680
- if( yymsp[-1].minor.yy442==0 ){
134533
+ if( yymsp[-1].minor.yy148==0 ){
133681134534
/* Expressions of the form
133682134535
**
133683134536
** expr1 IN ()
133684134537
** expr1 NOT IN ()
133685134538
**
133686134539
** simplify to constants 0 (false) and 1 (true), respectively,
133687134540
** regardless of the value of expr1.
133688134541
*/
133689
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);
133690
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);
133691
- }else if( yymsp[-1].minor.yy442->nExpr==1 ){
134542
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);
134543
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy194]);
134544
+ }else if( yymsp[-1].minor.yy148->nExpr==1 ){
133692134545
/* Expressions of the form:
133693134546
**
133694134547
** expr1 IN (?1)
133695134548
** expr1 NOT IN (?2)
133696134549
**
@@ -133703,417 +134556,421 @@
133703134556
** But, the RHS of the == or <> is marked with the EP_Generic flag
133704134557
** so that it may not contribute to the computation of comparison
133705134558
** affinity or the collating sequence to use for comparison. Otherwise,
133706134559
** the semantics would be subtly different from IN or NOT IN.
133707134560
*/
133708
- Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr;
133709
- yymsp[-1].minor.yy442->a[0].pExpr = 0;
133710
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
134561
+ Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;
134562
+ yymsp[-1].minor.yy148->a[0].pExpr = 0;
134563
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
133711134564
/* pRHS cannot be NULL because a malloc error would have been detected
133712134565
** before now and control would have never reached this point */
133713134566
if( ALWAYS(pRHS) ){
133714134567
pRHS->flags &= ~EP_Collate;
133715134568
pRHS->flags |= EP_Generic;
133716134569
}
133717
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy392 ? TK_NE : TK_EQ, yymsp[-4].minor.yy342.pExpr, pRHS, 0);
133718
- }else{
133719
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133720
- if( yymsp[-4].minor.yy342.pExpr ){
133721
- yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;
133722
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
133723
- }else{
133724
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
133725
- }
133726
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133727
- }
133728
- yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134570
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS, 0);
134571
+ }else{
134572
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134573
+ if( yymsp[-4].minor.yy190.pExpr ){
134574
+ yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;
134575
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134576
+ }else{
134577
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134578
+ }
134579
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134580
+ }
134581
+ yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133729134582
}
133730134583
break;
133731134584
case 188: /* expr ::= LP select RP */
133732134585
{
133733
- spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133734
- yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
133735
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy342.pExpr, yymsp[-1].minor.yy159);
134586
+ spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134587
+ yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134588
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
133736134589
}
133737134590
break;
133738134591
case 189: /* expr ::= expr in_op LP select RP */
133739134592
{
133740
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
133741
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy342.pExpr, yymsp[-1].minor.yy159);
133742
- exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342);
133743
- yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
133744
- }
133745
- break;
133746
- case 190: /* expr ::= expr in_op nm dbnm */
133747
-{
133748
- SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
134593
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134594
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134595
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134596
+ yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134597
+ }
134598
+ break;
134599
+ case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
134600
+{
134601
+ SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
133749134602
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
133750
- yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
133751
- sqlite3PExprAddSelect(pParse, yymsp[-3].minor.yy342.pExpr, pSelect);
133752
- exprNot(pParse, yymsp[-2].minor.yy392, &yymsp[-3].minor.yy342);
133753
- yymsp[-3].minor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
134603
+ if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134604
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134605
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134606
+ exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134607
+ yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
133754134608
}
133755134609
break;
133756134610
case 191: /* expr ::= EXISTS LP select RP */
133757134611
{
133758134612
Expr *p;
133759
- spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
133760
- p = yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
133761
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy159);
134613
+ spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134614
+ p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134615
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
133762134616
}
133763134617
break;
133764134618
case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
133765134619
{
133766
- spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
133767
- yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0);
133768
- if( yymsp[-4].minor.yy342.pExpr ){
133769
- yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442;
133770
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr);
134620
+ spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134621
+ yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134622
+ if( yymsp[-4].minor.yy190.pExpr ){
134623
+ yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
134624
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
133771134625
}else{
133772
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
133773
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122);
134626
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134627
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
133774134628
}
133775134629
}
133776134630
break;
133777134631
case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
133778134632
{
133779
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
133780
- yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
134633
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134634
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
133781134635
}
133782134636
break;
133783134637
case 194: /* case_exprlist ::= WHEN expr THEN expr */
133784134638
{
133785
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
133786
- yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy342.pExpr);
134639
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134640
+ yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
133787134641
}
133788134642
break;
133789134643
case 197: /* case_operand ::= expr */
133790
-{yymsp[0].minor.yy122 = yymsp[0].minor.yy342.pExpr; /*A-overwrites-X*/}
134644
+{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
133791134645
break;
133792134646
case 200: /* nexprlist ::= nexprlist COMMA expr */
133793
-{yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
134647
+{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
133794134648
break;
133795134649
case 201: /* nexprlist ::= expr */
133796
-{yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr); /*A-overwrites-Y*/}
134650
+{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
133797134651
break;
133798
- case 202: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134652
+ case 203: /* paren_exprlist ::= LP exprlist RP */
134653
+ case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
134654
+{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134655
+ break;
134656
+ case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
133799134657
{
133800134658
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
133801
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
133802
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
133803
-}
133804
- break;
133805
- case 203: /* uniqueflag ::= UNIQUE */
133806
- case 244: /* raisetype ::= ABORT */ yytestcase(yyruleno==244);
133807
-{yymsp[0].minor.yy392 = OE_Abort;}
133808
- break;
133809
- case 204: /* uniqueflag ::= */
133810
-{yymsp[1].minor.yy392 = OE_None;}
133811
- break;
133812
- case 206: /* eidlist_opt ::= LP eidlist RP */
133813
-{yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;}
133814
- break;
133815
- case 207: /* eidlist ::= eidlist COMMA nm collate sortorder */
133816
-{
133817
- yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392);
133818
-}
133819
- break;
133820
- case 208: /* eidlist ::= nm collate sortorder */
133821
-{
133822
- yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); /*A-overwrites-Y*/
133823
-}
133824
- break;
133825
- case 211: /* cmd ::= DROP INDEX ifexists fullname */
133826
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
133827
- break;
133828
- case 212: /* cmd ::= VACUUM */
133829
- case 213: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==213);
134659
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134660
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134661
+}
134662
+ break;
134663
+ case 205: /* uniqueflag ::= UNIQUE */
134664
+ case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
134665
+{yymsp[0].minor.yy194 = OE_Abort;}
134666
+ break;
134667
+ case 206: /* uniqueflag ::= */
134668
+{yymsp[1].minor.yy194 = OE_None;}
134669
+ break;
134670
+ case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
134671
+{
134672
+ yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134673
+}
134674
+ break;
134675
+ case 210: /* eidlist ::= nm collate sortorder */
134676
+{
134677
+ yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134678
+}
134679
+ break;
134680
+ case 213: /* cmd ::= DROP INDEX ifexists fullname */
134681
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134682
+ break;
134683
+ case 214: /* cmd ::= VACUUM */
134684
+ case 215: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==215);
133830134685
{sqlite3Vacuum(pParse);}
133831134686
break;
133832
- case 214: /* cmd ::= PRAGMA nm dbnm */
134687
+ case 216: /* cmd ::= PRAGMA nm dbnm */
133833134688
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
133834134689
break;
133835
- case 215: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134690
+ case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
133836134691
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
133837134692
break;
133838
- case 216: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134693
+ case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
133839134694
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
133840134695
break;
133841
- case 217: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134696
+ case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
133842134697
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
133843134698
break;
133844
- case 218: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134699
+ case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
133845134700
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
133846134701
break;
133847
- case 221: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134702
+ case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
133848134703
{
133849134704
Token all;
133850134705
all.z = yymsp[-3].minor.yy0.z;
133851134706
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
133852
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
134707
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
133853134708
}
133854134709
break;
133855
- case 222: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134710
+ case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
133856134711
{
133857
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
134712
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
133858134713
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
133859134714
}
133860134715
break;
133861
- case 223: /* trigger_time ::= BEFORE */
133862
-{ yymsp[0].minor.yy392 = TK_BEFORE; }
133863
- break;
133864
- case 224: /* trigger_time ::= AFTER */
133865
-{ yymsp[0].minor.yy392 = TK_AFTER; }
133866
- break;
133867
- case 225: /* trigger_time ::= INSTEAD OF */
133868
-{ yymsp[-1].minor.yy392 = TK_INSTEAD;}
133869
- break;
133870
- case 226: /* trigger_time ::= */
133871
-{ yymsp[1].minor.yy392 = TK_BEFORE; }
133872
- break;
133873
- case 227: /* trigger_event ::= DELETE|INSERT */
133874
- case 228: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==228);
133875
-{yymsp[0].minor.yy410.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy410.b = 0;}
133876
- break;
133877
- case 229: /* trigger_event ::= UPDATE OF idlist */
133878
-{yymsp[-2].minor.yy410.a = TK_UPDATE; yymsp[-2].minor.yy410.b = yymsp[0].minor.yy180;}
133879
- break;
133880
- case 230: /* when_clause ::= */
133881
- case 249: /* key_opt ::= */ yytestcase(yyruleno==249);
133882
-{ yymsp[1].minor.yy122 = 0; }
133883
- break;
133884
- case 231: /* when_clause ::= WHEN expr */
133885
- case 250: /* key_opt ::= KEY expr */ yytestcase(yyruleno==250);
133886
-{ yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr; }
133887
- break;
133888
- case 232: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
133889
-{
133890
- assert( yymsp[-2].minor.yy327!=0 );
133891
- yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
133892
- yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
133893
-}
133894
- break;
133895
- case 233: /* trigger_cmd_list ::= trigger_cmd SEMI */
133896
-{
133897
- assert( yymsp[-1].minor.yy327!=0 );
133898
- yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
133899
-}
133900
- break;
133901
- case 234: /* trnm ::= nm DOT nm */
134716
+ case 225: /* trigger_time ::= BEFORE */
134717
+{ yymsp[0].minor.yy194 = TK_BEFORE; }
134718
+ break;
134719
+ case 226: /* trigger_time ::= AFTER */
134720
+{ yymsp[0].minor.yy194 = TK_AFTER; }
134721
+ break;
134722
+ case 227: /* trigger_time ::= INSTEAD OF */
134723
+{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
134724
+ break;
134725
+ case 228: /* trigger_time ::= */
134726
+{ yymsp[1].minor.yy194 = TK_BEFORE; }
134727
+ break;
134728
+ case 229: /* trigger_event ::= DELETE|INSERT */
134729
+ case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
134730
+{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134731
+ break;
134732
+ case 231: /* trigger_event ::= UPDATE OF idlist */
134733
+{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134734
+ break;
134735
+ case 232: /* when_clause ::= */
134736
+ case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
134737
+{ yymsp[1].minor.yy72 = 0; }
134738
+ break;
134739
+ case 233: /* when_clause ::= WHEN expr */
134740
+ case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
134741
+{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134742
+ break;
134743
+ case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134744
+{
134745
+ assert( yymsp[-2].minor.yy145!=0 );
134746
+ yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134747
+ yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134748
+}
134749
+ break;
134750
+ case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
134751
+{
134752
+ assert( yymsp[-1].minor.yy145!=0 );
134753
+ yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134754
+}
134755
+ break;
134756
+ case 236: /* trnm ::= nm DOT nm */
133902134757
{
133903134758
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
133904134759
sqlite3ErrorMsg(pParse,
133905134760
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
133906134761
"statements within triggers");
133907134762
}
133908134763
break;
133909
- case 235: /* tridxby ::= INDEXED BY nm */
134764
+ case 237: /* tridxby ::= INDEXED BY nm */
133910134765
{
133911134766
sqlite3ErrorMsg(pParse,
133912134767
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
133913134768
"within triggers");
133914134769
}
133915134770
break;
133916
- case 236: /* tridxby ::= NOT INDEXED */
134771
+ case 238: /* tridxby ::= NOT INDEXED */
133917134772
{
133918134773
sqlite3ErrorMsg(pParse,
133919134774
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
133920134775
"within triggers");
133921134776
}
133922134777
break;
133923
- case 237: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
133924
-{yymsp[-6].minor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy392);}
133925
- break;
133926
- case 238: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
133927
-{yymsp[-4].minor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy159, yymsp[-4].minor.yy392);/*A-overwrites-R*/}
133928
- break;
133929
- case 239: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
133930
-{yymsp[-4].minor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
133931
- break;
133932
- case 240: /* trigger_cmd ::= select */
133933
-{yymsp[0].minor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); /*A-overwrites-X*/}
133934
- break;
133935
- case 241: /* expr ::= RAISE LP IGNORE RP */
133936
-{
133937
- spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133938
- yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
133939
- if( yymsp[-3].minor.yy342.pExpr ){
133940
- yymsp[-3].minor.yy342.pExpr->affinity = OE_Ignore;
133941
- }
133942
-}
133943
- break;
133944
- case 242: /* expr ::= RAISE LP raisetype COMMA nm RP */
133945
-{
133946
- spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
133947
- yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
133948
- if( yymsp[-5].minor.yy342.pExpr ) {
133949
- yymsp[-5].minor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
133950
- }
133951
-}
133952
- break;
133953
- case 243: /* raisetype ::= ROLLBACK */
133954
-{yymsp[0].minor.yy392 = OE_Rollback;}
133955
- break;
133956
- case 245: /* raisetype ::= FAIL */
133957
-{yymsp[0].minor.yy392 = OE_Fail;}
133958
- break;
133959
- case 246: /* cmd ::= DROP TRIGGER ifexists fullname */
133960
-{
133961
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
133962
-}
133963
- break;
133964
- case 247: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
133965
-{
133966
- sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
133967
-}
133968
- break;
133969
- case 248: /* cmd ::= DETACH database_kw_opt expr */
133970
-{
133971
- sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
133972
-}
133973
- break;
133974
- case 251: /* cmd ::= REINDEX */
134778
+ case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134779
+{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134780
+ break;
134781
+ case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134782
+{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
134783
+ break;
134784
+ case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134785
+{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134786
+ break;
134787
+ case 242: /* trigger_cmd ::= select */
134788
+{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134789
+ break;
134790
+ case 243: /* expr ::= RAISE LP IGNORE RP */
134791
+{
134792
+ spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134793
+ yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134794
+ if( yymsp[-3].minor.yy190.pExpr ){
134795
+ yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134796
+ }
134797
+}
134798
+ break;
134799
+ case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
134800
+{
134801
+ spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134802
+ yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134803
+ if( yymsp[-5].minor.yy190.pExpr ) {
134804
+ yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134805
+ }
134806
+}
134807
+ break;
134808
+ case 245: /* raisetype ::= ROLLBACK */
134809
+{yymsp[0].minor.yy194 = OE_Rollback;}
134810
+ break;
134811
+ case 247: /* raisetype ::= FAIL */
134812
+{yymsp[0].minor.yy194 = OE_Fail;}
134813
+ break;
134814
+ case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
134815
+{
134816
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134817
+}
134818
+ break;
134819
+ case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134820
+{
134821
+ sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134822
+}
134823
+ break;
134824
+ case 250: /* cmd ::= DETACH database_kw_opt expr */
134825
+{
134826
+ sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134827
+}
134828
+ break;
134829
+ case 253: /* cmd ::= REINDEX */
133975134830
{sqlite3Reindex(pParse, 0, 0);}
133976134831
break;
133977
- case 252: /* cmd ::= REINDEX nm dbnm */
134832
+ case 254: /* cmd ::= REINDEX nm dbnm */
133978134833
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133979134834
break;
133980
- case 253: /* cmd ::= ANALYZE */
134835
+ case 255: /* cmd ::= ANALYZE */
133981134836
{sqlite3Analyze(pParse, 0, 0);}
133982134837
break;
133983
- case 254: /* cmd ::= ANALYZE nm dbnm */
134838
+ case 256: /* cmd ::= ANALYZE nm dbnm */
133984134839
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
133985134840
break;
133986
- case 255: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134841
+ case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
133987134842
{
133988
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
134843
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
133989134844
}
133990134845
break;
133991
- case 256: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134846
+ case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
133992134847
{
133993134848
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
133994134849
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
133995134850
}
133996134851
break;
133997
- case 257: /* add_column_fullname ::= fullname */
134852
+ case 259: /* add_column_fullname ::= fullname */
133998134853
{
133999134854
disableLookaside(pParse);
134000
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
134855
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134001134856
}
134002134857
break;
134003
- case 258: /* cmd ::= create_vtab */
134858
+ case 260: /* cmd ::= create_vtab */
134004134859
{sqlite3VtabFinishParse(pParse,0);}
134005134860
break;
134006
- case 259: /* cmd ::= create_vtab LP vtabarglist RP */
134861
+ case 261: /* cmd ::= create_vtab LP vtabarglist RP */
134007134862
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134008134863
break;
134009
- case 260: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134864
+ case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134010134865
{
134011
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
134866
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134012134867
}
134013134868
break;
134014
- case 261: /* vtabarg ::= */
134869
+ case 263: /* vtabarg ::= */
134015134870
{sqlite3VtabArgInit(pParse);}
134016134871
break;
134017
- case 262: /* vtabargtoken ::= ANY */
134018
- case 263: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==263);
134019
- case 264: /* lp ::= LP */ yytestcase(yyruleno==264);
134872
+ case 264: /* vtabargtoken ::= ANY */
134873
+ case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134874
+ case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
134020134875
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134021134876
break;
134022
- case 265: /* with ::= */
134023
-{yymsp[1].minor.yy331 = 0;}
134024
- break;
134025
- case 266: /* with ::= WITH wqlist */
134026
-{ yymsp[-1].minor.yy331 = yymsp[0].minor.yy331; }
134027
- break;
134028
- case 267: /* with ::= WITH RECURSIVE wqlist */
134029
-{ yymsp[-2].minor.yy331 = yymsp[0].minor.yy331; }
134030
- break;
134031
- case 268: /* wqlist ::= nm eidlist_opt AS LP select RP */
134032
-{
134033
- yymsp[-5].minor.yy331 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159); /*A-overwrites-X*/
134034
-}
134035
- break;
134036
- case 269: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134037
-{
134038
- yymsp[-7].minor.yy331 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy331, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159);
134877
+ case 267: /* with ::= */
134878
+{yymsp[1].minor.yy285 = 0;}
134879
+ break;
134880
+ case 268: /* with ::= WITH wqlist */
134881
+{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134882
+ break;
134883
+ case 269: /* with ::= WITH RECURSIVE wqlist */
134884
+{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134885
+ break;
134886
+ case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
134887
+{
134888
+ yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134889
+}
134890
+ break;
134891
+ case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134892
+{
134893
+ yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134039134894
}
134040134895
break;
134041134896
default:
134042
- /* (270) input ::= cmdlist */ yytestcase(yyruleno==270);
134043
- /* (271) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==271);
134044
- /* (272) cmdlist ::= ecmd */ yytestcase(yyruleno==272);
134045
- /* (273) ecmd ::= SEMI */ yytestcase(yyruleno==273);
134046
- /* (274) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==274);
134047
- /* (275) explain ::= */ yytestcase(yyruleno==275);
134048
- /* (276) trans_opt ::= */ yytestcase(yyruleno==276);
134049
- /* (277) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==277);
134050
- /* (278) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==278);
134051
- /* (279) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==279);
134052
- /* (280) savepoint_opt ::= */ yytestcase(yyruleno==280);
134053
- /* (281) cmd ::= create_table create_table_args */ yytestcase(yyruleno==281);
134054
- /* (282) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==282);
134055
- /* (283) columnlist ::= columnname carglist */ yytestcase(yyruleno==283);
134056
- /* (284) nm ::= ID|INDEXED */ yytestcase(yyruleno==284);
134057
- /* (285) nm ::= STRING */ yytestcase(yyruleno==285);
134058
- /* (286) nm ::= JOIN_KW */ yytestcase(yyruleno==286);
134059
- /* (287) typetoken ::= typename */ yytestcase(yyruleno==287);
134060
- /* (288) typename ::= ID|STRING */ yytestcase(yyruleno==288);
134061
- /* (289) signed ::= plus_num */ yytestcase(yyruleno==289);
134062
- /* (290) signed ::= minus_num */ yytestcase(yyruleno==290);
134063
- /* (291) carglist ::= carglist ccons */ yytestcase(yyruleno==291);
134064
- /* (292) carglist ::= */ yytestcase(yyruleno==292);
134065
- /* (293) ccons ::= NULL onconf */ yytestcase(yyruleno==293);
134066
- /* (294) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==294);
134067
- /* (295) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==295);
134068
- /* (296) conslist ::= tcons */ yytestcase(yyruleno==296);
134069
- /* (297) tconscomma ::= */ yytestcase(yyruleno==297);
134070
- /* (298) defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==298);
134071
- /* (299) resolvetype ::= raisetype */ yytestcase(yyruleno==299);
134072
- /* (300) selectnowith ::= oneselect */ yytestcase(yyruleno==300);
134073
- /* (301) oneselect ::= values */ yytestcase(yyruleno==301);
134074
- /* (302) sclp ::= selcollist COMMA */ yytestcase(yyruleno==302);
134075
- /* (303) as ::= ID|STRING */ yytestcase(yyruleno==303);
134076
- /* (304) expr ::= term */ yytestcase(yyruleno==304);
134077
- /* (305) exprlist ::= nexprlist */ yytestcase(yyruleno==305);
134078
- /* (306) nmnum ::= plus_num */ yytestcase(yyruleno==306);
134079
- /* (307) nmnum ::= nm */ yytestcase(yyruleno==307);
134080
- /* (308) nmnum ::= ON */ yytestcase(yyruleno==308);
134081
- /* (309) nmnum ::= DELETE */ yytestcase(yyruleno==309);
134082
- /* (310) nmnum ::= DEFAULT */ yytestcase(yyruleno==310);
134083
- /* (311) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==311);
134084
- /* (312) foreach_clause ::= */ yytestcase(yyruleno==312);
134085
- /* (313) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==313);
134086
- /* (314) trnm ::= nm */ yytestcase(yyruleno==314);
134087
- /* (315) tridxby ::= */ yytestcase(yyruleno==315);
134088
- /* (316) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==316);
134089
- /* (317) database_kw_opt ::= */ yytestcase(yyruleno==317);
134090
- /* (318) kwcolumn_opt ::= */ yytestcase(yyruleno==318);
134091
- /* (319) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==319);
134092
- /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
134093
- /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
134094
- /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
134095
- /* (323) anylist ::= */ yytestcase(yyruleno==323);
134096
- /* (324) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==324);
134097
- /* (325) anylist ::= anylist ANY */ yytestcase(yyruleno==325);
134897
+ /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134898
+ /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134899
+ /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134900
+ /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134901
+ /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134902
+ /* (277) explain ::= */ yytestcase(yyruleno==277);
134903
+ /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134904
+ /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134905
+ /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134906
+ /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134907
+ /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134908
+ /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134909
+ /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134910
+ /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134911
+ /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134912
+ /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134913
+ /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134914
+ /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134915
+ /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134916
+ /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134917
+ /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134918
+ /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134919
+ /* (294) carglist ::= */ yytestcase(yyruleno==294);
134920
+ /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134921
+ /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134922
+ /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134923
+ /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134924
+ /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134925
+ /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134926
+ /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134927
+ /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134928
+ /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134929
+ /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134930
+ /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134931
+ /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134932
+ /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134933
+ /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134934
+ /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134935
+ /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134936
+ /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134937
+ /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134938
+ /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134939
+ /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134940
+ /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134941
+ /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134942
+ /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134943
+ /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134944
+ /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134945
+ /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134946
+ /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134947
+ /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134948
+ /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134949
+ /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134950
+ /* (325) anylist ::= */ yytestcase(yyruleno==325);
134951
+ /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134952
+ /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
134098134953
break;
134099134954
/********** End reduce actions ************************************************/
134100134955
};
134101134956
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134102134957
yygoto = yyRuleInfo[yyruleno].lhs;
134103134958
yysize = yyRuleInfo[yyruleno].nrhs;
134104134959
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
134105134960
if( yyact <= YY_MAX_SHIFTREDUCE ){
134106
- if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134107
- yypParser->yyidx -= yysize - 1;
134961
+ if( yyact>YY_MAX_SHIFT ){
134962
+ yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134963
+ }
134108134964
yymsp -= yysize-1;
134965
+ yypParser->yytos = yymsp;
134109134966
yymsp->stateno = (YYACTIONTYPE)yyact;
134110134967
yymsp->major = (YYCODETYPE)yygoto;
134111134968
yyTraceShift(yypParser, yyact);
134112134969
}else{
134113134970
assert( yyact == YY_ACCEPT_ACTION );
134114
- yypParser->yyidx -= yysize;
134971
+ yypParser->yytos -= yysize;
134115134972
yy_accept(yypParser);
134116134973
}
134117134974
}
134118134975
134119134976
/*
@@ -134127,11 +134984,11 @@
134127134984
#ifndef NDEBUG
134128134985
if( yyTraceFILE ){
134129134986
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
134130134987
}
134131134988
#endif
134132
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
134989
+ while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
134133134990
/* Here code is inserted which will be executed whenever the
134134134991
** parser fails */
134135134992
/************ Begin %parse_failure code ***************************************/
134136134993
/************ End %parse_failure code *****************************************/
134137134994
sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134167,11 +135024,14 @@
134167135024
#ifndef NDEBUG
134168135025
if( yyTraceFILE ){
134169135026
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
134170135027
}
134171135028
#endif
134172
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
135029
+#ifndef YYNOERRORRECOVERY
135030
+ yypParser->yyerrcnt = -1;
135031
+#endif
135032
+ assert( yypParser->yytos==yypParser->yystack );
134173135033
/* Here code is inserted which will be executed whenever the
134174135034
** parser accepts */
134175135035
/*********** Begin %parse_accept code *****************************************/
134176135036
/*********** End %parse_accept code *******************************************/
134177135037
sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134210,32 +135070,12 @@
134210135070
#ifdef YYERRORSYMBOL
134211135071
int yyerrorhit = 0; /* True if yymajor has invoked an error */
134212135072
#endif
134213135073
yyParser *yypParser; /* The parser */
134214135074
134215
- /* (re)initialize the parser, if necessary */
134216135075
yypParser = (yyParser*)yyp;
134217
- if( yypParser->yyidx<0 ){
134218
-#if YYSTACKDEPTH<=0
134219
- if( yypParser->yystksz <=0 ){
134220
- yyStackOverflow(yypParser);
134221
- return;
134222
- }
134223
-#endif
134224
- yypParser->yyidx = 0;
134225
-#ifndef YYNOERRORRECOVERY
134226
- yypParser->yyerrcnt = -1;
134227
-#endif
134228
- yypParser->yystack[0].stateno = 0;
134229
- yypParser->yystack[0].major = 0;
134230
-#ifndef NDEBUG
134231
- if( yyTraceFILE ){
134232
- fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
134233
- yyTracePrompt);
134234
- }
134235
-#endif
134236
- }
135076
+ assert( yypParser->yytos!=0 );
134237135077
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
134238135078
yyendofinput = (yymajor==0);
134239135079
#endif
134240135080
sqlite3ParserARG_STORE;
134241135081
@@ -134246,11 +135086,10 @@
134246135086
#endif
134247135087
134248135088
do{
134249135089
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
134250135090
if( yyact <= YY_MAX_SHIFTREDUCE ){
134251
- if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134252135091
yy_shift(yypParser,yyact,yymajor,yyminor);
134253135092
#ifndef YYNOERRORRECOVERY
134254135093
yypParser->yyerrcnt--;
134255135094
#endif
134256135095
yymajor = YYNOCODE;
@@ -134288,11 +135127,11 @@
134288135127
**
134289135128
*/
134290135129
if( yypParser->yyerrcnt<0 ){
134291135130
yy_syntax_error(yypParser,yymajor,yyminor);
134292135131
}
134293
- yymx = yypParser->yystack[yypParser->yyidx].major;
135132
+ yymx = yypParser->yytos->major;
134294135133
if( yymx==YYERRORSYMBOL || yyerrorhit ){
134295135134
#ifndef NDEBUG
134296135135
if( yyTraceFILE ){
134297135136
fprintf(yyTraceFILE,"%sDiscard input token %s\n",
134298135137
yyTracePrompt,yyTokenName[yymajor]);
@@ -134299,22 +135138,24 @@
134299135138
}
134300135139
#endif
134301135140
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
134302135141
yymajor = YYNOCODE;
134303135142
}else{
134304
- while(
134305
- yypParser->yyidx >= 0 &&
134306
- yymx != YYERRORSYMBOL &&
134307
- (yyact = yy_find_reduce_action(
134308
- yypParser->yystack[yypParser->yyidx].stateno,
135143
+ while( yypParser->yytos >= &yypParser->yystack
135144
+ && yymx != YYERRORSYMBOL
135145
+ && (yyact = yy_find_reduce_action(
135146
+ yypParser->yytos->stateno,
134309135147
YYERRORSYMBOL)) >= YY_MIN_REDUCE
134310135148
){
134311135149
yy_pop_parser_stack(yypParser);
134312135150
}
134313
- if( yypParser->yyidx < 0 || yymajor==0 ){
135151
+ if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
134314135152
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134315135153
yy_parse_failed(yypParser);
135154
+#ifndef YYNOERRORRECOVERY
135155
+ yypParser->yyerrcnt = -1;
135156
+#endif
134316135157
yymajor = YYNOCODE;
134317135158
}else if( yymx!=YYERRORSYMBOL ){
134318135159
yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
134319135160
}
134320135161
}
@@ -134347,22 +135188,27 @@
134347135188
}
134348135189
yypParser->yyerrcnt = 3;
134349135190
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
134350135191
if( yyendofinput ){
134351135192
yy_parse_failed(yypParser);
135193
+#ifndef YYNOERRORRECOVERY
135194
+ yypParser->yyerrcnt = -1;
135195
+#endif
134352135196
}
134353135197
yymajor = YYNOCODE;
134354135198
#endif
134355135199
}
134356
- }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
135200
+ }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
134357135201
#ifndef NDEBUG
134358135202
if( yyTraceFILE ){
134359
- int i;
135203
+ yyStackEntry *i;
135204
+ char cDiv = '[';
134360135205
fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
134361
- for(i=1; i<=yypParser->yyidx; i++)
134362
- fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
134363
- yyTokenName[yypParser->yystack[i].major]);
135206
+ for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
135207
+ fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
135208
+ cDiv = ' ';
135209
+ }
134364135210
fprintf(yyTraceFILE,"]\n");
134365135211
}
134366135212
#endif
134367135213
return;
134368135214
}
@@ -136680,10 +137526,13 @@
136680137526
}
136681137527
if( !sqlite3SafetyCheckSickOrOk(db) ){
136682137528
return SQLITE_MISUSE_BKPT;
136683137529
}
136684137530
sqlite3_mutex_enter(db->mutex);
137531
+ if( db->mTrace & SQLITE_TRACE_CLOSE ){
137532
+ db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);
137533
+ }
136685137534
136686137535
/* Force xDisconnect calls on all virtual tables */
136687137536
disconnectAllVtab(db);
136688137537
136689137538
/* If a transaction is open, the disconnectAllVtab() call above
@@ -137448,11 +138297,12 @@
137448138297
**
137449138298
** A NULL trace function means that no tracing is executes. A non-NULL
137450138299
** trace is a pointer to a function that is invoked at the start of each
137451138300
** SQL statement.
137452138301
*/
137453
-SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
138302
+#ifndef SQLITE_OMIT_DEPRECATED
138303
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){
137454138304
void *pOld;
137455138305
137456138306
#ifdef SQLITE_ENABLE_API_ARMOR
137457138307
if( !sqlite3SafetyCheckOk(db) ){
137458138308
(void)SQLITE_MISUSE_BKPT;
@@ -137459,15 +138309,40 @@
137459138309
return 0;
137460138310
}
137461138311
#endif
137462138312
sqlite3_mutex_enter(db->mutex);
137463138313
pOld = db->pTraceArg;
137464
- db->xTrace = xTrace;
138314
+ db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;
138315
+ db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;
137465138316
db->pTraceArg = pArg;
137466138317
sqlite3_mutex_leave(db->mutex);
137467138318
return pOld;
137468138319
}
138320
+#endif /* SQLITE_OMIT_DEPRECATED */
138321
+
138322
+/* Register a trace callback using the version-2 interface.
138323
+*/
138324
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
138325
+ sqlite3 *db, /* Trace this connection */
138326
+ unsigned mTrace, /* Mask of events to be traced */
138327
+ int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */
138328
+ void *pArg /* Context */
138329
+){
138330
+#ifdef SQLITE_ENABLE_API_ARMOR
138331
+ if( !sqlite3SafetyCheckOk(db) ){
138332
+ return SQLITE_MISUSE_BKPT;
138333
+ }
138334
+#endif
138335
+ sqlite3_mutex_enter(db->mutex);
138336
+ db->mTrace = mTrace;
138337
+ db->xTrace = xTrace;
138338
+ db->pTraceArg = pArg;
138339
+ sqlite3_mutex_leave(db->mutex);
138340
+ return SQLITE_OK;
138341
+}
138342
+
138343
+#ifndef SQLITE_OMIT_DEPRECATED
137469138344
/*
137470138345
** Register a profile function. The pArg from the previously registered
137471138346
** profile function is returned.
137472138347
**
137473138348
** A NULL profile function means that no profiling is executes. A non-NULL
@@ -137492,10 +138367,11 @@
137492138367
db->xProfile = xProfile;
137493138368
db->pProfileArg = pArg;
137494138369
sqlite3_mutex_leave(db->mutex);
137495138370
return pOld;
137496138371
}
138372
+#endif /* SQLITE_OMIT_DEPRECATED */
137497138373
#endif /* SQLITE_OMIT_TRACE */
137498138374
137499138375
/*
137500138376
** Register a function to be invoked when a transaction commits.
137501138377
** If the invoked function returns non-zero, then the commit becomes a
@@ -149942,11 +150818,15 @@
149942150818
}
149943150819
149944150820
149945150821
#ifdef SQLITE_TEST
149946150822
149947
-#include <tcl.h>
150823
+#if defined(INCLUDE_SQLITE_TCL_H)
150824
+# include "sqlite_tcl.h"
150825
+#else
150826
+# include "tcl.h"
150827
+#endif
149948150828
/* #include <string.h> */
149949150829
149950150830
/*
149951150831
** Implementation of a special SQL scalar function for testing tokenizers
149952150832
** designed to be used in concert with the Tcl testing framework. This
@@ -161881,10 +162761,57 @@
161881162761
}
161882162762
return f;
161883162763
}
161884162764
#endif /* !defined(SQLITE_RTREE_INT_ONLY) */
161885162765
162766
+/*
162767
+** A constraint has failed while inserting a row into an rtree table.
162768
+** Assuming no OOM error occurs, this function sets the error message
162769
+** (at pRtree->base.zErrMsg) to an appropriate value and returns
162770
+** SQLITE_CONSTRAINT.
162771
+**
162772
+** Parameter iCol is the index of the leftmost column involved in the
162773
+** constraint failure. If it is 0, then the constraint that failed is
162774
+** the unique constraint on the id column. Otherwise, it is the rtree
162775
+** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.
162776
+**
162777
+** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.
162778
+*/
162779
+static int rtreeConstraintError(Rtree *pRtree, int iCol){
162780
+ sqlite3_stmt *pStmt = 0;
162781
+ char *zSql;
162782
+ int rc;
162783
+
162784
+ assert( iCol==0 || iCol%2 );
162785
+ zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName);
162786
+ if( zSql ){
162787
+ rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);
162788
+ }else{
162789
+ rc = SQLITE_NOMEM;
162790
+ }
162791
+ sqlite3_free(zSql);
162792
+
162793
+ if( rc==SQLITE_OK ){
162794
+ if( iCol==0 ){
162795
+ const char *zCol = sqlite3_column_name(pStmt, 0);
162796
+ pRtree->base.zErrMsg = sqlite3_mprintf(
162797
+ "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol
162798
+ );
162799
+ }else{
162800
+ const char *zCol1 = sqlite3_column_name(pStmt, iCol);
162801
+ const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);
162802
+ pRtree->base.zErrMsg = sqlite3_mprintf(
162803
+ "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2
162804
+ );
162805
+ }
162806
+ }
162807
+
162808
+ sqlite3_finalize(pStmt);
162809
+ return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);
162810
+}
162811
+
162812
+
161886162813
161887162814
/*
161888162815
** The xUpdate method for rtree module virtual tables.
161889162816
*/
161890162817
static int rtreeUpdate(
@@ -161931,11 +162858,11 @@
161931162858
if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
161932162859
for(ii=0; ii<nData-4; ii+=2){
161933162860
cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
161934162861
cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
161935162862
if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
161936
- rc = SQLITE_CONSTRAINT;
162863
+ rc = rtreeConstraintError(pRtree, ii+1);
161937162864
goto constraint;
161938162865
}
161939162866
}
161940162867
}else
161941162868
#endif
@@ -161942,11 +162869,11 @@
161942162869
{
161943162870
for(ii=0; ii<nData-4; ii+=2){
161944162871
cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
161945162872
cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
161946162873
if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
161947
- rc = SQLITE_CONSTRAINT;
162874
+ rc = rtreeConstraintError(pRtree, ii+1);
161948162875
goto constraint;
161949162876
}
161950162877
}
161951162878
}
161952162879
@@ -161963,11 +162890,11 @@
161963162890
rc = sqlite3_reset(pRtree->pReadRowid);
161964162891
if( SQLITE_ROW==steprc ){
161965162892
if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
161966162893
rc = rtreeDeleteRowid(pRtree, cell.iRowid);
161967162894
}else{
161968
- rc = SQLITE_CONSTRAINT;
162895
+ rc = rtreeConstraintError(pRtree, 0);
161969162896
goto constraint;
161970162897
}
161971162898
}
161972162899
}
161973162900
bHaveRowid = 1;
@@ -162046,10 +162973,15 @@
162046162973
char *zSql;
162047162974
sqlite3_stmt *p;
162048162975
int rc;
162049162976
i64 nRow = 0;
162050162977
162978
+ if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1",
162979
+ 0,0,0,0,0,0)==SQLITE_ERROR ){
162980
+ pRtree->nRowEst = RTREE_DEFAULT_ROWEST;
162981
+ return SQLITE_OK;
162982
+ }
162051162983
zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
162052162984
if( zSql==0 ){
162053162985
rc = SQLITE_NOMEM;
162054162986
}else{
162055162987
rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
@@ -163977,10 +164909,48 @@
163977164909
** table exists but is not correctly populated, the value of the *pnOne
163978164910
** output variable during stage 1 is undefined.
163979164911
*/
163980164912
SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
163981164913
164914
+/*
164915
+** Obtain an indication as to the current stage of an RBU update or vacuum.
164916
+** This function always returns one of the SQLITE_RBU_STATE_XXX constants
164917
+** defined in this file. Return values should be interpreted as follows:
164918
+**
164919
+** SQLITE_RBU_STATE_OAL:
164920
+** RBU is currently building a *-oal file. The next call to sqlite3rbu_step()
164921
+** may either add further data to the *-oal file, or compute data that will
164922
+** be added by a subsequent call.
164923
+**
164924
+** SQLITE_RBU_STATE_MOVE:
164925
+** RBU has finished building the *-oal file. The next call to sqlite3rbu_step()
164926
+** will move the *-oal file to the equivalent *-wal path. If the current
164927
+** operation is an RBU update, then the updated version of the database
164928
+** file will become visible to ordinary SQLite clients following the next
164929
+** call to sqlite3rbu_step().
164930
+**
164931
+** SQLITE_RBU_STATE_CHECKPOINT:
164932
+** RBU is currently performing an incremental checkpoint. The next call to
164933
+** sqlite3rbu_step() will copy a page of data from the *-wal file into
164934
+** the target database file.
164935
+**
164936
+** SQLITE_RBU_STATE_DONE:
164937
+** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()
164938
+** will immediately return SQLITE_DONE.
164939
+**
164940
+** SQLITE_RBU_STATE_ERROR:
164941
+** An error has occurred. Any subsequent calls to sqlite3rbu_step() will
164942
+** immediately return the SQLite error code associated with the error.
164943
+*/
164944
+#define SQLITE_RBU_STATE_OAL 1
164945
+#define SQLITE_RBU_STATE_MOVE 2
164946
+#define SQLITE_RBU_STATE_CHECKPOINT 3
164947
+#define SQLITE_RBU_STATE_DONE 4
164948
+#define SQLITE_RBU_STATE_ERROR 5
164949
+
164950
+SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *pRbu);
164951
+
163982164952
/*
163983164953
** Create an RBU VFS named zName that accesses the underlying file-system
163984164954
** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
163985164955
** then the new RBU VFS uses the default system VFS to access the file-system.
163986164956
** The new object is registered as a non-default VFS with SQLite before
@@ -164872,16 +165842,18 @@
164872165842
*/
164873165843
static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
164874165844
int rc;
164875165845
memset(pIter, 0, sizeof(RbuObjIter));
164876165846
164877
- rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165847
+ rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165848
+ sqlite3_mprintf(
164878165849
"SELECT rbu_target_name(name, type='view') AS target, name "
164879165850
"FROM sqlite_master "
164880165851
"WHERE type IN ('table', 'view') AND target IS NOT NULL "
165852
+ " %s "
164881165853
"ORDER BY name"
164882
- );
165854
+ , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : ""));
164883165855
164884165856
if( rc==SQLITE_OK ){
164885165857
rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
164886165858
"SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' "
164887165859
" FROM main.sqlite_master "
@@ -166456,13 +167428,13 @@
166456167428
#if SQLITE_ENABLE_8_3_NAMES<2
166457167429
if( sqlite3_uri_boolean(zBase, "8_3_names", 0) )
166458167430
#endif
166459167431
{
166460167432
int i, sz;
166461
- sz = sqlite3Strlen30(z);
167433
+ sz = (int)strlen(z)&0xffffff;
166462167434
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
166463
- if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
167435
+ if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);
166464167436
}
166465167437
#endif
166466167438
}
166467167439
166468167440
/*
@@ -167504,34 +168476,11 @@
167504168476
}
167505168477
167506168478
if( p->rc==SQLITE_OK ){
167507168479
if( p->eStage==RBU_STAGE_OAL ){
167508168480
sqlite3 *db = p->dbMain;
167509
-
167510
- if( pState->eStage==0 && rbuIsVacuum(p) ){
167511
- rbuCopyPragma(p, "page_size");
167512
- rbuCopyPragma(p, "auto_vacuum");
167513
- }
167514
-
167515
- /* Open transactions both databases. The *-oal file is opened or
167516
- ** created at this point. */
167517
- if( p->rc==SQLITE_OK ){
167518
- p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
167519
- }
167520
- if( p->rc==SQLITE_OK ){
167521
- p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
167522
- }
167523
-
167524
- /* Check if the main database is a zipvfs db. If it is, set the upper
167525
- ** level pager to use "journal_mode=off". This prevents it from
167526
- ** generating a large journal using a temp file. */
167527
- if( p->rc==SQLITE_OK ){
167528
- int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
167529
- if( frc==SQLITE_OK ){
167530
- p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
167531
- }
167532
- }
168481
+ p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
167533168482
167534168483
/* Point the object iterator at the first object */
167535168484
if( p->rc==SQLITE_OK ){
167536168485
p->rc = rbuObjIterFirst(p, &p->objiter);
167537168486
}
@@ -167538,16 +168487,38 @@
167538168487
167539168488
/* If the RBU database contains no data_xxx tables, declare the RBU
167540168489
** update finished. */
167541168490
if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
167542168491
p->rc = SQLITE_DONE;
168492
+ p->eStage = RBU_STAGE_DONE;
168493
+ }else{
168494
+ if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){
168495
+ rbuCopyPragma(p, "page_size");
168496
+ rbuCopyPragma(p, "auto_vacuum");
168497
+ }
168498
+
168499
+ /* Open transactions both databases. The *-oal file is opened or
168500
+ ** created at this point. */
168501
+ if( p->rc==SQLITE_OK ){
168502
+ p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
168503
+ }
168504
+
168505
+ /* Check if the main database is a zipvfs db. If it is, set the upper
168506
+ ** level pager to use "journal_mode=off". This prevents it from
168507
+ ** generating a large journal using a temp file. */
168508
+ if( p->rc==SQLITE_OK ){
168509
+ int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
168510
+ if( frc==SQLITE_OK ){
168511
+ p->rc = sqlite3_exec(
168512
+ db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
168513
+ }
168514
+ }
168515
+
168516
+ if( p->rc==SQLITE_OK ){
168517
+ rbuSetupOal(p, pState);
168518
+ }
167543168519
}
167544
-
167545
- if( p->rc==SQLITE_OK ){
167546
- rbuSetupOal(p, pState);
167547
- }
167548
-
167549168520
}else if( p->eStage==RBU_STAGE_MOVE ){
167550168521
/* no-op */
167551168522
}else if( p->eStage==RBU_STAGE_CKPT ){
167552168523
rbuSetupCheckpoint(p, pState);
167553168524
}else if( p->eStage==RBU_STAGE_DONE ){
@@ -167709,14 +168680,44 @@
167709168680
167710168681
default:
167711168682
assert( 0 );
167712168683
}
167713168684
}
168685
+
168686
+/*
168687
+** Return the current state of the RBU vacuum or update operation.
168688
+*/
168689
+SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *p){
168690
+ int aRes[] = {
168691
+ 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,
168692
+ 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE
168693
+ };
168694
+
168695
+ assert( RBU_STAGE_OAL==1 );
168696
+ assert( RBU_STAGE_MOVE==2 );
168697
+ assert( RBU_STAGE_CKPT==4 );
168698
+ assert( RBU_STAGE_DONE==5 );
168699
+ assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );
168700
+ assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );
168701
+ assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );
168702
+ assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );
168703
+
168704
+ if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){
168705
+ return SQLITE_RBU_STATE_ERROR;
168706
+ }else{
168707
+ assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );
168708
+ assert( p->eStage==RBU_STAGE_OAL
168709
+ || p->eStage==RBU_STAGE_MOVE
168710
+ || p->eStage==RBU_STAGE_CKPT
168711
+ || p->eStage==RBU_STAGE_DONE
168712
+ );
168713
+ return aRes[p->eStage];
168714
+ }
168715
+}
167714168716
167715168717
SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){
167716168718
int rc = p->rc;
167717
-
167718168719
if( rc==SQLITE_DONE ) return SQLITE_OK;
167719168720
167720168721
assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
167721168722
if( p->eStage==RBU_STAGE_OAL ){
167722168723
assert( rc!=SQLITE_DONE );
@@ -168694,14 +169695,14 @@
168694169695
**
168695169696
** '/1c2/000/' // Left-most child of 451st child of root
168696169697
*/
168697169698
#define VTAB_SCHEMA \
168698169699
"CREATE TABLE xx( " \
168699
- " name STRING, /* Name of table or index */" \
168700
- " path INTEGER, /* Path to page from root */" \
169700
+ " name TEXT, /* Name of table or index */" \
169701
+ " path TEXT, /* Path to page from root */" \
168701169702
" pageno INTEGER, /* Page number */" \
168702
- " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \
169703
+ " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
168703169704
" ncell INTEGER, /* Cells on page (0 for overflow) */" \
168704169705
" payload INTEGER, /* Bytes of payload on this page */" \
168705169706
" unused INTEGER, /* Bytes of unused space on this page */" \
168706169707
" mx_payload INTEGER, /* Largest payload size of all cells */" \
168707169708
" pgoffset INTEGER, /* Offset of page in file */" \
@@ -175195,10 +176196,30 @@
175195176196
#endif /* SQLITE_DEBUG */
175196176197
175197176198
/****************************************************************************
175198176199
** Scalar SQL function implementations
175199176200
****************************************************************************/
176201
+
176202
+/*
176203
+** Implementation of the json_QUOTE(VALUE) function. Return a JSON value
176204
+** corresponding to the SQL value input. Mostly this means putting
176205
+** double-quotes around strings and returning the unquoted string "null"
176206
+** when given a NULL input.
176207
+*/
176208
+static void jsonQuoteFunc(
176209
+ sqlite3_context *ctx,
176210
+ int argc,
176211
+ sqlite3_value **argv
176212
+){
176213
+ JsonString jx;
176214
+ UNUSED_PARAM(argc);
176215
+
176216
+ jsonInit(&jx, ctx);
176217
+ jsonAppendValue(&jx, argv[0]);
176218
+ jsonResult(&jx);
176219
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
176220
+}
175200176221
175201176222
/*
175202176223
** Implementation of the json_array(VALUE,...) function. Return a JSON
175203176224
** array that contains all values given in arguments. Or if any argument
175204176225
** is a BLOB, throw an error.
@@ -176109,10 +177130,11 @@
176109177130
{ "json_array_length", 1, 0, jsonArrayLengthFunc },
176110177131
{ "json_array_length", 2, 0, jsonArrayLengthFunc },
176111177132
{ "json_extract", -1, 0, jsonExtractFunc },
176112177133
{ "json_insert", -1, 0, jsonSetFunc },
176113177134
{ "json_object", -1, 0, jsonObjectFunc },
177135
+ { "json_quote", 1, 0, jsonQuoteFunc },
176114177136
{ "json_remove", -1, 0, jsonRemoveFunc },
176115177137
{ "json_replace", -1, 0, jsonReplaceFunc },
176116177138
{ "json_set", -1, 1, jsonSetFunc },
176117177139
{ "json_type", 1, 0, jsonTypeFunc },
176118177140
{ "json_type", 2, 0, jsonTypeFunc },
@@ -176509,11 +177531,11 @@
176509177531
** following structure. All structure methods must be defined, setting
176510177532
** any member of the fts5_tokenizer struct to NULL leads to undefined
176511177533
** behaviour. The structure methods are expected to function as follows:
176512177534
**
176513177535
** xCreate:
176514
-** This function is used to allocate and inititalize a tokenizer instance.
177536
+** This function is used to allocate and initialize a tokenizer instance.
176515177537
** A tokenizer instance is required to actually tokenize text.
176516177538
**
176517177539
** The first argument passed to this function is a copy of the (void*)
176518177540
** pointer provided by the application when the fts5_tokenizer object
176519177541
** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -176768,11 +177790,10 @@
176768177790
#if 0
176769177791
} /* end of the 'extern "C"' block */
176770177792
#endif
176771177793
176772177794
#endif /* _FTS5_H */
176773
-
176774177795
176775177796
/*
176776177797
** 2014 May 31
176777177798
**
176778177799
** The author disclaims copyright to this source code. In place of
@@ -177458,11 +178479,10 @@
177458178479
static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
177459178480
static int sqlite3Fts5ExprPopulatePoslists(
177460178481
Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
177461178482
);
177462178483
static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
177463
-static void sqlite3Fts5ExprClearEof(Fts5Expr*);
177464178484
177465178485
static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
177466178486
177467178487
static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
177468178488
@@ -177874,21 +178894,22 @@
177874178894
typedef struct fts5yyStackEntry fts5yyStackEntry;
177875178895
177876178896
/* The state of the parser is completely contained in an instance of
177877178897
** the following structure */
177878178898
struct fts5yyParser {
177879
- int fts5yyidx; /* Index of top element in stack */
178899
+ fts5yyStackEntry *fts5yytos; /* Pointer to top element of the stack */
177880178900
#ifdef fts5YYTRACKMAXSTACKDEPTH
177881
- int fts5yyidxMax; /* Maximum value of fts5yyidx */
178901
+ int fts5yyhwm; /* High-water mark of the stack */
177882178902
#endif
177883178903
#ifndef fts5YYNOERRORRECOVERY
177884178904
int fts5yyerrcnt; /* Shifts left before out of the error */
177885178905
#endif
177886178906
sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
177887178907
#if fts5YYSTACKDEPTH<=0
177888178908
int fts5yystksz; /* Current side of the stack */
177889178909
fts5yyStackEntry *fts5yystack; /* The parser's stack */
178910
+ fts5yyStackEntry fts5yystk0; /* First stack entry */
177890178911
#else
177891178912
fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
177892178913
#endif
177893178914
};
177894178915
typedef struct fts5yyParser fts5yyParser;
@@ -177971,28 +178992,38 @@
177971178992
#endif /* NDEBUG */
177972178993
177973178994
177974178995
#if fts5YYSTACKDEPTH<=0
177975178996
/*
177976
-** Try to increase the size of the parser stack.
178997
+** Try to increase the size of the parser stack. Return the number
178998
+** of errors. Return 0 on success.
177977178999
*/
177978
-static void fts5yyGrowStack(fts5yyParser *p){
179000
+static int fts5yyGrowStack(fts5yyParser *p){
177979179001
int newSize;
179002
+ int idx;
177980179003
fts5yyStackEntry *pNew;
177981179004
177982179005
newSize = p->fts5yystksz*2 + 100;
177983
- pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
179006
+ idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;
179007
+ if( p->fts5yystack==&p->fts5yystk0 ){
179008
+ pNew = malloc(newSize*sizeof(pNew[0]));
179009
+ if( pNew ) pNew[0] = p->fts5yystk0;
179010
+ }else{
179011
+ pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
179012
+ }
177984179013
if( pNew ){
177985179014
p->fts5yystack = pNew;
177986
- p->fts5yystksz = newSize;
179015
+ p->fts5yytos = &p->fts5yystack[idx];
177987179016
#ifndef NDEBUG
177988179017
if( fts5yyTraceFILE ){
177989
- fprintf(fts5yyTraceFILE,"%sStack grows to %d entries!\n",
177990
- fts5yyTracePrompt, p->fts5yystksz);
179018
+ fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
179019
+ fts5yyTracePrompt, p->fts5yystksz, newSize);
177991179020
}
177992179021
#endif
179022
+ p->fts5yystksz = newSize;
177993179023
}
179024
+ return pNew==0;
177994179025
}
177995179026
#endif
177996179027
177997179028
/* Datatype of the argument to the memory allocated passed as the
177998179029
** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by
@@ -178017,19 +179048,28 @@
178017179048
*/
178018179049
static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
178019179050
fts5yyParser *pParser;
178020179051
pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
178021179052
if( pParser ){
178022
- pParser->fts5yyidx = -1;
178023179053
#ifdef fts5YYTRACKMAXSTACKDEPTH
178024
- pParser->fts5yyidxMax = 0;
179054
+ pParser->fts5yyhwm = 0;
178025179055
#endif
178026179056
#if fts5YYSTACKDEPTH<=0
179057
+ pParser->fts5yytos = NULL;
178027179058
pParser->fts5yystack = NULL;
178028179059
pParser->fts5yystksz = 0;
178029
- fts5yyGrowStack(pParser);
179060
+ if( fts5yyGrowStack(pParser) ){
179061
+ pParser->fts5yystack = &pParser->fts5yystk0;
179062
+ pParser->fts5yystksz = 1;
179063
+ }
178030179064
#endif
179065
+#ifndef fts5YYNOERRORRECOVERY
179066
+ pParser->fts5yyerrcnt = -1;
179067
+#endif
179068
+ pParser->fts5yytos = pParser->fts5yystack;
179069
+ pParser->fts5yystack[0].stateno = 0;
179070
+ pParser->fts5yystack[0].major = 0;
178031179071
}
178032179072
return pParser;
178033179073
}
178034179074
178035179075
/* The following function deletes the "minor type" or semantic value
@@ -178097,12 +179137,13 @@
178097179137
** If there is a destructor routine associated with the token which
178098179138
** is popped from the stack, then call it.
178099179139
*/
178100179140
static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
178101179141
fts5yyStackEntry *fts5yytos;
178102
- assert( pParser->fts5yyidx>=0 );
178103
- fts5yytos = &pParser->fts5yystack[pParser->fts5yyidx--];
179142
+ assert( pParser->fts5yytos!=0 );
179143
+ assert( pParser->fts5yytos > pParser->fts5yystack );
179144
+ fts5yytos = pParser->fts5yytos--;
178104179145
#ifndef NDEBUG
178105179146
if( fts5yyTraceFILE ){
178106179147
fprintf(fts5yyTraceFILE,"%sPopping %s\n",
178107179148
fts5yyTracePrompt,
178108179149
fts5yyTokenName[fts5yytos->major]);
@@ -178125,13 +179166,13 @@
178125179166
){
178126179167
fts5yyParser *pParser = (fts5yyParser*)p;
178127179168
#ifndef fts5YYPARSEFREENEVERNULL
178128179169
if( pParser==0 ) return;
178129179170
#endif
178130
- while( pParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(pParser);
179171
+ while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);
178131179172
#if fts5YYSTACKDEPTH<=0
178132
- free(pParser->fts5yystack);
179173
+ if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);
178133179174
#endif
178134179175
(*freeProc)((void*)pParser);
178135179176
}
178136179177
178137179178
/*
@@ -178138,11 +179179,11 @@
178138179179
** Return the peak depth of the stack for a parser.
178139179180
*/
178140179181
#ifdef fts5YYTRACKMAXSTACKDEPTH
178141179182
static int sqlite3Fts5ParserStackPeak(void *p){
178142179183
fts5yyParser *pParser = (fts5yyParser*)p;
178143
- return pParser->fts5yyidxMax;
179184
+ return pParser->fts5yyhwm;
178144179185
}
178145179186
#endif
178146179187
178147179188
/*
178148179189
** Find the appropriate action for a parser given the terminal
@@ -178151,11 +179192,11 @@
178151179192
static unsigned int fts5yy_find_shift_action(
178152179193
fts5yyParser *pParser, /* The parser */
178153179194
fts5YYCODETYPE iLookAhead /* The look-ahead token */
178154179195
){
178155179196
int i;
178156
- int stateno = pParser->fts5yystack[pParser->fts5yyidx].stateno;
179197
+ int stateno = pParser->fts5yytos->stateno;
178157179198
178158179199
if( stateno>=fts5YY_MIN_REDUCE ) return stateno;
178159179200
assert( stateno <= fts5YY_SHIFT_COUNT );
178160179201
do{
178161179202
i = fts5yy_shift_ofst[stateno];
@@ -178244,17 +179285,17 @@
178244179285
/*
178245179286
** The following routine is called if the stack overflows.
178246179287
*/
178247179288
static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
178248179289
sqlite3Fts5ParserARG_FETCH;
178249
- fts5yypParser->fts5yyidx--;
179290
+ fts5yypParser->fts5yytos--;
178250179291
#ifndef NDEBUG
178251179292
if( fts5yyTraceFILE ){
178252179293
fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
178253179294
}
178254179295
#endif
178255
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179296
+ while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
178256179297
/* Here code is inserted which will execute if the parser
178257179298
** stack every overflows */
178258179299
/******** Begin %stack_overflow code ******************************************/
178259179300
178260179301
sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
@@ -178268,15 +179309,15 @@
178268179309
#ifndef NDEBUG
178269179310
static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){
178270179311
if( fts5yyTraceFILE ){
178271179312
if( fts5yyNewState<fts5YYNSTATE ){
178272179313
fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n",
178273
- fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major],
179314
+ fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major],
178274179315
fts5yyNewState);
178275179316
}else{
178276179317
fprintf(fts5yyTraceFILE,"%sShift '%s'\n",
178277
- fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major]);
179318
+ fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]);
178278179319
}
178279179320
}
178280179321
}
178281179322
#else
178282179323
# define fts5yyTraceShift(X,Y)
@@ -178290,31 +179331,34 @@
178290179331
int fts5yyNewState, /* The new state to shift in */
178291179332
int fts5yyMajor, /* The major token to shift in */
178292179333
sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
178293179334
){
178294179335
fts5yyStackEntry *fts5yytos;
178295
- fts5yypParser->fts5yyidx++;
179336
+ fts5yypParser->fts5yytos++;
178296179337
#ifdef fts5YYTRACKMAXSTACKDEPTH
178297
- if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178298
- fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
179338
+ if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179339
+ fts5yypParser->fts5yyhwm++;
179340
+ assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
178299179341
}
178300179342
#endif
178301179343
#if fts5YYSTACKDEPTH>0
178302
- if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH ){
179344
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
178303179345
fts5yyStackOverflow(fts5yypParser);
178304179346
return;
178305179347
}
178306179348
#else
178307
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
178308
- fts5yyGrowStack(fts5yypParser);
178309
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){
179349
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){
179350
+ if( fts5yyGrowStack(fts5yypParser) ){
178310179351
fts5yyStackOverflow(fts5yypParser);
178311179352
return;
178312179353
}
178313179354
}
178314179355
#endif
178315
- fts5yytos = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
179356
+ if( fts5yyNewState > fts5YY_MAX_SHIFT ){
179357
+ fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179358
+ }
179359
+ fts5yytos = fts5yypParser->fts5yytos;
178316179360
fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
178317179361
fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
178318179362
fts5yytos->minor.fts5yy0 = fts5yyMinor;
178319179363
fts5yyTraceShift(fts5yypParser, fts5yyNewState);
178320179364
}
@@ -178365,11 +179409,11 @@
178365179409
int fts5yygoto; /* The next state */
178366179410
int fts5yyact; /* The next action */
178367179411
fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
178368179412
int fts5yysize; /* Amount to pop the stack */
178369179413
sqlite3Fts5ParserARG_FETCH;
178370
- fts5yymsp = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx];
179414
+ fts5yymsp = fts5yypParser->fts5yytos;
178371179415
#ifndef NDEBUG
178372179416
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
178373179417
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178374179418
fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
178375179419
fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
@@ -178379,26 +179423,27 @@
178379179423
/* Check that the stack is large enough to grow by a single entry
178380179424
** if the RHS of the rule is empty. This ensures that there is room
178381179425
** enough on the stack to push the LHS value */
178382179426
if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
178383179427
#ifdef fts5YYTRACKMAXSTACKDEPTH
178384
- if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){
178385
- fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx;
179428
+ if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179429
+ fts5yypParser->fts5yyhwm++;
179430
+ assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
178386179431
}
178387179432
#endif
178388179433
#if fts5YYSTACKDEPTH>0
178389
- if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH-1 ){
179434
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
178390179435
fts5yyStackOverflow(fts5yypParser);
178391179436
return;
178392179437
}
178393179438
#else
178394
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
178395
- fts5yyGrowStack(fts5yypParser);
178396
- if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){
179439
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
179440
+ if( fts5yyGrowStack(fts5yypParser) ){
178397179441
fts5yyStackOverflow(fts5yypParser);
178398179442
return;
178399179443
}
179444
+ fts5yymsp = fts5yypParser->fts5yytos;
178400179445
}
178401179446
#endif
178402179447
}
178403179448
178404179449
switch( fts5yyruleno ){
@@ -178535,19 +179580,21 @@
178535179580
assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
178536179581
fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
178537179582
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
178538179583
fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
178539179584
if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178540
- if( fts5yyact>fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178541
- fts5yypParser->fts5yyidx -= fts5yysize - 1;
179585
+ if( fts5yyact>fts5YY_MAX_SHIFT ){
179586
+ fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179587
+ }
178542179588
fts5yymsp -= fts5yysize-1;
179589
+ fts5yypParser->fts5yytos = fts5yymsp;
178543179590
fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
178544179591
fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
178545179592
fts5yyTraceShift(fts5yypParser, fts5yyact);
178546179593
}else{
178547179594
assert( fts5yyact == fts5YY_ACCEPT_ACTION );
178548
- fts5yypParser->fts5yyidx -= fts5yysize;
179595
+ fts5yypParser->fts5yytos -= fts5yysize;
178549179596
fts5yy_accept(fts5yypParser);
178550179597
}
178551179598
}
178552179599
178553179600
/*
@@ -178561,11 +179608,11 @@
178561179608
#ifndef NDEBUG
178562179609
if( fts5yyTraceFILE ){
178563179610
fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
178564179611
}
178565179612
#endif
178566
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179613
+ while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
178567179614
/* Here code is inserted which will be executed whenever the
178568179615
** parser fails */
178569179616
/************ Begin %parse_failure code ***************************************/
178570179617
/************ End %parse_failure code *****************************************/
178571179618
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178602,11 +179649,14 @@
178602179649
#ifndef NDEBUG
178603179650
if( fts5yyTraceFILE ){
178604179651
fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
178605179652
}
178606179653
#endif
178607
- while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser);
179654
+#ifndef fts5YYNOERRORRECOVERY
179655
+ fts5yypParser->fts5yyerrcnt = -1;
179656
+#endif
179657
+ assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
178608179658
/* Here code is inserted which will be executed whenever the
178609179659
** parser accepts */
178610179660
/*********** Begin %parse_accept code *****************************************/
178611179661
/*********** End %parse_accept code *******************************************/
178612179662
sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178645,32 +179695,12 @@
178645179695
#ifdef fts5YYERRORSYMBOL
178646179696
int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
178647179697
#endif
178648179698
fts5yyParser *fts5yypParser; /* The parser */
178649179699
178650
- /* (re)initialize the parser, if necessary */
178651179700
fts5yypParser = (fts5yyParser*)fts5yyp;
178652
- if( fts5yypParser->fts5yyidx<0 ){
178653
-#if fts5YYSTACKDEPTH<=0
178654
- if( fts5yypParser->fts5yystksz <=0 ){
178655
- fts5yyStackOverflow(fts5yypParser);
178656
- return;
178657
- }
178658
-#endif
178659
- fts5yypParser->fts5yyidx = 0;
178660
-#ifndef fts5YYNOERRORRECOVERY
178661
- fts5yypParser->fts5yyerrcnt = -1;
178662
-#endif
178663
- fts5yypParser->fts5yystack[0].stateno = 0;
178664
- fts5yypParser->fts5yystack[0].major = 0;
178665
-#ifndef NDEBUG
178666
- if( fts5yyTraceFILE ){
178667
- fprintf(fts5yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
178668
- fts5yyTracePrompt);
178669
- }
178670
-#endif
178671
- }
179701
+ assert( fts5yypParser->fts5yytos!=0 );
178672179702
#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
178673179703
fts5yyendofinput = (fts5yymajor==0);
178674179704
#endif
178675179705
sqlite3Fts5ParserARG_STORE;
178676179706
@@ -178681,11 +179711,10 @@
178681179711
#endif
178682179712
178683179713
do{
178684179714
fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
178685179715
if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
178686
- if( fts5yyact > fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
178687179716
fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
178688179717
#ifndef fts5YYNOERRORRECOVERY
178689179718
fts5yypParser->fts5yyerrcnt--;
178690179719
#endif
178691179720
fts5yymajor = fts5YYNOCODE;
@@ -178723,11 +179752,11 @@
178723179752
**
178724179753
*/
178725179754
if( fts5yypParser->fts5yyerrcnt<0 ){
178726179755
fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);
178727179756
}
178728
- fts5yymx = fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major;
179757
+ fts5yymx = fts5yypParser->fts5yytos->major;
178729179758
if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){
178730179759
#ifndef NDEBUG
178731179760
if( fts5yyTraceFILE ){
178732179761
fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n",
178733179762
fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);
@@ -178734,22 +179763,24 @@
178734179763
}
178735179764
#endif
178736179765
fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);
178737179766
fts5yymajor = fts5YYNOCODE;
178738179767
}else{
178739
- while(
178740
- fts5yypParser->fts5yyidx >= 0 &&
178741
- fts5yymx != fts5YYERRORSYMBOL &&
178742
- (fts5yyact = fts5yy_find_reduce_action(
178743
- fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].stateno,
179768
+ while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack
179769
+ && fts5yymx != fts5YYERRORSYMBOL
179770
+ && (fts5yyact = fts5yy_find_reduce_action(
179771
+ fts5yypParser->fts5yytos->stateno,
178744179772
fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE
178745179773
){
178746179774
fts5yy_pop_parser_stack(fts5yypParser);
178747179775
}
178748
- if( fts5yypParser->fts5yyidx < 0 || fts5yymajor==0 ){
179776
+ if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){
178749179777
fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178750179778
fts5yy_parse_failed(fts5yypParser);
179779
+#ifndef fts5YYNOERRORRECOVERY
179780
+ fts5yypParser->fts5yyerrcnt = -1;
179781
+#endif
178751179782
fts5yymajor = fts5YYNOCODE;
178752179783
}else if( fts5yymx!=fts5YYERRORSYMBOL ){
178753179784
fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
178754179785
}
178755179786
}
@@ -178782,22 +179813,27 @@
178782179813
}
178783179814
fts5yypParser->fts5yyerrcnt = 3;
178784179815
fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
178785179816
if( fts5yyendofinput ){
178786179817
fts5yy_parse_failed(fts5yypParser);
179818
+#ifndef fts5YYNOERRORRECOVERY
179819
+ fts5yypParser->fts5yyerrcnt = -1;
179820
+#endif
178787179821
}
178788179822
fts5yymajor = fts5YYNOCODE;
178789179823
#endif
178790179824
}
178791
- }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yyidx>=0 );
179825
+ }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
178792179826
#ifndef NDEBUG
178793179827
if( fts5yyTraceFILE ){
178794
- int i;
179828
+ fts5yyStackEntry *i;
179829
+ char cDiv = '[';
178795179830
fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
178796
- for(i=1; i<=fts5yypParser->fts5yyidx; i++)
178797
- fprintf(fts5yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
178798
- fts5yyTokenName[fts5yypParser->fts5yystack[i].major]);
179831
+ for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
179832
+ fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
179833
+ cDiv = ' ';
179834
+ }
178799179835
fprintf(fts5yyTraceFILE,"]\n");
178800179836
}
178801179837
#endif
178802179838
return;
178803179839
}
@@ -183337,21 +184373,10 @@
183337184373
183338184374
static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
183339184375
fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
183340184376
}
183341184377
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
-
183353184378
/*
183354184379
** This function is only called for detail=columns tables.
183355184380
*/
183356184381
static int sqlite3Fts5ExprPhraseCollist(
183357184382
Fts5Expr *pExpr,
@@ -191565,11 +192590,10 @@
191565192590
assert( pCsr->iLastRowid==LARGEST_INT64 );
191566192591
assert( pCsr->iFirstRowid==SMALLEST_INT64 );
191567192592
pCsr->ePlan = FTS5_PLAN_SOURCE;
191568192593
pCsr->pExpr = pTab->pSortCsr->pExpr;
191569192594
rc = fts5CursorFirst(pTab, pCsr, bDesc);
191570
- sqlite3Fts5ExprClearEof(pCsr->pExpr);
191571192595
}else if( pMatch ){
191572192596
const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
191573192597
if( zExpr==0 ) zExpr = "";
191574192598
191575192599
rc = fts5CursorParseRank(pConfig, pCsr, pRank);
@@ -192994,11 +194018,11 @@
192994194018
int nArg, /* Number of args */
192995194019
sqlite3_value **apUnused /* Function arguments */
192996194020
){
192997194021
assert( nArg==0 );
192998194022
UNUSED_PARAM2(nArg, apUnused);
192999
- sqlite3_result_text(pCtx, "fts5: 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2", -1, SQLITE_TRANSIENT);
194023
+ sqlite3_result_text(pCtx, "fts5: 2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b", -1, SQLITE_TRANSIENT);
193000194024
}
193001194025
193002194026
static int fts5Init(sqlite3 *db){
193003194027
static const sqlite3_module fts5Mod = {
193004194028
/* iVersion */ 2,
@@ -193359,11 +194383,15 @@
193359194383
){
193360194384
int rc;
193361194385
char *zErr = 0;
193362194386
193363194387
rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
193364
- pConfig->zDb, pConfig->zName, zPost, zDefn, bWithout?" WITHOUT ROWID":""
194388
+ pConfig->zDb, pConfig->zName, zPost, zDefn,
194389
+#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID
194390
+ bWithout?" WITHOUT ROWID":
194391
+#endif
194392
+ ""
193365194393
);
193366194394
if( zErr ){
193367194395
*pzErr = sqlite3_mprintf(
193368194396
"fts5: error creating shadow table %q_%s: %s",
193369194397
pConfig->zName, zPost, zErr
193370194398
--- 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:
@@ -65,10 +65,18 @@
65 ** In all cases, the special comment must be enclosed in the usual
66 ** slash-asterisk...asterisk-slash comment marks, with no spaces between the
67 ** asterisks and the comment text.
68 */
69
 
 
 
 
 
 
 
 
70 /*
71 ** Make sure that rand_s() is available on Windows systems with MSVC 2005
72 ** or higher.
73 */
74 #if defined(_MSC_VER) && _MSC_VER>=1400
@@ -95,12 +103,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 +124,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 +288,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 */
@@ -304,12 +312,21 @@
304 # define SQLITE_API
305 #endif
306 #ifndef SQLITE_CDECL
307 # define SQLITE_CDECL
308 #endif
 
 
 
309 #ifndef SQLITE_STDCALL
310 # define SQLITE_STDCALL
 
 
 
 
 
 
311 #endif
312
313 /*
314 ** These no-op macros are used in front of interfaces to mark those
315 ** interfaces as either deprecated or experimental. New applications
@@ -361,13 +378,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 +773,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
@@ -1285,10 +1303,20 @@
1285 **
1286 ** Mutexes are created using [sqlite3_mutex_alloc()].
1287 */
1288 typedef struct sqlite3_mutex sqlite3_mutex;
1289
 
 
 
 
 
 
 
 
 
 
1290 /*
1291 ** CAPI3REF: OS Interface Object
1292 **
1293 ** An instance of the sqlite3_vfs object defines the interface between
1294 ** the SQLite core and the underlying operating system. The "vfs"
@@ -2189,11 +2217,11 @@
2189 ** interface independently of the [load_extension()] SQL function.
2190 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2191 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2192 ** There should be two additional arguments.
2193 ** When the first argument to this interface is 1, then only the C-API is
2194 ** enabled and the SQL function remains disabled. If the first argment to
2195 ** this interface is 0, then both the C-API and the SQL function are disabled.
2196 ** If the first argument is -1, then no changes are made to state of either the
2197 ** C-API or the SQL function.
2198 ** The second parameter is a pointer to an integer into which
2199 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2482,11 +2510,11 @@
2482 ** result in undefined behavior.
2483 **
2484 ** A busy handler must not close the database connection
2485 ** or [prepared statement] that invoked the busy handler.
2486 */
2487 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2488
2489 /*
2490 ** CAPI3REF: Set A Busy Timeout
2491 ** METHOD: sqlite3
2492 **
@@ -3003,10 +3031,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 +3060,107 @@
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 +3776,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 **
@@ -4813,16 +4962,17 @@
4813 ** NULL if the metadata has been discarded.
4814 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4815 ** SQLite will invoke the destructor function X with parameter P exactly
4816 ** once, when the metadata is discarded.
4817 ** SQLite is free to discard the metadata at any time, including: <ul>
4818 ** <li> when the corresponding function parameter changes, or
4819 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4820 ** SQL statement, or
4821 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4822 ** <li> during the original sqlite3_set_auxdata() call when a memory
4823 ** allocation error occurs. </ul>)^
 
4824 **
4825 ** Note the last bullet in particular. The destructor X in
4826 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4827 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4828 ** should be called near the end of the function implementation and the
@@ -5645,11 +5795,11 @@
5645 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5646 ** the final five arguments with appropriate values if the specified
5647 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5648 ** SQLITE_ERROR and if the specified column does not exist.
5649 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5650 ** NULL pointer, then this routine simply checks for the existance of the
5651 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5652 ** does not.
5653 **
5654 ** ^The column is identified by the second, third and fourth parameters to
5655 ** this function. ^(The second parameter is either the name of the database
@@ -5779,12 +5929,12 @@
5779 ** to turn extension loading on and call it with onoff==0 to turn
5780 ** it back off again.
5781 **
5782 ** ^This interface enables or disables both the C-API
5783 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
5784 ** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5785 ** to enable or disable only the C-API.
5786 **
5787 ** <b>Security warning:</b> It is recommended that extension loading
5788 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
5789 ** rather than this interface, so the [load_extension()] SQL function
5790 ** remains disabled. This will prevent SQL injections from giving attackers
@@ -5800,11 +5950,11 @@
5800 ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
5801 ** that is to be automatically loaded into all new database connections.
5802 **
5803 ** ^(Even though the function prototype shows that xEntryPoint() takes
5804 ** no arguments and returns void, SQLite invokes xEntryPoint() with three
5805 ** arguments and expects and integer result as if the signature of the
5806 ** entry point where as follows:
5807 **
5808 ** <blockquote><pre>
5809 ** &nbsp; int xEntryPoint(
5810 ** &nbsp; sqlite3 *db,
@@ -5826,11 +5976,11 @@
5826 ** will be called more than once for each database connection that is opened.
5827 **
5828 ** See also: [sqlite3_reset_auto_extension()]
5829 ** and [sqlite3_cancel_auto_extension()]
5830 */
5831 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5832
5833 /*
5834 ** CAPI3REF: Cancel Automatic Extension Loading
5835 **
5836 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5838,11 +5988,11 @@
5838 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5839 ** routine returns 1 if initialization routine X was successfully
5840 ** unregistered and it returns 0 if X was not on the list of initialization
5841 ** routines.
5842 */
5843 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5844
5845 /*
5846 ** CAPI3REF: Reset Automatic Extension Loading
5847 **
5848 ** ^This interface disables all automatic extensions previously
@@ -7014,10 +7164,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 +7233,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
@@ -8227,11 +8390,11 @@
8227 ** tables.
8228 **
8229 ** ^The second parameter to the preupdate callback is a pointer to
8230 ** the [database connection] that registered the preupdate hook.
8231 ** ^The third parameter to the preupdate callback is one of the constants
8232 ** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
8233 ** kind of update operation that is about to occur.
8234 ** ^(The fourth parameter to the preupdate callback is the name of the
8235 ** database within the database connection that is being modified. This
8236 ** will be "main" for the main database or "temp" for TEMP tables or
8237 ** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8454,11 +8617,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 **
@@ -10174,11 +10337,11 @@
10174 ** following structure. All structure methods must be defined, setting
10175 ** any member of the fts5_tokenizer struct to NULL leads to undefined
10176 ** behaviour. The structure methods are expected to function as follows:
10177 **
10178 ** xCreate:
10179 ** This function is used to allocate and inititalize a tokenizer instance.
10180 ** A tokenizer instance is required to actually tokenize text.
10181 **
10182 ** The first argument passed to this function is a copy of the (void*)
10183 ** pointer provided by the application when the fts5_tokenizer object
10184 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10433,11 +10596,10 @@
10433 #if 0
10434 } /* end of the 'extern "C"' block */
10435 #endif
10436
10437 #endif /* _FTS5_H */
10438
10439
10440 /******** End of fts5.h *********/
10441
10442 /************** End of sqlite3.h *********************************************/
10443 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -10732,11 +10894,11 @@
10732 ** Make sure that the compiler intrinsics we desire are enabled when
10733 ** compiling with an appropriate version of MSVC unless prevented by
10734 ** the SQLITE_DISABLE_INTRINSIC define.
10735 */
10736 #if !defined(SQLITE_DISABLE_INTRINSIC)
10737 # if defined(_MSC_VER) && _MSC_VER>=1300
10738 # if !defined(_WIN32_WCE)
10739 # include <intrin.h>
10740 # pragma intrinsic(_byteswap_ushort)
10741 # pragma intrinsic(_byteswap_ulong)
10742 # pragma intrinsic(_ReadWriteBarrier)
@@ -11009,12 +11171,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 +11252,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 +12000,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 +12026,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 +12238,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 +12315,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 +12346,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 +12369,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 +12555,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 +12576,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 +12701,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 +12872,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 +12894,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 +13083,11 @@
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 +13110,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 +13348,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 +13389,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 +13846,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 +13884,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 +13905,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 +15100,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 +15146,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 */
@@ -15661,10 +15862,11 @@
15661 int iCur; /* A cursor number */
15662 SrcList *pSrcList; /* FROM clause */
15663 struct SrcCount *pSrcCount; /* Counting column references */
15664 struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
15665 int *aiCol; /* array of column indexes */
 
15666 } u;
15667 };
15668
15669 /* Forward declarations */
15670 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -15844,15 +16046,19 @@
15844 # define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N)
15845 # define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N)
15846 # define sqlite3StackFree(D,P) sqlite3DbFree(D,P)
15847 #endif
15848
15849 #ifdef SQLITE_ENABLE_MEMSYS3
15850 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
15851 #endif
15852 #ifdef SQLITE_ENABLE_MEMSYS5
15853 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
 
 
 
 
15854 #endif
15855
15856
15857 #ifndef SQLITE_MUTEX_OMIT
15858 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
@@ -16031,12 +16237,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 +16257,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 +16291,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*);
@@ -16097,10 +16306,11 @@
16097 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
16098 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
16099 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
16100 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
16101 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
 
16102 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
16103 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
16104 #ifndef SQLITE_OMIT_BUILTIN_TEST
16105 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
16106 SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
@@ -16648,11 +16858,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 +17193,19 @@
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 +17221,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 +17635,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 +18178,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 /*
@@ -18106,11 +18325,11 @@
18106 sqlite3_mutex_leave(pMutex);
18107 (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
18108 return SQLITE_OK;
18109 }
18110 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
18111 sqlite3_int64 iCur, iHwtr;
18112 int rc;
18113 #ifdef SQLITE_ENABLE_API_ARMOR
18114 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
18115 #endif
18116 rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
@@ -18167,19 +18386,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;
@@ -19409,11 +19633,10 @@
19409 int argc,
19410 sqlite3_value **argv
19411 ){
19412 time_t t;
19413 char *zFormat = (char *)sqlite3_user_data(context);
19414 sqlite3 *db;
19415 sqlite3_int64 iT;
19416 struct tm *pTm;
19417 struct tm sNow;
19418 char zBuf[20];
19419
@@ -19478,13 +19701,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 +23214,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 +23283,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 +23373,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 +23446,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 +26197,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 +28986,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 +29007,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 +29465,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 +29534,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 +36994,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 +37063,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 +37403,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 +39736,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 +40473,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 +40789,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 +40807,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 +40824,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 +40952,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 +40990,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 +41079,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 +41107,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 +41132,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 +41574,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 +41945,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 +41960,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 +42182,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 +42206,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 +42481,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 +42571,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 +42929,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 +43048,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 +44175,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 +44240,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 /*
@@ -44610,29 +44996,49 @@
44610 */
44611 static void pcache1TruncateUnsafe(
44612 PCache1 *pCache, /* The cache to truncate */
44613 unsigned int iLimit /* Drop pages with this pgno or larger */
44614 ){
44615 TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */
44616 unsigned int h;
44617 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
44618 for(h=0; h<pCache->nHash; h++){
44619 PgHdr1 **pp = &pCache->apHash[h];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44620 PgHdr1 *pPage;
 
 
44621 while( (pPage = *pp)!=0 ){
44622 if( pPage->iKey>=iLimit ){
44623 pCache->nPage--;
44624 *pp = pPage->pNext;
44625 if( !pPage->isPinned ) pcache1PinPage(pPage);
44626 pcache1FreePage(pPage);
44627 }else{
44628 pp = &pPage->pNext;
44629 TESTONLY( nPage++; )
44630 }
44631 }
 
 
44632 }
44633 assert( pCache->nPage==nPage );
44634 }
44635
44636 /******************************************************************************/
44637 /******** sqlite3_pcache Methods **********************************************/
44638
@@ -45105,11 +45511,11 @@
45105 static void pcache1Destroy(sqlite3_pcache *p){
45106 PCache1 *pCache = (PCache1 *)p;
45107 PGroup *pGroup = pCache->pGroup;
45108 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
45109 pcache1EnterMutex(pGroup);
45110 pcache1TruncateUnsafe(pCache, 0);
45111 assert( pGroup->nMaxPage >= pCache->nMax );
45112 pGroup->nMaxPage -= pCache->nMax;
45113 assert( pGroup->nMinPage >= pCache->nMin );
45114 pGroup->nMinPage -= pCache->nMin;
45115 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
@@ -45460,31 +45866,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 +45908,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 +46163,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 +46292,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
@@ -53036,10 +53441,11 @@
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()
@@ -53261,11 +53667,10 @@
53261 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
53262 assert( pPager->eState>=PAGER_READER );
53263 return sqlite3WalFramesize(pPager->pWal);
53264 }
53265 #endif
53266
53267
53268 #endif /* SQLITE_OMIT_DISKIO */
53269
53270 /************** End of pager.c ***********************************************/
53271 /************** Begin file wal.c *********************************************/
@@ -56378,20 +56783,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 +58584,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 +58752,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 +60471,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 +60544,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 +62404,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 +62872,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 +63205,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 +64199,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 +64223,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 +64277,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 +64362,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 +64428,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 +64445,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) );
@@ -64124,11 +64519,11 @@
64124 }
64125 }
64126
64127 /*
64128 ** A CellArray object contains a cache of pointers and sizes for a
64129 ** consecutive sequence of cells that might be held multiple pages.
64130 */
64131 typedef struct CellArray CellArray;
64132 struct CellArray {
64133 int nCell; /* Number of cells in apCell[] */
64134 MemPage *pRef; /* Reference page */
@@ -64556,12 +64951,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 +65474,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 +66046,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 +66075,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 +66105,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 +66124,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 +66181,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 +66205,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 +66342,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 +67833,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 /*
@@ -68211,14 +68626,14 @@
68211 /* 0x7FFFFFFF is the hard limit for the number of pages in a database
68212 ** file. By passing this as the number of pages to copy to
68213 ** sqlite3_backup_step(), we can guarantee that the copy finishes
68214 ** within a single call (unless an error occurs). The assert() statement
68215 ** checks this assumption - (p->rc) should be set to either SQLITE_DONE
68216 ** or an error code.
68217 */
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));
@@ -69225,15 +69640,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 +70420,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 +71139,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 +71193,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 +74663,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 +74740,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 +75002,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 +75518,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 +76553,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 +76633,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 +76921,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 +76978,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 +77027,11 @@
76575 }
76576 #endif
76577 }
76578 }
76579 }
 
76580 return sqlite3StrAccumFinish(&out);
76581 }
76582
76583 #endif /* #ifndef SQLITE_OMIT_TRACE */
76584
@@ -77107,12 +77560,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 +77629,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 +78508,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 +79146,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 +79159,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 +79512,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 +79534,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 +79548,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 +79564,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 +79582,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 +79603,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 +79633,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 +79649,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 +79662,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 +79693,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 +79710,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 +79723,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 +81141,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 +81175,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 +81319,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 +81402,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 +81439,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 +81463,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 +81487,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 +81576,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 +81592,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 +81746,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 +81763,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 +81777,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 +81844,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 +82119,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 +82135,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 }
@@ -83434,20 +83908,38 @@
83434 **
83435 ** If P2 is not zero, jump to instruction P2.
83436 */
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 +84518,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 +85953,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 +86042,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
@@ -88173,11 +88672,15 @@
88173 }
88174 if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
88175 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
88176 pNC->nErr++;
88177 is_agg = 0;
88178 }else if( no_such_func && pParse->db->init.busy==0 ){
 
 
 
 
88179 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
88180 pNC->nErr++;
88181 }else if( wrong_num_args ){
88182 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
88183 nId, zId);
@@ -90773,10 +91276,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 +91293,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 +91685,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 +91998,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 ){
@@ -91894,10 +92401,15 @@
91894 }
91895 nFarg = pFarg ? pFarg->nExpr : 0;
91896 assert( !ExprHasProperty(pExpr, EP_IntValue) );
91897 zId = pExpr->u.zToken;
91898 pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);
 
 
 
 
 
91899 if( pDef==0 || pDef->xFinalize!=0 ){
91900 sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
91901 break;
91902 }
91903
@@ -92915,10 +93427,65 @@
92915 ){
92916 return 1;
92917 }
92918 return 0;
92919 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92920
92921 /*
92922 ** An instance of the following structure is used by the tree walker
92923 ** to count references to table columns in the arguments of an
92924 ** aggregate function, in order to implement the
@@ -93870,10 +94437,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 +94532,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
@@ -96662,10 +97232,11 @@
96662 ){
96663 sqlite3 *db = pParse->db; /* Database handle */
96664 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
96665 int rc; /* Auth callback return code */
96666
 
96667 rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext
96668 #ifdef SQLITE_USER_AUTHENTICATION
96669 ,db->auth.zAuthUser
96670 #endif
96671 );
@@ -97152,11 +97723,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 +97737,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 +97749,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 +97773,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 +97784,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 +97992,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 +98676,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 +98722,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 +99040,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 +99101,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 +99132,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 +99891,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 +100262,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 +100293,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 }
@@ -99843,10 +100422,17 @@
99843 for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
99844 zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
99845 if( zName==0 ){
99846 goto exit_create_index;
99847 }
 
 
 
 
 
 
 
99848 }
99849
99850 /* Check for authorization to create an index.
99851 */
99852 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -99906,11 +100492,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 +100672,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 +100684,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 +100766,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 +100791,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 +100801,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 +100829,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 +101715,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 +103946,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 }
@@ -103939,10 +104521,30 @@
103939 }
103940 }
103941 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
103942 }
103943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103944
103945 /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
103946 ** is only available if the SQLITE_SOUNDEX compile-time option is used
103947 ** when SQLite is built.
103948 */
@@ -104410,17 +105012,20 @@
104410 AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
104411 AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
104412 AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
104413
104414 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104415 #ifdef SQLITE_CASE_SENSITIVE_LIKE
104416 LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104417 LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
104418 #else
104419 LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
104420 LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
104421 #endif
 
 
 
104422 FUNCTION(coalesce, 1, 0, 0, 0 ),
104423 FUNCTION(coalesce, 0, 0, 0, 0 ),
104424 FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
104425 };
104426 #ifndef SQLITE_OMIT_ALTERTABLE
@@ -105823,11 +106428,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,16 +108839,14 @@
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 /*
108245 ** The following structure holds pointers to all of the SQLite API
108246 ** routines.
108247 **
108248 ** WARNING: In order to maintain backwards compatibility, add new
@@ -108499,11 +109103,24 @@
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.
108509 **
@@ -108744,10 +109361,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,19 +109381,18 @@
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> */
108772
108773 #ifndef SQLITE_OMIT_LOAD_EXTENSION
108774
108775 /*
108776 ** Some API routines are omitted when various features are
108777 ** excluded from a build of SQLite. Substitute a NULL pointer
108778 ** for any missing APIs.
108779 */
@@ -108839,11 +109458,11 @@
108839
108840 #ifdef SQLITE_OMIT_SHARED_CACHE
108841 # define sqlite3_enable_shared_cache 0
108842 #endif
108843
108844 #ifdef SQLITE_OMIT_TRACE
108845 # define sqlite3_profile 0
108846 # define sqlite3_trace 0
108847 #endif
108848
108849 #ifdef SQLITE_OMIT_GET_TABLE
@@ -108858,10 +109477,14 @@
108858 #define sqlite3_blob_open 0
108859 #define sqlite3_blob_read 0
108860 #define sqlite3_blob_write 0
108861 #define sqlite3_blob_reopen 0
108862 #endif
 
 
 
 
108863
108864 /*
108865 ** The following structure contains pointers to all SQLite API routines.
108866 ** A pointer to this structure is passed into extensions when they are
108867 ** loaded so that the extension can make calls back into the SQLite
@@ -109164,11 +109787,14 @@
109164 /* Version 3.10.0 and later */
109165 sqlite3_status64,
109166 sqlite3_strlike,
109167 sqlite3_db_cacheflush,
109168 /* Version 3.12.0 and later */
109169 sqlite3_system_errno
 
 
 
109170 };
109171
109172 /*
109173 ** Attempt to load an SQLite extension library contained in the file
109174 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -109187,17 +109813,18 @@
109187 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
109188 char **pzErrMsg /* Put error message here if not 0 */
109189 ){
109190 sqlite3_vfs *pVfs = db->pVfs;
109191 void *handle;
109192 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
109193 char *zErrmsg = 0;
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"
@@ -109245,12 +109872,11 @@
109245 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
109246 }
109247 }
109248 return SQLITE_ERROR;
109249 }
109250 xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109251 sqlite3OsDlSym(pVfs, handle, zEntry);
109252
109253 /* If no entry point was specified and the default legacy
109254 ** entry point name "sqlite3_extension_init" was not found, then
109255 ** construct an entry point name "sqlite3_X_init" where the X is
109256 ** replaced by the lowercase value of every ASCII alphabetic
@@ -109278,12 +109904,11 @@
109278 zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
109279 }
109280 }
109281 memcpy(zAltEntry+iEntry, "_init", 6);
109282 zEntry = zAltEntry;
109283 xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109284 sqlite3OsDlSym(pVfs, handle, zEntry);
109285 }
109286 if( xInit==0 ){
109287 if( pzErrMsg ){
109288 nMsg += sqlite3Strlen30(zEntry);
109289 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
@@ -109296,11 +109921,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);
@@ -109407,11 +110034,13 @@
109407
109408 /*
109409 ** Register a statically linked extension that is automatically
109410 ** loaded by every new database connection.
109411 */
109412 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
 
 
109413 int rc = SQLITE_OK;
109414 #ifndef SQLITE_OMIT_AUTOINIT
109415 rc = sqlite3_initialize();
109416 if( rc ){
109417 return rc;
@@ -109452,11 +110081,13 @@
109452 ** routine is a no-op.
109453 **
109454 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
109455 ** was not on the list.
109456 */
109457 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
 
 
109458 #if SQLITE_THREADSAFE
109459 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
109460 #endif
109461 int i;
109462 int n = 0;
@@ -109501,11 +110132,11 @@
109501 */
109502 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
109503 u32 i;
109504 int go = 1;
109505 int rc;
109506 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
109507
109508 wsdAutoextInit;
109509 if( wsdAutoext.nExt==0 ){
109510 /* Common case: early out without every having to acquire a mutex */
109511 return;
@@ -109518,12 +110149,11 @@
109518 sqlite3_mutex_enter(mutex);
109519 if( i>=wsdAutoext.nExt ){
109520 xInit = 0;
109521 go = 0;
109522 }else{
109523 xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
109524 wsdAutoext.aExt[i];
109525 }
109526 sqlite3_mutex_leave(mutex);
109527 zErrmsg = 0;
109528 if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){
109529 sqlite3ErrorWithMsg(db, rc,
@@ -111034,11 +111664,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 +111686,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 +111968,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 +113542,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 +114076,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 +114514,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 +114536,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 +118684,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 +121454,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 +121475,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
@@ -120879,10 +121530,12 @@
120879 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
120880 if( nKey ) db->nextPagesize = 0;
120881 }
120882 #endif
120883
 
 
120884 rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF");
120885 if( rc!=SQLITE_OK ) goto end_of_vacuum;
120886
120887 /* Begin a transaction and take an exclusive lock on the main database
120888 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
@@ -121027,11 +121680,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 +122129,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 +122465,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);
@@ -121851,11 +122518,11 @@
121851 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
121852 int rc = SQLITE_OK;
121853 Table *pTab;
121854
121855 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
121856 if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
121857 VTable *p;
121858 int (*xDestroy)(sqlite3_vtab *);
121859 for(p=pTab->pVTable; p; p=p->pNext){
121860 assert( p->pVtab );
121861 if( p->pVtab->nRef>0 ){
@@ -121991,11 +122658,14 @@
121991 if( rc==SQLITE_OK ){
121992 rc = pModule->xBegin(pVTab->pVtab);
121993 if( rc==SQLITE_OK ){
121994 int iSvpt = db->nStatement + db->nSavepoint;
121995 addToVTrans(db, pVTab);
121996 if( iSvpt ) rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, iSvpt-1);
 
 
 
121997 }
121998 }
121999 }
122000 return rc;
122001 }
@@ -122145,11 +122815,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 +122832,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 +122869,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 +123380,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 +123399,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 +123618,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 +124061,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 +124118,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 +124202,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 +124233,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 +124302,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 +124336,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 +124391,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 +124531,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 +124558,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 +124772,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
@@ -124067,10 +124811,11 @@
124067 zStartAff[nEq] = SQLITE_AFF_BLOB;
124068 }
124069 }
124070 nConstraint++;
124071 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
 
124072 }else if( bSeekPastNull ){
124073 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124074 nConstraint++;
124075 startEq = 0;
124076 start_constraints = 1;
@@ -124332,15 +125077,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 +125185,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 +125221,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 +125246,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 +125908,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 +126125,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 +126462,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 +126754,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 +128352,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 +129373,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 +129405,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 +129466,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
@@ -128703,15 +129479,38 @@
128703 ){
128704 pNew->iSortIdx = b ? iSortIdx : 0;
128705
128706 /* The cost of visiting the index rows is N*K, where K is
128707 ** between 1.1 and 3.0, depending on the relative sizes of the
128708 ** index and table rows. If this is a non-covering index scan,
128709 ** also add the cost of visiting table rows (N*3.0). */
128710 pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;
128711 if( m!=0 ){
128712 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128713 }
128714 ApplyCostMultiplier(pNew->rRun, pTab->costMult);
128715 whereLoopOutputAdjust(pWC, pNew, rSize);
128716 rc = whereLoopInsert(pBuilder, pNew);
128717 pNew->nOut = rSize;
@@ -129076,13 +129875,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 +129968,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 +130014,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 +130025,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 +130076,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 +130103,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 +130143,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 +130672,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 +130732,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 +130879,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 +130893,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 +130912,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 +130944,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 +131024,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 +131062,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 +131204,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 +131243,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 +131259,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 +131323,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 +131446,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 +131798,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 +131904,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 +132492,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 +132602,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 +132806,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 +132818,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 +133006,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 +133058,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 +133077,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 +133139,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 +133168,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 +133181,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 +133194,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 +133287,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 +133311,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 +133333,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 +133560,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 +133594,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 +133678,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 +133715,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 +133729,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 +133771,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 +133805,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 +133819,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 +133877,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 +133899,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 +134085,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 +134556,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 +134984,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 +135024,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 +135070,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 +135086,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 +135127,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 +135138,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 +135188,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 +137526,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 +138297,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 +138309,40 @@
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
@@ -137492,10 +138367,11 @@
137492 db->xProfile = xProfile;
137493 db->pProfileArg = pArg;
137494 sqlite3_mutex_leave(db->mutex);
137495 return pOld;
137496 }
 
137497 #endif /* SQLITE_OMIT_TRACE */
137498
137499 /*
137500 ** Register a function to be invoked when a transaction commits.
137501 ** If the invoked function returns non-zero, then the commit becomes a
@@ -149942,11 +150818,15 @@
149942 }
149943
149944
149945 #ifdef SQLITE_TEST
149946
149947 #include <tcl.h>
 
 
 
 
149948 /* #include <string.h> */
149949
149950 /*
149951 ** Implementation of a special SQL scalar function for testing tokenizers
149952 ** designed to be used in concert with the Tcl testing framework. This
@@ -161881,10 +162761,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 +162858,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 +162869,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 +162890,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 +162973,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 +164909,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 +165842,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 +167428,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 +168476,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 +168487,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 +168680,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 +169695,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 +176196,30 @@
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 +177130,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 },
@@ -176509,11 +177531,11 @@
176509 ** following structure. All structure methods must be defined, setting
176510 ** any member of the fts5_tokenizer struct to NULL leads to undefined
176511 ** behaviour. The structure methods are expected to function as follows:
176512 **
176513 ** xCreate:
176514 ** This function is used to allocate and inititalize a tokenizer instance.
176515 ** A tokenizer instance is required to actually tokenize text.
176516 **
176517 ** The first argument passed to this function is a copy of the (void*)
176518 ** pointer provided by the application when the fts5_tokenizer object
176519 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -176768,11 +177790,10 @@
176768 #if 0
176769 } /* end of the 'extern "C"' block */
176770 #endif
176771
176772 #endif /* _FTS5_H */
176773
176774
176775 /*
176776 ** 2014 May 31
176777 **
176778 ** The author disclaims copyright to this source code. In place of
@@ -177458,11 +178479,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 +178894,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 +178992,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 +179048,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 +179137,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 +179166,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 +179179,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 +179192,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 +179285,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 +179309,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 +179331,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 +179409,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 +179423,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 +179580,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 +179608,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 +179649,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 +179695,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 +179711,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 +179752,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 +179763,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 +179813,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 +184373,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 +192590,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 +194018,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 +194383,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.1. 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:
@@ -65,10 +65,18 @@
65 ** In all cases, the special comment must be enclosed in the usual
66 ** slash-asterisk...asterisk-slash comment marks, with no spaces between the
67 ** asterisks and the comment text.
68 */
69
70 /*
71 ** Make sure the Tcl calling convention macro is defined. This macro is
72 ** only used by test code and Tcl integration code.
73 */
74 #ifndef SQLITE_TCLAPI
75 # define SQLITE_TCLAPI
76 #endif
77
78 /*
79 ** Make sure that rand_s() is available on Windows systems with MSVC 2005
80 ** or higher.
81 */
82 #if defined(_MSC_VER) && _MSC_VER>=1400
@@ -95,12 +103,12 @@
103 **
104 ******************************************************************************
105 **
106 ** This file contains code that is specific to MSVC.
107 */
108 #ifndef SQLITE_MSVC_H
109 #define SQLITE_MSVC_H
110
111 #if defined(_MSC_VER)
112 #pragma warning(disable : 4054)
113 #pragma warning(disable : 4055)
114 #pragma warning(disable : 4100)
@@ -116,11 +124,11 @@
124 #pragma warning(disable : 4306)
125 #pragma warning(disable : 4702)
126 #pragma warning(disable : 4706)
127 #endif /* defined(_MSC_VER) */
128
129 #endif /* SQLITE_MSVC_H */
130
131 /************** End of msvc.h ************************************************/
132 /************** Continuing where we left off in sqliteInt.h ******************/
133
134 /*
@@ -280,12 +288,12 @@
288 ** The name of this file under configuration management is "sqlite.h.in".
289 ** The makefile makes some minor changes to this file (such as inserting
290 ** the version number) and changes its name to "sqlite3.h" as
291 ** part of the build process.
292 */
293 #ifndef SQLITE3_H
294 #define SQLITE3_H
295 #include <stdarg.h> /* Needed for the definition of va_list */
296
297 /*
298 ** Make sure we can call this stuff from C++.
299 */
@@ -304,12 +312,21 @@
312 # define SQLITE_API
313 #endif
314 #ifndef SQLITE_CDECL
315 # define SQLITE_CDECL
316 #endif
317 #ifndef SQLITE_APICALL
318 # define SQLITE_APICALL
319 #endif
320 #ifndef SQLITE_STDCALL
321 # define SQLITE_STDCALL SQLITE_APICALL
322 #endif
323 #ifndef SQLITE_CALLBACK
324 # define SQLITE_CALLBACK
325 #endif
326 #ifndef SQLITE_SYSAPI
327 # define SQLITE_SYSAPI
328 #endif
329
330 /*
331 ** These no-op macros are used in front of interfaces to mark those
332 ** interfaces as either deprecated or experimental. New applications
@@ -361,13 +378,13 @@
378 **
379 ** See also: [sqlite3_libversion()],
380 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
381 ** [sqlite_version()] and [sqlite_source_id()].
382 */
383 #define SQLITE_VERSION "3.14.1"
384 #define SQLITE_VERSION_NUMBER 3014001
385 #define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
386
387 /*
388 ** CAPI3REF: Run-Time Library Version Numbers
389 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
390 **
@@ -756,10 +773,11 @@
773 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
774 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
775 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
776 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
777 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
778 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
779
780 /*
781 ** CAPI3REF: Flags For File Open Operations
782 **
783 ** These bit values are intended for use in the
@@ -1285,10 +1303,20 @@
1303 **
1304 ** Mutexes are created using [sqlite3_mutex_alloc()].
1305 */
1306 typedef struct sqlite3_mutex sqlite3_mutex;
1307
1308 /*
1309 ** CAPI3REF: Loadable Extension Thunk
1310 **
1311 ** A pointer to the opaque sqlite3_api_routines structure is passed as
1312 ** the third parameter to entry points of [loadable extensions]. This
1313 ** structure must be typedefed in order to work around compiler warnings
1314 ** on some platforms.
1315 */
1316 typedef struct sqlite3_api_routines sqlite3_api_routines;
1317
1318 /*
1319 ** CAPI3REF: OS Interface Object
1320 **
1321 ** An instance of the sqlite3_vfs object defines the interface between
1322 ** the SQLite core and the underlying operating system. The "vfs"
@@ -2189,11 +2217,11 @@
2217 ** interface independently of the [load_extension()] SQL function.
2218 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2219 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2220 ** There should be two additional arguments.
2221 ** When the first argument to this interface is 1, then only the C-API is
2222 ** enabled and the SQL function remains disabled. If the first argument to
2223 ** this interface is 0, then both the C-API and the SQL function are disabled.
2224 ** If the first argument is -1, then no changes are made to state of either the
2225 ** C-API or the SQL function.
2226 ** The second parameter is a pointer to an integer into which
2227 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2482,11 +2510,11 @@
2510 ** result in undefined behavior.
2511 **
2512 ** A busy handler must not close the database connection
2513 ** or [prepared statement] that invoked the busy handler.
2514 */
2515 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
2516
2517 /*
2518 ** CAPI3REF: Set A Busy Timeout
2519 ** METHOD: sqlite3
2520 **
@@ -3003,10 +3031,13 @@
3031 #define SQLITE_RECURSIVE 33 /* NULL NULL */
3032
3033 /*
3034 ** CAPI3REF: Tracing And Profiling Functions
3035 ** METHOD: sqlite3
3036 **
3037 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
3038 ** instead of the routines described here.
3039 **
3040 ** These routines register callback functions that can be used for
3041 ** tracing and profiling the execution of SQL statements.
3042 **
3043 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -3029,13 +3060,107 @@
3060 ** digits in the time are meaningless. Future versions of SQLite
3061 ** might provide greater resolution on the profiler callback. The
3062 ** sqlite3_profile() function is considered experimental and is
3063 ** subject to change in future versions of SQLite.
3064 */
3065 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
3066 void(*xTrace)(void*,const char*), void*);
3067 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
3068 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
3069
3070 /*
3071 ** CAPI3REF: SQL Trace Event Codes
3072 ** KEYWORDS: SQLITE_TRACE
3073 **
3074 ** These constants identify classes of events that can be monitored
3075 ** using the [sqlite3_trace_v2()] tracing logic. The third argument
3076 ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
3077 ** the following constants. ^The first argument to the trace callback
3078 ** is one of the following constants.
3079 **
3080 ** New tracing constants may be added in future releases.
3081 **
3082 ** ^A trace callback has four arguments: xCallback(T,C,P,X).
3083 ** ^The T argument is one of the integer type codes above.
3084 ** ^The C argument is a copy of the context pointer passed in as the
3085 ** fourth argument to [sqlite3_trace_v2()].
3086 ** The P and X arguments are pointers whose meanings depend on T.
3087 **
3088 ** <dl>
3089 ** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
3090 ** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
3091 ** first begins running and possibly at other times during the
3092 ** execution of the prepared statement, such as at the start of each
3093 ** trigger subprogram. ^The P argument is a pointer to the
3094 ** [prepared statement]. ^The X argument is a pointer to a string which
3095 ** is the unexpanded SQL text of the prepared statement or an SQL comment
3096 ** that indicates the invocation of a trigger. ^The callback can compute
3097 ** the same text that would have been returned by the legacy [sqlite3_trace()]
3098 ** interface by using the X argument when X begins with "--" and invoking
3099 ** [sqlite3_expanded_sql(P)] otherwise.
3100 **
3101 ** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
3102 ** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
3103 ** information as is provided by the [sqlite3_profile()] callback.
3104 ** ^The P argument is a pointer to the [prepared statement] and the
3105 ** X argument points to a 64-bit integer which is the estimated of
3106 ** the number of nanosecond that the prepared statement took to run.
3107 ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
3108 **
3109 ** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
3110 ** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
3111 ** statement generates a single row of result.
3112 ** ^The P argument is a pointer to the [prepared statement] and the
3113 ** X argument is unused.
3114 **
3115 ** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
3116 ** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
3117 ** connection closes.
3118 ** ^The P argument is a pointer to the [database connection] object
3119 ** and the X argument is unused.
3120 ** </dl>
3121 */
3122 #define SQLITE_TRACE_STMT 0x01
3123 #define SQLITE_TRACE_PROFILE 0x02
3124 #define SQLITE_TRACE_ROW 0x04
3125 #define SQLITE_TRACE_CLOSE 0x08
3126
3127 /*
3128 ** CAPI3REF: SQL Trace Hook
3129 ** METHOD: sqlite3
3130 **
3131 ** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
3132 ** function X against [database connection] D, using property mask M
3133 ** and context pointer P. ^If the X callback is
3134 ** NULL or if the M mask is zero, then tracing is disabled. The
3135 ** M argument should be the bitwise OR-ed combination of
3136 ** zero or more [SQLITE_TRACE] constants.
3137 **
3138 ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
3139 ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
3140 **
3141 ** ^The X callback is invoked whenever any of the events identified by
3142 ** mask M occur. ^The integer return value from the callback is currently
3143 ** ignored, though this may change in future releases. Callback
3144 ** implementations should return zero to ensure future compatibility.
3145 **
3146 ** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
3147 ** ^The T argument is one of the [SQLITE_TRACE]
3148 ** constants to indicate why the callback was invoked.
3149 ** ^The C argument is a copy of the context pointer.
3150 ** The P and X arguments are pointers whose meanings depend on T.
3151 **
3152 ** The sqlite3_trace_v2() interface is intended to replace the legacy
3153 ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
3154 ** are deprecated.
3155 */
3156 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
3157 sqlite3*,
3158 unsigned uMask,
3159 int(*xCallback)(unsigned,void*,void*,void*),
3160 void *pCtx
3161 );
3162
3163 /*
3164 ** CAPI3REF: Query Progress Callbacks
3165 ** METHOD: sqlite3
3166 **
@@ -3651,15 +3776,39 @@
3776
3777 /*
3778 ** CAPI3REF: Retrieving Statement SQL
3779 ** METHOD: sqlite3_stmt
3780 **
3781 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3782 ** SQL text used to create [prepared statement] P if P was
3783 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3784 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3785 ** string containing the SQL text of prepared statement P with
3786 ** [bound parameters] expanded.
3787 **
3788 ** ^(For example, if a prepared statement is created using the SQL
3789 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3790 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3791 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3792 ** will return "SELECT 2345,NULL".)^
3793 **
3794 ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3795 ** is available to hold the result, or if the result would exceed the
3796 ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3797 **
3798 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3799 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3800 ** option causes sqlite3_expanded_sql() to always return NULL.
3801 **
3802 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3803 ** automatically freed when the prepared statement is finalized.
3804 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3805 ** is obtained from [sqlite3_malloc()] and must be free by the application
3806 ** by passing it to [sqlite3_free()].
3807 */
3808 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3809 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3810
3811 /*
3812 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3813 ** METHOD: sqlite3_stmt
3814 **
@@ -4813,16 +4962,17 @@
4962 ** NULL if the metadata has been discarded.
4963 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4964 ** SQLite will invoke the destructor function X with parameter P exactly
4965 ** once, when the metadata is discarded.
4966 ** SQLite is free to discard the metadata at any time, including: <ul>
4967 ** <li> ^(when the corresponding function parameter changes)^, or
4968 ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4969 ** SQL statement)^, or
4970 ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
4971 ** parameter)^, or
4972 ** <li> ^(during the original sqlite3_set_auxdata() call when a memory
4973 ** allocation error occurs.)^ </ul>
4974 **
4975 ** Note the last bullet in particular. The destructor X in
4976 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4977 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4978 ** should be called near the end of the function implementation and the
@@ -5645,11 +5795,11 @@
5795 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5796 ** the final five arguments with appropriate values if the specified
5797 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5798 ** SQLITE_ERROR and if the specified column does not exist.
5799 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5800 ** NULL pointer, then this routine simply checks for the existence of the
5801 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5802 ** does not.
5803 **
5804 ** ^The column is identified by the second, third and fourth parameters to
5805 ** this function. ^(The second parameter is either the name of the database
@@ -5779,12 +5929,12 @@
5929 ** to turn extension loading on and call it with onoff==0 to turn
5930 ** it back off again.
5931 **
5932 ** ^This interface enables or disables both the C-API
5933 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
5934 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5935 ** to enable or disable only the C-API.)^
5936 **
5937 ** <b>Security warning:</b> It is recommended that extension loading
5938 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
5939 ** rather than this interface, so the [load_extension()] SQL function
5940 ** remains disabled. This will prevent SQL injections from giving attackers
@@ -5800,11 +5950,11 @@
5950 ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
5951 ** that is to be automatically loaded into all new database connections.
5952 **
5953 ** ^(Even though the function prototype shows that xEntryPoint() takes
5954 ** no arguments and returns void, SQLite invokes xEntryPoint() with three
5955 ** arguments and expects an integer result as if the signature of the
5956 ** entry point where as follows:
5957 **
5958 ** <blockquote><pre>
5959 ** &nbsp; int xEntryPoint(
5960 ** &nbsp; sqlite3 *db,
@@ -5826,11 +5976,11 @@
5976 ** will be called more than once for each database connection that is opened.
5977 **
5978 ** See also: [sqlite3_reset_auto_extension()]
5979 ** and [sqlite3_cancel_auto_extension()]
5980 */
5981 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
5982
5983 /*
5984 ** CAPI3REF: Cancel Automatic Extension Loading
5985 **
5986 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5838,11 +5988,11 @@
5988 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5989 ** routine returns 1 if initialization routine X was successfully
5990 ** unregistered and it returns 0 if X was not on the list of initialization
5991 ** routines.
5992 */
5993 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
5994
5995 /*
5996 ** CAPI3REF: Reset Automatic Extension Loading
5997 **
5998 ** ^This interface disables all automatic extensions previously
@@ -7014,10 +7164,22 @@
7164 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
7165 ** <dd>This parameter returns the approximate number of bytes of heap
7166 ** memory used by all pager caches associated with the database connection.)^
7167 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
7168 **
7169 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
7170 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
7171 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
7172 ** pager cache is shared between two or more connections the bytes of heap
7173 ** memory used by that pager cache is divided evenly between the attached
7174 ** connections.)^ In other words, if none of the pager caches associated
7175 ** with the database connection are shared, this request returns the same
7176 ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
7177 ** shared, the value returned by this call will be smaller than that returned
7178 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
7179 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
7180 **
7181 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
7182 ** <dd>This parameter returns the approximate number of bytes of heap
7183 ** memory used to store the schema for all databases associated
7184 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
7185 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -7071,11 +7233,12 @@
7233 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
7234 #define SQLITE_DBSTATUS_CACHE_HIT 7
7235 #define SQLITE_DBSTATUS_CACHE_MISS 8
7236 #define SQLITE_DBSTATUS_CACHE_WRITE 9
7237 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
7238 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
7239 #define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
7240
7241
7242 /*
7243 ** CAPI3REF: Prepared Statement Status
7244 ** METHOD: sqlite3_stmt
@@ -8227,11 +8390,11 @@
8390 ** tables.
8391 **
8392 ** ^The second parameter to the preupdate callback is a pointer to
8393 ** the [database connection] that registered the preupdate hook.
8394 ** ^The third parameter to the preupdate callback is one of the constants
8395 ** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
8396 ** kind of update operation that is about to occur.
8397 ** ^(The fourth parameter to the preupdate callback is the name of the
8398 ** database within the database connection that is being modified. This
8399 ** will be "main" for the main database or "temp" for TEMP tables or
8400 ** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8454,11 +8617,11 @@
8617 #endif
8618
8619 #if 0
8620 } /* End of the 'extern "C"' block */
8621 #endif
8622 #endif /* SQLITE3_H */
8623
8624 /******** Begin file sqlite3rtree.h *********/
8625 /*
8626 ** 2010 August 30
8627 **
@@ -10174,11 +10337,11 @@
10337 ** following structure. All structure methods must be defined, setting
10338 ** any member of the fts5_tokenizer struct to NULL leads to undefined
10339 ** behaviour. The structure methods are expected to function as follows:
10340 **
10341 ** xCreate:
10342 ** This function is used to allocate and initialize a tokenizer instance.
10343 ** A tokenizer instance is required to actually tokenize text.
10344 **
10345 ** The first argument passed to this function is a copy of the (void*)
10346 ** pointer provided by the application when the fts5_tokenizer object
10347 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10433,11 +10596,10 @@
10596 #if 0
10597 } /* end of the 'extern "C"' block */
10598 #endif
10599
10600 #endif /* _FTS5_H */
 
10601
10602 /******** End of fts5.h *********/
10603
10604 /************** End of sqlite3.h *********************************************/
10605 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -10732,11 +10894,11 @@
10894 ** Make sure that the compiler intrinsics we desire are enabled when
10895 ** compiling with an appropriate version of MSVC unless prevented by
10896 ** the SQLITE_DISABLE_INTRINSIC define.
10897 */
10898 #if !defined(SQLITE_DISABLE_INTRINSIC)
10899 # if defined(_MSC_VER) && _MSC_VER>=1400
10900 # if !defined(_WIN32_WCE)
10901 # include <intrin.h>
10902 # pragma intrinsic(_byteswap_ushort)
10903 # pragma intrinsic(_byteswap_ulong)
10904 # pragma intrinsic(_ReadWriteBarrier)
@@ -11009,12 +11171,12 @@
11171 **
11172 *************************************************************************
11173 ** This is the header file for the generic hash-table implementation
11174 ** used in SQLite.
11175 */
11176 #ifndef SQLITE_HASH_H
11177 #define SQLITE_HASH_H
11178
11179 /* Forward declarations of structures. */
11180 typedef struct Hash Hash;
11181 typedef struct HashElem HashElem;
11182
@@ -11090,11 +11252,11 @@
11252 /*
11253 ** Number of entries in a hash table
11254 */
11255 /* #define sqliteHashCount(H) ((H)->count) // NOT USED */
11256
11257 #endif /* SQLITE_HASH_H */
11258
11259 /************** End of hash.h ************************************************/
11260 /************** Continuing where we left off in sqliteInt.h ******************/
11261 /************** Include parse.h in the middle of sqliteInt.h *****************/
11262 /************** Begin file parse.h *******************************************/
@@ -11838,12 +12000,12 @@
12000 *************************************************************************
12001 ** This header file defines the interface that the sqlite B-Tree file
12002 ** subsystem. See comments in the source code for a detailed description
12003 ** of what each interface routine does.
12004 */
12005 #ifndef SQLITE_BTREE_H
12006 #define SQLITE_BTREE_H
12007
12008 /* TODO: This definition is just included so other modules compile. It
12009 ** needs to be revisited.
12010 */
12011 #define SQLITE_N_BTREE_META 16
@@ -11864,10 +12026,11 @@
12026 ** Forward declarations of structure
12027 */
12028 typedef struct Btree Btree;
12029 typedef struct BtCursor BtCursor;
12030 typedef struct BtShared BtShared;
12031 typedef struct BtreePayload BtreePayload;
12032
12033
12034 SQLITE_PRIVATE int sqlite3BtreeOpen(
12035 sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
12036 const char *zFilename, /* Name of database file to open */
@@ -12075,23 +12238,47 @@
12238
12239 /* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
12240 #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
12241 #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
12242
12243 /* An instance of the BtreePayload object describes the content of a single
12244 ** entry in either an index or table btree.
12245 **
12246 ** Index btrees (used for indexes and also WITHOUT ROWID tables) contain
12247 ** an arbitrary key and no data. These btrees have pKey,nKey set to their
12248 ** key and pData,nData,nZero set to zero.
12249 **
12250 ** Table btrees (used for rowid tables) contain an integer rowid used as
12251 ** the key and passed in the nKey field. The pKey field is zero.
12252 ** pData,nData hold the content of the new entry. nZero extra zero bytes
12253 ** are appended to the end of the content when constructing the entry.
12254 **
12255 ** This object is used to pass information into sqlite3BtreeInsert(). The
12256 ** same information used to be passed as five separate parameters. But placing
12257 ** the information into this object helps to keep the interface more
12258 ** organized and understandable, and it also helps the resulting code to
12259 ** run a little faster by using fewer registers for parameter passing.
12260 */
12261 struct BtreePayload {
12262 const void *pKey; /* Key content for indexes. NULL for tables */
12263 sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
12264 const void *pData; /* Data for tables. NULL for indexes */
12265 int nData; /* Size of pData. 0 if none. */
12266 int nZero; /* Extra zero data appended after pData,nData */
12267 };
12268
12269 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
12270 int bias, int seekResult);
12271 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
12272 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
12273 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
12274 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
12275 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12276 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
12277 SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
12278 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12279 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
 
12280 SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
12281
12282 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
12283 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
12284
@@ -12128,15 +12315,17 @@
12315 #ifndef SQLITE_OMIT_SHARED_CACHE
12316 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
12317 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
12318 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*);
12319 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
12320 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*);
12321 #else
12322 # define sqlite3BtreeEnter(X)
12323 # define sqlite3BtreeEnterAll(X)
12324 # define sqlite3BtreeSharable(X) 0
12325 # define sqlite3BtreeEnterCursor(X)
12326 # define sqlite3BtreeConnectionCount(X) 1
12327 #endif
12328
12329 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
12330 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
12331 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
@@ -12157,11 +12346,11 @@
12346 # define sqlite3BtreeHoldsAllMutexes(X) 1
12347 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
12348 #endif
12349
12350
12351 #endif /* SQLITE_BTREE_H */
12352
12353 /************** End of btree.h ***********************************************/
12354 /************** Continuing where we left off in sqliteInt.h ******************/
12355 /************** Include vdbe.h in the middle of sqliteInt.h ******************/
12356 /************** Begin file vdbe.h ********************************************/
@@ -12180,12 +12369,12 @@
12369 **
12370 ** This header defines the interface to the virtual database engine
12371 ** or VDBE. The VDBE implements an abstract machine that runs a
12372 ** simple program to access and modify the underlying database.
12373 */
12374 #ifndef SQLITE_VDBE_H
12375 #define SQLITE_VDBE_H
12376 /* #include <stdio.h> */
12377
12378 /*
12379 ** A single VDBE is an opaque structure named "Vdbe". Only routines
12380 ** in the source file sqliteVdbe.c are allowed to see the insides
@@ -12366,21 +12555,21 @@
12555 #define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
12556 #define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
12557 #define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */
12558 #define OP_NotFound 30 /* synopsis: key=r[P3@P4] */
12559 #define OP_Found 31 /* synopsis: key=r[P3@P4] */
12560 #define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12561 #define OP_NotExists 33 /* synopsis: intkey=r[P3] */
12562 #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
12563 #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12564 #define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
12565 #define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
12566 #define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
12567 #define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
12568 #define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
12569 #define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12570 #define OP_Last 42
12571 #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
12572 #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
12573 #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
12574 #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
12575 #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12387,118 +12576,119 @@
12576 #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
12577 #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
12578 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12579 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12580 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12581 #define OP_SorterSort 53
12582 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12583 #define OP_Sort 55
12584 #define OP_Rewind 56
12585 #define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12586 #define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12587 #define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12588 #define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12589 #define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12590 #define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12591 #define OP_Program 63
12592 #define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12593 #define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12594 #define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12595 #define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12596 #define OP_IncrVacuum 68
12597 #define OP_VNext 69
12598 #define OP_Init 70 /* synopsis: Start at P2 */
12599 #define OP_Return 71
12600 #define OP_EndCoroutine 72
12601 #define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12602 #define OP_Halt 74
12603 #define OP_Integer 75 /* synopsis: r[P2]=P1 */
12604 #define OP_Int64 76 /* synopsis: r[P2]=P4 */
12605 #define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12606 #define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12607 #define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12608 #define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12609 #define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12610 #define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12611 #define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12612 #define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12613 #define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12614 #define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12615 #define OP_CollSeq 87
12616 #define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12617 #define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12618 #define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12619 #define OP_RealAffinity 91
12620 #define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12621 #define OP_Permutation 93
12622 #define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12623 #define OP_Column 95 /* synopsis: r[P3]=PX */
12624 #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
12625 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12626 #define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12627 #define OP_Count 99 /* synopsis: r[P2]=count() */
12628 #define OP_ReadCookie 100
12629 #define OP_SetCookie 101
12630 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12631 #define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12632 #define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12633 #define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12634 #define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12635 #define OP_SorterOpen 107
12636 #define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12637 #define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12638 #define OP_Close 110
12639 #define OP_ColumnsUsed 111
12640 #define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12641 #define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12642 #define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12643 #define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12644 #define OP_Delete 116
12645 #define OP_ResetCount 117
12646 #define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12647 #define OP_SorterData 119 /* synopsis: r[P2]=data */
12648 #define OP_RowKey 120 /* synopsis: r[P2]=key */
12649 #define OP_RowData 121 /* synopsis: r[P2]=data */
12650 #define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12651 #define OP_NullRow 123
12652 #define OP_SorterInsert 124
12653 #define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12654 #define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12655 #define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12656 #define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12657 #define OP_Destroy 129
12658 #define OP_Clear 130
12659 #define OP_ResetSorter 131
12660 #define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
12661 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12662 #define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12663 #define OP_ParseSchema 135
12664 #define OP_LoadAnalysis 136
12665 #define OP_DropTable 137
12666 #define OP_DropIndex 138
12667 #define OP_DropTrigger 139
12668 #define OP_IntegrityCk 140
12669 #define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12670 #define OP_Param 142
12671 #define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12672 #define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12673 #define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12674 #define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12675 #define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12676 #define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12677 #define OP_Expire 149
12678 #define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12679 #define OP_VBegin 151
12680 #define OP_VCreate 152
12681 #define OP_VDestroy 153
12682 #define OP_VOpen 154
12683 #define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12684 #define OP_VRename 156
12685 #define OP_Pagecount 157
12686 #define OP_MaxPgcnt 158
12687 #define OP_CursorHint 159
12688 #define OP_Noop 160
12689 #define OP_Explain 161
12690
12691 /* Properties such as "out2" or "jump" that are specified in
12692 ** comments following the "case" for each opcode in the vdbe.c
12693 ** are encoded into bitvectors as follows:
12694 */
@@ -12511,35 +12701,35 @@
12701 #define OPFLG_INITIALIZER {\
12702 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
12703 /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
12704 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12705 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12706 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12707 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12708 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12709 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12710 /* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12711 /* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12712 /* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12713 /* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12714 /* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12715 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12716 /* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12717 /* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12718 /* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12719 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12720 /* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12721 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12722 /* 160 */ 0x00, 0x00,}
12723
12724 /* The sqlite3P2Values() routine is able to run faster if it knows
12725 ** the value of the largest JUMP opcode. The smaller the maximum
12726 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12727 ** generated this include file strives to group all JUMP opcodes
12728 ** together near the beginning of the list.
12729 */
12730 #define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
12731
12732 /************** End of opcodes.h *********************************************/
12733 /************** Continuing where we left off in vdbe.h ***********************/
12734
12735 /*
@@ -12682,11 +12872,11 @@
12872 SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
12873 #else
12874 # define sqlite3VdbeScanStatus(a,b,c,d,e)
12875 #endif
12876
12877 #endif /* SQLITE_VDBE_H */
12878
12879 /************** End of vdbe.h ************************************************/
12880 /************** Continuing where we left off in sqliteInt.h ******************/
12881 /************** Include pager.h in the middle of sqliteInt.h *****************/
12882 /************** Begin file pager.h *******************************************/
@@ -12704,12 +12894,12 @@
12894 ** This header file defines the interface that the sqlite page cache
12895 ** subsystem. The page cache subsystem reads and writes a file a page
12896 ** at a time and provides a journal for rollback.
12897 */
12898
12899 #ifndef SQLITE_PAGER_H
12900 #define SQLITE_PAGER_H
12901
12902 /*
12903 ** Default maximum size for persistent journal files. A negative
12904 ** value means no limit. This value may be overridden using the
12905 ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
@@ -12893,11 +13083,11 @@
13083 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
13084 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
13085 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
13086 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
13087 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
13088 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);
13089 SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
13090
13091 /* Functions used to truncate the database file. */
13092 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
13093
@@ -12920,11 +13110,11 @@
13110 #else
13111 # define disable_simulated_io_errors()
13112 # define enable_simulated_io_errors()
13113 #endif
13114
13115 #endif /* SQLITE_PAGER_H */
13116
13117 /************** End of pager.h ***********************************************/
13118 /************** Continuing where we left off in sqliteInt.h ******************/
13119 /************** Include pcache.h in the middle of sqliteInt.h ****************/
13120 /************** Begin file pcache.h ******************************************/
@@ -13158,12 +13348,12 @@
13348 ******************************************************************************
13349 **
13350 ** This file contains pre-processor directives related to operating system
13351 ** detection and/or setup.
13352 */
13353 #ifndef SQLITE_OS_SETUP_H
13354 #define SQLITE_OS_SETUP_H
13355
13356 /*
13357 ** Figure out if we are dealing with Unix, Windows, or some other operating
13358 ** system.
13359 **
@@ -13199,11 +13389,11 @@
13389 # ifndef SQLITE_OS_WIN
13390 # define SQLITE_OS_WIN 0
13391 # endif
13392 #endif
13393
13394 #endif /* SQLITE_OS_SETUP_H */
13395
13396 /************** End of os_setup.h ********************************************/
13397 /************** Continuing where we left off in os.h *************************/
13398
13399 /* If the SET_FULLSYNC macro is not defined above, then make it
@@ -13656,10 +13846,19 @@
13846 #else
13847 typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
13848 const char*);
13849 #endif
13850
13851 #ifndef SQLITE_OMIT_DEPRECATED
13852 /* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
13853 ** in the style of sqlite3_trace()
13854 */
13855 #define SQLITE_TRACE_LEGACY 0x80
13856 #else
13857 #define SQLITE_TRACE_LEGACY 0
13858 #endif /* SQLITE_OMIT_DEPRECATED */
13859
13860
13861 /*
13862 ** Each database connection is an instance of the following structure.
13863 */
13864 struct sqlite3 {
@@ -13685,10 +13884,11 @@
13884 u8 dfltLockMode; /* Default locking-mode for attached dbs */
13885 signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
13886 u8 suppressErr; /* Do not issue error messages if true */
13887 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
13888 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
13889 u8 mTrace; /* zero or more SQLITE_TRACE flags */
13890 int nextPagesize; /* Pagesize after VACUUM if >0 */
13891 u32 magic; /* Magic number for detect library misuse */
13892 int nChange; /* Value returned by sqlite3_changes() */
13893 int nTotalChange; /* Value returned by sqlite3_total_changes() */
13894 int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -13705,11 +13905,11 @@
13905 int nVdbeWrite; /* Number of active VDBEs that read and write */
13906 int nVdbeExec; /* Number of nested calls to VdbeExec() */
13907 int nVDestroy; /* Number of active OP_VDestroy operations */
13908 int nExtension; /* Number of loaded extensions */
13909 void **aExtension; /* Array of shared library handles */
13910 int (*xTrace)(u32,void*,void*,void*); /* Trace function */
13911 void *pTraceArg; /* Argument to the trace function */
13912 void (*xProfile)(void*,const char*,u64); /* Profiling function */
13913 void *pProfileArg; /* Argument to profile function */
13914 void *pCommitArg; /* Argument to xCommitCallback() */
13915 int (*xCommitCallback)(void*); /* Invoked at every commit. */
@@ -14900,11 +15100,11 @@
15100 Select *pSelect; /* A SELECT statement used in place of a table name */
15101 int addrFillSub; /* Address of subroutine to manifest a subquery */
15102 int regReturn; /* Register holding return address of addrFillSub */
15103 int regResult; /* Registers holding results of a co-routine */
15104 struct {
15105 u8 jointype; /* Type of join between this table and the previous */
15106 unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
15107 unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
15108 unsigned isTabFunc :1; /* True if table-valued-function syntax */
15109 unsigned isCorrelated :1; /* True if sub-query is correlated */
15110 unsigned viaCoroutine :1; /* Implemented as a co-routine */
@@ -14946,23 +15146,24 @@
15146 */
15147 #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */
15148 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
15149 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
15150 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
15151 #define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */
15152 #define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */
15153 #define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of
15154 ** the OR optimization */
15155 #define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */
15156 #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */
15157 #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */
15158 #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */
15159 #define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
15160 #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
15161 /* 0x1000 not currently used */
15162 /* 0x2000 not currently used */
15163 #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
15164 /* 0x8000 not currently used */
15165
15166 /* Allowed return values from sqlite3WhereIsDistinct()
15167 */
15168 #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */
15169 #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */
@@ -15661,10 +15862,11 @@
15862 int iCur; /* A cursor number */
15863 SrcList *pSrcList; /* FROM clause */
15864 struct SrcCount *pSrcCount; /* Counting column references */
15865 struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
15866 int *aiCol; /* array of column indexes */
15867 struct IdxCover *pIdxCover; /* Check for index coverage */
15868 } u;
15869 };
15870
15871 /* Forward declarations */
15872 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -15844,15 +16046,19 @@
16046 # define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N)
16047 # define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N)
16048 # define sqlite3StackFree(D,P) sqlite3DbFree(D,P)
16049 #endif
16050
16051 /* Do not allow both MEMSYS5 and MEMSYS3 to be defined together. If they
16052 ** are, disable MEMSYS3
16053 */
16054 #ifdef SQLITE_ENABLE_MEMSYS5
16055 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
16056 #undef SQLITE_ENABLE_MEMSYS3
16057 #endif
16058 #ifdef SQLITE_ENABLE_MEMSYS3
16059 SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);
16060 #endif
16061
16062
16063 #ifndef SQLITE_MUTEX_OMIT
16064 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
@@ -16031,12 +16237,12 @@
16237 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
16238 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
16239 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
16240 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
16241 SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);
16242 SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
16243 Expr*, int, int, u8);
16244 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
16245 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
16246 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
16247 Expr*,ExprList*,u32,Expr*,Expr*);
16248 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -16051,10 +16257,11 @@
16257 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
16258 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
16259 SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
16260 SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
16261 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
16262 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
16263 SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
16264 SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
16265 SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
16266 SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
16267 #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */
@@ -16084,12 +16291,14 @@
16291 #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */
16292 SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
16293 SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
16294 SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
16295 SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
16296 #define LOCATE_VIEW 0x01
16297 #define LOCATE_NOERR 0x02
16298 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
16299 SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
16300 SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
16301 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
16302 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16303 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
16304 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
@@ -16097,10 +16306,11 @@
16306 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
16307 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
16308 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
16309 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
16310 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
16311 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
16312 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
16313 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
16314 #ifndef SQLITE_OMIT_BUILTIN_TEST
16315 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
16316 SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
@@ -16648,11 +16858,11 @@
16858
16859 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
16860 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
16861 #endif
16862
16863 #endif /* SQLITEINT_H */
16864
16865 /************** End of sqliteInt.h *******************************************/
16866 /************** Begin file global.c ******************************************/
16867 /*
16868 ** 2008 June 13
@@ -16983,10 +17193,19 @@
17193 "CASE_SENSITIVE_LIKE",
17194 #endif
17195 #if SQLITE_CHECK_PAGES
17196 "CHECK_PAGES",
17197 #endif
17198 #if defined(__clang__) && defined(__clang_major__)
17199 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
17200 CTIMEOPT_VAL(__clang_minor__) "."
17201 CTIMEOPT_VAL(__clang_patchlevel__),
17202 #elif defined(_MSC_VER)
17203 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17204 #elif defined(__GNUC__) && defined(__VERSION__)
17205 "COMPILER=gcc-" __VERSION__,
17206 #endif
17207 #if SQLITE_COVERAGE_TEST
17208 "COVERAGE_TEST",
17209 #endif
17210 #if SQLITE_DEBUG
17211 "DEBUG",
@@ -17002,11 +17221,11 @@
17221 #endif
17222 #if SQLITE_DISABLE_LFS
17223 "DISABLE_LFS",
17224 #endif
17225 #if SQLITE_ENABLE_8_3_NAMES
17226 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
17227 #endif
17228 #if SQLITE_ENABLE_API_ARMOR
17229 "ENABLE_API_ARMOR",
17230 #endif
17231 #if SQLITE_ENABLE_ATOMIC_WRITE
@@ -17416,12 +17635,12 @@
17635 ** VDBE. This information used to all be at the top of the single
17636 ** source code file "vdbe.c". When that file became too big (over
17637 ** 6000 lines long) it was split up into several smaller files and
17638 ** this header information was factored out.
17639 */
17640 #ifndef SQLITE_VDBEINT_H
17641 #define SQLITE_VDBEINT_H
17642
17643 /*
17644 ** The maximum number of times that a statement will try to reparse
17645 ** itself before giving up and returning SQLITE_SCHEMA.
17646 */
@@ -17959,11 +18178,11 @@
18178 #else
18179 #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
18180 #define ExpandBlob(P) SQLITE_OK
18181 #endif
18182
18183 #endif /* !defined(SQLITE_VDBEINT_H) */
18184
18185 /************** End of vdbeInt.h *********************************************/
18186 /************** Continuing where we left off in status.c *********************/
18187
18188 /*
@@ -18106,11 +18325,11 @@
18325 sqlite3_mutex_leave(pMutex);
18326 (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
18327 return SQLITE_OK;
18328 }
18329 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
18330 sqlite3_int64 iCur = 0, iHwtr = 0;
18331 int rc;
18332 #ifdef SQLITE_ENABLE_API_ARMOR
18333 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
18334 #endif
18335 rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
@@ -18167,19 +18386,24 @@
18386 /*
18387 ** Return an approximation for the amount of memory currently used
18388 ** by all pagers associated with the given database connection. The
18389 ** highwater mark is meaningless and is returned as zero.
18390 */
18391 case SQLITE_DBSTATUS_CACHE_USED_SHARED:
18392 case SQLITE_DBSTATUS_CACHE_USED: {
18393 int totalUsed = 0;
18394 int i;
18395 sqlite3BtreeEnterAll(db);
18396 for(i=0; i<db->nDb; i++){
18397 Btree *pBt = db->aDb[i].pBt;
18398 if( pBt ){
18399 Pager *pPager = sqlite3BtreePager(pBt);
18400 int nByte = sqlite3PagerMemUsed(pPager);
18401 if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){
18402 nByte = nByte / sqlite3BtreeConnectionCount(pBt);
18403 }
18404 totalUsed += nByte;
18405 }
18406 }
18407 sqlite3BtreeLeaveAll(db);
18408 *pCurrent = totalUsed;
18409 *pHighwater = 0;
@@ -19409,11 +19633,10 @@
19633 int argc,
19634 sqlite3_value **argv
19635 ){
19636 time_t t;
19637 char *zFormat = (char *)sqlite3_user_data(context);
 
19638 sqlite3_int64 iT;
19639 struct tm *pTm;
19640 struct tm sNow;
19641 char zBuf[20];
19642
@@ -19478,13 +19701,11 @@
19701 ******************************************************************************
19702 **
19703 ** This file contains OS interface code that is common to all
19704 ** architectures.
19705 */
 
19706 /* #include "sqliteInt.h" */
 
19707
19708 /*
19709 ** If we compile with the SQLITE_TEST macro set, then the following block
19710 ** of code will give us the ability to simulate a disk I/O error. This
19711 ** is used for testing the I/O recovery logic.
@@ -22993,12 +23214,12 @@
23214 ******************************************************************************
23215 **
23216 ** This file contains inline asm code for retrieving "high-performance"
23217 ** counters for x86 class CPUs.
23218 */
23219 #ifndef SQLITE_HWTIME_H
23220 #define SQLITE_HWTIME_H
23221
23222 /*
23223 ** The following routine only works on pentium-class (or newer) processors.
23224 ** It uses the RDTSC opcode to read the cycle count value out of the
23225 ** processor and returns that value. This can be used for high-res
@@ -23062,11 +23283,11 @@
23283 */
23284 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
23285
23286 #endif
23287
23288 #endif /* !defined(SQLITE_HWTIME_H) */
23289
23290 /************** End of hwtime.h **********************************************/
23291 /************** Continuing where we left off in os_common.h ******************/
23292
23293 static sqlite_uint64 g_start;
@@ -23152,12 +23373,12 @@
23373 **
23374 ******************************************************************************
23375 **
23376 ** This file contains code that is specific to Windows.
23377 */
23378 #ifndef SQLITE_OS_WIN_H
23379 #define SQLITE_OS_WIN_H
23380
23381 /*
23382 ** Include the primary Windows SDK header file.
23383 */
23384 #include "windows.h"
@@ -23225,11 +23446,11 @@
23446 # define SQLITE_OS_WIN_THREADS 1
23447 #else
23448 # define SQLITE_OS_WIN_THREADS 0
23449 #endif
23450
23451 #endif /* SQLITE_OS_WIN_H */
23452
23453 /************** End of os_win.h **********************************************/
23454 /************** Continuing where we left off in mutex_w32.c ******************/
23455 #endif
23456
@@ -25976,10 +26197,16 @@
26197 }
26198 sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken);
26199 break;
26200 }
26201 #endif
26202 case TK_MATCH: {
26203 sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26204 pExpr->iTable, pExpr->iColumn, zFlgs);
26205 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26206 break;
26207 }
26208 default: {
26209 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
26210 break;
26211 }
26212 }
@@ -28759,21 +28986,21 @@
28986 /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
28987 /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
28988 /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
28989 /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
28990 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
28991 /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
28992 /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
28993 /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
28994 /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
28995 /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
28996 /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
28997 /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
28998 /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
28999 /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
29000 /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
29001 /* 42 */ "Last" OpHelp(""),
29002 /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
29003 /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
29004 /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
29005 /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
29006 /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -28780,118 +29007,119 @@
29007 /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
29008 /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
29009 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
29010 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
29011 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29012 /* 53 */ "SorterSort" OpHelp(""),
29013 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29014 /* 55 */ "Sort" OpHelp(""),
29015 /* 56 */ "Rewind" OpHelp(""),
29016 /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29017 /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29018 /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29019 /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29020 /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29021 /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29022 /* 63 */ "Program" OpHelp(""),
29023 /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29024 /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29025 /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29026 /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29027 /* 68 */ "IncrVacuum" OpHelp(""),
29028 /* 69 */ "VNext" OpHelp(""),
29029 /* 70 */ "Init" OpHelp("Start at P2"),
29030 /* 71 */ "Return" OpHelp(""),
29031 /* 72 */ "EndCoroutine" OpHelp(""),
29032 /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29033 /* 74 */ "Halt" OpHelp(""),
29034 /* 75 */ "Integer" OpHelp("r[P2]=P1"),
29035 /* 76 */ "Int64" OpHelp("r[P2]=P4"),
29036 /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29037 /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29038 /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29039 /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29040 /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29041 /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29042 /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29043 /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29044 /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29045 /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29046 /* 87 */ "CollSeq" OpHelp(""),
29047 /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29048 /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29049 /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29050 /* 91 */ "RealAffinity" OpHelp(""),
29051 /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29052 /* 93 */ "Permutation" OpHelp(""),
29053 /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29054 /* 95 */ "Column" OpHelp("r[P3]=PX"),
29055 /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29056 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29057 /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29058 /* 99 */ "Count" OpHelp("r[P2]=count()"),
29059 /* 100 */ "ReadCookie" OpHelp(""),
29060 /* 101 */ "SetCookie" OpHelp(""),
29061 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29062 /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29063 /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29064 /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29065 /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29066 /* 107 */ "SorterOpen" OpHelp(""),
29067 /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29068 /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29069 /* 110 */ "Close" OpHelp(""),
29070 /* 111 */ "ColumnsUsed" OpHelp(""),
29071 /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29072 /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29073 /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29074 /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29075 /* 116 */ "Delete" OpHelp(""),
29076 /* 117 */ "ResetCount" OpHelp(""),
29077 /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29078 /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29079 /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29080 /* 121 */ "RowData" OpHelp("r[P2]=data"),
29081 /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29082 /* 123 */ "NullRow" OpHelp(""),
29083 /* 124 */ "SorterInsert" OpHelp(""),
29084 /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29085 /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29086 /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29087 /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29088 /* 129 */ "Destroy" OpHelp(""),
29089 /* 130 */ "Clear" OpHelp(""),
29090 /* 131 */ "ResetSorter" OpHelp(""),
29091 /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29092 /* 133 */ "Real" OpHelp("r[P2]=P4"),
29093 /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29094 /* 135 */ "ParseSchema" OpHelp(""),
29095 /* 136 */ "LoadAnalysis" OpHelp(""),
29096 /* 137 */ "DropTable" OpHelp(""),
29097 /* 138 */ "DropIndex" OpHelp(""),
29098 /* 139 */ "DropTrigger" OpHelp(""),
29099 /* 140 */ "IntegrityCk" OpHelp(""),
29100 /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29101 /* 142 */ "Param" OpHelp(""),
29102 /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29103 /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29104 /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29105 /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29106 /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29107 /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29108 /* 149 */ "Expire" OpHelp(""),
29109 /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29110 /* 151 */ "VBegin" OpHelp(""),
29111 /* 152 */ "VCreate" OpHelp(""),
29112 /* 153 */ "VDestroy" OpHelp(""),
29113 /* 154 */ "VOpen" OpHelp(""),
29114 /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29115 /* 156 */ "VRename" OpHelp(""),
29116 /* 157 */ "Pagecount" OpHelp(""),
29117 /* 158 */ "MaxPgcnt" OpHelp(""),
29118 /* 159 */ "CursorHint" OpHelp(""),
29119 /* 160 */ "Noop" OpHelp(""),
29120 /* 161 */ "Explain" OpHelp(""),
29121 };
29122 return azName[i];
29123 }
29124 #endif
29125
@@ -29237,12 +29465,12 @@
29465 ******************************************************************************
29466 **
29467 ** This file contains inline asm code for retrieving "high-performance"
29468 ** counters for x86 class CPUs.
29469 */
29470 #ifndef SQLITE_HWTIME_H
29471 #define SQLITE_HWTIME_H
29472
29473 /*
29474 ** The following routine only works on pentium-class (or newer) processors.
29475 ** It uses the RDTSC opcode to read the cycle count value out of the
29476 ** processor and returns that value. This can be used for high-res
@@ -29306,11 +29534,11 @@
29534 */
29535 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
29536
29537 #endif
29538
29539 #endif /* !defined(SQLITE_HWTIME_H) */
29540
29541 /************** End of hwtime.h **********************************************/
29542 /************** Continuing where we left off in os_common.h ******************/
29543
29544 static sqlite_uint64 g_start;
@@ -36766,12 +36994,12 @@
36994 ******************************************************************************
36995 **
36996 ** This file contains inline asm code for retrieving "high-performance"
36997 ** counters for x86 class CPUs.
36998 */
36999 #ifndef SQLITE_HWTIME_H
37000 #define SQLITE_HWTIME_H
37001
37002 /*
37003 ** The following routine only works on pentium-class (or newer) processors.
37004 ** It uses the RDTSC opcode to read the cycle count value out of the
37005 ** processor and returns that value. This can be used for high-res
@@ -36835,11 +37063,11 @@
37063 */
37064 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
37065
37066 #endif
37067
37068 #endif /* !defined(SQLITE_HWTIME_H) */
37069
37070 /************** End of hwtime.h **********************************************/
37071 /************** Continuing where we left off in os_common.h ******************/
37072
37073 static sqlite_uint64 g_start;
@@ -37175,10 +37403,21 @@
37403 sqlite3_int64 mmapSize; /* Usable size of mapped region */
37404 sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */
37405 sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */
37406 #endif
37407 };
37408
37409 /*
37410 ** The winVfsAppData structure is used for the pAppData member for all of the
37411 ** Win32 VFS variants.
37412 */
37413 typedef struct winVfsAppData winVfsAppData;
37414 struct winVfsAppData {
37415 const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */
37416 void *pAppData; /* The extra pAppData, if any. */
37417 BOOL bNoLock; /* Non-zero if locking is disabled. */
37418 };
37419
37420 /*
37421 ** Allowed values for winFile.ctrlFlags
37422 */
37423 #define WINFILE_RDONLY 0x02 /* Connection is read only */
@@ -39497,11 +39736,16 @@
39736 rc = osCloseHandle(pFile->h);
39737 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
39738 }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );
39739 #if SQLITE_OS_WINCE
39740 #define WINCE_DELETION_ATTEMPTS 3
39741 {
39742 winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;
39743 if( pAppData==NULL || !pAppData->bNoLock ){
39744 winceDestroyLock(pFile);
39745 }
39746 }
39747 if( pFile->zDeleteOnClose ){
39748 int cnt = 0;
39749 while(
39750 osDeleteFileW(pFile->zDeleteOnClose)==0
39751 && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
@@ -40229,10 +40473,48 @@
40473 OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
40474 pFile->h, pFile->locktype, sqlite3ErrName(rc)));
40475 return rc;
40476 }
40477
40478 /******************************************************************************
40479 ****************************** No-op Locking **********************************
40480 **
40481 ** Of the various locking implementations available, this is by far the
40482 ** simplest: locking is ignored. No attempt is made to lock the database
40483 ** file for reading or writing.
40484 **
40485 ** This locking mode is appropriate for use on read-only databases
40486 ** (ex: databases that are burned into CD-ROM, for example.) It can
40487 ** also be used if the application employs some external mechanism to
40488 ** prevent simultaneous access of the same database by two or more
40489 ** database connections. But there is a serious risk of database
40490 ** corruption if this locking mode is used in situations where multiple
40491 ** database connections are accessing the same database file at the same
40492 ** time and one or more of those connections are writing.
40493 */
40494
40495 static int winNolockLock(sqlite3_file *id, int locktype){
40496 UNUSED_PARAMETER(id);
40497 UNUSED_PARAMETER(locktype);
40498 return SQLITE_OK;
40499 }
40500
40501 static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){
40502 UNUSED_PARAMETER(id);
40503 UNUSED_PARAMETER(pResOut);
40504 return SQLITE_OK;
40505 }
40506
40507 static int winNolockUnlock(sqlite3_file *id, int locktype){
40508 UNUSED_PARAMETER(id);
40509 UNUSED_PARAMETER(locktype);
40510 return SQLITE_OK;
40511 }
40512
40513 /******************* End of the no-op lock implementation *********************
40514 ******************************************************************************/
40515
40516 /*
40517 ** If *pArg is initially negative then this is a query. Set *pArg to
40518 ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
40519 **
40520 ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
@@ -40507,16 +40789,16 @@
40789 #define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
40790
40791 /*
40792 ** Apply advisory locks for all n bytes beginning at ofst.
40793 */
40794 #define WINSHM_UNLCK 1
40795 #define WINSHM_RDLCK 2
40796 #define WINSHM_WRLCK 3
40797 static int winShmSystemLock(
40798 winShmNode *pFile, /* Apply locks to this open shared-memory segment */
40799 int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */
40800 int ofst, /* Offset to first byte to be locked/unlocked */
40801 int nByte /* Number of bytes to lock or unlock */
40802 ){
40803 int rc = 0; /* Result code form Lock/UnlockFileEx() */
40804
@@ -40525,16 +40807,16 @@
40807
40808 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
40809 pFile->hFile.h, lockType, ofst, nByte));
40810
40811 /* Release/Acquire the system-level lock */
40812 if( lockType==WINSHM_UNLCK ){
40813 rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
40814 }else{
40815 /* Initialize the locking parameters */
40816 DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
40817 if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
40818 rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
40819 }
40820
40821 if( rc!= 0 ){
40822 rc = SQLITE_OK;
@@ -40542,11 +40824,11 @@
40824 pFile->lastErrno = osGetLastError();
40825 rc = SQLITE_BUSY;
40826 }
40827
40828 OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n",
40829 pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" :
40830 "winLockFile", pFile->lastErrno, sqlite3ErrName(rc)));
40831
40832 return rc;
40833 }
40834
@@ -40670,20 +40952,20 @@
40952 }
40953
40954 /* Check to see if another process is holding the dead-man switch.
40955 ** If not, truncate the file to zero length.
40956 */
40957 if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
40958 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
40959 if( rc!=SQLITE_OK ){
40960 rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
40961 "winOpenShm", pDbFd->zPath);
40962 }
40963 }
40964 if( rc==SQLITE_OK ){
40965 winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40966 rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);
40967 }
40968 if( rc ) goto shm_open_err;
40969 }
40970
40971 /* Make the new connection a child of the winShmNode */
@@ -40708,11 +40990,11 @@
40990 sqlite3_mutex_leave(pShmNode->mutex);
40991 return SQLITE_OK;
40992
40993 /* Jump here on any error */
40994 shm_open_err:
40995 winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);
40996 winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */
40997 sqlite3_free(p);
40998 sqlite3_free(pNew);
40999 winShmLeaveMutex();
41000 return rc;
@@ -40797,11 +41079,11 @@
41079 allMask |= pX->sharedMask;
41080 }
41081
41082 /* Unlock the system-level locks */
41083 if( (mask & allMask)==0 ){
41084 rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);
41085 }else{
41086 rc = SQLITE_OK;
41087 }
41088
41089 /* Undo the local locks */
@@ -40825,11 +41107,11 @@
41107 }
41108
41109 /* Get shared locks at the system level, if necessary */
41110 if( rc==SQLITE_OK ){
41111 if( (allShared & mask)==0 ){
41112 rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);
41113 }else{
41114 rc = SQLITE_OK;
41115 }
41116 }
41117
@@ -40850,11 +41132,11 @@
41132
41133 /* Get the exclusive locks at the system level. Then if successful
41134 ** also mark the local connection as being locked.
41135 */
41136 if( rc==SQLITE_OK ){
41137 rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);
41138 if( rc==SQLITE_OK ){
41139 assert( (p->sharedMask & mask)==0 );
41140 p->exclMask |= mask;
41141 }
41142 }
@@ -41292,10 +41574,48 @@
41574 winShmBarrier, /* xShmBarrier */
41575 winShmUnmap, /* xShmUnmap */
41576 winFetch, /* xFetch */
41577 winUnfetch /* xUnfetch */
41578 };
41579
41580 /*
41581 ** This vector defines all the methods that can operate on an
41582 ** sqlite3_file for win32 without performing any locking.
41583 */
41584 static const sqlite3_io_methods winIoNolockMethod = {
41585 3, /* iVersion */
41586 winClose, /* xClose */
41587 winRead, /* xRead */
41588 winWrite, /* xWrite */
41589 winTruncate, /* xTruncate */
41590 winSync, /* xSync */
41591 winFileSize, /* xFileSize */
41592 winNolockLock, /* xLock */
41593 winNolockUnlock, /* xUnlock */
41594 winNolockCheckReservedLock, /* xCheckReservedLock */
41595 winFileControl, /* xFileControl */
41596 winSectorSize, /* xSectorSize */
41597 winDeviceCharacteristics, /* xDeviceCharacteristics */
41598 winShmMap, /* xShmMap */
41599 winShmLock, /* xShmLock */
41600 winShmBarrier, /* xShmBarrier */
41601 winShmUnmap, /* xShmUnmap */
41602 winFetch, /* xFetch */
41603 winUnfetch /* xUnfetch */
41604 };
41605
41606 static winVfsAppData winAppData = {
41607 &winIoMethod, /* pMethod */
41608 0, /* pAppData */
41609 0 /* bNoLock */
41610 };
41611
41612 static winVfsAppData winNolockAppData = {
41613 &winIoNolockMethod, /* pMethod */
41614 0, /* pAppData */
41615 1 /* bNoLock */
41616 };
41617
41618 /****************************************************************************
41619 **************************** sqlite3_vfs methods ****************************
41620 **
41621 ** This division contains the implementation of methods on the
@@ -41625,11 +41945,11 @@
41945
41946 /*
41947 ** Open a file.
41948 */
41949 static int winOpen(
41950 sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */
41951 const char *zName, /* Name of the file (UTF-8) */
41952 sqlite3_file *id, /* Write the SQLite file handle here */
41953 int flags, /* Open mode flags */
41954 int *pOutFlags /* Status return flags */
41955 ){
@@ -41640,10 +41960,11 @@
41960 DWORD dwCreationDisposition;
41961 DWORD dwFlagsAndAttributes = 0;
41962 #if SQLITE_OS_WINCE
41963 int isTemp = 0;
41964 #endif
41965 winVfsAppData *pAppData;
41966 winFile *pFile = (winFile*)id;
41967 void *zConverted; /* Filename in OS encoding */
41968 const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
41969 int cnt = 0;
41970
@@ -41861,19 +42182,24 @@
42182
42183 OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, "
42184 "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?
42185 *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
42186
42187 pAppData = (winVfsAppData*)pVfs->pAppData;
42188
42189 #if SQLITE_OS_WINCE
42190 {
42191 if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
42192 && ((pAppData==NULL) || !pAppData->bNoLock)
42193 && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK
42194 ){
42195 osCloseHandle(h);
42196 sqlite3_free(zConverted);
42197 sqlite3_free(zTmpname);
42198 OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc)));
42199 return rc;
42200 }
42201 }
42202 if( isTemp ){
42203 pFile->zDeleteOnClose = zConverted;
42204 }else
42205 #endif
@@ -41880,11 +42206,11 @@
42206 {
42207 sqlite3_free(zConverted);
42208 }
42209
42210 sqlite3_free(zTmpname);
42211 pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;
42212 pFile->pVfs = pVfs;
42213 pFile->h = h;
42214 if( isReadonly ){
42215 pFile->ctrlFlags |= WINFILE_RDONLY;
42216 }
@@ -42155,10 +42481,22 @@
42481 sqlite3_vfs *pVfs, /* Pointer to vfs object */
42482 const char *zRelative, /* Possibly relative input path */
42483 int nFull, /* Size of output buffer in bytes */
42484 char *zFull /* Output buffer */
42485 ){
42486 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
42487 DWORD nByte;
42488 void *zConverted;
42489 char *zOut;
42490 #endif
42491
42492 /* If this path name begins with "/X:", where "X" is any alphabetic
42493 ** character, discard the initial "/" from the pathname.
42494 */
42495 if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
42496 zRelative++;
42497 }
42498
42499 #if defined(__CYGWIN__)
42500 SimulateIOError( return SQLITE_ERROR );
42501 UNUSED_PARAMETER(nFull);
42502 assert( nFull>=pVfs->mxPathname );
@@ -42233,21 +42571,10 @@
42571 }
42572 return SQLITE_OK;
42573 #endif
42574
42575 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
 
 
 
 
 
 
 
 
 
 
 
42576 /* It's odd to simulate an io-error here, but really this is just
42577 ** using the io-error infrastructure to test that SQLite handles this
42578 ** function failing. This function could fail if, for example, the
42579 ** current working directory has been unlinked.
42580 */
@@ -42602,57 +42929,107 @@
42929 /*
42930 ** Initialize and deinitialize the operating system interface.
42931 */
42932 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
42933 static sqlite3_vfs winVfs = {
42934 3, /* iVersion */
42935 sizeof(winFile), /* szOsFile */
42936 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42937 0, /* pNext */
42938 "win32", /* zName */
42939 &winAppData, /* pAppData */
42940 winOpen, /* xOpen */
42941 winDelete, /* xDelete */
42942 winAccess, /* xAccess */
42943 winFullPathname, /* xFullPathname */
42944 winDlOpen, /* xDlOpen */
42945 winDlError, /* xDlError */
42946 winDlSym, /* xDlSym */
42947 winDlClose, /* xDlClose */
42948 winRandomness, /* xRandomness */
42949 winSleep, /* xSleep */
42950 winCurrentTime, /* xCurrentTime */
42951 winGetLastError, /* xGetLastError */
42952 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42953 winSetSystemCall, /* xSetSystemCall */
42954 winGetSystemCall, /* xGetSystemCall */
42955 winNextSystemCall, /* xNextSystemCall */
42956 };
42957 #if defined(SQLITE_WIN32_HAS_WIDE)
42958 static sqlite3_vfs winLongPathVfs = {
42959 3, /* iVersion */
42960 sizeof(winFile), /* szOsFile */
42961 SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
42962 0, /* pNext */
42963 "win32-longpath", /* zName */
42964 &winAppData, /* pAppData */
42965 winOpen, /* xOpen */
42966 winDelete, /* xDelete */
42967 winAccess, /* xAccess */
42968 winFullPathname, /* xFullPathname */
42969 winDlOpen, /* xDlOpen */
42970 winDlError, /* xDlError */
42971 winDlSym, /* xDlSym */
42972 winDlClose, /* xDlClose */
42973 winRandomness, /* xRandomness */
42974 winSleep, /* xSleep */
42975 winCurrentTime, /* xCurrentTime */
42976 winGetLastError, /* xGetLastError */
42977 winCurrentTimeInt64, /* xCurrentTimeInt64 */
42978 winSetSystemCall, /* xSetSystemCall */
42979 winGetSystemCall, /* xGetSystemCall */
42980 winNextSystemCall, /* xNextSystemCall */
42981 };
42982 #endif
42983 static sqlite3_vfs winNolockVfs = {
42984 3, /* iVersion */
42985 sizeof(winFile), /* szOsFile */
42986 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
42987 0, /* pNext */
42988 "win32-none", /* zName */
42989 &winNolockAppData, /* pAppData */
42990 winOpen, /* xOpen */
42991 winDelete, /* xDelete */
42992 winAccess, /* xAccess */
42993 winFullPathname, /* xFullPathname */
42994 winDlOpen, /* xDlOpen */
42995 winDlError, /* xDlError */
42996 winDlSym, /* xDlSym */
42997 winDlClose, /* xDlClose */
42998 winRandomness, /* xRandomness */
42999 winSleep, /* xSleep */
43000 winCurrentTime, /* xCurrentTime */
43001 winGetLastError, /* xGetLastError */
43002 winCurrentTimeInt64, /* xCurrentTimeInt64 */
43003 winSetSystemCall, /* xSetSystemCall */
43004 winGetSystemCall, /* xGetSystemCall */
43005 winNextSystemCall, /* xNextSystemCall */
43006 };
43007 #if defined(SQLITE_WIN32_HAS_WIDE)
43008 static sqlite3_vfs winLongPathNolockVfs = {
43009 3, /* iVersion */
43010 sizeof(winFile), /* szOsFile */
43011 SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */
43012 0, /* pNext */
43013 "win32-longpath-none", /* zName */
43014 &winNolockAppData, /* pAppData */
43015 winOpen, /* xOpen */
43016 winDelete, /* xDelete */
43017 winAccess, /* xAccess */
43018 winFullPathname, /* xFullPathname */
43019 winDlOpen, /* xDlOpen */
43020 winDlError, /* xDlError */
43021 winDlSym, /* xDlSym */
43022 winDlClose, /* xDlClose */
43023 winRandomness, /* xRandomness */
43024 winSleep, /* xSleep */
43025 winCurrentTime, /* xCurrentTime */
43026 winGetLastError, /* xGetLastError */
43027 winCurrentTimeInt64, /* xCurrentTimeInt64 */
43028 winSetSystemCall, /* xSetSystemCall */
43029 winGetSystemCall, /* xGetSystemCall */
43030 winNextSystemCall, /* xNextSystemCall */
43031 };
43032 #endif
43033
43034 /* Double-check that the aSyscall[] array has been constructed
43035 ** correctly. See ticket [bb3a86e890c8e96ab] */
@@ -42671,10 +43048,16 @@
43048 sqlite3_vfs_register(&winVfs, 1);
43049
43050 #if defined(SQLITE_WIN32_HAS_WIDE)
43051 sqlite3_vfs_register(&winLongPathVfs, 0);
43052 #endif
43053
43054 sqlite3_vfs_register(&winNolockVfs, 0);
43055
43056 #if defined(SQLITE_WIN32_HAS_WIDE)
43057 sqlite3_vfs_register(&winLongPathNolockVfs, 0);
43058 #endif
43059
43060 return SQLITE_OK;
43061 }
43062
43063 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
@@ -43792,32 +44175,34 @@
44175 sqlite3PcacheTruncate(pCache, 0);
44176 }
44177
44178 /*
44179 ** Merge two lists of pages connected by pDirty and in pgno order.
44180 ** Do not bother fixing the pDirtyPrev pointers.
44181 */
44182 static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
44183 PgHdr result, *pTail;
44184 pTail = &result;
44185 assert( pA!=0 && pB!=0 );
44186 for(;;){
44187 if( pA->pgno<pB->pgno ){
44188 pTail->pDirty = pA;
44189 pTail = pA;
44190 pA = pA->pDirty;
44191 if( pA==0 ){
44192 pTail->pDirty = pB;
44193 break;
44194 }
44195 }else{
44196 pTail->pDirty = pB;
44197 pTail = pB;
44198 pB = pB->pDirty;
44199 if( pB==0 ){
44200 pTail->pDirty = pA;
44201 break;
44202 }
44203 }
 
 
 
44204 }
44205 return result.pDirty;
44206 }
44207
44208 /*
@@ -43855,11 +44240,12 @@
44240 a[i] = pcacheMergeDirtyList(a[i], p);
44241 }
44242 }
44243 p = a[0];
44244 for(i=1; i<N_SORT_BUCKET; i++){
44245 if( a[i]==0 ) continue;
44246 p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
44247 }
44248 return p;
44249 }
44250
44251 /*
@@ -44610,29 +44996,49 @@
44996 */
44997 static void pcache1TruncateUnsafe(
44998 PCache1 *pCache, /* The cache to truncate */
44999 unsigned int iLimit /* Drop pages with this pgno or larger */
45000 ){
45001 TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */
45002 unsigned int h, iStop;
45003 assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
45004 assert( pCache->iMaxKey >= iLimit );
45005 assert( pCache->nHash > 0 );
45006 if( pCache->iMaxKey - iLimit < pCache->nHash ){
45007 /* If we are just shaving the last few pages off the end of the
45008 ** cache, then there is no point in scanning the entire hash table.
45009 ** Only scan those hash slots that might contain pages that need to
45010 ** be removed. */
45011 h = iLimit % pCache->nHash;
45012 iStop = pCache->iMaxKey % pCache->nHash;
45013 TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */
45014 }else{
45015 /* This is the general case where many pages are being removed.
45016 ** It is necessary to scan the entire hash table */
45017 h = pCache->nHash/2;
45018 iStop = h - 1;
45019 }
45020 for(;;){
45021 PgHdr1 **pp;
45022 PgHdr1 *pPage;
45023 assert( h<pCache->nHash );
45024 pp = &pCache->apHash[h];
45025 while( (pPage = *pp)!=0 ){
45026 if( pPage->iKey>=iLimit ){
45027 pCache->nPage--;
45028 *pp = pPage->pNext;
45029 if( !pPage->isPinned ) pcache1PinPage(pPage);
45030 pcache1FreePage(pPage);
45031 }else{
45032 pp = &pPage->pNext;
45033 TESTONLY( if( nPage>=0 ) nPage++; )
45034 }
45035 }
45036 if( h==iStop ) break;
45037 h = (h+1) % pCache->nHash;
45038 }
45039 assert( nPage<0 || pCache->nPage==(unsigned)nPage );
45040 }
45041
45042 /******************************************************************************/
45043 /******** sqlite3_pcache Methods **********************************************/
45044
@@ -45105,11 +45511,11 @@
45511 static void pcache1Destroy(sqlite3_pcache *p){
45512 PCache1 *pCache = (PCache1 *)p;
45513 PGroup *pGroup = pCache->pGroup;
45514 assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
45515 pcache1EnterMutex(pGroup);
45516 if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
45517 assert( pGroup->nMaxPage >= pCache->nMax );
45518 pGroup->nMaxPage -= pCache->nMax;
45519 assert( pGroup->nMinPage >= pCache->nMin );
45520 pGroup->nMinPage -= pCache->nMin;
45521 pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
@@ -45460,31 +45866,29 @@
45866 ){
45867 struct RowSetEntry head;
45868 struct RowSetEntry *pTail;
45869
45870 pTail = &head;
45871 assert( pA!=0 && pB!=0 );
45872 for(;;){
45873 assert( pA->pRight==0 || pA->v<=pA->pRight->v );
45874 assert( pB->pRight==0 || pB->v<=pB->pRight->v );
45875 if( pA->v<=pB->v ){
45876 if( pA->v<pB->v ) pTail = pTail->pRight = pA;
45877 pA = pA->pRight;
45878 if( pA==0 ){
45879 pTail->pRight = pB;
45880 break;
45881 }
45882 }else{
45883 pTail = pTail->pRight = pB;
45884 pB = pB->pRight;
45885 if( pB==0 ){
45886 pTail->pRight = pA;
45887 break;
45888 }
45889 }
 
 
 
 
 
 
45890 }
45891 return head.pRight;
45892 }
45893
45894 /*
@@ -45504,13 +45908,14 @@
45908 aBucket[i] = 0;
45909 }
45910 aBucket[i] = pIn;
45911 pIn = pNext;
45912 }
45913 pIn = aBucket[0];
45914 for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){
45915 if( aBucket[i]==0 ) continue;
45916 pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];
45917 }
45918 return pIn;
45919 }
45920
45921
@@ -45758,12 +46163,12 @@
46163 ** This header file defines the interface to the write-ahead logging
46164 ** system. Refer to the comments below and the header comment attached to
46165 ** the implementation of each function in log.c for further details.
46166 */
46167
46168 #ifndef SQLITE_WAL_H
46169 #define SQLITE_WAL_H
46170
46171 /* #include "sqliteInt.h" */
46172
46173 /* Additional values that can be added to the sync_flags argument of
46174 ** sqlite3WalFrames():
@@ -45887,11 +46292,11 @@
46292
46293 /* Return the sqlite3_file object for the WAL file */
46294 SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);
46295
46296 #endif /* ifndef SQLITE_OMIT_WAL */
46297 #endif /* SQLITE_WAL_H */
46298
46299 /************** End of wal.h *************************************************/
46300 /************** Continuing where we left off in pager.c **********************/
46301
46302
@@ -53036,10 +53441,11 @@
53441 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
53442 assert( MEMDB==0 || pPager->tempFile );
53443 if( pPager->tempFile==0 ) pager_reset(pPager);
53444 }
53445 #endif
53446
53447
53448 #ifndef SQLITE_OMIT_WAL
53449 /*
53450 ** This function is called when the user invokes "PRAGMA wal_checkpoint",
53451 ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
@@ -53261,11 +53667,10 @@
53667 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
53668 assert( pPager->eState>=PAGER_READER );
53669 return sqlite3WalFramesize(pPager->pWal);
53670 }
53671 #endif
 
53672
53673 #endif /* SQLITE_OMIT_DISKIO */
53674
53675 /************** End of pager.c ***********************************************/
53676 /************** Begin file wal.c *********************************************/
@@ -56378,20 +56783,25 @@
56783 ** boundary is crossed. Only the part of the WAL prior to the last
56784 ** sector boundary is synced; the part of the last frame that extends
56785 ** past the sector boundary is written after the sync.
56786 */
56787 if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
56788 int bSync = 1;
56789 if( pWal->padToSectorBoundary ){
56790 int sectorSize = sqlite3SectorSize(pWal->pWalFd);
56791 w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
56792 bSync = (w.iSyncPoint==iOffset);
56793 testcase( bSync );
56794 while( iOffset<w.iSyncPoint ){
56795 rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);
56796 if( rc ) return rc;
56797 iOffset += szFrame;
56798 nExtra++;
56799 }
56800 }
56801 if( bSync ){
56802 assert( rc==SQLITE_OK );
56803 rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);
56804 }
56805 }
56806
56807 /* If this frame set completes the first transaction in the WAL and
@@ -58174,10 +58584,19 @@
58584 */
58585 #ifdef SQLITE_DEBUG
58586 static int cursorHoldsMutex(BtCursor *p){
58587 return sqlite3_mutex_held(p->pBt->mutex);
58588 }
58589
58590 /* Verify that the cursor and the BtShared agree about what is the current
58591 ** database connetion. This is important in shared-cache mode. If the database
58592 ** connection pointers get out-of-sync, it is possible for routines like
58593 ** btreeInitPage() to reference an stale connection pointer that references a
58594 ** a connection that has already closed. This routine is used inside assert()
58595 ** statements only and for the purpose of double-checking that the btree code
58596 ** does keep the database connection pointers up-to-date.
58597 */
58598 static int cursorOwnsBtShared(BtCursor *p){
58599 assert( cursorHoldsMutex(p) );
58600 return (p->pBtree->db==p->pBt->db);
58601 }
58602 #endif
@@ -58333,25 +58752,23 @@
58752 ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is
58753 ** set to point to a malloced buffer pCur->nKey bytes in size containing
58754 ** the key.
58755 */
58756 static int saveCursorKey(BtCursor *pCur){
58757 int rc = SQLITE_OK;
58758 assert( CURSOR_VALID==pCur->eState );
58759 assert( 0==pCur->pKey );
58760 assert( cursorHoldsMutex(pCur) );
58761
58762 if( pCur->curIntKey ){
58763 /* Only the rowid is required for a table btree */
58764 pCur->nKey = sqlite3BtreeIntegerKey(pCur);
58765 }else{
58766 /* For an index btree, save the complete key content */
58767 void *pKey;
58768 pCur->nKey = sqlite3BtreePayloadSize(pCur);
58769 pKey = sqlite3Malloc( pCur->nKey );
 
 
58770 if( pKey ){
58771 rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
58772 if( rc==SQLITE_OK ){
58773 pCur->pKey = pKey;
58774 }else{
@@ -60054,13 +60471,13 @@
60471 assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */
60472
60473 #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
60474 /* Add the new BtShared object to the linked list sharable BtShareds.
60475 */
60476 pBt->nRef = 1;
60477 if( p->sharable ){
60478 MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
 
60479 MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
60480 if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
60481 pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
60482 if( pBt->mutex==0 ){
60483 rc = SQLITE_NOMEM_BKPT;
@@ -60127,10 +60544,11 @@
60544 }
60545 if( mutexOpen ){
60546 assert( sqlite3_mutex_held(mutexOpen) );
60547 sqlite3_mutex_leave(mutexOpen);
60548 }
60549 assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );
60550 return rc;
60551 }
60552
60553 /*
60554 ** Decrement the BtShared.nRef counter. When it reaches zero,
@@ -61986,50 +62404,37 @@
62404 return pCur && pCur->eState==CURSOR_VALID;
62405 }
62406 #endif /* NDEBUG */
62407
62408 /*
62409 ** Return the value of the integer key or "rowid" for a table btree.
62410 ** This routine is only valid for a cursor that is pointing into a
62411 ** ordinary table btree. If the cursor points to an index btree or
62412 ** is invalid, the result of this routine is undefined.
 
 
 
 
 
 
62413 */
62414 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
62415 assert( cursorHoldsMutex(pCur) );
62416 assert( pCur->eState==CURSOR_VALID );
62417 assert( pCur->curIntKey );
62418 getCellInfo(pCur);
62419 return pCur->info.nKey;
 
62420 }
62421
62422 /*
62423 ** Return the number of bytes of payload for the entry that pCur is
62424 ** currently pointing to. For table btrees, this will be the amount
62425 ** of data. For index btrees, this will be the size of the key.
62426 **
62427 ** The caller must guarantee that the cursor is pointing to a non-NULL
62428 ** valid entry. In other words, the calling procedure must guarantee
62429 ** that the cursor has Cursor.eState==CURSOR_VALID.
 
 
 
 
62430 */
62431 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){
62432 assert( cursorHoldsMutex(pCur) );
62433 assert( pCur->eState==CURSOR_VALID );
 
 
 
62434 getCellInfo(pCur);
62435 return pCur->info.nPayload;
 
62436 }
62437
62438 /*
62439 ** Given the page number of an overflow page in the database (parameter
62440 ** ovfl), this function finds the page number of the next page in the
@@ -62467,14 +62872,11 @@
62872 ** this routine.
62873 **
62874 ** These routines is used to get quick access to key and data
62875 ** in the common case where no overflow pages are used.
62876 */
62877 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){
 
 
 
62878 return fetchPayload(pCur, pAmt);
62879 }
62880
62881
62882 /*
@@ -62803,15 +63205,16 @@
63205
63206 assert( cursorOwnsBtShared(pCur) );
63207 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
63208 assert( pRes );
63209 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
63210 assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
63211
63212 /* If the cursor is already positioned at the point we are trying
63213 ** to move to, then just return without doing any work */
63214 if( pIdxKey==0
63215 && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
63216 ){
63217 if( pCur->info.nKey==intKey ){
63218 *pRes = 0;
63219 return SQLITE_OK;
63220 }
@@ -63796,13 +64199,11 @@
64199 ** later.
64200 */
64201 static int fillInCell(
64202 MemPage *pPage, /* The page that contains the cell */
64203 unsigned char *pCell, /* Complete text of the cell */
64204 const BtreePayload *pX, /* Payload with which to construct the cell */
 
 
64205 int *pnSize /* Write cell size here */
64206 ){
64207 int nPayload;
64208 const u8 *pSrc;
64209 int nSrc, n, rc;
@@ -63822,30 +64223,27 @@
64223 assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]
64224 || sqlite3PagerIswriteable(pPage->pDbPage) );
64225
64226 /* Fill in the header. */
64227 nHeader = pPage->childPtrSize;
 
 
 
 
 
 
 
 
 
 
64228 if( pPage->intKey ){
64229 nPayload = pX->nData + pX->nZero;
64230 pSrc = pX->pData;
64231 nSrc = pX->nData;
64232 assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */
64233 nHeader += putVarint32(&pCell[nHeader], nPayload);
64234 nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);
64235 }else{
64236 assert( pX->nData==0 );
64237 assert( pX->nZero==0 );
64238 assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );
64239 nSrc = nPayload = (int)pX->nKey;
64240 pSrc = pX->pKey;
64241 nHeader += putVarint32(&pCell[nHeader], nPayload);
64242 }
64243
64244 /* Fill in the payload */
64245 if( nPayload<=pPage->maxLocal ){
64246 n = nHeader + nPayload;
64247 testcase( n==3 );
64248 testcase( n==4 );
64249 if( n<4 ) n = 4;
@@ -63879,11 +64277,11 @@
64277 #if SQLITE_DEBUG
64278 {
64279 CellInfo info;
64280 pPage->xParseCell(pPage, pCell, &info);
64281 assert( nHeader==(int)(info.pPayload - pCell) );
64282 assert( info.nKey==pX->nKey );
64283 assert( *pnSize == info.nSize );
64284 assert( spaceLeft == info.nLocal );
64285 }
64286 #endif
64287
@@ -63964,14 +64362,10 @@
64362 nPayload -= n;
64363 pPayload += n;
64364 pSrc += n;
64365 nSrc -= n;
64366 spaceLeft -= n;
 
 
 
 
64367 }
64368 releasePage(pToRelease);
64369 return SQLITE_OK;
64370 }
64371
@@ -64034,10 +64428,12 @@
64428 ** pTemp is not null. Regardless of pTemp, allocate a new entry
64429 ** in pPage->apOvfl[] and make it point to the cell content (either
64430 ** in pTemp or the original pCell) and also record its index.
64431 ** Allocating a new entry in pPage->aCell[] implies that
64432 ** pPage->nOverflow is incremented.
64433 **
64434 ** *pRC must be SQLITE_OK when this routine is called.
64435 */
64436 static void insertCell(
64437 MemPage *pPage, /* Page into which we are copying */
64438 int i, /* New cell becomes the i-th cell of the page */
64439 u8 *pCell, /* Content of the new cell */
@@ -64049,12 +64445,11 @@
64445 int idx = 0; /* Where to write new cell content in data[] */
64446 int j; /* Loop counter */
64447 u8 *data; /* The content of the whole page */
64448 u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
64449
64450 assert( *pRC==SQLITE_OK );
 
64451 assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
64452 assert( MX_CELL(pPage->pBt)<=10921 );
64453 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
64454 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
64455 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
@@ -64124,11 +64519,11 @@
64519 }
64520 }
64521
64522 /*
64523 ** A CellArray object contains a cache of pointers and sizes for a
64524 ** consecutive sequence of cells that might be held on multiple pages.
64525 */
64526 typedef struct CellArray CellArray;
64527 struct CellArray {
64528 int nCell; /* Number of cells in apCell[] */
64529 MemPage *pRef; /* Reference page */
@@ -64556,12 +64951,14 @@
64951 while( (*(pCell++)&0x80) && pCell<pStop );
64952 pStop = &pCell[9];
64953 while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );
64954
64955 /* Insert the new divider cell into pParent. */
64956 if( rc==SQLITE_OK ){
64957 insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),
64958 0, pPage->pgno, &rc);
64959 }
64960
64961 /* Set the right-child pointer of pParent to point to the new page. */
64962 put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
64963
64964 /* Release the reference to the new page. */
@@ -65077,11 +65474,11 @@
65474 do{
65475 assert( d<nMaxCells );
65476 assert( r<nMaxCells );
65477 (void)cachedCellSize(&b, r);
65478 if( szRight!=0
65479 && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){
65480 break;
65481 }
65482 szRight += b.szCell[d] + 2;
65483 szLeft -= b.szCell[r] + 2;
65484 cntNew[i-1] = r;
@@ -65649,17 +66046,23 @@
66046 return rc;
66047 }
66048
66049
66050 /*
66051 ** Insert a new record into the BTree. The content of the new record
66052 ** is described by the pX object. The pCur cursor is used only to
66053 ** define what table the record should be inserted into, and is left
66054 ** pointing at a random location.
66055 **
66056 ** For a table btree (used for rowid tables), only the pX.nKey value of
66057 ** the key is used. The pX.pKey value must be NULL. The pX.nKey is the
66058 ** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields
66059 ** hold the content of the row.
66060 **
66061 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
66062 ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
66063 ** pX.pData,nData,nZero fields must be zero.
66064 **
66065 ** If the seekResult parameter is non-zero, then a successful call to
66066 ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
66067 ** been performed. seekResult is the search result returned (a negative
66068 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
@@ -65672,13 +66075,11 @@
66075 ** point to any entry or to no entry at all and so this function has to seek
66076 ** the cursor before the new key can be inserted.
66077 */
66078 SQLITE_PRIVATE int sqlite3BtreeInsert(
66079 BtCursor *pCur, /* Insert data into the table of this cursor */
66080 const BtreePayload *pX, /* Content of the row to be inserted */
 
 
66081 int appendBias, /* True if this is likely an append */
66082 int seekResult /* Result of prior MovetoUnpacked() call */
66083 ){
66084 int rc;
66085 int loc = seekResult; /* -1: before desired location +1: after */
@@ -65704,11 +66105,11 @@
66105 /* Assert that the caller has been consistent. If this cursor was opened
66106 ** expecting an index b-tree, then the caller should be inserting blob
66107 ** keys with no associated data. If the cursor was opened expecting an
66108 ** intkey table, the caller should be inserting integer keys with a
66109 ** blob of associated data. */
66110 assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );
66111
66112 /* Save the positions of any other cursors open on this table.
66113 **
66114 ** In some cases, the call to btreeMoveto() below is a no-op. For
66115 ** example, when inserting data into a table with auto-generated integer
@@ -65723,42 +66124,42 @@
66124 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
66125 if( rc ) return rc;
66126 }
66127
66128 if( pCur->pKeyInfo==0 ){
66129 assert( pX->pKey==0 );
66130 /* If this is an insert into a table b-tree, invalidate any incrblob
66131 ** cursors open on the row being replaced */
66132 invalidateIncrblobCursors(p, pX->nKey, 0);
66133
66134 /* If the cursor is currently on the last row and we are appending a
66135 ** new row onto the end, set the "loc" to avoid an unnecessary
66136 ** btreeMoveto() call */
66137 if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0
66138 && pCur->info.nKey==pX->nKey-1 ){
66139 loc = -1;
66140 }else if( loc==0 ){
66141 rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc);
66142 if( rc ) return rc;
66143 }
66144 }else if( loc==0 ){
66145 rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc);
66146 if( rc ) return rc;
66147 }
66148 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
66149
66150 pPage = pCur->apPage[pCur->iPage];
66151 assert( pPage->intKey || pX->nKey>=0 );
66152 assert( pPage->leaf || !pPage->intKey );
66153
66154 TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n",
66155 pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,
66156 loc==0 ? "overwrite" : "new entry"));
66157 assert( pPage->isInit );
66158 newCell = pBt->pTmpSpace;
66159 assert( newCell!=0 );
66160 rc = fillInCell(pPage, newCell, pX, &szNew);
66161 if( rc ) goto end_insert;
66162 assert( szNew==pPage->xCellSize(pPage, newCell) );
66163 assert( szNew <= MX_CELL_SIZE(pBt) );
66164 idx = pCur->aiIdx[pCur->iPage];
66165 if( loc==0 ){
@@ -65780,10 +66181,11 @@
66181 idx = ++pCur->aiIdx[pCur->iPage];
66182 }else{
66183 assert( pPage->leaf );
66184 }
66185 insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
66186 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
66187 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
66188
66189 /* If no error has occurred and pPage has an overflow cell, call balance()
66190 ** to redistribute the cells within the tree. Since balance() may move
66191 ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey
@@ -65803,11 +66205,12 @@
66205 ** entry in the table, and the next row inserted has an integer key
66206 ** larger than the largest existing key, it is possible to insert the
66207 ** row without seeking the cursor. This can be a big performance boost.
66208 */
66209 pCur->info.nSize = 0;
66210 if( pPage->nOverflow ){
66211 assert( rc==SQLITE_OK );
66212 pCur->curFlags &= ~(BTCF_ValidNKey);
66213 rc = balance(pCur);
66214
66215 /* Must make sure nOverflow is reset to zero even if the balance()
66216 ** fails. Internal data structure corruption will result otherwise.
@@ -65939,11 +66342,13 @@
66342 nCell = pLeaf->xCellSize(pLeaf, pCell);
66343 assert( MX_CELL_SIZE(pBt) >= nCell );
66344 pTmp = pBt->pTmpSpace;
66345 assert( pTmp!=0 );
66346 rc = sqlite3PagerWrite(pLeaf->pDbPage);
66347 if( rc==SQLITE_OK ){
66348 insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);
66349 }
66350 dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);
66351 if( rc ) return rc;
66352 }
66353
66354 /* Balance the tree. If the entry deleted was located on a leaf page,
@@ -67428,10 +67833,20 @@
67833 ** Return true if the Btree passed as the only argument is sharable.
67834 */
67835 SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
67836 return p->sharable;
67837 }
67838
67839 /*
67840 ** Return the number of connections to the BtShared object accessed by
67841 ** the Btree handle passed as the only argument. For private caches
67842 ** this is always 1. For shared caches it may be 1 or greater.
67843 */
67844 SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){
67845 testcase( p->sharable );
67846 return p->pBt->nRef;
67847 }
67848 #endif
67849
67850 /************** End of btree.c ***********************************************/
67851 /************** Begin file backup.c ******************************************/
67852 /*
@@ -68211,14 +68626,14 @@
68626 /* 0x7FFFFFFF is the hard limit for the number of pages in a database
68627 ** file. By passing this as the number of pages to copy to
68628 ** sqlite3_backup_step(), we can guarantee that the copy finishes
68629 ** within a single call (unless an error occurs). The assert() statement
68630 ** checks this assumption - (p->rc) should be set to either SQLITE_DONE
68631 ** or an error code. */
 
68632 sqlite3_backup_step(&b, 0x7FFFFFFF);
68633 assert( b.rc!=SQLITE_OK );
68634
68635 rc = sqlite3_backup_finish(&b);
68636 if( rc==SQLITE_OK ){
68637 pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;
68638 }else{
68639 sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));
@@ -69225,15 +69640,11 @@
69640 assert( !VdbeMemDynamic(pMem) );
69641
69642 /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert()
69643 ** that both the BtShared and database handle mutexes are held. */
69644 assert( (pMem->flags & MEM_RowSet)==0 );
69645 zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);
 
 
 
 
69646 assert( zData!=0 );
69647
69648 if( offset+amt<=available ){
69649 pMem->z = &zData[offset];
69650 pMem->flags = MEM_Blob|MEM_Ephem;
@@ -70009,18 +70420,10 @@
70420 assert( p->zSql==0 );
70421 p->zSql = sqlite3DbStrNDup(p->db, z, n);
70422 p->isPrepareV2 = (u8)isPrepareV2;
70423 }
70424
 
 
 
 
 
 
 
 
70425 /*
70426 ** Swap all content between two VDBE structures.
70427 */
70428 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
70429 Vdbe tmp, *pTmp;
@@ -70736,26 +71139,34 @@
71139 /*
71140 ** If the input FuncDef structure is ephemeral, then free it. If
71141 ** the FuncDef is not ephermal, then do nothing.
71142 */
71143 static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
71144 if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){
71145 sqlite3DbFree(db, pDef);
71146 }
71147 }
71148
71149 static void vdbeFreeOpArray(sqlite3 *, Op *, int);
71150
71151 /*
71152 ** Delete a P4 value if necessary.
71153 */
71154 static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){
71155 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
71156 sqlite3DbFree(db, p);
71157 }
71158 static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){
71159 freeEphemeralFunction(db, p->pFunc);
71160 sqlite3DbFree(db, p);
71161 }
71162 static void freeP4(sqlite3 *db, int p4type, void *p4){
71163 assert( db );
71164 switch( p4type ){
71165 case P4_FUNCCTX: {
71166 freeP4FuncCtx(db, (sqlite3_context*)p4);
71167 break;
71168 }
71169 case P4_REAL:
71170 case P4_INT64:
71171 case P4_DYNAMIC:
71172 case P4_INTARRAY: {
@@ -70782,13 +71193,11 @@
71193 }
71194 case P4_MEM: {
71195 if( db->pnBytesFreed==0 ){
71196 sqlite3ValueFree((sqlite3_value*)p4);
71197 }else{
71198 freeP4Mem(db, (Mem*)p4);
 
 
71199 }
71200 break;
71201 }
71202 case P4_VTAB : {
71203 if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
@@ -74254,12 +74663,11 @@
74663 ** than 2GiB are support - anything large must be database corruption.
74664 ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so
74665 ** this code can safely assume that nCellKey is 32-bits
74666 */
74667 assert( sqlite3BtreeCursorIsValid(pCur) );
74668 nCellKey = sqlite3BtreePayloadSize(pCur);
 
74669 assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );
74670
74671 /* Read in the complete content of the index entry */
74672 sqlite3VdbeMemInit(&m, db, 0);
74673 rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m);
@@ -74332,12 +74740,11 @@
74740 Mem m;
74741
74742 assert( pC->eCurType==CURTYPE_BTREE );
74743 pCur = pC->uc.pCursor;
74744 assert( sqlite3BtreeCursorIsValid(pCur) );
74745 nCellKey = sqlite3BtreePayloadSize(pCur);
 
74746 /* nCellKey will always be between 0 and 0xffffffff because of the way
74747 ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
74748 if( nCellKey<=0 || nCellKey>0x7fffffff ){
74749 *res = 0;
74750 return SQLITE_CORRUPT_BKPT;
@@ -74595,16 +75002,23 @@
75002 ** Invoke the profile callback. This routine is only called if we already
75003 ** know that the profile callback is defined and needs to be invoked.
75004 */
75005 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
75006 sqlite3_int64 iNow;
75007 sqlite3_int64 iElapse;
75008 assert( p->startTime>0 );
75009 assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
75010 assert( db->init.busy==0 );
75011 assert( p->zSql!=0 );
75012 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
75013 iElapse = (iNow - p->startTime)*1000000;
75014 if( db->xProfile ){
75015 db->xProfile(db->pProfileArg, p->zSql, iElapse);
75016 }
75017 if( db->mTrace & SQLITE_TRACE_PROFILE ){
75018 db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
75019 }
75020 p->startTime = 0;
75021 }
75022 /*
75023 ** The checkProfileCallback(DB,P) macro checks to see if a profile callback
75024 ** is needed, and it invokes the callback if it is needed.
@@ -75104,11 +75518,12 @@
75518 assert( db->nVdbeWrite>0 || db->autoCommit==0
75519 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
75520 );
75521
75522 #ifndef SQLITE_OMIT_TRACE
75523 if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
75524 && !db->init.busy && p->zSql ){
75525 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
75526 }else{
75527 assert( p->startTime==0 );
75528 }
75529 #endif
@@ -76138,10 +76553,43 @@
76553 #endif
76554 v = pVdbe->aCounter[op];
76555 if( resetFlag ) pVdbe->aCounter[op] = 0;
76556 return (int)v;
76557 }
76558
76559 /*
76560 ** Return the SQL associated with a prepared statement
76561 */
76562 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
76563 Vdbe *p = (Vdbe *)pStmt;
76564 return p ? p->zSql : 0;
76565 }
76566
76567 /*
76568 ** Return the SQL associated with a prepared statement with
76569 ** bound parameters expanded. Space to hold the returned string is
76570 ** obtained from sqlite3_malloc(). The caller is responsible for
76571 ** freeing the returned string by passing it to sqlite3_free().
76572 **
76573 ** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
76574 ** expanded bound parameters.
76575 */
76576 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt){
76577 #ifdef SQLITE_OMIT_TRACE
76578 return 0;
76579 #else
76580 char *z = 0;
76581 const char *zSql = sqlite3_sql(pStmt);
76582 if( zSql ){
76583 Vdbe *p = (Vdbe *)pStmt;
76584 sqlite3_mutex_enter(p->db->mutex);
76585 z = sqlite3VdbeExpandSql(p, zSql);
76586 sqlite3_mutex_leave(p->db->mutex);
76587 }
76588 return z;
76589 #endif
76590 }
76591
76592 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
76593 /*
76594 ** Allocate and populate an UnpackedRecord structure based on the serialized
76595 ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
@@ -76185,12 +76633,11 @@
76633 /* If the old.* record has not yet been loaded into memory, do so now. */
76634 if( p->pUnpacked==0 ){
76635 u32 nRec;
76636 u8 *aRec;
76637
76638 nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
 
76639 aRec = sqlite3DbMallocRaw(db, nRec);
76640 if( !aRec ) goto preupdate_old_out;
76641 rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec);
76642 if( rc==SQLITE_OK ){
76643 p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
@@ -76474,14 +76921,17 @@
76921 int n; /* Length of a token prefix */
76922 int nToken; /* Length of the parameter token */
76923 int i; /* Loop counter */
76924 Mem *pVar; /* Value of a host parameter */
76925 StrAccum out; /* Accumulate the output here */
76926 #ifndef SQLITE_OMIT_UTF16
76927 Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */
76928 #endif
76929 char zBase[100]; /* Initial working space */
76930
76931 db = p->db;
76932 sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase),
76933 db->aLimit[SQLITE_LIMIT_LENGTH]);
76934 if( db->nVdbeExec>1 ){
76935 while( *zRawSql ){
76936 const char *zStart = zRawSql;
76937 while( *(zRawSql++)!='\n' && *zRawSql );
@@ -76528,16 +76978,18 @@
76978 sqlite3XPrintf(&out, "%!.15g", pVar->u.r);
76979 }else if( pVar->flags & MEM_Str ){
76980 int nOut; /* Number of bytes of the string text to include in output */
76981 #ifndef SQLITE_OMIT_UTF16
76982 u8 enc = ENC(db);
 
76983 if( enc!=SQLITE_UTF8 ){
76984 memset(&utf8, 0, sizeof(utf8));
76985 utf8.db = db;
76986 sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
76987 if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
76988 out.accError = STRACCUM_NOMEM;
76989 out.nAlloc = 0;
76990 }
76991 pVar = &utf8;
76992 }
76993 #endif
76994 nOut = pVar->n;
76995 #ifdef SQLITE_TRACE_SIZE_LIMIT
@@ -76575,10 +77027,11 @@
77027 }
77028 #endif
77029 }
77030 }
77031 }
77032 if( out.accError ) sqlite3StrAccumReset(&out);
77033 return sqlite3StrAccumFinish(&out);
77034 }
77035
77036 #endif /* #ifndef SQLITE_OMIT_TRACE */
77037
@@ -77107,12 +77560,12 @@
77560 ******************************************************************************
77561 **
77562 ** This file contains inline asm code for retrieving "high-performance"
77563 ** counters for x86 class CPUs.
77564 */
77565 #ifndef SQLITE_HWTIME_H
77566 #define SQLITE_HWTIME_H
77567
77568 /*
77569 ** The following routine only works on pentium-class (or newer) processors.
77570 ** It uses the RDTSC opcode to read the cycle count value out of the
77571 ** processor and returns that value. This can be used for high-res
@@ -77176,11 +77629,11 @@
77629 */
77630 SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
77631
77632 #endif
77633
77634 #endif /* !defined(SQLITE_HWTIME_H) */
77635
77636 /************** End of hwtime.h **********************************************/
77637 /************** Continuing where we left off in vdbe.c ***********************/
77638
77639 #endif
@@ -78055,10 +78508,14 @@
78508 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
78509 sqlite3VdbeMemNulTerminate(&pMem[i]);
78510 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
78511 }
78512 if( db->mallocFailed ) goto no_mem;
78513
78514 if( db->mTrace & SQLITE_TRACE_ROW ){
78515 db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);
78516 }
78517
78518 /* Return SQLITE_ROW
78519 */
78520 p->pc = (int)(pOp - aOp) + 1;
78521 rc = SQLITE_ROW;
@@ -78689,10 +79146,11 @@
79146 affinity = pOp->p5 & SQLITE_AFF_MASK;
79147 if( affinity>=SQLITE_AFF_NUMERIC ){
79148 if( (flags1 | flags3)&MEM_Str ){
79149 if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
79150 applyNumericAffinity(pIn1,0);
79151 flags3 = pIn3->flags;
79152 }
79153 if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
79154 applyNumericAffinity(pIn3,0);
79155 }
79156 }
@@ -78701,10 +79159,11 @@
79159 testcase( pIn1->flags & MEM_Int );
79160 testcase( pIn1->flags & MEM_Real );
79161 sqlite3VdbeMemStringify(pIn1, encoding, 1);
79162 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
79163 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
79164 flags3 = pIn3->flags;
79165 }
79166 if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
79167 testcase( pIn3->flags & MEM_Int );
79168 testcase( pIn3->flags & MEM_Real );
79169 sqlite3VdbeMemStringify(pIn3, encoding, 1);
@@ -79053,11 +79512,10 @@
79512 ** the result is guaranteed to only be used as the argument of a length()
79513 ** or typeof() function, respectively. The loading of large blobs can be
79514 ** skipped for length() and all content loading can be skipped for typeof().
79515 */
79516 case OP_Column: {
 
79517 int p2; /* column number to retrieve */
79518 VdbeCursor *pC; /* The VDBE cursor */
79519 BtCursor *pCrsr; /* The BTree cursor */
79520 u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
79521 int len; /* The length of the serialized data for the column */
@@ -79076,10 +79534,11 @@
79534 pC = p->apCsr[pOp->p1];
79535 p2 = pOp->p2;
79536
79537 /* If the cursor cache is stale, bring it up-to-date */
79538 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
79539 if( rc ) goto abort_due_to_error;
79540
79541 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
79542 pDest = &aMem[pOp->p3];
79543 memAboutToChange(p, pDest);
79544 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -79089,12 +79548,11 @@
79548 assert( pC->eCurType!=CURTYPE_VTAB );
79549 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
79550 assert( pC->eCurType!=CURTYPE_SORTER );
79551 pCrsr = pC->uc.pCursor;
79552
79553 if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/
 
79554 if( pC->nullRow ){
79555 if( pC->eCurType==CURTYPE_PSEUDO ){
79556 assert( pC->uc.pseudoTableReg>0 );
79557 pReg = &aMem[pC->uc.pseudoTableReg];
79558 assert( pReg->flags & MEM_Blob );
@@ -79106,26 +79564,13 @@
79564 goto op_column_out;
79565 }
79566 }else{
79567 assert( pC->eCurType==CURTYPE_BTREE );
79568 assert( pCrsr );
79569 assert( sqlite3BtreeCursorIsValid(pCrsr) );
79570 pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
79571 pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
 
 
 
 
 
 
 
 
 
 
 
 
 
79572 assert( avail<=65536 ); /* Maximum page size is 64KiB */
79573 if( pC->payloadSize <= (u32)avail ){
79574 pC->szRow = pC->payloadSize;
79575 }else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
79576 goto too_big;
@@ -79137,11 +79582,11 @@
79582 pC->iHdrOffset = getVarint32(pC->aRow, offset);
79583 pC->nHdrParsed = 0;
79584 aOffset[0] = offset;
79585
79586
79587 if( avail<offset ){ /*OPTIMIZATION-IF-FALSE*/
79588 /* pC->aRow does not have to hold the entire row, but it does at least
79589 ** need to cover the header of the record. If pC->aRow does not contain
79590 ** the complete header, then set it to zero, forcing the header to be
79591 ** dynamically allocated. */
79592 pC->aRow = 0;
@@ -79158,28 +79603,28 @@
79603 */
79604 if( offset > 98307 || offset > pC->payloadSize ){
79605 rc = SQLITE_CORRUPT_BKPT;
79606 goto abort_due_to_error;
79607 }
79608 }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/
79609 /* The following goto is an optimization. It can be omitted and
79610 ** everything will still work. But OP_Column is measurably faster
79611 ** by skipping the subsequent conditional, which is always true.
79612 */
79613 zData = pC->aRow;
79614 assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
79615 goto op_column_read_header;
79616 }
79617 }
79618
79619 /* Make sure at least the first p2+1 entries of the header have been
79620 ** parsed and valid information is in aOffset[] and pC->aType[].
79621 */
79622 if( pC->nHdrParsed<=p2 ){
79623 /* If there is more header available for parsing in the record, try
79624 ** to extract additional fields up through the p2+1-th field
79625 */
 
79626 if( pC->iHdrOffset<aOffset[0] ){
79627 /* Make sure zData points to enough of the record to cover the header. */
79628 if( pC->aRow==0 ){
79629 memset(&sMem, 0, sizeof(sMem));
79630 rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
@@ -79188,15 +79633,15 @@
79633 }else{
79634 zData = pC->aRow;
79635 }
79636
79637 /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
79638 op_column_read_header:
79639 i = pC->nHdrParsed;
79640 offset64 = aOffset[i];
79641 zHdr = zData + pC->iHdrOffset;
79642 zEndHdr = zData + aOffset[0];
 
79643 do{
79644 if( (t = zHdr[0])<0x80 ){
79645 zHdr++;
79646 offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
79647 }else{
@@ -79204,13 +79649,11 @@
79649 offset64 += sqlite3VdbeSerialTypeLen(t);
79650 }
79651 pC->aType[i++] = t;
79652 aOffset[i] = (u32)(offset64 & 0xffffffff);
79653 }while( i<=p2 && zHdr<zEndHdr );
79654
 
 
79655 /* The record is corrupt if any of the following are true:
79656 ** (1) the bytes of the header extend past the declared header size
79657 ** (2) the entire header was used but not all data was used
79658 ** (3) the end of the data extends beyond the end of the record.
79659 */
@@ -79219,12 +79662,14 @@
79662 ){
79663 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
79664 rc = SQLITE_CORRUPT_BKPT;
79665 goto abort_due_to_error;
79666 }
79667
79668 pC->nHdrParsed = i;
79669 pC->iHdrOffset = (u32)(zHdr - zData);
79670 if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);
 
79671 }else{
79672 t = 0;
79673 }
79674
79675 /* If after trying to extract new entries from the header, nHdrParsed is
@@ -79248,13 +79693,14 @@
79693 ** all valid.
79694 */
79695 assert( p2<pC->nHdrParsed );
79696 assert( rc==SQLITE_OK );
79697 assert( sqlite3VdbeCheckMemInvariants(pDest) );
79698 if( VdbeMemDynamic(pDest) ){
79699 sqlite3VdbeMemSetNull(pDest);
79700 }
79701 assert( t==pC->aType[p2] );
 
79702 if( pC->szRow>=aOffset[p2+1] ){
79703 /* This is the common case where the desired content fits on the original
79704 ** page - where the content is not on an overflow page */
79705 zData = pC->aRow + aOffset[p2];
79706 if( t<12 ){
@@ -79264,10 +79710,11 @@
79710 ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent
79711 ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().
79712 */
79713 static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
79714 pDest->n = len = (t-12)/2;
79715 pDest->enc = encoding;
79716 if( pDest->szMalloc < len+2 ){
79717 pDest->flags = MEM_Null;
79718 if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
79719 }else{
79720 pDest->z = pDest->zMalloc;
@@ -79276,10 +79723,11 @@
79723 pDest->z[len] = 0;
79724 pDest->z[len+1] = 0;
79725 pDest->flags = aFlag[t&1];
79726 }
79727 }else{
79728 pDest->enc = encoding;
79729 /* This branch happens only when content is on overflow pages */
79730 if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
79731 && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))
79732 || (len = sqlite3VdbeSerialTypeLen(t))==0
79733 ){
@@ -80693,10 +81141,34 @@
81141 if( takeJump || !alreadyExists ) goto jump_to_p2;
81142 }
81143 break;
81144 }
81145
81146 /* Opcode: SeekRowid P1 P2 P3 * *
81147 ** Synopsis: intkey=r[P3]
81148 **
81149 ** P1 is the index of a cursor open on an SQL table btree (with integer
81150 ** keys). If register P3 does not contain an integer or if P1 does not
81151 ** contain a record with rowid P3 then jump immediately to P2.
81152 ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain
81153 ** a record with rowid P3 then
81154 ** leave the cursor pointing at that record and fall through to the next
81155 ** instruction.
81156 **
81157 ** The OP_NotExists opcode performs the same operation, but with OP_NotExists
81158 ** the P3 register must be guaranteed to contain an integer value. With this
81159 ** opcode, register P3 might not contain an integer.
81160 **
81161 ** The OP_NotFound opcode performs the same operation on index btrees
81162 ** (with arbitrary multi-value keys).
81163 **
81164 ** This opcode leaves the cursor in a state where it cannot be advanced
81165 ** in either direction. In other words, the Next and Prev opcodes will
81166 ** not work following this opcode.
81167 **
81168 ** See also: Found, NotFound, NoConflict, SeekRowid
81169 */
81170 /* Opcode: NotExists P1 P2 P3 * *
81171 ** Synopsis: intkey=r[P3]
81172 **
81173 ** P1 is the index of a cursor open on an SQL table btree (with integer
81174 ** keys). P3 is an integer rowid. If P1 does not contain a record with
@@ -80703,26 +81175,37 @@
81175 ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an
81176 ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then
81177 ** leave the cursor pointing at that record and fall through to the next
81178 ** instruction.
81179 **
81180 ** The OP_SeekRowid opcode performs the same operation but also allows the
81181 ** P3 register to contain a non-integer value, in which case the jump is
81182 ** always taken. This opcode requires that P3 always contain an integer.
81183 **
81184 ** The OP_NotFound opcode performs the same operation on index btrees
81185 ** (with arbitrary multi-value keys).
81186 **
81187 ** This opcode leaves the cursor in a state where it cannot be advanced
81188 ** in either direction. In other words, the Next and Prev opcodes will
81189 ** not work following this opcode.
81190 **
81191 ** See also: Found, NotFound, NoConflict, SeekRowid
81192 */
81193 case OP_SeekRowid: { /* jump, in3 */
81194 VdbeCursor *pC;
81195 BtCursor *pCrsr;
81196 int res;
81197 u64 iKey;
81198
81199 pIn3 = &aMem[pOp->p3];
81200 if( (pIn3->flags & MEM_Int)==0 ){
81201 applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);
81202 if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;
81203 }
81204 /* Fall through into OP_NotExists */
81205 case OP_NotExists: /* jump, in3 */
81206 pIn3 = &aMem[pOp->p3];
81207 assert( pIn3->flags & MEM_Int );
81208 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
81209 pC = p->apCsr[pOp->p1];
81210 assert( pC!=0 );
81211 #ifdef SQLITE_DEBUG
@@ -80836,12 +81319,11 @@
81319 }
81320 if( res ){
81321 v = 1; /* IMP: R-61914-48074 */
81322 }else{
81323 assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );
81324 v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81325 if( v>=MAX_ROWID ){
81326 pC->useRandomRowid = 1;
81327 }else{
81328 v++; /* IMP: R-29538-34987 */
81329 }
@@ -80920,14 +81402,16 @@
81402 ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
81403 ** then rowid is stored for subsequent return by the
81404 ** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
81405 **
81406 ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
81407 ** the last seek operation (OP_NotExists or OP_SeekRowid) was a success,
81408 ** then this
81409 ** operation will not attempt to find the appropriate row before doing
81410 ** the insert but will instead overwrite the row that the cursor is
81411 ** currently pointing to. Presumably, the prior OP_NotExists or
81412 ** OP_SeekRowid opcode
81413 ** has already positioned the cursor correctly. This is an optimization
81414 ** that boosts performance by avoiding redundant seeks.
81415 **
81416 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
81417 ** UPDATE operation. Otherwise (if the flag is clear) then this opcode
@@ -80955,17 +81439,16 @@
81439 */
81440 case OP_Insert:
81441 case OP_InsertInt: {
81442 Mem *pData; /* MEM cell holding data for the record to be inserted */
81443 Mem *pKey; /* MEM cell holding key for the record */
 
81444 VdbeCursor *pC; /* Cursor to table into which insert is written */
 
81445 int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */
81446 const char *zDb; /* database name - used by the update hook */
81447 Table *pTab; /* Table structure - used by update and pre-update hooks */
81448 int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */
81449 BtreePayload x; /* Payload to be inserted */
81450
81451 op = 0;
81452 pData = &aMem[pOp->p2];
81453 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
81454 assert( memIsValid(pData) );
@@ -80980,14 +81463,14 @@
81463 if( pOp->opcode==OP_Insert ){
81464 pKey = &aMem[pOp->p3];
81465 assert( pKey->flags & MEM_Int );
81466 assert( memIsValid(pKey) );
81467 REGISTER_TRACE(pOp->p3, pKey);
81468 x.nKey = pKey->u.i;
81469 }else{
81470 assert( pOp->opcode==OP_InsertInt );
81471 x.nKey = pOp->p3;
81472 }
81473
81474 if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){
81475 assert( pC->isTable );
81476 assert( pC->iDb>=0 );
@@ -81004,39 +81487,41 @@
81487 /* Invoke the pre-update hook, if any */
81488 if( db->xPreUpdateCallback
81489 && pOp->p4type==P4_TABLE
81490 && !(pOp->p5 & OPFLAG_ISUPDATE)
81491 ){
81492 sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);
81493 }
81494 #endif
81495
81496 if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
81497 if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey;
81498 if( pData->flags & MEM_Null ){
81499 x.pData = 0;
81500 x.nData = 0;
81501 }else{
81502 assert( pData->flags & (MEM_Blob|MEM_Str) );
81503 x.pData = pData->z;
81504 x.nData = pData->n;
81505 }
81506 seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);
81507 if( pData->flags & MEM_Zero ){
81508 x.nZero = pData->u.nZero;
81509 }else{
81510 x.nZero = 0;
81511 }
81512 x.pKey = 0;
81513 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,
81514 (pOp->p5 & OPFLAG_APPEND)!=0, seekResult
81515 );
81516 pC->deferredMoveto = 0;
81517 pC->cacheStatus = CACHE_STALE;
81518
81519 /* Invoke the update-hook if required. */
81520 if( rc ) goto abort_due_to_error;
81521 if( db->xUpdateCallback && op ){
81522 db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);
81523 }
81524 break;
81525 }
81526
81527 /* Opcode: Delete P1 P2 P3 P4 P5
@@ -81091,12 +81576,11 @@
81576 #ifdef SQLITE_DEBUG
81577 if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){
81578 /* If p5 is zero, the seek operation that positioned the cursor prior to
81579 ** OP_Delete will have also set the pC->movetoTarget field to the rowid of
81580 ** the row that is being deleted */
81581 i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81582 assert( pC->movetoTarget==iKey );
81583 }
81584 #endif
81585
81586 /* If the update-hook or pre-update-hook will be invoked, set zDb to
@@ -81108,11 +81592,11 @@
81592 assert( pC->iDb>=0 );
81593 assert( pOp->p4.pTab!=0 );
81594 zDb = db->aDb[pC->iDb].zName;
81595 pTab = pOp->p4.pTab;
81596 if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){
81597 pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);
81598 }
81599 }else{
81600 zDb = 0; /* Not needed. Silence a compiler warning. */
81601 pTab = 0; /* Not needed. Silence a compiler warning. */
81602 }
@@ -81262,11 +81746,10 @@
81746 case OP_RowKey:
81747 case OP_RowData: {
81748 VdbeCursor *pC;
81749 BtCursor *pCrsr;
81750 u32 n;
 
81751
81752 pOut = &aMem[pOp->p2];
81753 memAboutToChange(p, pOut);
81754
81755 /* Note that RowKey and RowData are really exactly the same instruction */
@@ -81280,12 +81763,13 @@
81763 assert( pC->nullRow==0 );
81764 assert( pC->uc.pCursor!=0 );
81765 pCrsr = pC->uc.pCursor;
81766
81767 /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or
81768 ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions
81769 ** that might invalidate the cursor.
81770 ** If this where not the case, on of the following assert()s
81771 ** would fail. Should this ever change (because of changes in the code
81772 ** generator) then the fix would be to insert a call to
81773 ** sqlite3VdbeCursorMoveto().
81774 */
81775 assert( pC->deferredMoveto==0 );
@@ -81293,24 +81777,13 @@
81777 #if 0 /* Not required due to the previous to assert() statements */
81778 rc = sqlite3VdbeCursorMoveto(pC);
81779 if( rc!=SQLITE_OK ) goto abort_due_to_error;
81780 #endif
81781
81782 n = sqlite3BtreePayloadSize(pCrsr);
81783 if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
81784 goto too_big;
 
 
 
 
 
 
 
 
 
 
 
81785 }
81786 testcase( n==0 );
81787 if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){
81788 goto no_mem;
81789 }
@@ -81371,12 +81844,11 @@
81844 if( rc ) goto abort_due_to_error;
81845 if( pC->nullRow ){
81846 pOut->flags = MEM_Null;
81847 break;
81848 }
81849 v = sqlite3BtreeIntegerKey(pC->uc.pCursor);
 
81850 }
81851 pOut->u.i = v;
81852 break;
81853 }
81854
@@ -81647,12 +82119,11 @@
82119 ** for tables is OP_Insert.
82120 */
82121 case OP_SorterInsert: /* in2 */
82122 case OP_IdxInsert: { /* in2 */
82123 VdbeCursor *pC;
82124 BtreePayload x;
 
82125
82126 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
82127 pC = p->apCsr[pOp->p1];
82128 assert( pC!=0 );
82129 assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );
@@ -81664,13 +82135,16 @@
82135 rc = ExpandBlob(pIn2);
82136 if( rc ) goto abort_due_to_error;
82137 if( pOp->opcode==OP_SorterInsert ){
82138 rc = sqlite3VdbeSorterWrite(pC, pIn2);
82139 }else{
82140 x.nKey = pIn2->n;
82141 x.pKey = pIn2->z;
82142 x.nData = 0;
82143 x.nZero = 0;
82144 x.pData = 0;
82145 rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3,
82146 ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
82147 );
82148 assert( pC->deferredMoveto==0 );
82149 pC->cacheStatus = CACHE_STALE;
82150 }
@@ -83434,20 +83908,38 @@
83908 **
83909 ** If P2 is not zero, jump to instruction P2.
83910 */
83911 case OP_Init: { /* jump */
83912 char *zTrace;
83913
83914 /* If the P4 argument is not NULL, then it must be an SQL comment string.
83915 ** The "--" string is broken up to prevent false-positives with srcck1.c.
83916 **
83917 ** This assert() provides evidence for:
83918 ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that
83919 ** would have been returned by the legacy sqlite3_trace() interface by
83920 ** using the X argument when X begins with "--" and invoking
83921 ** sqlite3_expanded_sql(P) otherwise.
83922 */
83923 assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 );
83924
83925 #ifndef SQLITE_OMIT_TRACE
83926 if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
83927 && !p->doingRerun
83928 && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
83929 ){
83930 #ifndef SQLITE_OMIT_DEPRECATED
83931 if( db->mTrace & SQLITE_TRACE_LEGACY ){
83932 void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;
83933 char *z = sqlite3VdbeExpandSql(p, zTrace);
83934 x(db->pTraceArg, z);
83935 sqlite3_free(z);
83936 }else
83937 #endif
83938 {
83939 (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
83940 }
83941 }
83942 #ifdef SQLITE_USE_FCNTL_TRACE
83943 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
83944 if( zTrace ){
83945 int i;
@@ -84026,11 +84518,11 @@
84518 ** slightly more efficient). Since you cannot write to a PK column
84519 ** using the incremental-blob API, this works. For the sessions module
84520 ** anyhow.
84521 */
84522 sqlite3_int64 iKey;
84523 iKey = sqlite3BtreeIntegerKey(p->pCsr);
84524 sqlite3VdbePreUpdateHook(
84525 v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1
84526 );
84527 }
84528 #endif
@@ -85461,41 +85953,47 @@
85953 }
85954
85955
85956 /*
85957 ** Merge the two sorted lists p1 and p2 into a single list.
 
85958 */
85959 static SorterRecord *vdbeSorterMerge(
85960 SortSubtask *pTask, /* Calling thread context */
85961 SorterRecord *p1, /* First list to merge */
85962 SorterRecord *p2 /* Second list to merge */
 
85963 ){
85964 SorterRecord *pFinal = 0;
85965 SorterRecord **pp = &pFinal;
85966 int bCached = 0;
85967
85968 assert( p1!=0 && p2!=0 );
85969 for(;;){
85970 int res;
85971 res = pTask->xCompare(
85972 pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
85973 );
85974
85975 if( res<=0 ){
85976 *pp = p1;
85977 pp = &p1->u.pNext;
85978 p1 = p1->u.pNext;
85979 if( p1==0 ){
85980 *pp = p2;
85981 break;
85982 }
85983 }else{
85984 *pp = p2;
85985 pp = &p2->u.pNext;
85986 p2 = p2->u.pNext;
85987 bCached = 0;
85988 if( p2==0 ){
85989 *pp = p1;
85990 break;
85991 }
85992 }
85993 }
85994 return pFinal;
 
85995 }
85996
85997 /*
85998 ** Return the SorterCompare function to compare values collected by the
85999 ** sorter object passed as the only argument.
@@ -85544,20 +86042,21 @@
86042 pNext = p->u.pNext;
86043 }
86044
86045 p->u.pNext = 0;
86046 for(i=0; aSlot[i]; i++){
86047 p = vdbeSorterMerge(pTask, p, aSlot[i]);
86048 aSlot[i] = 0;
86049 }
86050 aSlot[i] = p;
86051 p = pNext;
86052 }
86053
86054 p = 0;
86055 for(i=0; i<64; i++){
86056 if( aSlot[i]==0 ) continue;
86057 p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
86058 }
86059 pList->pList = p;
86060
86061 sqlite3_free(aSlot);
86062 assert( pTask->pUnpacked->errCode==SQLITE_OK
@@ -88173,11 +88672,15 @@
88672 }
88673 if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
88674 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
88675 pNC->nErr++;
88676 is_agg = 0;
88677 }else if( no_such_func && pParse->db->init.busy==0
88678 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
88679 && pParse->explain==0
88680 #endif
88681 ){
88682 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
88683 pNC->nErr++;
88684 }else if( wrong_num_args ){
88685 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
88686 nId, zId);
@@ -90773,10 +91276,15 @@
91276 VdbeComment((v, "%s", pIdx->zName));
91277 assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91278 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91279
91280 if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91281 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91282 const i64 sOne = 1;
91283 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91284 iTab, 0, 0, (u8*)&sOne, P4_INT64);
91285 #endif
91286 *prRhsHasNull = ++pParse->nMem;
91287 sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91288 }
91289 sqlite3VdbeJumpHere(v, iAddr);
91290 }
@@ -90785,11 +91293,11 @@
91293 }
91294
91295 /* If no preexisting index is available for the IN clause
91296 ** and IN_INDEX_NOOP is an allowed reply
91297 ** and the RHS of the IN operator is a list, not a subquery
91298 ** and the RHS is not constant or has two or fewer terms,
91299 ** then it is not worth creating an ephemeral table to evaluate
91300 ** the IN operator so return IN_INDEX_NOOP.
91301 */
91302 if( eType==0
91303 && (inFlags & IN_INDEX_NOOP_OK)
@@ -91177,12 +91685,11 @@
91685 }
91686
91687 if( eType==IN_INDEX_ROWID ){
91688 /* In this case, the RHS is the ROWID of table b-tree
91689 */
91690 sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
 
91691 VdbeCoverage(v);
91692 }else{
91693 /* In this case, the RHS is an index b-tree.
91694 */
91695 sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
@@ -91491,11 +91998,11 @@
91998 if( iCol<0 || iCol==pTab->iPKey ){
91999 sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
92000 }else{
92001 int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
92002 int x = iCol;
92003 if( !HasRowid(pTab) && !IsVirtual(pTab) ){
92004 x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);
92005 }
92006 sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);
92007 }
92008 if( iCol>=0 ){
@@ -91894,10 +92401,15 @@
92401 }
92402 nFarg = pFarg ? pFarg->nExpr : 0;
92403 assert( !ExprHasProperty(pExpr, EP_IntValue) );
92404 zId = pExpr->u.zToken;
92405 pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);
92406 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
92407 if( pDef==0 && pParse->explain ){
92408 pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0);
92409 }
92410 #endif
92411 if( pDef==0 || pDef->xFinalize!=0 ){
92412 sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
92413 break;
92414 }
92415
@@ -92915,10 +93427,65 @@
93427 ){
93428 return 1;
93429 }
93430 return 0;
93431 }
93432
93433 /*
93434 ** An instance of the following structure is used by the tree walker
93435 ** to determine if an expression can be evaluated by reference to the
93436 ** index only, without having to do a search for the corresponding
93437 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
93438 ** is the cursor for the table.
93439 */
93440 struct IdxCover {
93441 Index *pIdx; /* The index to be tested for coverage */
93442 int iCur; /* Cursor number for the table corresponding to the index */
93443 };
93444
93445 /*
93446 ** Check to see if there are references to columns in table
93447 ** pWalker->u.pIdxCover->iCur can be satisfied using the index
93448 ** pWalker->u.pIdxCover->pIdx.
93449 */
93450 static int exprIdxCover(Walker *pWalker, Expr *pExpr){
93451 if( pExpr->op==TK_COLUMN
93452 && pExpr->iTable==pWalker->u.pIdxCover->iCur
93453 && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
93454 ){
93455 pWalker->eCode = 1;
93456 return WRC_Abort;
93457 }
93458 return WRC_Continue;
93459 }
93460
93461 /*
93462 ** Determine if an index pIdx on table with cursor iCur contains will
93463 ** the expression pExpr. Return true if the index does cover the
93464 ** expression and false if the pExpr expression references table columns
93465 ** that are not found in the index pIdx.
93466 **
93467 ** An index covering an expression means that the expression can be
93468 ** evaluated using only the index and without having to lookup the
93469 ** corresponding table entry.
93470 */
93471 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(
93472 Expr *pExpr, /* The index to be tested */
93473 int iCur, /* The cursor number for the corresponding table */
93474 Index *pIdx /* The index that might be used for coverage */
93475 ){
93476 Walker w;
93477 struct IdxCover xcov;
93478 memset(&w, 0, sizeof(w));
93479 xcov.iCur = iCur;
93480 xcov.pIdx = pIdx;
93481 w.xExprCallback = exprIdxCover;
93482 w.u.pIdxCover = &xcov;
93483 sqlite3WalkExpr(&w, pExpr);
93484 return !w.eCode;
93485 }
93486
93487
93488 /*
93489 ** An instance of the following structure is used by the tree walker
93490 ** to count references to table columns in the arguments of an
93491 ** aggregate function, in order to implement the
@@ -93870,10 +94437,11 @@
94437 char *zCol; /* Null-terminated column definition */
94438 Column *pCol; /* The new column */
94439 Expr *pDflt; /* Default value for the new column */
94440 sqlite3 *db; /* The database connection; */
94441 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
94442 int r1; /* Temporary registers */
94443
94444 db = pParse->db;
94445 if( pParse->nErr || db->mallocFailed ) return;
94446 assert( v!=0 );
94447 pNew = pParse->pNewTable;
@@ -93964,20 +94532,22 @@
94532 );
94533 sqlite3DbFree(db, zCol);
94534 db->flags = savedDbFlags;
94535 }
94536
94537 /* Make sure the schema version is at least 3. But do not upgrade
94538 ** from less than 3 to 4, as that will corrupt any preexisting DESC
94539 ** index.
 
 
 
 
94540 */
94541 r1 = sqlite3GetTempReg(pParse);
94542 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
94543 sqlite3VdbeUsesBtree(v, iDb);
94544 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
94545 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
94546 VdbeCoverage(v);
94547 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
94548 sqlite3ReleaseTempReg(pParse, r1);
94549
94550 /* Reload the schema of the modified table. */
94551 reloadTableSchema(pParse, pTab, pTab->zName);
94552 }
94553
@@ -96662,10 +97232,11 @@
97232 ){
97233 sqlite3 *db = pParse->db; /* Database handle */
97234 char *zDb = db->aDb[iDb].zName; /* Name of attached database */
97235 int rc; /* Auth callback return code */
97236
97237 if( db->init.busy ) return SQLITE_OK;
97238 rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext
97239 #ifdef SQLITE_USER_AUTHENTICATION
97240 ,db->auth.zAuthUser
97241 #endif
97242 );
@@ -97152,11 +97723,11 @@
97723 ** routine leaves an error message in pParse->zErrMsg where
97724 ** sqlite3FindTable() does not.
97725 */
97726 SQLITE_PRIVATE Table *sqlite3LocateTable(
97727 Parse *pParse, /* context in which to report errors */
97728 u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */
97729 const char *zName, /* Name of the table we are looking for */
97730 const char *zDbase /* Name of the database. Might be NULL */
97731 ){
97732 Table *p;
97733
@@ -97166,11 +97737,11 @@
97737 return 0;
97738 }
97739
97740 p = sqlite3FindTable(pParse->db, zName, zDbase);
97741 if( p==0 ){
97742 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
97743 #ifndef SQLITE_OMIT_VIRTUALTABLE
97744 if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
97745 /* If zName is the not the name of a table in the schema created using
97746 ** CREATE, then check to see if it is the name of an virtual table that
97747 ** can be an eponymous virtual table. */
@@ -97178,16 +97749,18 @@
97749 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
97750 return pMod->pEpoTab;
97751 }
97752 }
97753 #endif
97754 if( (flags & LOCATE_NOERR)==0 ){
97755 if( zDbase ){
97756 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
97757 }else{
97758 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
97759 }
97760 pParse->checkSchema = 1;
97761 }
 
97762 }
97763
97764 return p;
97765 }
97766
@@ -97200,11 +97773,11 @@
97773 ** non-NULL if it is part of a view or trigger program definition. See
97774 ** sqlite3FixSrcList() for details.
97775 */
97776 SQLITE_PRIVATE Table *sqlite3LocateTableItem(
97777 Parse *pParse,
97778 u32 flags,
97779 struct SrcList_item *p
97780 ){
97781 const char *zDb;
97782 assert( p->pSchema==0 || p->zDatabase==0 );
97783 if( p->pSchema ){
@@ -97211,11 +97784,11 @@
97784 int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
97785 zDb = pParse->db->aDb[iDb].zName;
97786 }else{
97787 zDb = p->zDatabase;
97788 }
97789 return sqlite3LocateTable(pParse, flags, p->zName, zDb);
97790 }
97791
97792 /*
97793 ** Locate the in-memory structure that describes
97794 ** a particular index given the name of that index
@@ -97419,12 +97992,13 @@
97992 db->lookaside.nOut : 0 );
97993
97994 /* Delete all indices associated with this table. */
97995 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
97996 pNext = pIndex->pNext;
97997 assert( pIndex->pSchema==pTable->pSchema
97998 || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );
97999 if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
98000 char *zName = pIndex->zName;
98001 TESTONLY ( Index *pOld = ) sqlite3HashInsert(
98002 &pIndex->pSchema->idxHash, zName, 0
98003 );
98004 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
@@ -98102,11 +98676,11 @@
98676 ){
98677 Table *pTab = pParse->pNewTable;
98678 Column *pCol = 0;
98679 int iCol = -1, i;
98680 int nTerm;
98681 if( pTab==0 ) goto primary_key_exit;
98682 if( pTab->tabFlags & TF_HasPrimaryKey ){
98683 sqlite3ErrorMsg(pParse,
98684 "table \"%s\" has more than one primary key", pTab->zName);
98685 goto primary_key_exit;
98686 }
@@ -98148,16 +98722,12 @@
98722 #ifndef SQLITE_OMIT_AUTOINCREMENT
98723 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
98724 "INTEGER PRIMARY KEY");
98725 #endif
98726 }else{
98727 sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
98728 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);
 
 
 
 
98729 pList = 0;
98730 }
98731
98732 primary_key_exit:
98733 sqlite3ExprListDelete(pParse->db, pList);
@@ -98470,33 +99040,49 @@
99040 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
99041 ** internal schema data structures and the generated VDBE code so that they
99042 ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
99043 ** Changes include:
99044 **
99045 ** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
99046 ** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is
99047 ** no rowid btree for a WITHOUT ROWID. Instead, the canonical
99048 ** data storage is a covering index btree.
99049 ** (3) Bypass the creation of the sqlite_master table entry
99050 ** for the PRIMARY KEY as the primary key index is now
99051 ** identified by the sqlite_master table entry of the table itself.
99052 ** (4) Set the Index.tnum of the PRIMARY KEY Index object in the
99053 ** schema to the rootpage from the main table.
 
99054 ** (5) Add all table columns to the PRIMARY KEY Index object
99055 ** so that the PRIMARY KEY is a covering index. The surplus
99056 ** columns are part of KeyInfo.nXField and are not used for
99057 ** sorting or lookup or uniqueness checks.
99058 ** (6) Replace the rowid tail on all automatically generated UNIQUE
99059 ** indices with the PRIMARY KEY columns.
99060 **
99061 ** For virtual tables, only (1) is performed.
99062 */
99063 static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
99064 Index *pIdx;
99065 Index *pPk;
99066 int nPk;
99067 int i, j;
99068 sqlite3 *db = pParse->db;
99069 Vdbe *v = pParse->pVdbe;
99070
99071 /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)
99072 */
99073 if( !db->init.imposterTable ){
99074 for(i=0; i<pTab->nCol; i++){
99075 if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
99076 pTab->aCol[i].notNull = OE_Abort;
99077 }
99078 }
99079 }
99080
99081 /* The remaining transformations only apply to b-tree tables, not to
99082 ** virtual tables */
99083 if( IN_DECLARE_VTAB ) return;
99084
99085 /* Convert the OP_CreateTable opcode that would normally create the
99086 ** root-page for the table into an OP_CreateIndex opcode. The index
99087 ** created will become the PRIMARY KEY index.
99088 */
@@ -98515,13 +99101,14 @@
99101 pList = sqlite3ExprListAppend(pParse, 0,
99102 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
99103 if( pList==0 ) return;
99104 pList->a[0].sortOrder = pParse->iPkSortOrder;
99105 assert( pParse->pNewTable==pTab );
99106 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
99107 SQLITE_IDXTYPE_PRIMARYKEY);
99108 if( db->mallocFailed ) return;
99109 pPk = sqlite3PrimaryKeyIndex(pTab);
99110 pTab->iPKey = -1;
99111 }else{
99112 pPk = sqlite3PrimaryKeyIndex(pTab);
99113
99114 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master
@@ -98545,23 +99132,15 @@
99132 pPk->aiColumn[j++] = pPk->aiColumn[i];
99133 }
99134 }
99135 pPk->nKeyCol = j;
99136 }
 
99137 assert( pPk!=0 );
99138 pPk->isCovering = 1;
99139 if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
99140 nPk = pPk->nKeyCol;
99141
 
 
 
 
 
 
 
 
 
99142 /* The root page of the PRIMARY KEY is the table root page */
99143 pPk->tnum = pTab->tnum;
99144
99145 /* Update the in-memory representation of all UNIQUE indices by converting
99146 ** the final rowid column into one or more columns of the PRIMARY KEY.
@@ -99312,10 +99891,11 @@
99891 }
99892 assert( pParse->nErr==0 );
99893 assert( pName->nSrc==1 );
99894 if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
99895 if( noErr ) db->suppressErr++;
99896 assert( isView==0 || isView==LOCATE_VIEW );
99897 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
99898 if( noErr ) db->suppressErr--;
99899
99900 if( pTab==0 ){
99901 if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
@@ -99682,28 +100262,24 @@
100262 ** currently being constructed by a CREATE TABLE statement.
100263 **
100264 ** pList is a list of columns to be indexed. pList will be NULL if this
100265 ** is a primary key or unique-constraint on the most recent column added
100266 ** to the table currently under construction.
 
 
 
 
100267 */
100268 SQLITE_PRIVATE void sqlite3CreateIndex(
100269 Parse *pParse, /* All information about this parse */
100270 Token *pName1, /* First part of index name. May be NULL */
100271 Token *pName2, /* Second part of index name. May be NULL */
100272 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
100273 ExprList *pList, /* A list of columns to be indexed */
100274 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
100275 Token *pStart, /* The CREATE token that begins this statement */
100276 Expr *pPIWhere, /* WHERE clause for partial indices */
100277 int sortOrder, /* Sort order of primary key when pList==NULL */
100278 int ifNotExist, /* Omit error if index already exists */
100279 u8 idxType /* The index type */
100280 ){
 
100281 Table *pTab = 0; /* Table to be indexed */
100282 Index *pIndex = 0; /* The index to be created */
100283 char *zName = 0; /* Name of the index */
100284 int nName; /* Number of characters in zName */
100285 int i, j;
@@ -99717,11 +100293,14 @@
100293 int nExtra = 0; /* Space allocated for zExtra[] */
100294 int nExtraCol; /* Number of extra columns needed */
100295 char *zExtra = 0; /* Extra space after the Index object */
100296 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
100297
100298 if( db->mallocFailed || pParse->nErr>0 ){
100299 goto exit_create_index;
100300 }
100301 if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
100302 goto exit_create_index;
100303 }
100304 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
100305 goto exit_create_index;
100306 }
@@ -99843,10 +100422,17 @@
100422 for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
100423 zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
100424 if( zName==0 ){
100425 goto exit_create_index;
100426 }
100427
100428 /* Automatic index names generated from within sqlite3_declare_vtab()
100429 ** must have names that are distinct from normal automatic index names.
100430 ** The following statement converts "sqlite3_autoindex..." into
100431 ** "sqlite3_butoindex..." in order to make the names distinct.
100432 ** The "vtab_err.test" test demonstrates the need of this statement. */
100433 if( IN_DECLARE_VTAB ) zName[7]++;
100434 }
100435
100436 /* Check for authorization to create an index.
100437 */
100438 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -99906,11 +100492,11 @@
100492 zExtra += nName + 1;
100493 memcpy(pIndex->zName, zName, nName+1);
100494 pIndex->pTable = pTab;
100495 pIndex->onError = (u8)onError;
100496 pIndex->uniqNotNull = onError!=OE_None;
100497 pIndex->idxType = idxType;
100498 pIndex->pSchema = db->aDb[iDb].pSchema;
100499 pIndex->nKeyCol = pList->nExpr;
100500 if( pPIWhere ){
100501 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
100502 pIndex->pPartIdxWhere = pPIWhere;
@@ -100086,11 +100672,11 @@
100672 }
100673 if( pIdx->onError==OE_Default ){
100674 pIdx->onError = pIndex->onError;
100675 }
100676 }
100677 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
100678 goto exit_create_index;
100679 }
100680 }
100681 }
100682
@@ -100098,10 +100684,11 @@
100684 ** in-memory database structures.
100685 */
100686 assert( pParse->nErr==0 );
100687 if( db->init.busy ){
100688 Index *p;
100689 assert( !IN_DECLARE_VTAB );
100690 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
100691 p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
100692 pIndex->zName, pIndex);
100693 if( p ){
100694 assert( p==pIndex ); /* Malloc must have failed */
@@ -100179,11 +100766,11 @@
100766 if( pTblName ){
100767 sqlite3RefillIndex(pParse, pIndex, iMem);
100768 sqlite3ChangeCookie(pParse, iDb);
100769 sqlite3VdbeAddParseSchemaOp(v, iDb,
100770 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
100771 sqlite3VdbeAddOp0(v, OP_Expire);
100772 }
100773
100774 sqlite3VdbeJumpHere(v, pIndex->tnum);
100775 }
100776
@@ -100204,11 +100791,10 @@
100791 pOther = pOther->pNext;
100792 }
100793 pIndex->pNext = pOther->pNext;
100794 pOther->pNext = pIndex;
100795 }
 
100796 pIndex = 0;
100797 }
100798
100799 /* Clean up before exiting */
100800 exit_create_index:
@@ -100215,11 +100801,10 @@
100801 if( pIndex ) freeIndex(db, pIndex);
100802 sqlite3ExprDelete(db, pPIWhere);
100803 sqlite3ExprListDelete(db, pList);
100804 sqlite3SrcListDelete(db, pTblName);
100805 sqlite3DbFree(db, zName);
 
100806 }
100807
100808 /*
100809 ** Fill the Index.aiRowEst[] array with default information - information
100810 ** to be used when we have not run the ANALYZE command.
@@ -100244,14 +100829,15 @@
100829 LogEst *a = pIdx->aiRowLogEst;
100830 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
100831 int i;
100832
100833 /* Set the first entry (number of rows in the index) to the estimated
100834 ** number of rows in the table, or half the number of rows in the table
100835 ** for a partial index. But do not let the estimate drop below 10. */
100836 a[0] = pIdx->pTable->nRowLogEst;
100837 if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
100838 if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
100839
100840 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is
100841 ** 6 and each subsequent value (if any) is 5. */
100842 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));
100843 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
@@ -101129,14 +101715,10 @@
101715 #endif
101716
101717 /*
101718 ** Return a KeyInfo structure that is appropriate for the given Index.
101719 **
 
 
 
 
101720 ** The caller should invoke sqlite3KeyInfoUnref() on the returned object
101721 ** when it has finished using it.
101722 */
101723 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
101724 int i;
@@ -103364,11 +103946,11 @@
103946 continue;
103947 }
103948 }
103949 c2 = Utf8Read(zString);
103950 if( c==c2 ) continue;
103951 if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){
103952 continue;
103953 }
103954 if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
103955 return 0;
103956 }
@@ -103939,10 +104521,30 @@
104521 }
104522 }
104523 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
104524 }
104525
104526
104527 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
104528 /*
104529 ** The "unknown" function is automatically substituted in place of
104530 ** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN
104531 ** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.
104532 ** When the "sqlite3" command-line shell is built using this functionality,
104533 ** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries
104534 ** involving application-defined functions to be examined in a generic
104535 ** sqlite3 shell.
104536 */
104537 static void unknownFunc(
104538 sqlite3_context *context,
104539 int argc,
104540 sqlite3_value **argv
104541 ){
104542 /* no-op */
104543 }
104544 #endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/
104545
104546
104547 /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
104548 ** is only available if the SQLITE_SOUNDEX compile-time option is used
104549 ** when SQLite is built.
104550 */
@@ -104410,17 +105012,20 @@
105012 AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
105013 AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
105014 AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
105015
105016 LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
105017 #ifdef SQLITE_CASE_SENSITIVE_LIKE
105018 LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
105019 LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
105020 #else
105021 LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
105022 LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
105023 #endif
105024 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
105025 FUNCTION(unknown, -1, 0, 0, unknownFunc ),
105026 #endif
105027 FUNCTION(coalesce, 1, 0, 0, 0 ),
105028 FUNCTION(coalesce, 0, 0, 0, 0 ),
105029 FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE),
105030 };
105031 #ifndef SQLITE_OMIT_ALTERTABLE
@@ -105823,11 +106428,12 @@
106428 */
106429 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
106430 FKey *pFKey; /* Iterator variable */
106431 FKey *pNext; /* Copy of pFKey->pNextFrom */
106432
106433 assert( db==0 || IsVirtual(pTab)
106434 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );
106435 for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
106436
106437 /* Remove the FK from the fkeyHash hash table. */
106438 if( !db || db->pnBytesFreed==0 ){
106439 if( pFKey->pPrevTo ){
@@ -108233,16 +108839,14 @@
108839 ** shared libraries that want to be imported as extensions into
108840 ** an SQLite instance. Shared libraries that intend to be loaded
108841 ** as extensions by SQLite should #include this file instead of
108842 ** sqlite3.h.
108843 */
108844 #ifndef SQLITE3EXT_H
108845 #define SQLITE3EXT_H
108846 /* #include "sqlite3.h" */
108847
 
 
108848 /*
108849 ** The following structure holds pointers to all of the SQLite API
108850 ** routines.
108851 **
108852 ** WARNING: In order to maintain backwards compatibility, add new
@@ -108499,11 +109103,24 @@
109103 int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
109104 int (*strlike)(const char*,const char*,unsigned int);
109105 int (*db_cacheflush)(sqlite3*);
109106 /* Version 3.12.0 and later */
109107 int (*system_errno)(sqlite3*);
109108 /* Version 3.14.0 and later */
109109 int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
109110 char *(*expanded_sql)(sqlite3_stmt*);
109111 };
109112
109113 /*
109114 ** This is the function signature used for all extension entry points. It
109115 ** is also defined in the file "loadext.c".
109116 */
109117 typedef int (*sqlite3_loadext_entry)(
109118 sqlite3 *db, /* Handle to the database. */
109119 char **pzErrMsg, /* Used to set error string on failure. */
109120 const sqlite3_api_routines *pThunk /* Extension API function pointers. */
109121 );
109122
109123 /*
109124 ** The following macros redefine the API routines so that they are
109125 ** redirected through the global sqlite3_api structure.
109126 **
@@ -108744,10 +109361,13 @@
109361 #define sqlite3_status64 sqlite3_api->status64
109362 #define sqlite3_strlike sqlite3_api->strlike
109363 #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
109364 /* Version 3.12.0 and later */
109365 #define sqlite3_system_errno sqlite3_api->system_errno
109366 /* Version 3.14.0 and later */
109367 #define sqlite3_trace_v2 sqlite3_api->trace_v2
109368 #define sqlite3_expanded_sql sqlite3_api->expanded_sql
109369 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
109370
109371 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
109372 /* This case when the file really is being compiled as a loadable
109373 ** extension */
@@ -108761,19 +109381,18 @@
109381 # define SQLITE_EXTENSION_INIT1 /*no-op*/
109382 # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
109383 # define SQLITE_EXTENSION_INIT3 /*no-op*/
109384 #endif
109385
109386 #endif /* SQLITE3EXT_H */
109387
109388 /************** End of sqlite3ext.h ******************************************/
109389 /************** Continuing where we left off in loadext.c ********************/
109390 /* #include "sqliteInt.h" */
109391 /* #include <string.h> */
109392
109393 #ifndef SQLITE_OMIT_LOAD_EXTENSION
 
109394 /*
109395 ** Some API routines are omitted when various features are
109396 ** excluded from a build of SQLite. Substitute a NULL pointer
109397 ** for any missing APIs.
109398 */
@@ -108839,11 +109458,11 @@
109458
109459 #ifdef SQLITE_OMIT_SHARED_CACHE
109460 # define sqlite3_enable_shared_cache 0
109461 #endif
109462
109463 #if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)
109464 # define sqlite3_profile 0
109465 # define sqlite3_trace 0
109466 #endif
109467
109468 #ifdef SQLITE_OMIT_GET_TABLE
@@ -108858,10 +109477,14 @@
109477 #define sqlite3_blob_open 0
109478 #define sqlite3_blob_read 0
109479 #define sqlite3_blob_write 0
109480 #define sqlite3_blob_reopen 0
109481 #endif
109482
109483 #if defined(SQLITE_OMIT_TRACE)
109484 # define sqlite3_trace_v2 0
109485 #endif
109486
109487 /*
109488 ** The following structure contains pointers to all SQLite API routines.
109489 ** A pointer to this structure is passed into extensions when they are
109490 ** loaded so that the extension can make calls back into the SQLite
@@ -109164,11 +109787,14 @@
109787 /* Version 3.10.0 and later */
109788 sqlite3_status64,
109789 sqlite3_strlike,
109790 sqlite3_db_cacheflush,
109791 /* Version 3.12.0 and later */
109792 sqlite3_system_errno,
109793 /* Version 3.14.0 and later */
109794 sqlite3_trace_v2,
109795 sqlite3_expanded_sql
109796 };
109797
109798 /*
109799 ** Attempt to load an SQLite extension library contained in the file
109800 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -109187,17 +109813,18 @@
109813 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
109814 char **pzErrMsg /* Put error message here if not 0 */
109815 ){
109816 sqlite3_vfs *pVfs = db->pVfs;
109817 void *handle;
109818 sqlite3_loadext_entry xInit;
109819 char *zErrmsg = 0;
109820 const char *zEntry;
109821 char *zAltEntry = 0;
109822 void **aHandle;
109823 u64 nMsg = 300 + sqlite3Strlen30(zFile);
109824 int ii;
109825 int rc;
109826
109827 /* Shared library endings to try if zFile cannot be loaded as written */
109828 static const char *azEndings[] = {
109829 #if SQLITE_OS_WIN
109830 "dll"
@@ -109245,12 +109872,11 @@
109872 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
109873 }
109874 }
109875 return SQLITE_ERROR;
109876 }
109877 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
 
109878
109879 /* If no entry point was specified and the default legacy
109880 ** entry point name "sqlite3_extension_init" was not found, then
109881 ** construct an entry point name "sqlite3_X_init" where the X is
109882 ** replaced by the lowercase value of every ASCII alphabetic
@@ -109278,12 +109904,11 @@
109904 zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];
109905 }
109906 }
109907 memcpy(zAltEntry+iEntry, "_init", 6);
109908 zEntry = zAltEntry;
109909 xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);
 
109910 }
109911 if( xInit==0 ){
109912 if( pzErrMsg ){
109913 nMsg += sqlite3Strlen30(zEntry);
109914 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
@@ -109296,11 +109921,13 @@
109921 sqlite3OsDlClose(pVfs, handle);
109922 sqlite3_free(zAltEntry);
109923 return SQLITE_ERROR;
109924 }
109925 sqlite3_free(zAltEntry);
109926 rc = xInit(db, &zErrmsg, &sqlite3Apis);
109927 if( rc ){
109928 if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;
109929 if( pzErrMsg ){
109930 *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
109931 }
109932 sqlite3_free(zErrmsg);
109933 sqlite3OsDlClose(pVfs, handle);
@@ -109407,11 +110034,13 @@
110034
110035 /*
110036 ** Register a statically linked extension that is automatically
110037 ** loaded by every new database connection.
110038 */
110039 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(
110040 void (*xInit)(void)
110041 ){
110042 int rc = SQLITE_OK;
110043 #ifndef SQLITE_OMIT_AUTOINIT
110044 rc = sqlite3_initialize();
110045 if( rc ){
110046 return rc;
@@ -109452,11 +110081,13 @@
110081 ** routine is a no-op.
110082 **
110083 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
110084 ** was not on the list.
110085 */
110086 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(
110087 void (*xInit)(void)
110088 ){
110089 #if SQLITE_THREADSAFE
110090 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
110091 #endif
110092 int i;
110093 int n = 0;
@@ -109501,11 +110132,11 @@
110132 */
110133 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
110134 u32 i;
110135 int go = 1;
110136 int rc;
110137 sqlite3_loadext_entry xInit;
110138
110139 wsdAutoextInit;
110140 if( wsdAutoext.nExt==0 ){
110141 /* Common case: early out without every having to acquire a mutex */
110142 return;
@@ -109518,12 +110149,11 @@
110149 sqlite3_mutex_enter(mutex);
110150 if( i>=wsdAutoext.nExt ){
110151 xInit = 0;
110152 go = 0;
110153 }else{
110154 xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i];
 
110155 }
110156 sqlite3_mutex_leave(mutex);
110157 zErrmsg = 0;
110158 if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){
110159 sqlite3ErrorWithMsg(db, rc,
@@ -111034,11 +111664,11 @@
111664
111665 /* Many of the flag-pragmas modify the code generated by the SQL
111666 ** compiler (eg. count_changes). So add an opcode to expire all
111667 ** compiled SQL statements after modifying a pragma value.
111668 */
111669 sqlite3VdbeAddOp0(v, OP_Expire);
111670 setAllPagerFlags(db);
111671 }
111672 break;
111673 }
111674 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
@@ -111056,11 +111686,11 @@
111686 ** notnull: True if 'NOT NULL' is part of column declaration
111687 ** dflt_value: The default value for the column, if any.
111688 */
111689 case PragTyp_TABLE_INFO: if( zRight ){
111690 Table *pTab;
111691 pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
111692 if( pTab ){
111693 static const char *azCol[] = {
111694 "cid", "name", "type", "notnull", "dflt_value", "pk"
111695 };
111696 int i, k;
@@ -111338,16 +111968,14 @@
111968 assert( iKey>=0 && iKey<pTab->nCol );
111969 if( iKey!=pTab->iPKey ){
111970 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
111971 sqlite3ColumnDefault(v, pTab, iKey, regRow);
111972 sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v);
 
 
111973 }else{
111974 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);
111975 }
111976 sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v);
111977 sqlite3VdbeGoto(v, addrOk);
111978 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
111979 }else{
111980 for(j=0; j<pFK->nCol; j++){
111981 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
@@ -112914,10 +113542,11 @@
113542 int regReturn; /* Register holding block-output return address */
113543 int labelBkOut; /* Start label for the block-output subroutine */
113544 int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */
113545 int labelDone; /* Jump here when done, ex: LIMIT reached */
113546 u8 sortFlags; /* Zero or more SORTFLAG_* bits */
113547 u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
113548 };
113549 #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
113550
113551 /*
113552 ** Delete all the content of a Select structure. Deallocate the structure
@@ -113447,13 +114076,34 @@
114076 op = OP_IdxInsert;
114077 }
114078 sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
114079 if( iLimit ){
114080 int addr;
114081 int r1 = 0;
114082 /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit
114083 ** register is initialized with value of LIMIT+OFFSET.) After the sorter
114084 ** fills up, delete the least entry in the sorter after each insert.
114085 ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */
114086 addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v);
114087 sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
114088 if( pSort->bOrderedInnerLoop ){
114089 r1 = ++pParse->nMem;
114090 sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);
114091 VdbeComment((v, "seq"));
114092 }
114093 sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
114094 if( pSort->bOrderedInnerLoop ){
114095 /* If the inner loop is driven by an index such that values from
114096 ** the same iteration of the inner loop are in sorted order, then
114097 ** immediately jump to the next iteration of an inner loop if the
114098 ** entry from the current iteration does not fit into the top
114099 ** LIMIT+OFFSET entries of the sorter. */
114100 int iBrk = sqlite3VdbeCurrentAddr(v) + 2;
114101 sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);
114102 sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
114103 VdbeCoverage(v);
114104 }
114105 sqlite3VdbeJumpHere(v, addr);
114106 }
114107 }
114108
114109 /*
@@ -113864,11 +114514,11 @@
114514 ** Allocate a KeyInfo object sufficient for an index of N key columns and
114515 ** X extra columns.
114516 */
114517 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
114518 int nExtra = (N+X)*(sizeof(CollSeq*)+1);
114519 KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra);
114520 if( p ){
114521 p->aSortOrder = (u8*)&p->aColl[N+X];
114522 p->nField = (u16)N;
114523 p->nXField = (u16)X;
114524 p->enc = ENC(db);
@@ -113886,11 +114536,11 @@
114536 */
114537 SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){
114538 if( p ){
114539 assert( p->nRef>0 );
114540 p->nRef--;
114541 if( p->nRef==0 ) sqlite3DbFree(p->db, p);
114542 }
114543 }
114544
114545 /*
114546 ** Make a new pointer to a KeyInfo object
@@ -118034,10 +118684,11 @@
118684 if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){
118685 sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);
118686 }
118687 if( sSort.pOrderBy ){
118688 sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);
118689 sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);
118690 if( sSort.nOBSat==sSort.pOrderBy->nExpr ){
118691 sSort.pOrderBy = 0;
118692 }
118693 }
118694
@@ -120803,11 +121454,11 @@
121454 Btree *pTemp; /* The temporary database we vacuum into */
121455 char *zSql = 0; /* SQL statements */
121456 int saved_flags; /* Saved value of the db->flags */
121457 int saved_nChange; /* Saved value of db->nChange */
121458 int saved_nTotalChange; /* Saved value of db->nTotalChange */
121459 u8 saved_mTrace; /* Saved trace settings */
121460 Db *pDb = 0; /* Database to detach at end of vacuum */
121461 int isMemDb; /* True if vacuuming a :memory: database */
121462 int nRes; /* Bytes of reserved space at the end of each page */
121463 int nDb; /* Number of attached databases */
121464
@@ -120824,14 +121475,14 @@
121475 ** restored before returning. Then set the writable-schema flag, and
121476 ** disable CHECK and foreign key constraints. */
121477 saved_flags = db->flags;
121478 saved_nChange = db->nChange;
121479 saved_nTotalChange = db->nTotalChange;
121480 saved_mTrace = db->mTrace;
121481 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
121482 db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
121483 db->mTrace = 0;
121484
121485 pMain = db->aDb[0].pBt;
121486 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
121487
121488 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -120879,10 +121530,12 @@
121530 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
121531 if( nKey ) db->nextPagesize = 0;
121532 }
121533 #endif
121534
121535 sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size);
121536 sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
121537 rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF");
121538 if( rc!=SQLITE_OK ) goto end_of_vacuum;
121539
121540 /* Begin a transaction and take an exclusive lock on the main database
121541 ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
@@ -121027,11 +121680,11 @@
121680 end_of_vacuum:
121681 /* Restore the original value of db->flags */
121682 db->flags = saved_flags;
121683 db->nChange = saved_nChange;
121684 db->nTotalChange = saved_nTotalChange;
121685 db->mTrace = saved_mTrace;
121686 sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
121687
121688 /* Currently there is an SQL level transaction open on the vacuum
121689 ** database. No locks are held on any other files (since the main file
121690 ** was committed at the btree level). So it safe to end the transaction
@@ -121476,11 +122129,11 @@
122129 );
122130 sqlite3DbFree(db, zStmt);
122131 v = sqlite3GetVdbe(pParse);
122132 sqlite3ChangeCookie(pParse, iDb);
122133
122134 sqlite3VdbeAddOp0(v, OP_Expire);
122135 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
122136 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
122137
122138 iReg = ++pParse->nMem;
122139 sqlite3VdbeLoadString(v, iReg, pTab->zName);
@@ -121812,14 +122465,28 @@
122465 && !db->mallocFailed
122466 && !pParse->pNewTable->pSelect
122467 && (pParse->pNewTable->tabFlags & TF_Virtual)==0
122468 ){
122469 if( !pTab->aCol ){
122470 Table *pNew = pParse->pNewTable;
122471 Index *pIdx;
122472 pTab->aCol = pNew->aCol;
122473 pTab->nCol = pNew->nCol;
122474 pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
122475 pNew->nCol = 0;
122476 pNew->aCol = 0;
122477 assert( pTab->pIndex==0 );
122478 if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){
122479 rc = SQLITE_ERROR;
122480 }
122481 pIdx = pNew->pIndex;
122482 if( pIdx ){
122483 assert( pIdx->pNext==0 );
122484 pTab->pIndex = pIdx;
122485 pNew->pIndex = 0;
122486 pIdx->pTable = pTab;
122487 }
122488 }
122489 pCtx->bDeclared = 1;
122490 }else{
122491 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
122492 sqlite3DbFree(db, zErr);
@@ -121851,11 +122518,11 @@
122518 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
122519 int rc = SQLITE_OK;
122520 Table *pTab;
122521
122522 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
122523 if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){
122524 VTable *p;
122525 int (*xDestroy)(sqlite3_vtab *);
122526 for(p=pTab->pVTable; p; p=p->pNext){
122527 assert( p->pVtab );
122528 if( p->pVtab->nRef>0 ){
@@ -121991,11 +122658,14 @@
122658 if( rc==SQLITE_OK ){
122659 rc = pModule->xBegin(pVTab->pVtab);
122660 if( rc==SQLITE_OK ){
122661 int iSvpt = db->nStatement + db->nSavepoint;
122662 addToVTrans(db, pVTab);
122663 if( iSvpt && pModule->xSavepoint ){
122664 pVTab->iSavepoint = iSvpt;
122665 rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);
122666 }
122667 }
122668 }
122669 }
122670 return rc;
122671 }
@@ -122145,11 +122815,11 @@
122815 sqlite3OomFault(pToplevel->db);
122816 }
122817 }
122818
122819 /*
122820 ** Check to see if virtual table module pMod can be have an eponymous
122821 ** virtual table instance. If it can, create one if one does not already
122822 ** exist. Return non-zero if the eponymous virtual table instance exists
122823 ** when this routine returns, and return zero if it does not exist.
122824 **
122825 ** An eponymous virtual table instance is one that is named after its
@@ -122162,21 +122832,22 @@
122832 */
122833 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
122834 const sqlite3_module *pModule = pMod->pModule;
122835 Table *pTab;
122836 char *zErr = 0;
 
122837 int rc;
122838 sqlite3 *db = pParse->db;
122839 if( pMod->pEpoTab ) return 1;
122840 if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;
122841 pTab = sqlite3DbMallocZero(db, sizeof(Table));
 
122842 if( pTab==0 ) return 0;
122843 pTab->zName = sqlite3DbStrDup(db, pMod->zName);
122844 if( pTab->zName==0 ){
122845 sqlite3DbFree(db, pTab);
122846 return 0;
122847 }
122848 pMod->pEpoTab = pTab;
 
 
122849 pTab->nRef = 1;
122850 pTab->pSchema = db->aDb[0].pSchema;
122851 pTab->tabFlags |= TF_Virtual;
122852 pTab->nModuleArg = 0;
122853 pTab->iPKey = -1;
@@ -122198,13 +122869,15 @@
122869 ** virtual table module pMod, if it exists.
122870 */
122871 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){
122872 Table *pTab = pMod->pEpoTab;
122873 if( pTab!=0 ){
122874 /* Mark the table as Ephemeral prior to deleting it, so that the
122875 ** sqlite3DeleteTable() routine will know that it is not stored in
122876 ** the schema. */
122877 pTab->tabFlags |= TF_Ephemeral;
122878 sqlite3DeleteTable(db, pTab);
122879 pMod->pEpoTab = 0;
122880 }
122881 }
122882
122883 /*
@@ -122707,12 +123380,13 @@
123380 u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
123381 i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
123382 u8 sorted; /* True if really sorted (not just grouped) */
123383 u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
123384 u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
123385 u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
123386 u8 nLevel; /* Number of nested loop */
123387 u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */
123388 int iTop; /* The very beginning of the WHERE loop */
123389 int iContinue; /* Jump here to continue with next record */
123390 int iBreak; /* Jump here to break out of the loop */
123391 int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
123392 int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
@@ -122725,10 +123399,13 @@
123399 ** Private interfaces - callable only by other where.c routines.
123400 **
123401 ** where.c:
123402 */
123403 SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);
123404 #ifdef WHERETRACE_ENABLED
123405 SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);
123406 #endif
123407 SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(
123408 WhereClause *pWC, /* The WHERE clause to be searched */
123409 int iCur, /* Cursor number of LHS */
123410 int iColumn, /* Column number of LHS */
123411 Bitmask notReady, /* RHS must not overlap with this mask */
@@ -122941,11 +123618,11 @@
123618 StrAccum str; /* EQP output string */
123619 char zBuf[100]; /* Initial space for EQP output string */
123620
123621 pLoop = pLevel->pWLoop;
123622 flags = pLoop->wsFlags;
123623 if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;
123624
123625 isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
123626 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
123627 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
123628
@@ -123384,11 +124061,11 @@
124061 **
124062 ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
124063 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
124064 ** scan loop run twice, once for strings and a second time for BLOBs.
124065 ** The OP_String opcodes on the second pass convert the upper and lower
124066 ** bound string constants to blobs. This routine makes the necessary changes
124067 ** to the OP_String opcodes for that to happen.
124068 **
124069 ** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then
124070 ** only the one pass through the string space is required, so this routine
124071 ** becomes a no-op.
@@ -123441,10 +124118,42 @@
124118 pWalker->eCode = 1;
124119 }
124120 return WRC_Continue;
124121 }
124122
124123 /*
124124 ** Test whether or not expression pExpr, which was part of a WHERE clause,
124125 ** should be included in the cursor-hint for a table that is on the rhs
124126 ** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the
124127 ** expression is not suitable.
124128 **
124129 ** An expression is unsuitable if it might evaluate to non NULL even if
124130 ** a TK_COLUMN node that does affect the value of the expression is set
124131 ** to NULL. For example:
124132 **
124133 ** col IS NULL
124134 ** col IS NOT NULL
124135 ** coalesce(col, 1)
124136 ** CASE WHEN col THEN 0 ELSE 1 END
124137 */
124138 static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){
124139 if( pExpr->op==TK_IS
124140 || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT
124141 || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE
124142 ){
124143 pWalker->eCode = 1;
124144 }else if( pExpr->op==TK_FUNCTION ){
124145 int d1;
124146 char d2[3];
124147 if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){
124148 pWalker->eCode = 1;
124149 }
124150 }
124151
124152 return WRC_Continue;
124153 }
124154
124155
124156 /*
124157 ** This function is called on every node of an expression tree used as an
124158 ** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN
124159 ** that accesses any table other than the one identified by
@@ -123493,10 +124202,11 @@
124202
124203 /*
124204 ** Insert an OP_CursorHint instruction if it is appropriate to do so.
124205 */
124206 static void codeCursorHint(
124207 struct SrcList_item *pTabItem, /* FROM clause item */
124208 WhereInfo *pWInfo, /* The where clause */
124209 WhereLevel *pLevel, /* Which loop to provide hints for */
124210 WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
124211 ){
124212 Parse *pParse = pWInfo->pParse;
@@ -123523,11 +124233,46 @@
124233 pWC = &pWInfo->sWC;
124234 for(i=0; i<pWC->nTerm; i++){
124235 pTerm = &pWC->a[i];
124236 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
124237 if( pTerm->prereqAll & pLevel->notReady ) continue;
124238
124239 /* Any terms specified as part of the ON(...) clause for any LEFT
124240 ** JOIN for which the current table is not the rhs are omitted
124241 ** from the cursor-hint.
124242 **
124243 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
124244 ** that were specified as part of the WHERE clause must be excluded.
124245 ** This is to address the following:
124246 **
124247 ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;
124248 **
124249 ** Say there is a single row in t2 that matches (t1.a=t2.b), but its
124250 ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is
124251 ** pushed down to the cursor, this row is filtered out, causing
124252 ** SQLite to synthesize a row of NULL values. Which does match the
124253 ** WHERE clause, and so the query returns a row. Which is incorrect.
124254 **
124255 ** For the same reason, WHERE terms such as:
124256 **
124257 ** WHERE 1 = (t2.c IS NULL)
124258 **
124259 ** are also excluded. See codeCursorHintIsOrFunction() for details.
124260 */
124261 if( pTabItem->fg.jointype & JT_LEFT ){
124262 Expr *pExpr = pTerm->pExpr;
124263 if( !ExprHasProperty(pExpr, EP_FromJoin)
124264 || pExpr->iRightJoinTable!=pTabItem->iCursor
124265 ){
124266 sWalker.eCode = 0;
124267 sWalker.xExprCallback = codeCursorHintIsOrFunction;
124268 sqlite3WalkExpr(&sWalker, pTerm->pExpr);
124269 if( sWalker.eCode ) continue;
124270 }
124271 }else{
124272 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;
124273 }
124274
124275 /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize
124276 ** the cursor. These terms are not needed as hints for a pure range
124277 ** scan (that has no == terms) so omit them. */
124278 if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){
@@ -123557,11 +124302,11 @@
124302 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
124303 (const char*)pExpr, P4_EXPR);
124304 }
124305 }
124306 #else
124307 # define codeCursorHint(A,B,C,D) /* No-op */
124308 #endif /* SQLITE_ENABLE_CURSOR_HINTS */
124309
124310 /*
124311 ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains
124312 ** a rowid value just read from cursor iIdxCur, open on index pIdx. This
@@ -123591,11 +124336,11 @@
124336
124337 assert( iIdxCur>0 );
124338 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
124339
124340 sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
124341 if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
124342 && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
124343 ){
124344 int i;
124345 Table *pTab = pIdx->pTable;
124346 int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
@@ -123646,11 +124391,11 @@
124391 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
124392 iCur = pTabItem->iCursor;
124393 pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
124394 bRev = (pWInfo->revMask>>iLevel)&1;
124395 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
124396 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
124397 VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
124398
124399 /* Create labels for the "break" and "continue" instructions
124400 ** for the current loop. Jump to addrBrk to break out of a loop.
124401 ** Jump to cont to go immediately to the next iteration of the
@@ -123786,12 +124531,11 @@
124531 testcase( pTerm->wtFlags & TERM_VIRTUAL );
124532 iReleaseReg = ++pParse->nMem;
124533 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
124534 if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
124535 addrNxt = pLevel->addrNxt;
124536 sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
 
124537 VdbeCoverage(v);
124538 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
124539 sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
124540 VdbeComment((v, "pk"));
124541 pLevel->op = OP_Noop;
@@ -123814,11 +124558,11 @@
124558 if( bRev ){
124559 pTerm = pStart;
124560 pStart = pEnd;
124561 pEnd = pTerm;
124562 }
124563 codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
124564 if( pStart ){
124565 Expr *pX; /* The expression that defines the start bound */
124566 int r1, rTemp; /* Registers for holding the start boundary */
124567
124568 /* The following constant maps TK_xx codes into corresponding
@@ -124028,11 +124772,11 @@
124772
124773 /* Generate code to evaluate all constraint terms using == or IN
124774 ** and store the values of those terms in an array of registers
124775 ** starting at regBase.
124776 */
124777 codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124778 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124779 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124780 if( zStartAff ) cEndAff = zStartAff[nEq];
124781 addrNxt = pLevel->addrNxt;
124782
@@ -124067,10 +124811,11 @@
124811 zStartAff[nEq] = SQLITE_AFF_BLOB;
124812 }
124813 }
124814 nConstraint++;
124815 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
124816 bSeekPastNull = 0;
124817 }else if( bSeekPastNull ){
124818 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124819 nConstraint++;
124820 startEq = 0;
124821 start_constraints = 1;
@@ -124332,15 +125077,11 @@
125077
125078 /* Run a separate WHERE clause for each term of the OR clause. After
125079 ** eliminating duplicates from other WHERE clauses, the action for each
125080 ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
125081 */
125082 wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
 
 
 
 
125083 for(ii=0; ii<pOrWc->nTerm; ii++){
125084 WhereTerm *pOrTerm = &pOrWc->a[ii];
125085 if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
125086 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
125087 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
@@ -124444,11 +125185,10 @@
125185 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
125186 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))
125187 ){
125188 assert( pSubWInfo->a[0].iIdxCur==iCovCur );
125189 pCov = pSubLoop->u.btree.pIndex;
 
125190 }else{
125191 pCov = 0;
125192 }
125193
125194 /* Finish the loop through table entries that match term pOrTerm. */
@@ -124481,11 +125221,11 @@
125221 if( pTabItem->fg.isRecursive ){
125222 /* Tables marked isRecursive have only a single row that is stored in
125223 ** a pseudo-cursor. No need to Rewind or Next such cursors. */
125224 pLevel->op = OP_Noop;
125225 }else{
125226 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
125227 pLevel->op = aStep[bRev];
125228 pLevel->p1 = iCur;
125229 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
125230 VdbeCoverageIf(v, bRev==0);
125231 VdbeCoverageIf(v, bRev!=0);
@@ -124506,11 +125246,11 @@
125246 testcase( pTerm->wtFlags & TERM_VIRTUAL );
125247 testcase( pTerm->wtFlags & TERM_CODED );
125248 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
125249 if( (pTerm->prereqAll & pLevel->notReady)!=0 ){
125250 testcase( pWInfo->untestedTerms==0
125251 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
125252 pWInfo->untestedTerms = 1;
125253 continue;
125254 }
125255 pE = pTerm->pExpr;
125256 assert( pE!=0 );
@@ -125168,11 +125908,13 @@
125908 sqlite3WhereExprAnalyze(pSrc, pAndWC);
125909 pAndWC->pOuter = pWC;
125910 if( !db->mallocFailed ){
125911 for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
125912 assert( pAndTerm->pExpr );
125913 if( allowedOp(pAndTerm->pExpr->op)
125914 || pAndTerm->eOperator==WO_MATCH
125915 ){
125916 b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);
125917 }
125918 }
125919 }
125920 indexable &= b;
@@ -125383,16 +126125,14 @@
126125 return 0;
126126 }
126127 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);
126128 if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1;
126129 pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
126130 zColl1 = pColl ? pColl->zName : 0;
 
 
126131 pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight);
126132 zColl2 = pColl ? pColl->zName : 0;
126133 return sqlite3_stricmp(zColl1, zColl2)==0;
126134 }
126135
126136 /*
126137 ** Recursively walk the expressions of a SELECT statement and generate
126138 ** a bitmask indicating which tables are used in that expression
@@ -125722,11 +126462,11 @@
126462 ** current expression is of the form: column MATCH expr.
126463 ** This information is used by the xBestIndex methods of
126464 ** virtual tables. The native query optimizer does not attempt
126465 ** to do anything with MATCH functions.
126466 */
126467 if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){
126468 int idxNew;
126469 Expr *pRight, *pLeft;
126470 WhereTerm *pNewTerm;
126471 Bitmask prereqColumn, prereqExpr;
126472
@@ -126014,10 +126754,22 @@
126754 ** Return FALSE if the output needs to be sorted.
126755 */
126756 SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){
126757 return pWInfo->nOBSat;
126758 }
126759
126760 /*
126761 ** Return TRUE if the innermost loop of the WHERE clause implementation
126762 ** returns rows in ORDER BY order for complete run of the inner loop.
126763 **
126764 ** Across multiple iterations of outer loops, the output rows need not be
126765 ** sorted. As long as rows are sorted for just the innermost loop, this
126766 ** routine can return TRUE.
126767 */
126768 SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){
126769 return pWInfo->bOrderedInnerLoop;
126770 }
126771
126772 /*
126773 ** Return the VDBE address or label to jump to in order to continue
126774 ** immediately with the next row of a WHERE clause.
126775 */
@@ -127600,20 +128352,42 @@
128352 static void whereTermPrint(WhereTerm *pTerm, int iTerm){
128353 if( pTerm==0 ){
128354 sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm);
128355 }else{
128356 char zType[4];
128357 char zLeft[50];
128358 memcpy(zType, "...", 4);
128359 if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';
128360 if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
128361 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
128362 if( pTerm->eOperator & WO_SINGLE ){
128363 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
128364 pTerm->leftCursor, pTerm->u.leftColumn);
128365 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
128366 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
128367 pTerm->u.pOrInfo->indexable);
128368 }else{
128369 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128370 }
128371 sqlite3DebugPrintf(
128372 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
128373 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
128374 pTerm->eOperator, pTerm->wtFlags);
128375 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
128376 }
128377 }
128378 #endif
128379
128380 #ifdef WHERETRACE_ENABLED
128381 /*
128382 ** Show the complete content of a WhereClause
128383 */
128384 SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){
128385 int i;
128386 for(i=0; i<pWC->nTerm; i++){
128387 whereTermPrint(&pWC->a[i], i);
128388 }
128389 }
128390 #endif
128391
128392 #ifdef WHERETRACE_ENABLED
128393 /*
@@ -128599,11 +129373,11 @@
129373 rLogSize = estLog(rSize);
129374
129375 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
129376 /* Automatic indexes */
129377 if( !pBuilder->pOrSet /* Not part of an OR optimization */
129378 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
129379 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
129380 && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */
129381 && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
129382 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
129383 && !pSrc->fg.isCorrelated /* Not a correlated subquery */
@@ -128631,10 +129405,11 @@
129405 pNew->rSetup = rLogSize + rSize + 4;
129406 if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){
129407 pNew->rSetup += 24;
129408 }
129409 ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
129410 if( pNew->rSetup<0 ) pNew->rSetup = 0;
129411 /* TUNING: Each index lookup yields 20 rows in the table. This
129412 ** is more than the usual guess of 10 rows, since we have no way
129413 ** of knowing how selective the index will ultimately be. It would
129414 ** not be unreasonable to make this value much larger. */
129415 pNew->nOut = 43; assert( 43==sqlite3LogEst(20) );
@@ -128691,10 +129466,11 @@
129466 }
129467
129468 /* Full scan via index */
129469 if( b
129470 || !HasRowid(pTab)
129471 || pProbe->pPartIdxWhere!=0
129472 || ( m==0
129473 && pProbe->bUnordered==0
129474 && (pProbe->szIdxRow<pTab->szTabRow)
129475 && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
129476 && sqlite3GlobalConfig.bUseCis
@@ -128703,15 +129479,38 @@
129479 ){
129480 pNew->iSortIdx = b ? iSortIdx : 0;
129481
129482 /* The cost of visiting the index rows is N*K, where K is
129483 ** between 1.1 and 3.0, depending on the relative sizes of the
129484 ** index and table rows. */
 
129485 pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;
129486 if( m!=0 ){
129487 /* If this is a non-covering index scan, add in the cost of
129488 ** doing table lookups. The cost will be 3x the number of
129489 ** lookups. Take into account WHERE clause terms that can be
129490 ** satisfied using just the index, and that do not require a
129491 ** table lookup. */
129492 LogEst nLookup = rSize + 16; /* Base cost: N*3 */
129493 int ii;
129494 int iCur = pSrc->iCursor;
129495 WhereClause *pWC2 = &pWInfo->sWC;
129496 for(ii=0; ii<pWC2->nTerm; ii++){
129497 WhereTerm *pTerm = &pWC2->a[ii];
129498 if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){
129499 break;
129500 }
129501 /* pTerm can be evaluated using just the index. So reduce
129502 ** the expected number of table lookups accordingly */
129503 if( pTerm->truthProb<=0 ){
129504 nLookup += pTerm->truthProb;
129505 }else{
129506 nLookup--;
129507 if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19;
129508 }
129509 }
129510
129511 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup);
129512 }
129513 ApplyCostMultiplier(pNew->rRun, pTab->costMult);
129514 whereLoopOutputAdjust(pWC, pNew, rSize);
129515 rc = whereLoopInsert(pBuilder, pNew);
129516 pNew->nOut = rSize;
@@ -129076,13 +129875,11 @@
129875 sCur.n = 0;
129876 #ifdef WHERETRACE_ENABLED
129877 WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
129878 (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
129879 if( sqlite3WhereTrace & 0x400 ){
129880 sqlite3WhereClausePrint(sSubBuild.pWC);
 
 
129881 }
129882 #endif
129883 #ifndef SQLITE_OMIT_VIRTUALTABLE
129884 if( IsVirtual(pItem->pTab) ){
129885 rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
@@ -129171,19 +129968,22 @@
129968 /* This condition is true when pItem is the FROM clause term on the
129969 ** right-hand-side of a LEFT or CROSS JOIN. */
129970 mPrereq = mPrior;
129971 }
129972 priorJointype = pItem->fg.jointype;
129973 #ifndef SQLITE_OMIT_VIRTUALTABLE
129974 if( IsVirtual(pItem->pTab) ){
129975 struct SrcList_item *p;
129976 for(p=&pItem[1]; p<pEnd; p++){
129977 if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){
129978 mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);
129979 }
129980 }
129981 rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);
129982 }else
129983 #endif /* SQLITE_OMIT_VIRTUALTABLE */
129984 {
129985 rc = whereLoopAddBtree(pBuilder, mPrereq);
129986 }
129987 if( rc==SQLITE_OK ){
129988 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
129989 }
@@ -129214,11 +130014,11 @@
130014 */
130015 static i8 wherePathSatisfiesOrderBy(
130016 WhereInfo *pWInfo, /* The WHERE clause */
130017 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
130018 WherePath *pPath, /* The WherePath to check */
130019 u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */
130020 u16 nLoop, /* Number of entries in pPath->aLoop[] */
130021 WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
130022 Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */
130023 ){
130024 u8 revSet; /* True if rev is known */
@@ -129225,10 +130025,11 @@
130025 u8 rev; /* Composite sort order */
130026 u8 revIdx; /* Index sort order */
130027 u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */
130028 u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */
130029 u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
130030 u16 eqOpMask; /* Allowed equality operators */
130031 u16 nKeyCol; /* Number of key columns in pIndex */
130032 u16 nColumn; /* Total number of ordered columns in the index */
130033 u16 nOrderBy; /* Number terms in the ORDER BY clause */
130034 int iLoop; /* Index of WhereLoop in pPath being processed */
130035 int i, j; /* Loop counters */
@@ -129275,13 +130076,20 @@
130076 if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */
130077 isOrderDistinct = 1;
130078 obDone = MASKBIT(nOrderBy)-1;
130079 orderDistinctMask = 0;
130080 ready = 0;
130081 eqOpMask = WO_EQ | WO_IS | WO_ISNULL;
130082 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;
130083 for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){
130084 if( iLoop>0 ) ready |= pLoop->maskSelf;
130085 if( iLoop<nLoop ){
130086 pLoop = pPath->aLoop[iLoop];
130087 if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;
130088 }else{
130089 pLoop = pLast;
130090 }
130091 if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){
130092 if( pLoop->u.vtab.isOrdered ) obSat = obDone;
130093 break;
130094 }
130095 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
@@ -129295,11 +130103,11 @@
130103 if( MASKBIT(i) & obSat ) continue;
130104 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
130105 if( pOBExpr->op!=TK_COLUMN ) continue;
130106 if( pOBExpr->iTable!=iCur ) continue;
130107 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
130108 ~ready, eqOpMask, 0);
130109 if( pTerm==0 ) continue;
130110 if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
130111 const char *z1, *z2;
130112 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
130113 if( !pColl ) pColl = db->pDfltColl;
@@ -129335,14 +130143,16 @@
130143 rev = revSet = 0;
130144 distinctColumns = 0;
130145 for(j=0; j<nColumn; j++){
130146 u8 bOnce; /* True to run the ORDER BY search loop */
130147
130148 /* Skip over == and IS and ISNULL terms.
130149 ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
130150 */
130151 if( j<pLoop->u.btree.nEq
130152 && pLoop->nSkip==0
130153 && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
130154 ){
130155 if( i & WO_ISNULL ){
130156 testcase( isOrderDistinct );
130157 isOrderDistinct = 0;
130158 }
@@ -129862,12 +130672,23 @@
130672 if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
130673 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
130674 }
130675 }else{
130676 pWInfo->nOBSat = pFrom->isOrdered;
 
130677 pWInfo->revMask = pFrom->revLoop;
130678 if( pWInfo->nOBSat<=0 ){
130679 pWInfo->nOBSat = 0;
130680 if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){
130681 Bitmask m = 0;
130682 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
130683 WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);
130684 if( rc==pWInfo->pOrderBy->nExpr ){
130685 pWInfo->bOrderedInnerLoop = 1;
130686 pWInfo->revMask = m;
130687 }
130688 }
130689 }
130690 }
130691 if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
130692 && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
130693 ){
130694 Bitmask revMask = 0;
@@ -129911,11 +130732,11 @@
130732 int j;
130733 Table *pTab;
130734 Index *pIdx;
130735
130736 pWInfo = pBuilder->pWInfo;
130737 if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
130738 assert( pWInfo->pTabList->nSrc>=1 );
130739 pItem = pWInfo->pTabList->a;
130740 pTab = pItem->pTab;
130741 if( IsVirtual(pTab) ) return 0;
130742 if( pItem->fg.isIndexedBy ) return 0;
@@ -130058,11 +130879,11 @@
130879 ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
130880 ** if there is one. If there is no ORDER BY clause or if this routine
130881 ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
130882 **
130883 ** The iIdxCur parameter is the cursor number of an index. If
130884 ** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
130885 ** to use for OR clause processing. The WHERE clause should use this
130886 ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
130887 ** the first cursor in an array of cursors for all indices. iIdxCur should
130888 ** be used to compute the appropriate cursor depending on which index is
130889 ** used.
@@ -130072,11 +130893,11 @@
130893 SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
130894 Expr *pWhere, /* The WHERE clause */
130895 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
130896 ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
130897 u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
130898 int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
130899 ** If WHERE_USE_LIMIT, then the limit amount */
130900 ){
130901 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
130902 int nTabList; /* Number of elements in pTabList */
130903 WhereInfo *pWInfo; /* Will become the return value of this function */
@@ -130091,15 +130912,15 @@
130912 int rc; /* Return code */
130913 u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */
130914
130915 assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (
130916 (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0
130917 && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130918 ));
130919
130920 /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */
130921 assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
130922 || (wctrlFlags & WHERE_USE_LIMIT)==0 );
130923
130924 /* Variable initialization */
130925 db = pParse->db;
130926 memset(&sWLB, 0, sizeof(sWLB));
@@ -130123,15 +130944,15 @@
130944 sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
130945 return 0;
130946 }
130947
130948 /* This function normally generates a nested loop for all tables in
130949 ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should
130950 ** only generate code for the first table in pTabList and assume that
130951 ** any cursors associated with subsequent tables are uninitialized.
130952 */
130953 nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;
130954
130955 /* Allocate and initialize the WhereInfo structure that will become the
130956 ** return value. A single allocation is used to store the WhereInfo
130957 ** struct, the contents of WhereInfo.a[], the WhereClause structure
130958 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
@@ -130203,11 +131024,11 @@
131024 ** important. Ticket #3015.
131025 **
131026 ** Note that bitmasks are created for all pTabList->nSrc tables in
131027 ** pTabList, not just the first nTabList tables. nTabList is normally
131028 ** equal to pTabList->nSrc but might be shortened to 1 if the
131029 ** WHERE_OR_SUBCLAUSE flag is set.
131030 */
131031 for(ii=0; ii<pTabList->nSrc; ii++){
131032 createMask(pMaskSet, pTabList->a[ii].iCursor);
131033 sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
131034 }
@@ -130241,14 +131062,11 @@
131062 sqlite3DebugPrintf(", limit: %d", iAuxArg);
131063 }
131064 sqlite3DebugPrintf(")\n");
131065 }
131066 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
131067 sqlite3WhereClausePrint(sWLB.pWC);
 
 
 
131068 }
131069 #endif
131070
131071 if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
131072 rc = whereLoopAddAll(&sWLB);
@@ -130386,11 +131204,11 @@
131204 }else if( IsVirtual(pTab) ){
131205 /* noop */
131206 }else
131207 #endif
131208 if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
131209 && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
131210 int op = OP_OpenRead;
131211 if( pWInfo->eOnePass!=ONEPASS_OFF ){
131212 op = OP_OpenWrite;
131213 pWInfo->aiCurOnePass[0] = pTabItem->iCursor;
131214 };
@@ -130425,11 +131243,11 @@
131243 int iIndexCur;
131244 int op = OP_OpenRead;
131245 /* iAuxArg is always set if to a positive value if ONEPASS is possible */
131246 assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );
131247 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)
131248 && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0
131249 ){
131250 /* This is one term of an OR-optimization using the PRIMARY KEY of a
131251 ** WITHOUT ROWID table. No need for a separate index */
131252 iIndexCur = pLevel->iTabCur;
131253 op = 0;
@@ -130441,13 +131259,13 @@
131259 iIndexCur++;
131260 pJ = pJ->pNext;
131261 }
131262 op = OP_OpenWrite;
131263 pWInfo->aiCurOnePass[1] = iIndexCur;
131264 }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){
131265 iIndexCur = iAuxArg;
131266 op = OP_ReopenIdx;
131267 }else{
131268 iIndexCur = pParse->nTab++;
131269 }
131270 pLevel->iIdxCur = iIndexCur;
131271 assert( pIx->pSchema==pTab->pSchema );
@@ -130505,11 +131323,11 @@
131323 pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
131324 );
131325 pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
131326 notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
131327 pWInfo->iContinue = pLevel->addrCont;
131328 if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
131329 sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
131330 }
131331 }
131332
131333 /* Done. */
@@ -130628,16 +131446,16 @@
131446 continue;
131447 }
131448
131449 /* Close all of the cursors that were opened by sqlite3WhereBegin.
131450 ** Except, do not close cursors that will be reused by the OR optimization
131451 ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
131452 ** created for the ONEPASS optimization.
131453 */
131454 if( (pTab->tabFlags & TF_Ephemeral)==0
131455 && pTab->pSelect==0
131456 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
131457 ){
131458 int ws = pLoop->wsFlags;
131459 if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
131460 sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
131461 }
@@ -130980,49 +131798,49 @@
131798 #ifndef INTERFACE
131799 # define INTERFACE 1
131800 #endif
131801 /************* Begin control #defines *****************************************/
131802 #define YYCODETYPE unsigned char
131803 #define YYNOCODE 252
131804 #define YYACTIONTYPE unsigned short int
131805 #define YYWILDCARD 96
131806 #define sqlite3ParserTOKENTYPE Token
131807 typedef union {
131808 int yyinit;
131809 sqlite3ParserTOKENTYPE yy0;
131810 Expr* yy72;
131811 TriggerStep* yy145;
131812 ExprList* yy148;
131813 SrcList* yy185;
131814 ExprSpan yy190;
131815 int yy194;
131816 Select* yy243;
131817 IdList* yy254;
131818 With* yy285;
131819 struct TrigEvent yy332;
131820 struct LimitVal yy354;
131821 struct LikeOp yy392;
131822 struct {int value; int mask;} yy497;
131823 } YYMINORTYPE;
131824 #ifndef YYSTACKDEPTH
131825 #define YYSTACKDEPTH 100
131826 #endif
131827 #define sqlite3ParserARG_SDECL Parse *pParse;
131828 #define sqlite3ParserARG_PDECL ,Parse *pParse
131829 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131830 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
131831 #define YYFALLBACK 1
131832 #define YYNSTATE 443
131833 #define YYNRULE 328
131834 #define YY_MAX_SHIFT 442
131835 #define YY_MIN_SHIFTREDUCE 653
131836 #define YY_MAX_SHIFTREDUCE 980
131837 #define YY_MIN_REDUCE 981
131838 #define YY_MAX_REDUCE 1308
131839 #define YY_ERROR_ACTION 1309
131840 #define YY_ACCEPT_ACTION 1310
131841 #define YY_NO_ACTION 1311
131842 /************* End control #defines *******************************************/
131843
131844 /* Define the yytestcase() macro to be a no-op if is not already defined
131845 ** otherwise.
131846 **
@@ -131086,450 +131904,452 @@
131904 ** yy_reduce_ofst[] For each state, the offset into yy_action for
131905 ** shifting non-terminals after a reduce.
131906 ** yy_default[] Default action for each state.
131907 **
131908 *********** Begin parsing tables **********************************************/
131909 #define YY_ACTTAB_COUNT (1507)
131910 static const YYACTIONTYPE yy_action[] = {
131911 /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131912 /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131913 /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131914 /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131915 /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131916 /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131917 /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131918 /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131919 /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131920 /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131921 /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131922 /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131923 /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131924 /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131925 /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131926 /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131927 /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131928 /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131929 /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131930 /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131931 /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131932 /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131933 /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131934 /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131935 /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131936 /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131937 /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131938 /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131939 /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131940 /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131941 /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131942 /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131943 /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131944 /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131945 /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131946 /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131947 /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131948 /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131949 /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131950 /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131951 /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131952 /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131953 /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131954 /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131955 /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131956 /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131957 /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131958 /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131959 /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131960 /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131961 /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131962 /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131963 /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131964 /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131965 /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131966 /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131967 /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131968 /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131969 /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131970 /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131971 /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131972 /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131973 /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131974 /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131975 /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131976 /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131977 /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131978 /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131979 /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
131980 /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
131981 /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
131982 /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
131983 /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
131984 /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
131985 /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
131986 /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
131987 /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
131988 /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
131989 /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
131990 /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
131991 /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
131992 /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131993 /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
131994 /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
131995 /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
131996 /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
131997 /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
131998 /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
131999 /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
132000 /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
132001 /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
132002 /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
132003 /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
132004 /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
132005 /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
132006 /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
132007 /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
132008 /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
132009 /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
132010 /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
132011 /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
132012 /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
132013 /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
132014 /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
132015 /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
132016 /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
132017 /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
132018 /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
132019 /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
132020 /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
132021 /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
132022 /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
132023 /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
132024 /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
132025 /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
132026 /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
132027 /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
132028 /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
132029 /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
132030 /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
132031 /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
132032 /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
132033 /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
132034 /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
132035 /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
132036 /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
132037 /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
132038 /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
132039 /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
132040 /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
132041 /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
132042 /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
132043 /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
132044 /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
132045 /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
132046 /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
132047 /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
132048 /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
132049 /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
132050 /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
132051 /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
132052 /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
132053 /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
132054 /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
132055 /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
132056 /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
132057 /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
132058 /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
132059 /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
132060 /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
132061 /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
132062 };
132063 static const YYCODETYPE yy_lookahead[] = {
132064 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
132065 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132066 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
132067 /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
132068 /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
132069 /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43,
132070 /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
132071 /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
132072 /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
132073 /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132074 /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
132075 /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
132076 /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
132077 /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
132078 /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
132079 /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
132080 /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
132081 /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
132082 /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132083 /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
132084 /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132085 /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132086 /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
132087 /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
132088 /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
132089 /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132090 /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
132091 /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132092 /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
132093 /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
132094 /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
132095 /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
132096 /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132097 /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
132098 /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132099 /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
132100 /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
132101 /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
132102 /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
132103 /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132104 /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
132105 /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132106 /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132107 /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
132108 /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
132109 /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
132110 /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
132111 /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
132112 /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
132113 /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132114 /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
132115 /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
132116 /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
132117 /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
132118 /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
132119 /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
132120 /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132121 /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
132122 /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
132123 /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
132124 /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
132125 /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
132126 /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
132127 /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
132128 /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
132129 /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
132130 /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
132131 /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
132132 /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
132133 /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
132134 /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
132135 /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
132136 /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
132137 /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
132138 /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
132139 /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
132140 /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
132141 /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
132142 /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
132143 /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
132144 /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
132145 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
132146 /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
132147 /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
132148 /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
132149 /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
132150 /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
132151 /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
132152 /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
132153 /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
132154 /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
132155 /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
132156 /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
132157 /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
132158 /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
132159 /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
132160 /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
132161 /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
132162 /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
132163 /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
132164 /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
132165 /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
132166 /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
132167 /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
132168 /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
132169 /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
132170 /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
132171 /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
132172 /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
132173 /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
132174 /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
132175 /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
132176 /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
132177 /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
132178 /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
132179 /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
132180 /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
132181 /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
132182 /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
132183 /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
132184 /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
132185 /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
132186 /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
132187 /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
132188 /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
132189 /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
132190 /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
132191 /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
132192 /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
132193 /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
132194 /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
132195 /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
132196 /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
132197 /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
132198 /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
132199 /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
132200 /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
132201 /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
132202 /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
132203 /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
132204 /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
132205 /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
132206 /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
132207 /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
132208 /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
132209 /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
132210 /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
132211 /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
132212 /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
132213 /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
132214 /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
132215 };
132216 #define YY_SHIFT_USE_DFLT (-95)
132217 #define YY_SHIFT_COUNT (442)
132218 #define YY_SHIFT_MIN (-94)
132219 #define YY_SHIFT_MAX (1491)
132220 static const short yy_shift_ofst[] = {
132221 /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132222 /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132223 /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132224 /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132225 /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132226 /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
132227 /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132228 /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132229 /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132230 /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132231 /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132232 /* 110 */ 837, 837, 924, 73, 183, -51, -95, -95, -95, 501,
132233 /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132234 /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132235 /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132236 /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, -95, -95,
132237 /* 160 */ -95, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132238 /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132239 /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132240 /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132241 /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132242 /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132243 /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132244 /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132245 /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132246 /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132247 /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132248 /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132249 /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132250 /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132251 /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, -95,
132252 /* 310 */ -95, -95, -95, -95, -95, -95, -95, 451, 936, 816,
132253 /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132254 /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132255 /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132256 /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132257 /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132258 /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132259 /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132260 /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132261 /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132262 /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132263 /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132264 /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132265 /* 440 */ 1482, 1491, 1490,
132266 };
132267 #define YY_REDUCE_USE_DFLT (-130)
132268 #define YY_REDUCE_COUNT (316)
132269 #define YY_REDUCE_MIN (-129)
132270 #define YY_REDUCE_MAX (1243)
132271 static const short yy_reduce_ofst[] = {
132272 /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132273 /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132274 /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
132275 /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132276 /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132277 /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132278 /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132279 /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132280 /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132281 /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132282 /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132283 /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132284 /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132285 /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132286 /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132287 /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132288 /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132289 /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132290 /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132291 /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132292 /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132293 /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132294 /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132295 /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132296 /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132297 /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132298 /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132299 /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132300 /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132301 /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132302 /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132303 /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
132304 };
132305 static const YYACTIONTYPE yy_default[] = {
132306 /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132307 /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132308 /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132309 /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132310 /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132311 /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132312 /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132313 /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132314 /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132315 /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132316 /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132317 /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132318 /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132319 /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132320 /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132321 /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132322 /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132323 /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132324 /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132325 /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132326 /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132327 /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132328 /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132329 /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132330 /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132331 /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132332 /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132333 /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132334 /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132335 /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132336 /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132337 /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132338 /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132339 /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132340 /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132341 /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132342 /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132343 /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132344 /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132345 /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132346 /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132347 /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132348 /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132349 /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132350 /* 440 */ 1309, 991, 1309,
132351 };
132352 /********** End of lemon-generated parsing tables *****************************/
132353
132354 /* The next table maps tokens (terminal symbols) into fallback tokens.
132355 ** If a construct like the following:
@@ -131672,21 +132492,22 @@
132492 typedef struct yyStackEntry yyStackEntry;
132493
132494 /* The state of the parser is completely contained in an instance of
132495 ** the following structure */
132496 struct yyParser {
132497 yyStackEntry *yytos; /* Pointer to top element of the stack */
132498 #ifdef YYTRACKMAXSTACKDEPTH
132499 int yyhwm; /* High-water mark of the stack */
132500 #endif
132501 #ifndef YYNOERRORRECOVERY
132502 int yyerrcnt; /* Shifts left before out of the error */
132503 #endif
132504 sqlite3ParserARG_SDECL /* A place to hold %extra_argument */
132505 #if YYSTACKDEPTH<=0
132506 int yystksz; /* Current side of the stack */
132507 yyStackEntry *yystack; /* The parser's stack */
132508 yyStackEntry yystk0; /* First stack entry */
132509 #else
132510 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
132511 #endif
132512 };
132513 typedef struct yyParser yyParser;
@@ -131781,17 +132602,17 @@
132602 "orderby_opt", "limit_opt", "values", "nexprlist",
132603 "exprlist", "sclp", "as", "seltablist",
132604 "stl_prefix", "joinop", "indexed_opt", "on_opt",
132605 "using_opt", "idlist", "setlist", "insert_cmd",
132606 "idlist_opt", "likeop", "between_op", "in_op",
132607 "paren_exprlist", "case_operand", "case_exprlist", "case_else",
132608 "uniqueflag", "collate", "nmnum", "trigger_decl",
132609 "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause",
132610 "when_clause", "trigger_cmd", "trnm", "tridxby",
132611 "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt",
132612 "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken",
132613 "lp", "anylist", "wqlist",
132614 };
132615 #endif /* NDEBUG */
132616
132617 #ifndef NDEBUG
132618 /* For tracing reduce actions, the names of all rules are required.
@@ -131985,11 +132806,11 @@
132806 /* 185 */ "in_op ::= IN",
132807 /* 186 */ "in_op ::= NOT IN",
132808 /* 187 */ "expr ::= expr in_op LP exprlist RP",
132809 /* 188 */ "expr ::= LP select RP",
132810 /* 189 */ "expr ::= expr in_op LP select RP",
132811 /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
132812 /* 191 */ "expr ::= EXISTS LP select RP",
132813 /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
132814 /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
132815 /* 194 */ "case_exprlist ::= WHEN expr THEN expr",
132816 /* 195 */ "case_else ::= ELSE expr",
@@ -131997,158 +132818,170 @@
132818 /* 197 */ "case_operand ::= expr",
132819 /* 198 */ "case_operand ::=",
132820 /* 199 */ "exprlist ::=",
132821 /* 200 */ "nexprlist ::= nexprlist COMMA expr",
132822 /* 201 */ "nexprlist ::= expr",
132823 /* 202 */ "paren_exprlist ::=",
132824 /* 203 */ "paren_exprlist ::= LP exprlist RP",
132825 /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132826 /* 205 */ "uniqueflag ::= UNIQUE",
132827 /* 206 */ "uniqueflag ::=",
132828 /* 207 */ "eidlist_opt ::=",
132829 /* 208 */ "eidlist_opt ::= LP eidlist RP",
132830 /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132831 /* 210 */ "eidlist ::= nm collate sortorder",
132832 /* 211 */ "collate ::=",
132833 /* 212 */ "collate ::= COLLATE ID|STRING",
132834 /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132835 /* 214 */ "cmd ::= VACUUM",
132836 /* 215 */ "cmd ::= VACUUM nm",
132837 /* 216 */ "cmd ::= PRAGMA nm dbnm",
132838 /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132839 /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132840 /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132841 /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132842 /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132843 /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132844 /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132845 /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132846 /* 225 */ "trigger_time ::= BEFORE",
132847 /* 226 */ "trigger_time ::= AFTER",
132848 /* 227 */ "trigger_time ::= INSTEAD OF",
132849 /* 228 */ "trigger_time ::=",
132850 /* 229 */ "trigger_event ::= DELETE|INSERT",
132851 /* 230 */ "trigger_event ::= UPDATE",
132852 /* 231 */ "trigger_event ::= UPDATE OF idlist",
132853 /* 232 */ "when_clause ::=",
132854 /* 233 */ "when_clause ::= WHEN expr",
132855 /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132856 /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132857 /* 236 */ "trnm ::= nm DOT nm",
132858 /* 237 */ "tridxby ::= INDEXED BY nm",
132859 /* 238 */ "tridxby ::= NOT INDEXED",
132860 /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132861 /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132862 /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132863 /* 242 */ "trigger_cmd ::= select",
132864 /* 243 */ "expr ::= RAISE LP IGNORE RP",
132865 /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132866 /* 245 */ "raisetype ::= ROLLBACK",
132867 /* 246 */ "raisetype ::= ABORT",
132868 /* 247 */ "raisetype ::= FAIL",
132869 /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132870 /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132871 /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132872 /* 251 */ "key_opt ::=",
132873 /* 252 */ "key_opt ::= KEY expr",
132874 /* 253 */ "cmd ::= REINDEX",
132875 /* 254 */ "cmd ::= REINDEX nm dbnm",
132876 /* 255 */ "cmd ::= ANALYZE",
132877 /* 256 */ "cmd ::= ANALYZE nm dbnm",
132878 /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132879 /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132880 /* 259 */ "add_column_fullname ::= fullname",
132881 /* 260 */ "cmd ::= create_vtab",
132882 /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132883 /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132884 /* 263 */ "vtabarg ::=",
132885 /* 264 */ "vtabargtoken ::= ANY",
132886 /* 265 */ "vtabargtoken ::= lp anylist RP",
132887 /* 266 */ "lp ::= LP",
132888 /* 267 */ "with ::=",
132889 /* 268 */ "with ::= WITH wqlist",
132890 /* 269 */ "with ::= WITH RECURSIVE wqlist",
132891 /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132892 /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132893 /* 272 */ "input ::= cmdlist",
132894 /* 273 */ "cmdlist ::= cmdlist ecmd",
132895 /* 274 */ "cmdlist ::= ecmd",
132896 /* 275 */ "ecmd ::= SEMI",
132897 /* 276 */ "ecmd ::= explain cmdx SEMI",
132898 /* 277 */ "explain ::=",
132899 /* 278 */ "trans_opt ::=",
132900 /* 279 */ "trans_opt ::= TRANSACTION",
132901 /* 280 */ "trans_opt ::= TRANSACTION nm",
132902 /* 281 */ "savepoint_opt ::= SAVEPOINT",
132903 /* 282 */ "savepoint_opt ::=",
132904 /* 283 */ "cmd ::= create_table create_table_args",
132905 /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132906 /* 285 */ "columnlist ::= columnname carglist",
132907 /* 286 */ "nm ::= ID|INDEXED",
132908 /* 287 */ "nm ::= STRING",
132909 /* 288 */ "nm ::= JOIN_KW",
132910 /* 289 */ "typetoken ::= typename",
132911 /* 290 */ "typename ::= ID|STRING",
132912 /* 291 */ "signed ::= plus_num",
132913 /* 292 */ "signed ::= minus_num",
132914 /* 293 */ "carglist ::= carglist ccons",
132915 /* 294 */ "carglist ::=",
132916 /* 295 */ "ccons ::= NULL onconf",
132917 /* 296 */ "conslist_opt ::= COMMA conslist",
132918 /* 297 */ "conslist ::= conslist tconscomma tcons",
132919 /* 298 */ "conslist ::= tcons",
132920 /* 299 */ "tconscomma ::=",
132921 /* 300 */ "defer_subclause_opt ::= defer_subclause",
132922 /* 301 */ "resolvetype ::= raisetype",
132923 /* 302 */ "selectnowith ::= oneselect",
132924 /* 303 */ "oneselect ::= values",
132925 /* 304 */ "sclp ::= selcollist COMMA",
132926 /* 305 */ "as ::= ID|STRING",
132927 /* 306 */ "expr ::= term",
132928 /* 307 */ "exprlist ::= nexprlist",
132929 /* 308 */ "nmnum ::= plus_num",
132930 /* 309 */ "nmnum ::= nm",
132931 /* 310 */ "nmnum ::= ON",
132932 /* 311 */ "nmnum ::= DELETE",
132933 /* 312 */ "nmnum ::= DEFAULT",
132934 /* 313 */ "plus_num ::= INTEGER|FLOAT",
132935 /* 314 */ "foreach_clause ::=",
132936 /* 315 */ "foreach_clause ::= FOR EACH ROW",
132937 /* 316 */ "trnm ::= nm",
132938 /* 317 */ "tridxby ::=",
132939 /* 318 */ "database_kw_opt ::= DATABASE",
132940 /* 319 */ "database_kw_opt ::=",
132941 /* 320 */ "kwcolumn_opt ::=",
132942 /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132943 /* 322 */ "vtabarglist ::= vtabarg",
132944 /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132945 /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132946 /* 325 */ "anylist ::=",
132947 /* 326 */ "anylist ::= anylist LP anylist RP",
132948 /* 327 */ "anylist ::= anylist ANY",
132949 };
132950 #endif /* NDEBUG */
132951
132952
132953 #if YYSTACKDEPTH<=0
132954 /*
132955 ** Try to increase the size of the parser stack. Return the number
132956 ** of errors. Return 0 on success.
132957 */
132958 static int yyGrowStack(yyParser *p){
132959 int newSize;
132960 int idx;
132961 yyStackEntry *pNew;
132962
132963 newSize = p->yystksz*2 + 100;
132964 idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
132965 if( p->yystack==&p->yystk0 ){
132966 pNew = malloc(newSize*sizeof(pNew[0]));
132967 if( pNew ) pNew[0] = p->yystk0;
132968 }else{
132969 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
132970 }
132971 if( pNew ){
132972 p->yystack = pNew;
132973 p->yytos = &p->yystack[idx];
132974 #ifndef NDEBUG
132975 if( yyTraceFILE ){
132976 fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
132977 yyTracePrompt, p->yystksz, newSize);
132978 }
132979 #endif
132980 p->yystksz = newSize;
132981 }
132982 return pNew==0;
132983 }
132984 #endif
132985
132986 /* Datatype of the argument to the memory allocated passed as the
132987 ** second argument to sqlite3ParserAlloc() below. This can be changed by
@@ -132173,19 +133006,28 @@
133006 */
133007 SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
133008 yyParser *pParser;
133009 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
133010 if( pParser ){
 
133011 #ifdef YYTRACKMAXSTACKDEPTH
133012 pParser->yyhwm = 0;
133013 #endif
133014 #if YYSTACKDEPTH<=0
133015 pParser->yytos = NULL;
133016 pParser->yystack = NULL;
133017 pParser->yystksz = 0;
133018 if( yyGrowStack(pParser) ){
133019 pParser->yystack = &pParser->yystk0;
133020 pParser->yystksz = 1;
133021 }
133022 #endif
133023 #ifndef YYNOERRORRECOVERY
133024 pParser->yyerrcnt = -1;
133025 #endif
133026 pParser->yytos = pParser->yystack;
133027 pParser->yystack[0].stateno = 0;
133028 pParser->yystack[0].major = 0;
133029 }
133030 return pParser;
133031 }
133032
133033 /* The following function deletes the "minor type" or semantic value
@@ -132216,17 +133058,17 @@
133058 case 163: /* select */
133059 case 194: /* selectnowith */
133060 case 195: /* oneselect */
133061 case 206: /* values */
133062 {
133063 sqlite3SelectDelete(pParse->db, (yypminor->yy243));
133064 }
133065 break;
133066 case 172: /* term */
133067 case 173: /* expr */
133068 {
133069 sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);
133070 }
133071 break;
133072 case 177: /* eidlist_opt */
133073 case 186: /* sortlist */
133074 case 187: /* eidlist */
@@ -132235,56 +133077,57 @@
133077 case 204: /* orderby_opt */
133078 case 207: /* nexprlist */
133079 case 208: /* exprlist */
133080 case 209: /* sclp */
133081 case 218: /* setlist */
133082 case 224: /* paren_exprlist */
133083 case 226: /* case_exprlist */
133084 {
133085 sqlite3ExprListDelete(pParse->db, (yypminor->yy148));
133086 }
133087 break;
133088 case 193: /* fullname */
133089 case 200: /* from */
133090 case 211: /* seltablist */
133091 case 212: /* stl_prefix */
133092 {
133093 sqlite3SrcListDelete(pParse->db, (yypminor->yy185));
133094 }
133095 break;
133096 case 196: /* with */
133097 case 250: /* wqlist */
133098 {
133099 sqlite3WithDelete(pParse->db, (yypminor->yy285));
133100 }
133101 break;
133102 case 201: /* where_opt */
133103 case 203: /* having_opt */
133104 case 215: /* on_opt */
133105 case 225: /* case_operand */
133106 case 227: /* case_else */
133107 case 236: /* when_clause */
133108 case 241: /* key_opt */
133109 {
133110 sqlite3ExprDelete(pParse->db, (yypminor->yy72));
133111 }
133112 break;
133113 case 216: /* using_opt */
133114 case 217: /* idlist */
133115 case 220: /* idlist_opt */
133116 {
133117 sqlite3IdListDelete(pParse->db, (yypminor->yy254));
133118 }
133119 break;
133120 case 232: /* trigger_cmd_list */
133121 case 237: /* trigger_cmd */
133122 {
133123 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145));
133124 }
133125 break;
133126 case 234: /* trigger_event */
133127 {
133128 sqlite3IdListDelete(pParse->db, (yypminor->yy332).b);
133129 }
133130 break;
133131 /********* End destructor definitions *****************************************/
133132 default: break; /* If no destructor action specified: do nothing */
133133 }
@@ -132296,12 +133139,13 @@
133139 ** If there is a destructor routine associated with the token which
133140 ** is popped from the stack, then call it.
133141 */
133142 static void yy_pop_parser_stack(yyParser *pParser){
133143 yyStackEntry *yytos;
133144 assert( pParser->yytos!=0 );
133145 assert( pParser->yytos > pParser->yystack );
133146 yytos = pParser->yytos--;
133147 #ifndef NDEBUG
133148 if( yyTraceFILE ){
133149 fprintf(yyTraceFILE,"%sPopping %s\n",
133150 yyTracePrompt,
133151 yyTokenName[yytos->major]);
@@ -132324,13 +133168,13 @@
133168 ){
133169 yyParser *pParser = (yyParser*)p;
133170 #ifndef YYPARSEFREENEVERNULL
133171 if( pParser==0 ) return;
133172 #endif
133173 while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
133174 #if YYSTACKDEPTH<=0
133175 if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
133176 #endif
133177 (*freeProc)((void*)pParser);
133178 }
133179
133180 /*
@@ -132337,11 +133181,11 @@
133181 ** Return the peak depth of the stack for a parser.
133182 */
133183 #ifdef YYTRACKMAXSTACKDEPTH
133184 SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){
133185 yyParser *pParser = (yyParser*)p;
133186 return pParser->yyhwm;
133187 }
133188 #endif
133189
133190 /*
133191 ** Find the appropriate action for a parser given the terminal
@@ -132350,11 +133194,11 @@
133194 static unsigned int yy_find_shift_action(
133195 yyParser *pParser, /* The parser */
133196 YYCODETYPE iLookAhead /* The look-ahead token */
133197 ){
133198 int i;
133199 int stateno = pParser->yytos->stateno;
133200
133201 if( stateno>=YY_MIN_REDUCE ) return stateno;
133202 assert( stateno <= YY_SHIFT_COUNT );
133203 do{
133204 i = yy_shift_ofst[stateno];
@@ -132443,17 +133287,17 @@
133287 /*
133288 ** The following routine is called if the stack overflows.
133289 */
133290 static void yyStackOverflow(yyParser *yypParser){
133291 sqlite3ParserARG_FETCH;
133292 yypParser->yytos--;
133293 #ifndef NDEBUG
133294 if( yyTraceFILE ){
133295 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
133296 }
133297 #endif
133298 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
133299 /* Here code is inserted which will execute if the parser
133300 ** stack every overflows */
133301 /******** Begin %stack_overflow code ******************************************/
133302
133303 sqlite3ErrorMsg(pParse, "parser stack overflow");
@@ -132467,15 +133311,15 @@
133311 #ifndef NDEBUG
133312 static void yyTraceShift(yyParser *yypParser, int yyNewState){
133313 if( yyTraceFILE ){
133314 if( yyNewState<YYNSTATE ){
133315 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
133316 yyTracePrompt,yyTokenName[yypParser->yytos->major],
133317 yyNewState);
133318 }else{
133319 fprintf(yyTraceFILE,"%sShift '%s'\n",
133320 yyTracePrompt,yyTokenName[yypParser->yytos->major]);
133321 }
133322 }
133323 }
133324 #else
133325 # define yyTraceShift(X,Y)
@@ -132489,31 +133333,34 @@
133333 int yyNewState, /* The new state to shift in */
133334 int yyMajor, /* The major token to shift in */
133335 sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */
133336 ){
133337 yyStackEntry *yytos;
133338 yypParser->yytos++;
133339 #ifdef YYTRACKMAXSTACKDEPTH
133340 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133341 yypParser->yyhwm++;
133342 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
133343 }
133344 #endif
133345 #if YYSTACKDEPTH>0
133346 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
133347 yyStackOverflow(yypParser);
133348 return;
133349 }
133350 #else
133351 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
133352 if( yyGrowStack(yypParser) ){
 
133353 yyStackOverflow(yypParser);
133354 return;
133355 }
133356 }
133357 #endif
133358 if( yyNewState > YY_MAX_SHIFT ){
133359 yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
133360 }
133361 yytos = yypParser->yytos;
133362 yytos->stateno = (YYACTIONTYPE)yyNewState;
133363 yytos->major = (YYCODETYPE)yyMajor;
133364 yytos->minor.yy0 = yyMinor;
133365 yyTraceShift(yypParser, yyNewState);
133366 }
@@ -132713,31 +133560,33 @@
133560 { 223, 1 },
133561 { 223, 2 },
133562 { 173, 5 },
133563 { 173, 3 },
133564 { 173, 5 },
133565 { 173, 5 },
133566 { 173, 4 },
133567 { 173, 5 },
133568 { 226, 5 },
133569 { 226, 4 },
133570 { 227, 2 },
133571 { 227, 0 },
133572 { 225, 1 },
133573 { 225, 0 },
133574 { 208, 0 },
133575 { 207, 3 },
133576 { 207, 1 },
133577 { 224, 0 },
133578 { 224, 3 },
133579 { 149, 12 },
133580 { 228, 1 },
133581 { 228, 0 },
133582 { 177, 0 },
133583 { 177, 3 },
133584 { 187, 5 },
133585 { 187, 3 },
133586 { 229, 0 },
133587 { 229, 2 },
133588 { 149, 4 },
133589 { 149, 1 },
133590 { 149, 2 },
133591 { 149, 3 },
133592 { 149, 5 },
@@ -132745,58 +133594,58 @@
133594 { 149, 5 },
133595 { 149, 6 },
133596 { 169, 2 },
133597 { 170, 2 },
133598 { 149, 5 },
133599 { 231, 11 },
 
 
 
 
133600 { 233, 1 },
133601 { 233, 1 },
133602 { 233, 2 },
133603 { 233, 0 },
133604 { 234, 1 },
133605 { 234, 1 },
133606 { 234, 3 },
133607 { 236, 0 },
133608 { 236, 2 },
133609 { 232, 3 },
133610 { 232, 2 },
133611 { 238, 3 },
133612 { 239, 3 },
133613 { 239, 2 },
133614 { 237, 7 },
133615 { 237, 5 },
133616 { 237, 5 },
133617 { 237, 1 },
133618 { 173, 4 },
133619 { 173, 6 },
133620 { 191, 1 },
133621 { 191, 1 },
133622 { 191, 1 },
133623 { 149, 4 },
133624 { 149, 6 },
133625 { 149, 3 },
133626 { 241, 0 },
133627 { 241, 2 },
133628 { 149, 1 },
133629 { 149, 3 },
133630 { 149, 1 },
133631 { 149, 3 },
133632 { 149, 6 },
133633 { 149, 7 },
133634 { 242, 1 },
133635 { 149, 1 },
133636 { 149, 4 },
133637 { 244, 8 },
133638 { 246, 0 },
 
 
133639 { 247, 1 },
133640 { 247, 3 },
133641 { 248, 1 },
133642 { 196, 0 },
133643 { 196, 2 },
133644 { 196, 3 },
133645 { 250, 6 },
133646 { 250, 8 },
133647 { 144, 1 },
133648 { 145, 2 },
133649 { 145, 1 },
133650 { 146, 1 },
133651 { 146, 3 },
@@ -132829,30 +133678,30 @@
133678 { 195, 1 },
133679 { 209, 2 },
133680 { 210, 1 },
133681 { 173, 1 },
133682 { 208, 1 },
133683 { 230, 1 },
133684 { 230, 1 },
133685 { 230, 1 },
133686 { 230, 1 },
133687 { 230, 1 },
133688 { 169, 1 },
133689 { 235, 0 },
133690 { 235, 3 },
133691 { 238, 1 },
 
 
133692 { 239, 0 },
133693 { 240, 1 },
133694 { 240, 0 },
133695 { 243, 0 },
133696 { 243, 1 },
133697 { 245, 1 },
133698 { 245, 3 },
133699 { 246, 2 },
133700 { 249, 0 },
133701 { 249, 4 },
133702 { 249, 2 },
133703 };
133704
133705 static void yy_accept(yyParser*); /* Forward Declaration */
133706
133707 /*
@@ -132866,11 +133715,11 @@
133715 int yygoto; /* The next state */
133716 int yyact; /* The next action */
133717 yyStackEntry *yymsp; /* The top of the parser's stack */
133718 int yysize; /* Amount to pop the stack */
133719 sqlite3ParserARG_FETCH;
133720 yymsp = yypParser->yytos;
133721 #ifndef NDEBUG
133722 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
133723 yysize = yyRuleInfo[yyruleno].nrhs;
133724 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
133725 yyRuleName[yyruleno], yymsp[-yysize].stateno);
@@ -132880,26 +133729,27 @@
133729 /* Check that the stack is large enough to grow by a single entry
133730 ** if the RHS of the rule is empty. This ensures that there is room
133731 ** enough on the stack to push the LHS value */
133732 if( yyRuleInfo[yyruleno].nrhs==0 ){
133733 #ifdef YYTRACKMAXSTACKDEPTH
133734 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
133735 yypParser->yyhwm++;
133736 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
133737 }
133738 #endif
133739 #if YYSTACKDEPTH>0
133740 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
133741 yyStackOverflow(yypParser);
133742 return;
133743 }
133744 #else
133745 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
133746 if( yyGrowStack(yypParser) ){
 
133747 yyStackOverflow(yypParser);
133748 return;
133749 }
133750 yymsp = yypParser->yytos;
133751 }
133752 #endif
133753 }
133754
133755 switch( yyruleno ){
@@ -132921,19 +133771,19 @@
133771 break;
133772 case 2: /* cmdx ::= cmd */
133773 { sqlite3FinishCoding(pParse); }
133774 break;
133775 case 3: /* cmd ::= BEGIN transtype trans_opt */
133776 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);}
133777 break;
133778 case 4: /* transtype ::= */
133779 {yymsp[1].minor.yy194 = TK_DEFERRED;}
133780 break;
133781 case 5: /* transtype ::= DEFERRED */
133782 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
133783 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
133784 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
133785 break;
133786 case 8: /* cmd ::= COMMIT trans_opt */
133787 case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
133788 {sqlite3CommitTransaction(pParse);}
133789 break;
@@ -132955,11 +133805,11 @@
133805 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
133806 }
133807 break;
133808 case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
133809 {
133810 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
133811 }
133812 break;
133813 case 15: /* createkw ::= CREATE */
133814 {disableLookaside(pParse);}
133815 break;
@@ -132969,37 +133819,37 @@
133819 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
133820 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
133821 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
133822 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
133823 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
133824 case 211: /* collate ::= */ yytestcase(yyruleno==211);
133825 {yymsp[1].minor.yy194 = 0;}
133826 break;
133827 case 17: /* ifnotexists ::= IF NOT EXISTS */
133828 {yymsp[-2].minor.yy194 = 1;}
133829 break;
133830 case 18: /* temp ::= TEMP */
133831 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
133832 {yymsp[0].minor.yy194 = 1;}
133833 break;
133834 case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
133835 {
133836 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
133837 }
133838 break;
133839 case 21: /* create_table_args ::= AS select */
133840 {
133841 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
133842 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
133843 }
133844 break;
133845 case 23: /* table_options ::= WITHOUT nm */
133846 {
133847 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
133848 yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
133849 }else{
133850 yymsp[-1].minor.yy194 = 0;
133851 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
133852 }
133853 }
133854 break;
133855 case 24: /* columnname ::= nm typetoken */
@@ -133027,21 +133877,21 @@
133877 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
133878 {pParse->constraintName = yymsp[0].minor.yy0;}
133879 break;
133880 case 30: /* ccons ::= DEFAULT term */
133881 case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
133882 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
133883 break;
133884 case 31: /* ccons ::= DEFAULT LP expr RP */
133885 {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
133886 break;
133887 case 33: /* ccons ::= DEFAULT MINUS term */
133888 {
133889 ExprSpan v;
133890 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0, 0);
133891 v.zStart = yymsp[-1].minor.yy0.z;
133892 v.zEnd = yymsp[0].minor.yy190.zEnd;
133893 sqlite3AddDefaultValue(pParse,&v);
133894 }
133895 break;
133896 case 34: /* ccons ::= DEFAULT ID|INDEXED */
133897 {
@@ -133049,184 +133899,186 @@
133899 spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
133900 sqlite3AddDefaultValue(pParse,&v);
133901 }
133902 break;
133903 case 35: /* ccons ::= NOT NULL onconf */
133904 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
133905 break;
133906 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
133907 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
133908 break;
133909 case 37: /* ccons ::= UNIQUE onconf */
133910 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
133911 SQLITE_IDXTYPE_UNIQUE);}
133912 break;
133913 case 38: /* ccons ::= CHECK LP expr RP */
133914 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
133915 break;
133916 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
133917 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
133918 break;
133919 case 40: /* ccons ::= defer_subclause */
133920 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
133921 break;
133922 case 41: /* ccons ::= COLLATE ID|STRING */
133923 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
133924 break;
133925 case 44: /* refargs ::= */
133926 { yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
133927 break;
133928 case 45: /* refargs ::= refargs refarg */
133929 { yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
133930 break;
133931 case 46: /* refarg ::= MATCH nm */
133932 { yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
133933 break;
133934 case 47: /* refarg ::= ON INSERT refact */
133935 { yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
133936 break;
133937 case 48: /* refarg ::= ON DELETE refact */
133938 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
133939 break;
133940 case 49: /* refarg ::= ON UPDATE refact */
133941 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
133942 break;
133943 case 50: /* refact ::= SET NULL */
133944 { yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
133945 break;
133946 case 51: /* refact ::= SET DEFAULT */
133947 { yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
133948 break;
133949 case 52: /* refact ::= CASCADE */
133950 { yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
133951 break;
133952 case 53: /* refact ::= RESTRICT */
133953 { yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
133954 break;
133955 case 54: /* refact ::= NO ACTION */
133956 { yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
133957 break;
133958 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133959 {yymsp[-2].minor.yy194 = 0;}
133960 break;
133961 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133962 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133963 case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133964 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133965 break;
133966 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133967 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133968 case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133969 case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133970 case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
133971 {yymsp[-1].minor.yy194 = 1;}
133972 break;
133973 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133974 {yymsp[-1].minor.yy194 = 0;}
133975 break;
133976 case 61: /* tconscomma ::= COMMA */
133977 {pParse->constraintName.n = 0;}
133978 break;
133979 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
133980 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
133981 break;
133982 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
133983 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
133984 SQLITE_IDXTYPE_UNIQUE);}
133985 break;
133986 case 65: /* tcons ::= CHECK LP expr RP onconf */
133987 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
133988 break;
133989 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
133990 {
133991 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
133992 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
133993 }
133994 break;
133995 case 68: /* onconf ::= */
133996 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
133997 {yymsp[1].minor.yy194 = OE_Default;}
133998 break;
133999 case 69: /* onconf ::= ON CONFLICT resolvetype */
134000 {yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
134001 break;
134002 case 72: /* resolvetype ::= IGNORE */
134003 {yymsp[0].minor.yy194 = OE_Ignore;}
134004 break;
134005 case 73: /* resolvetype ::= REPLACE */
134006 case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
134007 {yymsp[0].minor.yy194 = OE_Replace;}
134008 break;
134009 case 74: /* cmd ::= DROP TABLE ifexists fullname */
134010 {
134011 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
134012 }
134013 break;
134014 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
134015 {
134016 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
134017 }
134018 break;
134019 case 78: /* cmd ::= DROP VIEW ifexists fullname */
134020 {
134021 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
134022 }
134023 break;
134024 case 79: /* cmd ::= select */
134025 {
134026 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
134027 sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
134028 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
134029 }
134030 break;
134031 case 80: /* select ::= with selectnowith */
134032 {
134033 Select *p = yymsp[0].minor.yy243;
134034 if( p ){
134035 p->pWith = yymsp[-1].minor.yy285;
134036 parserDoubleLinkSelect(pParse, p);
134037 }else{
134038 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
134039 }
134040 yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
134041 }
134042 break;
134043 case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
134044 {
134045 Select *pRhs = yymsp[0].minor.yy243;
134046 Select *pLhs = yymsp[-2].minor.yy243;
134047 if( pRhs && pRhs->pPrior ){
134048 SrcList *pFrom;
134049 Token x;
134050 x.n = 0;
134051 parserDoubleLinkSelect(pParse, pRhs);
134052 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
134053 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
134054 }
134055 if( pRhs ){
134056 pRhs->op = (u8)yymsp[-1].minor.yy194;
134057 pRhs->pPrior = pLhs;
134058 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
134059 pRhs->selFlags &= ~SF_MultiValue;
134060 if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1;
134061 }else{
134062 sqlite3SelectDelete(pParse->db, pLhs);
134063 }
134064 yymsp[-2].minor.yy243 = pRhs;
134065 }
134066 break;
134067 case 82: /* multiselect_op ::= UNION */
134068 case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
134069 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
134070 break;
134071 case 83: /* multiselect_op ::= UNION ALL */
134072 {yymsp[-1].minor.yy194 = TK_ALL;}
134073 break;
134074 case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
134075 {
134076 #if SELECTTRACE_ENABLED
134077 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
134078 #endif
134079 yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
134080 #if SELECTTRACE_ENABLED
134081 /* Populate the Select.zSelName[] string that is used to help with
134082 ** query planner debugging, to differentiate between multiple Select
134083 ** objects in a complex query.
134084 **
@@ -133233,464 +134085,465 @@
134085 ** If the SELECT keyword is immediately followed by a C-style comment
134086 ** then extract the first few alphanumeric characters from within that
134087 ** comment to be the zSelName value. Otherwise, the label is #N where
134088 ** is an integer that is incremented with each SELECT statement seen.
134089 */
134090 if( yymsp[-8].minor.yy243!=0 ){
134091 const char *z = s.z+6;
134092 int i;
134093 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "#%d",
134094 ++pParse->nSelect);
134095 while( z[0]==' ' ) z++;
134096 if( z[0]=='/' && z[1]=='*' ){
134097 z += 2;
134098 while( z[0]==' ' ) z++;
134099 for(i=0; sqlite3Isalnum(z[i]); i++){}
134100 sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "%.*s", i, z);
134101 }
134102 }
134103 #endif /* SELECTRACE_ENABLED */
134104 }
134105 break;
134106 case 86: /* values ::= VALUES LP nexprlist RP */
134107 {
134108 yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
134109 }
134110 break;
134111 case 87: /* values ::= values COMMA LP exprlist RP */
134112 {
134113 Select *pRight, *pLeft = yymsp[-4].minor.yy243;
134114 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
134115 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
134116 if( pRight ){
134117 pRight->op = TK_ALL;
134118 pRight->pPrior = pLeft;
134119 yymsp[-4].minor.yy243 = pRight;
134120 }else{
134121 yymsp[-4].minor.yy243 = pLeft;
134122 }
134123 }
134124 break;
134125 case 88: /* distinct ::= DISTINCT */
134126 {yymsp[0].minor.yy194 = SF_Distinct;}
134127 break;
134128 case 89: /* distinct ::= ALL */
134129 {yymsp[0].minor.yy194 = SF_All;}
134130 break;
134131 case 91: /* sclp ::= */
134132 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
134133 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
134134 case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
134135 case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
134136 case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
134137 {yymsp[1].minor.yy148 = 0;}
134138 break;
134139 case 92: /* selcollist ::= sclp expr as */
134140 {
134141 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
134142 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
134143 sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
134144 }
134145 break;
134146 case 93: /* selcollist ::= sclp STAR */
134147 {
134148 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
134149 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
134150 }
134151 break;
134152 case 94: /* selcollist ::= sclp nm DOT STAR */
134153 {
134154 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0);
134155 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134156 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
134157 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
134158 }
134159 break;
134160 case 95: /* as ::= AS nm */
134161 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
134162 case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
134163 case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
134164 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
134165 break;
134166 case 97: /* from ::= */
134167 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
134168 break;
134169 case 98: /* from ::= FROM seltablist */
134170 {
134171 yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
134172 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
134173 }
134174 break;
134175 case 99: /* stl_prefix ::= seltablist joinop */
134176 {
134177 if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
134178 }
134179 break;
134180 case 100: /* stl_prefix ::= */
134181 {yymsp[1].minor.yy185 = 0;}
134182 break;
134183 case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
134184 {
134185 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134186 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
134187 }
134188 break;
134189 case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
134190 {
134191 yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134192 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
134193 }
134194 break;
134195 case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
134196 {
134197 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134198 }
134199 break;
134200 case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
134201 {
134202 if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
134203 yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
134204 }else if( yymsp[-4].minor.yy185->nSrc==1 ){
134205 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134206 if( yymsp[-6].minor.yy185 ){
134207 struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1];
134208 struct SrcList_item *pOld = yymsp[-4].minor.yy185->a;
134209 pNew->zName = pOld->zName;
134210 pNew->zDatabase = pOld->zDatabase;
134211 pNew->pSelect = pOld->pSelect;
134212 pOld->zName = pOld->zDatabase = 0;
134213 pOld->pSelect = 0;
134214 }
134215 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185);
134216 }else{
134217 Select *pSubquery;
134218 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185);
134219 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
134220 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
134221 }
134222 }
134223 break;
134224 case 105: /* dbnm ::= */
134225 case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
134226 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
134227 break;
134228 case 107: /* fullname ::= nm dbnm */
134229 {yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
134230 break;
134231 case 108: /* joinop ::= COMMA|JOIN */
134232 { yymsp[0].minor.yy194 = JT_INNER; }
134233 break;
134234 case 109: /* joinop ::= JOIN_KW JOIN */
134235 {yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
134236 break;
134237 case 110: /* joinop ::= JOIN_KW nm JOIN */
134238 {yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
134239 break;
134240 case 111: /* joinop ::= JOIN_KW nm nm JOIN */
134241 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134242 break;
134243 case 112: /* on_opt ::= ON expr */
134244 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
134245 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
134246 case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
134247 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
134248 break;
134249 case 113: /* on_opt ::= */
134250 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
134251 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
134252 case 196: /* case_else ::= */ yytestcase(yyruleno==196);
134253 case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
134254 {yymsp[1].minor.yy72 = 0;}
134255 break;
134256 case 115: /* indexed_opt ::= INDEXED BY nm */
134257 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
134258 break;
134259 case 116: /* indexed_opt ::= NOT INDEXED */
134260 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
134261 break;
134262 case 117: /* using_opt ::= USING LP idlist RP */
134263 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
134264 break;
134265 case 118: /* using_opt ::= */
134266 case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
134267 {yymsp[1].minor.yy254 = 0;}
134268 break;
134269 case 120: /* orderby_opt ::= ORDER BY sortlist */
134270 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
134271 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
134272 break;
134273 case 121: /* sortlist ::= sortlist COMMA expr sortorder */
134274 {
134275 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
134276 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
134277 }
134278 break;
134279 case 122: /* sortlist ::= expr sortorder */
134280 {
134281 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
134282 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
134283 }
134284 break;
134285 case 123: /* sortorder ::= ASC */
134286 {yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
134287 break;
134288 case 124: /* sortorder ::= DESC */
134289 {yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
134290 break;
134291 case 125: /* sortorder ::= */
134292 {yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
134293 break;
134294 case 130: /* limit_opt ::= */
134295 {yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
134296 break;
134297 case 131: /* limit_opt ::= LIMIT expr */
134298 {yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
134299 break;
134300 case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
134301 {yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
134302 break;
134303 case 133: /* limit_opt ::= LIMIT expr COMMA expr */
134304 {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
134305 break;
134306 case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
134307 {
134308 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134309 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
134310 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
134311 }
134312 break;
134313 case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
134314 {
134315 sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
134316 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
134317 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
134318 sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
134319 }
134320 break;
134321 case 138: /* setlist ::= setlist COMMA nm EQ expr */
134322 {
134323 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134324 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
134325 }
134326 break;
134327 case 139: /* setlist ::= nm EQ expr */
134328 {
134329 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134330 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
134331 }
134332 yymsp[-2].minor.yy148 = yylhsminor.yy148;
134333 break;
134334 case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
134335 {
134336 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134337 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
134338 }
134339 break;
134340 case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
134341 {
134342 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134343 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
134344 }
134345 break;
134346 case 145: /* idlist_opt ::= LP idlist RP */
134347 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
134348 break;
134349 case 146: /* idlist ::= idlist COMMA nm */
134350 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
134351 break;
134352 case 147: /* idlist ::= nm */
134353 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134354 break;
134355 case 148: /* expr ::= LP expr RP */
134356 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
134357 break;
134358 case 149: /* term ::= NULL */
134359 case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
134360 case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
134361 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134362 break;
134363 case 150: /* expr ::= ID|INDEXED */
134364 case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
134365 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134366 break;
134367 case 152: /* expr ::= nm DOT nm */
134368 {
134369 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134370 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134371 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134372 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134373 }
134374 break;
134375 case 153: /* expr ::= nm DOT nm DOT nm */
134376 {
134377 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
134378 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134379 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134380 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
134381 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134382 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134383 }
134384 break;
134385 case 156: /* expr ::= VARIABLE */
134386 {
134387 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
134388 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134389 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
134390 }else{
134391 /* When doing a nested parse, one can include terms in an expression
134392 ** that look like this: #1 #2 ... These terms refer to registers
134393 ** in the virtual machine. #N is the N-th register. */
134394 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
134395 assert( t.n>=2 );
134396 spanSet(&yymsp[0].minor.yy190, &t, &t);
134397 if( pParse->nested==0 ){
134398 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
134399 yymsp[0].minor.yy190.pExpr = 0;
134400 }else{
134401 yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t);
134402 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
134403 }
134404 }
134405 }
134406 break;
134407 case 157: /* expr ::= expr COLLATE ID|STRING */
134408 {
134409 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134410 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134411 }
134412 break;
134413 case 158: /* expr ::= CAST LP expr AS typetoken RP */
134414 {
134415 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134416 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
134417 }
134418 break;
134419 case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
134420 {
134421 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134422 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
134423 }
134424 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
134425 spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
134426 if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){
134427 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
134428 }
134429 }
134430 yymsp[-4].minor.yy190 = yylhsminor.yy190;
134431 break;
134432 case 160: /* expr ::= ID|INDEXED LP STAR RP */
134433 {
134434 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134435 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134436 }
134437 yymsp[-3].minor.yy190 = yylhsminor.yy190;
134438 break;
134439 case 161: /* term ::= CTIME_KW */
134440 {
134441 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134442 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134443 }
134444 yymsp[0].minor.yy190 = yylhsminor.yy190;
134445 break;
134446 case 162: /* expr ::= expr AND expr */
134447 case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
134448 case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
134449 case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
134450 case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
134451 case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
134452 case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
134453 case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
134454 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
134455 break;
134456 case 170: /* likeop ::= LIKE_KW|MATCH */
134457 {yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
134458 break;
134459 case 171: /* likeop ::= NOT LIKE_KW|MATCH */
134460 {yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
134461 break;
134462 case 172: /* expr ::= expr likeop expr */
134463 {
134464 ExprList *pList;
134465 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134466 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134467 yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
134468 exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134469 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134470 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
134471 }
134472 break;
134473 case 173: /* expr ::= expr likeop expr ESCAPE expr */
134474 {
134475 ExprList *pList;
134476 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134477 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134478 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134479 yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy392.eOperator);
134480 exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134481 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134482 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
134483 }
134484 break;
134485 case 174: /* expr ::= expr ISNULL|NOTNULL */
134486 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
134487 break;
134488 case 175: /* expr ::= expr NOT NULL */
134489 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
134490 break;
134491 case 176: /* expr ::= expr IS expr */
134492 {
134493 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134494 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
134495 }
134496 break;
134497 case 177: /* expr ::= expr IS NOT expr */
134498 {
134499 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134500 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
134501 }
134502 break;
134503 case 178: /* expr ::= NOT expr */
134504 case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
134505 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134506 break;
134507 case 180: /* expr ::= MINUS expr */
134508 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134509 break;
134510 case 181: /* expr ::= PLUS expr */
134511 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134512 break;
134513 case 182: /* between_op ::= BETWEEN */
134514 case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
134515 {yymsp[0].minor.yy194 = 0;}
134516 break;
134517 case 184: /* expr ::= expr between_op expr AND expr */
134518 {
134519 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134520 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134521 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134522 if( yymsp[-4].minor.yy190.pExpr ){
134523 yymsp[-4].minor.yy190.pExpr->x.pList = pList;
134524 }else{
134525 sqlite3ExprListDelete(pParse->db, pList);
134526 }
134527 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134528 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134529 }
134530 break;
134531 case 187: /* expr ::= expr in_op LP exprlist RP */
134532 {
134533 if( yymsp[-1].minor.yy148==0 ){
134534 /* Expressions of the form
134535 **
134536 ** expr1 IN ()
134537 ** expr1 NOT IN ()
134538 **
134539 ** simplify to constants 0 (false) and 1 (true), respectively,
134540 ** regardless of the value of expr1.
134541 */
134542 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);
134543 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy194]);
134544 }else if( yymsp[-1].minor.yy148->nExpr==1 ){
134545 /* Expressions of the form:
134546 **
134547 ** expr1 IN (?1)
134548 ** expr1 NOT IN (?2)
134549 **
@@ -133703,417 +134556,421 @@
134556 ** But, the RHS of the == or <> is marked with the EP_Generic flag
134557 ** so that it may not contribute to the computation of comparison
134558 ** affinity or the collating sequence to use for comparison. Otherwise,
134559 ** the semantics would be subtly different from IN or NOT IN.
134560 */
134561 Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;
134562 yymsp[-1].minor.yy148->a[0].pExpr = 0;
134563 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134564 /* pRHS cannot be NULL because a malloc error would have been detected
134565 ** before now and control would have never reached this point */
134566 if( ALWAYS(pRHS) ){
134567 pRHS->flags &= ~EP_Collate;
134568 pRHS->flags |= EP_Generic;
134569 }
134570 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS, 0);
134571 }else{
134572 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134573 if( yymsp[-4].minor.yy190.pExpr ){
134574 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;
134575 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134576 }else{
134577 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
134578 }
134579 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134580 }
134581 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134582 }
134583 break;
134584 case 188: /* expr ::= LP select RP */
134585 {
134586 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134587 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134588 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134589 }
134590 break;
134591 case 189: /* expr ::= expr in_op LP select RP */
134592 {
134593 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134594 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134595 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134596 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134597 }
134598 break;
134599 case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
134600 {
134601 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
134602 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
134603 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134604 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134605 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134606 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134607 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
134608 }
134609 break;
134610 case 191: /* expr ::= EXISTS LP select RP */
134611 {
134612 Expr *p;
134613 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134614 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134615 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
134616 }
134617 break;
134618 case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
134619 {
134620 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134621 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134622 if( yymsp[-4].minor.yy190.pExpr ){
134623 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
134624 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
134625 }else{
134626 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134627 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
134628 }
134629 }
134630 break;
134631 case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
134632 {
134633 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134634 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134635 }
134636 break;
134637 case 194: /* case_exprlist ::= WHEN expr THEN expr */
134638 {
134639 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134640 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
134641 }
134642 break;
134643 case 197: /* case_operand ::= expr */
134644 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
134645 break;
134646 case 200: /* nexprlist ::= nexprlist COMMA expr */
134647 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
134648 break;
134649 case 201: /* nexprlist ::= expr */
134650 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
134651 break;
134652 case 203: /* paren_exprlist ::= LP exprlist RP */
134653 case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
134654 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134655 break;
134656 case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134657 {
134658 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
134659 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134660 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134661 }
134662 break;
134663 case 205: /* uniqueflag ::= UNIQUE */
134664 case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
134665 {yymsp[0].minor.yy194 = OE_Abort;}
134666 break;
134667 case 206: /* uniqueflag ::= */
134668 {yymsp[1].minor.yy194 = OE_None;}
134669 break;
134670 case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
134671 {
134672 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134673 }
134674 break;
134675 case 210: /* eidlist ::= nm collate sortorder */
134676 {
134677 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134678 }
134679 break;
134680 case 213: /* cmd ::= DROP INDEX ifexists fullname */
134681 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134682 break;
134683 case 214: /* cmd ::= VACUUM */
134684 case 215: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==215);
 
 
 
134685 {sqlite3Vacuum(pParse);}
134686 break;
134687 case 216: /* cmd ::= PRAGMA nm dbnm */
134688 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
134689 break;
134690 case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134691 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
134692 break;
134693 case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134694 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
134695 break;
134696 case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134697 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
134698 break;
134699 case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134700 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
134701 break;
134702 case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134703 {
134704 Token all;
134705 all.z = yymsp[-3].minor.yy0.z;
134706 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
134707 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
134708 }
134709 break;
134710 case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134711 {
134712 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
134713 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
134714 }
134715 break;
134716 case 225: /* trigger_time ::= BEFORE */
134717 { yymsp[0].minor.yy194 = TK_BEFORE; }
134718 break;
134719 case 226: /* trigger_time ::= AFTER */
134720 { yymsp[0].minor.yy194 = TK_AFTER; }
134721 break;
134722 case 227: /* trigger_time ::= INSTEAD OF */
134723 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
134724 break;
134725 case 228: /* trigger_time ::= */
134726 { yymsp[1].minor.yy194 = TK_BEFORE; }
134727 break;
134728 case 229: /* trigger_event ::= DELETE|INSERT */
134729 case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
134730 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134731 break;
134732 case 231: /* trigger_event ::= UPDATE OF idlist */
134733 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134734 break;
134735 case 232: /* when_clause ::= */
134736 case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
134737 { yymsp[1].minor.yy72 = 0; }
134738 break;
134739 case 233: /* when_clause ::= WHEN expr */
134740 case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
134741 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134742 break;
134743 case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134744 {
134745 assert( yymsp[-2].minor.yy145!=0 );
134746 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134747 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134748 }
134749 break;
134750 case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
134751 {
134752 assert( yymsp[-1].minor.yy145!=0 );
134753 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134754 }
134755 break;
134756 case 236: /* trnm ::= nm DOT nm */
134757 {
134758 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
134759 sqlite3ErrorMsg(pParse,
134760 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
134761 "statements within triggers");
134762 }
134763 break;
134764 case 237: /* tridxby ::= INDEXED BY nm */
134765 {
134766 sqlite3ErrorMsg(pParse,
134767 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
134768 "within triggers");
134769 }
134770 break;
134771 case 238: /* tridxby ::= NOT INDEXED */
134772 {
134773 sqlite3ErrorMsg(pParse,
134774 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
134775 "within triggers");
134776 }
134777 break;
134778 case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134779 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134780 break;
134781 case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134782 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
134783 break;
134784 case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134785 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134786 break;
134787 case 242: /* trigger_cmd ::= select */
134788 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134789 break;
134790 case 243: /* expr ::= RAISE LP IGNORE RP */
134791 {
134792 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134793 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134794 if( yymsp[-3].minor.yy190.pExpr ){
134795 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134796 }
134797 }
134798 break;
134799 case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
134800 {
134801 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134802 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134803 if( yymsp[-5].minor.yy190.pExpr ) {
134804 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134805 }
134806 }
134807 break;
134808 case 245: /* raisetype ::= ROLLBACK */
134809 {yymsp[0].minor.yy194 = OE_Rollback;}
134810 break;
134811 case 247: /* raisetype ::= FAIL */
134812 {yymsp[0].minor.yy194 = OE_Fail;}
134813 break;
134814 case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
134815 {
134816 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134817 }
134818 break;
134819 case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134820 {
134821 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134822 }
134823 break;
134824 case 250: /* cmd ::= DETACH database_kw_opt expr */
134825 {
134826 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134827 }
134828 break;
134829 case 253: /* cmd ::= REINDEX */
134830 {sqlite3Reindex(pParse, 0, 0);}
134831 break;
134832 case 254: /* cmd ::= REINDEX nm dbnm */
134833 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134834 break;
134835 case 255: /* cmd ::= ANALYZE */
134836 {sqlite3Analyze(pParse, 0, 0);}
134837 break;
134838 case 256: /* cmd ::= ANALYZE nm dbnm */
134839 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134840 break;
134841 case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134842 {
134843 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
134844 }
134845 break;
134846 case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134847 {
134848 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
134849 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
134850 }
134851 break;
134852 case 259: /* add_column_fullname ::= fullname */
134853 {
134854 disableLookaside(pParse);
134855 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134856 }
134857 break;
134858 case 260: /* cmd ::= create_vtab */
134859 {sqlite3VtabFinishParse(pParse,0);}
134860 break;
134861 case 261: /* cmd ::= create_vtab LP vtabarglist RP */
134862 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134863 break;
134864 case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134865 {
134866 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134867 }
134868 break;
134869 case 263: /* vtabarg ::= */
134870 {sqlite3VtabArgInit(pParse);}
134871 break;
134872 case 264: /* vtabargtoken ::= ANY */
134873 case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134874 case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
134875 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134876 break;
134877 case 267: /* with ::= */
134878 {yymsp[1].minor.yy285 = 0;}
134879 break;
134880 case 268: /* with ::= WITH wqlist */
134881 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134882 break;
134883 case 269: /* with ::= WITH RECURSIVE wqlist */
134884 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134885 break;
134886 case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
134887 {
134888 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134889 }
134890 break;
134891 case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134892 {
134893 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134894 }
134895 break;
134896 default:
134897 /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134898 /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134899 /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134900 /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134901 /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134902 /* (277) explain ::= */ yytestcase(yyruleno==277);
134903 /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134904 /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134905 /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134906 /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134907 /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134908 /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134909 /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134910 /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134911 /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134912 /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134913 /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134914 /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134915 /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134916 /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134917 /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134918 /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134919 /* (294) carglist ::= */ yytestcase(yyruleno==294);
134920 /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134921 /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134922 /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134923 /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134924 /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134925 /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134926 /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134927 /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134928 /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134929 /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134930 /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134931 /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134932 /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134933 /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134934 /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134935 /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134936 /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134937 /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134938 /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134939 /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134940 /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134941 /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134942 /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134943 /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134944 /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134945 /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134946 /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134947 /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134948 /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134949 /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134950 /* (325) anylist ::= */ yytestcase(yyruleno==325);
134951 /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134952 /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
134953 break;
134954 /********** End reduce actions ************************************************/
134955 };
134956 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134957 yygoto = yyRuleInfo[yyruleno].lhs;
134958 yysize = yyRuleInfo[yyruleno].nrhs;
134959 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
134960 if( yyact <= YY_MAX_SHIFTREDUCE ){
134961 if( yyact>YY_MAX_SHIFT ){
134962 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
134963 }
134964 yymsp -= yysize-1;
134965 yypParser->yytos = yymsp;
134966 yymsp->stateno = (YYACTIONTYPE)yyact;
134967 yymsp->major = (YYCODETYPE)yygoto;
134968 yyTraceShift(yypParser, yyact);
134969 }else{
134970 assert( yyact == YY_ACCEPT_ACTION );
134971 yypParser->yytos -= yysize;
134972 yy_accept(yypParser);
134973 }
134974 }
134975
134976 /*
@@ -134127,11 +134984,11 @@
134984 #ifndef NDEBUG
134985 if( yyTraceFILE ){
134986 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
134987 }
134988 #endif
134989 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
134990 /* Here code is inserted which will be executed whenever the
134991 ** parser fails */
134992 /************ Begin %parse_failure code ***************************************/
134993 /************ End %parse_failure code *****************************************/
134994 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134167,11 +135024,14 @@
135024 #ifndef NDEBUG
135025 if( yyTraceFILE ){
135026 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
135027 }
135028 #endif
135029 #ifndef YYNOERRORRECOVERY
135030 yypParser->yyerrcnt = -1;
135031 #endif
135032 assert( yypParser->yytos==yypParser->yystack );
135033 /* Here code is inserted which will be executed whenever the
135034 ** parser accepts */
135035 /*********** Begin %parse_accept code *****************************************/
135036 /*********** End %parse_accept code *******************************************/
135037 sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -134210,32 +135070,12 @@
135070 #ifdef YYERRORSYMBOL
135071 int yyerrorhit = 0; /* True if yymajor has invoked an error */
135072 #endif
135073 yyParser *yypParser; /* The parser */
135074
 
135075 yypParser = (yyParser*)yyp;
135076 assert( yypParser->yytos!=0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135077 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
135078 yyendofinput = (yymajor==0);
135079 #endif
135080 sqlite3ParserARG_STORE;
135081
@@ -134246,11 +135086,10 @@
135086 #endif
135087
135088 do{
135089 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
135090 if( yyact <= YY_MAX_SHIFTREDUCE ){
 
135091 yy_shift(yypParser,yyact,yymajor,yyminor);
135092 #ifndef YYNOERRORRECOVERY
135093 yypParser->yyerrcnt--;
135094 #endif
135095 yymajor = YYNOCODE;
@@ -134288,11 +135127,11 @@
135127 **
135128 */
135129 if( yypParser->yyerrcnt<0 ){
135130 yy_syntax_error(yypParser,yymajor,yyminor);
135131 }
135132 yymx = yypParser->yytos->major;
135133 if( yymx==YYERRORSYMBOL || yyerrorhit ){
135134 #ifndef NDEBUG
135135 if( yyTraceFILE ){
135136 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
135137 yyTracePrompt,yyTokenName[yymajor]);
@@ -134299,22 +135138,24 @@
135138 }
135139 #endif
135140 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
135141 yymajor = YYNOCODE;
135142 }else{
135143 while( yypParser->yytos >= &yypParser->yystack
135144 && yymx != YYERRORSYMBOL
135145 && (yyact = yy_find_reduce_action(
135146 yypParser->yytos->stateno,
 
135147 YYERRORSYMBOL)) >= YY_MIN_REDUCE
135148 ){
135149 yy_pop_parser_stack(yypParser);
135150 }
135151 if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
135152 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
135153 yy_parse_failed(yypParser);
135154 #ifndef YYNOERRORRECOVERY
135155 yypParser->yyerrcnt = -1;
135156 #endif
135157 yymajor = YYNOCODE;
135158 }else if( yymx!=YYERRORSYMBOL ){
135159 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
135160 }
135161 }
@@ -134347,22 +135188,27 @@
135188 }
135189 yypParser->yyerrcnt = 3;
135190 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
135191 if( yyendofinput ){
135192 yy_parse_failed(yypParser);
135193 #ifndef YYNOERRORRECOVERY
135194 yypParser->yyerrcnt = -1;
135195 #endif
135196 }
135197 yymajor = YYNOCODE;
135198 #endif
135199 }
135200 }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
135201 #ifndef NDEBUG
135202 if( yyTraceFILE ){
135203 yyStackEntry *i;
135204 char cDiv = '[';
135205 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
135206 for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
135207 fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
135208 cDiv = ' ';
135209 }
135210 fprintf(yyTraceFILE,"]\n");
135211 }
135212 #endif
135213 return;
135214 }
@@ -136680,10 +137526,13 @@
137526 }
137527 if( !sqlite3SafetyCheckSickOrOk(db) ){
137528 return SQLITE_MISUSE_BKPT;
137529 }
137530 sqlite3_mutex_enter(db->mutex);
137531 if( db->mTrace & SQLITE_TRACE_CLOSE ){
137532 db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);
137533 }
137534
137535 /* Force xDisconnect calls on all virtual tables */
137536 disconnectAllVtab(db);
137537
137538 /* If a transaction is open, the disconnectAllVtab() call above
@@ -137448,11 +138297,12 @@
138297 **
138298 ** A NULL trace function means that no tracing is executes. A non-NULL
138299 ** trace is a pointer to a function that is invoked at the start of each
138300 ** SQL statement.
138301 */
138302 #ifndef SQLITE_OMIT_DEPRECATED
138303 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){
138304 void *pOld;
138305
138306 #ifdef SQLITE_ENABLE_API_ARMOR
138307 if( !sqlite3SafetyCheckOk(db) ){
138308 (void)SQLITE_MISUSE_BKPT;
@@ -137459,15 +138309,40 @@
138309 return 0;
138310 }
138311 #endif
138312 sqlite3_mutex_enter(db->mutex);
138313 pOld = db->pTraceArg;
138314 db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;
138315 db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;
138316 db->pTraceArg = pArg;
138317 sqlite3_mutex_leave(db->mutex);
138318 return pOld;
138319 }
138320 #endif /* SQLITE_OMIT_DEPRECATED */
138321
138322 /* Register a trace callback using the version-2 interface.
138323 */
138324 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
138325 sqlite3 *db, /* Trace this connection */
138326 unsigned mTrace, /* Mask of events to be traced */
138327 int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */
138328 void *pArg /* Context */
138329 ){
138330 #ifdef SQLITE_ENABLE_API_ARMOR
138331 if( !sqlite3SafetyCheckOk(db) ){
138332 return SQLITE_MISUSE_BKPT;
138333 }
138334 #endif
138335 sqlite3_mutex_enter(db->mutex);
138336 db->mTrace = mTrace;
138337 db->xTrace = xTrace;
138338 db->pTraceArg = pArg;
138339 sqlite3_mutex_leave(db->mutex);
138340 return SQLITE_OK;
138341 }
138342
138343 #ifndef SQLITE_OMIT_DEPRECATED
138344 /*
138345 ** Register a profile function. The pArg from the previously registered
138346 ** profile function is returned.
138347 **
138348 ** A NULL profile function means that no profiling is executes. A non-NULL
@@ -137492,10 +138367,11 @@
138367 db->xProfile = xProfile;
138368 db->pProfileArg = pArg;
138369 sqlite3_mutex_leave(db->mutex);
138370 return pOld;
138371 }
138372 #endif /* SQLITE_OMIT_DEPRECATED */
138373 #endif /* SQLITE_OMIT_TRACE */
138374
138375 /*
138376 ** Register a function to be invoked when a transaction commits.
138377 ** If the invoked function returns non-zero, then the commit becomes a
@@ -149942,11 +150818,15 @@
150818 }
150819
150820
150821 #ifdef SQLITE_TEST
150822
150823 #if defined(INCLUDE_SQLITE_TCL_H)
150824 # include "sqlite_tcl.h"
150825 #else
150826 # include "tcl.h"
150827 #endif
150828 /* #include <string.h> */
150829
150830 /*
150831 ** Implementation of a special SQL scalar function for testing tokenizers
150832 ** designed to be used in concert with the Tcl testing framework. This
@@ -161881,10 +162761,57 @@
162761 }
162762 return f;
162763 }
162764 #endif /* !defined(SQLITE_RTREE_INT_ONLY) */
162765
162766 /*
162767 ** A constraint has failed while inserting a row into an rtree table.
162768 ** Assuming no OOM error occurs, this function sets the error message
162769 ** (at pRtree->base.zErrMsg) to an appropriate value and returns
162770 ** SQLITE_CONSTRAINT.
162771 **
162772 ** Parameter iCol is the index of the leftmost column involved in the
162773 ** constraint failure. If it is 0, then the constraint that failed is
162774 ** the unique constraint on the id column. Otherwise, it is the rtree
162775 ** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.
162776 **
162777 ** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.
162778 */
162779 static int rtreeConstraintError(Rtree *pRtree, int iCol){
162780 sqlite3_stmt *pStmt = 0;
162781 char *zSql;
162782 int rc;
162783
162784 assert( iCol==0 || iCol%2 );
162785 zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName);
162786 if( zSql ){
162787 rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);
162788 }else{
162789 rc = SQLITE_NOMEM;
162790 }
162791 sqlite3_free(zSql);
162792
162793 if( rc==SQLITE_OK ){
162794 if( iCol==0 ){
162795 const char *zCol = sqlite3_column_name(pStmt, 0);
162796 pRtree->base.zErrMsg = sqlite3_mprintf(
162797 "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol
162798 );
162799 }else{
162800 const char *zCol1 = sqlite3_column_name(pStmt, iCol);
162801 const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);
162802 pRtree->base.zErrMsg = sqlite3_mprintf(
162803 "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2
162804 );
162805 }
162806 }
162807
162808 sqlite3_finalize(pStmt);
162809 return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);
162810 }
162811
162812
162813
162814 /*
162815 ** The xUpdate method for rtree module virtual tables.
162816 */
162817 static int rtreeUpdate(
@@ -161931,11 +162858,11 @@
162858 if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
162859 for(ii=0; ii<nData-4; ii+=2){
162860 cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
162861 cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
162862 if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
162863 rc = rtreeConstraintError(pRtree, ii+1);
162864 goto constraint;
162865 }
162866 }
162867 }else
162868 #endif
@@ -161942,11 +162869,11 @@
162869 {
162870 for(ii=0; ii<nData-4; ii+=2){
162871 cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
162872 cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
162873 if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
162874 rc = rtreeConstraintError(pRtree, ii+1);
162875 goto constraint;
162876 }
162877 }
162878 }
162879
@@ -161963,11 +162890,11 @@
162890 rc = sqlite3_reset(pRtree->pReadRowid);
162891 if( SQLITE_ROW==steprc ){
162892 if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){
162893 rc = rtreeDeleteRowid(pRtree, cell.iRowid);
162894 }else{
162895 rc = rtreeConstraintError(pRtree, 0);
162896 goto constraint;
162897 }
162898 }
162899 }
162900 bHaveRowid = 1;
@@ -162046,10 +162973,15 @@
162973 char *zSql;
162974 sqlite3_stmt *p;
162975 int rc;
162976 i64 nRow = 0;
162977
162978 if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1",
162979 0,0,0,0,0,0)==SQLITE_ERROR ){
162980 pRtree->nRowEst = RTREE_DEFAULT_ROWEST;
162981 return SQLITE_OK;
162982 }
162983 zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);
162984 if( zSql==0 ){
162985 rc = SQLITE_NOMEM;
162986 }else{
162987 rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);
@@ -163977,10 +164909,48 @@
164909 ** table exists but is not correctly populated, the value of the *pnOne
164910 ** output variable during stage 1 is undefined.
164911 */
164912 SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
164913
164914 /*
164915 ** Obtain an indication as to the current stage of an RBU update or vacuum.
164916 ** This function always returns one of the SQLITE_RBU_STATE_XXX constants
164917 ** defined in this file. Return values should be interpreted as follows:
164918 **
164919 ** SQLITE_RBU_STATE_OAL:
164920 ** RBU is currently building a *-oal file. The next call to sqlite3rbu_step()
164921 ** may either add further data to the *-oal file, or compute data that will
164922 ** be added by a subsequent call.
164923 **
164924 ** SQLITE_RBU_STATE_MOVE:
164925 ** RBU has finished building the *-oal file. The next call to sqlite3rbu_step()
164926 ** will move the *-oal file to the equivalent *-wal path. If the current
164927 ** operation is an RBU update, then the updated version of the database
164928 ** file will become visible to ordinary SQLite clients following the next
164929 ** call to sqlite3rbu_step().
164930 **
164931 ** SQLITE_RBU_STATE_CHECKPOINT:
164932 ** RBU is currently performing an incremental checkpoint. The next call to
164933 ** sqlite3rbu_step() will copy a page of data from the *-wal file into
164934 ** the target database file.
164935 **
164936 ** SQLITE_RBU_STATE_DONE:
164937 ** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()
164938 ** will immediately return SQLITE_DONE.
164939 **
164940 ** SQLITE_RBU_STATE_ERROR:
164941 ** An error has occurred. Any subsequent calls to sqlite3rbu_step() will
164942 ** immediately return the SQLite error code associated with the error.
164943 */
164944 #define SQLITE_RBU_STATE_OAL 1
164945 #define SQLITE_RBU_STATE_MOVE 2
164946 #define SQLITE_RBU_STATE_CHECKPOINT 3
164947 #define SQLITE_RBU_STATE_DONE 4
164948 #define SQLITE_RBU_STATE_ERROR 5
164949
164950 SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *pRbu);
164951
164952 /*
164953 ** Create an RBU VFS named zName that accesses the underlying file-system
164954 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
164955 ** then the new RBU VFS uses the default system VFS to access the file-system.
164956 ** The new object is registered as a non-default VFS with SQLite before
@@ -164872,16 +165842,18 @@
165842 */
165843 static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
165844 int rc;
165845 memset(pIter, 0, sizeof(RbuObjIter));
165846
165847 rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165848 sqlite3_mprintf(
165849 "SELECT rbu_target_name(name, type='view') AS target, name "
165850 "FROM sqlite_master "
165851 "WHERE type IN ('table', 'view') AND target IS NOT NULL "
165852 " %s "
165853 "ORDER BY name"
165854 , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : ""));
165855
165856 if( rc==SQLITE_OK ){
165857 rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
165858 "SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' "
165859 " FROM main.sqlite_master "
@@ -166456,13 +167428,13 @@
167428 #if SQLITE_ENABLE_8_3_NAMES<2
167429 if( sqlite3_uri_boolean(zBase, "8_3_names", 0) )
167430 #endif
167431 {
167432 int i, sz;
167433 sz = (int)strlen(z)&0xffffff;
167434 for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
167435 if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);
167436 }
167437 #endif
167438 }
167439
167440 /*
@@ -167504,34 +168476,11 @@
168476 }
168477
168478 if( p->rc==SQLITE_OK ){
168479 if( p->eStage==RBU_STAGE_OAL ){
168480 sqlite3 *db = p->dbMain;
168481 p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168482
168483 /* Point the object iterator at the first object */
168484 if( p->rc==SQLITE_OK ){
168485 p->rc = rbuObjIterFirst(p, &p->objiter);
168486 }
@@ -167538,16 +168487,38 @@
168487
168488 /* If the RBU database contains no data_xxx tables, declare the RBU
168489 ** update finished. */
168490 if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){
168491 p->rc = SQLITE_DONE;
168492 p->eStage = RBU_STAGE_DONE;
168493 }else{
168494 if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){
168495 rbuCopyPragma(p, "page_size");
168496 rbuCopyPragma(p, "auto_vacuum");
168497 }
168498
168499 /* Open transactions both databases. The *-oal file is opened or
168500 ** created at this point. */
168501 if( p->rc==SQLITE_OK ){
168502 p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg);
168503 }
168504
168505 /* Check if the main database is a zipvfs db. If it is, set the upper
168506 ** level pager to use "journal_mode=off". This prevents it from
168507 ** generating a large journal using a temp file. */
168508 if( p->rc==SQLITE_OK ){
168509 int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0);
168510 if( frc==SQLITE_OK ){
168511 p->rc = sqlite3_exec(
168512 db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg);
168513 }
168514 }
168515
168516 if( p->rc==SQLITE_OK ){
168517 rbuSetupOal(p, pState);
168518 }
168519 }
 
 
 
 
 
168520 }else if( p->eStage==RBU_STAGE_MOVE ){
168521 /* no-op */
168522 }else if( p->eStage==RBU_STAGE_CKPT ){
168523 rbuSetupCheckpoint(p, pState);
168524 }else if( p->eStage==RBU_STAGE_DONE ){
@@ -167709,14 +168680,44 @@
168680
168681 default:
168682 assert( 0 );
168683 }
168684 }
168685
168686 /*
168687 ** Return the current state of the RBU vacuum or update operation.
168688 */
168689 SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *p){
168690 int aRes[] = {
168691 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,
168692 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE
168693 };
168694
168695 assert( RBU_STAGE_OAL==1 );
168696 assert( RBU_STAGE_MOVE==2 );
168697 assert( RBU_STAGE_CKPT==4 );
168698 assert( RBU_STAGE_DONE==5 );
168699 assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );
168700 assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );
168701 assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );
168702 assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );
168703
168704 if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){
168705 return SQLITE_RBU_STATE_ERROR;
168706 }else{
168707 assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );
168708 assert( p->eStage==RBU_STAGE_OAL
168709 || p->eStage==RBU_STAGE_MOVE
168710 || p->eStage==RBU_STAGE_CKPT
168711 || p->eStage==RBU_STAGE_DONE
168712 );
168713 return aRes[p->eStage];
168714 }
168715 }
168716
168717 SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){
168718 int rc = p->rc;
 
168719 if( rc==SQLITE_DONE ) return SQLITE_OK;
168720
168721 assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
168722 if( p->eStage==RBU_STAGE_OAL ){
168723 assert( rc!=SQLITE_DONE );
@@ -168694,14 +169695,14 @@
169695 **
169696 ** '/1c2/000/' // Left-most child of 451st child of root
169697 */
169698 #define VTAB_SCHEMA \
169699 "CREATE TABLE xx( " \
169700 " name TEXT, /* Name of table or index */" \
169701 " path TEXT, /* Path to page from root */" \
169702 " pageno INTEGER, /* Page number */" \
169703 " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \
169704 " ncell INTEGER, /* Cells on page (0 for overflow) */" \
169705 " payload INTEGER, /* Bytes of payload on this page */" \
169706 " unused INTEGER, /* Bytes of unused space on this page */" \
169707 " mx_payload INTEGER, /* Largest payload size of all cells */" \
169708 " pgoffset INTEGER, /* Offset of page in file */" \
@@ -175195,10 +176196,30 @@
176196 #endif /* SQLITE_DEBUG */
176197
176198 /****************************************************************************
176199 ** Scalar SQL function implementations
176200 ****************************************************************************/
176201
176202 /*
176203 ** Implementation of the json_QUOTE(VALUE) function. Return a JSON value
176204 ** corresponding to the SQL value input. Mostly this means putting
176205 ** double-quotes around strings and returning the unquoted string "null"
176206 ** when given a NULL input.
176207 */
176208 static void jsonQuoteFunc(
176209 sqlite3_context *ctx,
176210 int argc,
176211 sqlite3_value **argv
176212 ){
176213 JsonString jx;
176214 UNUSED_PARAM(argc);
176215
176216 jsonInit(&jx, ctx);
176217 jsonAppendValue(&jx, argv[0]);
176218 jsonResult(&jx);
176219 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
176220 }
176221
176222 /*
176223 ** Implementation of the json_array(VALUE,...) function. Return a JSON
176224 ** array that contains all values given in arguments. Or if any argument
176225 ** is a BLOB, throw an error.
@@ -176109,10 +177130,11 @@
177130 { "json_array_length", 1, 0, jsonArrayLengthFunc },
177131 { "json_array_length", 2, 0, jsonArrayLengthFunc },
177132 { "json_extract", -1, 0, jsonExtractFunc },
177133 { "json_insert", -1, 0, jsonSetFunc },
177134 { "json_object", -1, 0, jsonObjectFunc },
177135 { "json_quote", 1, 0, jsonQuoteFunc },
177136 { "json_remove", -1, 0, jsonRemoveFunc },
177137 { "json_replace", -1, 0, jsonReplaceFunc },
177138 { "json_set", -1, 1, jsonSetFunc },
177139 { "json_type", 1, 0, jsonTypeFunc },
177140 { "json_type", 2, 0, jsonTypeFunc },
@@ -176509,11 +177531,11 @@
177531 ** following structure. All structure methods must be defined, setting
177532 ** any member of the fts5_tokenizer struct to NULL leads to undefined
177533 ** behaviour. The structure methods are expected to function as follows:
177534 **
177535 ** xCreate:
177536 ** This function is used to allocate and initialize a tokenizer instance.
177537 ** A tokenizer instance is required to actually tokenize text.
177538 **
177539 ** The first argument passed to this function is a copy of the (void*)
177540 ** pointer provided by the application when the fts5_tokenizer object
177541 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -176768,11 +177790,10 @@
177790 #if 0
177791 } /* end of the 'extern "C"' block */
177792 #endif
177793
177794 #endif /* _FTS5_H */
 
177795
177796 /*
177797 ** 2014 May 31
177798 **
177799 ** The author disclaims copyright to this source code. In place of
@@ -177458,11 +178479,10 @@
178479 static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);
178480 static int sqlite3Fts5ExprPopulatePoslists(
178481 Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int
178482 );
178483 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);
 
178484
178485 static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);
178486
178487 static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);
178488
@@ -177874,21 +178894,22 @@
178894 typedef struct fts5yyStackEntry fts5yyStackEntry;
178895
178896 /* The state of the parser is completely contained in an instance of
178897 ** the following structure */
178898 struct fts5yyParser {
178899 fts5yyStackEntry *fts5yytos; /* Pointer to top element of the stack */
178900 #ifdef fts5YYTRACKMAXSTACKDEPTH
178901 int fts5yyhwm; /* High-water mark of the stack */
178902 #endif
178903 #ifndef fts5YYNOERRORRECOVERY
178904 int fts5yyerrcnt; /* Shifts left before out of the error */
178905 #endif
178906 sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */
178907 #if fts5YYSTACKDEPTH<=0
178908 int fts5yystksz; /* Current side of the stack */
178909 fts5yyStackEntry *fts5yystack; /* The parser's stack */
178910 fts5yyStackEntry fts5yystk0; /* First stack entry */
178911 #else
178912 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
178913 #endif
178914 };
178915 typedef struct fts5yyParser fts5yyParser;
@@ -177971,28 +178992,38 @@
178992 #endif /* NDEBUG */
178993
178994
178995 #if fts5YYSTACKDEPTH<=0
178996 /*
178997 ** Try to increase the size of the parser stack. Return the number
178998 ** of errors. Return 0 on success.
178999 */
179000 static int fts5yyGrowStack(fts5yyParser *p){
179001 int newSize;
179002 int idx;
179003 fts5yyStackEntry *pNew;
179004
179005 newSize = p->fts5yystksz*2 + 100;
179006 idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;
179007 if( p->fts5yystack==&p->fts5yystk0 ){
179008 pNew = malloc(newSize*sizeof(pNew[0]));
179009 if( pNew ) pNew[0] = p->fts5yystk0;
179010 }else{
179011 pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
179012 }
179013 if( pNew ){
179014 p->fts5yystack = pNew;
179015 p->fts5yytos = &p->fts5yystack[idx];
179016 #ifndef NDEBUG
179017 if( fts5yyTraceFILE ){
179018 fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
179019 fts5yyTracePrompt, p->fts5yystksz, newSize);
179020 }
179021 #endif
179022 p->fts5yystksz = newSize;
179023 }
179024 return pNew==0;
179025 }
179026 #endif
179027
179028 /* Datatype of the argument to the memory allocated passed as the
179029 ** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by
@@ -178017,19 +179048,28 @@
179048 */
179049 static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){
179050 fts5yyParser *pParser;
179051 pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );
179052 if( pParser ){
 
179053 #ifdef fts5YYTRACKMAXSTACKDEPTH
179054 pParser->fts5yyhwm = 0;
179055 #endif
179056 #if fts5YYSTACKDEPTH<=0
179057 pParser->fts5yytos = NULL;
179058 pParser->fts5yystack = NULL;
179059 pParser->fts5yystksz = 0;
179060 if( fts5yyGrowStack(pParser) ){
179061 pParser->fts5yystack = &pParser->fts5yystk0;
179062 pParser->fts5yystksz = 1;
179063 }
179064 #endif
179065 #ifndef fts5YYNOERRORRECOVERY
179066 pParser->fts5yyerrcnt = -1;
179067 #endif
179068 pParser->fts5yytos = pParser->fts5yystack;
179069 pParser->fts5yystack[0].stateno = 0;
179070 pParser->fts5yystack[0].major = 0;
179071 }
179072 return pParser;
179073 }
179074
179075 /* The following function deletes the "minor type" or semantic value
@@ -178097,12 +179137,13 @@
179137 ** If there is a destructor routine associated with the token which
179138 ** is popped from the stack, then call it.
179139 */
179140 static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
179141 fts5yyStackEntry *fts5yytos;
179142 assert( pParser->fts5yytos!=0 );
179143 assert( pParser->fts5yytos > pParser->fts5yystack );
179144 fts5yytos = pParser->fts5yytos--;
179145 #ifndef NDEBUG
179146 if( fts5yyTraceFILE ){
179147 fprintf(fts5yyTraceFILE,"%sPopping %s\n",
179148 fts5yyTracePrompt,
179149 fts5yyTokenName[fts5yytos->major]);
@@ -178125,13 +179166,13 @@
179166 ){
179167 fts5yyParser *pParser = (fts5yyParser*)p;
179168 #ifndef fts5YYPARSEFREENEVERNULL
179169 if( pParser==0 ) return;
179170 #endif
179171 while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);
179172 #if fts5YYSTACKDEPTH<=0
179173 if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);
179174 #endif
179175 (*freeProc)((void*)pParser);
179176 }
179177
179178 /*
@@ -178138,11 +179179,11 @@
179179 ** Return the peak depth of the stack for a parser.
179180 */
179181 #ifdef fts5YYTRACKMAXSTACKDEPTH
179182 static int sqlite3Fts5ParserStackPeak(void *p){
179183 fts5yyParser *pParser = (fts5yyParser*)p;
179184 return pParser->fts5yyhwm;
179185 }
179186 #endif
179187
179188 /*
179189 ** Find the appropriate action for a parser given the terminal
@@ -178151,11 +179192,11 @@
179192 static unsigned int fts5yy_find_shift_action(
179193 fts5yyParser *pParser, /* The parser */
179194 fts5YYCODETYPE iLookAhead /* The look-ahead token */
179195 ){
179196 int i;
179197 int stateno = pParser->fts5yytos->stateno;
179198
179199 if( stateno>=fts5YY_MIN_REDUCE ) return stateno;
179200 assert( stateno <= fts5YY_SHIFT_COUNT );
179201 do{
179202 i = fts5yy_shift_ofst[stateno];
@@ -178244,17 +179285,17 @@
179285 /*
179286 ** The following routine is called if the stack overflows.
179287 */
179288 static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){
179289 sqlite3Fts5ParserARG_FETCH;
179290 fts5yypParser->fts5yytos--;
179291 #ifndef NDEBUG
179292 if( fts5yyTraceFILE ){
179293 fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt);
179294 }
179295 #endif
179296 while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
179297 /* Here code is inserted which will execute if the parser
179298 ** stack every overflows */
179299 /******** Begin %stack_overflow code ******************************************/
179300
179301 sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow");
@@ -178268,15 +179309,15 @@
179309 #ifndef NDEBUG
179310 static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){
179311 if( fts5yyTraceFILE ){
179312 if( fts5yyNewState<fts5YYNSTATE ){
179313 fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n",
179314 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major],
179315 fts5yyNewState);
179316 }else{
179317 fprintf(fts5yyTraceFILE,"%sShift '%s'\n",
179318 fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]);
179319 }
179320 }
179321 }
179322 #else
179323 # define fts5yyTraceShift(X,Y)
@@ -178290,31 +179331,34 @@
179331 int fts5yyNewState, /* The new state to shift in */
179332 int fts5yyMajor, /* The major token to shift in */
179333 sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */
179334 ){
179335 fts5yyStackEntry *fts5yytos;
179336 fts5yypParser->fts5yytos++;
179337 #ifdef fts5YYTRACKMAXSTACKDEPTH
179338 if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179339 fts5yypParser->fts5yyhwm++;
179340 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
179341 }
179342 #endif
179343 #if fts5YYSTACKDEPTH>0
179344 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
179345 fts5yyStackOverflow(fts5yypParser);
179346 return;
179347 }
179348 #else
179349 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){
179350 if( fts5yyGrowStack(fts5yypParser) ){
 
179351 fts5yyStackOverflow(fts5yypParser);
179352 return;
179353 }
179354 }
179355 #endif
179356 if( fts5yyNewState > fts5YY_MAX_SHIFT ){
179357 fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179358 }
179359 fts5yytos = fts5yypParser->fts5yytos;
179360 fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;
179361 fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;
179362 fts5yytos->minor.fts5yy0 = fts5yyMinor;
179363 fts5yyTraceShift(fts5yypParser, fts5yyNewState);
179364 }
@@ -178365,11 +179409,11 @@
179409 int fts5yygoto; /* The next state */
179410 int fts5yyact; /* The next action */
179411 fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */
179412 int fts5yysize; /* Amount to pop the stack */
179413 sqlite3Fts5ParserARG_FETCH;
179414 fts5yymsp = fts5yypParser->fts5yytos;
179415 #ifndef NDEBUG
179416 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
179417 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
179418 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
179419 fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
@@ -178379,26 +179423,27 @@
179423 /* Check that the stack is large enough to grow by a single entry
179424 ** if the RHS of the rule is empty. This ensures that there is room
179425 ** enough on the stack to push the LHS value */
179426 if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
179427 #ifdef fts5YYTRACKMAXSTACKDEPTH
179428 if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
179429 fts5yypParser->fts5yyhwm++;
179430 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
179431 }
179432 #endif
179433 #if fts5YYSTACKDEPTH>0
179434 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
179435 fts5yyStackOverflow(fts5yypParser);
179436 return;
179437 }
179438 #else
179439 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
179440 if( fts5yyGrowStack(fts5yypParser) ){
 
179441 fts5yyStackOverflow(fts5yypParser);
179442 return;
179443 }
179444 fts5yymsp = fts5yypParser->fts5yytos;
179445 }
179446 #endif
179447 }
179448
179449 switch( fts5yyruleno ){
@@ -178535,19 +179580,21 @@
179580 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
179581 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
179582 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
179583 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
179584 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
179585 if( fts5yyact>fts5YY_MAX_SHIFT ){
179586 fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
179587 }
179588 fts5yymsp -= fts5yysize-1;
179589 fts5yypParser->fts5yytos = fts5yymsp;
179590 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
179591 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
179592 fts5yyTraceShift(fts5yypParser, fts5yyact);
179593 }else{
179594 assert( fts5yyact == fts5YY_ACCEPT_ACTION );
179595 fts5yypParser->fts5yytos -= fts5yysize;
179596 fts5yy_accept(fts5yypParser);
179597 }
179598 }
179599
179600 /*
@@ -178561,11 +179608,11 @@
179608 #ifndef NDEBUG
179609 if( fts5yyTraceFILE ){
179610 fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt);
179611 }
179612 #endif
179613 while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);
179614 /* Here code is inserted which will be executed whenever the
179615 ** parser fails */
179616 /************ Begin %parse_failure code ***************************************/
179617 /************ End %parse_failure code *****************************************/
179618 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178602,11 +179649,14 @@
179649 #ifndef NDEBUG
179650 if( fts5yyTraceFILE ){
179651 fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt);
179652 }
179653 #endif
179654 #ifndef fts5YYNOERRORRECOVERY
179655 fts5yypParser->fts5yyerrcnt = -1;
179656 #endif
179657 assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );
179658 /* Here code is inserted which will be executed whenever the
179659 ** parser accepts */
179660 /*********** Begin %parse_accept code *****************************************/
179661 /*********** End %parse_accept code *******************************************/
179662 sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */
@@ -178645,32 +179695,12 @@
179695 #ifdef fts5YYERRORSYMBOL
179696 int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */
179697 #endif
179698 fts5yyParser *fts5yypParser; /* The parser */
179699
 
179700 fts5yypParser = (fts5yyParser*)fts5yyp;
179701 assert( fts5yypParser->fts5yytos!=0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179702 #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)
179703 fts5yyendofinput = (fts5yymajor==0);
179704 #endif
179705 sqlite3Fts5ParserARG_STORE;
179706
@@ -178681,11 +179711,10 @@
179711 #endif
179712
179713 do{
179714 fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);
179715 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
 
179716 fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);
179717 #ifndef fts5YYNOERRORRECOVERY
179718 fts5yypParser->fts5yyerrcnt--;
179719 #endif
179720 fts5yymajor = fts5YYNOCODE;
@@ -178723,11 +179752,11 @@
179752 **
179753 */
179754 if( fts5yypParser->fts5yyerrcnt<0 ){
179755 fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);
179756 }
179757 fts5yymx = fts5yypParser->fts5yytos->major;
179758 if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){
179759 #ifndef NDEBUG
179760 if( fts5yyTraceFILE ){
179761 fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n",
179762 fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);
@@ -178734,22 +179763,24 @@
179763 }
179764 #endif
179765 fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);
179766 fts5yymajor = fts5YYNOCODE;
179767 }else{
179768 while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack
179769 && fts5yymx != fts5YYERRORSYMBOL
179770 && (fts5yyact = fts5yy_find_reduce_action(
179771 fts5yypParser->fts5yytos->stateno,
 
179772 fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE
179773 ){
179774 fts5yy_pop_parser_stack(fts5yypParser);
179775 }
179776 if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){
179777 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
179778 fts5yy_parse_failed(fts5yypParser);
179779 #ifndef fts5YYNOERRORRECOVERY
179780 fts5yypParser->fts5yyerrcnt = -1;
179781 #endif
179782 fts5yymajor = fts5YYNOCODE;
179783 }else if( fts5yymx!=fts5YYERRORSYMBOL ){
179784 fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);
179785 }
179786 }
@@ -178782,22 +179813,27 @@
179813 }
179814 fts5yypParser->fts5yyerrcnt = 3;
179815 fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);
179816 if( fts5yyendofinput ){
179817 fts5yy_parse_failed(fts5yypParser);
179818 #ifndef fts5YYNOERRORRECOVERY
179819 fts5yypParser->fts5yyerrcnt = -1;
179820 #endif
179821 }
179822 fts5yymajor = fts5YYNOCODE;
179823 #endif
179824 }
179825 }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );
179826 #ifndef NDEBUG
179827 if( fts5yyTraceFILE ){
179828 fts5yyStackEntry *i;
179829 char cDiv = '[';
179830 fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt);
179831 for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){
179832 fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]);
179833 cDiv = ' ';
179834 }
179835 fprintf(fts5yyTraceFILE,"]\n");
179836 }
179837 #endif
179838 return;
179839 }
@@ -183337,21 +184373,10 @@
184373
184374 static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){
184375 fts5ExprCheckPoslists(pExpr->pRoot, iRowid);
184376 }
184377
 
 
 
 
 
 
 
 
 
 
 
184378 /*
184379 ** This function is only called for detail=columns tables.
184380 */
184381 static int sqlite3Fts5ExprPhraseCollist(
184382 Fts5Expr *pExpr,
@@ -191565,11 +192590,10 @@
192590 assert( pCsr->iLastRowid==LARGEST_INT64 );
192591 assert( pCsr->iFirstRowid==SMALLEST_INT64 );
192592 pCsr->ePlan = FTS5_PLAN_SOURCE;
192593 pCsr->pExpr = pTab->pSortCsr->pExpr;
192594 rc = fts5CursorFirst(pTab, pCsr, bDesc);
 
192595 }else if( pMatch ){
192596 const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
192597 if( zExpr==0 ) zExpr = "";
192598
192599 rc = fts5CursorParseRank(pConfig, pCsr, pRank);
@@ -192994,11 +194018,11 @@
194018 int nArg, /* Number of args */
194019 sqlite3_value **apUnused /* Function arguments */
194020 ){
194021 assert( nArg==0 );
194022 UNUSED_PARAM2(nArg, apUnused);
194023 sqlite3_result_text(pCtx, "fts5: 2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b", -1, SQLITE_TRANSIENT);
194024 }
194025
194026 static int fts5Init(sqlite3 *db){
194027 static const sqlite3_module fts5Mod = {
194028 /* iVersion */ 2,
@@ -193359,11 +194383,15 @@
194383 ){
194384 int rc;
194385 char *zErr = 0;
194386
194387 rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s",
194388 pConfig->zDb, pConfig->zName, zPost, zDefn,
194389 #ifndef SQLITE_FTS5_NO_WITHOUT_ROWID
194390 bWithout?" WITHOUT ROWID":
194391 #endif
194392 ""
194393 );
194394 if( zErr ){
194395 *pzErr = sqlite3_mprintf(
194396 "fts5: error creating shadow table %q_%s: %s",
194397 pConfig->zName, zPost, zErr
194398
+184 -30
--- 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
*/
@@ -52,12 +52,21 @@
5252
# define SQLITE_API
5353
#endif
5454
#ifndef SQLITE_CDECL
5555
# define SQLITE_CDECL
5656
#endif
57
+#ifndef SQLITE_APICALL
58
+# define SQLITE_APICALL
59
+#endif
5760
#ifndef SQLITE_STDCALL
58
-# define SQLITE_STDCALL
61
+# define SQLITE_STDCALL SQLITE_APICALL
62
+#endif
63
+#ifndef SQLITE_CALLBACK
64
+# define SQLITE_CALLBACK
65
+#endif
66
+#ifndef SQLITE_SYSAPI
67
+# define SQLITE_SYSAPI
5968
#endif
6069
6170
/*
6271
** These no-op macros are used in front of interfaces to mark those
6372
** interfaces as either deprecated or experimental. New applications
@@ -109,13 +118,13 @@
109118
**
110119
** See also: [sqlite3_libversion()],
111120
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112121
** [sqlite_version()] and [sqlite_source_id()].
113122
*/
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"
123
+#define SQLITE_VERSION "3.14.1"
124
+#define SQLITE_VERSION_NUMBER 3014001
125
+#define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
117126
118127
/*
119128
** CAPI3REF: Run-Time Library Version Numbers
120129
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121130
**
@@ -504,10 +513,11 @@
504513
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
505514
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
506515
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
507516
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
508517
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
518
+#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
509519
510520
/*
511521
** CAPI3REF: Flags For File Open Operations
512522
**
513523
** These bit values are intended for use in the
@@ -1033,10 +1043,20 @@
10331043
**
10341044
** Mutexes are created using [sqlite3_mutex_alloc()].
10351045
*/
10361046
typedef struct sqlite3_mutex sqlite3_mutex;
10371047
1048
+/*
1049
+** CAPI3REF: Loadable Extension Thunk
1050
+**
1051
+** A pointer to the opaque sqlite3_api_routines structure is passed as
1052
+** the third parameter to entry points of [loadable extensions]. This
1053
+** structure must be typedefed in order to work around compiler warnings
1054
+** on some platforms.
1055
+*/
1056
+typedef struct sqlite3_api_routines sqlite3_api_routines;
1057
+
10381058
/*
10391059
** CAPI3REF: OS Interface Object
10401060
**
10411061
** An instance of the sqlite3_vfs object defines the interface between
10421062
** the SQLite core and the underlying operating system. The "vfs"
@@ -1937,11 +1957,11 @@
19371957
** interface independently of the [load_extension()] SQL function.
19381958
** The [sqlite3_enable_load_extension()] API enables or disables both the
19391959
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
19401960
** There should be two additional arguments.
19411961
** When the first argument to this interface is 1, then only the C-API is
1942
-** enabled and the SQL function remains disabled. If the first argment to
1962
+** enabled and the SQL function remains disabled. If the first argument to
19431963
** this interface is 0, then both the C-API and the SQL function are disabled.
19441964
** If the first argument is -1, then no changes are made to state of either the
19451965
** C-API or the SQL function.
19461966
** The second parameter is a pointer to an integer into which
19471967
** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2230,11 +2250,11 @@
22302250
** result in undefined behavior.
22312251
**
22322252
** A busy handler must not close the database connection
22332253
** or [prepared statement] that invoked the busy handler.
22342254
*/
2235
-SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2255
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
22362256
22372257
/*
22382258
** CAPI3REF: Set A Busy Timeout
22392259
** METHOD: sqlite3
22402260
**
@@ -2751,10 +2771,13 @@
27512771
#define SQLITE_RECURSIVE 33 /* NULL NULL */
27522772
27532773
/*
27542774
** CAPI3REF: Tracing And Profiling Functions
27552775
** METHOD: sqlite3
2776
+**
2777
+** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
2778
+** instead of the routines described here.
27562779
**
27572780
** These routines register callback functions that can be used for
27582781
** tracing and profiling the execution of SQL statements.
27592782
**
27602783
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2777,13 +2800,107 @@
27772800
** digits in the time are meaningless. Future versions of SQLite
27782801
** might provide greater resolution on the profiler callback. The
27792802
** sqlite3_profile() function is considered experimental and is
27802803
** subject to change in future versions of SQLite.
27812804
*/
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*,
2805
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
2806
+ void(*xTrace)(void*,const char*), void*);
2807
+SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
27842808
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2809
+
2810
+/*
2811
+** CAPI3REF: SQL Trace Event Codes
2812
+** KEYWORDS: SQLITE_TRACE
2813
+**
2814
+** These constants identify classes of events that can be monitored
2815
+** using the [sqlite3_trace_v2()] tracing logic. The third argument
2816
+** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
2817
+** the following constants. ^The first argument to the trace callback
2818
+** is one of the following constants.
2819
+**
2820
+** New tracing constants may be added in future releases.
2821
+**
2822
+** ^A trace callback has four arguments: xCallback(T,C,P,X).
2823
+** ^The T argument is one of the integer type codes above.
2824
+** ^The C argument is a copy of the context pointer passed in as the
2825
+** fourth argument to [sqlite3_trace_v2()].
2826
+** The P and X arguments are pointers whose meanings depend on T.
2827
+**
2828
+** <dl>
2829
+** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
2830
+** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
2831
+** first begins running and possibly at other times during the
2832
+** execution of the prepared statement, such as at the start of each
2833
+** trigger subprogram. ^The P argument is a pointer to the
2834
+** [prepared statement]. ^The X argument is a pointer to a string which
2835
+** is the unexpanded SQL text of the prepared statement or an SQL comment
2836
+** that indicates the invocation of a trigger. ^The callback can compute
2837
+** the same text that would have been returned by the legacy [sqlite3_trace()]
2838
+** interface by using the X argument when X begins with "--" and invoking
2839
+** [sqlite3_expanded_sql(P)] otherwise.
2840
+**
2841
+** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
2842
+** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
2843
+** information as is provided by the [sqlite3_profile()] callback.
2844
+** ^The P argument is a pointer to the [prepared statement] and the
2845
+** X argument points to a 64-bit integer which is the estimated of
2846
+** the number of nanosecond that the prepared statement took to run.
2847
+** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
2848
+**
2849
+** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
2850
+** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
2851
+** statement generates a single row of result.
2852
+** ^The P argument is a pointer to the [prepared statement] and the
2853
+** X argument is unused.
2854
+**
2855
+** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
2856
+** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
2857
+** connection closes.
2858
+** ^The P argument is a pointer to the [database connection] object
2859
+** and the X argument is unused.
2860
+** </dl>
2861
+*/
2862
+#define SQLITE_TRACE_STMT 0x01
2863
+#define SQLITE_TRACE_PROFILE 0x02
2864
+#define SQLITE_TRACE_ROW 0x04
2865
+#define SQLITE_TRACE_CLOSE 0x08
2866
+
2867
+/*
2868
+** CAPI3REF: SQL Trace Hook
2869
+** METHOD: sqlite3
2870
+**
2871
+** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
2872
+** function X against [database connection] D, using property mask M
2873
+** and context pointer P. ^If the X callback is
2874
+** NULL or if the M mask is zero, then tracing is disabled. The
2875
+** M argument should be the bitwise OR-ed combination of
2876
+** zero or more [SQLITE_TRACE] constants.
2877
+**
2878
+** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
2879
+** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
2880
+**
2881
+** ^The X callback is invoked whenever any of the events identified by
2882
+** mask M occur. ^The integer return value from the callback is currently
2883
+** ignored, though this may change in future releases. Callback
2884
+** implementations should return zero to ensure future compatibility.
2885
+**
2886
+** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
2887
+** ^The T argument is one of the [SQLITE_TRACE]
2888
+** constants to indicate why the callback was invoked.
2889
+** ^The C argument is a copy of the context pointer.
2890
+** The P and X arguments are pointers whose meanings depend on T.
2891
+**
2892
+** The sqlite3_trace_v2() interface is intended to replace the legacy
2893
+** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
2894
+** are deprecated.
2895
+*/
2896
+SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
2897
+ sqlite3*,
2898
+ unsigned uMask,
2899
+ int(*xCallback)(unsigned,void*,void*,void*),
2900
+ void *pCtx
2901
+);
27852902
27862903
/*
27872904
** CAPI3REF: Query Progress Callbacks
27882905
** METHOD: sqlite3
27892906
**
@@ -3399,15 +3516,39 @@
33993516
34003517
/*
34013518
** CAPI3REF: Retrieving Statement SQL
34023519
** METHOD: sqlite3_stmt
34033520
**
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()].
3521
+** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3522
+** SQL text used to create [prepared statement] P if P was
3523
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3524
+** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3525
+** string containing the SQL text of prepared statement P with
3526
+** [bound parameters] expanded.
3527
+**
3528
+** ^(For example, if a prepared statement is created using the SQL
3529
+** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3530
+** and parameter :xyz is unbound, then sqlite3_sql() will return
3531
+** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3532
+** will return "SELECT 2345,NULL".)^
3533
+**
3534
+** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3535
+** is available to hold the result, or if the result would exceed the
3536
+** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3537
+**
3538
+** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3539
+** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3540
+** option causes sqlite3_expanded_sql() to always return NULL.
3541
+**
3542
+** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3543
+** automatically freed when the prepared statement is finalized.
3544
+** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3545
+** is obtained from [sqlite3_malloc()] and must be free by the application
3546
+** by passing it to [sqlite3_free()].
34073547
*/
34083548
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3549
+SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
34093550
34103551
/*
34113552
** CAPI3REF: Determine If An SQL Statement Writes The Database
34123553
** METHOD: sqlite3_stmt
34133554
**
@@ -4561,16 +4702,17 @@
45614702
** NULL if the metadata has been discarded.
45624703
** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
45634704
** SQLite will invoke the destructor function X with parameter P exactly
45644705
** once, when the metadata is discarded.
45654706
** SQLite is free to discard the metadata at any time, including: <ul>
4566
-** <li> when the corresponding function parameter changes, or
4567
-** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4568
-** SQL statement, or
4569
-** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4570
-** <li> during the original sqlite3_set_auxdata() call when a memory
4571
-** allocation error occurs. </ul>)^
4707
+** <li> ^(when the corresponding function parameter changes)^, or
4708
+** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4709
+** SQL statement)^, or
4710
+** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
4711
+** parameter)^, or
4712
+** <li> ^(during the original sqlite3_set_auxdata() call when a memory
4713
+** allocation error occurs.)^ </ul>
45724714
**
45734715
** Note the last bullet in particular. The destructor X in
45744716
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
45754717
** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
45764718
** should be called near the end of the function implementation and the
@@ -5393,11 +5535,11 @@
53935535
** interface returns SQLITE_OK and fills in the non-NULL pointers in
53945536
** the final five arguments with appropriate values if the specified
53955537
** column exists. ^The sqlite3_table_column_metadata() interface returns
53965538
** SQLITE_ERROR and if the specified column does not exist.
53975539
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5398
-** NULL pointer, then this routine simply checks for the existance of the
5540
+** NULL pointer, then this routine simply checks for the existence of the
53995541
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
54005542
** does not.
54015543
**
54025544
** ^The column is identified by the second, third and fourth parameters to
54035545
** this function. ^(The second parameter is either the name of the database
@@ -5527,12 +5669,12 @@
55275669
** to turn extension loading on and call it with onoff==0 to turn
55285670
** it back off again.
55295671
**
55305672
** ^This interface enables or disables both the C-API
55315673
** [sqlite3_load_extension()] and the SQL function [load_extension()].
5532
-** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5533
-** to enable or disable only the C-API.
5674
+** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5675
+** to enable or disable only the C-API.)^
55345676
**
55355677
** <b>Security warning:</b> It is recommended that extension loading
55365678
** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
55375679
** rather than this interface, so the [load_extension()] SQL function
55385680
** remains disabled. This will prevent SQL injections from giving attackers
@@ -5548,11 +5690,11 @@
55485690
** xEntryPoint() is the entry point for a statically linked [SQLite extension]
55495691
** that is to be automatically loaded into all new database connections.
55505692
**
55515693
** ^(Even though the function prototype shows that xEntryPoint() takes
55525694
** no arguments and returns void, SQLite invokes xEntryPoint() with three
5553
-** arguments and expects and integer result as if the signature of the
5695
+** arguments and expects an integer result as if the signature of the
55545696
** entry point where as follows:
55555697
**
55565698
** <blockquote><pre>
55575699
** &nbsp; int xEntryPoint(
55585700
** &nbsp; sqlite3 *db,
@@ -5574,11 +5716,11 @@
55745716
** will be called more than once for each database connection that is opened.
55755717
**
55765718
** See also: [sqlite3_reset_auto_extension()]
55775719
** and [sqlite3_cancel_auto_extension()]
55785720
*/
5579
-SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5721
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
55805722
55815723
/*
55825724
** CAPI3REF: Cancel Automatic Extension Loading
55835725
**
55845726
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5586,11 +5728,11 @@
55865728
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
55875729
** routine returns 1 if initialization routine X was successfully
55885730
** unregistered and it returns 0 if X was not on the list of initialization
55895731
** routines.
55905732
*/
5591
-SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5733
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
55925734
55935735
/*
55945736
** CAPI3REF: Reset Automatic Extension Loading
55955737
**
55965738
** ^This interface disables all automatic extensions previously
@@ -6762,10 +6904,22 @@
67626904
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
67636905
** <dd>This parameter returns the approximate number of bytes of heap
67646906
** memory used by all pager caches associated with the database connection.)^
67656907
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
67666908
**
6909
+** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
6910
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
6911
+** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
6912
+** pager cache is shared between two or more connections the bytes of heap
6913
+** memory used by that pager cache is divided evenly between the attached
6914
+** connections.)^ In other words, if none of the pager caches associated
6915
+** with the database connection are shared, this request returns the same
6916
+** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
6917
+** shared, the value returned by this call will be smaller than that returned
6918
+** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
6919
+** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
6920
+**
67676921
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
67686922
** <dd>This parameter returns the approximate number of bytes of heap
67696923
** memory used to store the schema for all databases associated
67706924
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
67716925
** ^The full amount of memory used by the schemas is reported, even if the
@@ -6819,11 +6973,12 @@
68196973
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
68206974
#define SQLITE_DBSTATUS_CACHE_HIT 7
68216975
#define SQLITE_DBSTATUS_CACHE_MISS 8
68226976
#define SQLITE_DBSTATUS_CACHE_WRITE 9
68236977
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
6824
-#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6978
+#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
6979
+#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
68256980
68266981
68276982
/*
68286983
** CAPI3REF: Prepared Statement Status
68296984
** METHOD: sqlite3_stmt
@@ -7975,11 +8130,11 @@
79758130
** tables.
79768131
**
79778132
** ^The second parameter to the preupdate callback is a pointer to
79788133
** the [database connection] that registered the preupdate hook.
79798134
** ^The third parameter to the preupdate callback is one of the constants
7980
-** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
8135
+** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
79818136
** kind of update operation that is about to occur.
79828137
** ^(The fourth parameter to the preupdate callback is the name of the
79838138
** database within the database connection that is being modified. This
79848139
** will be "main" for the main database or "temp" for TEMP tables or
79858140
** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8202,11 +8357,11 @@
82028357
#endif
82038358
82048359
#ifdef __cplusplus
82058360
} /* End of the 'extern "C"' block */
82068361
#endif
8207
-#endif /* _SQLITE3_H_ */
8362
+#endif /* SQLITE3_H */
82088363
82098364
/******** Begin file sqlite3rtree.h *********/
82108365
/*
82118366
** 2010 August 30
82128367
**
@@ -9922,11 +10077,11 @@
992210077
** following structure. All structure methods must be defined, setting
992310078
** any member of the fts5_tokenizer struct to NULL leads to undefined
992410079
** behaviour. The structure methods are expected to function as follows:
992510080
**
992610081
** xCreate:
9927
-** This function is used to allocate and inititalize a tokenizer instance.
10082
+** This function is used to allocate and initialize a tokenizer instance.
992810083
** A tokenizer instance is required to actually tokenize text.
992910084
**
993010085
** The first argument passed to this function is a copy of the (void*)
993110086
** pointer provided by the application when the fts5_tokenizer object
993210087
** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10181,8 +10336,7 @@
1018110336
#ifdef __cplusplus
1018210337
} /* end of the 'extern "C"' block */
1018310338
#endif
1018410339
1018510340
#endif /* _FTS5_H */
10186
-
1018710341
1018810342
/******** End of fts5.h *********/
1018910343
--- 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 */
@@ -52,12 +52,21 @@
52 # define SQLITE_API
53 #endif
54 #ifndef SQLITE_CDECL
55 # define SQLITE_CDECL
56 #endif
 
 
 
57 #ifndef SQLITE_STDCALL
58 # define SQLITE_STDCALL
 
 
 
 
 
 
59 #endif
60
61 /*
62 ** These no-op macros are used in front of interfaces to mark those
63 ** interfaces as either deprecated or experimental. New applications
@@ -109,13 +118,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 +513,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
@@ -1033,10 +1043,20 @@
1033 **
1034 ** Mutexes are created using [sqlite3_mutex_alloc()].
1035 */
1036 typedef struct sqlite3_mutex sqlite3_mutex;
1037
 
 
 
 
 
 
 
 
 
 
1038 /*
1039 ** CAPI3REF: OS Interface Object
1040 **
1041 ** An instance of the sqlite3_vfs object defines the interface between
1042 ** the SQLite core and the underlying operating system. The "vfs"
@@ -1937,11 +1957,11 @@
1937 ** interface independently of the [load_extension()] SQL function.
1938 ** The [sqlite3_enable_load_extension()] API enables or disables both the
1939 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
1940 ** There should be two additional arguments.
1941 ** When the first argument to this interface is 1, then only the C-API is
1942 ** enabled and the SQL function remains disabled. If the first argment to
1943 ** this interface is 0, then both the C-API and the SQL function are disabled.
1944 ** If the first argument is -1, then no changes are made to state of either the
1945 ** C-API or the SQL function.
1946 ** The second parameter is a pointer to an integer into which
1947 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2230,11 +2250,11 @@
2230 ** result in undefined behavior.
2231 **
2232 ** A busy handler must not close the database connection
2233 ** or [prepared statement] that invoked the busy handler.
2234 */
2235 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2236
2237 /*
2238 ** CAPI3REF: Set A Busy Timeout
2239 ** METHOD: sqlite3
2240 **
@@ -2751,10 +2771,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 +2800,107 @@
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 +3516,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 **
@@ -4561,16 +4702,17 @@
4561 ** NULL if the metadata has been discarded.
4562 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4563 ** SQLite will invoke the destructor function X with parameter P exactly
4564 ** once, when the metadata is discarded.
4565 ** SQLite is free to discard the metadata at any time, including: <ul>
4566 ** <li> when the corresponding function parameter changes, or
4567 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4568 ** SQL statement, or
4569 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4570 ** <li> during the original sqlite3_set_auxdata() call when a memory
4571 ** allocation error occurs. </ul>)^
 
4572 **
4573 ** Note the last bullet in particular. The destructor X in
4574 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4575 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4576 ** should be called near the end of the function implementation and the
@@ -5393,11 +5535,11 @@
5393 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5394 ** the final five arguments with appropriate values if the specified
5395 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5396 ** SQLITE_ERROR and if the specified column does not exist.
5397 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5398 ** NULL pointer, then this routine simply checks for the existance of the
5399 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5400 ** does not.
5401 **
5402 ** ^The column is identified by the second, third and fourth parameters to
5403 ** this function. ^(The second parameter is either the name of the database
@@ -5527,12 +5669,12 @@
5527 ** to turn extension loading on and call it with onoff==0 to turn
5528 ** it back off again.
5529 **
5530 ** ^This interface enables or disables both the C-API
5531 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
5532 ** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5533 ** to enable or disable only the C-API.
5534 **
5535 ** <b>Security warning:</b> It is recommended that extension loading
5536 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
5537 ** rather than this interface, so the [load_extension()] SQL function
5538 ** remains disabled. This will prevent SQL injections from giving attackers
@@ -5548,11 +5690,11 @@
5548 ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
5549 ** that is to be automatically loaded into all new database connections.
5550 **
5551 ** ^(Even though the function prototype shows that xEntryPoint() takes
5552 ** no arguments and returns void, SQLite invokes xEntryPoint() with three
5553 ** arguments and expects and integer result as if the signature of the
5554 ** entry point where as follows:
5555 **
5556 ** <blockquote><pre>
5557 ** &nbsp; int xEntryPoint(
5558 ** &nbsp; sqlite3 *db,
@@ -5574,11 +5716,11 @@
5574 ** will be called more than once for each database connection that is opened.
5575 **
5576 ** See also: [sqlite3_reset_auto_extension()]
5577 ** and [sqlite3_cancel_auto_extension()]
5578 */
5579 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5580
5581 /*
5582 ** CAPI3REF: Cancel Automatic Extension Loading
5583 **
5584 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5586,11 +5728,11 @@
5586 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5587 ** routine returns 1 if initialization routine X was successfully
5588 ** unregistered and it returns 0 if X was not on the list of initialization
5589 ** routines.
5590 */
5591 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5592
5593 /*
5594 ** CAPI3REF: Reset Automatic Extension Loading
5595 **
5596 ** ^This interface disables all automatic extensions previously
@@ -6762,10 +6904,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 +6973,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
@@ -7975,11 +8130,11 @@
7975 ** tables.
7976 **
7977 ** ^The second parameter to the preupdate callback is a pointer to
7978 ** the [database connection] that registered the preupdate hook.
7979 ** ^The third parameter to the preupdate callback is one of the constants
7980 ** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
7981 ** kind of update operation that is about to occur.
7982 ** ^(The fourth parameter to the preupdate callback is the name of the
7983 ** database within the database connection that is being modified. This
7984 ** will be "main" for the main database or "temp" for TEMP tables or
7985 ** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8202,11 +8357,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 **
@@ -9922,11 +10077,11 @@
9922 ** following structure. All structure methods must be defined, setting
9923 ** any member of the fts5_tokenizer struct to NULL leads to undefined
9924 ** behaviour. The structure methods are expected to function as follows:
9925 **
9926 ** xCreate:
9927 ** This function is used to allocate and inititalize a tokenizer instance.
9928 ** A tokenizer instance is required to actually tokenize text.
9929 **
9930 ** The first argument passed to this function is a copy of the (void*)
9931 ** pointer provided by the application when the fts5_tokenizer object
9932 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10181,8 +10336,7 @@
10181 #ifdef __cplusplus
10182 } /* end of the 'extern "C"' block */
10183 #endif
10184
10185 #endif /* _FTS5_H */
10186
10187
10188 /******** End of fts5.h *********/
10189
--- 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 */
@@ -52,12 +52,21 @@
52 # define SQLITE_API
53 #endif
54 #ifndef SQLITE_CDECL
55 # define SQLITE_CDECL
56 #endif
57 #ifndef SQLITE_APICALL
58 # define SQLITE_APICALL
59 #endif
60 #ifndef SQLITE_STDCALL
61 # define SQLITE_STDCALL SQLITE_APICALL
62 #endif
63 #ifndef SQLITE_CALLBACK
64 # define SQLITE_CALLBACK
65 #endif
66 #ifndef SQLITE_SYSAPI
67 # define SQLITE_SYSAPI
68 #endif
69
70 /*
71 ** These no-op macros are used in front of interfaces to mark those
72 ** interfaces as either deprecated or experimental. New applications
@@ -109,13 +118,13 @@
118 **
119 ** See also: [sqlite3_libversion()],
120 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
121 ** [sqlite_version()] and [sqlite_source_id()].
122 */
123 #define SQLITE_VERSION "3.14.1"
124 #define SQLITE_VERSION_NUMBER 3014001
125 #define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
126
127 /*
128 ** CAPI3REF: Run-Time Library Version Numbers
129 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
130 **
@@ -504,10 +513,11 @@
513 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
514 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
515 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
516 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
517 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
518 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
519
520 /*
521 ** CAPI3REF: Flags For File Open Operations
522 **
523 ** These bit values are intended for use in the
@@ -1033,10 +1043,20 @@
1043 **
1044 ** Mutexes are created using [sqlite3_mutex_alloc()].
1045 */
1046 typedef struct sqlite3_mutex sqlite3_mutex;
1047
1048 /*
1049 ** CAPI3REF: Loadable Extension Thunk
1050 **
1051 ** A pointer to the opaque sqlite3_api_routines structure is passed as
1052 ** the third parameter to entry points of [loadable extensions]. This
1053 ** structure must be typedefed in order to work around compiler warnings
1054 ** on some platforms.
1055 */
1056 typedef struct sqlite3_api_routines sqlite3_api_routines;
1057
1058 /*
1059 ** CAPI3REF: OS Interface Object
1060 **
1061 ** An instance of the sqlite3_vfs object defines the interface between
1062 ** the SQLite core and the underlying operating system. The "vfs"
@@ -1937,11 +1957,11 @@
1957 ** interface independently of the [load_extension()] SQL function.
1958 ** The [sqlite3_enable_load_extension()] API enables or disables both the
1959 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
1960 ** There should be two additional arguments.
1961 ** When the first argument to this interface is 1, then only the C-API is
1962 ** enabled and the SQL function remains disabled. If the first argument to
1963 ** this interface is 0, then both the C-API and the SQL function are disabled.
1964 ** If the first argument is -1, then no changes are made to state of either the
1965 ** C-API or the SQL function.
1966 ** The second parameter is a pointer to an integer into which
1967 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
@@ -2230,11 +2250,11 @@
2250 ** result in undefined behavior.
2251 **
2252 ** A busy handler must not close the database connection
2253 ** or [prepared statement] that invoked the busy handler.
2254 */
2255 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
2256
2257 /*
2258 ** CAPI3REF: Set A Busy Timeout
2259 ** METHOD: sqlite3
2260 **
@@ -2751,10 +2771,13 @@
2771 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2772
2773 /*
2774 ** CAPI3REF: Tracing And Profiling Functions
2775 ** METHOD: sqlite3
2776 **
2777 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
2778 ** instead of the routines described here.
2779 **
2780 ** These routines register callback functions that can be used for
2781 ** tracing and profiling the execution of SQL statements.
2782 **
2783 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2777,13 +2800,107 @@
2800 ** digits in the time are meaningless. Future versions of SQLite
2801 ** might provide greater resolution on the profiler callback. The
2802 ** sqlite3_profile() function is considered experimental and is
2803 ** subject to change in future versions of SQLite.
2804 */
2805 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
2806 void(*xTrace)(void*,const char*), void*);
2807 SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2808 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2809
2810 /*
2811 ** CAPI3REF: SQL Trace Event Codes
2812 ** KEYWORDS: SQLITE_TRACE
2813 **
2814 ** These constants identify classes of events that can be monitored
2815 ** using the [sqlite3_trace_v2()] tracing logic. The third argument
2816 ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
2817 ** the following constants. ^The first argument to the trace callback
2818 ** is one of the following constants.
2819 **
2820 ** New tracing constants may be added in future releases.
2821 **
2822 ** ^A trace callback has four arguments: xCallback(T,C,P,X).
2823 ** ^The T argument is one of the integer type codes above.
2824 ** ^The C argument is a copy of the context pointer passed in as the
2825 ** fourth argument to [sqlite3_trace_v2()].
2826 ** The P and X arguments are pointers whose meanings depend on T.
2827 **
2828 ** <dl>
2829 ** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
2830 ** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
2831 ** first begins running and possibly at other times during the
2832 ** execution of the prepared statement, such as at the start of each
2833 ** trigger subprogram. ^The P argument is a pointer to the
2834 ** [prepared statement]. ^The X argument is a pointer to a string which
2835 ** is the unexpanded SQL text of the prepared statement or an SQL comment
2836 ** that indicates the invocation of a trigger. ^The callback can compute
2837 ** the same text that would have been returned by the legacy [sqlite3_trace()]
2838 ** interface by using the X argument when X begins with "--" and invoking
2839 ** [sqlite3_expanded_sql(P)] otherwise.
2840 **
2841 ** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
2842 ** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
2843 ** information as is provided by the [sqlite3_profile()] callback.
2844 ** ^The P argument is a pointer to the [prepared statement] and the
2845 ** X argument points to a 64-bit integer which is the estimated of
2846 ** the number of nanosecond that the prepared statement took to run.
2847 ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
2848 **
2849 ** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
2850 ** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
2851 ** statement generates a single row of result.
2852 ** ^The P argument is a pointer to the [prepared statement] and the
2853 ** X argument is unused.
2854 **
2855 ** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
2856 ** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
2857 ** connection closes.
2858 ** ^The P argument is a pointer to the [database connection] object
2859 ** and the X argument is unused.
2860 ** </dl>
2861 */
2862 #define SQLITE_TRACE_STMT 0x01
2863 #define SQLITE_TRACE_PROFILE 0x02
2864 #define SQLITE_TRACE_ROW 0x04
2865 #define SQLITE_TRACE_CLOSE 0x08
2866
2867 /*
2868 ** CAPI3REF: SQL Trace Hook
2869 ** METHOD: sqlite3
2870 **
2871 ** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
2872 ** function X against [database connection] D, using property mask M
2873 ** and context pointer P. ^If the X callback is
2874 ** NULL or if the M mask is zero, then tracing is disabled. The
2875 ** M argument should be the bitwise OR-ed combination of
2876 ** zero or more [SQLITE_TRACE] constants.
2877 **
2878 ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
2879 ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
2880 **
2881 ** ^The X callback is invoked whenever any of the events identified by
2882 ** mask M occur. ^The integer return value from the callback is currently
2883 ** ignored, though this may change in future releases. Callback
2884 ** implementations should return zero to ensure future compatibility.
2885 **
2886 ** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
2887 ** ^The T argument is one of the [SQLITE_TRACE]
2888 ** constants to indicate why the callback was invoked.
2889 ** ^The C argument is a copy of the context pointer.
2890 ** The P and X arguments are pointers whose meanings depend on T.
2891 **
2892 ** The sqlite3_trace_v2() interface is intended to replace the legacy
2893 ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
2894 ** are deprecated.
2895 */
2896 SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
2897 sqlite3*,
2898 unsigned uMask,
2899 int(*xCallback)(unsigned,void*,void*,void*),
2900 void *pCtx
2901 );
2902
2903 /*
2904 ** CAPI3REF: Query Progress Callbacks
2905 ** METHOD: sqlite3
2906 **
@@ -3399,15 +3516,39 @@
3516
3517 /*
3518 ** CAPI3REF: Retrieving Statement SQL
3519 ** METHOD: sqlite3_stmt
3520 **
3521 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3522 ** SQL text used to create [prepared statement] P if P was
3523 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3524 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3525 ** string containing the SQL text of prepared statement P with
3526 ** [bound parameters] expanded.
3527 **
3528 ** ^(For example, if a prepared statement is created using the SQL
3529 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3530 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3531 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
3532 ** will return "SELECT 2345,NULL".)^
3533 **
3534 ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
3535 ** is available to hold the result, or if the result would exceed the
3536 ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
3537 **
3538 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3539 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3540 ** option causes sqlite3_expanded_sql() to always return NULL.
3541 **
3542 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3543 ** automatically freed when the prepared statement is finalized.
3544 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3545 ** is obtained from [sqlite3_malloc()] and must be free by the application
3546 ** by passing it to [sqlite3_free()].
3547 */
3548 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3549 SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3550
3551 /*
3552 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3553 ** METHOD: sqlite3_stmt
3554 **
@@ -4561,16 +4702,17 @@
4702 ** NULL if the metadata has been discarded.
4703 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4704 ** SQLite will invoke the destructor function X with parameter P exactly
4705 ** once, when the metadata is discarded.
4706 ** SQLite is free to discard the metadata at any time, including: <ul>
4707 ** <li> ^(when the corresponding function parameter changes)^, or
4708 ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4709 ** SQL statement)^, or
4710 ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
4711 ** parameter)^, or
4712 ** <li> ^(during the original sqlite3_set_auxdata() call when a memory
4713 ** allocation error occurs.)^ </ul>
4714 **
4715 ** Note the last bullet in particular. The destructor X in
4716 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4717 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4718 ** should be called near the end of the function implementation and the
@@ -5393,11 +5535,11 @@
5535 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
5536 ** the final five arguments with appropriate values if the specified
5537 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5538 ** SQLITE_ERROR and if the specified column does not exist.
5539 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5540 ** NULL pointer, then this routine simply checks for the existence of the
5541 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5542 ** does not.
5543 **
5544 ** ^The column is identified by the second, third and fourth parameters to
5545 ** this function. ^(The second parameter is either the name of the database
@@ -5527,12 +5669,12 @@
5669 ** to turn extension loading on and call it with onoff==0 to turn
5670 ** it back off again.
5671 **
5672 ** ^This interface enables or disables both the C-API
5673 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
5674 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
5675 ** to enable or disable only the C-API.)^
5676 **
5677 ** <b>Security warning:</b> It is recommended that extension loading
5678 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
5679 ** rather than this interface, so the [load_extension()] SQL function
5680 ** remains disabled. This will prevent SQL injections from giving attackers
@@ -5548,11 +5690,11 @@
5690 ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
5691 ** that is to be automatically loaded into all new database connections.
5692 **
5693 ** ^(Even though the function prototype shows that xEntryPoint() takes
5694 ** no arguments and returns void, SQLite invokes xEntryPoint() with three
5695 ** arguments and expects an integer result as if the signature of the
5696 ** entry point where as follows:
5697 **
5698 ** <blockquote><pre>
5699 ** &nbsp; int xEntryPoint(
5700 ** &nbsp; sqlite3 *db,
@@ -5574,11 +5716,11 @@
5716 ** will be called more than once for each database connection that is opened.
5717 **
5718 ** See also: [sqlite3_reset_auto_extension()]
5719 ** and [sqlite3_cancel_auto_extension()]
5720 */
5721 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
5722
5723 /*
5724 ** CAPI3REF: Cancel Automatic Extension Loading
5725 **
5726 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5586,11 +5728,11 @@
5728 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5729 ** routine returns 1 if initialization routine X was successfully
5730 ** unregistered and it returns 0 if X was not on the list of initialization
5731 ** routines.
5732 */
5733 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
5734
5735 /*
5736 ** CAPI3REF: Reset Automatic Extension Loading
5737 **
5738 ** ^This interface disables all automatic extensions previously
@@ -6762,10 +6904,22 @@
6904 ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
6905 ** <dd>This parameter returns the approximate number of bytes of heap
6906 ** memory used by all pager caches associated with the database connection.)^
6907 ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
6908 **
6909 ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
6910 ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
6911 ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
6912 ** pager cache is shared between two or more connections the bytes of heap
6913 ** memory used by that pager cache is divided evenly between the attached
6914 ** connections.)^ In other words, if none of the pager caches associated
6915 ** with the database connection are shared, this request returns the same
6916 ** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
6917 ** shared, the value returned by this call will be smaller than that returned
6918 ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
6919 ** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
6920 **
6921 ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
6922 ** <dd>This parameter returns the approximate number of bytes of heap
6923 ** memory used to store the schema for all databases associated
6924 ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
6925 ** ^The full amount of memory used by the schemas is reported, even if the
@@ -6819,11 +6973,12 @@
6973 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6974 #define SQLITE_DBSTATUS_CACHE_HIT 7
6975 #define SQLITE_DBSTATUS_CACHE_MISS 8
6976 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6977 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
6978 #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
6979 #define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
6980
6981
6982 /*
6983 ** CAPI3REF: Prepared Statement Status
6984 ** METHOD: sqlite3_stmt
@@ -7975,11 +8130,11 @@
8130 ** tables.
8131 **
8132 ** ^The second parameter to the preupdate callback is a pointer to
8133 ** the [database connection] that registered the preupdate hook.
8134 ** ^The third parameter to the preupdate callback is one of the constants
8135 ** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
8136 ** kind of update operation that is about to occur.
8137 ** ^(The fourth parameter to the preupdate callback is the name of the
8138 ** database within the database connection that is being modified. This
8139 ** will be "main" for the main database or "temp" for TEMP tables or
8140 ** the name given after the AS keyword in the [ATTACH] statement for attached
@@ -8202,11 +8357,11 @@
8357 #endif
8358
8359 #ifdef __cplusplus
8360 } /* End of the 'extern "C"' block */
8361 #endif
8362 #endif /* SQLITE3_H */
8363
8364 /******** Begin file sqlite3rtree.h *********/
8365 /*
8366 ** 2010 August 30
8367 **
@@ -9922,11 +10077,11 @@
10077 ** following structure. All structure methods must be defined, setting
10078 ** any member of the fts5_tokenizer struct to NULL leads to undefined
10079 ** behaviour. The structure methods are expected to function as follows:
10080 **
10081 ** xCreate:
10082 ** This function is used to allocate and initialize a tokenizer instance.
10083 ** A tokenizer instance is required to actually tokenize text.
10084 **
10085 ** The first argument passed to this function is a copy of the (void*)
10086 ** pointer provided by the application when the fts5_tokenizer object
10087 ** was registered with FTS5 (the third argument to xCreateTokenizer()).
@@ -10181,8 +10336,7 @@
10336 #ifdef __cplusplus
10337 } /* end of the 'extern "C"' block */
10338 #endif
10339
10340 #endif /* _FTS5_H */
 
10341
10342 /******** End of fts5.h *********/
10343
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
8383
8484
# define the SQLite files, which need special flags on compile
8585
SQLITESRC=sqlite3.c
8686
ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
8787
SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88
-SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_WIN32_NO_ANSI
88
+SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_WIN32_NO_ANSI
8989
9090
# define the SQLite shell files, which need special flags on compile
9191
SQLITESHELLSRC=shell.c
9292
ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
9393
SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
9494
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
83
84 # define the SQLite files, which need special flags on compile
85 SQLITESRC=sqlite3.c
86 ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
87 SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88 SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_WIN32_NO_ANSI
89
90 # define the SQLite shell files, which need special flags on compile
91 SQLITESHELLSRC=shell.c
92 ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
93 SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
94
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
83
84 # define the SQLite files, which need special flags on compile
85 SQLITESRC=sqlite3.c
86 ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
87 SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88 SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_WIN32_NO_ANSI
89
90 # define the SQLite shell files, which need special flags on compile
91 SQLITESHELLSRC=shell.c
92 ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
93 SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
94
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
2424
CFLAGS = -o
2525
BCC = $(DMDIR)\bin\dmc $(CFLAGS)
2626
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
2727
LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
2828
29
-SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
29
+SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
3030
3131
SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
3232
3333
SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
3434
3535
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
30
31 SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,11 +24,11 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
30
31 SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2134,11 +2134,10 @@
21342134
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
21352135
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
21362136
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
21372137
-DSQLITE_THREADSAFE=0 \
21382138
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
2139
- -DSQLITE_OMIT_DEPRECATED \
21402139
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
21412140
-DSQLITE_ENABLE_FTS4 \
21422141
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
21432142
-DSQLITE_ENABLE_DBSTAT_VTAB \
21442143
-DSQLITE_ENABLE_JSON1 \
21452144
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2134,11 +2134,10 @@
2134 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2135 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2136 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
2137 -DSQLITE_THREADSAFE=0 \
2138 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2139 -DSQLITE_OMIT_DEPRECATED \
2140 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2141 -DSQLITE_ENABLE_FTS4 \
2142 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2143 -DSQLITE_ENABLE_DBSTAT_VTAB \
2144 -DSQLITE_ENABLE_JSON1 \
2145
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2134,11 +2134,10 @@
2134 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2135 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2136 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
2137 -DSQLITE_THREADSAFE=0 \
2138 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
2139 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2140 -DSQLITE_ENABLE_FTS4 \
2141 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2142 -DSQLITE_ENABLE_DBSTAT_VTAB \
2143 -DSQLITE_ENABLE_JSON1 \
2144
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -2134,11 +2134,10 @@
21342134
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
21352135
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
21362136
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
21372137
-DSQLITE_THREADSAFE=0 \
21382138
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
2139
- -DSQLITE_OMIT_DEPRECATED \
21402139
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
21412140
-DSQLITE_ENABLE_FTS4 \
21422141
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
21432142
-DSQLITE_ENABLE_DBSTAT_VTAB \
21442143
-DSQLITE_ENABLE_JSON1 \
21452144
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -2134,11 +2134,10 @@
2134 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2135 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2136 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
2137 -DSQLITE_THREADSAFE=0 \
2138 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2139 -DSQLITE_OMIT_DEPRECATED \
2140 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2141 -DSQLITE_ENABLE_FTS4 \
2142 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2143 -DSQLITE_ENABLE_DBSTAT_VTAB \
2144 -DSQLITE_ENABLE_JSON1 \
2145
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -2134,11 +2134,10 @@
2134 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2135 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2136 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
2137 -DSQLITE_THREADSAFE=0 \
2138 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
2139 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2140 -DSQLITE_ENABLE_FTS4 \
2141 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2142 -DSQLITE_ENABLE_DBSTAT_VTAB \
2143 -DSQLITE_ENABLE_JSON1 \
2144
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -317,11 +317,10 @@
317317
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
318318
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
319319
/DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
320320
/DSQLITE_THREADSAFE=0 \
321321
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
322
- /DSQLITE_OMIT_DEPRECATED \
323322
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
324323
/DSQLITE_ENABLE_FTS4 \
325324
/DSQLITE_ENABLE_FTS3_PARENTHESIS \
326325
/DSQLITE_ENABLE_DBSTAT_VTAB \
327326
/DSQLITE_ENABLE_JSON1 \
328327
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -317,11 +317,10 @@
317 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
318 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
319 /DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
320 /DSQLITE_THREADSAFE=0 \
321 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
322 /DSQLITE_OMIT_DEPRECATED \
323 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
324 /DSQLITE_ENABLE_FTS4 \
325 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
326 /DSQLITE_ENABLE_DBSTAT_VTAB \
327 /DSQLITE_ENABLE_JSON1 \
328
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -317,11 +317,10 @@
317 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
318 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
319 /DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
320 /DSQLITE_THREADSAFE=0 \
321 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
322 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
323 /DSQLITE_ENABLE_FTS4 \
324 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
325 /DSQLITE_ENABLE_DBSTAT_VTAB \
326 /DSQLITE_ENABLE_JSON1 \
327
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,8 +1,13 @@
11
<title>Change Log</title>
22
3
-<h2>Changes for Version 1.35 (2016-00-00)</h2>
3
+<h2>Changes for Version 1.35.1 (2016-00-00)</h2>
4
+
5
+ * Update the built-in SQLite to version 3.14.1.
6
+ * Fix [https://www.mail-archive.com/[email protected]/msg23622.html|multi-line timeline bug]
7
+
8
+<h2>Changes for Version 1.35 (2016-06-14)</h2>
49
510
* Enable symlinks by default on all non-Windows platforms.
611
* Enhance the [/md_rules|Markdown formatting] so that hyperlinks that begin
712
with "/" are relative to the root of the Fossil repository.
813
* Rework the [/help?cmd=/setup_ulist|/setup_list page] (the User List page)
914
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,8 +1,13 @@
1 <title>Change Log</title>
2
3 <h2>Changes for Version 1.35 (2016-00-00)</h2>
 
 
 
 
 
4
5 * Enable symlinks by default on all non-Windows platforms.
6 * Enhance the [/md_rules|Markdown formatting] so that hyperlinks that begin
7 with "/" are relative to the root of the Fossil repository.
8 * Rework the [/help?cmd=/setup_ulist|/setup_list page] (the User List page)
9
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,8 +1,13 @@
1 <title>Change Log</title>
2
3 <h2>Changes for Version 1.35.1 (2016-00-00)</h2>
4
5 * Update the built-in SQLite to version 3.14.1.
6 * Fix [https://www.mail-archive.com/[email protected]/msg23622.html|multi-line timeline bug]
7
8 <h2>Changes for Version 1.35 (2016-06-14)</h2>
9
10 * Enable symlinks by default on all non-Windows platforms.
11 * Enhance the [/md_rules|Markdown formatting] so that hyperlinks that begin
12 with "/" are relative to the root of the Fossil repository.
13 * Rework the [/help?cmd=/setup_ulist|/setup_list page] (the User List page)
14

Keyboard Shortcuts

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