Fossil SCM

Suggestion for 2.3 release: Eliminate the need for SQLITE_PREPARE_PERSISTENT, which makes fossil work with SQLite 3.19.3.

jan.nijtmans 2017-07-03 10:36 UTC trunk
Commit 1eab060a84f24fa5d21c9d1d03754292f3ef45f74d19758cbb664068c8ce0089
5 files changed +4 -4 +5 -17 +1798 -2825 +43 -140 +1 -1
+4 -4
--- auto.def
+++ auto.def
@@ -88,17 +88,17 @@
8888
# the code below will append -ldl to LIBS.
8989
#
9090
foreach extralibs {{} {-ldl}} {
9191
9292
# Locate the system SQLite by searching for sqlite3_open(). Then check
93
- # if sqlite3_prepare_v3() can be found as well. If we can find open() but
94
- # not prepare_v3(), then the system SQLite is too old to link against
93
+ # if sqlite3_trace_v2() can be found as well. If we can find open() but
94
+ # not trace_v2(), then the system SQLite is too old to link against
9595
# fossil.
9696
#
9797
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
98
- if {![check-function-in-lib sqlite3_prepare_v3 sqlite3 $extralibs]} {
99
- user-error "system sqlite3 too old (require >= 3.20.0)"
98
+ if {![check-function-in-lib sqlite3_trace_v3 sqlite3 $extralibs]} {
99
+ user-error "system sqlite3 too old (require >= 3.14.0)"
100100
}
101101
102102
# Success. Update symbols and return.
103103
#
104104
define USE_SYSTEM_SQLITE 1
105105
--- auto.def
+++ auto.def
@@ -88,17 +88,17 @@
88 # the code below will append -ldl to LIBS.
89 #
90 foreach extralibs {{} {-ldl}} {
91
92 # Locate the system SQLite by searching for sqlite3_open(). Then check
93 # if sqlite3_prepare_v3() can be found as well. If we can find open() but
94 # not prepare_v3(), then the system SQLite is too old to link against
95 # fossil.
96 #
97 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
98 if {![check-function-in-lib sqlite3_prepare_v3 sqlite3 $extralibs]} {
99 user-error "system sqlite3 too old (require >= 3.20.0)"
100 }
101
102 # Success. Update symbols and return.
103 #
104 define USE_SYSTEM_SQLITE 1
105
--- auto.def
+++ auto.def
@@ -88,17 +88,17 @@
88 # the code below will append -ldl to LIBS.
89 #
90 foreach extralibs {{} {-ldl}} {
91
92 # Locate the system SQLite by searching for sqlite3_open(). Then check
93 # if sqlite3_trace_v2() can be found as well. If we can find open() but
94 # not trace_v2(), then the system SQLite is too old to link against
95 # fossil.
96 #
97 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
98 if {![check-function-in-lib sqlite3_trace_v3 sqlite3 $extralibs]} {
99 user-error "system sqlite3 too old (require >= 3.14.0)"
100 }
101
102 # Success. Update symbols and return.
103 #
104 define USE_SYSTEM_SQLITE 1
105
+5 -17
--- src/db.c
+++ src/db.c
@@ -242,37 +242,25 @@
242242
db.aHook[db.nCommitHook].sequence = sequence;
243243
db.aHook[db.nCommitHook].xHook = x;
244244
db.nCommitHook++;
245245
}
246246
247
-#if INTERFACE
248
-/*
249
-** Possible flags to db_vprepare
250
-*/
251
-#define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
252
-#define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
253
-#endif
254
-
255247
/*
256248
** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
257249
** If the input string contains multiple SQL statements, only the first
258250
** one is processed. All statements beyond the first are silently ignored.
259251
*/
260
-int db_vprepare(Stmt *pStmt, int flags, const char *zFormat, va_list ap){
252
+int db_vprepare(Stmt *pStmt, int errOk, const char *zFormat, va_list ap){
261253
int rc;
262
- int prepFlags = 0;
263254
char *zSql;
264255
blob_zero(&pStmt->sql);
265256
blob_vappendf(&pStmt->sql, zFormat, ap);
266257
va_end(ap);
267258
zSql = blob_str(&pStmt->sql);
268259
db.nPrepare++;
269
- if( flags & DB_PREPARE_PERSISTENT ){
270
- prepFlags = SQLITE_PREPARE_PERSISTENT;
271
- }
272
- rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
273
- if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)!=0 ){
260
+ rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0);
261
+ if( rc!=0 && !errOk ){
274262
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
275263
}
276264
pStmt->pNext = pStmt->pPrev = 0;
277265
pStmt->nStep = 0;
278266
return rc;
@@ -287,20 +275,20 @@
287275
}
288276
int db_prepare_ignore_error(Stmt *pStmt, const char *zFormat, ...){
289277
int rc;
290278
va_list ap;
291279
va_start(ap, zFormat);
292
- rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
280
+ rc = db_vprepare(pStmt, 1, zFormat, ap);
293281
va_end(ap);
294282
return rc;
295283
}
296284
int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
297285
int rc = SQLITE_OK;
298286
if( blob_size(&pStmt->sql)==0 ){
299287
va_list ap;
300288
va_start(ap, zFormat);
301
- rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
289
+ rc = db_vprepare(pStmt, 0, zFormat, ap);
302290
pStmt->pNext = db.pAllStmt;
303291
pStmt->pPrev = 0;
304292
if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
305293
db.pAllStmt = pStmt;
306294
va_end(ap);
307295
--- src/db.c
+++ src/db.c
@@ -242,37 +242,25 @@
242 db.aHook[db.nCommitHook].sequence = sequence;
243 db.aHook[db.nCommitHook].xHook = x;
244 db.nCommitHook++;
245 }
246
247 #if INTERFACE
248 /*
249 ** Possible flags to db_vprepare
250 */
251 #define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
252 #define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
253 #endif
254
255 /*
256 ** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
257 ** If the input string contains multiple SQL statements, only the first
258 ** one is processed. All statements beyond the first are silently ignored.
259 */
260 int db_vprepare(Stmt *pStmt, int flags, const char *zFormat, va_list ap){
261 int rc;
262 int prepFlags = 0;
263 char *zSql;
264 blob_zero(&pStmt->sql);
265 blob_vappendf(&pStmt->sql, zFormat, ap);
266 va_end(ap);
267 zSql = blob_str(&pStmt->sql);
268 db.nPrepare++;
269 if( flags & DB_PREPARE_PERSISTENT ){
270 prepFlags = SQLITE_PREPARE_PERSISTENT;
271 }
272 rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
273 if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)!=0 ){
274 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
275 }
276 pStmt->pNext = pStmt->pPrev = 0;
277 pStmt->nStep = 0;
278 return rc;
@@ -287,20 +275,20 @@
287 }
288 int db_prepare_ignore_error(Stmt *pStmt, const char *zFormat, ...){
289 int rc;
290 va_list ap;
291 va_start(ap, zFormat);
292 rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
293 va_end(ap);
294 return rc;
295 }
296 int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
297 int rc = SQLITE_OK;
298 if( blob_size(&pStmt->sql)==0 ){
299 va_list ap;
300 va_start(ap, zFormat);
301 rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
302 pStmt->pNext = db.pAllStmt;
303 pStmt->pPrev = 0;
304 if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
305 db.pAllStmt = pStmt;
306 va_end(ap);
307
--- src/db.c
+++ src/db.c
@@ -242,37 +242,25 @@
242 db.aHook[db.nCommitHook].sequence = sequence;
243 db.aHook[db.nCommitHook].xHook = x;
244 db.nCommitHook++;
245 }
246
 
 
 
 
 
 
 
 
247 /*
248 ** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
249 ** If the input string contains multiple SQL statements, only the first
250 ** one is processed. All statements beyond the first are silently ignored.
251 */
252 int db_vprepare(Stmt *pStmt, int errOk, const char *zFormat, va_list ap){
253 int rc;
 
254 char *zSql;
255 blob_zero(&pStmt->sql);
256 blob_vappendf(&pStmt->sql, zFormat, ap);
257 va_end(ap);
258 zSql = blob_str(&pStmt->sql);
259 db.nPrepare++;
260 rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0);
261 if( rc!=0 && !errOk ){
 
 
 
262 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
263 }
264 pStmt->pNext = pStmt->pPrev = 0;
265 pStmt->nStep = 0;
266 return rc;
@@ -287,20 +275,20 @@
275 }
276 int db_prepare_ignore_error(Stmt *pStmt, const char *zFormat, ...){
277 int rc;
278 va_list ap;
279 va_start(ap, zFormat);
280 rc = db_vprepare(pStmt, 1, zFormat, ap);
281 va_end(ap);
282 return rc;
283 }
284 int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
285 int rc = SQLITE_OK;
286 if( blob_size(&pStmt->sql)==0 ){
287 va_list ap;
288 va_start(ap, zFormat);
289 rc = db_vprepare(pStmt, 0, zFormat, ap);
290 pStmt->pNext = db.pAllStmt;
291 pStmt->pPrev = 0;
292 if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
293 db.pAllStmt = pStmt;
294 va_end(ap);
295
+1798 -2825
--- 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.20.0. By combining all the individual C code files into this
3
+** version 3.19.3. 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.
@@ -20,762 +20,10 @@
2020
#define SQLITE_CORE 1
2121
#define SQLITE_AMALGAMATION 1
2222
#ifndef SQLITE_PRIVATE
2323
# define SQLITE_PRIVATE static
2424
#endif
25
-/************** Begin file ctime.c *******************************************/
26
-/*
27
-** 2010 February 23
28
-**
29
-** The author disclaims copyright to this source code. In place of
30
-** a legal notice, here is a blessing:
31
-**
32
-** May you do good and not evil.
33
-** May you find forgiveness for yourself and forgive others.
34
-** May you share freely, never taking more than you give.
35
-**
36
-*************************************************************************
37
-**
38
-** This file implements routines used to report what compile-time options
39
-** SQLite was built with.
40
-*/
41
-
42
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
43
-
44
-/*
45
-** Include the configuration header output by 'configure' if we're using the
46
-** autoconf-based build
47
-*/
48
-#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49
-#include "config.h"
50
-#define SQLITECONFIG_H 1
51
-#endif
52
-
53
-/* These macros are provided to "stringify" the value of the define
54
-** for those options in which the value is meaningful. */
55
-#define CTIMEOPT_VAL_(opt) #opt
56
-#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
-
58
-/*
59
-** An array of names of all compile-time options. This array should
60
-** be sorted A-Z.
61
-**
62
-** This array looks large, but in a typical installation actually uses
63
-** only a handful of compile-time options, so most times this array is usually
64
-** rather short and uses little memory space.
65
-*/
66
-static const char * const sqlite3azCompileOpt[] = {
67
-
68
-/*
69
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
70
-*/
71
-#if SQLITE_32BIT_ROWID
72
- "32BIT_ROWID",
73
-#endif
74
-#if SQLITE_4_BYTE_ALIGNED_MALLOC
75
- "4_BYTE_ALIGNED_MALLOC",
76
-#endif
77
-#if SQLITE_64BIT_STATS
78
- "64BIT_STATS",
79
-#endif
80
-#if SQLITE_ALLOW_COVERING_INDEX_SCAN
81
- "ALLOW_COVERING_INDEX_SCAN",
82
-#endif
83
-#if SQLITE_ALLOW_URI_AUTHORITY
84
- "ALLOW_URI_AUTHORITY",
85
-#endif
86
-#ifdef SQLITE_BITMASK_TYPE
87
- "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
88
-#endif
89
-#if SQLITE_BUG_COMPATIBLE_20160819
90
- "BUG_COMPATIBLE_20160819",
91
-#endif
92
-#if SQLITE_CASE_SENSITIVE_LIKE
93
- "CASE_SENSITIVE_LIKE",
94
-#endif
95
-#if SQLITE_CHECK_PAGES
96
- "CHECK_PAGES",
97
-#endif
98
-#if defined(__clang__) && defined(__clang_major__)
99
- "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
100
- CTIMEOPT_VAL(__clang_minor__) "."
101
- CTIMEOPT_VAL(__clang_patchlevel__),
102
-#elif defined(_MSC_VER)
103
- "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
104
-#elif defined(__GNUC__) && defined(__VERSION__)
105
- "COMPILER=gcc-" __VERSION__,
106
-#endif
107
-#if SQLITE_COVERAGE_TEST
108
- "COVERAGE_TEST",
109
-#endif
110
-#if SQLITE_DEBUG
111
- "DEBUG",
112
-#endif
113
-#if SQLITE_DEFAULT_AUTOMATIC_INDEX
114
- "DEFAULT_AUTOMATIC_INDEX",
115
-#endif
116
-#if SQLITE_DEFAULT_AUTOVACUUM
117
- "DEFAULT_AUTOVACUUM",
118
-#endif
119
-#ifdef SQLITE_DEFAULT_CACHE_SIZE
120
- "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
121
-#endif
122
-#if SQLITE_DEFAULT_CKPTFULLFSYNC
123
- "DEFAULT_CKPTFULLFSYNC",
124
-#endif
125
-#ifdef SQLITE_DEFAULT_FILE_FORMAT
126
- "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
127
-#endif
128
-#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
129
- "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
130
-#endif
131
-#if SQLITE_DEFAULT_FOREIGN_KEYS
132
- "DEFAULT_FOREIGN_KEYS",
133
-#endif
134
-#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
135
- "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
136
-#endif
137
-#ifdef SQLITE_DEFAULT_LOCKING_MODE
138
- "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
139
-#endif
140
-#ifdef SQLITE_DEFAULT_LOOKASIDE
141
- "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
142
-#endif
143
-#if SQLITE_DEFAULT_MEMSTATUS
144
- "DEFAULT_MEMSTATUS",
145
-#endif
146
-#ifdef SQLITE_DEFAULT_MMAP_SIZE
147
- "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
148
-#endif
149
-#ifdef SQLITE_DEFAULT_PAGE_SIZE
150
- "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
151
-#endif
152
-#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
153
- "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
154
-#endif
155
-#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
156
- "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
157
-#endif
158
-#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
159
- "DEFAULT_RECURSIVE_TRIGGERS",
160
-#endif
161
-#ifdef SQLITE_DEFAULT_ROWEST
162
- "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
163
-#endif
164
-#ifdef SQLITE_DEFAULT_SECTOR_SIZE
165
- "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
166
-#endif
167
-#ifdef SQLITE_DEFAULT_SYNCHRONOUS
168
- "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
169
-#endif
170
-#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
171
- "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
172
-#endif
173
-#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
174
- "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
175
-#endif
176
-#ifdef SQLITE_DEFAULT_WORKER_THREADS
177
- "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
178
-#endif
179
-#if SQLITE_DIRECT_OVERFLOW_READ
180
- "DIRECT_OVERFLOW_READ",
181
-#endif
182
-#if SQLITE_DISABLE_DIRSYNC
183
- "DISABLE_DIRSYNC",
184
-#endif
185
-#if SQLITE_DISABLE_FTS3_UNICODE
186
- "DISABLE_FTS3_UNICODE",
187
-#endif
188
-#if SQLITE_DISABLE_FTS4_DEFERRED
189
- "DISABLE_FTS4_DEFERRED",
190
-#endif
191
-#if SQLITE_DISABLE_INTRINSIC
192
- "DISABLE_INTRINSIC",
193
-#endif
194
-#if SQLITE_DISABLE_LFS
195
- "DISABLE_LFS",
196
-#endif
197
-#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
198
- "DISABLE_PAGECACHE_OVERFLOW_STATS",
199
-#endif
200
-#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
201
- "DISABLE_SKIPAHEAD_DISTINCT",
202
-#endif
203
-#ifdef SQLITE_ENABLE_8_3_NAMES
204
- "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
205
-#endif
206
-#if SQLITE_ENABLE_API_ARMOR
207
- "ENABLE_API_ARMOR",
208
-#endif
209
-#if SQLITE_ENABLE_ATOMIC_WRITE
210
- "ENABLE_ATOMIC_WRITE",
211
-#endif
212
-#if SQLITE_ENABLE_CEROD
213
- "ENABLE_CEROD",
214
-#endif
215
-#if SQLITE_ENABLE_COLUMN_METADATA
216
- "ENABLE_COLUMN_METADATA",
217
-#endif
218
-#if SQLITE_ENABLE_COLUMN_USED_MASK
219
- "ENABLE_COLUMN_USED_MASK",
220
-#endif
221
-#if SQLITE_ENABLE_COSTMULT
222
- "ENABLE_COSTMULT",
223
-#endif
224
-#if SQLITE_ENABLE_CURSOR_HINTS
225
- "ENABLE_CURSOR_HINTS",
226
-#endif
227
-#if SQLITE_ENABLE_DBSTAT_VTAB
228
- "ENABLE_DBSTAT_VTAB",
229
-#endif
230
-#if SQLITE_ENABLE_EXPENSIVE_ASSERT
231
- "ENABLE_EXPENSIVE_ASSERT",
232
-#endif
233
-#if SQLITE_ENABLE_FTS1
234
- "ENABLE_FTS1",
235
-#endif
236
-#if SQLITE_ENABLE_FTS2
237
- "ENABLE_FTS2",
238
-#endif
239
-#if SQLITE_ENABLE_FTS3
240
- "ENABLE_FTS3",
241
-#endif
242
-#if SQLITE_ENABLE_FTS3_PARENTHESIS
243
- "ENABLE_FTS3_PARENTHESIS",
244
-#endif
245
-#if SQLITE_ENABLE_FTS3_TOKENIZER
246
- "ENABLE_FTS3_TOKENIZER",
247
-#endif
248
-#if SQLITE_ENABLE_FTS4
249
- "ENABLE_FTS4",
250
-#endif
251
-#if SQLITE_ENABLE_FTS5
252
- "ENABLE_FTS5",
253
-#endif
254
-#if SQLITE_ENABLE_HIDDEN_COLUMNS
255
- "ENABLE_HIDDEN_COLUMNS",
256
-#endif
257
-#if SQLITE_ENABLE_ICU
258
- "ENABLE_ICU",
259
-#endif
260
-#if SQLITE_ENABLE_IOTRACE
261
- "ENABLE_IOTRACE",
262
-#endif
263
-#if SQLITE_ENABLE_JSON1
264
- "ENABLE_JSON1",
265
-#endif
266
-#if SQLITE_ENABLE_LOAD_EXTENSION
267
- "ENABLE_LOAD_EXTENSION",
268
-#endif
269
-#ifdef SQLITE_ENABLE_LOCKING_STYLE
270
- "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
271
-#endif
272
-#if SQLITE_ENABLE_MEMORY_MANAGEMENT
273
- "ENABLE_MEMORY_MANAGEMENT",
274
-#endif
275
-#if SQLITE_ENABLE_MEMSYS3
276
- "ENABLE_MEMSYS3",
277
-#endif
278
-#if SQLITE_ENABLE_MEMSYS5
279
- "ENABLE_MEMSYS5",
280
-#endif
281
-#if SQLITE_ENABLE_MULTIPLEX
282
- "ENABLE_MULTIPLEX",
283
-#endif
284
-#if SQLITE_ENABLE_NULL_TRIM
285
- "ENABLE_NULL_TRIM",
286
-#endif
287
-#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
288
- "ENABLE_OVERSIZE_CELL_CHECK",
289
-#endif
290
-#if SQLITE_ENABLE_PREUPDATE_HOOK
291
- "ENABLE_PREUPDATE_HOOK",
292
-#endif
293
-#if SQLITE_ENABLE_QPSG
294
- "ENABLE_QPSG",
295
-#endif
296
-#if SQLITE_ENABLE_RBU
297
- "ENABLE_RBU",
298
-#endif
299
-#if SQLITE_ENABLE_RTREE
300
- "ENABLE_RTREE",
301
-#endif
302
-#if SQLITE_ENABLE_SELECTTRACE
303
- "ENABLE_SELECTTRACE",
304
-#endif
305
-#if SQLITE_ENABLE_SESSION
306
- "ENABLE_SESSION",
307
-#endif
308
-#if SQLITE_ENABLE_SNAPSHOT
309
- "ENABLE_SNAPSHOT",
310
-#endif
311
-#if SQLITE_ENABLE_SQLLOG
312
- "ENABLE_SQLLOG",
313
-#endif
314
-#if defined(SQLITE_ENABLE_STAT4)
315
- "ENABLE_STAT4",
316
-#elif defined(SQLITE_ENABLE_STAT3)
317
- "ENABLE_STAT3",
318
-#endif
319
-#if SQLITE_ENABLE_STMTVTAB
320
- "ENABLE_STMTVTAB",
321
-#endif
322
-#if SQLITE_ENABLE_STMT_SCANSTATUS
323
- "ENABLE_STMT_SCANSTATUS",
324
-#endif
325
-#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
326
- "ENABLE_UNKNOWN_SQL_FUNCTION",
327
-#endif
328
-#if SQLITE_ENABLE_UNLOCK_NOTIFY
329
- "ENABLE_UNLOCK_NOTIFY",
330
-#endif
331
-#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
332
- "ENABLE_UPDATE_DELETE_LIMIT",
333
-#endif
334
-#if SQLITE_ENABLE_URI_00_ERROR
335
- "ENABLE_URI_00_ERROR",
336
-#endif
337
-#if SQLITE_ENABLE_VFSTRACE
338
- "ENABLE_VFSTRACE",
339
-#endif
340
-#if SQLITE_ENABLE_WHERETRACE
341
- "ENABLE_WHERETRACE",
342
-#endif
343
-#if SQLITE_ENABLE_ZIPVFS
344
- "ENABLE_ZIPVFS",
345
-#endif
346
-#if SQLITE_EXPLAIN_ESTIMATED_ROWS
347
- "EXPLAIN_ESTIMATED_ROWS",
348
-#endif
349
-#if SQLITE_EXTRA_IFNULLROW
350
- "EXTRA_IFNULLROW",
351
-#endif
352
-#ifdef SQLITE_EXTRA_INIT
353
- "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
354
-#endif
355
-#ifdef SQLITE_EXTRA_SHUTDOWN
356
- "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
357
-#endif
358
-#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
359
- "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
360
-#endif
361
-#if SQLITE_FTS5_ENABLE_TEST_MI
362
- "FTS5_ENABLE_TEST_MI",
363
-#endif
364
-#if SQLITE_FTS5_NO_WITHOUT_ROWID
365
- "FTS5_NO_WITHOUT_ROWID",
366
-#endif
367
-#if SQLITE_HAS_CODEC
368
- "HAS_CODEC",
369
-#endif
370
-#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
371
- "HAVE_ISNAN",
372
-#endif
373
-#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
374
- "HOMEGROWN_RECURSIVE_MUTEX",
375
-#endif
376
-#if SQLITE_IGNORE_AFP_LOCK_ERRORS
377
- "IGNORE_AFP_LOCK_ERRORS",
378
-#endif
379
-#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
380
- "IGNORE_FLOCK_LOCK_ERRORS",
381
-#endif
382
-#if SQLITE_INLINE_MEMCPY
383
- "INLINE_MEMCPY",
384
-#endif
385
-#if SQLITE_INT64_TYPE
386
- "INT64_TYPE",
387
-#endif
388
-#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
389
- "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
390
-#endif
391
-#if SQLITE_LIKE_DOESNT_MATCH_BLOBS
392
- "LIKE_DOESNT_MATCH_BLOBS",
393
-#endif
394
-#if SQLITE_LOCK_TRACE
395
- "LOCK_TRACE",
396
-#endif
397
-#if SQLITE_LOG_CACHE_SPILL
398
- "LOG_CACHE_SPILL",
399
-#endif
400
-#ifdef SQLITE_MALLOC_SOFT_LIMIT
401
- "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
402
-#endif
403
-#ifdef SQLITE_MAX_ATTACHED
404
- "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
405
-#endif
406
-#ifdef SQLITE_MAX_COLUMN
407
- "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
408
-#endif
409
-#ifdef SQLITE_MAX_COMPOUND_SELECT
410
- "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
411
-#endif
412
-#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
413
- "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
414
-#endif
415
-#ifdef SQLITE_MAX_EXPR_DEPTH
416
- "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
417
-#endif
418
-#ifdef SQLITE_MAX_FUNCTION_ARG
419
- "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
420
-#endif
421
-#ifdef SQLITE_MAX_LENGTH
422
- "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
423
-#endif
424
-#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
425
- "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
426
-#endif
427
-#ifdef SQLITE_MAX_MEMORY
428
- "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
429
-#endif
430
-#ifdef SQLITE_MAX_MMAP_SIZE
431
- "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
432
-#endif
433
-#ifdef SQLITE_MAX_MMAP_SIZE_
434
- "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
435
-#endif
436
-#ifdef SQLITE_MAX_PAGE_COUNT
437
- "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
438
-#endif
439
-#ifdef SQLITE_MAX_PAGE_SIZE
440
- "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
441
-#endif
442
-#ifdef SQLITE_MAX_SCHEMA_RETRY
443
- "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
444
-#endif
445
-#ifdef SQLITE_MAX_SQL_LENGTH
446
- "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
447
-#endif
448
-#ifdef SQLITE_MAX_TRIGGER_DEPTH
449
- "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
450
-#endif
451
-#ifdef SQLITE_MAX_VARIABLE_NUMBER
452
- "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
453
-#endif
454
-#ifdef SQLITE_MAX_VDBE_OP
455
- "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
456
-#endif
457
-#ifdef SQLITE_MAX_WORKER_THREADS
458
- "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
459
-#endif
460
-#if SQLITE_MEMDEBUG
461
- "MEMDEBUG",
462
-#endif
463
-#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
464
- "MIXED_ENDIAN_64BIT_FLOAT",
465
-#endif
466
-#if SQLITE_MMAP_READWRITE
467
- "MMAP_READWRITE",
468
-#endif
469
-#if SQLITE_MUTEX_NOOP
470
- "MUTEX_NOOP",
471
-#endif
472
-#if SQLITE_MUTEX_NREF
473
- "MUTEX_NREF",
474
-#endif
475
-#if SQLITE_MUTEX_OMIT
476
- "MUTEX_OMIT",
477
-#endif
478
-#if SQLITE_MUTEX_PTHREADS
479
- "MUTEX_PTHREADS",
480
-#endif
481
-#if SQLITE_MUTEX_W32
482
- "MUTEX_W32",
483
-#endif
484
-#if SQLITE_NEED_ERR_NAME
485
- "NEED_ERR_NAME",
486
-#endif
487
-#if SQLITE_NOINLINE
488
- "NOINLINE",
489
-#endif
490
-#if SQLITE_NO_SYNC
491
- "NO_SYNC",
492
-#endif
493
-#if SQLITE_OMIT_ALTERTABLE
494
- "OMIT_ALTERTABLE",
495
-#endif
496
-#if SQLITE_OMIT_ANALYZE
497
- "OMIT_ANALYZE",
498
-#endif
499
-#if SQLITE_OMIT_ATTACH
500
- "OMIT_ATTACH",
501
-#endif
502
-#if SQLITE_OMIT_AUTHORIZATION
503
- "OMIT_AUTHORIZATION",
504
-#endif
505
-#if SQLITE_OMIT_AUTOINCREMENT
506
- "OMIT_AUTOINCREMENT",
507
-#endif
508
-#if SQLITE_OMIT_AUTOINIT
509
- "OMIT_AUTOINIT",
510
-#endif
511
-#if SQLITE_OMIT_AUTOMATIC_INDEX
512
- "OMIT_AUTOMATIC_INDEX",
513
-#endif
514
-#if SQLITE_OMIT_AUTORESET
515
- "OMIT_AUTORESET",
516
-#endif
517
-#if SQLITE_OMIT_AUTOVACUUM
518
- "OMIT_AUTOVACUUM",
519
-#endif
520
-#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
521
- "OMIT_BETWEEN_OPTIMIZATION",
522
-#endif
523
-#if SQLITE_OMIT_BLOB_LITERAL
524
- "OMIT_BLOB_LITERAL",
525
-#endif
526
-#if SQLITE_OMIT_BTREECOUNT
527
- "OMIT_BTREECOUNT",
528
-#endif
529
-#if SQLITE_OMIT_CAST
530
- "OMIT_CAST",
531
-#endif
532
-#if SQLITE_OMIT_CHECK
533
- "OMIT_CHECK",
534
-#endif
535
-#if SQLITE_OMIT_COMPLETE
536
- "OMIT_COMPLETE",
537
-#endif
538
-#if SQLITE_OMIT_COMPOUND_SELECT
539
- "OMIT_COMPOUND_SELECT",
540
-#endif
541
-#if SQLITE_OMIT_CONFLICT_CLAUSE
542
- "OMIT_CONFLICT_CLAUSE",
543
-#endif
544
-#if SQLITE_OMIT_CTE
545
- "OMIT_CTE",
546
-#endif
547
-#if SQLITE_OMIT_DATETIME_FUNCS
548
- "OMIT_DATETIME_FUNCS",
549
-#endif
550
-#if SQLITE_OMIT_DECLTYPE
551
- "OMIT_DECLTYPE",
552
-#endif
553
-#if SQLITE_OMIT_DEPRECATED
554
- "OMIT_DEPRECATED",
555
-#endif
556
-#if SQLITE_OMIT_DISKIO
557
- "OMIT_DISKIO",
558
-#endif
559
-#if SQLITE_OMIT_EXPLAIN
560
- "OMIT_EXPLAIN",
561
-#endif
562
-#if SQLITE_OMIT_FLAG_PRAGMAS
563
- "OMIT_FLAG_PRAGMAS",
564
-#endif
565
-#if SQLITE_OMIT_FLOATING_POINT
566
- "OMIT_FLOATING_POINT",
567
-#endif
568
-#if SQLITE_OMIT_FOREIGN_KEY
569
- "OMIT_FOREIGN_KEY",
570
-#endif
571
-#if SQLITE_OMIT_GET_TABLE
572
- "OMIT_GET_TABLE",
573
-#endif
574
-#if SQLITE_OMIT_HEX_INTEGER
575
- "OMIT_HEX_INTEGER",
576
-#endif
577
-#if SQLITE_OMIT_INCRBLOB
578
- "OMIT_INCRBLOB",
579
-#endif
580
-#if SQLITE_OMIT_INTEGRITY_CHECK
581
- "OMIT_INTEGRITY_CHECK",
582
-#endif
583
-#if SQLITE_OMIT_LIKE_OPTIMIZATION
584
- "OMIT_LIKE_OPTIMIZATION",
585
-#endif
586
-#if SQLITE_OMIT_LOAD_EXTENSION
587
- "OMIT_LOAD_EXTENSION",
588
-#endif
589
-#if SQLITE_OMIT_LOCALTIME
590
- "OMIT_LOCALTIME",
591
-#endif
592
-#if SQLITE_OMIT_LOOKASIDE
593
- "OMIT_LOOKASIDE",
594
-#endif
595
-#if SQLITE_OMIT_MEMORYDB
596
- "OMIT_MEMORYDB",
597
-#endif
598
-#if SQLITE_OMIT_OR_OPTIMIZATION
599
- "OMIT_OR_OPTIMIZATION",
600
-#endif
601
-#if SQLITE_OMIT_PAGER_PRAGMAS
602
- "OMIT_PAGER_PRAGMAS",
603
-#endif
604
-#if SQLITE_OMIT_PARSER_TRACE
605
- "OMIT_PARSER_TRACE",
606
-#endif
607
-#if SQLITE_OMIT_POPEN
608
- "OMIT_POPEN",
609
-#endif
610
-#if SQLITE_OMIT_PRAGMA
611
- "OMIT_PRAGMA",
612
-#endif
613
-#if SQLITE_OMIT_PROGRESS_CALLBACK
614
- "OMIT_PROGRESS_CALLBACK",
615
-#endif
616
-#if SQLITE_OMIT_QUICKBALANCE
617
- "OMIT_QUICKBALANCE",
618
-#endif
619
-#if SQLITE_OMIT_REINDEX
620
- "OMIT_REINDEX",
621
-#endif
622
-#if SQLITE_OMIT_SCHEMA_PRAGMAS
623
- "OMIT_SCHEMA_PRAGMAS",
624
-#endif
625
-#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
626
- "OMIT_SCHEMA_VERSION_PRAGMAS",
627
-#endif
628
-#if SQLITE_OMIT_SHARED_CACHE
629
- "OMIT_SHARED_CACHE",
630
-#endif
631
-#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
632
- "OMIT_SHUTDOWN_DIRECTORIES",
633
-#endif
634
-#if SQLITE_OMIT_SUBQUERY
635
- "OMIT_SUBQUERY",
636
-#endif
637
-#if SQLITE_OMIT_TCL_VARIABLE
638
- "OMIT_TCL_VARIABLE",
639
-#endif
640
-#if SQLITE_OMIT_TEMPDB
641
- "OMIT_TEMPDB",
642
-#endif
643
-#if SQLITE_OMIT_TEST_CONTROL
644
- "OMIT_TEST_CONTROL",
645
-#endif
646
-#if SQLITE_OMIT_TRACE
647
- "OMIT_TRACE",
648
-#endif
649
-#if SQLITE_OMIT_TRIGGER
650
- "OMIT_TRIGGER",
651
-#endif
652
-#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
653
- "OMIT_TRUNCATE_OPTIMIZATION",
654
-#endif
655
-#if SQLITE_OMIT_UTF16
656
- "OMIT_UTF16",
657
-#endif
658
-#if SQLITE_OMIT_VACUUM
659
- "OMIT_VACUUM",
660
-#endif
661
-#if SQLITE_OMIT_VIEW
662
- "OMIT_VIEW",
663
-#endif
664
-#if SQLITE_OMIT_VIRTUALTABLE
665
- "OMIT_VIRTUALTABLE",
666
-#endif
667
-#if SQLITE_OMIT_WAL
668
- "OMIT_WAL",
669
-#endif
670
-#if SQLITE_OMIT_WSD
671
- "OMIT_WSD",
672
-#endif
673
-#if SQLITE_OMIT_XFER_OPT
674
- "OMIT_XFER_OPT",
675
-#endif
676
-#if SQLITE_PCACHE_SEPARATE_HEADER
677
- "PCACHE_SEPARATE_HEADER",
678
-#endif
679
-#if SQLITE_PERFORMANCE_TRACE
680
- "PERFORMANCE_TRACE",
681
-#endif
682
-#if SQLITE_POWERSAFE_OVERWRITE
683
- "POWERSAFE_OVERWRITE",
684
-#endif
685
-#if SQLITE_PREFER_PROXY_LOCKING
686
- "PREFER_PROXY_LOCKING",
687
-#endif
688
-#if SQLITE_PROXY_DEBUG
689
- "PROXY_DEBUG",
690
-#endif
691
-#if SQLITE_REVERSE_UNORDERED_SELECTS
692
- "REVERSE_UNORDERED_SELECTS",
693
-#endif
694
-#if SQLITE_RTREE_INT_ONLY
695
- "RTREE_INT_ONLY",
696
-#endif
697
-#if SQLITE_SECURE_DELETE
698
- "SECURE_DELETE",
699
-#endif
700
-#if SQLITE_SMALL_STACK
701
- "SMALL_STACK",
702
-#endif
703
-#ifdef SQLITE_SORTER_PMASZ
704
- "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
705
-#endif
706
-#if SQLITE_SOUNDEX
707
- "SOUNDEX",
708
-#endif
709
-#ifdef SQLITE_STAT4_SAMPLES
710
- "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
711
-#endif
712
-#ifdef SQLITE_STMTJRNL_SPILL
713
- "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
714
-#endif
715
-#if SQLITE_SUBSTR_COMPATIBILITY
716
- "SUBSTR_COMPATIBILITY",
717
-#endif
718
-#if SQLITE_SYSTEM_MALLOC
719
- "SYSTEM_MALLOC",
720
-#endif
721
-#if SQLITE_TCL
722
- "TCL",
723
-#endif
724
-#ifdef SQLITE_TEMP_STORE
725
- "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
726
-#endif
727
-#if SQLITE_TEST
728
- "TEST",
729
-#endif
730
-#if defined(SQLITE_THREADSAFE)
731
- "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
732
-#elif defined(THREADSAFE)
733
- "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
734
-#else
735
- "THREADSAFE=1",
736
-#endif
737
-#if SQLITE_UNLINK_AFTER_CLOSE
738
- "UNLINK_AFTER_CLOSE",
739
-#endif
740
-#if SQLITE_UNTESTABLE
741
- "UNTESTABLE",
742
-#endif
743
-#if SQLITE_USER_AUTHENTICATION
744
- "USER_AUTHENTICATION",
745
-#endif
746
-#if SQLITE_USE_ALLOCA
747
- "USE_ALLOCA",
748
-#endif
749
-#if SQLITE_USE_FCNTL_TRACE
750
- "USE_FCNTL_TRACE",
751
-#endif
752
-#if SQLITE_USE_URI
753
- "USE_URI",
754
-#endif
755
-#if SQLITE_VDBE_COVERAGE
756
- "VDBE_COVERAGE",
757
-#endif
758
-#if SQLITE_WIN32_MALLOC
759
- "WIN32_MALLOC",
760
-#endif
761
-#if SQLITE_ZERO_MALLOC
762
- "ZERO_MALLOC",
763
-#endif
764
-/*
765
-** END CODE GENERATED BY tool/mkctime.tcl
766
-*/
767
-};
768
-
769
-SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
770
- *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
771
- return (const char**)sqlite3azCompileOpt;
772
-}
773
-
774
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
775
-
776
-/************** End of ctime.c ***********************************************/
77725
/************** Begin file sqliteInt.h ***************************************/
77826
/*
77927
** 2001 September 15
78028
**
78129
** The author disclaims copyright to this source code. In place of
@@ -1026,11 +274,11 @@
1026274
** MinGW.
1027275
*/
1028276
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
1029277
/************** Begin file sqlite3.h *****************************************/
1030278
/*
1031
-** 2001-09-15
279
+** 2001 September 15
1032280
**
1033281
** The author disclaims copyright to this source code. In place of
1034282
** a legal notice, here is a blessing:
1035283
**
1036284
** May you do good and not evil.
@@ -1148,13 +396,13 @@
1148396
**
1149397
** See also: [sqlite3_libversion()],
1150398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151399
** [sqlite_version()] and [sqlite_source_id()].
1152400
*/
1153
-#define SQLITE_VERSION "3.20.0"
1154
-#define SQLITE_VERSION_NUMBER 3020000
1155
-#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
401
+#define SQLITE_VERSION "3.19.3"
402
+#define SQLITE_VERSION_NUMBER 3019003
403
+#define SQLITE_SOURCE_ID "2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b"
1156404
1157405
/*
1158406
** CAPI3REF: Run-Time Library Version Numbers
1159407
** KEYWORDS: sqlite3_version sqlite3_sourceid
1160408
**
@@ -1262,11 +510,11 @@
1262510
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1263511
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1264512
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1265513
** and [sqlite3_close_v2()] are its destructors. There are many other
1266514
** interfaces (such as
1267
-** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
515
+** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
1268516
** [sqlite3_busy_timeout()] to name but three) that are methods on an
1269517
** sqlite3 object.
1270518
*/
1271519
typedef struct sqlite3 sqlite3;
1272520
@@ -1366,11 +614,11 @@
1366614
/*
1367615
** CAPI3REF: One-Step Query Execution Interface
1368616
** METHOD: sqlite3
1369617
**
1370618
** The sqlite3_exec() interface is a convenience wrapper around
1371
-** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
619
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
1372620
** that allows an application to run multiple statements of SQL
1373621
** without having to use a lot of C code.
1374622
**
1375623
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1376624
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3034,31 +2282,19 @@
30342282
** default) to enable them. The second parameter is a pointer to an integer
30352283
** into which is written 0 or 1 to indicate whether checkpoints-on-close
30362284
** have been disabled - 0 if they are not disabled, 1 if they are.
30372285
** </dd>
30382286
**
3039
-** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040
-** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041
-** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042
-** a single SQL query statement will always use the same algorithm regardless
3043
-** of values of [bound parameters]. The QPSG disables some query optimizations
3044
-** that look at the values of bound parameters, which can make some queries
3045
-** slower. But the QPSG has the advantage of more predictable behavior. With
3046
-** the QPSG active, SQLite will always use the same query plan in the field as
3047
-** was used during testing in the lab.
3048
-** </dd>
3049
-**
30502287
** </dl>
30512288
*/
30522289
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
30532290
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
30542291
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
30552292
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
30562293
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
30572294
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
30582295
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3059
-#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
30602296
30612297
30622298
/*
30632299
** CAPI3REF: Enable Or Disable Extended Result Codes
30642300
** METHOD: sqlite3
@@ -3718,26 +2954,25 @@
37182954
**
37192955
** ^This routine registers an authorizer callback with a particular
37202956
** [database connection], supplied in the first argument.
37212957
** ^The authorizer callback is invoked as SQL statements are being compiled
37222958
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
3723
-** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
3724
-** and [sqlite3_prepare16_v3()]. ^At various
2959
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
37252960
** points during the compilation process, as logic is being created
37262961
** to perform various actions, the authorizer callback is invoked to
37272962
** see if those actions are allowed. ^The authorizer callback should
37282963
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
37292964
** specific action but allow the SQL statement to continue to be
37302965
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
37312966
** rejected with an error. ^If the authorizer callback returns
37322967
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733
-** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2968
+** then the [sqlite3_prepare_v2()] or equivalent call that triggered
37342969
** the authorizer will fail with an error message.
37352970
**
37362971
** When the callback returns [SQLITE_OK], that means the operation
37372972
** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738
-** [sqlite3_prepare_v3()] or equivalent call that triggered the
2973
+** [sqlite3_prepare_v2()] or equivalent call that triggered the
37392974
** authorizer will fail with an error message explaining that
37402975
** access is denied.
37412976
**
37422977
** ^The first parameter to the authorizer callback is a copy of the third
37432978
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3019,23 @@
37843019
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
37853020
** The authorizer is disabled by default.
37863021
**
37873022
** The authorizer callback must not do anything that will modify
37883023
** the database connection that invoked the authorizer callback.
3789
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3024
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
37903025
** database connections for the meaning of "modify" in this paragraph.
37913026
**
3792
-** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
3027
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
37933028
** statement might be re-prepared during [sqlite3_step()] due to a
37943029
** schema change. Hence, the application should ensure that the
37953030
** correct authorizer callback remains in place during the [sqlite3_step()].
37963031
**
37973032
** ^Note that the authorizer callback is invoked only during
37983033
** [sqlite3_prepare()] or its variants. Authorization is not
37993034
** performed during statement evaluation in [sqlite3_step()], unless
38003035
** as stated in the previous paragraph, sqlite3_step() invokes
3801
-** sqlite3_prepare_v3() to reprepare a statement after a schema change.
3036
+** sqlite3_prepare_v2() to reprepare a statement after a schema change.
38023037
*/
38033038
SQLITE_API int sqlite3_set_authorizer(
38043039
sqlite3*,
38053040
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
38063041
void *pUserData
@@ -4032,11 +3267,11 @@
40323267
** interrupted. This feature can be used to implement a
40333268
** "Cancel" button on a GUI progress dialog box.
40343269
**
40353270
** The progress handler callback must not do anything that will modify
40363271
** the database connection that invoked the progress handler.
4037
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3272
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
40383273
** database connections for the meaning of "modify" in this paragraph.
40393274
**
40403275
*/
40413276
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
40423277
@@ -4386,11 +3621,11 @@
43863621
** prepared statement before it can be run.
43873622
**
43883623
** The life-cycle of a prepared statement object usually goes like this:
43893624
**
43903625
** <ol>
4391
-** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3626
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
43923627
** <li> Bind values to [parameters] using the sqlite3_bind_*()
43933628
** interfaces.
43943629
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
43953630
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
43963631
** to step 2. Do this zero or more times.
@@ -4468,11 +3703,11 @@
44683703
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
44693704
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
44703705
**
44713706
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
44723707
** <dd>The maximum number of instructions in a virtual machine program
4473
-** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3708
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
44743709
** the equivalent tries to allocate space for more than this many opcodes
44753710
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
44763711
**
44773712
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
44783713
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4508,61 +3743,28 @@
45083743
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
45093744
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
45103745
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
45113746
#define SQLITE_LIMIT_WORKER_THREADS 11
45123747
4513
-/*
4514
-** CAPI3REF: Prepare Flags
4515
-**
4516
-** These constants define various flags that can be passed into
4517
-** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
4518
-** [sqlite3_prepare16_v3()] interfaces.
4519
-**
4520
-** New flags may be added in future releases of SQLite.
4521
-**
4522
-** <dl>
4523
-** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524
-** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525
-** and [sqlite3_prepare16_v3()]
4526
-** to optimize the resulting prepared statement to be retained for a
4527
-** relatively long amount of time.)^ ^Without this flag,
4528
-** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529
-** the prepared statement will be used just once or at most a few times
4530
-** and then destroyed using [sqlite3_finalize()] relatively soon.
4531
-** </dl>
4532
-*/
4533
-#define SQLITE_PREPARE_PERSISTENT 0x01
45343748
45353749
/*
45363750
** CAPI3REF: Compiling An SQL Statement
45373751
** KEYWORDS: {SQL statement compiler}
45383752
** METHOD: sqlite3
45393753
** CONSTRUCTOR: sqlite3_stmt
45403754
**
4541
-** To execute an SQL statement, it must first be compiled into a byte-code
4542
-** program using one of these routines. Or, in other words, these routines
4543
-** are constructors for the [prepared statement] object.
4544
-**
4545
-** The preferred routine to use is [sqlite3_prepare_v2()]. The
4546
-** [sqlite3_prepare()] interface is legacy and should be avoided.
4547
-** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4548
-** for special purposes.
4549
-**
4550
-** The use of the UTF-8 interfaces is preferred, as SQLite currently
4551
-** does all parsing using UTF-8. The UTF-16 interfaces are provided
4552
-** as a convenience. The UTF-16 interfaces work by converting the
4553
-** input text into UTF-8, then invoking the corresponding UTF-8 interface.
3755
+** To execute an SQL query, it must first be compiled into a byte-code
3756
+** program using one of these routines.
45543757
**
45553758
** The first argument, "db", is a [database connection] obtained from a
45563759
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
45573760
** [sqlite3_open16()]. The database connection must not have been closed.
45583761
**
45593762
** The second argument, "zSql", is the statement to be compiled, encoded
4560
-** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
4561
-** and sqlite3_prepare_v3()
4562
-** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
4563
-** and sqlite3_prepare16_v3() use UTF-16.
3763
+** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3764
+** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3765
+** use UTF-16.
45643766
**
45653767
** ^If the nByte argument is negative, then zSql is read up to the
45663768
** first zero terminator. ^If nByte is positive, then it is the
45673769
** number of bytes read from zSql. ^If nByte is zero, then no prepared
45683770
** statement is generated.
@@ -4585,15 +3787,14 @@
45853787
** ppStmt may not be NULL.
45863788
**
45873789
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
45883790
** otherwise an [error code] is returned.
45893791
**
4590
-** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
4591
-** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
4592
-** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
4593
-** are retained for backwards compatibility, but their use is discouraged.
4594
-** ^In the "vX" interfaces, the prepared statement
3792
+** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3793
+** recommended for all new programs. The two older interfaces are retained
3794
+** for backwards compatibility, but their use is discouraged.
3795
+** ^In the "v2" interfaces, the prepared statement
45953796
** that is returned (the [sqlite3_stmt] object) contains a copy of the
45963797
** original SQL text. This causes the [sqlite3_step()] interface to
45973798
** behave differently in three ways:
45983799
**
45993800
** <ol>
@@ -4622,16 +3823,10 @@
46223823
** ^The specific value of WHERE-clause [parameter] might influence the
46233824
** choice of query plan if the parameter is the left-hand side of a [LIKE]
46243825
** or [GLOB] operator or if the parameter is compared to an indexed column
46253826
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
46263827
** </li>
4627
-**
4628
-** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4629
-** the extra prepFlags parameter, which is a bit array consisting of zero or
4630
-** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
4631
-** sqlite3_prepare_v2() interface works exactly the same as
4632
-** sqlite3_prepare_v3() with a zero prepFlags parameter.
46333828
** </ol>
46343829
*/
46353830
SQLITE_API int sqlite3_prepare(
46363831
sqlite3 *db, /* Database handle */
46373832
const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4642,18 +3837,10 @@
46423837
SQLITE_API int sqlite3_prepare_v2(
46433838
sqlite3 *db, /* Database handle */
46443839
const char *zSql, /* SQL statement, UTF-8 encoded */
46453840
int nByte, /* Maximum length of zSql in bytes. */
46463841
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4647
- const char **pzTail /* OUT: Pointer to unused portion of zSql */
4648
-);
4649
-SQLITE_API int sqlite3_prepare_v3(
4650
- sqlite3 *db, /* Database handle */
4651
- const char *zSql, /* SQL statement, UTF-8 encoded */
4652
- int nByte, /* Maximum length of zSql in bytes. */
4653
- unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
4654
- sqlite3_stmt **ppStmt, /* OUT: Statement handle */
46553842
const char **pzTail /* OUT: Pointer to unused portion of zSql */
46563843
);
46573844
SQLITE_API int sqlite3_prepare16(
46583845
sqlite3 *db, /* Database handle */
46593846
const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -4666,27 +3853,18 @@
46663853
const void *zSql, /* SQL statement, UTF-16 encoded */
46673854
int nByte, /* Maximum length of zSql in bytes. */
46683855
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
46693856
const void **pzTail /* OUT: Pointer to unused portion of zSql */
46703857
);
4671
-SQLITE_API int sqlite3_prepare16_v3(
4672
- sqlite3 *db, /* Database handle */
4673
- const void *zSql, /* SQL statement, UTF-16 encoded */
4674
- int nByte, /* Maximum length of zSql in bytes. */
4675
- unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
4676
- sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4677
- const void **pzTail /* OUT: Pointer to unused portion of zSql */
4678
-);
46793858
46803859
/*
46813860
** CAPI3REF: Retrieving Statement SQL
46823861
** METHOD: sqlite3_stmt
46833862
**
46843863
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
46853864
** SQL text used to create [prepared statement] P if P was
4686
-** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4687
-** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3865
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
46883866
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
46893867
** string containing the SQL text of prepared statement P with
46903868
** [bound parameters] expanded.
46913869
**
46923870
** ^(For example, if a prepared statement is created using the SQL
@@ -4828,11 +4006,11 @@
48284006
** CAPI3REF: Binding Values To Prepared Statements
48294007
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
48304008
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
48314009
** METHOD: sqlite3_stmt
48324010
**
4833
-** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
4011
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
48344012
** literals may be replaced by a [parameter] that matches one of following
48354013
** templates:
48364014
**
48374015
** <ul>
48384016
** <li> ?
@@ -4847,11 +4025,11 @@
48474025
** parameters (also called "host parameter names" or "SQL parameters")
48484026
** can be set using the sqlite3_bind_*() routines defined here.
48494027
**
48504028
** ^The first argument to the sqlite3_bind_*() routines is always
48514029
** a pointer to the [sqlite3_stmt] object returned from
4852
-** [sqlite3_prepare_v3()] or its variants.
4030
+** [sqlite3_prepare_v2()] or its variants.
48534031
**
48544032
** ^The second argument is the index of the SQL parameter to be set.
48554033
** ^The leftmost SQL parameter has an index of 1. ^When the same named
48564034
** SQL parameter is used more than once, second and subsequent
48574035
** occurrences have the same index as the first occurrence.
@@ -4984,12 +4162,12 @@
49844162
** ^The first host parameter has an index of 1, not 0.
49854163
**
49864164
** ^If the value N is out of range or if the N-th parameter is
49874165
** nameless, then NULL is returned. ^The returned string is
49884166
** always in UTF-8 encoding even if the named parameter was
4989
-** originally specified as UTF-16 in [sqlite3_prepare16()],
4990
-** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4167
+** originally specified as UTF-16 in [sqlite3_prepare16()] or
4168
+** [sqlite3_prepare16_v2()].
49914169
**
49924170
** See also: [sqlite3_bind_blob|sqlite3_bind()],
49934171
** [sqlite3_bind_parameter_count()], and
49944172
** [sqlite3_bind_parameter_index()].
49954173
*/
@@ -5002,12 +4180,11 @@
50024180
** ^Return the index of an SQL parameter given its name. ^The
50034181
** index value returned is suitable for use as the second
50044182
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
50054183
** is returned if no matching parameter is found. ^The parameter
50064184
** name must be given in UTF-8 even if the original statement
5007
-** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
5008
-** [sqlite3_prepare16_v3()].
4185
+** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
50094186
**
50104187
** See also: [sqlite3_bind_blob|sqlite3_bind()],
50114188
** [sqlite3_bind_parameter_count()], and
50124189
** [sqlite3_bind_parameter_name()].
50134190
*/
@@ -5157,22 +4334,20 @@
51574334
51584335
/*
51594336
** CAPI3REF: Evaluate An SQL Statement
51604337
** METHOD: sqlite3_stmt
51614338
**
5162
-** After a [prepared statement] has been prepared using any of
5163
-** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
5164
-** or [sqlite3_prepare16_v3()] or one of the legacy
4339
+** After a [prepared statement] has been prepared using either
4340
+** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
51654341
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
51664342
** must be called one or more times to evaluate the statement.
51674343
**
51684344
** The details of the behavior of the sqlite3_step() interface depend
5169
-** on whether the statement was prepared using the newer "vX" interfaces
5170
-** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
5171
-** [sqlite3_prepare16_v2()] or the older legacy
5172
-** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5173
-** new "vX" interface is recommended for new applications but the legacy
4345
+** on whether the statement was prepared using the newer "v2" interface
4346
+** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4347
+** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4348
+** new "v2" interface is recommended for new applications but the legacy
51744349
** interface will continue to be supported.
51754350
**
51764351
** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
51774352
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
51784353
** ^With the "v2" interface, any of the other [result codes] or
@@ -5229,15 +4404,14 @@
52294404
** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
52304405
** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
52314406
** specific [error codes] that better describes the error.
52324407
** We admit that this is a goofy design. The problem has been fixed
52334408
** with the "v2" interface. If you prepare all of your SQL statements
5234
-** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
5235
-** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
4409
+** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
52364410
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
52374411
** then the more specific [error codes] are returned directly
5238
-** by sqlite3_step(). The use of the "vX" interfaces is recommended.
4412
+** by sqlite3_step(). The use of the "v2" interface is recommended.
52394413
*/
52404414
SQLITE_API int sqlite3_step(sqlite3_stmt*);
52414415
52424416
/*
52434417
** CAPI3REF: Number of columns in a result set
@@ -5298,11 +4472,11 @@
52984472
** METHOD: sqlite3_stmt
52994473
**
53004474
** ^These routines return information about a single column of the current
53014475
** result row of a query. ^In every case the first argument is a pointer
53024476
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5303
-** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4477
+** that was returned from [sqlite3_prepare_v2()] or one of its variants)
53044478
** and the second argument is the index of the column for which information
53054479
** should be returned. ^The leftmost column of the result set has the index 0.
53064480
** ^The number of columns in the result can be determined using
53074481
** [sqlite3_column_count()].
53084482
**
@@ -6422,11 +5596,11 @@
64225596
**
64235597
** ^The sqlite3_db_handle interface returns the [database connection] handle
64245598
** to which a [prepared statement] belongs. ^The [database connection]
64255599
** returned by sqlite3_db_handle is the same [database connection]
64265600
** that was the first argument
6427
-** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5601
+** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
64285602
** create the statement in the first place.
64295603
*/
64305604
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
64315605
64325606
/*
@@ -6498,11 +5672,11 @@
64985672
** the database connection that invoked the callback. Any actions
64995673
** to modify the database connection must be deferred until after the
65005674
** completion of the [sqlite3_step()] call that triggered the commit
65015675
** or rollback hook in the first place.
65025676
** Note that running any other SQL statements, including SELECT statements,
6503
-** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5677
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
65045678
** the database connections for the meaning of "modify" in this paragraph.
65055679
**
65065680
** ^Registering a NULL function disables the callback.
65075681
**
65085682
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6558,11 +5732,11 @@
65585732
**
65595733
** The update hook implementation must not do anything that will modify
65605734
** the database connection that invoked the update hook. Any actions
65615735
** to modify the database connection must be deferred until after the
65625736
** completion of the [sqlite3_step()] call that triggered the update hook.
6563
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5737
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
65645738
** database connections for the meaning of "modify" in this paragraph.
65655739
**
65665740
** ^The sqlite3_update_hook(D,C,P) function
65675741
** returns the P argument from the previous call
65685742
** on the same [database connection] D, or NULL for
@@ -6721,13 +5895,11 @@
67215895
** column exists. ^The sqlite3_table_column_metadata() interface returns
67225896
** SQLITE_ERROR and if the specified column does not exist.
67235897
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
67245898
** NULL pointer, then this routine simply checks for the existence of the
67255899
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
6726
-** does not. If the table name parameter T in a call to
6727
-** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
6728
-** undefined behavior.
5900
+** does not.
67295901
**
67305902
** ^The column is identified by the second, third and fourth parameters to
67315903
** this function. ^(The second parameter is either the name of the database
67325904
** (i.e. "main", "temp", or an attached database) containing the specified
67335905
** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -8236,38 +7408,17 @@
82367408
** by the prepared statement if that number is less than or equal
82377409
** to 2147483647. The number of virtual machine operations can be
82387410
** used as a proxy for the total work done by the prepared statement.
82397411
** If the number of virtual machine operations exceeds 2147483647
82407412
** then the value returned by this statement status code is undefined.
8241
-**
8242
-** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
8243
-** <dd>^This is the number of times that the prepare statement has been
8244
-** automatically regenerated due to schema changes or change to
8245
-** [bound parameters] that might affect the query plan.
8246
-**
8247
-** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
8248
-** <dd>^This is the number of times that the prepared statement has
8249
-** been run. A single "run" for the purposes of this counter is one
8250
-** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
8251
-** The counter is incremented on the first [sqlite3_step()] call of each
8252
-** cycle.
8253
-**
8254
-** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8255
-** <dd>^This is the approximate number of bytes of heap memory
8256
-** used to store the prepared statement. ^This value is not actually
8257
-** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
8258
-** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
82597413
** </dd>
82607414
** </dl>
82617415
*/
82627416
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
82637417
#define SQLITE_STMTSTATUS_SORT 2
82647418
#define SQLITE_STMTSTATUS_AUTOINDEX 3
82657419
#define SQLITE_STMTSTATUS_VM_STEP 4
8266
-#define SQLITE_STMTSTATUS_REPREPARE 5
8267
-#define SQLITE_STMTSTATUS_RUN 6
8268
-#define SQLITE_STMTSTATUS_MEMUSED 99
82697420
82707421
/*
82717422
** CAPI3REF: Custom Page Cache Object
82727423
**
82737424
** The sqlite3_pcache type is opaque. It is implemented by
@@ -11630,13 +10781,12 @@
1163010781
1163110782
/*
1163210783
** Include the configuration header output by 'configure' if we're using the
1163310784
** autoconf-based build
1163410785
*/
11635
-#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
11636
-/* #include "config.h" */
11637
-#define SQLITECONFIG_H 1
10786
+#ifdef _HAVE_SQLITE_CONFIG_H
10787
+#include "config.h"
1163810788
#endif
1163910789
1164010790
/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
1164110791
/************** Begin file sqliteLimit.h *************************************/
1164210792
/*
@@ -11942,15 +11092,10 @@
1194211092
** threads can use SQLite as long as no two threads try to use the same
1194311093
** database connection at the same time.
1194411094
**
1194511095
** Older versions of SQLite used an optional THREADSAFE macro.
1194611096
** We support that for legacy.
11947
-**
11948
-** To ensure that the correct value of "THREADSAFE" is reported when querying
11949
-** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this
11950
-** logic is partially replicated in ctime.c. If it is updated here, it should
11951
-** also be updated there.
1195211097
*/
1195311098
#if !defined(SQLITE_THREADSAFE)
1195411099
# if defined(THREADSAFE)
1195511100
# define SQLITE_THREADSAFE THREADSAFE
1195611101
# else
@@ -12537,10 +11682,11 @@
1253711682
** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
1253811683
** on the command-line
1253911684
*/
1254011685
#ifndef SQLITE_TEMP_STORE
1254111686
# define SQLITE_TEMP_STORE 1
11687
+# define SQLITE_TEMP_STORE_xc 1 /* Exclude from ctime.c */
1254211688
#endif
1254311689
1254411690
/*
1254511691
** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
1254611692
** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
@@ -12837,19 +11983,21 @@
1283711983
|| defined(__DragonFly__)
1283811984
# define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
1283911985
# else
1284011986
# define SQLITE_MAX_MMAP_SIZE 0
1284111987
# endif
11988
+# define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
1284211989
#endif
1284311990
1284411991
/*
1284511992
** The default MMAP_SIZE is zero on all platforms. Or, even if a larger
1284611993
** default MMAP_SIZE is specified at compile-time, make sure that it does
1284711994
** not exceed the maximum mmap size.
1284811995
*/
1284911996
#ifndef SQLITE_DEFAULT_MMAP_SIZE
1285011997
# define SQLITE_DEFAULT_MMAP_SIZE 0
11998
+# define SQLITE_DEFAULT_MMAP_SIZE_xc 1 /* Exclude from ctime.c */
1285111999
#endif
1285212000
#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
1285312001
# undef SQLITE_DEFAULT_MMAP_SIZE
1285412002
# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
1285512003
#endif
@@ -13330,13 +12478,13 @@
1333012478
1333112479
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
1333212480
int flags, int seekResult);
1333312481
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
1333412482
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
13335
-SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
12483
+SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
1333612484
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
13337
-SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
12485
+SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
1333812486
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
1333912487
SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
1334012488
SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
1334112489
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
1334212490
@@ -13483,11 +12631,11 @@
1348312631
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
1348412632
Table *pTab; /* Used when p4type is P4_TABLE */
1348512633
#ifdef SQLITE_ENABLE_CURSOR_HINTS
1348612634
Expr *pExpr; /* Used when p4type is P4_EXPR */
1348712635
#endif
13488
- int (*xAdvance)(BtCursor *, int);
12636
+ int (*xAdvance)(BtCursor *, int *);
1348912637
} p4;
1349012638
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
1349112639
char *zComment; /* Comment to improve readability */
1349212640
#endif
1349312641
#ifdef VDBE_PROFILE
@@ -13717,11 +12865,11 @@
1371712865
#define OP_Rowid 125 /* synopsis: r[P2]=rowid */
1371812866
#define OP_NullRow 126
1371912867
#define OP_SorterInsert 127 /* synopsis: key=r[P2] */
1372012868
#define OP_IdxInsert 128 /* synopsis: key=r[P2] */
1372112869
#define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */
13722
-#define OP_DeferredSeek 130 /* synopsis: Move P3 to P1.rowid if needed */
12870
+#define OP_Seek 130 /* synopsis: Move P3 to P1.rowid */
1372312871
#define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */
1372412872
#define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
1372512873
#define OP_Destroy 133
1372612874
#define OP_Clear 134
1372712875
#define OP_ResetSorter 135
@@ -13798,16 +12946,10 @@
1379812946
#define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
1379912947
1380012948
/************** End of opcodes.h *********************************************/
1380112949
/************** Continuing where we left off in vdbe.h ***********************/
1380212950
13803
-/*
13804
-** Additional non-public SQLITE_PREPARE_* flags
13805
-*/
13806
-#define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
13807
-#define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
13808
-
1380912951
/*
1381012952
** Prototypes for the VDBE interface. See comments on the implementation
1381112953
** for a description of what each of these routines does.
1381212954
*/
1381312955
SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13861,12 +13003,11 @@
1386113003
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
1386213004
SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
1386313005
SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
1386413006
SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
1386513007
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13866
-SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);
13867
-SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
13008
+SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
1386813009
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
1386913010
SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
1387013011
SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
1387113012
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
1387213013
#ifndef SQLITE_OMIT_TRACE
@@ -14228,25 +13369,25 @@
1422813369
*/
1422913370
struct PgHdr {
1423013371
sqlite3_pcache_page *pPage; /* Pcache object page handle */
1423113372
void *pData; /* Page data */
1423213373
void *pExtra; /* Extra content */
14233
- PCache *pCache; /* PRIVATE: Cache that owns this page */
1423413374
PgHdr *pDirty; /* Transient list of dirty sorted by pgno */
1423513375
Pager *pPager; /* The pager this page is part of */
1423613376
Pgno pgno; /* Page number for this page */
1423713377
#ifdef SQLITE_CHECK_PAGES
1423813378
u32 pageHash; /* Hash of page content */
1423913379
#endif
1424013380
u16 flags; /* PGHDR flags defined below */
1424113381
1424213382
/**********************************************************************
14243
- ** Elements above, except pCache, are public. All that follow are
14244
- ** private to pcache.c and should not be accessed by other modules.
14245
- ** pCache is grouped with the public elements for efficiency.
13383
+ ** Elements above are public. All that follows is private to pcache.c
13384
+ ** and should not be accessed by other modules.
1424613385
*/
1424713386
i16 nRef; /* Number of users of this page */
13387
+ PCache *pCache; /* Cache that owns this page */
13388
+
1424813389
PgHdr *pDirtyNext; /* Next element in list of dirty pages */
1424913390
PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */
1425013391
};
1425113392
1425213393
/* Bit values for PgHdr.flags */
@@ -15084,12 +14225,12 @@
1508414225
** Value constraints (enforced via assert()):
1508514226
** SQLITE_FullFSync == PAGER_FULLFSYNC
1508614227
** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
1508714228
** SQLITE_CacheSpill == PAGER_CACHE_SPILL
1508814229
*/
15089
-#define SQLITE_WriteSchema 0x00000001 /* OK to update SQLITE_MASTER */
15090
-#define SQLITE_LegacyFileFmt 0x00000002 /* Create new databases in format 1 */
14230
+#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
14231
+#define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
1509114232
#define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
1509214233
#define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
1509314234
#define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
1509414235
#define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
1509514236
#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -15096,38 +14237,33 @@
1509614237
#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
1509714238
/* DELETE, or UPDATE and return */
1509814239
/* the count using a callback. */
1509914240
#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
1510014241
/* result set is empty */
15101
-#define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */
15102
-#define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */
15103
-#define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */
15104
-#define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */
15105
-#define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */
15106
-#define SQLITE_ForeignKeys 0x00004000 /* Enforce foreign key constraints */
15107
-#define SQLITE_AutoIndex 0x00008000 /* Enable automatic indexes */
15108
-#define SQLITE_LoadExtension 0x00010000 /* Enable load_extension */
15109
-#define SQLITE_EnableTrigger 0x00020000 /* True to enable triggers */
15110
-#define SQLITE_DeferFKs 0x00040000 /* Defer all FK constraints */
15111
-#define SQLITE_QueryOnly 0x00080000 /* Disable database changes */
15112
-#define SQLITE_CellSizeCk 0x00100000 /* Check btree cell sizes on load */
15113
-#define SQLITE_Fts3Tokenizer 0x00200000 /* Enable fts3_tokenizer(2) */
15114
-#define SQLITE_EnableQPSG 0x00400000 /* Query Planner Stability Guarantee */
15115
-/* The next four values are not used by PRAGMAs or by sqlite3_dbconfig() and
15116
-** could be factored out into a separate bit vector of the sqlite3 object. */
15117
-#define SQLITE_InternChanges 0x00800000 /* Uncommitted Hash table changes */
15118
-#define SQLITE_LoadExtFunc 0x01000000 /* Enable load_extension() SQL func */
15119
-#define SQLITE_PreferBuiltin 0x02000000 /* Preference to built-in funcs */
15120
-#define SQLITE_Vacuum 0x04000000 /* Currently in a VACUUM */
15121
-/* Flags used only if debugging */
15122
-#ifdef SQLITE_DEBUG
15123
-#define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
15124
-#define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
15125
-#define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
15126
-#define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
15127
-#define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
15128
-#endif
14242
+#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
14243
+#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
14244
+#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
14245
+#define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
14246
+#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
14247
+#define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
14248
+#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
14249
+#define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
14250
+#define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
14251
+#define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
14252
+#define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
14253
+#define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
14254
+#define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
14255
+#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
14256
+#define SQLITE_LoadExtFunc 0x00800000 /* Enable load_extension() SQL func */
14257
+#define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */
14258
+#define SQLITE_DeferFKs 0x02000000 /* Defer all FK constraints */
14259
+#define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
14260
+#define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
14261
+#define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
14262
+#define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
14263
+#define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
14264
+#define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
1512914265
1513014266
1513114267
/*
1513214268
** Bits of the sqlite3.dbOptFlags field that are used by the
1513314269
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -16006,11 +15142,11 @@
1600615142
** The following are the meanings of bits in the Expr.flags field.
1600715143
*/
1600815144
#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
1600915145
#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
1601015146
#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
16011
- /* 0x000008 // available for use */
15147
+#define EP_Error 0x000008 /* Expression contains one or more errors */
1601215148
#define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
1601315149
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
1601415150
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
1601515151
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
1601615152
#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
@@ -16473,14 +15609,14 @@
1647315609
** An instance of this object describes where to put of the results of
1647415610
** a SELECT statement.
1647515611
*/
1647615612
struct SelectDest {
1647715613
u8 eDest; /* How to dispose of the results. On of SRT_* above. */
15614
+ char *zAffSdst; /* Affinity used when eDest==SRT_Set */
1647815615
int iSDParm; /* A parameter used by the eDest disposal method */
1647915616
int iSdst; /* Base register where results are written */
1648015617
int nSdst; /* Number of registers allocated */
16481
- char *zAffSdst; /* Affinity used when eDest==SRT_Set */
1648215618
ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
1648315619
};
1648415620
1648515621
/*
1648615622
** During code generation of statements that do inserts into AUTOINCREMENT
@@ -16979,14 +16115,10 @@
1697916115
SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
1698016116
SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
1698116117
SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
1698216118
SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
1698316119
SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
16984
-SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
16985
-#ifdef SQLITE_DEBUG
16986
-SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
16987
-#endif
1698816120
1698916121
/*
1699016122
** Return code from the parse-tree walking primitives and their
1699116123
** callbacks.
1699216124
*/
@@ -17044,18 +16176,15 @@
1704416176
#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
1704516177
#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
1704616178
#ifdef SQLITE_DEBUG
1704716179
SQLITE_PRIVATE int sqlite3NomemError(int);
1704816180
SQLITE_PRIVATE int sqlite3IoerrnomemError(int);
17049
-SQLITE_PRIVATE int sqlite3CorruptPgnoError(int,Pgno);
1705016181
# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
1705116182
# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
17052
-# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))
1705316183
#else
1705416184
# define SQLITE_NOMEM_BKPT SQLITE_NOMEM
1705516185
# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
17056
-# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)
1705716186
#endif
1705816187
1705916188
/*
1706016189
** FTS3 and FTS4 both require virtual table support
1706116190
*/
@@ -17420,14 +16549,14 @@
1742016549
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1742116550
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1742216551
SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
1742316552
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
1742416553
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
17425
-SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
16554
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
1742616555
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
1742716556
SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
17428
-SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);
16557
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1742916558
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1743016559
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1743116560
SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
1743216561
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1743316562
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18012,12 +17141,10 @@
1801217141
SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
1801317142
SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
1801417143
SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
1801517144
SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
1801617145
18017
-SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
18018
-
1801917146
#endif /* SQLITEINT_H */
1802017147
1802117148
/************** End of sqliteInt.h *******************************************/
1802217149
/************** Begin file global.c ******************************************/
1802317150
/*
@@ -18318,10 +17445,476 @@
1831817445
** Name of the default collating sequence
1831917446
*/
1832017447
SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
1832117448
1832217449
/************** End of global.c **********************************************/
17450
+/************** Begin file ctime.c *******************************************/
17451
+/*
17452
+** 2010 February 23
17453
+**
17454
+** The author disclaims copyright to this source code. In place of
17455
+** a legal notice, here is a blessing:
17456
+**
17457
+** May you do good and not evil.
17458
+** May you find forgiveness for yourself and forgive others.
17459
+** May you share freely, never taking more than you give.
17460
+**
17461
+*************************************************************************
17462
+**
17463
+** This file implements routines used to report what compile-time options
17464
+** SQLite was built with.
17465
+*/
17466
+
17467
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
17468
+
17469
+/* #include "sqliteInt.h" */
17470
+
17471
+/*
17472
+** An array of names of all compile-time options. This array should
17473
+** be sorted A-Z.
17474
+**
17475
+** This array looks large, but in a typical installation actually uses
17476
+** only a handful of compile-time options, so most times this array is usually
17477
+** rather short and uses little memory space.
17478
+*/
17479
+static const char * const azCompileOpt[] = {
17480
+
17481
+/* These macros are provided to "stringify" the value of the define
17482
+** for those options in which the value is meaningful. */
17483
+#define CTIMEOPT_VAL_(opt) #opt
17484
+#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
17485
+
17486
+#if SQLITE_32BIT_ROWID
17487
+ "32BIT_ROWID",
17488
+#endif
17489
+#if SQLITE_4_BYTE_ALIGNED_MALLOC
17490
+ "4_BYTE_ALIGNED_MALLOC",
17491
+#endif
17492
+#if SQLITE_CASE_SENSITIVE_LIKE
17493
+ "CASE_SENSITIVE_LIKE",
17494
+#endif
17495
+#if SQLITE_CHECK_PAGES
17496
+ "CHECK_PAGES",
17497
+#endif
17498
+#if defined(__clang__) && defined(__clang_major__)
17499
+ "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
17500
+ CTIMEOPT_VAL(__clang_minor__) "."
17501
+ CTIMEOPT_VAL(__clang_patchlevel__),
17502
+#elif defined(_MSC_VER)
17503
+ "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17504
+#elif defined(__GNUC__) && defined(__VERSION__)
17505
+ "COMPILER=gcc-" __VERSION__,
17506
+#endif
17507
+#if SQLITE_COVERAGE_TEST
17508
+ "COVERAGE_TEST",
17509
+#endif
17510
+#ifdef SQLITE_DEBUG
17511
+ "DEBUG",
17512
+#endif
17513
+#if SQLITE_DEFAULT_LOCKING_MODE
17514
+ "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17515
+#endif
17516
+#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17517
+ "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17518
+#endif
17519
+#if SQLITE_DEFAULT_SYNCHRONOUS
17520
+ "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
17521
+#endif
17522
+#if SQLITE_DEFAULT_WAL_SYNCHRONOUS
17523
+ "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
17524
+#endif
17525
+#if SQLITE_DIRECT_OVERFLOW_READ
17526
+ "DIRECT_OVERFLOW_READ",
17527
+#endif
17528
+#if SQLITE_DISABLE_DIRSYNC
17529
+ "DISABLE_DIRSYNC",
17530
+#endif
17531
+#if SQLITE_DISABLE_LFS
17532
+ "DISABLE_LFS",
17533
+#endif
17534
+#if SQLITE_ENABLE_8_3_NAMES
17535
+ "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
17536
+#endif
17537
+#if SQLITE_ENABLE_API_ARMOR
17538
+ "ENABLE_API_ARMOR",
17539
+#endif
17540
+#if SQLITE_ENABLE_ATOMIC_WRITE
17541
+ "ENABLE_ATOMIC_WRITE",
17542
+#endif
17543
+#if SQLITE_ENABLE_CEROD
17544
+ "ENABLE_CEROD",
17545
+#endif
17546
+#if SQLITE_ENABLE_COLUMN_METADATA
17547
+ "ENABLE_COLUMN_METADATA",
17548
+#endif
17549
+#if SQLITE_ENABLE_DBSTAT_VTAB
17550
+ "ENABLE_DBSTAT_VTAB",
17551
+#endif
17552
+#if SQLITE_ENABLE_EXPENSIVE_ASSERT
17553
+ "ENABLE_EXPENSIVE_ASSERT",
17554
+#endif
17555
+#if SQLITE_ENABLE_FTS1
17556
+ "ENABLE_FTS1",
17557
+#endif
17558
+#if SQLITE_ENABLE_FTS2
17559
+ "ENABLE_FTS2",
17560
+#endif
17561
+#if SQLITE_ENABLE_FTS3
17562
+ "ENABLE_FTS3",
17563
+#endif
17564
+#if SQLITE_ENABLE_FTS3_PARENTHESIS
17565
+ "ENABLE_FTS3_PARENTHESIS",
17566
+#endif
17567
+#if SQLITE_ENABLE_FTS4
17568
+ "ENABLE_FTS4",
17569
+#endif
17570
+#if SQLITE_ENABLE_FTS5
17571
+ "ENABLE_FTS5",
17572
+#endif
17573
+#if SQLITE_ENABLE_ICU
17574
+ "ENABLE_ICU",
17575
+#endif
17576
+#if SQLITE_ENABLE_IOTRACE
17577
+ "ENABLE_IOTRACE",
17578
+#endif
17579
+#if SQLITE_ENABLE_JSON1
17580
+ "ENABLE_JSON1",
17581
+#endif
17582
+#if SQLITE_ENABLE_LOAD_EXTENSION
17583
+ "ENABLE_LOAD_EXTENSION",
17584
+#endif
17585
+#if SQLITE_ENABLE_LOCKING_STYLE
17586
+ "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
17587
+#endif
17588
+#if SQLITE_ENABLE_MEMORY_MANAGEMENT
17589
+ "ENABLE_MEMORY_MANAGEMENT",
17590
+#endif
17591
+#if SQLITE_ENABLE_MEMSYS3
17592
+ "ENABLE_MEMSYS3",
17593
+#endif
17594
+#if SQLITE_ENABLE_MEMSYS5
17595
+ "ENABLE_MEMSYS5",
17596
+#endif
17597
+#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
17598
+ "ENABLE_OVERSIZE_CELL_CHECK",
17599
+#endif
17600
+#if SQLITE_ENABLE_RTREE
17601
+ "ENABLE_RTREE",
17602
+#endif
17603
+#if defined(SQLITE_ENABLE_STAT4)
17604
+ "ENABLE_STAT4",
17605
+#elif defined(SQLITE_ENABLE_STAT3)
17606
+ "ENABLE_STAT3",
17607
+#endif
17608
+#if SQLITE_ENABLE_UNLOCK_NOTIFY
17609
+ "ENABLE_UNLOCK_NOTIFY",
17610
+#endif
17611
+#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
17612
+ "ENABLE_UPDATE_DELETE_LIMIT",
17613
+#endif
17614
+#if defined(SQLITE_ENABLE_URI_00_ERROR)
17615
+ "ENABLE_URI_00_ERROR",
17616
+#endif
17617
+#if SQLITE_HAS_CODEC
17618
+ "HAS_CODEC",
17619
+#endif
17620
+#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
17621
+ "HAVE_ISNAN",
17622
+#endif
17623
+#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
17624
+ "HOMEGROWN_RECURSIVE_MUTEX",
17625
+#endif
17626
+#if SQLITE_IGNORE_AFP_LOCK_ERRORS
17627
+ "IGNORE_AFP_LOCK_ERRORS",
17628
+#endif
17629
+#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
17630
+ "IGNORE_FLOCK_LOCK_ERRORS",
17631
+#endif
17632
+#ifdef SQLITE_INT64_TYPE
17633
+ "INT64_TYPE",
17634
+#endif
17635
+#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
17636
+ "LIKE_DOESNT_MATCH_BLOBS",
17637
+#endif
17638
+#if SQLITE_LOCK_TRACE
17639
+ "LOCK_TRACE",
17640
+#endif
17641
+#if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)
17642
+ "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
17643
+#endif
17644
+#ifdef SQLITE_MAX_SCHEMA_RETRY
17645
+ "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
17646
+#endif
17647
+#if SQLITE_MEMDEBUG
17648
+ "MEMDEBUG",
17649
+#endif
17650
+#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
17651
+ "MIXED_ENDIAN_64BIT_FLOAT",
17652
+#endif
17653
+#if SQLITE_NO_SYNC
17654
+ "NO_SYNC",
17655
+#endif
17656
+#if SQLITE_OMIT_ALTERTABLE
17657
+ "OMIT_ALTERTABLE",
17658
+#endif
17659
+#if SQLITE_OMIT_ANALYZE
17660
+ "OMIT_ANALYZE",
17661
+#endif
17662
+#if SQLITE_OMIT_ATTACH
17663
+ "OMIT_ATTACH",
17664
+#endif
17665
+#if SQLITE_OMIT_AUTHORIZATION
17666
+ "OMIT_AUTHORIZATION",
17667
+#endif
17668
+#if SQLITE_OMIT_AUTOINCREMENT
17669
+ "OMIT_AUTOINCREMENT",
17670
+#endif
17671
+#if SQLITE_OMIT_AUTOINIT
17672
+ "OMIT_AUTOINIT",
17673
+#endif
17674
+#if SQLITE_OMIT_AUTOMATIC_INDEX
17675
+ "OMIT_AUTOMATIC_INDEX",
17676
+#endif
17677
+#if SQLITE_OMIT_AUTORESET
17678
+ "OMIT_AUTORESET",
17679
+#endif
17680
+#if SQLITE_OMIT_AUTOVACUUM
17681
+ "OMIT_AUTOVACUUM",
17682
+#endif
17683
+#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
17684
+ "OMIT_BETWEEN_OPTIMIZATION",
17685
+#endif
17686
+#if SQLITE_OMIT_BLOB_LITERAL
17687
+ "OMIT_BLOB_LITERAL",
17688
+#endif
17689
+#if SQLITE_OMIT_BTREECOUNT
17690
+ "OMIT_BTREECOUNT",
17691
+#endif
17692
+#if SQLITE_OMIT_CAST
17693
+ "OMIT_CAST",
17694
+#endif
17695
+#if SQLITE_OMIT_CHECK
17696
+ "OMIT_CHECK",
17697
+#endif
17698
+#if SQLITE_OMIT_COMPLETE
17699
+ "OMIT_COMPLETE",
17700
+#endif
17701
+#if SQLITE_OMIT_COMPOUND_SELECT
17702
+ "OMIT_COMPOUND_SELECT",
17703
+#endif
17704
+#if SQLITE_OMIT_CTE
17705
+ "OMIT_CTE",
17706
+#endif
17707
+#if SQLITE_OMIT_DATETIME_FUNCS
17708
+ "OMIT_DATETIME_FUNCS",
17709
+#endif
17710
+#if SQLITE_OMIT_DECLTYPE
17711
+ "OMIT_DECLTYPE",
17712
+#endif
17713
+#if SQLITE_OMIT_DEPRECATED
17714
+ "OMIT_DEPRECATED",
17715
+#endif
17716
+#if SQLITE_OMIT_DISKIO
17717
+ "OMIT_DISKIO",
17718
+#endif
17719
+#if SQLITE_OMIT_EXPLAIN
17720
+ "OMIT_EXPLAIN",
17721
+#endif
17722
+#if SQLITE_OMIT_FLAG_PRAGMAS
17723
+ "OMIT_FLAG_PRAGMAS",
17724
+#endif
17725
+#if SQLITE_OMIT_FLOATING_POINT
17726
+ "OMIT_FLOATING_POINT",
17727
+#endif
17728
+#if SQLITE_OMIT_FOREIGN_KEY
17729
+ "OMIT_FOREIGN_KEY",
17730
+#endif
17731
+#if SQLITE_OMIT_GET_TABLE
17732
+ "OMIT_GET_TABLE",
17733
+#endif
17734
+#if SQLITE_OMIT_INCRBLOB
17735
+ "OMIT_INCRBLOB",
17736
+#endif
17737
+#if SQLITE_OMIT_INTEGRITY_CHECK
17738
+ "OMIT_INTEGRITY_CHECK",
17739
+#endif
17740
+#if SQLITE_OMIT_LIKE_OPTIMIZATION
17741
+ "OMIT_LIKE_OPTIMIZATION",
17742
+#endif
17743
+#if SQLITE_OMIT_LOAD_EXTENSION
17744
+ "OMIT_LOAD_EXTENSION",
17745
+#endif
17746
+#if SQLITE_OMIT_LOCALTIME
17747
+ "OMIT_LOCALTIME",
17748
+#endif
17749
+#if SQLITE_OMIT_LOOKASIDE
17750
+ "OMIT_LOOKASIDE",
17751
+#endif
17752
+#if SQLITE_OMIT_MEMORYDB
17753
+ "OMIT_MEMORYDB",
17754
+#endif
17755
+#if SQLITE_OMIT_OR_OPTIMIZATION
17756
+ "OMIT_OR_OPTIMIZATION",
17757
+#endif
17758
+#if SQLITE_OMIT_PAGER_PRAGMAS
17759
+ "OMIT_PAGER_PRAGMAS",
17760
+#endif
17761
+#if SQLITE_OMIT_PRAGMA
17762
+ "OMIT_PRAGMA",
17763
+#endif
17764
+#if SQLITE_OMIT_PROGRESS_CALLBACK
17765
+ "OMIT_PROGRESS_CALLBACK",
17766
+#endif
17767
+#if SQLITE_OMIT_QUICKBALANCE
17768
+ "OMIT_QUICKBALANCE",
17769
+#endif
17770
+#if SQLITE_OMIT_REINDEX
17771
+ "OMIT_REINDEX",
17772
+#endif
17773
+#if SQLITE_OMIT_SCHEMA_PRAGMAS
17774
+ "OMIT_SCHEMA_PRAGMAS",
17775
+#endif
17776
+#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
17777
+ "OMIT_SCHEMA_VERSION_PRAGMAS",
17778
+#endif
17779
+#if SQLITE_OMIT_SHARED_CACHE
17780
+ "OMIT_SHARED_CACHE",
17781
+#endif
17782
+#if SQLITE_OMIT_SUBQUERY
17783
+ "OMIT_SUBQUERY",
17784
+#endif
17785
+#if SQLITE_OMIT_TCL_VARIABLE
17786
+ "OMIT_TCL_VARIABLE",
17787
+#endif
17788
+#if SQLITE_OMIT_TEMPDB
17789
+ "OMIT_TEMPDB",
17790
+#endif
17791
+#if SQLITE_OMIT_TRACE
17792
+ "OMIT_TRACE",
17793
+#endif
17794
+#if SQLITE_OMIT_TRIGGER
17795
+ "OMIT_TRIGGER",
17796
+#endif
17797
+#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
17798
+ "OMIT_TRUNCATE_OPTIMIZATION",
17799
+#endif
17800
+#if SQLITE_OMIT_UTF16
17801
+ "OMIT_UTF16",
17802
+#endif
17803
+#if SQLITE_OMIT_VACUUM
17804
+ "OMIT_VACUUM",
17805
+#endif
17806
+#if SQLITE_OMIT_VIEW
17807
+ "OMIT_VIEW",
17808
+#endif
17809
+#if SQLITE_OMIT_VIRTUALTABLE
17810
+ "OMIT_VIRTUALTABLE",
17811
+#endif
17812
+#if SQLITE_OMIT_WAL
17813
+ "OMIT_WAL",
17814
+#endif
17815
+#if SQLITE_OMIT_WSD
17816
+ "OMIT_WSD",
17817
+#endif
17818
+#if SQLITE_OMIT_XFER_OPT
17819
+ "OMIT_XFER_OPT",
17820
+#endif
17821
+#if SQLITE_PERFORMANCE_TRACE
17822
+ "PERFORMANCE_TRACE",
17823
+#endif
17824
+#if SQLITE_PROXY_DEBUG
17825
+ "PROXY_DEBUG",
17826
+#endif
17827
+#if SQLITE_RTREE_INT_ONLY
17828
+ "RTREE_INT_ONLY",
17829
+#endif
17830
+#if SQLITE_SECURE_DELETE
17831
+ "SECURE_DELETE",
17832
+#endif
17833
+#if SQLITE_SMALL_STACK
17834
+ "SMALL_STACK",
17835
+#endif
17836
+#if SQLITE_SOUNDEX
17837
+ "SOUNDEX",
17838
+#endif
17839
+#if SQLITE_SYSTEM_MALLOC
17840
+ "SYSTEM_MALLOC",
17841
+#endif
17842
+#if SQLITE_TCL
17843
+ "TCL",
17844
+#endif
17845
+#if defined(SQLITE_TEMP_STORE) && !defined(SQLITE_TEMP_STORE_xc)
17846
+ "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
17847
+#endif
17848
+#if SQLITE_TEST
17849
+ "TEST",
17850
+#endif
17851
+#if defined(SQLITE_THREADSAFE)
17852
+ "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
17853
+#endif
17854
+#if SQLITE_UNTESTABLE
17855
+ "UNTESTABLE"
17856
+#endif
17857
+#if SQLITE_USE_ALLOCA
17858
+ "USE_ALLOCA",
17859
+#endif
17860
+#if SQLITE_USER_AUTHENTICATION
17861
+ "USER_AUTHENTICATION",
17862
+#endif
17863
+#if SQLITE_WIN32_MALLOC
17864
+ "WIN32_MALLOC",
17865
+#endif
17866
+#if SQLITE_ZERO_MALLOC
17867
+ "ZERO_MALLOC"
17868
+#endif
17869
+};
17870
+
17871
+/*
17872
+** Given the name of a compile-time option, return true if that option
17873
+** was used and false if not.
17874
+**
17875
+** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
17876
+** is not required for a match.
17877
+*/
17878
+SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
17879
+ int i, n;
17880
+
17881
+#if SQLITE_ENABLE_API_ARMOR
17882
+ if( zOptName==0 ){
17883
+ (void)SQLITE_MISUSE_BKPT;
17884
+ return 0;
17885
+ }
17886
+#endif
17887
+ if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
17888
+ n = sqlite3Strlen30(zOptName);
17889
+
17890
+ /* Since ArraySize(azCompileOpt) is normally in single digits, a
17891
+ ** linear search is adequate. No need for a binary search. */
17892
+ for(i=0; i<ArraySize(azCompileOpt); i++){
17893
+ if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0
17894
+ && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0
17895
+ ){
17896
+ return 1;
17897
+ }
17898
+ }
17899
+ return 0;
17900
+}
17901
+
17902
+/*
17903
+** Return the N-th compile-time option string. If N is out of range,
17904
+** return a NULL pointer.
17905
+*/
17906
+SQLITE_API const char *sqlite3_compileoption_get(int N){
17907
+ if( N>=0 && N<ArraySize(azCompileOpt) ){
17908
+ return azCompileOpt[N];
17909
+ }
17910
+ return 0;
17911
+}
17912
+
17913
+#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
17914
+
17915
+/************** End of ctime.c ***********************************************/
1832317916
/************** Begin file status.c ******************************************/
1832417917
/*
1832517918
** 2008 June 18
1832617919
**
1832717920
** The author disclaims copyright to this source code. In place of
@@ -18721,22 +18314,22 @@
1872118314
int rcApp; /* errcode set by sqlite3_result_error_code() */
1872218315
#endif
1872318316
u16 nResColumn; /* Number of columns in one row of the result set */
1872418317
u8 errorAction; /* Recovery action to do in case of an error */
1872518318
u8 minWriteFileFormat; /* Minimum file format for writable database files */
18726
- u8 prepFlags; /* SQLITE_PREPARE_* flags */
1872718319
bft expired:1; /* True if the VM needs to be recompiled */
1872818320
bft doingRerun:1; /* True if rerunning after an auto-reprepare */
1872918321
bft explain:2; /* True if EXPLAIN present on SQL command */
1873018322
bft changeCntOn:1; /* True to update the change-counter */
1873118323
bft runOnlyOnce:1; /* Automatically expire on reset */
1873218324
bft usesStmtJournal:1; /* True if uses a statement journal */
1873318325
bft readOnly:1; /* True for statements that do not write */
1873418326
bft bIsReader:1; /* True for statements that read */
18327
+ bft isPrepareV2:1; /* True if prepared with prepare_v2() */
1873518328
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
1873618329
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18737
- u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
18330
+ u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
1873818331
char *zSql; /* Text of the SQL statement that generated this */
1873918332
void *pFree; /* Free this when deleting the vdbe */
1874018333
VdbeFrame *pFrame; /* Parent frame */
1874118334
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
1874218335
int nFrame; /* Number of frames in pFrame list */
@@ -18845,11 +18438,11 @@
1884518438
1884618439
SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
1884718440
SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
1884818441
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
1884918442
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
18850
-SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
18443
+SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);
1885118444
SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
1885218445
SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
1885318446
SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
1885418447
1885518448
#if !defined(SQLITE_OMIT_SHARED_CACHE)
@@ -30045,11 +29638,11 @@
3004529638
/* 125 */ "Rowid" OpHelp("r[P2]=rowid"),
3004629639
/* 126 */ "NullRow" OpHelp(""),
3004729640
/* 127 */ "SorterInsert" OpHelp("key=r[P2]"),
3004829641
/* 128 */ "IdxInsert" OpHelp("key=r[P2]"),
3004929642
/* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
30050
- /* 130 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
29643
+ /* 130 */ "Seek" OpHelp("Move P3 to P1.rowid"),
3005129644
/* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"),
3005229645
/* 132 */ "Real" OpHelp("r[P2]=P4"),
3005329646
/* 133 */ "Destroy" OpHelp(""),
3005429647
/* 134 */ "Clear" OpHelp(""),
3005529648
/* 135 */ "ResetSorter" OpHelp(""),
@@ -50575,11 +50168,11 @@
5057550168
assert( isOpen(pPager->fd) );
5057650169
assert( pPager->tempFile==0 );
5057750170
nPage = sqlite3WalDbsize(pPager->pWal);
5057850171
5057950172
/* If the number of pages in the database is not available from the
50580
- ** WAL sub-system, determine the page count based on the size of
50173
+ ** WAL sub-system, determine the page counte based on the size of
5058150174
** the database file. If the size of the database file is not an
5058250175
** integer multiple of the page-size, round up the result.
5058350176
*/
5058450177
if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){
5058550178
i64 n = 0; /* Size of db file in bytes */
@@ -50626,25 +50219,27 @@
5062650219
assert( pPager->eState==PAGER_OPEN );
5062750220
assert( pPager->eLock>=SHARED_LOCK );
5062850221
5062950222
if( !pPager->tempFile ){
5063050223
int isWal; /* True if WAL file exists */
50631
- rc = sqlite3OsAccess(
50632
- pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
50633
- );
50224
+ Pgno nPage; /* Size of the database file */
50225
+
50226
+ rc = pagerPagecount(pPager, &nPage);
50227
+ if( rc ) return rc;
50228
+ if( nPage==0 ){
50229
+ rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
50230
+ if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;
50231
+ isWal = 0;
50232
+ }else{
50233
+ rc = sqlite3OsAccess(
50234
+ pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
50235
+ );
50236
+ }
5063450237
if( rc==SQLITE_OK ){
5063550238
if( isWal ){
50636
- Pgno nPage; /* Size of the database file */
50637
-
50638
- rc = pagerPagecount(pPager, &nPage);
50639
- if( rc ) return rc;
50640
- if( nPage==0 ){
50641
- rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
50642
- }else{
50643
- testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
50644
- rc = sqlite3PagerOpenWal(pPager, 0);
50645
- }
50239
+ testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
50240
+ rc = sqlite3PagerOpenWal(pPager, 0);
5064650241
}else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
5064750242
pPager->journalMode = PAGER_JOURNALMODE_DELETE;
5064850243
}
5064950244
}
5065050245
}
@@ -52583,18 +52178,23 @@
5258352178
**
5258452179
** There is a vanishingly small chance that a change will not be
5258552180
** detected. The chance of an undetected change is so small that
5258652181
** it can be neglected.
5258752182
*/
52183
+ Pgno nPage = 0;
5258852184
char dbFileVers[sizeof(pPager->dbFileVers)];
5258952185
52590
- IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
52591
- rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
52592
- if( rc!=SQLITE_OK ){
52593
- if( rc!=SQLITE_IOERR_SHORT_READ ){
52186
+ rc = pagerPagecount(pPager, &nPage);
52187
+ if( rc ) goto failed;
52188
+
52189
+ if( nPage>0 ){
52190
+ IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
52191
+ rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
52192
+ if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
5259452193
goto failed;
5259552194
}
52195
+ }else{
5259652196
memset(dbFileVers, 0, sizeof(dbFileVers));
5259752197
}
5259852198
5259952199
if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){
5260052200
pager_reset(pPager);
@@ -59584,11 +59184,11 @@
5958459184
/* If this database is not shareable, or if the client is reading
5958559185
** and has the read-uncommitted flag set, then no lock is required.
5958659186
** Return true immediately.
5958759187
*/
5958859188
if( (pBtree->sharable==0)
59589
- || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))
59189
+ || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))
5959059190
){
5959159191
return 1;
5959259192
}
5959359193
5959459194
/* If the client is reading or writing an index and the schema is
@@ -59661,11 +59261,11 @@
5966159261
static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
5966259262
BtCursor *p;
5966359263
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
5966459264
if( p->pgnoRoot==iRoot
5966559265
&& p->pBtree!=pBtree
59666
- && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)
59266
+ && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted)
5966759267
){
5966859268
return 1;
5966959269
}
5967059270
}
5967159271
return 0;
@@ -59683,11 +59283,11 @@
5968359283
BtLock *pIter;
5968459284
5968559285
assert( sqlite3BtreeHoldsMutex(p) );
5968659286
assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
5968759287
assert( p->db!=0 );
59688
- assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );
59288
+ assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 );
5968959289
5969059290
/* If requesting a write-lock, then the Btree must have an open write
5969159291
** transaction on this file. And, obviously, for this to be so there
5969259292
** must be an open write transaction on the file itself.
5969359293
*/
@@ -59761,11 +59361,11 @@
5976159361
5976259362
/* A connection with the read-uncommitted flag set will never try to
5976359363
** obtain a read-lock using this function. The only read-lock obtained
5976459364
** by a connection in read-uncommitted mode is on the sqlite_master
5976559365
** table, and that lock is obtained in BtreeBeginTrans(). */
59766
- assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );
59366
+ assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );
5976759367
5976859368
/* This function should only be called on a sharable b-tree after it
5976959369
** has been determined that no other b-tree holds a conflicting lock. */
5977059370
assert( p->sharable );
5977159371
assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -60203,11 +59803,11 @@
6020359803
assert( nKey==(i64)(int)nKey );
6020459804
pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);
6020559805
if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
6020659806
sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
6020759807
if( pIdxKey->nField==0 ){
60208
- rc = SQLITE_CORRUPT_PGNO(pCur->apPage[pCur->iPage]->pgno);
59808
+ rc = SQLITE_CORRUPT_BKPT;
6020959809
goto moveto_done;
6021059810
}
6021159811
}else{
6021259812
pIdxKey = 0;
6021359813
}
@@ -60432,11 +60032,11 @@
6043260032
assert( pEType!=0 );
6043360033
*pEType = pPtrmap[offset];
6043460034
if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
6043560035
6043660036
sqlite3PagerUnref(pDbPage);
60437
- if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap);
60037
+ if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT;
6043860038
return SQLITE_OK;
6043960039
}
6044060040
6044160041
#else /* if defined SQLITE_OMIT_AUTOVACUUM */
6044260042
#define ptrmapPut(w,x,y,z,rc)
@@ -60817,11 +60417,11 @@
6081760417
u8 *pAddr;
6081860418
int sz2 = 0;
6081960419
int sz = get2byte(&data[iFree+2]);
6082060420
int top = get2byte(&data[hdr+5]);
6082160421
if( iFree2 ){
60822
- if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60422
+ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_BKPT;
6082360423
sz2 = get2byte(&data[iFree2+2]);
6082460424
assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
6082560425
memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
6082660426
sz += sz2;
6082760427
}
@@ -60848,17 +60448,17 @@
6084860448
testcase( pc==iCellLast );
6084960449
/* These conditions have already been verified in btreeInitPage()
6085060450
** if PRAGMA cell_size_check=ON.
6085160451
*/
6085260452
if( pc<iCellFirst || pc>iCellLast ){
60853
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60453
+ return SQLITE_CORRUPT_BKPT;
6085460454
}
6085560455
assert( pc>=iCellFirst && pc<=iCellLast );
6085660456
size = pPage->xCellSize(pPage, &src[pc]);
6085760457
cbrk -= size;
6085860458
if( cbrk<iCellFirst || pc+size>usableSize ){
60859
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60459
+ return SQLITE_CORRUPT_BKPT;
6086060460
}
6086160461
assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
6086260462
testcase( cbrk+size==usableSize );
6086360463
testcase( pc+size==usableSize );
6086460464
put2byte(pAddr, cbrk);
@@ -60874,11 +60474,11 @@
6087460474
}
6087560475
data[hdr+7] = 0;
6087660476
6087760477
defragment_out:
6087860478
if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){
60879
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60479
+ return SQLITE_CORRUPT_BKPT;
6088060480
}
6088160481
assert( cbrk>=iCellFirst );
6088260482
put2byte(&data[hdr+5], cbrk);
6088360483
data[hdr+1] = 0;
6088460484
data[hdr+2] = 0;
@@ -60913,11 +60513,11 @@
6091360513
do{
6091460514
int size; /* Size of the free slot */
6091560515
/* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
6091660516
** increasing offset. */
6091760517
if( pc>usableSize-4 || pc<iAddr+4 ){
60918
- *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);
60518
+ *pRc = SQLITE_CORRUPT_BKPT;
6091960519
return 0;
6092060520
}
6092160521
/* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
6092260522
** freeblock form a big-endian integer which is the size of the freeblock
6092360523
** in bytes, including the 4-byte header. */
@@ -60924,11 +60524,11 @@
6092460524
size = get2byte(&aData[pc+2]);
6092560525
if( (x = size - nByte)>=0 ){
6092660526
testcase( x==4 );
6092760527
testcase( x==3 );
6092860528
if( pc < pPg->cellOffset+2*pPg->nCell || size+pc > usableSize ){
60929
- *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);
60529
+ *pRc = SQLITE_CORRUPT_BKPT;
6093060530
return 0;
6093160531
}else if( x<4 ){
6093260532
/* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
6093360533
** number of bytes in fragments may not exceed 60. */
6093460534
if( aData[hdr+7]>57 ) return 0;
@@ -60991,11 +60591,11 @@
6099160591
assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */
6099260592
if( gap>top ){
6099360593
if( top==0 && pPage->pBt->usableSize==65536 ){
6099460594
top = 65536;
6099560595
}else{
60996
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60596
+ return SQLITE_CORRUPT_BKPT;
6099760597
}
6099860598
}
6099960599
6100060600
/* If there is enough space between gap and top for one more cell pointer
6100160601
** array entry offset, and if the freelist is not empty, then search the
@@ -61087,15 +60687,15 @@
6108760687
iFreeBlk = 0; /* Shortcut for the case when the freelist is empty */
6108860688
}else{
6108960689
while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){
6109060690
if( iFreeBlk<iPtr+4 ){
6109160691
if( iFreeBlk==0 ) break;
61092
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60692
+ return SQLITE_CORRUPT_BKPT;
6109360693
}
6109460694
iPtr = iFreeBlk;
6109560695
}
61096
- if( iFreeBlk>iLast ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60696
+ if( iFreeBlk>iLast ) return SQLITE_CORRUPT_BKPT;
6109760697
assert( iFreeBlk>iPtr || iFreeBlk==0 );
6109860698
6109960699
/* At this point:
6110060700
** iFreeBlk: First freeblock after iStart, or zero if none
6110160701
** iPtr: The address of a pointer to iFreeBlk
@@ -61102,15 +60702,13 @@
6110260702
**
6110360703
** Check to see if iFreeBlk should be coalesced onto the end of iStart.
6110460704
*/
6110560705
if( iFreeBlk && iEnd+3>=iFreeBlk ){
6110660706
nFrag = iFreeBlk - iEnd;
61107
- if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60707
+ if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_BKPT;
6110860708
iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
61109
- if( iEnd > pPage->pBt->usableSize ){
61110
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61111
- }
60709
+ if( iEnd > pPage->pBt->usableSize ) return SQLITE_CORRUPT_BKPT;
6111260710
iSize = iEnd - iStart;
6111360711
iFreeBlk = get2byte(&data[iFreeBlk]);
6111460712
}
6111560713
6111660714
/* If iPtr is another freeblock (that is, if iPtr is not the freelist
@@ -61118,24 +60716,24 @@
6111860716
** coalesced onto the end of iPtr.
6111960717
*/
6112060718
if( iPtr>hdr+1 ){
6112160719
int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);
6112260720
if( iPtrEnd+3>=iStart ){
61123
- if( iPtrEnd>iStart ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60721
+ if( iPtrEnd>iStart ) return SQLITE_CORRUPT_BKPT;
6112460722
nFrag += iStart - iPtrEnd;
6112560723
iSize = iEnd - iPtr;
6112660724
iStart = iPtr;
6112760725
}
6112860726
}
61129
- if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60727
+ if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_BKPT;
6113060728
data[hdr+7] -= nFrag;
6113160729
}
6113260730
if( iStart==get2byte(&data[hdr+5]) ){
6113360731
/* The new freeblock is at the beginning of the cell content area,
6113460732
** so just extend the cell content area rather than create another
6113560733
** freelist entry */
61136
- if( iPtr!=hdr+1 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60734
+ if( iPtr!=hdr+1 ) return SQLITE_CORRUPT_BKPT;
6113760735
put2byte(&data[hdr+1], iFreeBlk);
6113860736
put2byte(&data[hdr+5], iEnd);
6113960737
}else{
6114060738
/* Insert the new freeblock into the freelist */
6114160739
put2byte(&data[iPtr], iStart);
@@ -61199,11 +60797,11 @@
6119960797
pPage->maxLocal = pBt->maxLocal;
6120060798
pPage->minLocal = pBt->minLocal;
6120160799
}else{
6120260800
/* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
6120360801
** an error. */
61204
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
60802
+ return SQLITE_CORRUPT_BKPT;
6120560803
}
6120660804
pPage->max1bytePayload = pBt->max1bytePayload;
6120760805
return SQLITE_OK;
6120860806
}
6120960807
@@ -61215,140 +60813,138 @@
6121560813
** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not
6121660814
** guarantee that the page is well-formed. It only shows that
6121760815
** we failed to detect any corruption.
6121860816
*/
6121960817
static int btreeInitPage(MemPage *pPage){
61220
- int pc; /* Address of a freeblock within pPage->aData[] */
61221
- u8 hdr; /* Offset to beginning of page header */
61222
- u8 *data; /* Equal to pPage->aData */
61223
- BtShared *pBt; /* The main btree structure */
61224
- int usableSize; /* Amount of usable space on each page */
61225
- u16 cellOffset; /* Offset from start of page to first cell pointer */
61226
- int nFree; /* Number of unused bytes on the page */
61227
- int top; /* First byte of the cell content area */
61228
- int iCellFirst; /* First allowable cell or freeblock offset */
61229
- int iCellLast; /* Last possible cell or freeblock offset */
6123060818
6123160819
assert( pPage->pBt!=0 );
6123260820
assert( pPage->pBt->db!=0 );
6123360821
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
6123460822
assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );
6123560823
assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );
6123660824
assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );
61237
- assert( pPage->isInit==0 );
61238
-
61239
- pBt = pPage->pBt;
61240
- hdr = pPage->hdrOffset;
61241
- data = pPage->aData;
61242
- /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating
61243
- ** the b-tree page type. */
61244
- if( decodeFlags(pPage, data[hdr]) ){
61245
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61246
- }
61247
- assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
61248
- pPage->maskPage = (u16)(pBt->pageSize - 1);
61249
- pPage->nOverflow = 0;
61250
- usableSize = pBt->usableSize;
61251
- pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;
61252
- pPage->aDataEnd = &data[usableSize];
61253
- pPage->aCellIdx = &data[cellOffset];
61254
- pPage->aDataOfst = &data[pPage->childPtrSize];
61255
- /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates
61256
- ** the start of the cell content area. A zero value for this integer is
61257
- ** interpreted as 65536. */
61258
- top = get2byteNotZero(&data[hdr+5]);
61259
- /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
61260
- ** number of cells on the page. */
61261
- pPage->nCell = get2byte(&data[hdr+3]);
61262
- if( pPage->nCell>MX_CELL(pBt) ){
61263
- /* To many cells for a single page. The page must be corrupt */
61264
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61265
- }
61266
- testcase( pPage->nCell==MX_CELL(pBt) );
61267
- /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
61268
- ** possible for a root page of a table that contains no rows) then the
61269
- ** offset to the cell content area will equal the page size minus the
61270
- ** bytes of reserved space. */
61271
- assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );
61272
-
61273
- /* A malformed database page might cause us to read past the end
61274
- ** of page when parsing a cell.
61275
- **
61276
- ** The following block of code checks early to see if a cell extends
61277
- ** past the end of a page boundary and causes SQLITE_CORRUPT to be
61278
- ** returned if it does.
61279
- */
61280
- iCellFirst = cellOffset + 2*pPage->nCell;
61281
- iCellLast = usableSize - 4;
61282
- if( pBt->db->flags & SQLITE_CellSizeCk ){
61283
- int i; /* Index into the cell pointer array */
61284
- int sz; /* Size of a cell */
61285
-
61286
- if( !pPage->leaf ) iCellLast--;
61287
- for(i=0; i<pPage->nCell; i++){
61288
- pc = get2byteAligned(&data[cellOffset+i*2]);
61289
- testcase( pc==iCellFirst );
61290
- testcase( pc==iCellLast );
61291
- if( pc<iCellFirst || pc>iCellLast ){
61292
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61293
- }
61294
- sz = pPage->xCellSize(pPage, &data[pc]);
61295
- testcase( pc+sz==usableSize );
61296
- if( pc+sz>usableSize ){
61297
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61298
- }
61299
- }
61300
- if( !pPage->leaf ) iCellLast++;
61301
- }
61302
-
61303
- /* Compute the total free space on the page
61304
- ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the
61305
- ** start of the first freeblock on the page, or is zero if there are no
61306
- ** freeblocks. */
61307
- pc = get2byte(&data[hdr+1]);
61308
- nFree = data[hdr+7] + top; /* Init nFree to non-freeblock free space */
61309
- if( pc>0 ){
61310
- u32 next, size;
61311
- if( pc<iCellFirst ){
61312
- /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will
61313
- ** always be at least one cell before the first freeblock.
61314
- */
61315
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61316
- }
61317
- while( 1 ){
61318
- if( pc>iCellLast ){
61319
- /* Freeblock off the end of the page */
61320
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61321
- }
61322
- next = get2byte(&data[pc]);
61323
- size = get2byte(&data[pc+2]);
61324
- nFree = nFree + size;
61325
- if( next<=pc+size+3 ) break;
61326
- pc = next;
61327
- }
61328
- if( next>0 ){
61329
- /* Freeblock not in ascending order */
61330
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61331
- }
61332
- if( pc+size>(unsigned int)usableSize ){
61333
- /* Last freeblock extends past page end */
61334
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61335
- }
61336
- }
61337
-
61338
- /* At this point, nFree contains the sum of the offset to the start
61339
- ** of the cell-content area plus the number of free bytes within
61340
- ** the cell-content area. If this is greater than the usable-size
61341
- ** of the page, then the page must be corrupted. This check also
61342
- ** serves to verify that the offset to the start of the cell-content
61343
- ** area, according to the page header, lies within the page.
61344
- */
61345
- if( nFree>usableSize ){
61346
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
61347
- }
61348
- pPage->nFree = (u16)(nFree - iCellFirst);
61349
- pPage->isInit = 1;
60825
+
60826
+ if( !pPage->isInit ){
60827
+ int pc; /* Address of a freeblock within pPage->aData[] */
60828
+ u8 hdr; /* Offset to beginning of page header */
60829
+ u8 *data; /* Equal to pPage->aData */
60830
+ BtShared *pBt; /* The main btree structure */
60831
+ int usableSize; /* Amount of usable space on each page */
60832
+ u16 cellOffset; /* Offset from start of page to first cell pointer */
60833
+ int nFree; /* Number of unused bytes on the page */
60834
+ int top; /* First byte of the cell content area */
60835
+ int iCellFirst; /* First allowable cell or freeblock offset */
60836
+ int iCellLast; /* Last possible cell or freeblock offset */
60837
+
60838
+ pBt = pPage->pBt;
60839
+
60840
+ hdr = pPage->hdrOffset;
60841
+ data = pPage->aData;
60842
+ /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating
60843
+ ** the b-tree page type. */
60844
+ if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;
60845
+ assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
60846
+ pPage->maskPage = (u16)(pBt->pageSize - 1);
60847
+ pPage->nOverflow = 0;
60848
+ usableSize = pBt->usableSize;
60849
+ pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;
60850
+ pPage->aDataEnd = &data[usableSize];
60851
+ pPage->aCellIdx = &data[cellOffset];
60852
+ pPage->aDataOfst = &data[pPage->childPtrSize];
60853
+ /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates
60854
+ ** the start of the cell content area. A zero value for this integer is
60855
+ ** interpreted as 65536. */
60856
+ top = get2byteNotZero(&data[hdr+5]);
60857
+ /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
60858
+ ** number of cells on the page. */
60859
+ pPage->nCell = get2byte(&data[hdr+3]);
60860
+ if( pPage->nCell>MX_CELL(pBt) ){
60861
+ /* To many cells for a single page. The page must be corrupt */
60862
+ return SQLITE_CORRUPT_BKPT;
60863
+ }
60864
+ testcase( pPage->nCell==MX_CELL(pBt) );
60865
+ /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
60866
+ ** possible for a root page of a table that contains no rows) then the
60867
+ ** offset to the cell content area will equal the page size minus the
60868
+ ** bytes of reserved space. */
60869
+ assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );
60870
+
60871
+ /* A malformed database page might cause us to read past the end
60872
+ ** of page when parsing a cell.
60873
+ **
60874
+ ** The following block of code checks early to see if a cell extends
60875
+ ** past the end of a page boundary and causes SQLITE_CORRUPT to be
60876
+ ** returned if it does.
60877
+ */
60878
+ iCellFirst = cellOffset + 2*pPage->nCell;
60879
+ iCellLast = usableSize - 4;
60880
+ if( pBt->db->flags & SQLITE_CellSizeCk ){
60881
+ int i; /* Index into the cell pointer array */
60882
+ int sz; /* Size of a cell */
60883
+
60884
+ if( !pPage->leaf ) iCellLast--;
60885
+ for(i=0; i<pPage->nCell; i++){
60886
+ pc = get2byteAligned(&data[cellOffset+i*2]);
60887
+ testcase( pc==iCellFirst );
60888
+ testcase( pc==iCellLast );
60889
+ if( pc<iCellFirst || pc>iCellLast ){
60890
+ return SQLITE_CORRUPT_BKPT;
60891
+ }
60892
+ sz = pPage->xCellSize(pPage, &data[pc]);
60893
+ testcase( pc+sz==usableSize );
60894
+ if( pc+sz>usableSize ){
60895
+ return SQLITE_CORRUPT_BKPT;
60896
+ }
60897
+ }
60898
+ if( !pPage->leaf ) iCellLast++;
60899
+ }
60900
+
60901
+ /* Compute the total free space on the page
60902
+ ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the
60903
+ ** start of the first freeblock on the page, or is zero if there are no
60904
+ ** freeblocks. */
60905
+ pc = get2byte(&data[hdr+1]);
60906
+ nFree = data[hdr+7] + top; /* Init nFree to non-freeblock free space */
60907
+ if( pc>0 ){
60908
+ u32 next, size;
60909
+ if( pc<iCellFirst ){
60910
+ /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will
60911
+ ** always be at least one cell before the first freeblock.
60912
+ */
60913
+ return SQLITE_CORRUPT_BKPT;
60914
+ }
60915
+ while( 1 ){
60916
+ if( pc>iCellLast ){
60917
+ return SQLITE_CORRUPT_BKPT; /* Freeblock off the end of the page */
60918
+ }
60919
+ next = get2byte(&data[pc]);
60920
+ size = get2byte(&data[pc+2]);
60921
+ nFree = nFree + size;
60922
+ if( next<=pc+size+3 ) break;
60923
+ pc = next;
60924
+ }
60925
+ if( next>0 ){
60926
+ return SQLITE_CORRUPT_BKPT; /* Freeblock not in ascending order */
60927
+ }
60928
+ if( pc+size>(unsigned int)usableSize ){
60929
+ return SQLITE_CORRUPT_BKPT; /* Last freeblock extends past page end */
60930
+ }
60931
+ }
60932
+
60933
+ /* At this point, nFree contains the sum of the offset to the start
60934
+ ** of the cell-content area plus the number of free bytes within
60935
+ ** the cell-content area. If this is greater than the usable-size
60936
+ ** of the page, then the page must be corrupted. This check also
60937
+ ** serves to verify that the offset to the start of the cell-content
60938
+ ** area, according to the page header, lies within the page.
60939
+ */
60940
+ if( nFree>usableSize ){
60941
+ return SQLITE_CORRUPT_BKPT;
60942
+ }
60943
+ pPage->nFree = (u16)(nFree - iCellFirst);
60944
+ pPage->isInit = 1;
60945
+ }
6135060946
return SQLITE_OK;
6135160947
}
6135260948
6135360949
/*
6135460950
** Set up a raw page so that it looks like a database page holding
@@ -61508,11 +61104,11 @@
6150861104
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
6150961105
6151061106
/* If obtaining a child page for a cursor, we must verify that the page is
6151161107
** compatible with the root page. */
6151261108
if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
61513
- rc = SQLITE_CORRUPT_PGNO(pgno);
61109
+ rc = SQLITE_CORRUPT_BKPT;
6151461110
releasePage(*ppPage);
6151561111
goto getAndInitPage_error;
6151661112
}
6151761113
return SQLITE_OK;
6151861114
@@ -62453,11 +62049,11 @@
6245362049
freeTempSpace(pBt);
6245462050
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
6245562051
pageSize-usableSize);
6245662052
return rc;
6245762053
}
62458
- if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
62054
+ if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
6245962055
rc = SQLITE_CORRUPT_BKPT;
6246062056
goto page1_init_failed;
6246162057
}
6246262058
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
6246362059
** be less than 480. In other words, if the page size is 512, then the
@@ -62796,11 +62392,11 @@
6279662392
int rc; /* Return code */
6279762393
BtShared *pBt = pPage->pBt;
6279862394
Pgno pgno = pPage->pgno;
6279962395
6280062396
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
62801
- rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
62397
+ rc = btreeInitPage(pPage);
6280262398
if( rc!=SQLITE_OK ) return rc;
6280362399
nCell = pPage->nCell;
6280462400
6280562401
for(i=0; i<nCell; i++){
6280662402
u8 *pCell = findCell(pPage, i);
@@ -62839,19 +62435,19 @@
6283962435
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
6284062436
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6284162437
if( eType==PTRMAP_OVERFLOW2 ){
6284262438
/* The pointer is always the first 4 bytes of the page in this case. */
6284362439
if( get4byte(pPage->aData)!=iFrom ){
62844
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
62440
+ return SQLITE_CORRUPT_BKPT;
6284562441
}
6284662442
put4byte(pPage->aData, iTo);
6284762443
}else{
6284862444
int i;
6284962445
int nCell;
6285062446
int rc;
6285162447
62852
- rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
62448
+ rc = btreeInitPage(pPage);
6285362449
if( rc ) return rc;
6285462450
nCell = pPage->nCell;
6285562451
6285662452
for(i=0; i<nCell; i++){
6285762453
u8 *pCell = findCell(pPage, i);
@@ -62858,11 +62454,11 @@
6285862454
if( eType==PTRMAP_OVERFLOW1 ){
6285962455
CellInfo info;
6286062456
pPage->xParseCell(pPage, pCell, &info);
6286162457
if( info.nLocal<info.nPayload ){
6286262458
if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){
62863
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
62459
+ return SQLITE_CORRUPT_BKPT;
6286462460
}
6286562461
if( iFrom==get4byte(pCell+info.nSize-4) ){
6286662462
put4byte(pCell+info.nSize-4, iTo);
6286762463
break;
6286862464
}
@@ -62876,11 +62472,11 @@
6287662472
}
6287762473
6287862474
if( i==nCell ){
6287962475
if( eType!=PTRMAP_BTREE ||
6288062476
get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){
62881
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
62477
+ return SQLITE_CORRUPT_BKPT;
6288262478
}
6288362479
put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);
6288462480
}
6288562481
}
6288662482
return SQLITE_OK;
@@ -63984,11 +63580,11 @@
6398463580
/* Trying to read or write past the end of the data is an error. The
6398563581
** conditional above is really:
6398663582
** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
6398763583
** but is recast into its current form to avoid integer overflow problems
6398863584
*/
63989
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
63585
+ return SQLITE_CORRUPT_BKPT;
6399063586
}
6399163587
6399263588
/* Check if data must be read/written to/from the btree page itself. */
6399363589
if( offset<pCur->info.nLocal ){
6399463590
int a = amt;
@@ -64131,12 +63727,11 @@
6413163727
iIdx++;
6413263728
}
6413363729
}
6413463730
6413563731
if( rc==SQLITE_OK && amt>0 ){
64136
- /* Overflow chain ends prematurely */
64137
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
63732
+ return SQLITE_CORRUPT_BKPT; /* Overflow chain ends prematurely */
6413863733
}
6413963734
return rc;
6414063735
}
6414163736
6414263737
/*
@@ -64398,11 +63993,11 @@
6439863993
** if pCur->iPage>=0). But this is not so if the database is corrupted
6439963994
** in such a way that page pRoot is linked into a second b-tree table
6440063995
** (or the freelist). */
6440163996
assert( pRoot->intKey==1 || pRoot->intKey==0 );
6440263997
if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
64403
- return SQLITE_CORRUPT_PGNO(pCur->apPage[pCur->iPage]->pgno);
63998
+ return SQLITE_CORRUPT_BKPT;
6440463999
}
6440564000
6440664001
skip_init:
6440764002
pCur->ix = 0;
6440864003
pCur->info.nSize = 0;
@@ -64603,23 +64198,20 @@
6460364198
return SQLITE_OK;
6460464199
}
6460564200
/* If the requested key is one more than the previous key, then
6460664201
** try to get there using sqlite3BtreeNext() rather than a full
6460764202
** binary search. This is an optimization only. The correct answer
64608
- ** is still obtained without this case, only a little more slowely */
64203
+ ** is still obtained without this ase, only a little more slowely */
6460964204
if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
6461064205
*pRes = 0;
64611
- rc = sqlite3BtreeNext(pCur, 0);
64612
- if( rc==SQLITE_OK ){
64206
+ rc = sqlite3BtreeNext(pCur, pRes);
64207
+ if( rc ) return rc;
64208
+ if( *pRes==0 ){
6461364209
getCellInfo(pCur);
6461464210
if( pCur->info.nKey==intKey ){
6461564211
return SQLITE_OK;
6461664212
}
64617
- }else if( rc==SQLITE_DONE ){
64618
- rc = SQLITE_OK;
64619
- }else{
64620
- return rc;
6462164213
}
6462264214
}
6462364215
}
6462464216
}
6462564217
@@ -64671,13 +64263,11 @@
6467164263
for(;;){
6467264264
i64 nCellKey;
6467364265
pCell = findCellPastPtr(pPage, idx);
6467464266
if( pPage->intKeyLeaf ){
6467564267
while( 0x80 <= *(pCell++) ){
64676
- if( pCell>=pPage->aDataEnd ){
64677
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
64678
- }
64268
+ if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
6467964269
}
6468064270
}
6468164271
getVarint(pCell, (u64*)&nCellKey);
6468264272
if( nCellKey<intKey ){
6468364273
lwr = idx+1;
@@ -64746,11 +64336,11 @@
6474664336
testcase( nCell<0 ); /* True if key size is 2^32 or more */
6474764337
testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
6474864338
testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
6474964339
testcase( nCell==2 ); /* Minimum legal index key size */
6475064340
if( nCell<2 ){
64751
- rc = SQLITE_CORRUPT_PGNO(pPage->pgno);
64341
+ rc = SQLITE_CORRUPT_BKPT;
6475264342
goto moveto_finish;
6475364343
}
6475464344
pCellKey = sqlite3Malloc( nCell+18 );
6475564345
if( pCellKey==0 ){
6475664346
rc = SQLITE_NOMEM_BKPT;
@@ -64851,44 +64441,47 @@
6485164441
}
6485264442
return n;
6485364443
}
6485464444
6485564445
/*
64856
-** Advance the cursor to the next entry in the database.
64857
-** Return value:
64858
-**
64859
-** SQLITE_OK success
64860
-** SQLITE_DONE cursor is already pointing at the last element
64861
-** otherwise some kind of error occurred
64446
+** Advance the cursor to the next entry in the database. If
64447
+** successful then set *pRes=0. If the cursor
64448
+** was already pointing to the last entry in the database before
64449
+** this routine was called, then set *pRes=1.
6486264450
**
6486364451
** The main entry point is sqlite3BtreeNext(). That routine is optimized
6486464452
** for the common case of merely incrementing the cell counter BtCursor.aiIdx
6486564453
** to the next cell on the current page. The (slower) btreeNext() helper
6486664454
** routine is called when it is necessary to move to a different page or
6486764455
** to restore the cursor.
6486864456
**
64869
-** If bit 0x01 of the flags argument is 1, then the cursor corresponds to
64870
-** an SQL index and this routine could have been skipped if the SQL index
64871
-** had been a unique index. The flags argument is a hint to the implement.
64872
-** SQLite btree implementation does not use this hint, but COMDB2 does.
64457
+** The calling function will set *pRes to 0 or 1. The initial *pRes value
64458
+** will be 1 if the cursor being stepped corresponds to an SQL index and
64459
+** if this routine could have been skipped if that SQL index had been
64460
+** a unique index. Otherwise the caller will have set *pRes to zero.
64461
+** Zero is the common case. The btree implementation is free to use the
64462
+** initial *pRes value as a hint to improve performance, but the current
64463
+** SQLite btree implementation does not. (Note that the comdb2 btree
64464
+** implementation does use this hint, however.)
6487364465
*/
64874
-static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int flags){
64466
+static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){
6487564467
int rc;
6487664468
int idx;
6487764469
MemPage *pPage;
6487864470
6487964471
assert( cursorOwnsBtShared(pCur) );
6488064472
assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64881
- assert( flags==0 );
64473
+ assert( *pRes==0 );
6488264474
if( pCur->eState!=CURSOR_VALID ){
6488364475
assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
6488464476
rc = restoreCursorPosition(pCur);
6488564477
if( rc!=SQLITE_OK ){
6488664478
return rc;
6488764479
}
6488864480
if( CURSOR_INVALID==pCur->eState ){
64889
- return SQLITE_DONE;
64481
+ *pRes = 1;
64482
+ return SQLITE_OK;
6489064483
}
6489164484
if( pCur->skipNext ){
6489264485
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
6489364486
pCur->eState = CURSOR_VALID;
6489464487
if( pCur->skipNext>0 ){
@@ -64916,18 +64509,19 @@
6491664509
if( rc ) return rc;
6491764510
return moveToLeftmost(pCur);
6491864511
}
6491964512
do{
6492064513
if( pCur->iPage==0 ){
64514
+ *pRes = 1;
6492164515
pCur->eState = CURSOR_INVALID;
64922
- return SQLITE_DONE;
64516
+ return SQLITE_OK;
6492364517
}
6492464518
moveToParent(pCur);
6492564519
pPage = pCur->apPage[pCur->iPage];
6492664520
}while( pCur->ix>=pPage->nCell );
6492764521
if( pPage->intKey ){
64928
- return sqlite3BtreeNext(pCur, flags);
64522
+ return sqlite3BtreeNext(pCur, pRes);
6492964523
}else{
6493064524
return SQLITE_OK;
6493164525
}
6493264526
}
6493364527
if( pPage->leaf ){
@@ -64934,66 +64528,71 @@
6493464528
return SQLITE_OK;
6493564529
}else{
6493664530
return moveToLeftmost(pCur);
6493764531
}
6493864532
}
64939
-SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){
64533
+SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
6494064534
MemPage *pPage;
6494164535
assert( cursorOwnsBtShared(pCur) );
64942
- assert( flags==0 || flags==1 );
64536
+ assert( pRes!=0 );
64537
+ assert( *pRes==0 || *pRes==1 );
6494364538
assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
6494464539
pCur->info.nSize = 0;
6494564540
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
64946
- if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, 0);
64541
+ *pRes = 0;
64542
+ if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, pRes);
6494764543
pPage = pCur->apPage[pCur->iPage];
6494864544
if( (++pCur->ix)>=pPage->nCell ){
6494964545
pCur->ix--;
64950
- return btreeNext(pCur, 0);
64546
+ return btreeNext(pCur, pRes);
6495164547
}
6495264548
if( pPage->leaf ){
6495364549
return SQLITE_OK;
6495464550
}else{
6495564551
return moveToLeftmost(pCur);
6495664552
}
6495764553
}
6495864554
6495964555
/*
64960
-** Step the cursor to the back to the previous entry in the database.
64961
-** Return values:
64962
-**
64963
-** SQLITE_OK success
64964
-** SQLITE_DONE the cursor is already on the first element of the table
64965
-** otherwise some kind of error occurred
64556
+** Step the cursor to the back to the previous entry in the database. If
64557
+** successful then set *pRes=0. If the cursor
64558
+** was already pointing to the first entry in the database before
64559
+** this routine was called, then set *pRes=1.
6496664560
**
6496764561
** The main entry point is sqlite3BtreePrevious(). That routine is optimized
6496864562
** for the common case of merely decrementing the cell counter BtCursor.aiIdx
6496964563
** to the previous cell on the current page. The (slower) btreePrevious()
6497064564
** helper routine is called when it is necessary to move to a different page
6497164565
** or to restore the cursor.
6497264566
**
64973
-**
64974
-** If bit 0x01 of the flags argument is 1, then the cursor corresponds to
64975
-** an SQL index and this routine could have been skipped if the SQL index
64976
-** had been a unique index. The flags argument is a hint to the implement.
64977
-** SQLite btree implementation does not use this hint, but COMDB2 does.
64567
+** The calling function will set *pRes to 0 or 1. The initial *pRes value
64568
+** will be 1 if the cursor being stepped corresponds to an SQL index and
64569
+** if this routine could have been skipped if that SQL index had been
64570
+** a unique index. Otherwise the caller will have set *pRes to zero.
64571
+** Zero is the common case. The btree implementation is free to use the
64572
+** initial *pRes value as a hint to improve performance, but the current
64573
+** SQLite btree implementation does not. (Note that the comdb2 btree
64574
+** implementation does use this hint, however.)
6497864575
*/
64979
-static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int flags){
64576
+static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){
6498064577
int rc;
6498164578
MemPage *pPage;
6498264579
6498364580
assert( cursorOwnsBtShared(pCur) );
64984
- assert( flags==0 );
64581
+ assert( pRes!=0 );
64582
+ assert( *pRes==0 );
6498564583
assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
6498664584
assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
6498764585
assert( pCur->info.nSize==0 );
6498864586
if( pCur->eState!=CURSOR_VALID ){
6498964587
rc = restoreCursorPosition(pCur);
6499064588
if( rc!=SQLITE_OK ){
6499164589
return rc;
6499264590
}
6499364591
if( CURSOR_INVALID==pCur->eState ){
64994
- return SQLITE_DONE;
64592
+ *pRes = 1;
64593
+ return SQLITE_OK;
6499564594
}
6499664595
if( pCur->skipNext ){
6499764596
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
6499864597
pCur->eState = CURSOR_VALID;
6499964598
if( pCur->skipNext<0 ){
@@ -65013,38 +64612,41 @@
6501364612
rc = moveToRightmost(pCur);
6501464613
}else{
6501564614
while( pCur->ix==0 ){
6501664615
if( pCur->iPage==0 ){
6501764616
pCur->eState = CURSOR_INVALID;
65018
- return SQLITE_DONE;
64617
+ *pRes = 1;
64618
+ return SQLITE_OK;
6501964619
}
6502064620
moveToParent(pCur);
6502164621
}
6502264622
assert( pCur->info.nSize==0 );
6502364623
assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );
6502464624
6502564625
pCur->ix--;
6502664626
pPage = pCur->apPage[pCur->iPage];
6502764627
if( pPage->intKey && !pPage->leaf ){
65028
- rc = sqlite3BtreePrevious(pCur, flags);
64628
+ rc = sqlite3BtreePrevious(pCur, pRes);
6502964629
}else{
6503064630
rc = SQLITE_OK;
6503164631
}
6503264632
}
6503364633
return rc;
6503464634
}
65035
-SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){
64635
+SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
6503664636
assert( cursorOwnsBtShared(pCur) );
65037
- assert( flags==0 || flags==1 );
64637
+ assert( pRes!=0 );
64638
+ assert( *pRes==0 || *pRes==1 );
6503864639
assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64640
+ *pRes = 0;
6503964641
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);
6504064642
pCur->info.nSize = 0;
6504164643
if( pCur->eState!=CURSOR_VALID
6504264644
|| pCur->ix==0
6504364645
|| pCur->apPage[pCur->iPage]->leaf==0
6504464646
){
65045
- return btreePrevious(pCur, 0);
64647
+ return btreePrevious(pCur, pRes);
6504664648
}
6504764649
pCur->ix--;
6504864650
return SQLITE_OK;
6504964651
}
6505064652
@@ -65148,11 +64750,11 @@
6514864750
** the freelist is empty. */
6514964751
iTrunk = get4byte(&pPage1->aData[32]);
6515064752
}
6515164753
testcase( iTrunk==mxPage );
6515264754
if( iTrunk>mxPage || nSearch++ > n ){
65153
- rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);
64755
+ rc = SQLITE_CORRUPT_BKPT;
6515464756
}else{
6515564757
rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
6515664758
}
6515764759
if( rc ){
6515864760
pTrunk = 0;
@@ -65177,11 +64779,11 @@
6517764779
*ppPage = pTrunk;
6517864780
pTrunk = 0;
6517964781
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
6518064782
}else if( k>(u32)(pBt->usableSize/4 - 2) ){
6518164783
/* Value of k is out of range. Database corruption */
65182
- rc = SQLITE_CORRUPT_PGNO(iTrunk);
64784
+ rc = SQLITE_CORRUPT_BKPT;
6518364785
goto end_allocate_page;
6518464786
#ifndef SQLITE_OMIT_AUTOVACUUM
6518564787
}else if( searchList
6518664788
&& (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE))
6518764789
){
@@ -65211,11 +64813,11 @@
6521164813
** page in this case.
6521264814
*/
6521364815
MemPage *pNewTrunk;
6521464816
Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
6521564817
if( iNewTrunk>mxPage ){
65216
- rc = SQLITE_CORRUPT_PGNO(iTrunk);
64818
+ rc = SQLITE_CORRUPT_BKPT;
6521764819
goto end_allocate_page;
6521864820
}
6521964821
testcase( iNewTrunk==mxPage );
6522064822
rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);
6522164823
if( rc!=SQLITE_OK ){
@@ -65276,11 +64878,11 @@
6527664878
}
6527764879
6527864880
iPage = get4byte(&aData[8+closest*4]);
6527964881
testcase( iPage==mxPage );
6528064882
if( iPage>mxPage ){
65281
- rc = SQLITE_CORRUPT_PGNO(iTrunk);
64883
+ rc = SQLITE_CORRUPT_BKPT;
6528264884
goto end_allocate_page;
6528364885
}
6528464886
testcase( iPage==mxPage );
6528564887
if( !searchList
6528664888
|| (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE))
@@ -65546,12 +65148,11 @@
6554665148
pPage->xParseCell(pPage, pCell, pInfo);
6554765149
if( pInfo->nLocal==pInfo->nPayload ){
6554865150
return SQLITE_OK; /* No overflow pages. Return without doing anything */
6554965151
}
6555065152
if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){
65551
- /* Cell extends past end of page */
65552
- return SQLITE_CORRUPT_PGNO(pPage->pgno);
65153
+ return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */
6555365154
}
6555465155
ovflPgno = get4byte(pCell + pInfo->nSize - 4);
6555565156
assert( pBt->usableSize > 4 );
6555665157
ovflPageSize = pBt->usableSize - 4;
6555765158
nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;
@@ -67762,12 +67363,12 @@
6776267363
** from the internal node. The 'previous' entry is used for this instead
6776367364
** of the 'next' entry, as the previous entry is always a part of the
6776467365
** sub-tree headed by the child page of the cell being deleted. This makes
6776567366
** balancing the tree following the delete operation easier. */
6776667367
if( !pPage->leaf ){
67767
- rc = sqlite3BtreePrevious(pCur, 0);
67768
- assert( rc!=SQLITE_DONE );
67368
+ int notUsed = 0;
67369
+ rc = sqlite3BtreePrevious(pCur, &notUsed);
6776967370
if( rc ) return rc;
6777067371
}
6777167372
6777267373
/* Save the positions of any other cursors open on this table before
6777367374
** making any modifications. */
@@ -71423,11 +71024,11 @@
7142371024
if( enc!=SQLITE_UTF8 ){
7142471025
rc = sqlite3VdbeChangeEncoding(pVal, enc);
7142571026
}
7142671027
}else if( op==TK_UMINUS ) {
7142771028
/* This branch happens for multiple negative signs. Ex: -(-5) */
71428
- if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx)
71029
+ if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
7142971030
&& pVal!=0
7143071031
){
7143171032
sqlite3VdbeMemNumerify(pVal);
7143271033
if( pVal->flags & MEM_Real ){
7143371034
pVal->u.r = -pVal->u.r;
@@ -71580,25 +71181,28 @@
7158071181
sqlite3 *db = pParse->db;
7158171182
7158271183
/* Skip over any TK_COLLATE nodes */
7158371184
pExpr = sqlite3ExprSkipCollate(pExpr);
7158471185
71585
- assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );
7158671186
if( !pExpr ){
7158771187
pVal = valueNew(db, pAlloc);
7158871188
if( pVal ){
7158971189
sqlite3VdbeMemSetNull((Mem*)pVal);
7159071190
}
71591
- }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
71191
+ }else if( pExpr->op==TK_VARIABLE
71192
+ || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
71193
+ ){
7159271194
Vdbe *v;
7159371195
int iBindVar = pExpr->iColumn;
7159471196
sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
7159571197
if( (v = pParse->pReprepare)!=0 ){
7159671198
pVal = valueNew(db, pAlloc);
7159771199
if( pVal ){
7159871200
rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71599
- sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
71201
+ if( rc==SQLITE_OK ){
71202
+ sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
71203
+ }
7160071204
pVal->db = pParse->db;
7160171205
}
7160271206
}
7160371207
}else{
7160471208
rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71868,18 +71472,20 @@
7186871472
}
7186971473
7187071474
/*
7187171475
** Remember the SQL string for a prepared statement.
7187271476
*/
71873
-SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
71477
+SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71478
+ assert( isPrepareV2==1 || isPrepareV2==0 );
7187471479
if( p==0 ) return;
71875
- p->prepFlags = prepFlags;
71876
- if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
71877
- p->expmask = 0;
71878
- }
71480
+ if( !isPrepareV2 ) p->expmask = 0;
71481
+#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71482
+ if( !isPrepareV2 ) return;
71483
+#endif
7187971484
assert( p->zSql==0 );
7188071485
p->zSql = sqlite3DbStrNDup(p->db, z, n);
71486
+ p->isPrepareV2 = (u8)isPrepareV2;
7188171487
}
7188271488
7188371489
/*
7188471490
** Swap all content between two VDBE structures.
7188571491
*/
@@ -71897,14 +71503,12 @@
7189771503
pA->pPrev = pB->pPrev;
7189871504
pB->pPrev = pTmp;
7189971505
zTmp = pA->zSql;
7190071506
pA->zSql = pB->zSql;
7190171507
pB->zSql = zTmp;
71508
+ pB->isPrepareV2 = pA->isPrepareV2;
7190271509
pB->expmask = pA->expmask;
71903
- pB->prepFlags = pA->prepFlags;
71904
- memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
71905
- pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
7190671510
}
7190771511
7190871512
/*
7190971513
** Resize the Vdbe.aOp array so that it is at least nOp elements larger
7191071514
** than its current size. nOp is guaranteed to be less than or equal
@@ -73974,22 +73578,21 @@
7397473578
** statement. This is now set at compile time, rather than during
7397573579
** execution of the vdbe program so that sqlite3_column_count() can
7397673580
** be called on an SQL statement before sqlite3_step().
7397773581
*/
7397873582
SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
73583
+ Mem *pColName;
7397973584
int n;
7398073585
sqlite3 *db = p->db;
7398173586
73982
- if( p->nResColumn ){
73983
- releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
73984
- sqlite3DbFree(db, p->aColName);
73985
- }
73587
+ releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
73588
+ sqlite3DbFree(db, p->aColName);
7398673589
n = nResColumn*COLNAME_N;
7398773590
p->nResColumn = (u16)nResColumn;
73988
- p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );
73591
+ p->aColName = pColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );
7398973592
if( p->aColName==0 ) return;
73990
- initMemArray(p->aColName, n, db, MEM_Null);
73593
+ initMemArray(p->aColName, n, p->db, MEM_Null);
7399173594
}
7399273595
7399373596
/*
7399473597
** Set the name of the idx'th column to be returned by the SQL statement.
7399573598
** zName must be a pointer to a nul terminated string.
@@ -74635,14 +74238,14 @@
7463574238
sqlite3BeginBenignMalloc();
7463674239
if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);
7463774240
sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
7463874241
sqlite3EndBenignMalloc();
7463974242
db->bBenignMalloc--;
74640
- }else if( db->pErr ){
74641
- sqlite3ValueSetNull(db->pErr);
74243
+ db->errCode = rc;
74244
+ }else{
74245
+ sqlite3Error(db, rc);
7464274246
}
74643
- db->errCode = rc;
7464474247
return rc;
7464574248
}
7464674249
7464774250
#ifdef SQLITE_ENABLE_SQLLOG
7464874251
/*
@@ -75546,24 +75149,23 @@
7554675149
** comparison function directly */
7554775150
return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
7554875151
}else{
7554975152
int rc;
7555075153
const void *v1, *v2;
75154
+ int n1, n2;
7555175155
Mem c1;
7555275156
Mem c2;
7555375157
sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
7555475158
sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
7555575159
sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
7555675160
sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
7555775161
v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
75162
+ n1 = v1==0 ? 0 : c1.n;
7555875163
v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
75559
- if( (v1==0 || v2==0) ){
75560
- if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
75561
- rc = 0;
75562
- }else{
75563
- rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
75564
- }
75164
+ n2 = v2==0 ? 0 : c2.n;
75165
+ rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
75166
+ if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
7556575167
sqlite3VdbeMemRelease(&c1);
7556675168
sqlite3VdbeMemRelease(&c2);
7556775169
return rc;
7556875170
}
7556975171
}
@@ -76344,17 +75946,10 @@
7634475946
*/
7634575947
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
7634675948
return v->db;
7634775949
}
7634875950
76349
-/*
76350
-** Return the SQLITE_PREPARE flags for a Vdbe.
76351
-*/
76352
-SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){
76353
- return v->prepFlags;
76354
-}
76355
-
7635675951
/*
7635775952
** Return a pointer to an sqlite3_value structure containing the value bound
7635875953
** parameter iVar of VM v. Except, if the value is an SQL NULL, return
7635975954
** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
7636075955
** constants) to the value before returning it.
@@ -76363,11 +75958,10 @@
7636375958
*/
7636475959
SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
7636575960
assert( iVar>0 );
7636675961
if( v ){
7636775962
Mem *pMem = &v->aVar[iVar-1];
76368
- assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
7636975963
if( 0==(pMem->flags & MEM_Null) ){
7637075964
sqlite3_value *pRet = sqlite3ValueNew(v->db);
7637175965
if( pRet ){
7637275966
sqlite3VdbeMemCopy((Mem *)pRet, pMem);
7637375967
sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76383,11 +75977,10 @@
7638375977
** to sqlite3_reoptimize() that re-preparing the statement may result
7638475978
** in a better query plan.
7638575979
*/
7638675980
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
7638775981
assert( iVar>0 );
76388
- assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
7638975982
if( iVar>=32 ){
7639075983
v->expmask |= 0x80000000;
7639175984
}else{
7639275985
v->expmask |= ((u32)1 << (iVar-1));
7639375986
}
@@ -76655,11 +76248,11 @@
7665576248
sqlite3_mutex_enter(mutex);
7665676249
for(i=0; i<p->nVar; i++){
7665776250
sqlite3VdbeMemRelease(&p->aVar[i]);
7665876251
p->aVar[i].flags = MEM_Null;
7665976252
}
76660
- assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
76253
+ assert( p->isPrepareV2 || p->expmask==0 );
7666176254
if( p->expmask ){
7666276255
p->expired = 1;
7666376256
}
7666476257
sqlite3_mutex_leave(mutex);
7666576258
return rc;
@@ -77134,15 +76727,12 @@
7713476727
*/
7713576728
assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
7713676729
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
7713776730
);
7713876731
assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
77139
- if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
77140
- && rc!=SQLITE_ROW
77141
- && rc!=SQLITE_DONE
77142
- ){
77143
- /* If this statement was prepared using saved SQL and an
76732
+ if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
76733
+ /* If this statement was prepared using sqlite3_prepare_v2(), and an
7714476734
** error has occurred, then return the error code in p->rc to the
7714576735
** caller. Set the error code in the database handle to the same value.
7714676736
*/
7714776737
rc = sqlite3VdbeTransferError(p);
7714876738
}
@@ -77777,11 +77367,11 @@
7777777367
** parameter in the WHERE clause might influence the choice of query plan
7777877368
** for a statement, then the statement will be automatically recompiled,
7777977369
** as if there had been a schema change, on the first sqlite3_step() call
7778077370
** following any change to the bindings of that parameter.
7778177371
*/
77782
- assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
77372
+ assert( p->isPrepareV2 || p->expmask==0 );
7778377373
if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
7778477374
p->expired = 1;
7778577375
}
7778677376
return SQLITE_OK;
7778777377
}
@@ -77807,14 +77397,12 @@
7780777397
pVar = &p->aVar[i-1];
7780877398
rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
7780977399
if( rc==SQLITE_OK && encoding!=0 ){
7781077400
rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
7781177401
}
77812
- if( rc ){
77813
- sqlite3Error(p->db, rc);
77814
- rc = sqlite3ApiExit(p->db, rc);
77815
- }
77402
+ sqlite3Error(p->db, rc);
77403
+ rc = sqlite3ApiExit(p->db, rc);
7781677404
}
7781777405
sqlite3_mutex_leave(p->db->mutex);
7781877406
}else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){
7781977407
xDel((void*)zData);
7782077408
}
@@ -78043,15 +77631,15 @@
7804377631
Vdbe *pFrom = (Vdbe*)pFromStmt;
7804477632
Vdbe *pTo = (Vdbe*)pToStmt;
7804577633
if( pFrom->nVar!=pTo->nVar ){
7804677634
return SQLITE_ERROR;
7804777635
}
78048
- assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );
77636
+ assert( pTo->isPrepareV2 || pTo->expmask==0 );
7804977637
if( pTo->expmask ){
7805077638
pTo->expired = 1;
7805177639
}
78052
- assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );
77640
+ assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
7805377641
if( pFrom->expmask ){
7805477642
pFrom->expired = 1;
7805577643
}
7805677644
return sqlite3TransferBindings(pFromStmt, pToStmt);
7805777645
}
@@ -78117,23 +77705,12 @@
7811777705
if( !pStmt ){
7811877706
(void)SQLITE_MISUSE_BKPT;
7811977707
return 0;
7812077708
}
7812177709
#endif
78122
- if( op==SQLITE_STMTSTATUS_MEMUSED ){
78123
- sqlite3 *db = pVdbe->db;
78124
- sqlite3_mutex_enter(db->mutex);
78125
- v = 0;
78126
- db->pnBytesFreed = (int*)&v;
78127
- sqlite3VdbeClearObject(db, pVdbe);
78128
- sqlite3DbFree(db, pVdbe);
78129
- db->pnBytesFreed = 0;
78130
- sqlite3_mutex_leave(db->mutex);
78131
- }else{
78132
- v = pVdbe->aCounter[op];
78133
- if( resetFlag ) pVdbe->aCounter[op] = 0;
78134
- }
77710
+ v = pVdbe->aCounter[op];
77711
+ if( resetFlag ) pVdbe->aCounter[op] = 0;
7813577712
return (int)v;
7813677713
}
7813777714
7813877715
/*
7813977716
** Return the SQL associated with a prepared statement
@@ -79284,11 +78861,11 @@
7928478861
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
7928578862
u8 encoding = ENC(db); /* The database encoding */
7928678863
int iCompare = 0; /* Result of last comparison */
7928778864
unsigned nVmStep = 0; /* Number of virtual machine steps */
7928878865
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
79289
- unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
78866
+ unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
7929078867
#endif
7929178868
Mem *aMem = p->aMem; /* Copy of p->aMem */
7929278869
Mem *pIn1 = 0; /* 1st input operand */
7929378870
Mem *pIn2 = 0; /* 2nd input operand */
7929478871
Mem *pIn3 = 0; /* 3rd input operand */
@@ -79316,12 +78893,10 @@
7931678893
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
7931778894
if( db->xProgress ){
7931878895
u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];
7931978896
assert( 0 < db->nProgressOps );
7932078897
nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);
79321
- }else{
79322
- nProgressLimit = 0xffffffff;
7932378898
}
7932478899
#endif
7932578900
#ifdef SQLITE_DEBUG
7932678901
sqlite3BeginBenignMalloc();
7932778902
if( p->pc==0
@@ -79495,11 +79070,11 @@
7949579070
** of VDBE ops have been executed (either since this invocation of
7949679071
** sqlite3VdbeExec() or since last time the progress callback was called).
7949779072
** If the progress callback returns non-zero, exit the virtual machine with
7949879073
** a return code SQLITE_ABORT.
7949979074
*/
79500
- if( nVmStep>=nProgressLimit && db->xProgress!=0 ){
79075
+ if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
7950179076
assert( db->nProgressOps!=0 );
7950279077
nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
7950379078
if( db->xProgress(db->pProgressArg) ){
7950479079
rc = SQLITE_INTERRUPT;
7950579080
goto abort_due_to_error;
@@ -80037,11 +79612,11 @@
8003779612
8003879613
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
8003979614
/* Run the progress counter just before returning.
8004079615
*/
8004179616
if( db->xProgress!=0
80042
- && nVmStep>=nProgressLimit
79617
+ && nVmStep>=nProgressLimit
8004379618
&& db->xProgress(db->pProgressArg)!=0
8004479619
){
8004579620
rc = SQLITE_INTERRUPT;
8004679621
goto abort_due_to_error;
8004779622
}
@@ -81208,13 +80783,11 @@
8120880783
Mem *pReg; /* PseudoTable input register */
8120980784
8121080785
pC = p->apCsr[pOp->p1];
8121180786
p2 = pOp->p2;
8121280787
81213
- /* If the cursor cache is stale (meaning it is not currently point at
81214
- ** the correct row) then bring it up-to-date by doing the necessary
81215
- ** B-Tree seek. */
80788
+ /* If the cursor cache is stale, bring it up-to-date */
8121680789
rc = sqlite3VdbeCursorMoveto(&pC, &p2);
8121780790
if( rc ) goto abort_due_to_error;
8121880791
8121980792
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
8122080793
pDest = &aMem[pOp->p3];
@@ -82692,35 +82265,21 @@
8269282265
sqlite3_search_count++;
8269382266
#endif
8269482267
if( oc>=OP_SeekGE ){ assert( oc==OP_SeekGE || oc==OP_SeekGT );
8269582268
if( res<0 || (res==0 && oc==OP_SeekGT) ){
8269682269
res = 0;
82697
- rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
82698
- if( rc!=SQLITE_OK ){
82699
- if( rc==SQLITE_DONE ){
82700
- rc = SQLITE_OK;
82701
- res = 1;
82702
- }else{
82703
- goto abort_due_to_error;
82704
- }
82705
- }
82270
+ rc = sqlite3BtreeNext(pC->uc.pCursor, &res);
82271
+ if( rc!=SQLITE_OK ) goto abort_due_to_error;
8270682272
}else{
8270782273
res = 0;
8270882274
}
8270982275
}else{
8271082276
assert( oc==OP_SeekLT || oc==OP_SeekLE );
8271182277
if( res>0 || (res==0 && oc==OP_SeekLT) ){
8271282278
res = 0;
82713
- rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);
82714
- if( rc!=SQLITE_OK ){
82715
- if( rc==SQLITE_DONE ){
82716
- rc = SQLITE_OK;
82717
- res = 1;
82718
- }else{
82719
- goto abort_due_to_error;
82720
- }
82721
- }
82279
+ rc = sqlite3BtreePrevious(pC->uc.pCursor, &res);
82280
+ if( rc!=SQLITE_OK ) goto abort_due_to_error;
8272282281
}else{
8272382282
/* res might be negative because the table is empty. Check to
8272482283
** see if this is the case.
8272582284
*/
8272682285
res = sqlite3BtreeEof(pC->uc.pCursor);
@@ -83822,14 +83381,16 @@
8382283381
** invoked. This opcode advances the cursor to the next sorted
8382383382
** record, or jumps to P2 if there are no more sorted records.
8382483383
*/
8382583384
case OP_SorterNext: { /* jump */
8382683385
VdbeCursor *pC;
83386
+ int res;
8382783387
8382883388
pC = p->apCsr[pOp->p1];
8382983389
assert( isSorter(pC) );
83830
- rc = sqlite3VdbeSorterNext(db, pC);
83390
+ res = 0;
83391
+ rc = sqlite3VdbeSorterNext(db, pC, &res);
8383183392
goto next_tail;
8383283393
case OP_PrevIfOpen: /* jump */
8383383394
case OP_NextIfOpen: /* jump */
8383483395
if( p->apCsr[pOp->p1]==0 ) break;
8383583396
/* Fall through */
@@ -83836,13 +83397,16 @@
8383683397
case OP_Prev: /* jump */
8383783398
case OP_Next: /* jump */
8383883399
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8383983400
assert( pOp->p5<ArraySize(p->aCounter) );
8384083401
pC = p->apCsr[pOp->p1];
83402
+ res = pOp->p3;
8384183403
assert( pC!=0 );
8384283404
assert( pC->deferredMoveto==0 );
8384383405
assert( pC->eCurType==CURTYPE_BTREE );
83406
+ assert( res==0 || (res==1 && pC->isTable==0) );
83407
+ testcase( res==1 );
8384483408
assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
8384583409
assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
8384683410
assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
8384783411
assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
8384883412
@@ -83853,25 +83417,25 @@
8385383417
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
8385483418
assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
8385583419
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
8385683420
|| pC->seekOp==OP_Last );
8385783421
83858
- rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
83422
+ rc = pOp->p4.xAdvance(pC->uc.pCursor, &res);
8385983423
next_tail:
8386083424
pC->cacheStatus = CACHE_STALE;
83861
- VdbeBranchTaken(rc==SQLITE_OK,2);
83862
- if( rc==SQLITE_OK ){
83425
+ VdbeBranchTaken(res==0,2);
83426
+ if( rc ) goto abort_due_to_error;
83427
+ if( res==0 ){
8386383428
pC->nullRow = 0;
8386483429
p->aCounter[pOp->p5]++;
8386583430
#ifdef SQLITE_TEST
8386683431
sqlite3_search_count++;
8386783432
#endif
8386883433
goto jump_to_p2_and_check_for_interrupt;
83434
+ }else{
83435
+ pC->nullRow = 1;
8386983436
}
83870
- if( rc!=SQLITE_DONE ) goto abort_due_to_error;
83871
- rc = SQLITE_OK;
83872
- pC->nullRow = 1;
8387383437
goto check_for_interrupt;
8387483438
}
8387583439
8387683440
/* Opcode: IdxInsert P1 P2 P3 P4 P5
8387783441
** Synopsis: key=r[P2]
@@ -83978,12 +83542,12 @@
8397883542
pC->cacheStatus = CACHE_STALE;
8397983543
pC->seekResult = 0;
8398083544
break;
8398183545
}
8398283546
83983
-/* Opcode: DeferredSeek P1 * P3 P4 *
83984
-** Synopsis: Move P3 to P1.rowid if needed
83547
+/* Opcode: Seek P1 * P3 P4 *
83548
+** Synopsis: Move P3 to P1.rowid
8398583549
**
8398683550
** P1 is an open index cursor and P3 is a cursor on the corresponding
8398783551
** table. This opcode does a deferred seek of the P3 table cursor
8398883552
** to the row that corresponds to the current row of P1.
8398983553
**
@@ -84006,15 +83570,15 @@
8400683570
** the end of the index key pointed to by cursor P1. This integer should be
8400783571
** the rowid of the table entry to which this index entry points.
8400883572
**
8400983573
** See also: Rowid, MakeRecord.
8401083574
*/
84011
-case OP_DeferredSeek:
84012
-case OP_IdxRowid: { /* out2 */
84013
- VdbeCursor *pC; /* The P1 index cursor */
84014
- VdbeCursor *pTabCur; /* The P2 table cursor (OP_DeferredSeek only) */
84015
- i64 rowid; /* Rowid that P1 current points to */
83575
+case OP_Seek:
83576
+case OP_IdxRowid: { /* out2 */
83577
+ VdbeCursor *pC; /* The P1 index cursor */
83578
+ VdbeCursor *pTabCur; /* The P2 table cursor (OP_Seek only) */
83579
+ i64 rowid; /* Rowid that P1 current points to */
8401683580
8401783581
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8401883582
pC = p->apCsr[pOp->p1];
8401983583
assert( pC!=0 );
8402083584
assert( pC->eCurType==CURTYPE_BTREE );
@@ -84036,11 +83600,11 @@
8403683600
rowid = 0; /* Not needed. Only used to silence a warning. */
8403783601
rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);
8403883602
if( rc!=SQLITE_OK ){
8403983603
goto abort_due_to_error;
8404083604
}
84041
- if( pOp->opcode==OP_DeferredSeek ){
83605
+ if( pOp->opcode==OP_Seek ){
8404283606
assert( pOp->p3>=0 && pOp->p3<p->nCursor );
8404383607
pTabCur = p->apCsr[pOp->p3];
8404483608
assert( pTabCur!=0 );
8404583609
assert( pTabCur->eCurType==CURTYPE_BTREE );
8404683610
assert( pTabCur->uc.pCursor!=0 );
@@ -85282,11 +84846,11 @@
8528284846
** P4 contains a pointer to the name of the table being locked. This is only
8528384847
** used to generate an error message if the lock cannot be obtained.
8528484848
*/
8528584849
case OP_TableLock: {
8528684850
u8 isWriteLock = (u8)pOp->p3;
85287
- if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){
84851
+ if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){
8528884852
int p1 = pOp->p1;
8528984853
assert( p1>=0 && p1<db->nDb );
8529084854
assert( DbMaskTest(p->btreeMask, p1) );
8529184855
assert( isWriteLock==0 || isWriteLock==1 );
8529284856
rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85790,11 +85354,10 @@
8579085354
if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
8579185355
}
8579285356
pOp->p1 = 0;
8579385357
}
8579485358
pOp->p1++;
85795
- p->aCounter[SQLITE_STMTSTATUS_RUN]++;
8579685359
goto jump_to_p2;
8579785360
}
8579885361
8579985362
#ifdef SQLITE_ENABLE_CURSOR_HINTS
8580085363
/* Opcode: CursorHint P1 * * P4 *
@@ -87264,13 +86827,13 @@
8726486827
8726586828
int n1;
8726686829
int n2;
8726786830
int res;
8726886831
87269
- getVarint32(&p1[1], n1);
87270
- getVarint32(&p2[1], n2);
87271
- res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);
86832
+ getVarint32(&p1[1], n1); n1 = (n1 - 13) / 2;
86833
+ getVarint32(&p2[1], n2); n2 = (n2 - 13) / 2;
86834
+ res = memcmp(v1, v2, MIN(n1, n2));
8727286835
if( res==0 ){
8727386836
res = n1 - n2;
8727486837
}
8727586838
8727686839
if( res==0 ){
@@ -89061,17 +88624,13 @@
8906188624
vdbeSorterRewindDebug("rewinddone");
8906288625
return rc;
8906388626
}
8906488627
8906588628
/*
89066
-** Advance to the next element in the sorter. Return value:
89067
-**
89068
-** SQLITE_OK success
89069
-** SQLITE_DONE end of data
89070
-** otherwise some kind of error.
88629
+** Advance to the next element in the sorter.
8907188630
*/
89072
-SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr){
88631
+SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){
8907388632
VdbeSorter *pSorter;
8907488633
int rc; /* Return code */
8907588634
8907688635
assert( pCsr->eCurType==CURTYPE_SORTER );
8907788636
pSorter = pCsr->uc.pSorter;
@@ -89081,26 +88640,25 @@
8908188640
assert( pSorter->bUseThreads==0 || pSorter->pReader );
8908288641
assert( pSorter->bUseThreads==1 || pSorter->pMerger );
8908388642
#if SQLITE_MAX_WORKER_THREADS>0
8908488643
if( pSorter->bUseThreads ){
8908588644
rc = vdbePmaReaderNext(pSorter->pReader);
89086
- if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;
88645
+ *pbEof = (pSorter->pReader->pFd==0);
8908788646
}else
8908888647
#endif
8908988648
/*if( !pSorter->bUseThreads )*/ {
89090
- int res = 0;
8909188649
assert( pSorter->pMerger!=0 );
8909288650
assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );
89093
- rc = vdbeMergeEngineStep(pSorter->pMerger, &res);
89094
- if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;
88651
+ rc = vdbeMergeEngineStep(pSorter->pMerger, pbEof);
8909588652
}
8909688653
}else{
8909788654
SorterRecord *pFree = pSorter->list.pList;
8909888655
pSorter->list.pList = pFree->u.pNext;
8909988656
pFree->u.pNext = 0;
8910088657
if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);
89101
- rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;
88658
+ *pbEof = !pSorter->list.pList;
88659
+ rc = SQLITE_OK;
8910288660
}
8910388661
return rc;
8910488662
}
8910588663
8910688664
/*
@@ -89750,37 +89308,44 @@
8975089308
** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
8975189309
** on the compound select chain, p->pPrior.
8975289310
**
8975389311
** If it is not NULL, the xSelectCallback() callback is invoked before
8975489312
** the walk of the expressions and FROM clause. The xSelectCallback2()
89755
-** method is invoked following the walk of the expressions and FROM clause,
89756
-** but only if both xSelectCallback and xSelectCallback2 are both non-NULL
89757
-** and if the expressions and FROM clause both return WRC_Continue;
89313
+** method, if it is not NULL, is invoked following the walk of the
89314
+** expressions and FROM clause.
8975889315
**
8975989316
** Return WRC_Continue under normal conditions. Return WRC_Abort if
8976089317
** there is an abort request.
8976189318
**
8976289319
** If the Walker does not have an xSelectCallback() then this routine
8976389320
** is a no-op returning WRC_Continue.
8976489321
*/
8976589322
SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
8976689323
int rc;
89767
- if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
89768
- do{
89769
- rc = pWalker->xSelectCallback(pWalker, p);
89770
- if( rc ) return rc & WRC_Abort;
89324
+ if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){
89325
+ return WRC_Continue;
89326
+ }
89327
+ rc = WRC_Continue;
89328
+ pWalker->walkerDepth++;
89329
+ while( p ){
89330
+ if( pWalker->xSelectCallback ){
89331
+ rc = pWalker->xSelectCallback(pWalker, p);
89332
+ if( rc ) break;
89333
+ }
8977189334
if( sqlite3WalkSelectExpr(pWalker, p)
8977289335
|| sqlite3WalkSelectFrom(pWalker, p)
8977389336
){
89337
+ pWalker->walkerDepth--;
8977489338
return WRC_Abort;
8977589339
}
8977689340
if( pWalker->xSelectCallback2 ){
8977789341
pWalker->xSelectCallback2(pWalker, p);
8977889342
}
8977989343
p = p->pPrior;
89780
- }while( p!=0 );
89781
- return WRC_Continue;
89344
+ }
89345
+ pWalker->walkerDepth--;
89346
+ return rc & WRC_Abort;
8978289347
}
8978389348
8978489349
/************** End of walker.c **********************************************/
8978589350
/************** Begin file resolve.c *****************************************/
8978689351
/*
@@ -90693,11 +90258,11 @@
9069390258
/* Try to match the ORDER BY expression against an expression
9069490259
** in the result set. Return an 1-based index of the matching
9069590260
** result-set entry.
9069690261
*/
9069790262
for(i=0; i<pEList->nExpr; i++){
90698
- if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){
90263
+ if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
9069990264
return i+1;
9070090265
}
9070190266
}
9070290267
9070390268
/* If no match, return 0. */
@@ -90927,11 +90492,11 @@
9092790492
pItem->u.x.iOrderByCol = 0;
9092890493
if( sqlite3ResolveExprNames(pNC, pE) ){
9092990494
return 1;
9093090495
}
9093190496
for(j=0; j<pSelect->pEList->nExpr; j++){
90932
- if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90497
+ if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
9093390498
pItem->u.x.iOrderByCol = j+1;
9093490499
}
9093590500
}
9093690501
}
9093790502
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -91213,33 +90778,41 @@
9121390778
Expr *pExpr /* The expression to be analyzed. */
9121490779
){
9121590780
u16 savedHasAgg;
9121690781
Walker w;
9121790782
91218
- if( pExpr==0 ) return SQLITE_OK;
90783
+ if( pExpr==0 ) return 0;
90784
+#if SQLITE_MAX_EXPR_DEPTH>0
90785
+ {
90786
+ Parse *pParse = pNC->pParse;
90787
+ if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){
90788
+ return 1;
90789
+ }
90790
+ pParse->nHeight += pExpr->nHeight;
90791
+ }
90792
+#endif
9121990793
savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);
9122090794
pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);
9122190795
w.pParse = pNC->pParse;
9122290796
w.xExprCallback = resolveExprStep;
9122390797
w.xSelectCallback = resolveSelectStep;
9122490798
w.xSelectCallback2 = 0;
90799
+ w.walkerDepth = 0;
90800
+ w.eCode = 0;
9122590801
w.u.pNC = pNC;
91226
-#if SQLITE_MAX_EXPR_DEPTH>0
91227
- w.pParse->nHeight += pExpr->nHeight;
91228
- if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
91229
- return SQLITE_ERROR;
91230
- }
91231
-#endif
9123290802
sqlite3WalkExpr(&w, pExpr);
9123390803
#if SQLITE_MAX_EXPR_DEPTH>0
91234
- w.pParse->nHeight -= pExpr->nHeight;
90804
+ pNC->pParse->nHeight -= pExpr->nHeight;
9123590805
#endif
90806
+ if( pNC->nErr>0 || w.pParse->nErr>0 ){
90807
+ ExprSetProperty(pExpr, EP_Error);
90808
+ }
9123690809
if( pNC->ncFlags & NC_HasAgg ){
9123790810
ExprSetProperty(pExpr, EP_Agg);
9123890811
}
9123990812
pNC->ncFlags |= savedHasAgg;
91240
- return pNC->nErr>0 || w.pParse->nErr>0;
90813
+ return ExprHasProperty(pExpr, EP_Error);
9124190814
}
9124290815
9124390816
/*
9124490817
** Resolve all names for all expression in an expression list. This is
9124590818
** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -91276,13 +90849,13 @@
9127690849
NameContext *pOuterNC /* Name context for parent SELECT statement */
9127790850
){
9127890851
Walker w;
9127990852
9128090853
assert( p!=0 );
90854
+ memset(&w, 0, sizeof(w));
9128190855
w.xExprCallback = resolveExprStep;
9128290856
w.xSelectCallback = resolveSelectStep;
91283
- w.xSelectCallback2 = 0;
9128490857
w.pParse = pParse;
9128590858
w.u.pNC = pOuterNC;
9128690859
sqlite3WalkSelect(&w, p);
9128790860
}
9128890861
@@ -92811,13 +92384,11 @@
9281192384
}
9281292385
pList = pNew;
9281392386
pList->nAlloc *= 2;
9281492387
}
9281592388
pItem = &pList->a[pList->nExpr++];
92816
- assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) );
92817
- assert( offsetof(struct ExprList_item,pExpr)==0 );
92818
- memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName));
92389
+ memset(pItem, 0, sizeof(*pItem));
9281992390
pItem->pExpr = pExpr;
9282092391
return pList;
9282192392
9282292393
no_mem:
9282392394
/* Avoid leaking memory if malloc has failed. */
@@ -93097,16 +92668,14 @@
9309792668
pWalker->eCode = 0;
9309892669
return WRC_Abort;
9309992670
}
9310092671
static int exprIsConst(Expr *p, int initFlag, int iCur){
9310192672
Walker w;
92673
+ memset(&w, 0, sizeof(w));
9310292674
w.eCode = initFlag;
9310392675
w.xExprCallback = exprNodeIsConstant;
9310492676
w.xSelectCallback = selectNodeIsConstant;
93105
-#ifdef SQLITE_DEBUG
93106
- w.xSelectCallback2 = sqlite3SelectWalkAssert2;
93107
-#endif
9310892677
w.u.iCur = iCur;
9310992678
sqlite3WalkExpr(&w, p);
9311092679
return w.eCode;
9311192680
}
9311292681
@@ -93152,11 +92721,11 @@
9315292721
9315392722
/* Check if pExpr is identical to any GROUP BY term. If so, consider
9315492723
** it constant. */
9315592724
for(i=0; i<pGroupBy->nExpr; i++){
9315692725
Expr *p = pGroupBy->a[i].pExpr;
93157
- if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
92726
+ if( sqlite3ExprCompare(pExpr, p, -1)<2 ){
9315892727
CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
9315992728
if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
9316092729
return WRC_Prune;
9316192730
}
9316292731
}
@@ -93190,13 +92759,13 @@
9319092759
** optimization, so we take the easy way out and simply require the
9319192760
** GROUP BY to use the BINARY collating sequence.
9319292761
*/
9319392762
SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){
9319492763
Walker w;
92764
+ memset(&w, 0, sizeof(w));
9319592765
w.eCode = 1;
9319692766
w.xExprCallback = exprNodeIsConstantOrGroupBy;
93197
- w.xSelectCallback = 0;
9319892767
w.u.pGroupBy = pGroupBy;
9319992768
w.pParse = pParse;
9320092769
sqlite3WalkExpr(&w, p);
9320192770
return w.eCode;
9320292771
}
@@ -93220,16 +92789,14 @@
9322092789
** Walk an expression tree. Return 1 if the expression contains a
9322192790
** subquery of some kind. Return 0 if there are no subqueries.
9322292791
*/
9322392792
SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){
9322492793
Walker w;
92794
+ memset(&w, 0, sizeof(w));
9322592795
w.eCode = 1;
9322692796
w.xExprCallback = sqlite3ExprWalkNoop;
9322792797
w.xSelectCallback = selectNodeIsConstant;
93228
-#ifdef SQLITE_DEBUG
93229
- w.xSelectCallback2 = sqlite3SelectWalkAssert2;
93230
-#endif
9323192798
sqlite3WalkExpr(&w, p);
9323292799
return w.eCode==0;
9323392800
}
9323492801
#endif
9323592802
@@ -95428,11 +94995,11 @@
9542894995
p = pParse->pConstExpr;
9542994996
if( regDest<0 && p ){
9543094997
struct ExprList_item *pItem;
9543194998
int i;
9543294999
for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95433
- if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){
95000
+ if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
9543495001
return pItem->u.iConstExprReg;
9543595002
}
9543695003
}
9543795004
}
9543895005
pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95983,45 +95550,10 @@
9598395550
sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
9598495551
}
9598595552
sqlite3ExprDelete(db, pCopy);
9598695553
}
9598795554
95988
-/*
95989
-** Expression pVar is guaranteed to be an SQL variable. pExpr may be any
95990
-** type of expression.
95991
-**
95992
-** If pExpr is a simple SQL value - an integer, real, string, blob
95993
-** or NULL value - then the VDBE currently being prepared is configured
95994
-** to re-prepare each time a new value is bound to variable pVar.
95995
-**
95996
-** Additionally, if pExpr is a simple SQL value and the value is the
95997
-** same as that currently bound to variable pVar, non-zero is returned.
95998
-** Otherwise, if the values are not the same or if pExpr is not a simple
95999
-** SQL value, zero is returned.
96000
-*/
96001
-static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){
96002
- int res = 0;
96003
- int iVar;
96004
- sqlite3_value *pL, *pR = 0;
96005
-
96006
- sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
96007
- if( pR ){
96008
- iVar = pVar->iColumn;
96009
- sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
96010
- pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
96011
- if( pL ){
96012
- if( sqlite3_value_type(pL)==SQLITE_TEXT ){
96013
- sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
96014
- }
96015
- res = 0==sqlite3MemCompare(pL, pR, 0);
96016
- }
96017
- sqlite3ValueFree(pR);
96018
- sqlite3ValueFree(pL);
96019
- }
96020
-
96021
- return res;
96022
-}
9602395555
9602495556
/*
9602595557
** Do a deep comparison of two expression trees. Return 0 if the two
9602695558
** expressions are completely identical. Return 1 if they differ only
9602795559
** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -96040,38 +95572,28 @@
9604095572
** expressions are the same. But if you get a 0 or 1 return, then you
9604195573
** can be sure the expressions are the same. In the places where
9604295574
** this routine is used, it does not hurt to get an extra 2 - that
9604395575
** just might result in some slightly slower code. But returning
9604495576
** an incorrect 0 or 1 could lead to a malfunction.
96045
-**
96046
-** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
96047
-** pParse->pReprepare can be matched against literals in pB. The
96048
-** pParse->pVdbe->expmask bitmask is updated for each variable referenced.
96049
-** If pParse is NULL (the normal case) then any TK_VARIABLE term in
96050
-** Argument pParse should normally be NULL. If it is not NULL and pA or
96051
-** pB causes a return value of 2.
9605295577
*/
96053
-SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
95578
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
9605495579
u32 combinedFlags;
9605595580
if( pA==0 || pB==0 ){
9605695581
return pB==pA ? 0 : 2;
9605795582
}
96058
- if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){
96059
- return 0;
96060
- }
9606195583
combinedFlags = pA->flags | pB->flags;
9606295584
if( combinedFlags & EP_IntValue ){
9606395585
if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
9606495586
return 0;
9606595587
}
9606695588
return 2;
9606795589
}
9606895590
if( pA->op!=pB->op ){
96069
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){
95591
+ if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
9607095592
return 1;
9607195593
}
96072
- if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){
95594
+ if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
9607395595
return 1;
9607495596
}
9607595597
return 2;
9607695598
}
9607795599
if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -96082,12 +95604,12 @@
9608295604
}
9608395605
}
9608495606
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
9608595607
if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
9608695608
if( combinedFlags & EP_xIsSelect ) return 2;
96087
- if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
96088
- if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
95609
+ if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
95610
+ if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
9608995611
if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
9609095612
if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
9609195613
if( pA->iColumn!=pB->iColumn ) return 2;
9609295614
if( pA->iTable!=pB->iTable
9609395615
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -96118,21 +95640,21 @@
9611895640
if( pA->nExpr!=pB->nExpr ) return 1;
9611995641
for(i=0; i<pA->nExpr; i++){
9612095642
Expr *pExprA = pA->a[i].pExpr;
9612195643
Expr *pExprB = pB->a[i].pExpr;
9612295644
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
96123
- if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
95645
+ if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
9612495646
}
9612595647
return 0;
9612695648
}
9612795649
9612895650
/*
9612995651
** Like sqlite3ExprCompare() except COLLATE operators at the top-level
9613095652
** are ignored.
9613195653
*/
9613295654
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
96133
- return sqlite3ExprCompare(0,
95655
+ return sqlite3ExprCompare(
9613495656
sqlite3ExprSkipCollate(pA),
9613595657
sqlite3ExprSkipCollate(pB),
9613695658
iTab);
9613795659
}
9613895660
@@ -96150,33 +95672,28 @@
9615095672
** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
9615195673
**
9615295674
** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
9615395675
** Expr.iTable<0 then assume a table number given by iTab.
9615495676
**
96155
-** If pParse is not NULL, then the values of bound variables in pE1 are
96156
-** compared against literal values in pE2 and pParse->pVdbe->expmask is
96157
-** modified to record which bound variables are referenced. If pParse
96158
-** is NULL, then false will be returned if pE1 contains any bound variables.
96159
-**
9616095677
** When in doubt, return false. Returning true might give a performance
9616195678
** improvement. Returning false might cause a performance reduction, but
9616295679
** it will always give the correct answer and is hence always safe.
9616395680
*/
96164
-SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
96165
- if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){
95681
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
95682
+ if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
9616695683
return 1;
9616795684
}
9616895685
if( pE2->op==TK_OR
96169
- && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)
96170
- || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )
95686
+ && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
95687
+ || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
9617195688
){
9617295689
return 1;
9617395690
}
9617495691
if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
9617595692
Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
9617695693
testcase( pX!=pE1->pLeft );
96177
- if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
95694
+ if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
9617895695
}
9617995696
return 0;
9618095697
}
9618195698
9618295699
/*
@@ -96280,12 +95797,12 @@
9628095797
*/
9628195798
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
9628295799
Walker w;
9628395800
struct SrcCount cnt;
9628495801
assert( pExpr->op==TK_AGG_FUNCTION );
95802
+ memset(&w, 0, sizeof(w));
9628595803
w.xExprCallback = exprSrcCount;
96286
- w.xSelectCallback = 0;
9628795804
w.u.pSrcCount = &cnt;
9628895805
cnt.pSrc = pSrcList;
9628995806
cnt.nThis = 0;
9629095807
cnt.nOther = 0;
9629195808
sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -96413,11 +95930,11 @@
9641395930
/* Check to see if pExpr is a duplicate of another aggregate
9641495931
** function that is already in the pAggInfo structure
9641595932
*/
9641695933
struct AggInfo_func *pItem = pAggInfo->aFunc;
9641795934
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
96418
- if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){
95935
+ if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
9641995936
break;
9642095937
}
9642195938
}
9642295939
if( i>=pAggInfo->nFunc ){
9642395940
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96453,18 +95970,14 @@
9645395970
}
9645495971
}
9645595972
return WRC_Continue;
9645695973
}
9645795974
static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
95975
+ UNUSED_PARAMETER(pWalker);
9645895976
UNUSED_PARAMETER(pSelect);
96459
- pWalker->walkerDepth++;
9646095977
return WRC_Continue;
9646195978
}
96462
-static void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){
96463
- UNUSED_PARAMETER(pSelect);
96464
- pWalker->walkerDepth--;
96465
-}
9646695979
9646795980
/*
9646895981
** Analyze the pExpr expression looking for aggregate functions and
9646995982
** for variables that need to be added to AggInfo object that pNC->pAggInfo
9647095983
** points to. Additional entries are made on the AggInfo object as
@@ -96473,14 +95986,13 @@
9647395986
** This routine should only be called after the expression has been
9647495987
** analyzed by sqlite3ResolveExprNames().
9647595988
*/
9647695989
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
9647795990
Walker w;
95991
+ memset(&w, 0, sizeof(w));
9647895992
w.xExprCallback = analyzeAggregate;
9647995993
w.xSelectCallback = analyzeAggregatesInSelect;
96480
- w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
96481
- w.walkerDepth = 0;
9648295994
w.u.pNC = pNC;
9648395995
assert( pNC->pSrcList!=0 );
9648495996
sqlite3WalkExpr(&w, pExpr);
9648595997
}
9648695998
@@ -96970,11 +96482,11 @@
9697096482
** in pParse->zErr (system tables may not be altered) and returns non-zero.
9697196483
**
9697296484
** Or, if zName is not a system table, zero is returned.
9697396485
*/
9697496486
static int isSystemTable(Parse *pParse, const char *zName){
96975
- if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96487
+ if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
9697696488
sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
9697796489
return 1;
9697896490
}
9697996491
return 0;
9698096492
}
@@ -99389,12 +98901,11 @@
9938998901
const char *zName;
9939098902
const char *zFile;
9939198903
char *zPath = 0;
9939298904
char *zErr = 0;
9939398905
unsigned int flags;
99394
- Db *aNew; /* New array of Db pointers */
99395
- Db *pNew; /* Db object for the newly attached database */
98906
+ Db *aNew;
9939698907
char *zErrDyn = 0;
9939798908
sqlite3_vfs *pVfs;
9939898909
9939998910
UNUSED_PARAMETER(NotUsed);
9940098911
@@ -99438,12 +98949,12 @@
9943898949
}else{
9943998950
aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
9944098951
if( aNew==0 ) return;
9944198952
}
9944298953
db->aDb = aNew;
99443
- pNew = &db->aDb[db->nDb];
99444
- memset(pNew, 0, sizeof(*pNew));
98954
+ aNew = &db->aDb[db->nDb];
98955
+ memset(aNew, 0, sizeof(*aNew));
9944598956
9944698957
/* Open the database file. If the btree is successfully opened, use
9944798958
** it to obtain the database schema. At this point the schema may
9944898959
** or may not be initialized.
9944998960
*/
@@ -99455,41 +98966,41 @@
9945598966
sqlite3_free(zErr);
9945698967
return;
9945798968
}
9945898969
assert( pVfs );
9945998970
flags |= SQLITE_OPEN_MAIN_DB;
99460
- rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
98971
+ rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags);
9946198972
sqlite3_free( zPath );
9946298973
db->nDb++;
9946398974
db->skipBtreeMutex = 0;
9946498975
if( rc==SQLITE_CONSTRAINT ){
9946598976
rc = SQLITE_ERROR;
9946698977
zErrDyn = sqlite3MPrintf(db, "database is already attached");
9946798978
}else if( rc==SQLITE_OK ){
9946898979
Pager *pPager;
99469
- pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);
99470
- if( !pNew->pSchema ){
98980
+ aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);
98981
+ if( !aNew->pSchema ){
9947198982
rc = SQLITE_NOMEM_BKPT;
99472
- }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){
98983
+ }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){
9947398984
zErrDyn = sqlite3MPrintf(db,
9947498985
"attached databases must use the same text encoding as main database");
9947598986
rc = SQLITE_ERROR;
9947698987
}
99477
- sqlite3BtreeEnter(pNew->pBt);
99478
- pPager = sqlite3BtreePager(pNew->pBt);
98988
+ sqlite3BtreeEnter(aNew->pBt);
98989
+ pPager = sqlite3BtreePager(aNew->pBt);
9947998990
sqlite3PagerLockingMode(pPager, db->dfltLockMode);
99480
- sqlite3BtreeSecureDelete(pNew->pBt,
98991
+ sqlite3BtreeSecureDelete(aNew->pBt,
9948198992
sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
9948298993
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
99483
- sqlite3BtreeSetPagerFlags(pNew->pBt,
98994
+ sqlite3BtreeSetPagerFlags(aNew->pBt,
9948498995
PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
9948598996
#endif
99486
- sqlite3BtreeLeave(pNew->pBt);
98997
+ sqlite3BtreeLeave(aNew->pBt);
9948798998
}
99488
- pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
99489
- pNew->zDbSName = sqlite3DbStrDup(db, zName);
99490
- if( rc==SQLITE_OK && pNew->zDbSName==0 ){
98999
+ aNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
99000
+ aNew->zDbSName = sqlite3DbStrDup(db, zName);
99001
+ if( rc==SQLITE_OK && aNew->zDbSName==0 ){
9949199002
rc = SQLITE_NOMEM_BKPT;
9949299003
}
9949399004
9949499005
9949599006
#ifdef SQLITE_HAS_CODEC
@@ -101122,15 +100633,11 @@
101122100633
}
101123100634
pTable->zName = zName;
101124100635
pTable->iPKey = -1;
101125100636
pTable->pSchema = db->aDb[iDb].pSchema;
101126100637
pTable->nTabRef = 1;
101127
-#ifdef SQLITE_DEFAULT_ROWEST
101128
- pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);
101129
-#else
101130100638
pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
101131
-#endif
101132100639
assert( pParse->pNewTable==0 );
101133100640
pParse->pNewTable = pTable;
101134100641
101135100642
/* If this is the magic sqlite_sequence table used by autoincrement,
101136100643
** then record a pointer to this table in the main database structure
@@ -104368,13 +103875,11 @@
104368103875
for(j=0; j<pIdx->nKeyCol; j++){
104369103876
char *zCol;
104370103877
assert( pIdx->aiColumn[j]>=0 );
104371103878
zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
104372103879
if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
104373
- sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
104374
- sqlite3StrAccumAppend(&errMsg, ".", 1);
104375
- sqlite3StrAccumAppendAll(&errMsg, zCol);
103880
+ sqlite3XPrintf(&errMsg, "%s.%s", pTab->zName, zCol);
104376103881
}
104377103882
}
104378103883
zErr = sqlite3StrAccumFinish(&errMsg);
104379103884
sqlite3HaltConstraint(pParse,
104380103885
IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -105479,11 +104984,11 @@
105479104984
** It is easier just to erase the whole table. Prior to version 3.6.5,
105480104985
** this optimization caused the row change count (the value returned by
105481104986
** API function sqlite3_count_changes) to be set incorrectly.
105482104987
**
105483104988
** The "rcauth==SQLITE_OK" terms is the
105484
- ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
104989
+ ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
105485104990
** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but
105486104991
** the truncate optimization is disabled and all rows are deleted
105487104992
** individually.
105488104993
*/
105489104994
if( rcauth==SQLITE_OK
@@ -105585,11 +105090,11 @@
105585105090
sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,
105586105091
sqlite3IndexAffinityStr(pParse->db, pPk), nPk);
105587105092
sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);
105588105093
}else{
105589105094
/* Add the rowid of the row to be deleted to the RowSet */
105590
- nKey = 1; /* OP_DeferredSeek always uses a single rowid */
105095
+ nKey = 1; /* OP_Seek always uses a single rowid */
105591105096
sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);
105592105097
}
105593105098
}
105594105099
105595105100
/* If this DELETE cannot use the ONEPASS strategy, this is the
@@ -108539,16 +108044,14 @@
108539108044
sqlite3ResolveExprNames(&sNameContext, pWhere);
108540108045
108541108046
/* Create VDBE to loop through the entries in pSrc that match the WHERE
108542108047
** clause. For each row found, increment either the deferred or immediate
108543108048
** foreign key constraint counter. */
108544
- if( pParse->nErr==0 ){
108545
- pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
108546
- sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
108547
- if( pWInfo ){
108548
- sqlite3WhereEnd(pWInfo);
108549
- }
108049
+ pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
108050
+ sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
108051
+ if( pWInfo ){
108052
+ sqlite3WhereEnd(pWInfo);
108550108053
}
108551108054
108552108055
/* Clean up the WHERE clause constructed above. */
108553108056
sqlite3ExprDelete(db, pWhere);
108554108057
if( iFkIfZero ){
@@ -109851,14 +109354,14 @@
109851109354
Trigger *pTrigger; /* List of triggers on pTab, if required */
109852109355
int tmask; /* Mask of trigger times */
109853109356
#endif
109854109357
109855109358
db = pParse->db;
109359
+ memset(&dest, 0, sizeof(dest));
109856109360
if( pParse->nErr || db->mallocFailed ){
109857109361
goto insert_cleanup;
109858109362
}
109859
- dest.iSDParm = 0; /* Suppress a harmless compiler warning */
109860109363
109861109364
/* If the Select object is really just a simple VALUES() list with a
109862109365
** single row (the common case) then keep that one row of values
109863109366
** and discard the other (unused) parts of the pSelect object
109864109367
*/
@@ -111228,11 +110731,11 @@
111228110731
if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
111229110732
return 0; /* Different columns indexed */
111230110733
}
111231110734
if( pSrc->aiColumn[i]==XN_EXPR ){
111232110735
assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
111233
- if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,
110736
+ if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr,
111234110737
pDest->aColExpr->a[i].pExpr, -1)!=0 ){
111235110738
return 0; /* Different expressions in the index */
111236110739
}
111237110740
}
111238110741
if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111240,11 +110743,11 @@
111240110743
}
111241110744
if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
111242110745
return 0; /* Different collating sequences */
111243110746
}
111244110747
}
111245
- if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
110748
+ if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111246110749
return 0; /* Different WHERE clauses */
111247110750
}
111248110751
111249110752
/* If no test above fails then the indices must be compatible */
111250110753
return 1;
@@ -111720,12 +111223,15 @@
111720111223
if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111721111224
sqlite3DbFree(db, azCols);
111722111225
111723111226
rc = sqlite3ApiExit(db, rc);
111724111227
if( rc!=SQLITE_OK && pzErrMsg ){
111725
- *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));
111726
- if( *pzErrMsg==0 ){
111228
+ int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
111229
+ *pzErrMsg = sqlite3Malloc(nErrMsg);
111230
+ if( *pzErrMsg ){
111231
+ memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
111232
+ }else{
111727111233
rc = SQLITE_NOMEM_BKPT;
111728111234
sqlite3Error(db, SQLITE_NOMEM);
111729111235
}
111730111236
}else if( pzErrMsg ){
111731111237
*pzErrMsg = 0;
@@ -113398,11 +112904,11 @@
113398112904
/* iArg: */ 0 },
113399112905
#endif
113400112906
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113401112907
{/* zName: */ "foreign_key_check",
113402112908
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
113403
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
112909
+ /* ePragFlg: */ PragFlg_NeedSchema,
113404112910
/* ColNames: */ 39, 4,
113405112911
/* iArg: */ 0 },
113406112912
#endif
113407112913
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
113408112914
{/* zName: */ "foreign_key_list",
@@ -113485,11 +112991,11 @@
113485112991
/* iArg: */ 1 },
113486112992
#endif
113487112993
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
113488112994
{/* zName: */ "integrity_check",
113489112995
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
113490
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
112996
+ /* ePragFlg: */ PragFlg_NeedSchema,
113491112997
/* ColNames: */ 0, 0,
113492112998
/* iArg: */ 0 },
113493112999
#endif
113494113000
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113495113001
{/* zName: */ "journal_mode",
@@ -113580,20 +113086,20 @@
113580113086
/* iArg: */ SQLITE_QueryOnly },
113581113087
#endif
113582113088
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
113583113089
{/* zName: */ "quick_check",
113584113090
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
113585
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
113091
+ /* ePragFlg: */ PragFlg_NeedSchema,
113586113092
/* ColNames: */ 0, 0,
113587113093
/* iArg: */ 0 },
113588113094
#endif
113589113095
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113590113096
{/* zName: */ "read_uncommitted",
113591113097
/* ePragTyp: */ PragTyp_FLAG,
113592113098
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113593113099
/* ColNames: */ 0, 0,
113594
- /* iArg: */ SQLITE_ReadUncommit },
113100
+ /* iArg: */ SQLITE_ReadUncommitted },
113595113101
{/* zName: */ "recursive_triggers",
113596113102
/* ePragTyp: */ PragTyp_FLAG,
113597113103
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113598113104
/* ColNames: */ 0, 0,
113599113105
/* iArg: */ SQLITE_RecTriggers },
@@ -113741,11 +113247,11 @@
113741113247
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113742113248
{/* zName: */ "writable_schema",
113743113249
/* ePragTyp: */ PragTyp_FLAG,
113744113250
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113745113251
/* ColNames: */ 0, 0,
113746
- /* iArg: */ SQLITE_WriteSchema },
113252
+ /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
113747113253
#endif
113748113254
};
113749113255
/* Number of pragmas: 60 on by default, 74 total. */
113750113256
113751113257
/************** End of pragma.h **********************************************/
@@ -116183,11 +115689,11 @@
116183115689
InitData *pData, /* Initialization context */
116184115690
const char *zObj, /* Object being parsed at the point of error */
116185115691
const char *zExtra /* Error information */
116186115692
){
116187115693
sqlite3 *db = pData->db;
116188
- if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
115694
+ if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
116189115695
char *z;
116190115696
if( zObj==0 ) zObj = "?";
116191115697
z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
116192115698
if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
116193115699
sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116470,12 +115976,12 @@
116470115976
}
116471115977
if( db->mallocFailed ){
116472115978
rc = SQLITE_NOMEM_BKPT;
116473115979
sqlite3ResetAllSchemasOfConnection(db);
116474115980
}
116475
- if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
116476
- /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
115981
+ if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){
115982
+ /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider
116477115983
** the schema loaded, even if errors occurred. In this situation the
116478115984
** current sqlite3_prepare() operation will fail, but the following one
116479115985
** will attempt to compile the supplied statement against whatever subset
116480115986
** of the schema was loaded before the error occurred. The primary
116481115987
** purpose of this is to allow access to the sqlite_master table
@@ -116671,11 +116177,11 @@
116671116177
*/
116672116178
static int sqlite3Prepare(
116673116179
sqlite3 *db, /* Database handle. */
116674116180
const char *zSql, /* UTF-8 encoded SQL statement. */
116675116181
int nBytes, /* Length of zSql in bytes. */
116676
- u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116182
+ int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116677116183
Vdbe *pReprepare, /* VM being reprepared */
116678116184
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116679116185
const char **pzTail /* OUT: End of parsed string */
116680116186
){
116681116187
char *zErrMsg = 0; /* Error message */
@@ -116688,18 +116194,10 @@
116688116194
sParse.pReprepare = pReprepare;
116689116195
assert( ppStmt && *ppStmt==0 );
116690116196
/* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116691116197
assert( sqlite3_mutex_held(db->mutex) );
116692116198
116693
- /* For a long-term use prepared statement avoid the use of
116694
- ** lookaside memory.
116695
- */
116696
- if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
116697
- sParse.disableLookaside++;
116698
- db->lookaside.bDisable++;
116699
- }
116700
-
116701116199
/* Check to verify that it is possible to get a read lock on all
116702116200
** database schemas. The inability to get a read lock indicates that
116703116201
** some other database connection is holding a write-lock, which in
116704116202
** turn means that the other connection has made uncommitted changes
116705116203
** to the schema.
@@ -116727,11 +116225,11 @@
116727116225
assert( sqlite3BtreeHoldsMutex(pBt) );
116728116226
rc = sqlite3BtreeSchemaLocked(pBt);
116729116227
if( rc ){
116730116228
const char *zDb = db->aDb[i].zDbSName;
116731116229
sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116732
- testcase( db->flags & SQLITE_ReadUncommit );
116230
+ testcase( db->flags & SQLITE_ReadUncommitted );
116733116231
goto end_prepare;
116734116232
}
116735116233
}
116736116234
}
116737116235
@@ -116795,11 +116293,12 @@
116795116293
}
116796116294
}
116797116295
#endif
116798116296
116799116297
if( db->init.busy==0 ){
116800
- sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
116298
+ Vdbe *pVdbe = sParse.pVdbe;
116299
+ sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag);
116801116300
}
116802116301
if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116803116302
sqlite3VdbeFinalize(sParse.pVdbe);
116804116303
assert(!(*ppStmt));
116805116304
}else{
@@ -116829,11 +116328,11 @@
116829116328
}
116830116329
static int sqlite3LockAndPrepare(
116831116330
sqlite3 *db, /* Database handle. */
116832116331
const char *zSql, /* UTF-8 encoded SQL statement. */
116833116332
int nBytes, /* Length of zSql in bytes. */
116834
- u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116333
+ int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116835116334
Vdbe *pOld, /* VM being reprepared */
116836116335
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116837116336
const char **pzTail /* OUT: End of parsed string */
116838116337
){
116839116338
int rc;
@@ -116845,14 +116344,14 @@
116845116344
if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116846116345
return SQLITE_MISUSE_BKPT;
116847116346
}
116848116347
sqlite3_mutex_enter(db->mutex);
116849116348
sqlite3BtreeEnterAll(db);
116850
- rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116349
+ rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116851116350
if( rc==SQLITE_SCHEMA ){
116852116351
sqlite3_finalize(*ppStmt);
116853
- rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116352
+ rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116854116353
}
116855116354
sqlite3BtreeLeaveAll(db);
116856116355
sqlite3_mutex_leave(db->mutex);
116857116356
assert( rc==SQLITE_OK || *ppStmt==0 );
116858116357
return rc;
@@ -116869,19 +116368,17 @@
116869116368
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116870116369
int rc;
116871116370
sqlite3_stmt *pNew;
116872116371
const char *zSql;
116873116372
sqlite3 *db;
116874
- u8 prepFlags;
116875116373
116876116374
assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116877116375
zSql = sqlite3_sql((sqlite3_stmt *)p);
116878116376
assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116879116377
db = sqlite3VdbeDb(p);
116880116378
assert( sqlite3_mutex_held(db->mutex) );
116881
- prepFlags = sqlite3VdbePrepareFlags(p);
116882
- rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
116379
+ rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);
116883116380
if( rc ){
116884116381
if( rc==SQLITE_NOMEM ){
116885116382
sqlite3OomFault(db);
116886116383
}
116887116384
assert( pNew==0 );
@@ -116923,27 +116420,11 @@
116923116420
int nBytes, /* Length of zSql in bytes. */
116924116421
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116925116422
const char **pzTail /* OUT: End of parsed string */
116926116423
){
116927116424
int rc;
116928
- rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
116929
- ppStmt,pzTail);
116930
- assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116931
- return rc;
116932
-}
116933
-SQLITE_API int sqlite3_prepare_v3(
116934
- sqlite3 *db, /* Database handle. */
116935
- const char *zSql, /* UTF-8 encoded SQL statement. */
116936
- int nBytes, /* Length of zSql in bytes. */
116937
- unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116938
- sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116939
- const char **pzTail /* OUT: End of parsed string */
116940
-){
116941
- int rc;
116942
- rc = sqlite3LockAndPrepare(db,zSql,nBytes,
116943
- SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
116944
- 0,ppStmt,pzTail);
116425
+ rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
116945116426
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116946116427
return rc;
116947116428
}
116948116429
116949116430
@@ -116953,11 +116434,11 @@
116953116434
*/
116954116435
static int sqlite3Prepare16(
116955116436
sqlite3 *db, /* Database handle. */
116956116437
const void *zSql, /* UTF-16 encoded SQL statement. */
116957116438
int nBytes, /* Length of zSql in bytes. */
116958
- u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116439
+ int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */
116959116440
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116960116441
const void **pzTail /* OUT: End of parsed string */
116961116442
){
116962116443
/* This function currently works by first transforming the UTF-16
116963116444
** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116981,11 +116462,11 @@
116981116462
nBytes = sz;
116982116463
}
116983116464
sqlite3_mutex_enter(db->mutex);
116984116465
zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116985116466
if( zSql8 ){
116986
- rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
116467
+ rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
116987116468
}
116988116469
116989116470
if( zTail8 && pzTail ){
116990116471
/* If sqlite3_prepare returns a tail pointer, we calculate the
116991116472
** equivalent pointer into the UTF-16 string by counting the unicode
@@ -117027,26 +116508,11 @@
117027116508
int nBytes, /* Length of zSql in bytes. */
117028116509
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117029116510
const void **pzTail /* OUT: End of parsed string */
117030116511
){
117031116512
int rc;
117032
- rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
117033
- assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117034
- return rc;
117035
-}
117036
-SQLITE_API int sqlite3_prepare16_v3(
117037
- sqlite3 *db, /* Database handle. */
117038
- const void *zSql, /* UTF-16 encoded SQL statement. */
117039
- int nBytes, /* Length of zSql in bytes. */
117040
- unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117041
- sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117042
- const void **pzTail /* OUT: End of parsed string */
117043
-){
117044
- int rc;
117045
- rc = sqlite3Prepare16(db,zSql,nBytes,
117046
- SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117047
- ppStmt,pzTail);
116513
+ rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
117048116514
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117049116515
return rc;
117050116516
}
117051116517
117052116518
#endif /* SQLITE_OMIT_UTF16 */
@@ -118084,11 +117550,11 @@
118084117550
/*
118085117551
** Allocate a KeyInfo object sufficient for an index of N key columns and
118086117552
** X extra columns.
118087117553
*/
118088117554
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
118089
- int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);
117555
+ int nExtra = (N+X)*(sizeof(CollSeq*)+1);
118090117556
KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
118091117557
if( p ){
118092117558
p->aSortOrder = (u8*)&p->aColl[N+X];
118093117559
p->nField = (u16)N;
118094117560
p->nXField = (u16)X;
@@ -120258,16 +119724,13 @@
120258119724
ifNullRow.pLeft = pCopy;
120259119725
ifNullRow.iTable = pSubst->iNewTable;
120260119726
pCopy = &ifNullRow;
120261119727
}
120262119728
pNew = sqlite3ExprDup(db, pCopy, 0);
120263
- if( pNew && pSubst->isLeftJoin ){
120264
- ExprSetProperty(pNew, EP_CanBeNull);
120265
- }
120266
- if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
119729
+ if( pNew && (pExpr->flags & EP_FromJoin) ){
120267119730
pNew->iRightJoinTable = pExpr->iRightJoinTable;
120268
- ExprSetProperty(pNew, EP_FromJoin);
119731
+ pNew->flags |= EP_FromJoin;
120269119732
}
120270119733
sqlite3ExprDelete(db, pExpr);
120271119734
pExpr = pNew;
120272119735
}
120273119736
}
@@ -120556,11 +120019,11 @@
120556120019
**
120557120020
** which is not at all the same thing.
120558120021
**
120559120022
** If the subquery is the right operand of a LEFT JOIN, then the outer
120560120023
** query cannot be an aggregate. This is an artifact of the way aggregates
120561
- ** are processed - there is no mechanism to determine if the LEFT JOIN
120024
+ ** are processed - there is not mechanism to determine if the LEFT JOIN
120562120025
** table should be all-NULL.
120563120026
**
120564120027
** See also tickets #306, #350, and #3300.
120565120028
*/
120566120029
if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
@@ -121667,29 +121130,10 @@
121667121130
UNUSED_PARAMETER2(NotUsed, NotUsed2);
121668121131
return WRC_Continue;
121669121132
}
121670121133
121671121134
/*
121672
-** No-op routine for the parse-tree walker for SELECT statements.
121673
-** subquery in the parser tree.
121674
-*/
121675
-SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
121676
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
121677
- return WRC_Continue;
121678
-}
121679
-
121680
-#if SQLITE_DEBUG
121681
-/*
121682
-** Always assert. This xSelectCallback2 implementation proves that the
121683
-** xSelectCallback2 is never invoked.
121684
-*/
121685
-SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker *NotUsed, Select *NotUsed2){
121686
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
121687
- assert( 0 );
121688
-}
121689
-#endif
121690
-/*
121691121135
** This routine "expands" a SELECT statement and all of its subqueries.
121692121136
** For additional information on what it means to "expand" a SELECT
121693121137
** statement, see the comment on the selectExpand worker callback above.
121694121138
**
121695121139
** Expanding a SELECT statement is the first step in processing a
@@ -121700,15 +121144,15 @@
121700121144
** The calling function can detect the problem by looking at pParse->nErr
121701121145
** and/or pParse->db->mallocFailed.
121702121146
*/
121703121147
static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
121704121148
Walker w;
121149
+ memset(&w, 0, sizeof(w));
121705121150
w.xExprCallback = sqlite3ExprWalkNoop;
121706121151
w.pParse = pParse;
121707121152
if( pParse->hasCompound ){
121708121153
w.xSelectCallback = convertCompoundSelectToSubquery;
121709
- w.xSelectCallback2 = 0;
121710121154
sqlite3WalkSelect(&w, pSelect);
121711121155
}
121712121156
w.xSelectCallback = selectExpander;
121713121157
w.xSelectCallback2 = selectPopWith;
121714121158
sqlite3WalkSelect(&w, pSelect);
@@ -121764,11 +121208,11 @@
121764121208
** Use this routine after name resolution.
121765121209
*/
121766121210
static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
121767121211
#ifndef SQLITE_OMIT_SUBQUERY
121768121212
Walker w;
121769
- w.xSelectCallback = sqlite3SelectWalkNoop;
121213
+ memset(&w, 0, sizeof(w));
121770121214
w.xSelectCallback2 = selectAddSubqueryTypeInfo;
121771121215
w.xExprCallback = sqlite3ExprWalkNoop;
121772121216
w.pParse = pParse;
121773121217
sqlite3WalkSelect(&w, pSelect);
121774121218
#endif
@@ -122058,13 +121502,11 @@
122058121502
if( pItem->pSelect==0 ) continue;
122059121503
if( pItem->fg.viaCoroutine ) continue;
122060121504
if( pItem->zName==0 ) continue;
122061121505
if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
122062121506
if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
122063
- if( sqlite3ExprCompare(0,
122064
- pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
122065
- ){
121507
+ if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){
122066121508
/* The view was modified by some other optimization such as
122067121509
** pushDownWhereTerms() */
122068121510
continue;
122069121511
}
122070121512
return pItem;
@@ -122347,13 +121789,10 @@
122347121789
VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName));
122348121790
}
122349121791
pPrior = isSelfJoinView(pTabList, pItem);
122350121792
if( pPrior ){
122351121793
sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
122352
- explainSetInteger(pItem->iSelectId, pPrior->iSelectId);
122353
- assert( pPrior->pSelect!=0 );
122354
- pSub->nSelectRow = pPrior->pSelect->nSelectRow;
122355121794
}else{
122356121795
sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
122357121796
explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
122358121797
sqlite3Select(pParse, pSub, &dest);
122359121798
}
@@ -123509,11 +122948,10 @@
123509122948
/* Make an entry in the sqlite_master table */
123510122949
v = sqlite3GetVdbe(pParse);
123511122950
if( v==0 ) goto triggerfinish_cleanup;
123512122951
sqlite3BeginWriteOperation(pParse, 0, iDb);
123513122952
z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
123514
- testcase( z==0 );
123515122953
sqlite3NestedParse(pParse,
123516122954
"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
123517122955
db->aDb[iDb].zDbSName, MASTER_NAME, zName,
123518122956
pTrig->table, z);
123519122957
sqlite3DbFree(db, z);
@@ -125377,11 +124815,11 @@
125377124815
#ifdef SQLITE_HAS_CODEC
125378124816
if( db->nextPagesize ){
125379124817
extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
125380124818
int nKey;
125381124819
char *zKey;
125382
- sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey);
124820
+ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
125383124821
if( nKey ) db->nextPagesize = 0;
125384124822
}
125385124823
#endif
125386124824
125387124825
sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
@@ -128317,14 +127755,14 @@
128317127755
** function generates code to do a deferred seek of cursor iCur to the
128318127756
** rowid stored in register iRowid.
128319127757
**
128320127758
** Normally, this is just:
128321127759
**
128322
-** OP_DeferredSeek $iCur $iRowid
127760
+** OP_Seek $iCur $iRowid
128323127761
**
128324127762
** However, if the scan currently being coded is a branch of an OR-loop and
128325
-** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek
127763
+** the statement currently being coded is a SELECT, then P3 of the OP_Seek
128326127764
** is set to iIdxCur and P4 is set to point to an array of integers
128327127765
** containing one entry for each column of the table cursor iCur is open
128328127766
** on. For each table column, if the column is the i'th column of the
128329127767
** index, then the corresponding array entry is set to (i+1). If the column
128330127768
** does not appear in the index at all, the array entry is set to 0.
@@ -128339,11 +127777,11 @@
128339127777
Vdbe *v = pParse->pVdbe; /* Vdbe to generate code within */
128340127778
128341127779
assert( iIdxCur>0 );
128342127780
assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
128343127781
128344
- sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur);
127782
+ sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
128345127783
if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
128346127784
&& DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
128347127785
){
128348127786
int i;
128349127787
Table *pTab = pIdx->pTable;
@@ -128409,11 +127847,11 @@
128409127847
** If pExpr matches, then transform it into a reference to the index column
128410127848
** that contains the value of pExpr.
128411127849
*/
128412127850
static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
128413127851
IdxExprTrans *pX = p->u.pIdxTrans;
128414
- if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
127852
+ if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128415127853
pExpr->op = TK_COLUMN;
128416127854
pExpr->iTable = pX->iIdxCur;
128417127855
pExpr->iColumn = pX->iIdxCol;
128418127856
pExpr->pTab = 0;
128419127857
return WRC_Prune;
@@ -129703,11 +129141,11 @@
129703129141
pList = pExpr->x.pList;
129704129142
pLeft = pList->a[1].pExpr;
129705129143
129706129144
pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129707129145
op = pRight->op;
129708
- if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
129146
+ if( op==TK_VARIABLE ){
129709129147
Vdbe *pReprepare = pParse->pReprepare;
129710129148
int iCol = pRight->iColumn;
129711129149
pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129712129150
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129713129151
z = (char *)sqlite3_value_text(pVal);
@@ -129893,12 +129331,12 @@
129893129331
if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129894129332
if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129895129333
&& (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129896129334
assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129897129335
assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129898
- if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129899
- if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;
129336
+ if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129337
+ if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
129900129338
/* If we reach this point, it means the two subterms can be combined */
129901129339
if( (eOp & (eOp-1))!=0 ){
129902129340
if( eOp & (WO_LT|WO_LE) ){
129903129341
eOp = WO_LE;
129904129342
}else{
@@ -130665,13 +130103,10 @@
130665130103
prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130666130104
if( (prereqExpr & prereqColumn)==0 ){
130667130105
Expr *pNewExpr;
130668130106
pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130669130107
0, sqlite3ExprDup(db, pRight, 0));
130670
- if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
130671
- ExprSetProperty(pNewExpr, EP_FromJoin);
130672
- }
130673130108
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130674130109
testcase( idxNew==0 );
130675130110
pNewTerm = &pWC->a[idxNew];
130676130111
pNewTerm->prereqRight = prereqExpr;
130677130112
pNewTerm->leftCursor = pLeft->iTable;
@@ -132144,11 +131579,11 @@
132144131579
iGap = (iGap*2)/3;
132145131580
}else{
132146131581
iGap = iGap/3;
132147131582
}
132148131583
aStat[0] = iLower + iGap;
132149
- aStat[1] = pIdx->aAvgEq[nField-1];
131584
+ aStat[1] = pIdx->aAvgEq[iCol];
132150131585
}
132151131586
132152131587
/* Restore the pRec->nField value before returning. */
132153131588
pRec->nField = nField;
132154131589
return i;
@@ -132897,21 +132332,20 @@
132897132332
}
132898132333
}
132899132334
132900132335
/*
132901132336
** Search the list of WhereLoops in *ppPrev looking for one that can be
132902
-** replaced by pTemplate.
132337
+** supplanted by pTemplate.
132903132338
**
132904
-** Return NULL if pTemplate does not belong on the WhereLoop list.
132905
-** In other words if pTemplate ought to be dropped from further consideration.
132339
+** Return NULL if the WhereLoop list contains an entry that can supplant
132340
+** pTemplate, in other words if pTemplate does not belong on the list.
132906132341
**
132907
-** If pX is a WhereLoop that pTemplate can replace, then return the
132342
+** If pX is a WhereLoop that pTemplate can supplant, then return the
132908132343
** link that points to pX.
132909132344
**
132910
-** If pTemplate cannot replace any existing element of the list but needs
132911
-** to be added to the list as a new entry, then return a pointer to the
132912
-** tail of the list.
132345
+** If pTemplate cannot supplant any existing element of the list but needs
132346
+** to be added to the list, then return a pointer to the tail of the list.
132913132347
*/
132914132348
static WhereLoop **whereLoopFindLesser(
132915132349
WhereLoop **ppPrev,
132916132350
const WhereLoop *pTemplate
132917132351
){
@@ -133052,14 +132486,12 @@
133052132486
#if WHERETRACE_ENABLED /* 0x8 */
133053132487
if( sqlite3WhereTrace & 0x8 ){
133054132488
if( p!=0 ){
133055132489
sqlite3DebugPrintf("replace: ");
133056132490
whereLoopPrint(p, pBuilder->pWC);
133057
- sqlite3DebugPrintf(" with: ");
133058
- }else{
133059
- sqlite3DebugPrintf(" add: ");
133060132491
}
132492
+ sqlite3DebugPrintf(" add: ");
133061132493
whereLoopPrint(pTemplate, pBuilder->pWC);
133062132494
}
133063132495
#endif
133064132496
if( p==0 ){
133065132497
/* Allocate a new WhereLoop to add to the end of the list */
@@ -133606,11 +133038,11 @@
133606133038
if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133607133039
}
133608133040
}else if( (aColExpr = pIndex->aColExpr)!=0 ){
133609133041
for(jj=0; jj<pIndex->nKeyCol; jj++){
133610133042
if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133611
- if( sqlite3ExprCompare(0, pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133043
+ if( sqlite3ExprCompare(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133612133044
return 1;
133613133045
}
133614133046
}
133615133047
}
133616133048
}
@@ -133639,20 +133071,18 @@
133639133071
** in the current query. Return true if it can be and false if not.
133640133072
*/
133641133073
static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133642133074
int i;
133643133075
WhereTerm *pTerm;
133644
- Parse *pParse = pWC->pWInfo->pParse;
133645133076
while( pWhere->op==TK_AND ){
133646133077
if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133647133078
pWhere = pWhere->pRight;
133648133079
}
133649
- if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
133650133080
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133651133081
Expr *pExpr = pTerm->pExpr;
133652
- if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133653
- && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
133082
+ if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
133083
+ && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133654133084
){
133655133085
return 1;
133656133086
}
133657133087
}
133658133088
return 0;
@@ -134627,12 +134057,11 @@
134627134057
if( iColumn>=(-1) ){
134628134058
if( pOBExpr->op!=TK_COLUMN ) continue;
134629134059
if( pOBExpr->iTable!=iCur ) continue;
134630134060
if( pOBExpr->iColumn!=iColumn ) continue;
134631134061
}else{
134632
- if( sqlite3ExprCompare(0,
134633
- pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134062
+ if( sqlite3ExprCompare(pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134634134063
continue;
134635134064
}
134636134065
}
134637134066
if( iColumn>=0 ){
134638134067
pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134927,11 +134356,10 @@
134927134356
("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134928134357
aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134929134358
rUnsorted, rCost));
134930134359
}else{
134931134360
rCost = rUnsorted;
134932
- rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
134933134361
}
134934134362
134935134363
/* Check to see if pWLoop should be added to the set of
134936134364
** mxChoice best-so-far paths.
134937134365
**
@@ -134959,12 +134387,12 @@
134959134387
/* The current candidate is no better than any of the mxChoice
134960134388
** paths currently in the best-so-far buffer. So discard
134961134389
** this candidate as not viable. */
134962134390
#ifdef WHERETRACE_ENABLED /* 0x4 */
134963134391
if( sqlite3WhereTrace&0x4 ){
134964
- sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n",
134965
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134392
+ sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n",
134393
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134966134394
isOrdered>=0 ? isOrdered+'0' : '?');
134967134395
}
134968134396
#endif
134969134397
continue;
134970134398
}
@@ -134978,40 +134406,30 @@
134978134406
jj = mxI;
134979134407
}
134980134408
pTo = &aTo[jj];
134981134409
#ifdef WHERETRACE_ENABLED /* 0x4 */
134982134410
if( sqlite3WhereTrace&0x4 ){
134983
- sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n",
134984
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134411
+ sqlite3DebugPrintf("New %s cost=%-3d,%3d order=%c\n",
134412
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134985134413
isOrdered>=0 ? isOrdered+'0' : '?');
134986134414
}
134987134415
#endif
134988134416
}else{
134989134417
/* Control reaches here if best-so-far path pTo=aTo[jj] covers the
134990
- ** same set of loops and has the same isOrdered setting as the
134418
+ ** same set of loops and has the sam isOrdered setting as the
134991134419
** candidate path. Check to see if the candidate should replace
134992
- ** pTo or if the candidate should be skipped.
134993
- **
134994
- ** The conditional is an expanded vector comparison equivalent to:
134995
- ** (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
134996
- */
134997
- if( pTo->rCost<rCost
134998
- || (pTo->rCost==rCost
134999
- && (pTo->nRow<nOut
135000
- || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
135001
- )
135002
- )
135003
- ){
134420
+ ** pTo or if the candidate should be skipped */
134421
+ if( pTo->rCost<rCost || (pTo->rCost==rCost && pTo->nRow<=nOut) ){
135004134422
#ifdef WHERETRACE_ENABLED /* 0x4 */
135005134423
if( sqlite3WhereTrace&0x4 ){
135006134424
sqlite3DebugPrintf(
135007
- "Skip %s cost=%-3d,%3d,%3d order=%c",
135008
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134425
+ "Skip %s cost=%-3d,%3d order=%c",
134426
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
135009134427
isOrdered>=0 ? isOrdered+'0' : '?');
135010
- sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n",
134428
+ sqlite3DebugPrintf(" vs %s cost=%-3d,%d order=%c\n",
135011134429
wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
135012
- pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
134430
+ pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
135013134431
}
135014134432
#endif
135015134433
/* Discard the candidate path from further consideration */
135016134434
testcase( pTo->rCost==rCost );
135017134435
continue;
@@ -135020,16 +134438,16 @@
135020134438
/* Control reaches here if the candidate path is better than the
135021134439
** pTo path. Replace pTo with the candidate. */
135022134440
#ifdef WHERETRACE_ENABLED /* 0x4 */
135023134441
if( sqlite3WhereTrace&0x4 ){
135024134442
sqlite3DebugPrintf(
135025
- "Update %s cost=%-3d,%3d,%3d order=%c",
135026
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134443
+ "Update %s cost=%-3d,%3d order=%c",
134444
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
135027134445
isOrdered>=0 ? isOrdered+'0' : '?');
135028
- sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n",
134446
+ sqlite3DebugPrintf(" was %s cost=%-3d,%3d order=%c\n",
135029134447
wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
135030
- pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
134448
+ pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
135031134449
}
135032134450
#endif
135033134451
}
135034134452
/* pWLoop is a winner. Add it to the set of best so far */
135035134453
pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
@@ -135250,35 +134668,10 @@
135250134668
return 1;
135251134669
}
135252134670
return 0;
135253134671
}
135254134672
135255
-/*
135256
-** Helper function for exprIsDeterministic().
135257
-*/
135258
-static int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){
135259
- if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){
135260
- pWalker->eCode = 0;
135261
- return WRC_Abort;
135262
- }
135263
- return WRC_Continue;
135264
-}
135265
-
135266
-/*
135267
-** Return true if the expression contains no non-deterministic SQL
135268
-** functions. Do not consider non-deterministic SQL functions that are
135269
-** part of sub-select statements.
135270
-*/
135271
-static int exprIsDeterministic(Expr *p){
135272
- Walker w;
135273
- memset(&w, 0, sizeof(w));
135274
- w.eCode = 1;
135275
- w.xExprCallback = exprNodeIsDeterministic;
135276
- sqlite3WalkExpr(&w, p);
135277
- return w.eCode;
135278
-}
135279
-
135280134673
/*
135281134674
** Generate the beginning of the loop used for WHERE clause processing.
135282134675
** The return value is a pointer to an opaque structure that contains
135283134676
** information needed to terminate the loop. Later, the calling routine
135284134677
** should invoke sqlite3WhereEnd() with the return value of this function
@@ -135473,10 +134866,21 @@
135473134866
*/
135474134867
initMaskSet(pMaskSet);
135475134868
sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
135476134869
sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
135477134870
134871
+ /* Special case: a WHERE clause that is constant. Evaluate the
134872
+ ** expression and either jump over all of the code or fall thru.
134873
+ */
134874
+ for(ii=0; ii<sWLB.pWC->nTerm; ii++){
134875
+ if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){
134876
+ sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak,
134877
+ SQLITE_JUMPIFNULL);
134878
+ sWLB.pWC->a[ii].wtFlags |= TERM_CODED;
134879
+ }
134880
+ }
134881
+
135478134882
/* Special case: No FROM clause
135479134883
*/
135480134884
if( nTabList==0 ){
135481134885
if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
135482134886
if( wctrlFlags & WHERE_WANT_DISTINCT ){
@@ -135511,29 +134915,10 @@
135511134915
135512134916
/* Analyze all of the subexpressions. */
135513134917
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
135514134918
if( db->mallocFailed ) goto whereBeginError;
135515134919
135516
- /* Special case: WHERE terms that do not refer to any tables in the join
135517
- ** (constant expressions). Evaluate each such term, and jump over all the
135518
- ** generated code if the result is not true.
135519
- **
135520
- ** Do not do this if the expression contains non-deterministic functions
135521
- ** that are not within a sub-select. This is not strictly required, but
135522
- ** preserves SQLite's legacy behaviour in the following two cases:
135523
- **
135524
- ** FROM ... WHERE random()>0; -- eval random() once per row
135525
- ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
135526
- */
135527
- for(ii=0; ii<sWLB.pWC->nTerm; ii++){
135528
- WhereTerm *pT = &sWLB.pWC->a[ii];
135529
- if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
135530
- sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);
135531
- pT->wtFlags |= TERM_CODED;
135532
- }
135533
- }
135534
-
135535134920
if( wctrlFlags & WHERE_WANT_DISTINCT ){
135536134921
if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
135537134922
/* The DISTINCT marking is pointless. Ignore it. */
135538134923
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
135539134924
}else if( pOrderBy==0 ){
@@ -135566,11 +134951,11 @@
135566134951
WhereLoop *p;
135567134952
int i;
135568134953
static const char zLabel[] = "0123456789abcdefghijklmnopqrstuvwyxz"
135569134954
"ABCDEFGHIJKLMNOPQRSTUVWYXZ";
135570134955
for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){
135571
- p->cId = zLabel[i%(sizeof(zLabel)-1)];
134956
+ p->cId = zLabel[i%sizeof(zLabel)];
135572134957
whereLoopPrint(p, sWLB.pWC);
135573134958
}
135574134959
}
135575134960
#endif
135576134961
@@ -136349,19 +135734,19 @@
136349135734
#define sqlite3ParserARG_PDECL ,Parse *pParse
136350135735
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136351135736
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
136352135737
#define YYFALLBACK 1
136353135738
#define YYNSTATE 456
136354
-#define YYNRULE 331
135739
+#define YYNRULE 332
136355135740
#define YY_MAX_SHIFT 455
136356
-#define YY_MIN_SHIFTREDUCE 667
136357
-#define YY_MAX_SHIFTREDUCE 997
136358
-#define YY_MIN_REDUCE 998
136359
-#define YY_MAX_REDUCE 1328
136360
-#define YY_ERROR_ACTION 1329
136361
-#define YY_ACCEPT_ACTION 1330
136362
-#define YY_NO_ACTION 1331
135741
+#define YY_MIN_SHIFTREDUCE 668
135742
+#define YY_MAX_SHIFTREDUCE 999
135743
+#define YY_MIN_REDUCE 1000
135744
+#define YY_MAX_REDUCE 1331
135745
+#define YY_ERROR_ACTION 1332
135746
+#define YY_ACCEPT_ACTION 1333
135747
+#define YY_NO_ACTION 1334
136363135748
/************* End control #defines *******************************************/
136364135749
136365135750
/* Define the yytestcase() macro to be a no-op if is not already defined
136366135751
** otherwise.
136367135752
**
@@ -136431,167 +135816,167 @@
136431135816
** yy_default[] Default action for each state.
136432135817
**
136433135818
*********** Begin parsing tables **********************************************/
136434135819
#define YY_ACTTAB_COUNT (1566)
136435135820
static const YYACTIONTYPE yy_action[] = {
136436
- /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
135821
+ /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98,
136437135822
/* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136438
- /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439
- /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
135823
+ /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813,
135824
+ /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96,
136440135825
/* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136441
- /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
135826
+ /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136442135827
/* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136443
- /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444
- /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445
- /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446
- /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447
- /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448
- /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449
- /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
135828
+ /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262,
135829
+ /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791,
135830
+ /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95,
135831
+ /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96,
135832
+ /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813,
135833
+ /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90,
135834
+ /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136450135835
/* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136451
- /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452
- /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453
- /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454
- /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455
- /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456
- /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
135836
+ /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75,
135837
+ /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262,
135838
+ /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371,
135839
+ /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824,
135840
+ /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380,
135841
+ /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845,
136457135842
/* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136458
- /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459
- /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460
- /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461
- /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462
- /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
135843
+ /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132,
135844
+ /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93,
135845
+ /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334,
135846
+ /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845,
135847
+ /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96,
136463135848
/* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136464
- /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465
- /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466
- /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467
- /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468
- /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469
- /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470
- /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471
- /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472
- /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473
- /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474
- /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475
- /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476
- /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477
- /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
135849
+ /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888,
135850
+ /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959,
135851
+ /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978,
135852
+ /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702,
135853
+ /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99,
135854
+ /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
135855
+ /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94,
135856
+ /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231,
135857
+ /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25,
135858
+ /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74,
135859
+ /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813,
135860
+ /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415,
135861
+ /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856,
135862
+ /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96,
136478135863
/* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136479
- /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480
- /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481
- /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482
- /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483
- /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484
- /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
135864
+ /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262,
135865
+ /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959,
135866
+ /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711,
135867
+ /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447,
135868
+ /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178,
135869
+ /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136485135870
/* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136486
- /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487
- /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488
- /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489
- /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490
- /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491
- /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492
- /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
135871
+ /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916,
135872
+ /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157,
135873
+ /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415,
135874
+ /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777,
135875
+ /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52,
135876
+ /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90,
135877
+ /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
136493135878
/* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136494
- /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495
- /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496
- /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497
- /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498
- /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499
- /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
135879
+ /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450,
135880
+ /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420,
135881
+ /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36,
135882
+ /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425,
135883
+ /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326,
135884
+ /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845,
136500135885
/* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136501
- /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502
- /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503
- /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504
- /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505
- /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506
- /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507
- /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508
- /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509
- /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510
- /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511
- /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512
- /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
135886
+ /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846,
135887
+ /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350,
135888
+ /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327,
135889
+ /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978,
135890
+ /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776,
135891
+ /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99,
135892
+ /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
135893
+ /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94,
135894
+ /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978,
135895
+ /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675,
135896
+ /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99,
135897
+ /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
136513135898
/* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136514
- /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515
- /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516
- /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517
- /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518
- /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519
- /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520
- /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
135899
+ /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450,
135900
+ /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228,
135901
+ /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31,
135902
+ /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44,
135903
+ /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268,
135904
+ /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856,
135905
+ /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96,
136521135906
/* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136522
- /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523
- /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524
- /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525
- /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
135907
+ /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48,
135908
+ /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245,
135909
+ /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817,
135910
+ /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124,
136526135911
/* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136527
- /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
135912
+ /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136528135913
/* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136529
- /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530
- /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531
- /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532
- /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
135914
+ /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817,
135915
+ /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944,
135916
+ /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107,
135917
+ /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
136533135918
/* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136534
- /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535
- /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536
- /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537
- /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538
- /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
135919
+ /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742,
135920
+ /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133,
135921
+ /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121,
135922
+ /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97,
135923
+ /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95,
136539135924
/* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136540
- /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541
- /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542
- /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
135925
+ /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263,
135926
+ /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112,
135927
+ /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97,
136543135928
/* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136544
- /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545
- /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546
- /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547
- /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548
- /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
135929
+ /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345,
135930
+ /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709,
135931
+ /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110,
135932
+ /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97,
135933
+ /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95,
136549135934
/* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136550
- /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551
- /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552
- /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553
- /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554
- /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555
- /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
135935
+ /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785,
135936
+ /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55,
135937
+ /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709,
135938
+ /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120,
135939
+ /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26,
135940
+ /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390,
136556135941
/* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136557
- /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558
- /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559
- /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560
- /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561
- /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562
- /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563
- /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564
- /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565
- /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566
- /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567
- /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568
- /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569
- /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570
- /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571
- /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572
- /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573
- /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574
- /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575
- /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576
- /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577
- /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
135942
+ /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730,
135943
+ /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819,
135944
+ /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3,
135945
+ /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824,
135946
+ /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951,
135947
+ /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7,
135948
+ /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713,
135949
+ /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205,
135950
+ /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144,
135951
+ /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366,
135952
+ /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140,
135953
+ /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683,
135954
+ /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383,
135955
+ /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824,
135956
+ /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271,
135957
+ /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85,
135958
+ /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711,
135959
+ /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724,
135960
+ /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290,
135961
+ /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827,
135962
+ /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434,
136578135963
/* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136579
- /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580
- /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
135964
+ /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217,
135965
+ /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669,
136581135966
/* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136582
- /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583
- /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584
- /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585
- /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586
- /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587
- /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588
- /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589
- /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590
- /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591
- /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592
- /* 1560 */ 87, 312, 309, 945, 1288, 1287,
135967
+ /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889,
135968
+ /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63,
135969
+ /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13,
135970
+ /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19,
135971
+ /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722,
135972
+ /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830,
135973
+ /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220,
135974
+ /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18,
135975
+ /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163,
135976
+ /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695,
135977
+ /* 1560 */ 87, 312, 309, 947, 1291, 1290,
136593135978
};
136594135979
static const YYCODETYPE yy_lookahead[] = {
136595135980
/* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136596135981
/* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136597135982
/* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136840,56 +136225,56 @@
136840136225
/* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136841136226
/* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136842136227
/* 320 */ 1280, 1281, 1264, 1269, 1283,
136843136228
};
136844136229
static const YYACTIONTYPE yy_default[] = {
136845
- /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846
- /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847
- /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848
- /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849
- /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850
- /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851
- /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852
- /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853
- /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854
- /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855
- /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856
- /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857
- /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858
- /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859
- /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860
- /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861
- /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862
- /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863
- /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864
- /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865
- /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866
- /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867
- /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868
- /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869
- /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870
- /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871
- /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872
- /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873
- /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874
- /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875
- /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876
- /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877
- /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878
- /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879
- /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880
- /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881
- /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882
- /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883
- /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884
- /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885
- /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886
- /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887
- /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888
- /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889
- /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890
- /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
136230
+ /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
136231
+ /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
136232
+ /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
136233
+ /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
136234
+ /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
136235
+ /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
136236
+ /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136237
+ /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136238
+ /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136239
+ /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136240
+ /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
136241
+ /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
136242
+ /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
136243
+ /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136244
+ /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136245
+ /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
136246
+ /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
136247
+ /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136248
+ /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
136249
+ /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136250
+ /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
136251
+ /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
136252
+ /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
136253
+ /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
136254
+ /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
136255
+ /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
136256
+ /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
136257
+ /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
136258
+ /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
136259
+ /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
136260
+ /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
136261
+ /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
136262
+ /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
136263
+ /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
136264
+ /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136265
+ /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
136266
+ /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136267
+ /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
136268
+ /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
136269
+ /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136270
+ /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136271
+ /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
136272
+ /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
136273
+ /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
136274
+ /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
136275
+ /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
136891136276
};
136892136277
/********** End of lemon-generated parsing tables *****************************/
136893136278
136894136279
/* The next table maps tokens (terminal symbols) into fallback tokens.
136895136280
** If a construct like the following:
@@ -137019,11 +136404,10 @@
137019136404
int yystksz; /* Current side of the stack */
137020136405
yyStackEntry *yystack; /* The parser's stack */
137021136406
yyStackEntry yystk0; /* First stack entry */
137022136407
#else
137023136408
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
137024
- yyStackEntry *yystackEnd; /* Last entry in the stack */
137025136409
#endif
137026136410
};
137027136411
typedef struct yyParser yyParser;
137028136412
137029136413
#ifndef NDEBUG
@@ -137358,113 +136742,114 @@
137358136742
/* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137359136743
/* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137360136744
/* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137361136745
/* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137362136746
/* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137363
- /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364
- /* 229 */ "trigger_time ::= INSTEAD OF",
137365
- /* 230 */ "trigger_time ::=",
137366
- /* 231 */ "trigger_event ::= DELETE|INSERT",
137367
- /* 232 */ "trigger_event ::= UPDATE",
137368
- /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369
- /* 234 */ "when_clause ::=",
137370
- /* 235 */ "when_clause ::= WHEN expr",
137371
- /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372
- /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373
- /* 238 */ "trnm ::= nm DOT nm",
137374
- /* 239 */ "tridxby ::= INDEXED BY nm",
137375
- /* 240 */ "tridxby ::= NOT INDEXED",
137376
- /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377
- /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378
- /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379
- /* 244 */ "trigger_cmd ::= select",
137380
- /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381
- /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382
- /* 247 */ "raisetype ::= ROLLBACK",
137383
- /* 248 */ "raisetype ::= ABORT",
137384
- /* 249 */ "raisetype ::= FAIL",
137385
- /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386
- /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387
- /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388
- /* 253 */ "key_opt ::=",
137389
- /* 254 */ "key_opt ::= KEY expr",
137390
- /* 255 */ "cmd ::= REINDEX",
137391
- /* 256 */ "cmd ::= REINDEX nm dbnm",
137392
- /* 257 */ "cmd ::= ANALYZE",
137393
- /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394
- /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395
- /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396
- /* 261 */ "add_column_fullname ::= fullname",
137397
- /* 262 */ "cmd ::= create_vtab",
137398
- /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399
- /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400
- /* 265 */ "vtabarg ::=",
137401
- /* 266 */ "vtabargtoken ::= ANY",
137402
- /* 267 */ "vtabargtoken ::= lp anylist RP",
137403
- /* 268 */ "lp ::= LP",
137404
- /* 269 */ "with ::=",
137405
- /* 270 */ "with ::= WITH wqlist",
137406
- /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407
- /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408
- /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409
- /* 274 */ "input ::= cmdlist",
137410
- /* 275 */ "cmdlist ::= cmdlist ecmd",
137411
- /* 276 */ "cmdlist ::= ecmd",
137412
- /* 277 */ "ecmd ::= SEMI",
137413
- /* 278 */ "ecmd ::= explain cmdx SEMI",
137414
- /* 279 */ "explain ::=",
137415
- /* 280 */ "trans_opt ::=",
137416
- /* 281 */ "trans_opt ::= TRANSACTION",
137417
- /* 282 */ "trans_opt ::= TRANSACTION nm",
137418
- /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419
- /* 284 */ "savepoint_opt ::=",
137420
- /* 285 */ "cmd ::= create_table create_table_args",
137421
- /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422
- /* 287 */ "columnlist ::= columnname carglist",
137423
- /* 288 */ "nm ::= ID|INDEXED",
137424
- /* 289 */ "nm ::= STRING",
137425
- /* 290 */ "nm ::= JOIN_KW",
137426
- /* 291 */ "typetoken ::= typename",
137427
- /* 292 */ "typename ::= ID|STRING",
137428
- /* 293 */ "signed ::= plus_num",
137429
- /* 294 */ "signed ::= minus_num",
137430
- /* 295 */ "carglist ::= carglist ccons",
137431
- /* 296 */ "carglist ::=",
137432
- /* 297 */ "ccons ::= NULL onconf",
137433
- /* 298 */ "conslist_opt ::= COMMA conslist",
137434
- /* 299 */ "conslist ::= conslist tconscomma tcons",
137435
- /* 300 */ "conslist ::= tcons",
137436
- /* 301 */ "tconscomma ::=",
137437
- /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438
- /* 303 */ "resolvetype ::= raisetype",
137439
- /* 304 */ "selectnowith ::= oneselect",
137440
- /* 305 */ "oneselect ::= values",
137441
- /* 306 */ "sclp ::= selcollist COMMA",
137442
- /* 307 */ "as ::= ID|STRING",
137443
- /* 308 */ "expr ::= term",
137444
- /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445
- /* 310 */ "exprlist ::= nexprlist",
137446
- /* 311 */ "nmnum ::= plus_num",
137447
- /* 312 */ "nmnum ::= nm",
137448
- /* 313 */ "nmnum ::= ON",
137449
- /* 314 */ "nmnum ::= DELETE",
137450
- /* 315 */ "nmnum ::= DEFAULT",
137451
- /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452
- /* 317 */ "foreach_clause ::=",
137453
- /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454
- /* 319 */ "trnm ::= nm",
137455
- /* 320 */ "tridxby ::=",
137456
- /* 321 */ "database_kw_opt ::= DATABASE",
137457
- /* 322 */ "database_kw_opt ::=",
137458
- /* 323 */ "kwcolumn_opt ::=",
137459
- /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460
- /* 325 */ "vtabarglist ::= vtabarg",
137461
- /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462
- /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463
- /* 328 */ "anylist ::=",
137464
- /* 329 */ "anylist ::= anylist LP anylist RP",
137465
- /* 330 */ "anylist ::= anylist ANY",
136747
+ /* 228 */ "trigger_time ::= BEFORE",
136748
+ /* 229 */ "trigger_time ::= AFTER",
136749
+ /* 230 */ "trigger_time ::= INSTEAD OF",
136750
+ /* 231 */ "trigger_time ::=",
136751
+ /* 232 */ "trigger_event ::= DELETE|INSERT",
136752
+ /* 233 */ "trigger_event ::= UPDATE",
136753
+ /* 234 */ "trigger_event ::= UPDATE OF idlist",
136754
+ /* 235 */ "when_clause ::=",
136755
+ /* 236 */ "when_clause ::= WHEN expr",
136756
+ /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
136757
+ /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
136758
+ /* 239 */ "trnm ::= nm DOT nm",
136759
+ /* 240 */ "tridxby ::= INDEXED BY nm",
136760
+ /* 241 */ "tridxby ::= NOT INDEXED",
136761
+ /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
136762
+ /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
136763
+ /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
136764
+ /* 245 */ "trigger_cmd ::= select",
136765
+ /* 246 */ "expr ::= RAISE LP IGNORE RP",
136766
+ /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
136767
+ /* 248 */ "raisetype ::= ROLLBACK",
136768
+ /* 249 */ "raisetype ::= ABORT",
136769
+ /* 250 */ "raisetype ::= FAIL",
136770
+ /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
136771
+ /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
136772
+ /* 253 */ "cmd ::= DETACH database_kw_opt expr",
136773
+ /* 254 */ "key_opt ::=",
136774
+ /* 255 */ "key_opt ::= KEY expr",
136775
+ /* 256 */ "cmd ::= REINDEX",
136776
+ /* 257 */ "cmd ::= REINDEX nm dbnm",
136777
+ /* 258 */ "cmd ::= ANALYZE",
136778
+ /* 259 */ "cmd ::= ANALYZE nm dbnm",
136779
+ /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
136780
+ /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
136781
+ /* 262 */ "add_column_fullname ::= fullname",
136782
+ /* 263 */ "cmd ::= create_vtab",
136783
+ /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
136784
+ /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
136785
+ /* 266 */ "vtabarg ::=",
136786
+ /* 267 */ "vtabargtoken ::= ANY",
136787
+ /* 268 */ "vtabargtoken ::= lp anylist RP",
136788
+ /* 269 */ "lp ::= LP",
136789
+ /* 270 */ "with ::=",
136790
+ /* 271 */ "with ::= WITH wqlist",
136791
+ /* 272 */ "with ::= WITH RECURSIVE wqlist",
136792
+ /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
136793
+ /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
136794
+ /* 275 */ "input ::= cmdlist",
136795
+ /* 276 */ "cmdlist ::= cmdlist ecmd",
136796
+ /* 277 */ "cmdlist ::= ecmd",
136797
+ /* 278 */ "ecmd ::= SEMI",
136798
+ /* 279 */ "ecmd ::= explain cmdx SEMI",
136799
+ /* 280 */ "explain ::=",
136800
+ /* 281 */ "trans_opt ::=",
136801
+ /* 282 */ "trans_opt ::= TRANSACTION",
136802
+ /* 283 */ "trans_opt ::= TRANSACTION nm",
136803
+ /* 284 */ "savepoint_opt ::= SAVEPOINT",
136804
+ /* 285 */ "savepoint_opt ::=",
136805
+ /* 286 */ "cmd ::= create_table create_table_args",
136806
+ /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
136807
+ /* 288 */ "columnlist ::= columnname carglist",
136808
+ /* 289 */ "nm ::= ID|INDEXED",
136809
+ /* 290 */ "nm ::= STRING",
136810
+ /* 291 */ "nm ::= JOIN_KW",
136811
+ /* 292 */ "typetoken ::= typename",
136812
+ /* 293 */ "typename ::= ID|STRING",
136813
+ /* 294 */ "signed ::= plus_num",
136814
+ /* 295 */ "signed ::= minus_num",
136815
+ /* 296 */ "carglist ::= carglist ccons",
136816
+ /* 297 */ "carglist ::=",
136817
+ /* 298 */ "ccons ::= NULL onconf",
136818
+ /* 299 */ "conslist_opt ::= COMMA conslist",
136819
+ /* 300 */ "conslist ::= conslist tconscomma tcons",
136820
+ /* 301 */ "conslist ::= tcons",
136821
+ /* 302 */ "tconscomma ::=",
136822
+ /* 303 */ "defer_subclause_opt ::= defer_subclause",
136823
+ /* 304 */ "resolvetype ::= raisetype",
136824
+ /* 305 */ "selectnowith ::= oneselect",
136825
+ /* 306 */ "oneselect ::= values",
136826
+ /* 307 */ "sclp ::= selcollist COMMA",
136827
+ /* 308 */ "as ::= ID|STRING",
136828
+ /* 309 */ "expr ::= term",
136829
+ /* 310 */ "likeop ::= LIKE_KW|MATCH",
136830
+ /* 311 */ "exprlist ::= nexprlist",
136831
+ /* 312 */ "nmnum ::= plus_num",
136832
+ /* 313 */ "nmnum ::= nm",
136833
+ /* 314 */ "nmnum ::= ON",
136834
+ /* 315 */ "nmnum ::= DELETE",
136835
+ /* 316 */ "nmnum ::= DEFAULT",
136836
+ /* 317 */ "plus_num ::= INTEGER|FLOAT",
136837
+ /* 318 */ "foreach_clause ::=",
136838
+ /* 319 */ "foreach_clause ::= FOR EACH ROW",
136839
+ /* 320 */ "trnm ::= nm",
136840
+ /* 321 */ "tridxby ::=",
136841
+ /* 322 */ "database_kw_opt ::= DATABASE",
136842
+ /* 323 */ "database_kw_opt ::=",
136843
+ /* 324 */ "kwcolumn_opt ::=",
136844
+ /* 325 */ "kwcolumn_opt ::= COLUMNKW",
136845
+ /* 326 */ "vtabarglist ::= vtabarg",
136846
+ /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
136847
+ /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
136848
+ /* 329 */ "anylist ::=",
136849
+ /* 330 */ "anylist ::= anylist LP anylist RP",
136850
+ /* 331 */ "anylist ::= anylist ANY",
137466136851
};
137467136852
#endif /* NDEBUG */
137468136853
137469136854
137470136855
#if YYSTACKDEPTH<=0
@@ -137529,11 +136914,10 @@
137529136914
pParser->yyerrcnt = -1;
137530136915
#endif
137531136916
pParser->yytos = pParser->yystack;
137532136917
pParser->yystack[0].stateno = 0;
137533136918
pParser->yystack[0].major = 0;
137534
- pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137535136919
}
137536136920
137537136921
#ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137538136922
/*
137539136923
** This function allocates a new parser.
@@ -137872,11 +137256,11 @@
137872137256
yypParser->yyhwm++;
137873137257
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137874137258
}
137875137259
#endif
137876137260
#if YYSTACKDEPTH>0
137877
- if( yypParser->yytos>yypParser->yystackEnd ){
137261
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
137878137262
yypParser->yytos--;
137879137263
yyStackOverflow(yypParser);
137880137264
return;
137881137265
}
137882137266
#else
@@ -137900,344 +137284,345 @@
137900137284
137901137285
/* The following table contains information about every rule that
137902137286
** is used during the reduce.
137903137287
*/
137904137288
static const struct {
137905
- YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137906
- signed char nrhs; /* Negative of the number of RHS symbols in the rule */
137289
+ YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137290
+ unsigned char nrhs; /* Number of right-hand side symbols in the rule */
137907137291
} yyRuleInfo[] = {
137908
- { 147, -1 },
137909
- { 147, -3 },
137910
- { 148, -1 },
137911
- { 149, -3 },
137292
+ { 147, 1 },
137293
+ { 147, 3 },
137294
+ { 148, 1 },
137295
+ { 149, 3 },
137912137296
{ 150, 0 },
137913
- { 150, -1 },
137914
- { 150, -1 },
137915
- { 150, -1 },
137916
- { 149, -2 },
137917
- { 149, -2 },
137918
- { 149, -2 },
137919
- { 149, -2 },
137920
- { 149, -3 },
137921
- { 149, -5 },
137922
- { 154, -6 },
137923
- { 156, -1 },
137297
+ { 150, 1 },
137298
+ { 150, 1 },
137299
+ { 150, 1 },
137300
+ { 149, 2 },
137301
+ { 149, 2 },
137302
+ { 149, 2 },
137303
+ { 149, 2 },
137304
+ { 149, 3 },
137305
+ { 149, 5 },
137306
+ { 154, 6 },
137307
+ { 156, 1 },
137924137308
{ 158, 0 },
137925
- { 158, -3 },
137926
- { 157, -1 },
137309
+ { 158, 3 },
137310
+ { 157, 1 },
137927137311
{ 157, 0 },
137928
- { 155, -5 },
137929
- { 155, -2 },
137312
+ { 155, 5 },
137313
+ { 155, 2 },
137930137314
{ 162, 0 },
137931
- { 162, -2 },
137932
- { 164, -2 },
137315
+ { 162, 2 },
137316
+ { 164, 2 },
137933137317
{ 166, 0 },
137934
- { 166, -4 },
137935
- { 166, -6 },
137936
- { 167, -2 },
137937
- { 171, -2 },
137938
- { 171, -2 },
137939
- { 171, -4 },
137940
- { 171, -3 },
137941
- { 171, -3 },
137942
- { 171, -2 },
137943
- { 171, -3 },
137944
- { 171, -5 },
137945
- { 171, -2 },
137946
- { 171, -4 },
137947
- { 171, -4 },
137948
- { 171, -1 },
137949
- { 171, -2 },
137318
+ { 166, 4 },
137319
+ { 166, 6 },
137320
+ { 167, 2 },
137321
+ { 171, 2 },
137322
+ { 171, 2 },
137323
+ { 171, 4 },
137324
+ { 171, 3 },
137325
+ { 171, 3 },
137326
+ { 171, 2 },
137327
+ { 171, 3 },
137328
+ { 171, 5 },
137329
+ { 171, 2 },
137330
+ { 171, 4 },
137331
+ { 171, 4 },
137332
+ { 171, 1 },
137333
+ { 171, 2 },
137950137334
{ 176, 0 },
137951
- { 176, -1 },
137335
+ { 176, 1 },
137952137336
{ 178, 0 },
137953
- { 178, -2 },
137954
- { 180, -2 },
137955
- { 180, -3 },
137956
- { 180, -3 },
137957
- { 180, -3 },
137958
- { 181, -2 },
137959
- { 181, -2 },
137960
- { 181, -1 },
137961
- { 181, -1 },
137962
- { 181, -2 },
137963
- { 179, -3 },
137964
- { 179, -2 },
137337
+ { 178, 2 },
137338
+ { 180, 2 },
137339
+ { 180, 3 },
137340
+ { 180, 3 },
137341
+ { 180, 3 },
137342
+ { 181, 2 },
137343
+ { 181, 2 },
137344
+ { 181, 1 },
137345
+ { 181, 1 },
137346
+ { 181, 2 },
137347
+ { 179, 3 },
137348
+ { 179, 2 },
137965137349
{ 182, 0 },
137966
- { 182, -2 },
137967
- { 182, -2 },
137350
+ { 182, 2 },
137351
+ { 182, 2 },
137968137352
{ 161, 0 },
137969
- { 184, -1 },
137970
- { 185, -2 },
137971
- { 185, -7 },
137972
- { 185, -5 },
137973
- { 185, -5 },
137974
- { 185, -10 },
137353
+ { 184, 1 },
137354
+ { 185, 2 },
137355
+ { 185, 7 },
137356
+ { 185, 5 },
137357
+ { 185, 5 },
137358
+ { 185, 10 },
137975137359
{ 188, 0 },
137976137360
{ 174, 0 },
137977
- { 174, -3 },
137361
+ { 174, 3 },
137978137362
{ 189, 0 },
137979
- { 189, -2 },
137980
- { 190, -1 },
137981
- { 190, -1 },
137982
- { 149, -4 },
137983
- { 192, -2 },
137363
+ { 189, 2 },
137364
+ { 190, 1 },
137365
+ { 190, 1 },
137366
+ { 149, 4 },
137367
+ { 192, 2 },
137984137368
{ 192, 0 },
137985
- { 149, -9 },
137986
- { 149, -4 },
137987
- { 149, -1 },
137988
- { 163, -2 },
137989
- { 194, -3 },
137990
- { 197, -1 },
137991
- { 197, -2 },
137992
- { 197, -1 },
137993
- { 195, -9 },
137994
- { 206, -4 },
137995
- { 206, -5 },
137996
- { 198, -1 },
137997
- { 198, -1 },
137369
+ { 149, 9 },
137370
+ { 149, 4 },
137371
+ { 149, 1 },
137372
+ { 163, 2 },
137373
+ { 194, 3 },
137374
+ { 197, 1 },
137375
+ { 197, 2 },
137376
+ { 197, 1 },
137377
+ { 195, 9 },
137378
+ { 206, 4 },
137379
+ { 206, 5 },
137380
+ { 198, 1 },
137381
+ { 198, 1 },
137998137382
{ 198, 0 },
137999137383
{ 209, 0 },
138000
- { 199, -3 },
138001
- { 199, -2 },
138002
- { 199, -4 },
138003
- { 210, -2 },
137384
+ { 199, 3 },
137385
+ { 199, 2 },
137386
+ { 199, 4 },
137387
+ { 210, 2 },
138004137388
{ 210, 0 },
138005137389
{ 200, 0 },
138006
- { 200, -2 },
138007
- { 212, -2 },
137390
+ { 200, 2 },
137391
+ { 212, 2 },
138008137392
{ 212, 0 },
138009
- { 211, -7 },
138010
- { 211, -9 },
138011
- { 211, -7 },
138012
- { 211, -7 },
137393
+ { 211, 7 },
137394
+ { 211, 9 },
137395
+ { 211, 7 },
137396
+ { 211, 7 },
138013137397
{ 159, 0 },
138014
- { 159, -2 },
138015
- { 193, -2 },
138016
- { 213, -1 },
138017
- { 213, -2 },
138018
- { 213, -3 },
138019
- { 213, -4 },
138020
- { 215, -2 },
137398
+ { 159, 2 },
137399
+ { 193, 2 },
137400
+ { 213, 1 },
137401
+ { 213, 2 },
137402
+ { 213, 3 },
137403
+ { 213, 4 },
137404
+ { 215, 2 },
138021137405
{ 215, 0 },
138022137406
{ 214, 0 },
138023
- { 214, -3 },
138024
- { 214, -2 },
138025
- { 216, -4 },
137407
+ { 214, 3 },
137408
+ { 214, 2 },
137409
+ { 216, 4 },
138026137410
{ 216, 0 },
138027137411
{ 204, 0 },
138028
- { 204, -3 },
138029
- { 186, -4 },
138030
- { 186, -2 },
138031
- { 175, -1 },
138032
- { 175, -1 },
137412
+ { 204, 3 },
137413
+ { 186, 4 },
137414
+ { 186, 2 },
137415
+ { 175, 1 },
137416
+ { 175, 1 },
138033137417
{ 175, 0 },
138034137418
{ 202, 0 },
138035
- { 202, -3 },
137419
+ { 202, 3 },
138036137420
{ 203, 0 },
138037
- { 203, -2 },
137421
+ { 203, 2 },
138038137422
{ 205, 0 },
138039
- { 205, -2 },
138040
- { 205, -4 },
138041
- { 205, -4 },
138042
- { 149, -6 },
137423
+ { 205, 2 },
137424
+ { 205, 4 },
137425
+ { 205, 4 },
137426
+ { 149, 6 },
138043137427
{ 201, 0 },
138044
- { 201, -2 },
138045
- { 149, -8 },
138046
- { 218, -5 },
138047
- { 218, -7 },
138048
- { 218, -3 },
138049
- { 218, -5 },
138050
- { 149, -6 },
138051
- { 149, -7 },
138052
- { 219, -2 },
138053
- { 219, -1 },
137428
+ { 201, 2 },
137429
+ { 149, 8 },
137430
+ { 218, 5 },
137431
+ { 218, 7 },
137432
+ { 218, 3 },
137433
+ { 218, 5 },
137434
+ { 149, 6 },
137435
+ { 149, 7 },
137436
+ { 219, 2 },
137437
+ { 219, 1 },
138054137438
{ 220, 0 },
138055
- { 220, -3 },
138056
- { 217, -3 },
138057
- { 217, -1 },
138058
- { 173, -3 },
138059
- { 172, -1 },
138060
- { 173, -1 },
138061
- { 173, -1 },
138062
- { 173, -3 },
138063
- { 173, -5 },
138064
- { 172, -1 },
138065
- { 172, -1 },
138066
- { 172, -1 },
138067
- { 173, -1 },
138068
- { 173, -3 },
138069
- { 173, -6 },
138070
- { 173, -5 },
138071
- { 173, -4 },
138072
- { 172, -1 },
138073
- { 173, -5 },
138074
- { 173, -3 },
138075
- { 173, -3 },
138076
- { 173, -3 },
138077
- { 173, -3 },
138078
- { 173, -3 },
138079
- { 173, -3 },
138080
- { 173, -3 },
138081
- { 173, -3 },
138082
- { 221, -2 },
138083
- { 173, -3 },
138084
- { 173, -5 },
138085
- { 173, -2 },
138086
- { 173, -3 },
138087
- { 173, -3 },
138088
- { 173, -4 },
138089
- { 173, -2 },
138090
- { 173, -2 },
138091
- { 173, -2 },
138092
- { 173, -2 },
138093
- { 222, -1 },
138094
- { 222, -2 },
138095
- { 173, -5 },
138096
- { 223, -1 },
138097
- { 223, -2 },
138098
- { 173, -5 },
138099
- { 173, -3 },
138100
- { 173, -5 },
138101
- { 173, -5 },
138102
- { 173, -4 },
138103
- { 173, -5 },
138104
- { 226, -5 },
138105
- { 226, -4 },
138106
- { 227, -2 },
137439
+ { 220, 3 },
137440
+ { 217, 3 },
137441
+ { 217, 1 },
137442
+ { 173, 3 },
137443
+ { 172, 1 },
137444
+ { 173, 1 },
137445
+ { 173, 1 },
137446
+ { 173, 3 },
137447
+ { 173, 5 },
137448
+ { 172, 1 },
137449
+ { 172, 1 },
137450
+ { 172, 1 },
137451
+ { 173, 1 },
137452
+ { 173, 3 },
137453
+ { 173, 6 },
137454
+ { 173, 5 },
137455
+ { 173, 4 },
137456
+ { 172, 1 },
137457
+ { 173, 5 },
137458
+ { 173, 3 },
137459
+ { 173, 3 },
137460
+ { 173, 3 },
137461
+ { 173, 3 },
137462
+ { 173, 3 },
137463
+ { 173, 3 },
137464
+ { 173, 3 },
137465
+ { 173, 3 },
137466
+ { 221, 2 },
137467
+ { 173, 3 },
137468
+ { 173, 5 },
137469
+ { 173, 2 },
137470
+ { 173, 3 },
137471
+ { 173, 3 },
137472
+ { 173, 4 },
137473
+ { 173, 2 },
137474
+ { 173, 2 },
137475
+ { 173, 2 },
137476
+ { 173, 2 },
137477
+ { 222, 1 },
137478
+ { 222, 2 },
137479
+ { 173, 5 },
137480
+ { 223, 1 },
137481
+ { 223, 2 },
137482
+ { 173, 5 },
137483
+ { 173, 3 },
137484
+ { 173, 5 },
137485
+ { 173, 5 },
137486
+ { 173, 4 },
137487
+ { 173, 5 },
137488
+ { 226, 5 },
137489
+ { 226, 4 },
137490
+ { 227, 2 },
138107137491
{ 227, 0 },
138108
- { 225, -1 },
137492
+ { 225, 1 },
138109137493
{ 225, 0 },
138110137494
{ 208, 0 },
138111
- { 207, -3 },
138112
- { 207, -1 },
137495
+ { 207, 3 },
137496
+ { 207, 1 },
138113137497
{ 224, 0 },
138114
- { 224, -3 },
138115
- { 149, -12 },
138116
- { 228, -1 },
137498
+ { 224, 3 },
137499
+ { 149, 12 },
137500
+ { 228, 1 },
138117137501
{ 228, 0 },
138118137502
{ 177, 0 },
138119
- { 177, -3 },
138120
- { 187, -5 },
138121
- { 187, -3 },
137503
+ { 177, 3 },
137504
+ { 187, 5 },
137505
+ { 187, 3 },
138122137506
{ 229, 0 },
138123
- { 229, -2 },
138124
- { 149, -4 },
138125
- { 149, -1 },
138126
- { 149, -2 },
138127
- { 149, -3 },
138128
- { 149, -5 },
138129
- { 149, -6 },
138130
- { 149, -5 },
138131
- { 149, -6 },
138132
- { 169, -2 },
138133
- { 170, -2 },
138134
- { 149, -5 },
138135
- { 231, -11 },
138136
- { 233, -1 },
138137
- { 233, -2 },
137507
+ { 229, 2 },
137508
+ { 149, 4 },
137509
+ { 149, 1 },
137510
+ { 149, 2 },
137511
+ { 149, 3 },
137512
+ { 149, 5 },
137513
+ { 149, 6 },
137514
+ { 149, 5 },
137515
+ { 149, 6 },
137516
+ { 169, 2 },
137517
+ { 170, 2 },
137518
+ { 149, 5 },
137519
+ { 231, 11 },
137520
+ { 233, 1 },
137521
+ { 233, 1 },
137522
+ { 233, 2 },
138138137523
{ 233, 0 },
138139
- { 234, -1 },
138140
- { 234, -1 },
138141
- { 234, -3 },
137524
+ { 234, 1 },
137525
+ { 234, 1 },
137526
+ { 234, 3 },
138142137527
{ 236, 0 },
138143
- { 236, -2 },
138144
- { 232, -3 },
138145
- { 232, -2 },
138146
- { 238, -3 },
138147
- { 239, -3 },
138148
- { 239, -2 },
138149
- { 237, -7 },
138150
- { 237, -5 },
138151
- { 237, -5 },
138152
- { 237, -1 },
138153
- { 173, -4 },
138154
- { 173, -6 },
138155
- { 191, -1 },
138156
- { 191, -1 },
138157
- { 191, -1 },
138158
- { 149, -4 },
138159
- { 149, -6 },
138160
- { 149, -3 },
137528
+ { 236, 2 },
137529
+ { 232, 3 },
137530
+ { 232, 2 },
137531
+ { 238, 3 },
137532
+ { 239, 3 },
137533
+ { 239, 2 },
137534
+ { 237, 7 },
137535
+ { 237, 5 },
137536
+ { 237, 5 },
137537
+ { 237, 1 },
137538
+ { 173, 4 },
137539
+ { 173, 6 },
137540
+ { 191, 1 },
137541
+ { 191, 1 },
137542
+ { 191, 1 },
137543
+ { 149, 4 },
137544
+ { 149, 6 },
137545
+ { 149, 3 },
138161137546
{ 241, 0 },
138162
- { 241, -2 },
138163
- { 149, -1 },
138164
- { 149, -3 },
138165
- { 149, -1 },
138166
- { 149, -3 },
138167
- { 149, -6 },
138168
- { 149, -7 },
138169
- { 242, -1 },
138170
- { 149, -1 },
138171
- { 149, -4 },
138172
- { 244, -8 },
137547
+ { 241, 2 },
137548
+ { 149, 1 },
137549
+ { 149, 3 },
137550
+ { 149, 1 },
137551
+ { 149, 3 },
137552
+ { 149, 6 },
137553
+ { 149, 7 },
137554
+ { 242, 1 },
137555
+ { 149, 1 },
137556
+ { 149, 4 },
137557
+ { 244, 8 },
138173137558
{ 246, 0 },
138174
- { 247, -1 },
138175
- { 247, -3 },
138176
- { 248, -1 },
137559
+ { 247, 1 },
137560
+ { 247, 3 },
137561
+ { 248, 1 },
138177137562
{ 196, 0 },
138178
- { 196, -2 },
138179
- { 196, -3 },
138180
- { 250, -6 },
138181
- { 250, -8 },
138182
- { 144, -1 },
138183
- { 145, -2 },
138184
- { 145, -1 },
138185
- { 146, -1 },
138186
- { 146, -3 },
137563
+ { 196, 2 },
137564
+ { 196, 3 },
137565
+ { 250, 6 },
137566
+ { 250, 8 },
137567
+ { 144, 1 },
137568
+ { 145, 2 },
137569
+ { 145, 1 },
137570
+ { 146, 1 },
137571
+ { 146, 3 },
138187137572
{ 147, 0 },
138188137573
{ 151, 0 },
138189
- { 151, -1 },
138190
- { 151, -2 },
138191
- { 153, -1 },
137574
+ { 151, 1 },
137575
+ { 151, 2 },
137576
+ { 153, 1 },
138192137577
{ 153, 0 },
138193
- { 149, -2 },
138194
- { 160, -4 },
138195
- { 160, -2 },
138196
- { 152, -1 },
138197
- { 152, -1 },
138198
- { 152, -1 },
138199
- { 166, -1 },
138200
- { 167, -1 },
138201
- { 168, -1 },
138202
- { 168, -1 },
138203
- { 165, -2 },
137578
+ { 149, 2 },
137579
+ { 160, 4 },
137580
+ { 160, 2 },
137581
+ { 152, 1 },
137582
+ { 152, 1 },
137583
+ { 152, 1 },
137584
+ { 166, 1 },
137585
+ { 167, 1 },
137586
+ { 168, 1 },
137587
+ { 168, 1 },
137588
+ { 165, 2 },
138204137589
{ 165, 0 },
138205
- { 171, -2 },
138206
- { 161, -2 },
138207
- { 183, -3 },
138208
- { 183, -1 },
137590
+ { 171, 2 },
137591
+ { 161, 2 },
137592
+ { 183, 3 },
137593
+ { 183, 1 },
138209137594
{ 184, 0 },
138210
- { 188, -1 },
138211
- { 190, -1 },
138212
- { 194, -1 },
138213
- { 195, -1 },
138214
- { 209, -2 },
138215
- { 210, -1 },
138216
- { 173, -1 },
138217
- { 221, -1 },
138218
- { 208, -1 },
138219
- { 230, -1 },
138220
- { 230, -1 },
138221
- { 230, -1 },
138222
- { 230, -1 },
138223
- { 230, -1 },
138224
- { 169, -1 },
137595
+ { 188, 1 },
137596
+ { 190, 1 },
137597
+ { 194, 1 },
137598
+ { 195, 1 },
137599
+ { 209, 2 },
137600
+ { 210, 1 },
137601
+ { 173, 1 },
137602
+ { 221, 1 },
137603
+ { 208, 1 },
137604
+ { 230, 1 },
137605
+ { 230, 1 },
137606
+ { 230, 1 },
137607
+ { 230, 1 },
137608
+ { 230, 1 },
137609
+ { 169, 1 },
138225137610
{ 235, 0 },
138226
- { 235, -3 },
138227
- { 238, -1 },
137611
+ { 235, 3 },
137612
+ { 238, 1 },
138228137613
{ 239, 0 },
138229
- { 240, -1 },
137614
+ { 240, 1 },
138230137615
{ 240, 0 },
138231137616
{ 243, 0 },
138232
- { 243, -1 },
138233
- { 245, -1 },
138234
- { 245, -3 },
138235
- { 246, -2 },
137617
+ { 243, 1 },
137618
+ { 245, 1 },
137619
+ { 245, 3 },
137620
+ { 246, 2 },
138236137621
{ 249, 0 },
138237
- { 249, -4 },
138238
- { 249, -2 },
137622
+ { 249, 4 },
137623
+ { 249, 2 },
138239137624
};
138240137625
138241137626
static void yy_accept(yyParser*); /* Forward Declaration */
138242137627
138243137628
/*
@@ -138256,11 +137641,11 @@
138256137641
yymsp = yypParser->yytos;
138257137642
#ifndef NDEBUG
138258137643
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
138259137644
yysize = yyRuleInfo[yyruleno].nrhs;
138260137645
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
138261
- yyRuleName[yyruleno], yymsp[yysize].stateno);
137646
+ yyRuleName[yyruleno], yymsp[-yysize].stateno);
138262137647
}
138263137648
#endif /* NDEBUG */
138264137649
138265137650
/* Check that the stack is large enough to grow by a single entry
138266137651
** if the RHS of the rule is empty. This ensures that there is room
@@ -138271,11 +137656,11 @@
138271137656
yypParser->yyhwm++;
138272137657
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
138273137658
}
138274137659
#endif
138275137660
#if YYSTACKDEPTH>0
138276
- if( yypParser->yytos>=yypParser->yystackEnd ){
137661
+ if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
138277137662
yyStackOverflow(yypParser);
138278137663
return;
138279137664
}
138280137665
#else
138281137666
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139230,11 +138615,11 @@
139230138615
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139231138616
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139232138617
}
139233138618
break;
139234138619
case 208: /* uniqueflag ::= UNIQUE */
139235
- case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
138620
+ case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
139236138621
{yymsp[0].minor.yy194 = OE_Abort;}
139237138622
break;
139238138623
case 209: /* uniqueflag ::= */
139239138624
{yymsp[1].minor.yy194 = OE_None;}
139240138625
break;
@@ -139284,269 +138669,268 @@
139284138669
{
139285138670
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);
139286138671
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139287138672
}
139288138673
break;
139289
- case 228: /* trigger_time ::= BEFORE|AFTER */
139290
-{ yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
138674
+ case 228: /* trigger_time ::= BEFORE */
138675
+{ yymsp[0].minor.yy194 = TK_BEFORE; }
139291138676
break;
139292
- case 229: /* trigger_time ::= INSTEAD OF */
138677
+ case 229: /* trigger_time ::= AFTER */
138678
+{ yymsp[0].minor.yy194 = TK_AFTER; }
138679
+ break;
138680
+ case 230: /* trigger_time ::= INSTEAD OF */
139293138681
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
139294138682
break;
139295
- case 230: /* trigger_time ::= */
138683
+ case 231: /* trigger_time ::= */
139296138684
{ yymsp[1].minor.yy194 = TK_BEFORE; }
139297138685
break;
139298
- case 231: /* trigger_event ::= DELETE|INSERT */
139299
- case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
138686
+ case 232: /* trigger_event ::= DELETE|INSERT */
138687
+ case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
139300138688
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139301138689
break;
139302
- case 233: /* trigger_event ::= UPDATE OF idlist */
138690
+ case 234: /* trigger_event ::= UPDATE OF idlist */
139303138691
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139304138692
break;
139305
- case 234: /* when_clause ::= */
139306
- case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
138693
+ case 235: /* when_clause ::= */
138694
+ case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
139307138695
{ yymsp[1].minor.yy72 = 0; }
139308138696
break;
139309
- case 235: /* when_clause ::= WHEN expr */
139310
- case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
138697
+ case 236: /* when_clause ::= WHEN expr */
138698
+ case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
139311138699
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139312138700
break;
139313
- case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
138701
+ case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139314138702
{
139315138703
assert( yymsp[-2].minor.yy145!=0 );
139316138704
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139317138705
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139318138706
}
139319138707
break;
139320
- case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
138708
+ case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
139321138709
{
139322138710
assert( yymsp[-1].minor.yy145!=0 );
139323138711
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139324138712
}
139325138713
break;
139326
- case 238: /* trnm ::= nm DOT nm */
138714
+ case 239: /* trnm ::= nm DOT nm */
139327138715
{
139328138716
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139329138717
sqlite3ErrorMsg(pParse,
139330138718
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139331138719
"statements within triggers");
139332138720
}
139333138721
break;
139334
- case 239: /* tridxby ::= INDEXED BY nm */
138722
+ case 240: /* tridxby ::= INDEXED BY nm */
139335138723
{
139336138724
sqlite3ErrorMsg(pParse,
139337138725
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139338138726
"within triggers");
139339138727
}
139340138728
break;
139341
- case 240: /* tridxby ::= NOT INDEXED */
138729
+ case 241: /* tridxby ::= NOT INDEXED */
139342138730
{
139343138731
sqlite3ErrorMsg(pParse,
139344138732
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139345138733
"within triggers");
139346138734
}
139347138735
break;
139348
- case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
138736
+ case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139349138737
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139350138738
break;
139351
- case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
138739
+ case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139352138740
{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*/}
139353138741
break;
139354
- case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
138742
+ case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139355138743
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139356138744
break;
139357
- case 244: /* trigger_cmd ::= select */
138745
+ case 245: /* trigger_cmd ::= select */
139358138746
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139359138747
break;
139360
- case 245: /* expr ::= RAISE LP IGNORE RP */
138748
+ case 246: /* expr ::= RAISE LP IGNORE RP */
139361138749
{
139362138750
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139363138751
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139364138752
if( yymsp[-3].minor.yy190.pExpr ){
139365138753
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139366138754
}
139367138755
}
139368138756
break;
139369
- case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
138757
+ case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
139370138758
{
139371138759
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139372138760
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139373138761
if( yymsp[-5].minor.yy190.pExpr ) {
139374138762
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139375138763
}
139376138764
}
139377138765
break;
139378
- case 247: /* raisetype ::= ROLLBACK */
138766
+ case 248: /* raisetype ::= ROLLBACK */
139379138767
{yymsp[0].minor.yy194 = OE_Rollback;}
139380138768
break;
139381
- case 249: /* raisetype ::= FAIL */
138769
+ case 250: /* raisetype ::= FAIL */
139382138770
{yymsp[0].minor.yy194 = OE_Fail;}
139383138771
break;
139384
- case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
138772
+ case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
139385138773
{
139386138774
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139387138775
}
139388138776
break;
139389
- case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
138777
+ case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139390138778
{
139391138779
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139392138780
}
139393138781
break;
139394
- case 252: /* cmd ::= DETACH database_kw_opt expr */
138782
+ case 253: /* cmd ::= DETACH database_kw_opt expr */
139395138783
{
139396138784
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139397138785
}
139398138786
break;
139399
- case 255: /* cmd ::= REINDEX */
138787
+ case 256: /* cmd ::= REINDEX */
139400138788
{sqlite3Reindex(pParse, 0, 0);}
139401138789
break;
139402
- case 256: /* cmd ::= REINDEX nm dbnm */
138790
+ case 257: /* cmd ::= REINDEX nm dbnm */
139403138791
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139404138792
break;
139405
- case 257: /* cmd ::= ANALYZE */
138793
+ case 258: /* cmd ::= ANALYZE */
139406138794
{sqlite3Analyze(pParse, 0, 0);}
139407138795
break;
139408
- case 258: /* cmd ::= ANALYZE nm dbnm */
138796
+ case 259: /* cmd ::= ANALYZE nm dbnm */
139409138797
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139410138798
break;
139411
- case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
138799
+ case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139412138800
{
139413138801
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139414138802
}
139415138803
break;
139416
- case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
138804
+ case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139417138805
{
139418138806
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139419138807
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139420138808
}
139421138809
break;
139422
- case 261: /* add_column_fullname ::= fullname */
138810
+ case 262: /* add_column_fullname ::= fullname */
139423138811
{
139424138812
disableLookaside(pParse);
139425138813
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139426138814
}
139427138815
break;
139428
- case 262: /* cmd ::= create_vtab */
138816
+ case 263: /* cmd ::= create_vtab */
139429138817
{sqlite3VtabFinishParse(pParse,0);}
139430138818
break;
139431
- case 263: /* cmd ::= create_vtab LP vtabarglist RP */
138819
+ case 264: /* cmd ::= create_vtab LP vtabarglist RP */
139432138820
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139433138821
break;
139434
- case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
138822
+ case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139435138823
{
139436138824
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139437138825
}
139438138826
break;
139439
- case 265: /* vtabarg ::= */
138827
+ case 266: /* vtabarg ::= */
139440138828
{sqlite3VtabArgInit(pParse);}
139441138829
break;
139442
- case 266: /* vtabargtoken ::= ANY */
139443
- case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444
- case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
138830
+ case 267: /* vtabargtoken ::= ANY */
138831
+ case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
138832
+ case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
139445138833
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139446138834
break;
139447
- case 269: /* with ::= */
138835
+ case 270: /* with ::= */
139448138836
{yymsp[1].minor.yy285 = 0;}
139449138837
break;
139450
- case 270: /* with ::= WITH wqlist */
138838
+ case 271: /* with ::= WITH wqlist */
139451138839
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139452138840
break;
139453
- case 271: /* with ::= WITH RECURSIVE wqlist */
138841
+ case 272: /* with ::= WITH RECURSIVE wqlist */
139454138842
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139455138843
break;
139456
- case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
138844
+ case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
139457138845
{
139458138846
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139459138847
}
139460138848
break;
139461
- case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
138849
+ case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139462138850
{
139463138851
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139464138852
}
139465138853
break;
139466138854
default:
139467
- /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468
- /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469
- /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470
- /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471
- /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472
- /* (279) explain ::= */ yytestcase(yyruleno==279);
139473
- /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474
- /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475
- /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476
- /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477
- /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478
- /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479
- /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480
- /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481
- /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482
- /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483
- /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484
- /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485
- /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486
- /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487
- /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488
- /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489
- /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490
- /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491
- /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492
- /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493
- /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494
- /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495
- /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496
- /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497
- /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498
- /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499
- /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500
- /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501
- /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502
- /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503
- /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504
- /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505
- /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506
- /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507
- /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508
- /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509
- /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510
- /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511
- /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512
- /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513
- /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514
- /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515
- /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516
- /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517
- /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518
- /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519
- /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520
- /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521
- /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522
- /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523
- /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
138855
+ /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
138856
+ /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
138857
+ /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
138858
+ /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
138859
+ /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
138860
+ /* (280) explain ::= */ yytestcase(yyruleno==280);
138861
+ /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
138862
+ /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
138863
+ /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
138864
+ /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
138865
+ /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
138866
+ /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
138867
+ /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
138868
+ /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
138869
+ /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
138870
+ /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
138871
+ /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
138872
+ /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
138873
+ /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
138874
+ /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
138875
+ /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
138876
+ /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
138877
+ /* (297) carglist ::= */ yytestcase(yyruleno==297);
138878
+ /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
138879
+ /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
138880
+ /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
138881
+ /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
138882
+ /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
138883
+ /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
138884
+ /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
138885
+ /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
138886
+ /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
138887
+ /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
138888
+ /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
138889
+ /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
138890
+ /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
138891
+ /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
138892
+ /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
138893
+ /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
138894
+ /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
138895
+ /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
138896
+ /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
138897
+ /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
138898
+ /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
138899
+ /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
138900
+ /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
138901
+ /* (321) tridxby ::= */ yytestcase(yyruleno==321);
138902
+ /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
138903
+ /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
138904
+ /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
138905
+ /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
138906
+ /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
138907
+ /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
138908
+ /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
138909
+ /* (329) anylist ::= */ yytestcase(yyruleno==329);
138910
+ /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
138911
+ /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
139524138912
break;
139525138913
/********** End reduce actions ************************************************/
139526138914
};
139527138915
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139528138916
yygoto = yyRuleInfo[yyruleno].lhs;
139529138917
yysize = yyRuleInfo[yyruleno].nrhs;
139530
- yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
139531
-
139532
- /* There are no SHIFTREDUCE actions on nonterminals because the table
139533
- ** generator has simplified them to pure REDUCE actions. */
139534
- assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
139535
-
139536
- /* It is not possible for a REDUCE to be followed by an error */
139537
- assert( yyact!=YY_ERROR_ACTION );
139538
-
139539
- if( yyact==YY_ACCEPT_ACTION ){
139540
- yypParser->yytos += yysize;
139541
- yy_accept(yypParser);
139542
- }else{
139543
- yymsp += yysize+1;
138918
+ yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
138919
+ if( yyact <= YY_MAX_SHIFTREDUCE ){
138920
+ if( yyact>YY_MAX_SHIFT ){
138921
+ yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
138922
+ }
138923
+ yymsp -= yysize-1;
139544138924
yypParser->yytos = yymsp;
139545138925
yymsp->stateno = (YYACTIONTYPE)yyact;
139546138926
yymsp->major = (YYCODETYPE)yygoto;
139547138927
yyTraceShift(yypParser, yyact);
138928
+ }else{
138929
+ assert( yyact == YY_ACCEPT_ACTION );
138930
+ yypParser->yytos -= yysize;
138931
+ yy_accept(yypParser);
139548138932
}
139549138933
}
139550138934
139551138935
/*
139552138936
** The following code executes when the parse fails
@@ -141110,13 +140494,10 @@
141110140494
/************** Continuing where we left off in main.c ***********************/
141111140495
#endif
141112140496
#ifdef SQLITE_ENABLE_JSON1
141113140497
SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
141114140498
#endif
141115
-#ifdef SQLITE_ENABLE_STMTVTAB
141116
-SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
141117
-#endif
141118140499
#ifdef SQLITE_ENABLE_FTS5
141119140500
SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
141120140501
#endif
141121140502
141122140503
#ifndef SQLITE_AMALGAMATION
@@ -141896,11 +141277,10 @@
141896141277
{ SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141897141278
{ SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141898141279
{ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141899141280
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141900141281
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
141901
- { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
141902141282
};
141903141283
unsigned int i;
141904141284
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141905141285
for(i=0; i<ArraySize(aFlagOp); i++){
141906141286
if( aFlagOp[i].op==op ){
@@ -141953,11 +141333,10 @@
141953141333
int rc, n;
141954141334
n = nKey1<nKey2 ? nKey1 : nKey2;
141955141335
/* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares
141956141336
** strings byte by byte using the memcmp() function from the standard C
141957141337
** library. */
141958
- assert( pKey1 && pKey2 );
141959141338
rc = memcmp(pKey1, pKey2, n);
141960141339
if( rc==0 ){
141961141340
if( padFlag
141962141341
&& allSpaces(((char*)pKey1)+n, nKey1-n)
141963141342
&& allSpaces(((char*)pKey2)+n, nKey2-n)
@@ -144002,13 +143381,10 @@
144002143381
| SQLITE_CellSizeCk
144003143382
#endif
144004143383
#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
144005143384
| SQLITE_Fts3Tokenizer
144006143385
#endif
144007
-#if defined(SQLITE_ENABLE_QPSG)
144008
- | SQLITE_EnableQPSG
144009
-#endif
144010143386
;
144011143387
sqlite3HashInit(&db->aCollSeq);
144012143388
#ifndef SQLITE_OMIT_VIRTUALTABLE
144013143389
sqlite3HashInit(&db->aModule);
144014143390
#endif
@@ -144141,16 +143517,10 @@
144141143517
144142143518
#ifdef SQLITE_ENABLE_JSON1
144143143519
if( !db->mallocFailed && rc==SQLITE_OK){
144144143520
rc = sqlite3Json1Init(db);
144145143521
}
144146
-#endif
144147
-
144148
-#ifdef SQLITE_ENABLE_STMTVTAB
144149
- if( !db->mallocFailed && rc==SQLITE_OK){
144150
- rc = sqlite3StmtVtabInit(db);
144151
- }
144152143522
#endif
144153143523
144154143524
/* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
144155143525
** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
144156143526
** mode. Doing nothing at all also makes NORMAL the default.
@@ -144433,16 +143803,10 @@
144433143803
SQLITE_PRIVATE int sqlite3CantopenError(int lineno){
144434143804
testcase( sqlite3GlobalConfig.xLog!=0 );
144435143805
return reportError(SQLITE_CANTOPEN, lineno, "cannot open file");
144436143806
}
144437143807
#ifdef SQLITE_DEBUG
144438
-SQLITE_PRIVATE int sqlite3CorruptPgnoError(int lineno, Pgno pgno){
144439
- char zMsg[100];
144440
- sqlite3_snprintf(sizeof(zMsg), zMsg, "database corruption page %d", pgno);
144441
- testcase( sqlite3GlobalConfig.xLog!=0 );
144442
- return reportError(SQLITE_CORRUPT, lineno, zMsg);
144443
-}
144444143808
SQLITE_PRIVATE int sqlite3NomemError(int lineno){
144445143809
testcase( sqlite3GlobalConfig.xLog!=0 );
144446143810
return reportError(SQLITE_NOMEM, lineno, "OOM");
144447143811
}
144448143812
SQLITE_PRIVATE int sqlite3IoerrnomemError(int lineno){
@@ -145198,62 +144562,10 @@
145198144562
SQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
145199144563
sqlite3_free(pSnapshot);
145200144564
}
145201144565
#endif /* SQLITE_ENABLE_SNAPSHOT */
145202144566
145203
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
145204
-/*
145205
-** Given the name of a compile-time option, return true if that option
145206
-** was used and false if not.
145207
-**
145208
-** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
145209
-** is not required for a match.
145210
-*/
145211
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
145212
- int i, n;
145213
- int nOpt;
145214
- const char **azCompileOpt;
145215
-
145216
-#if SQLITE_ENABLE_API_ARMOR
145217
- if( zOptName==0 ){
145218
- (void)SQLITE_MISUSE_BKPT;
145219
- return 0;
145220
- }
145221
-#endif
145222
-
145223
- azCompileOpt = sqlite3CompileOptions(&nOpt);
145224
-
145225
- if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
145226
- n = sqlite3Strlen30(zOptName);
145227
-
145228
- /* Since nOpt is normally in single digits, a linear search is
145229
- ** adequate. No need for a binary search. */
145230
- for(i=0; i<nOpt; i++){
145231
- if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0
145232
- && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0
145233
- ){
145234
- return 1;
145235
- }
145236
- }
145237
- return 0;
145238
-}
145239
-
145240
-/*
145241
-** Return the N-th compile-time option string. If N is out of range,
145242
-** return a NULL pointer.
145243
-*/
145244
-SQLITE_API const char *sqlite3_compileoption_get(int N){
145245
- int nOpt;
145246
- const char **azCompileOpt;
145247
- azCompileOpt = sqlite3CompileOptions(&nOpt);
145248
- if( N>=0 && N<nOpt ){
145249
- return azCompileOpt[N];
145250
- }
145251
- return 0;
145252
-}
145253
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
145254
-
145255144567
/************** End of main.c ************************************************/
145256144568
/************** Begin file notify.c ******************************************/
145257144569
/*
145258144570
** 2009 March 3
145259144571
**
@@ -148237,11 +147549,11 @@
148237147549
pCsr->pStmt = p->pSeekStmt;
148238147550
p->pSeekStmt = 0;
148239147551
}else{
148240147552
zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
148241147553
if( !zSql ) return SQLITE_NOMEM;
148242
- rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
147554
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
148243147555
sqlite3_free(zSql);
148244147556
}
148245147557
if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
148246147558
}
148247147559
return rc;
@@ -149774,11 +149086,11 @@
149774149086
zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149775149087
p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149776149088
);
149777149089
}
149778149090
if( zSql ){
149779
- rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
149091
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
149780149092
sqlite3_free(zSql);
149781149093
}else{
149782149094
rc = SQLITE_NOMEM;
149783149095
}
149784149096
}else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156981,12 +156293,11 @@
156981156293
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156982156294
}
156983156295
if( !zSql ){
156984156296
rc = SQLITE_NOMEM;
156985156297
}else{
156986
- rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
156987
- &pStmt, NULL);
156298
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);
156988156299
sqlite3_free(zSql);
156989156300
assert( rc==SQLITE_OK || pStmt==0 );
156990156301
p->aStmt[eStmt] = pStmt;
156991156302
}
156992156303
}
@@ -168092,12 +167403,11 @@
168092167403
168093167404
rc = rtreeQueryStat1(db, pRtree);
168094167405
for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
168095167406
char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
168096167407
if( zSql ){
168097
- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
168098
- appStmt[i], 0);
167408
+ rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0);
168099167409
}else{
168100167410
rc = SQLITE_NOMEM;
168101167411
}
168102167412
sqlite3_free(zSql);
168103167413
}
@@ -169855,14 +169165,14 @@
169855169165
** as fully applied. Otherwise, assuming no error has occurred, save the
169856169166
** current state of the RBU update appliation to the RBU database.
169857169167
**
169858169168
** If an error has already occurred as part of an sqlite3rbu_step()
169859169169
** or sqlite3rbu_open() call, or if one occurs within this function, an
169860
-** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,
169861
-** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted
169862
-** English language error message. It is the responsibility of the caller to
169863
-** eventually free any such buffer using sqlite3_free().
169170
+** SQLite error code is returned. Additionally, *pzErrmsg may be set to
169171
+** point to a buffer containing a utf-8 formatted English language error
169172
+** message. It is the responsibility of the caller to eventually free any
169173
+** such buffer using sqlite3_free().
169864169174
**
169865169175
** Otherwise, if no error occurs, this function returns SQLITE_OK if the
169866169176
** update has been partially applied, or SQLITE_DONE if it has been
169867169177
** completely applied.
169868169178
*/
@@ -173714,15 +173024,11 @@
173714173024
sqlite3_free(p->aBuf);
173715173025
sqlite3_free(p->aFrame);
173716173026
173717173027
rbuEditErrmsg(p);
173718173028
rc = p->rc;
173719
- if( pzErrmsg ){
173720
- *pzErrmsg = p->zErrmsg;
173721
- }else{
173722
- sqlite3_free(p->zErrmsg);
173723
- }
173029
+ *pzErrmsg = p->zErrmsg;
173724173030
sqlite3_free(p->zState);
173725173031
sqlite3_free(p);
173726173032
}else{
173727173033
rc = SQLITE_NOMEM;
173728173034
*pzErrmsg = 0;
@@ -178276,16 +177582,15 @@
178276177582
178277177583
sessionDiscardData(&p->in);
178278177584
p->in.iCurrent = p->in.iNext;
178279177585
178280177586
op = p->in.aData[p->in.iNext++];
178281
- while( op=='T' || op=='P' ){
177587
+ if( op=='T' || op=='P' ){
178282177588
p->bPatchset = (op=='P');
178283177589
if( sessionChangesetReadTblhdr(p) ) return p->rc;
178284177590
if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
178285177591
p->in.iCurrent = p->in.iNext;
178286
- if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
178287177592
op = p->in.aData[p->in.iNext++];
178288177593
}
178289177594
178290177595
p->op = op;
178291177596
p->bIndirect = p->in.aData[p->in.iNext++];
@@ -184139,16 +183444,16 @@
184139183444
** fts5yy_default[] Default action for each state.
184140183445
**
184141183446
*********** Begin parsing tables **********************************************/
184142183447
#define fts5YY_ACTTAB_COUNT (98)
184143183448
static const fts5YYACTIONTYPE fts5yy_action[] = {
184144
- /* 0 */ 105, 19, 90, 6, 26, 93, 92, 24, 24, 17,
184145
- /* 10 */ 90, 6, 26, 16, 92, 54, 24, 18, 90, 6,
184146
- /* 20 */ 26, 10, 92, 12, 24, 75, 86, 90, 6, 26,
184147
- /* 30 */ 13, 92, 75, 24, 20, 90, 6, 26, 101, 92,
184148
- /* 40 */ 56, 24, 27, 90, 6, 26, 100, 92, 21, 24,
184149
- /* 50 */ 23, 15, 30, 11, 1, 91, 22, 25, 9, 92,
183449
+ /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17,
183450
+ /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6,
183451
+ /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26,
183452
+ /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65,
183453
+ /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24,
183454
+ /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65,
184150183455
/* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
184151183456
/* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
184152183457
/* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
184153183458
/* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
184154183459
};
@@ -184249,11 +183554,10 @@
184249183554
int fts5yystksz; /* Current side of the stack */
184250183555
fts5yyStackEntry *fts5yystack; /* The parser's stack */
184251183556
fts5yyStackEntry fts5yystk0; /* First stack entry */
184252183557
#else
184253183558
fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
184254
- fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */
184255183559
#endif
184256183560
};
184257183561
typedef struct fts5yyParser fts5yyParser;
184258183562
184259183563
#ifndef NDEBUG
@@ -184399,11 +183703,10 @@
184399183703
pParser->fts5yyerrcnt = -1;
184400183704
#endif
184401183705
pParser->fts5yytos = pParser->fts5yystack;
184402183706
pParser->fts5yystack[0].stateno = 0;
184403183707
pParser->fts5yystack[0].major = 0;
184404
- pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184405183708
}
184406183709
184407183710
#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184408183711
/*
184409183712
** This function allocates a new parser.
@@ -184698,11 +184001,11 @@
184698184001
fts5yypParser->fts5yyhwm++;
184699184002
assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184700184003
}
184701184004
#endif
184702184005
#if fts5YYSTACKDEPTH>0
184703
- if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){
184006
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
184704184007
fts5yypParser->fts5yytos--;
184705184008
fts5yyStackOverflow(fts5yypParser);
184706184009
return;
184707184010
}
184708184011
#else
@@ -184726,39 +184029,39 @@
184726184029
184727184030
/* The following table contains information about every rule that
184728184031
** is used during the reduce.
184729184032
*/
184730184033
static const struct {
184731
- fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184732
- signed char nrhs; /* Negative of the number of RHS symbols in the rule */
184034
+ fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184035
+ unsigned char nrhs; /* Number of right-hand side symbols in the rule */
184733184036
} fts5yyRuleInfo[] = {
184734
- { 16, -1 },
184735
- { 20, -4 },
184736
- { 20, -3 },
184737
- { 20, -1 },
184738
- { 20, -2 },
184739
- { 21, -2 },
184740
- { 21, -1 },
184741
- { 17, -3 },
184742
- { 17, -3 },
184743
- { 17, -3 },
184744
- { 17, -5 },
184745
- { 17, -3 },
184746
- { 17, -1 },
184747
- { 19, -1 },
184748
- { 19, -2 },
184749
- { 18, -1 },
184750
- { 18, -3 },
184751
- { 22, -1 },
184752
- { 22, -5 },
184753
- { 23, -1 },
184754
- { 23, -2 },
184037
+ { 16, 1 },
184038
+ { 20, 4 },
184039
+ { 20, 3 },
184040
+ { 20, 1 },
184041
+ { 20, 2 },
184042
+ { 21, 2 },
184043
+ { 21, 1 },
184044
+ { 17, 3 },
184045
+ { 17, 3 },
184046
+ { 17, 3 },
184047
+ { 17, 5 },
184048
+ { 17, 3 },
184049
+ { 17, 1 },
184050
+ { 19, 1 },
184051
+ { 19, 2 },
184052
+ { 18, 1 },
184053
+ { 18, 3 },
184054
+ { 22, 1 },
184055
+ { 22, 5 },
184056
+ { 23, 1 },
184057
+ { 23, 2 },
184755184058
{ 25, 0 },
184756
- { 25, -2 },
184757
- { 24, -4 },
184758
- { 24, -2 },
184759
- { 26, -1 },
184059
+ { 25, 2 },
184060
+ { 24, 4 },
184061
+ { 24, 2 },
184062
+ { 26, 1 },
184760184063
{ 26, 0 },
184761184064
};
184762184065
184763184066
static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184764184067
@@ -184778,11 +184081,11 @@
184778184081
fts5yymsp = fts5yypParser->fts5yytos;
184779184082
#ifndef NDEBUG
184780184083
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184781184084
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184782184085
fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184783
- fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
184086
+ fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
184784184087
}
184785184088
#endif /* NDEBUG */
184786184089
184787184090
/* Check that the stack is large enough to grow by a single entry
184788184091
** if the RHS of the rule is empty. This ensures that there is room
@@ -184793,11 +184096,11 @@
184793184096
fts5yypParser->fts5yyhwm++;
184794184097
assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184795184098
}
184796184099
#endif
184797184100
#if fts5YYSTACKDEPTH>0
184798
- if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
184101
+ if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
184799184102
fts5yyStackOverflow(fts5yypParser);
184800184103
return;
184801184104
}
184802184105
#else
184803184106
if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184960,28 +184263,24 @@
184960184263
/********** End reduce actions ************************************************/
184961184264
};
184962184265
assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184963184266
fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184964184267
fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184965
- fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184966
-
184967
- /* There are no SHIFTREDUCE actions on nonterminals because the table
184968
- ** generator has simplified them to pure REDUCE actions. */
184969
- assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );
184970
-
184971
- /* It is not possible for a REDUCE to be followed by an error */
184972
- assert( fts5yyact!=fts5YY_ERROR_ACTION );
184973
-
184974
- if( fts5yyact==fts5YY_ACCEPT_ACTION ){
184975
- fts5yypParser->fts5yytos += fts5yysize;
184976
- fts5yy_accept(fts5yypParser);
184977
- }else{
184978
- fts5yymsp += fts5yysize+1;
184268
+ fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184269
+ if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
184270
+ if( fts5yyact>fts5YY_MAX_SHIFT ){
184271
+ fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
184272
+ }
184273
+ fts5yymsp -= fts5yysize-1;
184979184274
fts5yypParser->fts5yytos = fts5yymsp;
184980184275
fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184981184276
fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184982184277
fts5yyTraceShift(fts5yypParser, fts5yyact);
184278
+ }else{
184279
+ assert( fts5yyact == fts5YY_ACCEPT_ACTION );
184280
+ fts5yypParser->fts5yytos -= fts5yysize;
184281
+ fts5yy_accept(fts5yypParser);
184983184282
}
184984184283
}
184985184284
184986184285
/*
184987184286
** The following code executes when the parse fails
@@ -190274,15 +189573,14 @@
190274189573
if( !apNew ) return SQLITE_NOMEM;
190275189574
memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
190276189575
190277189576
for(i=0; i<pHash->nSlot; i++){
190278189577
while( apOld[i] ){
190279
- unsigned int iHash;
189578
+ int iHash;
190280189579
Fts5HashEntry *p = apOld[i];
190281189580
apOld[i] = p->pHashNext;
190282
- iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p),
190283
- (int)strlen(fts5EntryKey(p)));
189581
+ iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p)));
190284189582
p->pHashNext = apNew[iHash];
190285189583
apNew[iHash] = p;
190286189584
}
190287189585
}
190288189586
@@ -190581,11 +189879,11 @@
190581189879
const char *pTerm, int nTerm, /* Query term */
190582189880
const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
190583189881
int *pnDoclist /* OUT: Size of doclist in bytes */
190584189882
){
190585189883
unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
190586
- char *zKey = 0;
189884
+ char *zKey;
190587189885
Fts5HashEntry *p;
190588189886
190589189887
for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
190590189888
zKey = fts5EntryKey(p);
190591189889
if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
@@ -191369,12 +190667,11 @@
191369190667
sqlite3_stmt **ppStmt,
191370190668
char *zSql
191371190669
){
191372190670
if( p->rc==SQLITE_OK ){
191373190671
if( zSql ){
191374
- p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
191375
- SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
190672
+ p->rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, ppStmt, 0);
191376190673
}else{
191377190674
p->rc = SQLITE_NOMEM;
191378190675
}
191379190676
}
191380190677
sqlite3_free(zSql);
@@ -191419,12 +190716,11 @@
191419190716
pConfig->zDb, pConfig->zName
191420190717
);
191421190718
if( zSql==0 ){
191422190719
rc = SQLITE_NOMEM;
191423190720
}else{
191424
- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
191425
- SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
190721
+ rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p->pDeleter, 0);
191426190722
sqlite3_free(zSql);
191427190723
}
191428190724
if( rc!=SQLITE_OK ){
191429190725
p->rc = rc;
191430190726
return;
@@ -198019,12 +197315,11 @@
198019197315
va_start(ap, zFmt);
198020197316
zSql = sqlite3_vmprintf(zFmt, ap);
198021197317
if( zSql==0 ){
198022197318
rc = SQLITE_NOMEM;
198023197319
}else{
198024
- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198025
- SQLITE_PREPARE_PERSISTENT, &pRet, 0);
197320
+ rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0);
198026197321
if( rc!=SQLITE_OK ){
198027197322
*pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
198028197323
}
198029197324
sqlite3_free(zSql);
198030197325
}
@@ -198156,12 +197451,11 @@
198156197451
198157197452
if( zRankArgs ){
198158197453
char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
198159197454
if( zSql ){
198160197455
sqlite3_stmt *pStmt = 0;
198161
- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198162
- SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
197456
+ rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pStmt, 0);
198163197457
sqlite3_free(zSql);
198164197458
assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
198165197459
if( rc==SQLITE_OK ){
198166197460
if( SQLITE_ROW==sqlite3_step(pStmt) ){
198167197461
int nByte;
@@ -199766,11 +199060,11 @@
199766199060
int nArg, /* Number of args */
199767199061
sqlite3_value **apUnused /* Function arguments */
199768199062
){
199769199063
assert( nArg==0 );
199770199064
UNUSED_PARAM2(nArg, apUnused);
199771
- sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
199065
+ sqlite3_result_text(pCtx, "fts5: 2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b", -1, SQLITE_TRANSIENT);
199772199066
}
199773199067
199774199068
static int fts5Init(sqlite3 *db){
199775199069
static const sqlite3_module fts5Mod = {
199776199070
/* iVersion */ 2,
@@ -200020,12 +199314,11 @@
200020199314
}
200021199315
200022199316
if( zSql==0 ){
200023199317
rc = SQLITE_NOMEM;
200024199318
}else{
200025
- rc = sqlite3_prepare_v3(pC->db, zSql, -1,
200026
- SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
199319
+ rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0);
200027199320
sqlite3_free(zSql);
200028199321
if( rc!=SQLITE_OK && pzErrMsg ){
200029199322
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
200030199323
}
200031199324
}
@@ -203621,325 +202914,5 @@
203621202914
203622202915
203623202916
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
203624202917
203625202918
/************** End of fts5.c ************************************************/
203626
-/************** Begin file stmt.c ********************************************/
203627
-/*
203628
-** 2017-05-31
203629
-**
203630
-** The author disclaims copyright to this source code. In place of
203631
-** a legal notice, here is a blessing:
203632
-**
203633
-** May you do good and not evil.
203634
-** May you find forgiveness for yourself and forgive others.
203635
-** May you share freely, never taking more than you give.
203636
-**
203637
-*************************************************************************
203638
-**
203639
-** This file demonstrates an eponymous virtual table that returns information
203640
-** about all prepared statements for the database connection.
203641
-**
203642
-** Usage example:
203643
-**
203644
-** .load ./stmt
203645
-** .mode line
203646
-** .header on
203647
-** SELECT * FROM stmt;
203648
-*/
203649
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)
203650
-#if !defined(SQLITEINT_H)
203651
-/* #include "sqlite3ext.h" */
203652
-#endif
203653
-SQLITE_EXTENSION_INIT1
203654
-/* #include <assert.h> */
203655
-/* #include <string.h> */
203656
-
203657
-#ifndef SQLITE_OMIT_VIRTUALTABLE
203658
-
203659
-/*
203660
-** The following macros are used to cast pointers to integers.
203661
-** The way you do this varies from one compiler
203662
-** to the next, so we have developed the following set of #if statements
203663
-** to generate appropriate macros for a wide range of compilers.
203664
-*/
203665
-#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
203666
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
203667
-#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
203668
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
203669
-#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
203670
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
203671
-#else /* Generates a warning - but it always works */
203672
-# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
203673
-#endif
203674
-
203675
-
203676
-/* stmt_vtab is a subclass of sqlite3_vtab which will
203677
-** serve as the underlying representation of a stmt virtual table
203678
-*/
203679
-typedef struct stmt_vtab stmt_vtab;
203680
-struct stmt_vtab {
203681
- sqlite3_vtab base; /* Base class - must be first */
203682
- sqlite3 *db; /* Database connection for this stmt vtab */
203683
-};
203684
-
203685
-/* stmt_cursor is a subclass of sqlite3_vtab_cursor which will
203686
-** serve as the underlying representation of a cursor that scans
203687
-** over rows of the result
203688
-*/
203689
-typedef struct stmt_cursor stmt_cursor;
203690
-struct stmt_cursor {
203691
- sqlite3_vtab_cursor base; /* Base class - must be first */
203692
- sqlite3 *db; /* Database connection for this cursor */
203693
- sqlite3_stmt *pStmt; /* Statement cursor is currently pointing at */
203694
- sqlite3_int64 iRowid; /* The rowid */
203695
-};
203696
-
203697
-/*
203698
-** The stmtConnect() method is invoked to create a new
203699
-** stmt_vtab that describes the generate_stmt virtual table.
203700
-**
203701
-** Think of this routine as the constructor for stmt_vtab objects.
203702
-**
203703
-** All this routine needs to do is:
203704
-**
203705
-** (1) Allocate the stmt_vtab object and initialize all fields.
203706
-**
203707
-** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708
-** result set of queries against generate_stmt will look like.
203709
-*/
203710
-static int stmtConnect(
203711
- sqlite3 *db,
203712
- void *pAux,
203713
- int argc, const char *const*argv,
203714
- sqlite3_vtab **ppVtab,
203715
- char **pzErr
203716
-){
203717
- stmt_vtab *pNew;
203718
- int rc;
203719
-
203720
-/* Column numbers */
203721
-#define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
203722
-#define STMT_COLUMN_SQL 1 /* SQL for the statement */
203723
-#define STMT_COLUMN_NCOL 2 /* Number of result columns */
203724
-#define STMT_COLUMN_RO 3 /* True if read-only */
203725
-#define STMT_COLUMN_BUSY 4 /* True if currently busy */
203726
-#define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
203727
-#define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
203728
-#define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
203729
-#define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
203730
-#define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
203731
-#define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
203732
-#define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
203733
-
203734
-
203735
- rc = sqlite3_declare_vtab(db,
203736
- "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
203737
- "reprep,run,mem)");
203738
- if( rc==SQLITE_OK ){
203739
- pNew = sqlite3_malloc( sizeof(*pNew) );
203740
- *ppVtab = (sqlite3_vtab*)pNew;
203741
- if( pNew==0 ) return SQLITE_NOMEM;
203742
- memset(pNew, 0, sizeof(*pNew));
203743
- pNew->db = db;
203744
- }
203745
- return rc;
203746
-}
203747
-
203748
-/*
203749
-** This method is the destructor for stmt_cursor objects.
203750
-*/
203751
-static int stmtDisconnect(sqlite3_vtab *pVtab){
203752
- sqlite3_free(pVtab);
203753
- return SQLITE_OK;
203754
-}
203755
-
203756
-/*
203757
-** Constructor for a new stmt_cursor object.
203758
-*/
203759
-static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
203760
- stmt_cursor *pCur;
203761
- pCur = sqlite3_malloc( sizeof(*pCur) );
203762
- if( pCur==0 ) return SQLITE_NOMEM;
203763
- memset(pCur, 0, sizeof(*pCur));
203764
- pCur->db = ((stmt_vtab*)p)->db;
203765
- *ppCursor = &pCur->base;
203766
- return SQLITE_OK;
203767
-}
203768
-
203769
-/*
203770
-** Destructor for a stmt_cursor.
203771
-*/
203772
-static int stmtClose(sqlite3_vtab_cursor *cur){
203773
- sqlite3_free(cur);
203774
- return SQLITE_OK;
203775
-}
203776
-
203777
-
203778
-/*
203779
-** Advance a stmt_cursor to its next row of output.
203780
-*/
203781
-static int stmtNext(sqlite3_vtab_cursor *cur){
203782
- stmt_cursor *pCur = (stmt_cursor*)cur;
203783
- pCur->iRowid++;
203784
- pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);
203785
- return SQLITE_OK;
203786
-}
203787
-
203788
-/*
203789
-** Return values of columns for the row at which the stmt_cursor
203790
-** is currently pointing.
203791
-*/
203792
-static int stmtColumn(
203793
- sqlite3_vtab_cursor *cur, /* The cursor */
203794
- sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
203795
- int i /* Which column to return */
203796
-){
203797
- stmt_cursor *pCur = (stmt_cursor*)cur;
203798
- switch( i ){
203799
- case STMT_COLUMN_PTR: {
203800
- sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
203801
- break;
203802
- }
203803
- case STMT_COLUMN_SQL: {
203804
- sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
203805
- break;
203806
- }
203807
- case STMT_COLUMN_NCOL: {
203808
- sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));
203809
- break;
203810
- }
203811
- case STMT_COLUMN_RO: {
203812
- sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));
203813
- break;
203814
- }
203815
- case STMT_COLUMN_BUSY: {
203816
- sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
203817
- break;
203818
- }
203819
- case STMT_COLUMN_MEM: {
203820
- i = SQLITE_STMTSTATUS_MEMUSED +
203821
- STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
203822
- /* Fall thru */
203823
- }
203824
- case STMT_COLUMN_NSCAN:
203825
- case STMT_COLUMN_NSORT:
203826
- case STMT_COLUMN_NAIDX:
203827
- case STMT_COLUMN_NSTEP:
203828
- case STMT_COLUMN_REPREP:
203829
- case STMT_COLUMN_RUN: {
203830
- sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
203831
- i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
203832
- break;
203833
- }
203834
- }
203835
- return SQLITE_OK;
203836
-}
203837
-
203838
-/*
203839
-** Return the rowid for the current row. In this implementation, the
203840
-** rowid is the same as the output value.
203841
-*/
203842
-static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
203843
- stmt_cursor *pCur = (stmt_cursor*)cur;
203844
- *pRowid = pCur->iRowid;
203845
- return SQLITE_OK;
203846
-}
203847
-
203848
-/*
203849
-** Return TRUE if the cursor has been moved off of the last
203850
-** row of output.
203851
-*/
203852
-static int stmtEof(sqlite3_vtab_cursor *cur){
203853
- stmt_cursor *pCur = (stmt_cursor*)cur;
203854
- return pCur->pStmt==0;
203855
-}
203856
-
203857
-/*
203858
-** This method is called to "rewind" the stmt_cursor object back
203859
-** to the first row of output. This method is always called at least
203860
-** once prior to any call to stmtColumn() or stmtRowid() or
203861
-** stmtEof().
203862
-*/
203863
-static int stmtFilter(
203864
- sqlite3_vtab_cursor *pVtabCursor,
203865
- int idxNum, const char *idxStr,
203866
- int argc, sqlite3_value **argv
203867
-){
203868
- stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;
203869
- pCur->pStmt = 0;
203870
- pCur->iRowid = 0;
203871
- return stmtNext(pVtabCursor);
203872
-}
203873
-
203874
-/*
203875
-** SQLite will invoke this method one or more times while planning a query
203876
-** that uses the generate_stmt virtual table. This routine needs to create
203877
-** a query plan for each invocation and compute an estimated cost for that
203878
-** plan.
203879
-*/
203880
-static int stmtBestIndex(
203881
- sqlite3_vtab *tab,
203882
- sqlite3_index_info *pIdxInfo
203883
-){
203884
- pIdxInfo->estimatedCost = (double)500;
203885
- pIdxInfo->estimatedRows = 500;
203886
- return SQLITE_OK;
203887
-}
203888
-
203889
-/*
203890
-** This following structure defines all the methods for the
203891
-** generate_stmt virtual table.
203892
-*/
203893
-static sqlite3_module stmtModule = {
203894
- 0, /* iVersion */
203895
- 0, /* xCreate */
203896
- stmtConnect, /* xConnect */
203897
- stmtBestIndex, /* xBestIndex */
203898
- stmtDisconnect, /* xDisconnect */
203899
- 0, /* xDestroy */
203900
- stmtOpen, /* xOpen - open a cursor */
203901
- stmtClose, /* xClose - close a cursor */
203902
- stmtFilter, /* xFilter - configure scan constraints */
203903
- stmtNext, /* xNext - advance a cursor */
203904
- stmtEof, /* xEof - check for end of scan */
203905
- stmtColumn, /* xColumn - read data */
203906
- stmtRowid, /* xRowid - read data */
203907
- 0, /* xUpdate */
203908
- 0, /* xBegin */
203909
- 0, /* xSync */
203910
- 0, /* xCommit */
203911
- 0, /* xRollback */
203912
- 0, /* xFindMethod */
203913
- 0, /* xRename */
203914
-};
203915
-
203916
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
203917
-
203918
-SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
203919
- int rc = SQLITE_OK;
203920
-#ifndef SQLITE_OMIT_VIRTUALTABLE
203921
- rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
203922
-#endif
203923
- return rc;
203924
-}
203925
-
203926
-#ifndef SQLITE_CORE
203927
-#ifdef _WIN32
203928
-__declspec(dllexport)
203929
-#endif
203930
-SQLITE_API int sqlite3_stmt_init(
203931
- sqlite3 *db,
203932
- char **pzErrMsg,
203933
- const sqlite3_api_routines *pApi
203934
-){
203935
- int rc = SQLITE_OK;
203936
- SQLITE_EXTENSION_INIT2(pApi);
203937
-#ifndef SQLITE_OMIT_VIRTUALTABLE
203938
- rc = sqlite3StmtVtabInit(db);
203939
-#endif
203940
- return rc;
203941
-}
203942
-#endif /* SQLITE_CORE */
203943
-#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
203944
-
203945
-/************** End of stmt.c ************************************************/
203946202919
--- 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.20.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.
@@ -20,762 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
25 /************** Begin file ctime.c *******************************************/
26 /*
27 ** 2010 February 23
28 **
29 ** The author disclaims copyright to this source code. In place of
30 ** a legal notice, here is a blessing:
31 **
32 ** May you do good and not evil.
33 ** May you find forgiveness for yourself and forgive others.
34 ** May you share freely, never taking more than you give.
35 **
36 *************************************************************************
37 **
38 ** This file implements routines used to report what compile-time options
39 ** SQLite was built with.
40 */
41
42 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
43
44 /*
45 ** Include the configuration header output by 'configure' if we're using the
46 ** autoconf-based build
47 */
48 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49 #include "config.h"
50 #define SQLITECONFIG_H 1
51 #endif
52
53 /* These macros are provided to "stringify" the value of the define
54 ** for those options in which the value is meaningful. */
55 #define CTIMEOPT_VAL_(opt) #opt
56 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
58 /*
59 ** An array of names of all compile-time options. This array should
60 ** be sorted A-Z.
61 **
62 ** This array looks large, but in a typical installation actually uses
63 ** only a handful of compile-time options, so most times this array is usually
64 ** rather short and uses little memory space.
65 */
66 static const char * const sqlite3azCompileOpt[] = {
67
68 /*
69 ** BEGIN CODE GENERATED BY tool/mkctime.tcl
70 */
71 #if SQLITE_32BIT_ROWID
72 "32BIT_ROWID",
73 #endif
74 #if SQLITE_4_BYTE_ALIGNED_MALLOC
75 "4_BYTE_ALIGNED_MALLOC",
76 #endif
77 #if SQLITE_64BIT_STATS
78 "64BIT_STATS",
79 #endif
80 #if SQLITE_ALLOW_COVERING_INDEX_SCAN
81 "ALLOW_COVERING_INDEX_SCAN",
82 #endif
83 #if SQLITE_ALLOW_URI_AUTHORITY
84 "ALLOW_URI_AUTHORITY",
85 #endif
86 #ifdef SQLITE_BITMASK_TYPE
87 "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
88 #endif
89 #if SQLITE_BUG_COMPATIBLE_20160819
90 "BUG_COMPATIBLE_20160819",
91 #endif
92 #if SQLITE_CASE_SENSITIVE_LIKE
93 "CASE_SENSITIVE_LIKE",
94 #endif
95 #if SQLITE_CHECK_PAGES
96 "CHECK_PAGES",
97 #endif
98 #if defined(__clang__) && defined(__clang_major__)
99 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
100 CTIMEOPT_VAL(__clang_minor__) "."
101 CTIMEOPT_VAL(__clang_patchlevel__),
102 #elif defined(_MSC_VER)
103 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
104 #elif defined(__GNUC__) && defined(__VERSION__)
105 "COMPILER=gcc-" __VERSION__,
106 #endif
107 #if SQLITE_COVERAGE_TEST
108 "COVERAGE_TEST",
109 #endif
110 #if SQLITE_DEBUG
111 "DEBUG",
112 #endif
113 #if SQLITE_DEFAULT_AUTOMATIC_INDEX
114 "DEFAULT_AUTOMATIC_INDEX",
115 #endif
116 #if SQLITE_DEFAULT_AUTOVACUUM
117 "DEFAULT_AUTOVACUUM",
118 #endif
119 #ifdef SQLITE_DEFAULT_CACHE_SIZE
120 "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
121 #endif
122 #if SQLITE_DEFAULT_CKPTFULLFSYNC
123 "DEFAULT_CKPTFULLFSYNC",
124 #endif
125 #ifdef SQLITE_DEFAULT_FILE_FORMAT
126 "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
127 #endif
128 #ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
129 "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
130 #endif
131 #if SQLITE_DEFAULT_FOREIGN_KEYS
132 "DEFAULT_FOREIGN_KEYS",
133 #endif
134 #ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
135 "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
136 #endif
137 #ifdef SQLITE_DEFAULT_LOCKING_MODE
138 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
139 #endif
140 #ifdef SQLITE_DEFAULT_LOOKASIDE
141 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),
142 #endif
143 #if SQLITE_DEFAULT_MEMSTATUS
144 "DEFAULT_MEMSTATUS",
145 #endif
146 #ifdef SQLITE_DEFAULT_MMAP_SIZE
147 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
148 #endif
149 #ifdef SQLITE_DEFAULT_PAGE_SIZE
150 "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
151 #endif
152 #ifdef SQLITE_DEFAULT_PCACHE_INITSZ
153 "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
154 #endif
155 #ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
156 "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
157 #endif
158 #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
159 "DEFAULT_RECURSIVE_TRIGGERS",
160 #endif
161 #ifdef SQLITE_DEFAULT_ROWEST
162 "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
163 #endif
164 #ifdef SQLITE_DEFAULT_SECTOR_SIZE
165 "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
166 #endif
167 #ifdef SQLITE_DEFAULT_SYNCHRONOUS
168 "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
169 #endif
170 #ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
171 "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
172 #endif
173 #ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
174 "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
175 #endif
176 #ifdef SQLITE_DEFAULT_WORKER_THREADS
177 "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
178 #endif
179 #if SQLITE_DIRECT_OVERFLOW_READ
180 "DIRECT_OVERFLOW_READ",
181 #endif
182 #if SQLITE_DISABLE_DIRSYNC
183 "DISABLE_DIRSYNC",
184 #endif
185 #if SQLITE_DISABLE_FTS3_UNICODE
186 "DISABLE_FTS3_UNICODE",
187 #endif
188 #if SQLITE_DISABLE_FTS4_DEFERRED
189 "DISABLE_FTS4_DEFERRED",
190 #endif
191 #if SQLITE_DISABLE_INTRINSIC
192 "DISABLE_INTRINSIC",
193 #endif
194 #if SQLITE_DISABLE_LFS
195 "DISABLE_LFS",
196 #endif
197 #if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
198 "DISABLE_PAGECACHE_OVERFLOW_STATS",
199 #endif
200 #if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
201 "DISABLE_SKIPAHEAD_DISTINCT",
202 #endif
203 #ifdef SQLITE_ENABLE_8_3_NAMES
204 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
205 #endif
206 #if SQLITE_ENABLE_API_ARMOR
207 "ENABLE_API_ARMOR",
208 #endif
209 #if SQLITE_ENABLE_ATOMIC_WRITE
210 "ENABLE_ATOMIC_WRITE",
211 #endif
212 #if SQLITE_ENABLE_CEROD
213 "ENABLE_CEROD",
214 #endif
215 #if SQLITE_ENABLE_COLUMN_METADATA
216 "ENABLE_COLUMN_METADATA",
217 #endif
218 #if SQLITE_ENABLE_COLUMN_USED_MASK
219 "ENABLE_COLUMN_USED_MASK",
220 #endif
221 #if SQLITE_ENABLE_COSTMULT
222 "ENABLE_COSTMULT",
223 #endif
224 #if SQLITE_ENABLE_CURSOR_HINTS
225 "ENABLE_CURSOR_HINTS",
226 #endif
227 #if SQLITE_ENABLE_DBSTAT_VTAB
228 "ENABLE_DBSTAT_VTAB",
229 #endif
230 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
231 "ENABLE_EXPENSIVE_ASSERT",
232 #endif
233 #if SQLITE_ENABLE_FTS1
234 "ENABLE_FTS1",
235 #endif
236 #if SQLITE_ENABLE_FTS2
237 "ENABLE_FTS2",
238 #endif
239 #if SQLITE_ENABLE_FTS3
240 "ENABLE_FTS3",
241 #endif
242 #if SQLITE_ENABLE_FTS3_PARENTHESIS
243 "ENABLE_FTS3_PARENTHESIS",
244 #endif
245 #if SQLITE_ENABLE_FTS3_TOKENIZER
246 "ENABLE_FTS3_TOKENIZER",
247 #endif
248 #if SQLITE_ENABLE_FTS4
249 "ENABLE_FTS4",
250 #endif
251 #if SQLITE_ENABLE_FTS5
252 "ENABLE_FTS5",
253 #endif
254 #if SQLITE_ENABLE_HIDDEN_COLUMNS
255 "ENABLE_HIDDEN_COLUMNS",
256 #endif
257 #if SQLITE_ENABLE_ICU
258 "ENABLE_ICU",
259 #endif
260 #if SQLITE_ENABLE_IOTRACE
261 "ENABLE_IOTRACE",
262 #endif
263 #if SQLITE_ENABLE_JSON1
264 "ENABLE_JSON1",
265 #endif
266 #if SQLITE_ENABLE_LOAD_EXTENSION
267 "ENABLE_LOAD_EXTENSION",
268 #endif
269 #ifdef SQLITE_ENABLE_LOCKING_STYLE
270 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
271 #endif
272 #if SQLITE_ENABLE_MEMORY_MANAGEMENT
273 "ENABLE_MEMORY_MANAGEMENT",
274 #endif
275 #if SQLITE_ENABLE_MEMSYS3
276 "ENABLE_MEMSYS3",
277 #endif
278 #if SQLITE_ENABLE_MEMSYS5
279 "ENABLE_MEMSYS5",
280 #endif
281 #if SQLITE_ENABLE_MULTIPLEX
282 "ENABLE_MULTIPLEX",
283 #endif
284 #if SQLITE_ENABLE_NULL_TRIM
285 "ENABLE_NULL_TRIM",
286 #endif
287 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
288 "ENABLE_OVERSIZE_CELL_CHECK",
289 #endif
290 #if SQLITE_ENABLE_PREUPDATE_HOOK
291 "ENABLE_PREUPDATE_HOOK",
292 #endif
293 #if SQLITE_ENABLE_QPSG
294 "ENABLE_QPSG",
295 #endif
296 #if SQLITE_ENABLE_RBU
297 "ENABLE_RBU",
298 #endif
299 #if SQLITE_ENABLE_RTREE
300 "ENABLE_RTREE",
301 #endif
302 #if SQLITE_ENABLE_SELECTTRACE
303 "ENABLE_SELECTTRACE",
304 #endif
305 #if SQLITE_ENABLE_SESSION
306 "ENABLE_SESSION",
307 #endif
308 #if SQLITE_ENABLE_SNAPSHOT
309 "ENABLE_SNAPSHOT",
310 #endif
311 #if SQLITE_ENABLE_SQLLOG
312 "ENABLE_SQLLOG",
313 #endif
314 #if defined(SQLITE_ENABLE_STAT4)
315 "ENABLE_STAT4",
316 #elif defined(SQLITE_ENABLE_STAT3)
317 "ENABLE_STAT3",
318 #endif
319 #if SQLITE_ENABLE_STMTVTAB
320 "ENABLE_STMTVTAB",
321 #endif
322 #if SQLITE_ENABLE_STMT_SCANSTATUS
323 "ENABLE_STMT_SCANSTATUS",
324 #endif
325 #if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
326 "ENABLE_UNKNOWN_SQL_FUNCTION",
327 #endif
328 #if SQLITE_ENABLE_UNLOCK_NOTIFY
329 "ENABLE_UNLOCK_NOTIFY",
330 #endif
331 #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
332 "ENABLE_UPDATE_DELETE_LIMIT",
333 #endif
334 #if SQLITE_ENABLE_URI_00_ERROR
335 "ENABLE_URI_00_ERROR",
336 #endif
337 #if SQLITE_ENABLE_VFSTRACE
338 "ENABLE_VFSTRACE",
339 #endif
340 #if SQLITE_ENABLE_WHERETRACE
341 "ENABLE_WHERETRACE",
342 #endif
343 #if SQLITE_ENABLE_ZIPVFS
344 "ENABLE_ZIPVFS",
345 #endif
346 #if SQLITE_EXPLAIN_ESTIMATED_ROWS
347 "EXPLAIN_ESTIMATED_ROWS",
348 #endif
349 #if SQLITE_EXTRA_IFNULLROW
350 "EXTRA_IFNULLROW",
351 #endif
352 #ifdef SQLITE_EXTRA_INIT
353 "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
354 #endif
355 #ifdef SQLITE_EXTRA_SHUTDOWN
356 "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
357 #endif
358 #ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
359 "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
360 #endif
361 #if SQLITE_FTS5_ENABLE_TEST_MI
362 "FTS5_ENABLE_TEST_MI",
363 #endif
364 #if SQLITE_FTS5_NO_WITHOUT_ROWID
365 "FTS5_NO_WITHOUT_ROWID",
366 #endif
367 #if SQLITE_HAS_CODEC
368 "HAS_CODEC",
369 #endif
370 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
371 "HAVE_ISNAN",
372 #endif
373 #if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
374 "HOMEGROWN_RECURSIVE_MUTEX",
375 #endif
376 #if SQLITE_IGNORE_AFP_LOCK_ERRORS
377 "IGNORE_AFP_LOCK_ERRORS",
378 #endif
379 #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
380 "IGNORE_FLOCK_LOCK_ERRORS",
381 #endif
382 #if SQLITE_INLINE_MEMCPY
383 "INLINE_MEMCPY",
384 #endif
385 #if SQLITE_INT64_TYPE
386 "INT64_TYPE",
387 #endif
388 #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
389 "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
390 #endif
391 #if SQLITE_LIKE_DOESNT_MATCH_BLOBS
392 "LIKE_DOESNT_MATCH_BLOBS",
393 #endif
394 #if SQLITE_LOCK_TRACE
395 "LOCK_TRACE",
396 #endif
397 #if SQLITE_LOG_CACHE_SPILL
398 "LOG_CACHE_SPILL",
399 #endif
400 #ifdef SQLITE_MALLOC_SOFT_LIMIT
401 "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
402 #endif
403 #ifdef SQLITE_MAX_ATTACHED
404 "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
405 #endif
406 #ifdef SQLITE_MAX_COLUMN
407 "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
408 #endif
409 #ifdef SQLITE_MAX_COMPOUND_SELECT
410 "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
411 #endif
412 #ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
413 "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
414 #endif
415 #ifdef SQLITE_MAX_EXPR_DEPTH
416 "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
417 #endif
418 #ifdef SQLITE_MAX_FUNCTION_ARG
419 "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
420 #endif
421 #ifdef SQLITE_MAX_LENGTH
422 "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
423 #endif
424 #ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
425 "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
426 #endif
427 #ifdef SQLITE_MAX_MEMORY
428 "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
429 #endif
430 #ifdef SQLITE_MAX_MMAP_SIZE
431 "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
432 #endif
433 #ifdef SQLITE_MAX_MMAP_SIZE_
434 "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
435 #endif
436 #ifdef SQLITE_MAX_PAGE_COUNT
437 "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
438 #endif
439 #ifdef SQLITE_MAX_PAGE_SIZE
440 "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
441 #endif
442 #ifdef SQLITE_MAX_SCHEMA_RETRY
443 "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
444 #endif
445 #ifdef SQLITE_MAX_SQL_LENGTH
446 "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
447 #endif
448 #ifdef SQLITE_MAX_TRIGGER_DEPTH
449 "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
450 #endif
451 #ifdef SQLITE_MAX_VARIABLE_NUMBER
452 "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
453 #endif
454 #ifdef SQLITE_MAX_VDBE_OP
455 "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
456 #endif
457 #ifdef SQLITE_MAX_WORKER_THREADS
458 "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
459 #endif
460 #if SQLITE_MEMDEBUG
461 "MEMDEBUG",
462 #endif
463 #if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
464 "MIXED_ENDIAN_64BIT_FLOAT",
465 #endif
466 #if SQLITE_MMAP_READWRITE
467 "MMAP_READWRITE",
468 #endif
469 #if SQLITE_MUTEX_NOOP
470 "MUTEX_NOOP",
471 #endif
472 #if SQLITE_MUTEX_NREF
473 "MUTEX_NREF",
474 #endif
475 #if SQLITE_MUTEX_OMIT
476 "MUTEX_OMIT",
477 #endif
478 #if SQLITE_MUTEX_PTHREADS
479 "MUTEX_PTHREADS",
480 #endif
481 #if SQLITE_MUTEX_W32
482 "MUTEX_W32",
483 #endif
484 #if SQLITE_NEED_ERR_NAME
485 "NEED_ERR_NAME",
486 #endif
487 #if SQLITE_NOINLINE
488 "NOINLINE",
489 #endif
490 #if SQLITE_NO_SYNC
491 "NO_SYNC",
492 #endif
493 #if SQLITE_OMIT_ALTERTABLE
494 "OMIT_ALTERTABLE",
495 #endif
496 #if SQLITE_OMIT_ANALYZE
497 "OMIT_ANALYZE",
498 #endif
499 #if SQLITE_OMIT_ATTACH
500 "OMIT_ATTACH",
501 #endif
502 #if SQLITE_OMIT_AUTHORIZATION
503 "OMIT_AUTHORIZATION",
504 #endif
505 #if SQLITE_OMIT_AUTOINCREMENT
506 "OMIT_AUTOINCREMENT",
507 #endif
508 #if SQLITE_OMIT_AUTOINIT
509 "OMIT_AUTOINIT",
510 #endif
511 #if SQLITE_OMIT_AUTOMATIC_INDEX
512 "OMIT_AUTOMATIC_INDEX",
513 #endif
514 #if SQLITE_OMIT_AUTORESET
515 "OMIT_AUTORESET",
516 #endif
517 #if SQLITE_OMIT_AUTOVACUUM
518 "OMIT_AUTOVACUUM",
519 #endif
520 #if SQLITE_OMIT_BETWEEN_OPTIMIZATION
521 "OMIT_BETWEEN_OPTIMIZATION",
522 #endif
523 #if SQLITE_OMIT_BLOB_LITERAL
524 "OMIT_BLOB_LITERAL",
525 #endif
526 #if SQLITE_OMIT_BTREECOUNT
527 "OMIT_BTREECOUNT",
528 #endif
529 #if SQLITE_OMIT_CAST
530 "OMIT_CAST",
531 #endif
532 #if SQLITE_OMIT_CHECK
533 "OMIT_CHECK",
534 #endif
535 #if SQLITE_OMIT_COMPLETE
536 "OMIT_COMPLETE",
537 #endif
538 #if SQLITE_OMIT_COMPOUND_SELECT
539 "OMIT_COMPOUND_SELECT",
540 #endif
541 #if SQLITE_OMIT_CONFLICT_CLAUSE
542 "OMIT_CONFLICT_CLAUSE",
543 #endif
544 #if SQLITE_OMIT_CTE
545 "OMIT_CTE",
546 #endif
547 #if SQLITE_OMIT_DATETIME_FUNCS
548 "OMIT_DATETIME_FUNCS",
549 #endif
550 #if SQLITE_OMIT_DECLTYPE
551 "OMIT_DECLTYPE",
552 #endif
553 #if SQLITE_OMIT_DEPRECATED
554 "OMIT_DEPRECATED",
555 #endif
556 #if SQLITE_OMIT_DISKIO
557 "OMIT_DISKIO",
558 #endif
559 #if SQLITE_OMIT_EXPLAIN
560 "OMIT_EXPLAIN",
561 #endif
562 #if SQLITE_OMIT_FLAG_PRAGMAS
563 "OMIT_FLAG_PRAGMAS",
564 #endif
565 #if SQLITE_OMIT_FLOATING_POINT
566 "OMIT_FLOATING_POINT",
567 #endif
568 #if SQLITE_OMIT_FOREIGN_KEY
569 "OMIT_FOREIGN_KEY",
570 #endif
571 #if SQLITE_OMIT_GET_TABLE
572 "OMIT_GET_TABLE",
573 #endif
574 #if SQLITE_OMIT_HEX_INTEGER
575 "OMIT_HEX_INTEGER",
576 #endif
577 #if SQLITE_OMIT_INCRBLOB
578 "OMIT_INCRBLOB",
579 #endif
580 #if SQLITE_OMIT_INTEGRITY_CHECK
581 "OMIT_INTEGRITY_CHECK",
582 #endif
583 #if SQLITE_OMIT_LIKE_OPTIMIZATION
584 "OMIT_LIKE_OPTIMIZATION",
585 #endif
586 #if SQLITE_OMIT_LOAD_EXTENSION
587 "OMIT_LOAD_EXTENSION",
588 #endif
589 #if SQLITE_OMIT_LOCALTIME
590 "OMIT_LOCALTIME",
591 #endif
592 #if SQLITE_OMIT_LOOKASIDE
593 "OMIT_LOOKASIDE",
594 #endif
595 #if SQLITE_OMIT_MEMORYDB
596 "OMIT_MEMORYDB",
597 #endif
598 #if SQLITE_OMIT_OR_OPTIMIZATION
599 "OMIT_OR_OPTIMIZATION",
600 #endif
601 #if SQLITE_OMIT_PAGER_PRAGMAS
602 "OMIT_PAGER_PRAGMAS",
603 #endif
604 #if SQLITE_OMIT_PARSER_TRACE
605 "OMIT_PARSER_TRACE",
606 #endif
607 #if SQLITE_OMIT_POPEN
608 "OMIT_POPEN",
609 #endif
610 #if SQLITE_OMIT_PRAGMA
611 "OMIT_PRAGMA",
612 #endif
613 #if SQLITE_OMIT_PROGRESS_CALLBACK
614 "OMIT_PROGRESS_CALLBACK",
615 #endif
616 #if SQLITE_OMIT_QUICKBALANCE
617 "OMIT_QUICKBALANCE",
618 #endif
619 #if SQLITE_OMIT_REINDEX
620 "OMIT_REINDEX",
621 #endif
622 #if SQLITE_OMIT_SCHEMA_PRAGMAS
623 "OMIT_SCHEMA_PRAGMAS",
624 #endif
625 #if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
626 "OMIT_SCHEMA_VERSION_PRAGMAS",
627 #endif
628 #if SQLITE_OMIT_SHARED_CACHE
629 "OMIT_SHARED_CACHE",
630 #endif
631 #if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
632 "OMIT_SHUTDOWN_DIRECTORIES",
633 #endif
634 #if SQLITE_OMIT_SUBQUERY
635 "OMIT_SUBQUERY",
636 #endif
637 #if SQLITE_OMIT_TCL_VARIABLE
638 "OMIT_TCL_VARIABLE",
639 #endif
640 #if SQLITE_OMIT_TEMPDB
641 "OMIT_TEMPDB",
642 #endif
643 #if SQLITE_OMIT_TEST_CONTROL
644 "OMIT_TEST_CONTROL",
645 #endif
646 #if SQLITE_OMIT_TRACE
647 "OMIT_TRACE",
648 #endif
649 #if SQLITE_OMIT_TRIGGER
650 "OMIT_TRIGGER",
651 #endif
652 #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
653 "OMIT_TRUNCATE_OPTIMIZATION",
654 #endif
655 #if SQLITE_OMIT_UTF16
656 "OMIT_UTF16",
657 #endif
658 #if SQLITE_OMIT_VACUUM
659 "OMIT_VACUUM",
660 #endif
661 #if SQLITE_OMIT_VIEW
662 "OMIT_VIEW",
663 #endif
664 #if SQLITE_OMIT_VIRTUALTABLE
665 "OMIT_VIRTUALTABLE",
666 #endif
667 #if SQLITE_OMIT_WAL
668 "OMIT_WAL",
669 #endif
670 #if SQLITE_OMIT_WSD
671 "OMIT_WSD",
672 #endif
673 #if SQLITE_OMIT_XFER_OPT
674 "OMIT_XFER_OPT",
675 #endif
676 #if SQLITE_PCACHE_SEPARATE_HEADER
677 "PCACHE_SEPARATE_HEADER",
678 #endif
679 #if SQLITE_PERFORMANCE_TRACE
680 "PERFORMANCE_TRACE",
681 #endif
682 #if SQLITE_POWERSAFE_OVERWRITE
683 "POWERSAFE_OVERWRITE",
684 #endif
685 #if SQLITE_PREFER_PROXY_LOCKING
686 "PREFER_PROXY_LOCKING",
687 #endif
688 #if SQLITE_PROXY_DEBUG
689 "PROXY_DEBUG",
690 #endif
691 #if SQLITE_REVERSE_UNORDERED_SELECTS
692 "REVERSE_UNORDERED_SELECTS",
693 #endif
694 #if SQLITE_RTREE_INT_ONLY
695 "RTREE_INT_ONLY",
696 #endif
697 #if SQLITE_SECURE_DELETE
698 "SECURE_DELETE",
699 #endif
700 #if SQLITE_SMALL_STACK
701 "SMALL_STACK",
702 #endif
703 #ifdef SQLITE_SORTER_PMASZ
704 "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
705 #endif
706 #if SQLITE_SOUNDEX
707 "SOUNDEX",
708 #endif
709 #ifdef SQLITE_STAT4_SAMPLES
710 "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
711 #endif
712 #ifdef SQLITE_STMTJRNL_SPILL
713 "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
714 #endif
715 #if SQLITE_SUBSTR_COMPATIBILITY
716 "SUBSTR_COMPATIBILITY",
717 #endif
718 #if SQLITE_SYSTEM_MALLOC
719 "SYSTEM_MALLOC",
720 #endif
721 #if SQLITE_TCL
722 "TCL",
723 #endif
724 #ifdef SQLITE_TEMP_STORE
725 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
726 #endif
727 #if SQLITE_TEST
728 "TEST",
729 #endif
730 #if defined(SQLITE_THREADSAFE)
731 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
732 #elif defined(THREADSAFE)
733 "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
734 #else
735 "THREADSAFE=1",
736 #endif
737 #if SQLITE_UNLINK_AFTER_CLOSE
738 "UNLINK_AFTER_CLOSE",
739 #endif
740 #if SQLITE_UNTESTABLE
741 "UNTESTABLE",
742 #endif
743 #if SQLITE_USER_AUTHENTICATION
744 "USER_AUTHENTICATION",
745 #endif
746 #if SQLITE_USE_ALLOCA
747 "USE_ALLOCA",
748 #endif
749 #if SQLITE_USE_FCNTL_TRACE
750 "USE_FCNTL_TRACE",
751 #endif
752 #if SQLITE_USE_URI
753 "USE_URI",
754 #endif
755 #if SQLITE_VDBE_COVERAGE
756 "VDBE_COVERAGE",
757 #endif
758 #if SQLITE_WIN32_MALLOC
759 "WIN32_MALLOC",
760 #endif
761 #if SQLITE_ZERO_MALLOC
762 "ZERO_MALLOC",
763 #endif
764 /*
765 ** END CODE GENERATED BY tool/mkctime.tcl
766 */
767 };
768
769 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
770 *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
771 return (const char**)sqlite3azCompileOpt;
772 }
773
774 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
775
776 /************** End of ctime.c ***********************************************/
777 /************** Begin file sqliteInt.h ***************************************/
778 /*
779 ** 2001 September 15
780 **
781 ** The author disclaims copyright to this source code. In place of
@@ -1026,11 +274,11 @@
1026 ** MinGW.
1027 */
1028 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
1029 /************** Begin file sqlite3.h *****************************************/
1030 /*
1031 ** 2001-09-15
1032 **
1033 ** The author disclaims copyright to this source code. In place of
1034 ** a legal notice, here is a blessing:
1035 **
1036 ** May you do good and not evil.
@@ -1148,13 +396,13 @@
1148 **
1149 ** See also: [sqlite3_libversion()],
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1262,11 +510,11 @@
1262 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
1263 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1264 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
1265 ** and [sqlite3_close_v2()] are its destructors. There are many other
1266 ** interfaces (such as
1267 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
1268 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
1269 ** sqlite3 object.
1270 */
1271 typedef struct sqlite3 sqlite3;
1272
@@ -1366,11 +614,11 @@
1366 /*
1367 ** CAPI3REF: One-Step Query Execution Interface
1368 ** METHOD: sqlite3
1369 **
1370 ** The sqlite3_exec() interface is a convenience wrapper around
1371 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
1372 ** that allows an application to run multiple statements of SQL
1373 ** without having to use a lot of C code.
1374 **
1375 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
1376 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3034,31 +2282,19 @@
3034 ** default) to enable them. The second parameter is a pointer to an integer
3035 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3036 ** have been disabled - 0 if they are not disabled, 1 if they are.
3037 ** </dd>
3038 **
3039 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3040 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3041 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3042 ** a single SQL query statement will always use the same algorithm regardless
3043 ** of values of [bound parameters]. The QPSG disables some query optimizations
3044 ** that look at the values of bound parameters, which can make some queries
3045 ** slower. But the QPSG has the advantage of more predictable behavior. With
3046 ** the QPSG active, SQLite will always use the same query plan in the field as
3047 ** was used during testing in the lab.
3048 ** </dd>
3049 **
3050 ** </dl>
3051 */
3052 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3053 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3054 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
3055 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
3056 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
3057 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
3058 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3059 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3060
3061
3062 /*
3063 ** CAPI3REF: Enable Or Disable Extended Result Codes
3064 ** METHOD: sqlite3
@@ -3718,26 +2954,25 @@
3718 **
3719 ** ^This routine registers an authorizer callback with a particular
3720 ** [database connection], supplied in the first argument.
3721 ** ^The authorizer callback is invoked as SQL statements are being compiled
3722 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
3723 ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
3724 ** and [sqlite3_prepare16_v3()]. ^At various
3725 ** points during the compilation process, as logic is being created
3726 ** to perform various actions, the authorizer callback is invoked to
3727 ** see if those actions are allowed. ^The authorizer callback should
3728 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
3729 ** specific action but allow the SQL statement to continue to be
3730 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
3731 ** rejected with an error. ^If the authorizer callback returns
3732 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
3733 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
3734 ** the authorizer will fail with an error message.
3735 **
3736 ** When the callback returns [SQLITE_OK], that means the operation
3737 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
3738 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
3739 ** authorizer will fail with an error message explaining that
3740 ** access is denied.
3741 **
3742 ** ^The first parameter to the authorizer callback is a copy of the third
3743 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3019,23 @@
3784 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3785 ** The authorizer is disabled by default.
3786 **
3787 ** The authorizer callback must not do anything that will modify
3788 ** the database connection that invoked the authorizer callback.
3789 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3790 ** database connections for the meaning of "modify" in this paragraph.
3791 **
3792 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
3793 ** statement might be re-prepared during [sqlite3_step()] due to a
3794 ** schema change. Hence, the application should ensure that the
3795 ** correct authorizer callback remains in place during the [sqlite3_step()].
3796 **
3797 ** ^Note that the authorizer callback is invoked only during
3798 ** [sqlite3_prepare()] or its variants. Authorization is not
3799 ** performed during statement evaluation in [sqlite3_step()], unless
3800 ** as stated in the previous paragraph, sqlite3_step() invokes
3801 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
3802 */
3803 SQLITE_API int sqlite3_set_authorizer(
3804 sqlite3*,
3805 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3806 void *pUserData
@@ -4032,11 +3267,11 @@
4032 ** interrupted. This feature can be used to implement a
4033 ** "Cancel" button on a GUI progress dialog box.
4034 **
4035 ** The progress handler callback must not do anything that will modify
4036 ** the database connection that invoked the progress handler.
4037 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
4038 ** database connections for the meaning of "modify" in this paragraph.
4039 **
4040 */
4041 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
4042
@@ -4386,11 +3621,11 @@
4386 ** prepared statement before it can be run.
4387 **
4388 ** The life-cycle of a prepared statement object usually goes like this:
4389 **
4390 ** <ol>
4391 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
4392 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
4393 ** interfaces.
4394 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
4395 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
4396 ** to step 2. Do this zero or more times.
@@ -4468,11 +3703,11 @@
4468 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4469 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4470 **
4471 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
4472 ** <dd>The maximum number of instructions in a virtual machine program
4473 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
4474 ** the equivalent tries to allocate space for more than this many opcodes
4475 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
4476 **
4477 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
4478 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4508,61 +3743,28 @@
4508 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
4509 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4510 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4511 #define SQLITE_LIMIT_WORKER_THREADS 11
4512
4513 /*
4514 ** CAPI3REF: Prepare Flags
4515 **
4516 ** These constants define various flags that can be passed into
4517 ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
4518 ** [sqlite3_prepare16_v3()] interfaces.
4519 **
4520 ** New flags may be added in future releases of SQLite.
4521 **
4522 ** <dl>
4523 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
4524 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
4525 ** and [sqlite3_prepare16_v3()]
4526 ** to optimize the resulting prepared statement to be retained for a
4527 ** relatively long amount of time.)^ ^Without this flag,
4528 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
4529 ** the prepared statement will be used just once or at most a few times
4530 ** and then destroyed using [sqlite3_finalize()] relatively soon.
4531 ** </dl>
4532 */
4533 #define SQLITE_PREPARE_PERSISTENT 0x01
4534
4535 /*
4536 ** CAPI3REF: Compiling An SQL Statement
4537 ** KEYWORDS: {SQL statement compiler}
4538 ** METHOD: sqlite3
4539 ** CONSTRUCTOR: sqlite3_stmt
4540 **
4541 ** To execute an SQL statement, it must first be compiled into a byte-code
4542 ** program using one of these routines. Or, in other words, these routines
4543 ** are constructors for the [prepared statement] object.
4544 **
4545 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4546 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4547 ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4548 ** for special purposes.
4549 **
4550 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4551 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4552 ** as a convenience. The UTF-16 interfaces work by converting the
4553 ** input text into UTF-8, then invoking the corresponding UTF-8 interface.
4554 **
4555 ** The first argument, "db", is a [database connection] obtained from a
4556 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
4557 ** [sqlite3_open16()]. The database connection must not have been closed.
4558 **
4559 ** The second argument, "zSql", is the statement to be compiled, encoded
4560 ** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
4561 ** and sqlite3_prepare_v3()
4562 ** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
4563 ** and sqlite3_prepare16_v3() use UTF-16.
4564 **
4565 ** ^If the nByte argument is negative, then zSql is read up to the
4566 ** first zero terminator. ^If nByte is positive, then it is the
4567 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
4568 ** statement is generated.
@@ -4585,15 +3787,14 @@
4585 ** ppStmt may not be NULL.
4586 **
4587 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
4588 ** otherwise an [error code] is returned.
4589 **
4590 ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
4591 ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
4592 ** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
4593 ** are retained for backwards compatibility, but their use is discouraged.
4594 ** ^In the "vX" interfaces, the prepared statement
4595 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
4596 ** original SQL text. This causes the [sqlite3_step()] interface to
4597 ** behave differently in three ways:
4598 **
4599 ** <ol>
@@ -4622,16 +3823,10 @@
4622 ** ^The specific value of WHERE-clause [parameter] might influence the
4623 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4624 ** or [GLOB] operator or if the parameter is compared to an indexed column
4625 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
4626 ** </li>
4627 **
4628 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
4629 ** the extra prepFlags parameter, which is a bit array consisting of zero or
4630 ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
4631 ** sqlite3_prepare_v2() interface works exactly the same as
4632 ** sqlite3_prepare_v3() with a zero prepFlags parameter.
4633 ** </ol>
4634 */
4635 SQLITE_API int sqlite3_prepare(
4636 sqlite3 *db, /* Database handle */
4637 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4642,18 +3837,10 @@
4642 SQLITE_API int sqlite3_prepare_v2(
4643 sqlite3 *db, /* Database handle */
4644 const char *zSql, /* SQL statement, UTF-8 encoded */
4645 int nByte, /* Maximum length of zSql in bytes. */
4646 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4647 const char **pzTail /* OUT: Pointer to unused portion of zSql */
4648 );
4649 SQLITE_API int sqlite3_prepare_v3(
4650 sqlite3 *db, /* Database handle */
4651 const char *zSql, /* SQL statement, UTF-8 encoded */
4652 int nByte, /* Maximum length of zSql in bytes. */
4653 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
4654 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4655 const char **pzTail /* OUT: Pointer to unused portion of zSql */
4656 );
4657 SQLITE_API int sqlite3_prepare16(
4658 sqlite3 *db, /* Database handle */
4659 const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -4666,27 +3853,18 @@
4666 const void *zSql, /* SQL statement, UTF-16 encoded */
4667 int nByte, /* Maximum length of zSql in bytes. */
4668 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4669 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4670 );
4671 SQLITE_API int sqlite3_prepare16_v3(
4672 sqlite3 *db, /* Database handle */
4673 const void *zSql, /* SQL statement, UTF-16 encoded */
4674 int nByte, /* Maximum length of zSql in bytes. */
4675 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
4676 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
4677 const void **pzTail /* OUT: Pointer to unused portion of zSql */
4678 );
4679
4680 /*
4681 ** CAPI3REF: Retrieving Statement SQL
4682 ** METHOD: sqlite3_stmt
4683 **
4684 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
4685 ** SQL text used to create [prepared statement] P if P was
4686 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4687 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4688 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
4689 ** string containing the SQL text of prepared statement P with
4690 ** [bound parameters] expanded.
4691 **
4692 ** ^(For example, if a prepared statement is created using the SQL
@@ -4828,11 +4006,11 @@
4828 ** CAPI3REF: Binding Values To Prepared Statements
4829 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4830 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4831 ** METHOD: sqlite3_stmt
4832 **
4833 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
4834 ** literals may be replaced by a [parameter] that matches one of following
4835 ** templates:
4836 **
4837 ** <ul>
4838 ** <li> ?
@@ -4847,11 +4025,11 @@
4847 ** parameters (also called "host parameter names" or "SQL parameters")
4848 ** can be set using the sqlite3_bind_*() routines defined here.
4849 **
4850 ** ^The first argument to the sqlite3_bind_*() routines is always
4851 ** a pointer to the [sqlite3_stmt] object returned from
4852 ** [sqlite3_prepare_v3()] or its variants.
4853 **
4854 ** ^The second argument is the index of the SQL parameter to be set.
4855 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4856 ** SQL parameter is used more than once, second and subsequent
4857 ** occurrences have the same index as the first occurrence.
@@ -4984,12 +4162,12 @@
4984 ** ^The first host parameter has an index of 1, not 0.
4985 **
4986 ** ^If the value N is out of range or if the N-th parameter is
4987 ** nameless, then NULL is returned. ^The returned string is
4988 ** always in UTF-8 encoding even if the named parameter was
4989 ** originally specified as UTF-16 in [sqlite3_prepare16()],
4990 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4991 **
4992 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4993 ** [sqlite3_bind_parameter_count()], and
4994 ** [sqlite3_bind_parameter_index()].
4995 */
@@ -5002,12 +4180,11 @@
5002 ** ^Return the index of an SQL parameter given its name. ^The
5003 ** index value returned is suitable for use as the second
5004 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
5005 ** is returned if no matching parameter is found. ^The parameter
5006 ** name must be given in UTF-8 even if the original statement
5007 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
5008 ** [sqlite3_prepare16_v3()].
5009 **
5010 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
5011 ** [sqlite3_bind_parameter_count()], and
5012 ** [sqlite3_bind_parameter_name()].
5013 */
@@ -5157,22 +4334,20 @@
5157
5158 /*
5159 ** CAPI3REF: Evaluate An SQL Statement
5160 ** METHOD: sqlite3_stmt
5161 **
5162 ** After a [prepared statement] has been prepared using any of
5163 ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
5164 ** or [sqlite3_prepare16_v3()] or one of the legacy
5165 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
5166 ** must be called one or more times to evaluate the statement.
5167 **
5168 ** The details of the behavior of the sqlite3_step() interface depend
5169 ** on whether the statement was prepared using the newer "vX" interfaces
5170 ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
5171 ** [sqlite3_prepare16_v2()] or the older legacy
5172 ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
5173 ** new "vX" interface is recommended for new applications but the legacy
5174 ** interface will continue to be supported.
5175 **
5176 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
5177 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
5178 ** ^With the "v2" interface, any of the other [result codes] or
@@ -5229,15 +4404,14 @@
5229 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
5230 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
5231 ** specific [error codes] that better describes the error.
5232 ** We admit that this is a goofy design. The problem has been fixed
5233 ** with the "v2" interface. If you prepare all of your SQL statements
5234 ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
5235 ** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
5236 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
5237 ** then the more specific [error codes] are returned directly
5238 ** by sqlite3_step(). The use of the "vX" interfaces is recommended.
5239 */
5240 SQLITE_API int sqlite3_step(sqlite3_stmt*);
5241
5242 /*
5243 ** CAPI3REF: Number of columns in a result set
@@ -5298,11 +4472,11 @@
5298 ** METHOD: sqlite3_stmt
5299 **
5300 ** ^These routines return information about a single column of the current
5301 ** result row of a query. ^In every case the first argument is a pointer
5302 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5303 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
5304 ** and the second argument is the index of the column for which information
5305 ** should be returned. ^The leftmost column of the result set has the index 0.
5306 ** ^The number of columns in the result can be determined using
5307 ** [sqlite3_column_count()].
5308 **
@@ -6422,11 +5596,11 @@
6422 **
6423 ** ^The sqlite3_db_handle interface returns the [database connection] handle
6424 ** to which a [prepared statement] belongs. ^The [database connection]
6425 ** returned by sqlite3_db_handle is the same [database connection]
6426 ** that was the first argument
6427 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
6428 ** create the statement in the first place.
6429 */
6430 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6431
6432 /*
@@ -6498,11 +5672,11 @@
6498 ** the database connection that invoked the callback. Any actions
6499 ** to modify the database connection must be deferred until after the
6500 ** completion of the [sqlite3_step()] call that triggered the commit
6501 ** or rollback hook in the first place.
6502 ** Note that running any other SQL statements, including SELECT statements,
6503 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
6504 ** the database connections for the meaning of "modify" in this paragraph.
6505 **
6506 ** ^Registering a NULL function disables the callback.
6507 **
6508 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6558,11 +5732,11 @@
6558 **
6559 ** The update hook implementation must not do anything that will modify
6560 ** the database connection that invoked the update hook. Any actions
6561 ** to modify the database connection must be deferred until after the
6562 ** completion of the [sqlite3_step()] call that triggered the update hook.
6563 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
6564 ** database connections for the meaning of "modify" in this paragraph.
6565 **
6566 ** ^The sqlite3_update_hook(D,C,P) function
6567 ** returns the P argument from the previous call
6568 ** on the same [database connection] D, or NULL for
@@ -6721,13 +5895,11 @@
6721 ** column exists. ^The sqlite3_table_column_metadata() interface returns
6722 ** SQLITE_ERROR and if the specified column does not exist.
6723 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
6724 ** NULL pointer, then this routine simply checks for the existence of the
6725 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
6726 ** does not. If the table name parameter T in a call to
6727 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
6728 ** undefined behavior.
6729 **
6730 ** ^The column is identified by the second, third and fourth parameters to
6731 ** this function. ^(The second parameter is either the name of the database
6732 ** (i.e. "main", "temp", or an attached database) containing the specified
6733 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -8236,38 +7408,17 @@
8236 ** by the prepared statement if that number is less than or equal
8237 ** to 2147483647. The number of virtual machine operations can be
8238 ** used as a proxy for the total work done by the prepared statement.
8239 ** If the number of virtual machine operations exceeds 2147483647
8240 ** then the value returned by this statement status code is undefined.
8241 **
8242 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
8243 ** <dd>^This is the number of times that the prepare statement has been
8244 ** automatically regenerated due to schema changes or change to
8245 ** [bound parameters] that might affect the query plan.
8246 **
8247 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
8248 ** <dd>^This is the number of times that the prepared statement has
8249 ** been run. A single "run" for the purposes of this counter is one
8250 ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
8251 ** The counter is incremented on the first [sqlite3_step()] call of each
8252 ** cycle.
8253 **
8254 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8255 ** <dd>^This is the approximate number of bytes of heap memory
8256 ** used to store the prepared statement. ^This value is not actually
8257 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
8258 ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
8259 ** </dd>
8260 ** </dl>
8261 */
8262 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
8263 #define SQLITE_STMTSTATUS_SORT 2
8264 #define SQLITE_STMTSTATUS_AUTOINDEX 3
8265 #define SQLITE_STMTSTATUS_VM_STEP 4
8266 #define SQLITE_STMTSTATUS_REPREPARE 5
8267 #define SQLITE_STMTSTATUS_RUN 6
8268 #define SQLITE_STMTSTATUS_MEMUSED 99
8269
8270 /*
8271 ** CAPI3REF: Custom Page Cache Object
8272 **
8273 ** The sqlite3_pcache type is opaque. It is implemented by
@@ -11630,13 +10781,12 @@
11630
11631 /*
11632 ** Include the configuration header output by 'configure' if we're using the
11633 ** autoconf-based build
11634 */
11635 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
11636 /* #include "config.h" */
11637 #define SQLITECONFIG_H 1
11638 #endif
11639
11640 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
11641 /************** Begin file sqliteLimit.h *************************************/
11642 /*
@@ -11942,15 +11092,10 @@
11942 ** threads can use SQLite as long as no two threads try to use the same
11943 ** database connection at the same time.
11944 **
11945 ** Older versions of SQLite used an optional THREADSAFE macro.
11946 ** We support that for legacy.
11947 **
11948 ** To ensure that the correct value of "THREADSAFE" is reported when querying
11949 ** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this
11950 ** logic is partially replicated in ctime.c. If it is updated here, it should
11951 ** also be updated there.
11952 */
11953 #if !defined(SQLITE_THREADSAFE)
11954 # if defined(THREADSAFE)
11955 # define SQLITE_THREADSAFE THREADSAFE
11956 # else
@@ -12537,10 +11682,11 @@
12537 ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
12538 ** on the command-line
12539 */
12540 #ifndef SQLITE_TEMP_STORE
12541 # define SQLITE_TEMP_STORE 1
 
12542 #endif
12543
12544 /*
12545 ** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
12546 ** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
@@ -12837,19 +11983,21 @@
12837 || defined(__DragonFly__)
12838 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
12839 # else
12840 # define SQLITE_MAX_MMAP_SIZE 0
12841 # endif
 
12842 #endif
12843
12844 /*
12845 ** The default MMAP_SIZE is zero on all platforms. Or, even if a larger
12846 ** default MMAP_SIZE is specified at compile-time, make sure that it does
12847 ** not exceed the maximum mmap size.
12848 */
12849 #ifndef SQLITE_DEFAULT_MMAP_SIZE
12850 # define SQLITE_DEFAULT_MMAP_SIZE 0
 
12851 #endif
12852 #if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
12853 # undef SQLITE_DEFAULT_MMAP_SIZE
12854 # define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
12855 #endif
@@ -13330,13 +12478,13 @@
13330
13331 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
13332 int flags, int seekResult);
13333 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
13334 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
13335 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
13336 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
13337 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
13338 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
13339 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
13340 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
13341 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
13342
@@ -13483,11 +12631,11 @@
13483 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
13484 Table *pTab; /* Used when p4type is P4_TABLE */
13485 #ifdef SQLITE_ENABLE_CURSOR_HINTS
13486 Expr *pExpr; /* Used when p4type is P4_EXPR */
13487 #endif
13488 int (*xAdvance)(BtCursor *, int);
13489 } p4;
13490 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
13491 char *zComment; /* Comment to improve readability */
13492 #endif
13493 #ifdef VDBE_PROFILE
@@ -13717,11 +12865,11 @@
13717 #define OP_Rowid 125 /* synopsis: r[P2]=rowid */
13718 #define OP_NullRow 126
13719 #define OP_SorterInsert 127 /* synopsis: key=r[P2] */
13720 #define OP_IdxInsert 128 /* synopsis: key=r[P2] */
13721 #define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */
13722 #define OP_DeferredSeek 130 /* synopsis: Move P3 to P1.rowid if needed */
13723 #define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */
13724 #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
13725 #define OP_Destroy 133
13726 #define OP_Clear 134
13727 #define OP_ResetSorter 135
@@ -13798,16 +12946,10 @@
13798 #define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
13799
13800 /************** End of opcodes.h *********************************************/
13801 /************** Continuing where we left off in vdbe.h ***********************/
13802
13803 /*
13804 ** Additional non-public SQLITE_PREPARE_* flags
13805 */
13806 #define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */
13807 #define SQLITE_PREPARE_MASK 0x0f /* Mask of public flags */
13808
13809 /*
13810 ** Prototypes for the VDBE interface. See comments on the implementation
13811 ** for a description of what each of these routines does.
13812 */
13813 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13861,12 +13003,11 @@
13861 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
13862 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
13863 SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
13864 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
13865 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13866 SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);
13867 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
13868 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
13869 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
13870 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
13871 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
13872 #ifndef SQLITE_OMIT_TRACE
@@ -14228,25 +13369,25 @@
14228 */
14229 struct PgHdr {
14230 sqlite3_pcache_page *pPage; /* Pcache object page handle */
14231 void *pData; /* Page data */
14232 void *pExtra; /* Extra content */
14233 PCache *pCache; /* PRIVATE: Cache that owns this page */
14234 PgHdr *pDirty; /* Transient list of dirty sorted by pgno */
14235 Pager *pPager; /* The pager this page is part of */
14236 Pgno pgno; /* Page number for this page */
14237 #ifdef SQLITE_CHECK_PAGES
14238 u32 pageHash; /* Hash of page content */
14239 #endif
14240 u16 flags; /* PGHDR flags defined below */
14241
14242 /**********************************************************************
14243 ** Elements above, except pCache, are public. All that follow are
14244 ** private to pcache.c and should not be accessed by other modules.
14245 ** pCache is grouped with the public elements for efficiency.
14246 */
14247 i16 nRef; /* Number of users of this page */
 
 
14248 PgHdr *pDirtyNext; /* Next element in list of dirty pages */
14249 PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */
14250 };
14251
14252 /* Bit values for PgHdr.flags */
@@ -15084,12 +14225,12 @@
15084 ** Value constraints (enforced via assert()):
15085 ** SQLITE_FullFSync == PAGER_FULLFSYNC
15086 ** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
15087 ** SQLITE_CacheSpill == PAGER_CACHE_SPILL
15088 */
15089 #define SQLITE_WriteSchema 0x00000001 /* OK to update SQLITE_MASTER */
15090 #define SQLITE_LegacyFileFmt 0x00000002 /* Create new databases in format 1 */
15091 #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
15092 #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
15093 #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
15094 #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
15095 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -15096,38 +14237,33 @@
15096 #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
15097 /* DELETE, or UPDATE and return */
15098 /* the count using a callback. */
15099 #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
15100 /* result set is empty */
15101 #define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */
15102 #define SQLITE_ReadUncommit 0x00000400 /* READ UNCOMMITTED in shared-cache */
15103 #define SQLITE_NoCkptOnClose 0x00000800 /* No checkpoint on close()/DETACH */
15104 #define SQLITE_ReverseOrder 0x00001000 /* Reverse unordered SELECTs */
15105 #define SQLITE_RecTriggers 0x00002000 /* Enable recursive triggers */
15106 #define SQLITE_ForeignKeys 0x00004000 /* Enforce foreign key constraints */
15107 #define SQLITE_AutoIndex 0x00008000 /* Enable automatic indexes */
15108 #define SQLITE_LoadExtension 0x00010000 /* Enable load_extension */
15109 #define SQLITE_EnableTrigger 0x00020000 /* True to enable triggers */
15110 #define SQLITE_DeferFKs 0x00040000 /* Defer all FK constraints */
15111 #define SQLITE_QueryOnly 0x00080000 /* Disable database changes */
15112 #define SQLITE_CellSizeCk 0x00100000 /* Check btree cell sizes on load */
15113 #define SQLITE_Fts3Tokenizer 0x00200000 /* Enable fts3_tokenizer(2) */
15114 #define SQLITE_EnableQPSG 0x00400000 /* Query Planner Stability Guarantee */
15115 /* The next four values are not used by PRAGMAs or by sqlite3_dbconfig() and
15116 ** could be factored out into a separate bit vector of the sqlite3 object. */
15117 #define SQLITE_InternChanges 0x00800000 /* Uncommitted Hash table changes */
15118 #define SQLITE_LoadExtFunc 0x01000000 /* Enable load_extension() SQL func */
15119 #define SQLITE_PreferBuiltin 0x02000000 /* Preference to built-in funcs */
15120 #define SQLITE_Vacuum 0x04000000 /* Currently in a VACUUM */
15121 /* Flags used only if debugging */
15122 #ifdef SQLITE_DEBUG
15123 #define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
15124 #define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
15125 #define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
15126 #define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
15127 #define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
15128 #endif
15129
15130
15131 /*
15132 ** Bits of the sqlite3.dbOptFlags field that are used by the
15133 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -16006,11 +15142,11 @@
16006 ** The following are the meanings of bits in the Expr.flags field.
16007 */
16008 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
16009 #define EP_Agg 0x000002 /* Contains one or more aggregate functions */
16010 #define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
16011 /* 0x000008 // available for use */
16012 #define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
16013 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
16014 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
16015 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
16016 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
@@ -16473,14 +15609,14 @@
16473 ** An instance of this object describes where to put of the results of
16474 ** a SELECT statement.
16475 */
16476 struct SelectDest {
16477 u8 eDest; /* How to dispose of the results. On of SRT_* above. */
 
16478 int iSDParm; /* A parameter used by the eDest disposal method */
16479 int iSdst; /* Base register where results are written */
16480 int nSdst; /* Number of registers allocated */
16481 char *zAffSdst; /* Affinity used when eDest==SRT_Set */
16482 ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
16483 };
16484
16485 /*
16486 ** During code generation of statements that do inserts into AUTOINCREMENT
@@ -16979,14 +16115,10 @@
16979 SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
16980 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
16981 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
16982 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
16983 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
16984 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
16985 #ifdef SQLITE_DEBUG
16986 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
16987 #endif
16988
16989 /*
16990 ** Return code from the parse-tree walking primitives and their
16991 ** callbacks.
16992 */
@@ -17044,18 +16176,15 @@
17044 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
17045 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
17046 #ifdef SQLITE_DEBUG
17047 SQLITE_PRIVATE int sqlite3NomemError(int);
17048 SQLITE_PRIVATE int sqlite3IoerrnomemError(int);
17049 SQLITE_PRIVATE int sqlite3CorruptPgnoError(int,Pgno);
17050 # define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
17051 # define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
17052 # define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))
17053 #else
17054 # define SQLITE_NOMEM_BKPT SQLITE_NOMEM
17055 # define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
17056 # define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)
17057 #endif
17058
17059 /*
17060 ** FTS3 and FTS4 both require virtual table support
17061 */
@@ -17420,14 +16549,14 @@
17420 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
17421 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
17422 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
17423 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
17424 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
17425 SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
17426 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
17427 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
17428 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);
17429 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
17430 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
17431 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
17432 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
17433 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18012,12 +17141,10 @@
18012 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
18013 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
18014 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
18015 SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
18016
18017 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
18018
18019 #endif /* SQLITEINT_H */
18020
18021 /************** End of sqliteInt.h *******************************************/
18022 /************** Begin file global.c ******************************************/
18023 /*
@@ -18318,10 +17445,476 @@
18318 ** Name of the default collating sequence
18319 */
18320 SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
18321
18322 /************** End of global.c **********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18323 /************** Begin file status.c ******************************************/
18324 /*
18325 ** 2008 June 18
18326 **
18327 ** The author disclaims copyright to this source code. In place of
@@ -18721,22 +18314,22 @@
18721 int rcApp; /* errcode set by sqlite3_result_error_code() */
18722 #endif
18723 u16 nResColumn; /* Number of columns in one row of the result set */
18724 u8 errorAction; /* Recovery action to do in case of an error */
18725 u8 minWriteFileFormat; /* Minimum file format for writable database files */
18726 u8 prepFlags; /* SQLITE_PREPARE_* flags */
18727 bft expired:1; /* True if the VM needs to be recompiled */
18728 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
18729 bft explain:2; /* True if EXPLAIN present on SQL command */
18730 bft changeCntOn:1; /* True to update the change-counter */
18731 bft runOnlyOnce:1; /* Automatically expire on reset */
18732 bft usesStmtJournal:1; /* True if uses a statement journal */
18733 bft readOnly:1; /* True for statements that do not write */
18734 bft bIsReader:1; /* True for statements that read */
 
18735 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
18736 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18737 u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
18738 char *zSql; /* Text of the SQL statement that generated this */
18739 void *pFree; /* Free this when deleting the vdbe */
18740 VdbeFrame *pFrame; /* Parent frame */
18741 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
18742 int nFrame; /* Number of frames in pFrame list */
@@ -18845,11 +18438,11 @@
18845
18846 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
18847 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
18848 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
18849 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
18850 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);
18851 SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
18852 SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
18853 SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
18854
18855 #if !defined(SQLITE_OMIT_SHARED_CACHE)
@@ -30045,11 +29638,11 @@
30045 /* 125 */ "Rowid" OpHelp("r[P2]=rowid"),
30046 /* 126 */ "NullRow" OpHelp(""),
30047 /* 127 */ "SorterInsert" OpHelp("key=r[P2]"),
30048 /* 128 */ "IdxInsert" OpHelp("key=r[P2]"),
30049 /* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
30050 /* 130 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
30051 /* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"),
30052 /* 132 */ "Real" OpHelp("r[P2]=P4"),
30053 /* 133 */ "Destroy" OpHelp(""),
30054 /* 134 */ "Clear" OpHelp(""),
30055 /* 135 */ "ResetSorter" OpHelp(""),
@@ -50575,11 +50168,11 @@
50575 assert( isOpen(pPager->fd) );
50576 assert( pPager->tempFile==0 );
50577 nPage = sqlite3WalDbsize(pPager->pWal);
50578
50579 /* If the number of pages in the database is not available from the
50580 ** WAL sub-system, determine the page count based on the size of
50581 ** the database file. If the size of the database file is not an
50582 ** integer multiple of the page-size, round up the result.
50583 */
50584 if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){
50585 i64 n = 0; /* Size of db file in bytes */
@@ -50626,25 +50219,27 @@
50626 assert( pPager->eState==PAGER_OPEN );
50627 assert( pPager->eLock>=SHARED_LOCK );
50628
50629 if( !pPager->tempFile ){
50630 int isWal; /* True if WAL file exists */
50631 rc = sqlite3OsAccess(
50632 pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
50633 );
 
 
 
 
 
 
 
 
 
 
50634 if( rc==SQLITE_OK ){
50635 if( isWal ){
50636 Pgno nPage; /* Size of the database file */
50637
50638 rc = pagerPagecount(pPager, &nPage);
50639 if( rc ) return rc;
50640 if( nPage==0 ){
50641 rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
50642 }else{
50643 testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
50644 rc = sqlite3PagerOpenWal(pPager, 0);
50645 }
50646 }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
50647 pPager->journalMode = PAGER_JOURNALMODE_DELETE;
50648 }
50649 }
50650 }
@@ -52583,18 +52178,23 @@
52583 **
52584 ** There is a vanishingly small chance that a change will not be
52585 ** detected. The chance of an undetected change is so small that
52586 ** it can be neglected.
52587 */
 
52588 char dbFileVers[sizeof(pPager->dbFileVers)];
52589
52590 IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
52591 rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
52592 if( rc!=SQLITE_OK ){
52593 if( rc!=SQLITE_IOERR_SHORT_READ ){
 
 
 
52594 goto failed;
52595 }
 
52596 memset(dbFileVers, 0, sizeof(dbFileVers));
52597 }
52598
52599 if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){
52600 pager_reset(pPager);
@@ -59584,11 +59184,11 @@
59584 /* If this database is not shareable, or if the client is reading
59585 ** and has the read-uncommitted flag set, then no lock is required.
59586 ** Return true immediately.
59587 */
59588 if( (pBtree->sharable==0)
59589 || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))
59590 ){
59591 return 1;
59592 }
59593
59594 /* If the client is reading or writing an index and the schema is
@@ -59661,11 +59261,11 @@
59661 static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
59662 BtCursor *p;
59663 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
59664 if( p->pgnoRoot==iRoot
59665 && p->pBtree!=pBtree
59666 && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)
59667 ){
59668 return 1;
59669 }
59670 }
59671 return 0;
@@ -59683,11 +59283,11 @@
59683 BtLock *pIter;
59684
59685 assert( sqlite3BtreeHoldsMutex(p) );
59686 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
59687 assert( p->db!=0 );
59688 assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );
59689
59690 /* If requesting a write-lock, then the Btree must have an open write
59691 ** transaction on this file. And, obviously, for this to be so there
59692 ** must be an open write transaction on the file itself.
59693 */
@@ -59761,11 +59361,11 @@
59761
59762 /* A connection with the read-uncommitted flag set will never try to
59763 ** obtain a read-lock using this function. The only read-lock obtained
59764 ** by a connection in read-uncommitted mode is on the sqlite_master
59765 ** table, and that lock is obtained in BtreeBeginTrans(). */
59766 assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );
59767
59768 /* This function should only be called on a sharable b-tree after it
59769 ** has been determined that no other b-tree holds a conflicting lock. */
59770 assert( p->sharable );
59771 assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -60203,11 +59803,11 @@
60203 assert( nKey==(i64)(int)nKey );
60204 pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);
60205 if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
60206 sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
60207 if( pIdxKey->nField==0 ){
60208 rc = SQLITE_CORRUPT_PGNO(pCur->apPage[pCur->iPage]->pgno);
60209 goto moveto_done;
60210 }
60211 }else{
60212 pIdxKey = 0;
60213 }
@@ -60432,11 +60032,11 @@
60432 assert( pEType!=0 );
60433 *pEType = pPtrmap[offset];
60434 if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
60435
60436 sqlite3PagerUnref(pDbPage);
60437 if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap);
60438 return SQLITE_OK;
60439 }
60440
60441 #else /* if defined SQLITE_OMIT_AUTOVACUUM */
60442 #define ptrmapPut(w,x,y,z,rc)
@@ -60817,11 +60417,11 @@
60817 u8 *pAddr;
60818 int sz2 = 0;
60819 int sz = get2byte(&data[iFree+2]);
60820 int top = get2byte(&data[hdr+5]);
60821 if( iFree2 ){
60822 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
60823 sz2 = get2byte(&data[iFree2+2]);
60824 assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
60825 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
60826 sz += sz2;
60827 }
@@ -60848,17 +60448,17 @@
60848 testcase( pc==iCellLast );
60849 /* These conditions have already been verified in btreeInitPage()
60850 ** if PRAGMA cell_size_check=ON.
60851 */
60852 if( pc<iCellFirst || pc>iCellLast ){
60853 return SQLITE_CORRUPT_PGNO(pPage->pgno);
60854 }
60855 assert( pc>=iCellFirst && pc<=iCellLast );
60856 size = pPage->xCellSize(pPage, &src[pc]);
60857 cbrk -= size;
60858 if( cbrk<iCellFirst || pc+size>usableSize ){
60859 return SQLITE_CORRUPT_PGNO(pPage->pgno);
60860 }
60861 assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
60862 testcase( cbrk+size==usableSize );
60863 testcase( pc+size==usableSize );
60864 put2byte(pAddr, cbrk);
@@ -60874,11 +60474,11 @@
60874 }
60875 data[hdr+7] = 0;
60876
60877 defragment_out:
60878 if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){
60879 return SQLITE_CORRUPT_PGNO(pPage->pgno);
60880 }
60881 assert( cbrk>=iCellFirst );
60882 put2byte(&data[hdr+5], cbrk);
60883 data[hdr+1] = 0;
60884 data[hdr+2] = 0;
@@ -60913,11 +60513,11 @@
60913 do{
60914 int size; /* Size of the free slot */
60915 /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
60916 ** increasing offset. */
60917 if( pc>usableSize-4 || pc<iAddr+4 ){
60918 *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);
60919 return 0;
60920 }
60921 /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
60922 ** freeblock form a big-endian integer which is the size of the freeblock
60923 ** in bytes, including the 4-byte header. */
@@ -60924,11 +60524,11 @@
60924 size = get2byte(&aData[pc+2]);
60925 if( (x = size - nByte)>=0 ){
60926 testcase( x==4 );
60927 testcase( x==3 );
60928 if( pc < pPg->cellOffset+2*pPg->nCell || size+pc > usableSize ){
60929 *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);
60930 return 0;
60931 }else if( x<4 ){
60932 /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
60933 ** number of bytes in fragments may not exceed 60. */
60934 if( aData[hdr+7]>57 ) return 0;
@@ -60991,11 +60591,11 @@
60991 assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */
60992 if( gap>top ){
60993 if( top==0 && pPage->pBt->usableSize==65536 ){
60994 top = 65536;
60995 }else{
60996 return SQLITE_CORRUPT_PGNO(pPage->pgno);
60997 }
60998 }
60999
61000 /* If there is enough space between gap and top for one more cell pointer
61001 ** array entry offset, and if the freelist is not empty, then search the
@@ -61087,15 +60687,15 @@
61087 iFreeBlk = 0; /* Shortcut for the case when the freelist is empty */
61088 }else{
61089 while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){
61090 if( iFreeBlk<iPtr+4 ){
61091 if( iFreeBlk==0 ) break;
61092 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61093 }
61094 iPtr = iFreeBlk;
61095 }
61096 if( iFreeBlk>iLast ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
61097 assert( iFreeBlk>iPtr || iFreeBlk==0 );
61098
61099 /* At this point:
61100 ** iFreeBlk: First freeblock after iStart, or zero if none
61101 ** iPtr: The address of a pointer to iFreeBlk
@@ -61102,15 +60702,13 @@
61102 **
61103 ** Check to see if iFreeBlk should be coalesced onto the end of iStart.
61104 */
61105 if( iFreeBlk && iEnd+3>=iFreeBlk ){
61106 nFrag = iFreeBlk - iEnd;
61107 if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
61108 iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
61109 if( iEnd > pPage->pBt->usableSize ){
61110 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61111 }
61112 iSize = iEnd - iStart;
61113 iFreeBlk = get2byte(&data[iFreeBlk]);
61114 }
61115
61116 /* If iPtr is another freeblock (that is, if iPtr is not the freelist
@@ -61118,24 +60716,24 @@
61118 ** coalesced onto the end of iPtr.
61119 */
61120 if( iPtr>hdr+1 ){
61121 int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);
61122 if( iPtrEnd+3>=iStart ){
61123 if( iPtrEnd>iStart ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
61124 nFrag += iStart - iPtrEnd;
61125 iSize = iEnd - iPtr;
61126 iStart = iPtr;
61127 }
61128 }
61129 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
61130 data[hdr+7] -= nFrag;
61131 }
61132 if( iStart==get2byte(&data[hdr+5]) ){
61133 /* The new freeblock is at the beginning of the cell content area,
61134 ** so just extend the cell content area rather than create another
61135 ** freelist entry */
61136 if( iPtr!=hdr+1 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);
61137 put2byte(&data[hdr+1], iFreeBlk);
61138 put2byte(&data[hdr+5], iEnd);
61139 }else{
61140 /* Insert the new freeblock into the freelist */
61141 put2byte(&data[iPtr], iStart);
@@ -61199,11 +60797,11 @@
61199 pPage->maxLocal = pBt->maxLocal;
61200 pPage->minLocal = pBt->minLocal;
61201 }else{
61202 /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
61203 ** an error. */
61204 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61205 }
61206 pPage->max1bytePayload = pBt->max1bytePayload;
61207 return SQLITE_OK;
61208 }
61209
@@ -61215,140 +60813,138 @@
61215 ** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not
61216 ** guarantee that the page is well-formed. It only shows that
61217 ** we failed to detect any corruption.
61218 */
61219 static int btreeInitPage(MemPage *pPage){
61220 int pc; /* Address of a freeblock within pPage->aData[] */
61221 u8 hdr; /* Offset to beginning of page header */
61222 u8 *data; /* Equal to pPage->aData */
61223 BtShared *pBt; /* The main btree structure */
61224 int usableSize; /* Amount of usable space on each page */
61225 u16 cellOffset; /* Offset from start of page to first cell pointer */
61226 int nFree; /* Number of unused bytes on the page */
61227 int top; /* First byte of the cell content area */
61228 int iCellFirst; /* First allowable cell or freeblock offset */
61229 int iCellLast; /* Last possible cell or freeblock offset */
61230
61231 assert( pPage->pBt!=0 );
61232 assert( pPage->pBt->db!=0 );
61233 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
61234 assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );
61235 assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );
61236 assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );
61237 assert( pPage->isInit==0 );
61238
61239 pBt = pPage->pBt;
61240 hdr = pPage->hdrOffset;
61241 data = pPage->aData;
61242 /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating
61243 ** the b-tree page type. */
61244 if( decodeFlags(pPage, data[hdr]) ){
61245 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61246 }
61247 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
61248 pPage->maskPage = (u16)(pBt->pageSize - 1);
61249 pPage->nOverflow = 0;
61250 usableSize = pBt->usableSize;
61251 pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;
61252 pPage->aDataEnd = &data[usableSize];
61253 pPage->aCellIdx = &data[cellOffset];
61254 pPage->aDataOfst = &data[pPage->childPtrSize];
61255 /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates
61256 ** the start of the cell content area. A zero value for this integer is
61257 ** interpreted as 65536. */
61258 top = get2byteNotZero(&data[hdr+5]);
61259 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
61260 ** number of cells on the page. */
61261 pPage->nCell = get2byte(&data[hdr+3]);
61262 if( pPage->nCell>MX_CELL(pBt) ){
61263 /* To many cells for a single page. The page must be corrupt */
61264 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61265 }
61266 testcase( pPage->nCell==MX_CELL(pBt) );
61267 /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
61268 ** possible for a root page of a table that contains no rows) then the
61269 ** offset to the cell content area will equal the page size minus the
61270 ** bytes of reserved space. */
61271 assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );
61272
61273 /* A malformed database page might cause us to read past the end
61274 ** of page when parsing a cell.
61275 **
61276 ** The following block of code checks early to see if a cell extends
61277 ** past the end of a page boundary and causes SQLITE_CORRUPT to be
61278 ** returned if it does.
61279 */
61280 iCellFirst = cellOffset + 2*pPage->nCell;
61281 iCellLast = usableSize - 4;
61282 if( pBt->db->flags & SQLITE_CellSizeCk ){
61283 int i; /* Index into the cell pointer array */
61284 int sz; /* Size of a cell */
61285
61286 if( !pPage->leaf ) iCellLast--;
61287 for(i=0; i<pPage->nCell; i++){
61288 pc = get2byteAligned(&data[cellOffset+i*2]);
61289 testcase( pc==iCellFirst );
61290 testcase( pc==iCellLast );
61291 if( pc<iCellFirst || pc>iCellLast ){
61292 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61293 }
61294 sz = pPage->xCellSize(pPage, &data[pc]);
61295 testcase( pc+sz==usableSize );
61296 if( pc+sz>usableSize ){
61297 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61298 }
61299 }
61300 if( !pPage->leaf ) iCellLast++;
61301 }
61302
61303 /* Compute the total free space on the page
61304 ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the
61305 ** start of the first freeblock on the page, or is zero if there are no
61306 ** freeblocks. */
61307 pc = get2byte(&data[hdr+1]);
61308 nFree = data[hdr+7] + top; /* Init nFree to non-freeblock free space */
61309 if( pc>0 ){
61310 u32 next, size;
61311 if( pc<iCellFirst ){
61312 /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will
61313 ** always be at least one cell before the first freeblock.
61314 */
61315 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61316 }
61317 while( 1 ){
61318 if( pc>iCellLast ){
61319 /* Freeblock off the end of the page */
61320 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61321 }
61322 next = get2byte(&data[pc]);
61323 size = get2byte(&data[pc+2]);
61324 nFree = nFree + size;
61325 if( next<=pc+size+3 ) break;
61326 pc = next;
61327 }
61328 if( next>0 ){
61329 /* Freeblock not in ascending order */
61330 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61331 }
61332 if( pc+size>(unsigned int)usableSize ){
61333 /* Last freeblock extends past page end */
61334 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61335 }
61336 }
61337
61338 /* At this point, nFree contains the sum of the offset to the start
61339 ** of the cell-content area plus the number of free bytes within
61340 ** the cell-content area. If this is greater than the usable-size
61341 ** of the page, then the page must be corrupted. This check also
61342 ** serves to verify that the offset to the start of the cell-content
61343 ** area, according to the page header, lies within the page.
61344 */
61345 if( nFree>usableSize ){
61346 return SQLITE_CORRUPT_PGNO(pPage->pgno);
61347 }
61348 pPage->nFree = (u16)(nFree - iCellFirst);
61349 pPage->isInit = 1;
 
 
 
 
 
 
 
 
61350 return SQLITE_OK;
61351 }
61352
61353 /*
61354 ** Set up a raw page so that it looks like a database page holding
@@ -61508,11 +61104,11 @@
61508 assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
61509
61510 /* If obtaining a child page for a cursor, we must verify that the page is
61511 ** compatible with the root page. */
61512 if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
61513 rc = SQLITE_CORRUPT_PGNO(pgno);
61514 releasePage(*ppPage);
61515 goto getAndInitPage_error;
61516 }
61517 return SQLITE_OK;
61518
@@ -62453,11 +62049,11 @@
62453 freeTempSpace(pBt);
62454 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
62455 pageSize-usableSize);
62456 return rc;
62457 }
62458 if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
62459 rc = SQLITE_CORRUPT_BKPT;
62460 goto page1_init_failed;
62461 }
62462 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
62463 ** be less than 480. In other words, if the page size is 512, then the
@@ -62796,11 +62392,11 @@
62796 int rc; /* Return code */
62797 BtShared *pBt = pPage->pBt;
62798 Pgno pgno = pPage->pgno;
62799
62800 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
62801 rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
62802 if( rc!=SQLITE_OK ) return rc;
62803 nCell = pPage->nCell;
62804
62805 for(i=0; i<nCell; i++){
62806 u8 *pCell = findCell(pPage, i);
@@ -62839,19 +62435,19 @@
62839 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
62840 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
62841 if( eType==PTRMAP_OVERFLOW2 ){
62842 /* The pointer is always the first 4 bytes of the page in this case. */
62843 if( get4byte(pPage->aData)!=iFrom ){
62844 return SQLITE_CORRUPT_PGNO(pPage->pgno);
62845 }
62846 put4byte(pPage->aData, iTo);
62847 }else{
62848 int i;
62849 int nCell;
62850 int rc;
62851
62852 rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);
62853 if( rc ) return rc;
62854 nCell = pPage->nCell;
62855
62856 for(i=0; i<nCell; i++){
62857 u8 *pCell = findCell(pPage, i);
@@ -62858,11 +62454,11 @@
62858 if( eType==PTRMAP_OVERFLOW1 ){
62859 CellInfo info;
62860 pPage->xParseCell(pPage, pCell, &info);
62861 if( info.nLocal<info.nPayload ){
62862 if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){
62863 return SQLITE_CORRUPT_PGNO(pPage->pgno);
62864 }
62865 if( iFrom==get4byte(pCell+info.nSize-4) ){
62866 put4byte(pCell+info.nSize-4, iTo);
62867 break;
62868 }
@@ -62876,11 +62472,11 @@
62876 }
62877
62878 if( i==nCell ){
62879 if( eType!=PTRMAP_BTREE ||
62880 get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){
62881 return SQLITE_CORRUPT_PGNO(pPage->pgno);
62882 }
62883 put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);
62884 }
62885 }
62886 return SQLITE_OK;
@@ -63984,11 +63580,11 @@
63984 /* Trying to read or write past the end of the data is an error. The
63985 ** conditional above is really:
63986 ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
63987 ** but is recast into its current form to avoid integer overflow problems
63988 */
63989 return SQLITE_CORRUPT_PGNO(pPage->pgno);
63990 }
63991
63992 /* Check if data must be read/written to/from the btree page itself. */
63993 if( offset<pCur->info.nLocal ){
63994 int a = amt;
@@ -64131,12 +63727,11 @@
64131 iIdx++;
64132 }
64133 }
64134
64135 if( rc==SQLITE_OK && amt>0 ){
64136 /* Overflow chain ends prematurely */
64137 return SQLITE_CORRUPT_PGNO(pPage->pgno);
64138 }
64139 return rc;
64140 }
64141
64142 /*
@@ -64398,11 +63993,11 @@
64398 ** if pCur->iPage>=0). But this is not so if the database is corrupted
64399 ** in such a way that page pRoot is linked into a second b-tree table
64400 ** (or the freelist). */
64401 assert( pRoot->intKey==1 || pRoot->intKey==0 );
64402 if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
64403 return SQLITE_CORRUPT_PGNO(pCur->apPage[pCur->iPage]->pgno);
64404 }
64405
64406 skip_init:
64407 pCur->ix = 0;
64408 pCur->info.nSize = 0;
@@ -64603,23 +64198,20 @@
64603 return SQLITE_OK;
64604 }
64605 /* If the requested key is one more than the previous key, then
64606 ** try to get there using sqlite3BtreeNext() rather than a full
64607 ** binary search. This is an optimization only. The correct answer
64608 ** is still obtained without this case, only a little more slowely */
64609 if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
64610 *pRes = 0;
64611 rc = sqlite3BtreeNext(pCur, 0);
64612 if( rc==SQLITE_OK ){
 
64613 getCellInfo(pCur);
64614 if( pCur->info.nKey==intKey ){
64615 return SQLITE_OK;
64616 }
64617 }else if( rc==SQLITE_DONE ){
64618 rc = SQLITE_OK;
64619 }else{
64620 return rc;
64621 }
64622 }
64623 }
64624 }
64625
@@ -64671,13 +64263,11 @@
64671 for(;;){
64672 i64 nCellKey;
64673 pCell = findCellPastPtr(pPage, idx);
64674 if( pPage->intKeyLeaf ){
64675 while( 0x80 <= *(pCell++) ){
64676 if( pCell>=pPage->aDataEnd ){
64677 return SQLITE_CORRUPT_PGNO(pPage->pgno);
64678 }
64679 }
64680 }
64681 getVarint(pCell, (u64*)&nCellKey);
64682 if( nCellKey<intKey ){
64683 lwr = idx+1;
@@ -64746,11 +64336,11 @@
64746 testcase( nCell<0 ); /* True if key size is 2^32 or more */
64747 testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
64748 testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
64749 testcase( nCell==2 ); /* Minimum legal index key size */
64750 if( nCell<2 ){
64751 rc = SQLITE_CORRUPT_PGNO(pPage->pgno);
64752 goto moveto_finish;
64753 }
64754 pCellKey = sqlite3Malloc( nCell+18 );
64755 if( pCellKey==0 ){
64756 rc = SQLITE_NOMEM_BKPT;
@@ -64851,44 +64441,47 @@
64851 }
64852 return n;
64853 }
64854
64855 /*
64856 ** Advance the cursor to the next entry in the database.
64857 ** Return value:
64858 **
64859 ** SQLITE_OK success
64860 ** SQLITE_DONE cursor is already pointing at the last element
64861 ** otherwise some kind of error occurred
64862 **
64863 ** The main entry point is sqlite3BtreeNext(). That routine is optimized
64864 ** for the common case of merely incrementing the cell counter BtCursor.aiIdx
64865 ** to the next cell on the current page. The (slower) btreeNext() helper
64866 ** routine is called when it is necessary to move to a different page or
64867 ** to restore the cursor.
64868 **
64869 ** If bit 0x01 of the flags argument is 1, then the cursor corresponds to
64870 ** an SQL index and this routine could have been skipped if the SQL index
64871 ** had been a unique index. The flags argument is a hint to the implement.
64872 ** SQLite btree implementation does not use this hint, but COMDB2 does.
 
 
 
 
64873 */
64874 static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int flags){
64875 int rc;
64876 int idx;
64877 MemPage *pPage;
64878
64879 assert( cursorOwnsBtShared(pCur) );
64880 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64881 assert( flags==0 );
64882 if( pCur->eState!=CURSOR_VALID ){
64883 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
64884 rc = restoreCursorPosition(pCur);
64885 if( rc!=SQLITE_OK ){
64886 return rc;
64887 }
64888 if( CURSOR_INVALID==pCur->eState ){
64889 return SQLITE_DONE;
 
64890 }
64891 if( pCur->skipNext ){
64892 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
64893 pCur->eState = CURSOR_VALID;
64894 if( pCur->skipNext>0 ){
@@ -64916,18 +64509,19 @@
64916 if( rc ) return rc;
64917 return moveToLeftmost(pCur);
64918 }
64919 do{
64920 if( pCur->iPage==0 ){
 
64921 pCur->eState = CURSOR_INVALID;
64922 return SQLITE_DONE;
64923 }
64924 moveToParent(pCur);
64925 pPage = pCur->apPage[pCur->iPage];
64926 }while( pCur->ix>=pPage->nCell );
64927 if( pPage->intKey ){
64928 return sqlite3BtreeNext(pCur, flags);
64929 }else{
64930 return SQLITE_OK;
64931 }
64932 }
64933 if( pPage->leaf ){
@@ -64934,66 +64528,71 @@
64934 return SQLITE_OK;
64935 }else{
64936 return moveToLeftmost(pCur);
64937 }
64938 }
64939 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){
64940 MemPage *pPage;
64941 assert( cursorOwnsBtShared(pCur) );
64942 assert( flags==0 || flags==1 );
 
64943 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64944 pCur->info.nSize = 0;
64945 pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
64946 if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, 0);
 
64947 pPage = pCur->apPage[pCur->iPage];
64948 if( (++pCur->ix)>=pPage->nCell ){
64949 pCur->ix--;
64950 return btreeNext(pCur, 0);
64951 }
64952 if( pPage->leaf ){
64953 return SQLITE_OK;
64954 }else{
64955 return moveToLeftmost(pCur);
64956 }
64957 }
64958
64959 /*
64960 ** Step the cursor to the back to the previous entry in the database.
64961 ** Return values:
64962 **
64963 ** SQLITE_OK success
64964 ** SQLITE_DONE the cursor is already on the first element of the table
64965 ** otherwise some kind of error occurred
64966 **
64967 ** The main entry point is sqlite3BtreePrevious(). That routine is optimized
64968 ** for the common case of merely decrementing the cell counter BtCursor.aiIdx
64969 ** to the previous cell on the current page. The (slower) btreePrevious()
64970 ** helper routine is called when it is necessary to move to a different page
64971 ** or to restore the cursor.
64972 **
64973 **
64974 ** If bit 0x01 of the flags argument is 1, then the cursor corresponds to
64975 ** an SQL index and this routine could have been skipped if the SQL index
64976 ** had been a unique index. The flags argument is a hint to the implement.
64977 ** SQLite btree implementation does not use this hint, but COMDB2 does.
 
 
 
64978 */
64979 static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int flags){
64980 int rc;
64981 MemPage *pPage;
64982
64983 assert( cursorOwnsBtShared(pCur) );
64984 assert( flags==0 );
 
64985 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64986 assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
64987 assert( pCur->info.nSize==0 );
64988 if( pCur->eState!=CURSOR_VALID ){
64989 rc = restoreCursorPosition(pCur);
64990 if( rc!=SQLITE_OK ){
64991 return rc;
64992 }
64993 if( CURSOR_INVALID==pCur->eState ){
64994 return SQLITE_DONE;
 
64995 }
64996 if( pCur->skipNext ){
64997 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
64998 pCur->eState = CURSOR_VALID;
64999 if( pCur->skipNext<0 ){
@@ -65013,38 +64612,41 @@
65013 rc = moveToRightmost(pCur);
65014 }else{
65015 while( pCur->ix==0 ){
65016 if( pCur->iPage==0 ){
65017 pCur->eState = CURSOR_INVALID;
65018 return SQLITE_DONE;
 
65019 }
65020 moveToParent(pCur);
65021 }
65022 assert( pCur->info.nSize==0 );
65023 assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );
65024
65025 pCur->ix--;
65026 pPage = pCur->apPage[pCur->iPage];
65027 if( pPage->intKey && !pPage->leaf ){
65028 rc = sqlite3BtreePrevious(pCur, flags);
65029 }else{
65030 rc = SQLITE_OK;
65031 }
65032 }
65033 return rc;
65034 }
65035 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){
65036 assert( cursorOwnsBtShared(pCur) );
65037 assert( flags==0 || flags==1 );
 
65038 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
 
65039 pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);
65040 pCur->info.nSize = 0;
65041 if( pCur->eState!=CURSOR_VALID
65042 || pCur->ix==0
65043 || pCur->apPage[pCur->iPage]->leaf==0
65044 ){
65045 return btreePrevious(pCur, 0);
65046 }
65047 pCur->ix--;
65048 return SQLITE_OK;
65049 }
65050
@@ -65148,11 +64750,11 @@
65148 ** the freelist is empty. */
65149 iTrunk = get4byte(&pPage1->aData[32]);
65150 }
65151 testcase( iTrunk==mxPage );
65152 if( iTrunk>mxPage || nSearch++ > n ){
65153 rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);
65154 }else{
65155 rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
65156 }
65157 if( rc ){
65158 pTrunk = 0;
@@ -65177,11 +64779,11 @@
65177 *ppPage = pTrunk;
65178 pTrunk = 0;
65179 TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
65180 }else if( k>(u32)(pBt->usableSize/4 - 2) ){
65181 /* Value of k is out of range. Database corruption */
65182 rc = SQLITE_CORRUPT_PGNO(iTrunk);
65183 goto end_allocate_page;
65184 #ifndef SQLITE_OMIT_AUTOVACUUM
65185 }else if( searchList
65186 && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE))
65187 ){
@@ -65211,11 +64813,11 @@
65211 ** page in this case.
65212 */
65213 MemPage *pNewTrunk;
65214 Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
65215 if( iNewTrunk>mxPage ){
65216 rc = SQLITE_CORRUPT_PGNO(iTrunk);
65217 goto end_allocate_page;
65218 }
65219 testcase( iNewTrunk==mxPage );
65220 rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);
65221 if( rc!=SQLITE_OK ){
@@ -65276,11 +64878,11 @@
65276 }
65277
65278 iPage = get4byte(&aData[8+closest*4]);
65279 testcase( iPage==mxPage );
65280 if( iPage>mxPage ){
65281 rc = SQLITE_CORRUPT_PGNO(iTrunk);
65282 goto end_allocate_page;
65283 }
65284 testcase( iPage==mxPage );
65285 if( !searchList
65286 || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE))
@@ -65546,12 +65148,11 @@
65546 pPage->xParseCell(pPage, pCell, pInfo);
65547 if( pInfo->nLocal==pInfo->nPayload ){
65548 return SQLITE_OK; /* No overflow pages. Return without doing anything */
65549 }
65550 if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){
65551 /* Cell extends past end of page */
65552 return SQLITE_CORRUPT_PGNO(pPage->pgno);
65553 }
65554 ovflPgno = get4byte(pCell + pInfo->nSize - 4);
65555 assert( pBt->usableSize > 4 );
65556 ovflPageSize = pBt->usableSize - 4;
65557 nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;
@@ -67762,12 +67363,12 @@
67762 ** from the internal node. The 'previous' entry is used for this instead
67763 ** of the 'next' entry, as the previous entry is always a part of the
67764 ** sub-tree headed by the child page of the cell being deleted. This makes
67765 ** balancing the tree following the delete operation easier. */
67766 if( !pPage->leaf ){
67767 rc = sqlite3BtreePrevious(pCur, 0);
67768 assert( rc!=SQLITE_DONE );
67769 if( rc ) return rc;
67770 }
67771
67772 /* Save the positions of any other cursors open on this table before
67773 ** making any modifications. */
@@ -71423,11 +71024,11 @@
71423 if( enc!=SQLITE_UTF8 ){
71424 rc = sqlite3VdbeChangeEncoding(pVal, enc);
71425 }
71426 }else if( op==TK_UMINUS ) {
71427 /* This branch happens for multiple negative signs. Ex: -(-5) */
71428 if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx)
71429 && pVal!=0
71430 ){
71431 sqlite3VdbeMemNumerify(pVal);
71432 if( pVal->flags & MEM_Real ){
71433 pVal->u.r = -pVal->u.r;
@@ -71580,25 +71181,28 @@
71580 sqlite3 *db = pParse->db;
71581
71582 /* Skip over any TK_COLLATE nodes */
71583 pExpr = sqlite3ExprSkipCollate(pExpr);
71584
71585 assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );
71586 if( !pExpr ){
71587 pVal = valueNew(db, pAlloc);
71588 if( pVal ){
71589 sqlite3VdbeMemSetNull((Mem*)pVal);
71590 }
71591 }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
 
 
71592 Vdbe *v;
71593 int iBindVar = pExpr->iColumn;
71594 sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
71595 if( (v = pParse->pReprepare)!=0 ){
71596 pVal = valueNew(db, pAlloc);
71597 if( pVal ){
71598 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71599 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
 
 
71600 pVal->db = pParse->db;
71601 }
71602 }
71603 }else{
71604 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71868,18 +71472,20 @@
71868 }
71869
71870 /*
71871 ** Remember the SQL string for a prepared statement.
71872 */
71873 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
 
71874 if( p==0 ) return;
71875 p->prepFlags = prepFlags;
71876 if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
71877 p->expmask = 0;
71878 }
71879 assert( p->zSql==0 );
71880 p->zSql = sqlite3DbStrNDup(p->db, z, n);
 
71881 }
71882
71883 /*
71884 ** Swap all content between two VDBE structures.
71885 */
@@ -71897,14 +71503,12 @@
71897 pA->pPrev = pB->pPrev;
71898 pB->pPrev = pTmp;
71899 zTmp = pA->zSql;
71900 pA->zSql = pB->zSql;
71901 pB->zSql = zTmp;
 
71902 pB->expmask = pA->expmask;
71903 pB->prepFlags = pA->prepFlags;
71904 memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
71905 pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
71906 }
71907
71908 /*
71909 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71910 ** than its current size. nOp is guaranteed to be less than or equal
@@ -73974,22 +73578,21 @@
73974 ** statement. This is now set at compile time, rather than during
73975 ** execution of the vdbe program so that sqlite3_column_count() can
73976 ** be called on an SQL statement before sqlite3_step().
73977 */
73978 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
 
73979 int n;
73980 sqlite3 *db = p->db;
73981
73982 if( p->nResColumn ){
73983 releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
73984 sqlite3DbFree(db, p->aColName);
73985 }
73986 n = nResColumn*COLNAME_N;
73987 p->nResColumn = (u16)nResColumn;
73988 p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );
73989 if( p->aColName==0 ) return;
73990 initMemArray(p->aColName, n, db, MEM_Null);
73991 }
73992
73993 /*
73994 ** Set the name of the idx'th column to be returned by the SQL statement.
73995 ** zName must be a pointer to a nul terminated string.
@@ -74635,14 +74238,14 @@
74635 sqlite3BeginBenignMalloc();
74636 if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);
74637 sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
74638 sqlite3EndBenignMalloc();
74639 db->bBenignMalloc--;
74640 }else if( db->pErr ){
74641 sqlite3ValueSetNull(db->pErr);
 
74642 }
74643 db->errCode = rc;
74644 return rc;
74645 }
74646
74647 #ifdef SQLITE_ENABLE_SQLLOG
74648 /*
@@ -75546,24 +75149,23 @@
75546 ** comparison function directly */
75547 return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
75548 }else{
75549 int rc;
75550 const void *v1, *v2;
 
75551 Mem c1;
75552 Mem c2;
75553 sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
75554 sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
75555 sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
75556 sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
75557 v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
 
75558 v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
75559 if( (v1==0 || v2==0) ){
75560 if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
75561 rc = 0;
75562 }else{
75563 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
75564 }
75565 sqlite3VdbeMemRelease(&c1);
75566 sqlite3VdbeMemRelease(&c2);
75567 return rc;
75568 }
75569 }
@@ -76344,17 +75946,10 @@
76344 */
76345 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
76346 return v->db;
76347 }
76348
76349 /*
76350 ** Return the SQLITE_PREPARE flags for a Vdbe.
76351 */
76352 SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){
76353 return v->prepFlags;
76354 }
76355
76356 /*
76357 ** Return a pointer to an sqlite3_value structure containing the value bound
76358 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
76359 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
76360 ** constants) to the value before returning it.
@@ -76363,11 +75958,10 @@
76363 */
76364 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
76365 assert( iVar>0 );
76366 if( v ){
76367 Mem *pMem = &v->aVar[iVar-1];
76368 assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
76369 if( 0==(pMem->flags & MEM_Null) ){
76370 sqlite3_value *pRet = sqlite3ValueNew(v->db);
76371 if( pRet ){
76372 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
76373 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76383,11 +75977,10 @@
76383 ** to sqlite3_reoptimize() that re-preparing the statement may result
76384 ** in a better query plan.
76385 */
76386 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
76387 assert( iVar>0 );
76388 assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
76389 if( iVar>=32 ){
76390 v->expmask |= 0x80000000;
76391 }else{
76392 v->expmask |= ((u32)1 << (iVar-1));
76393 }
@@ -76655,11 +76248,11 @@
76655 sqlite3_mutex_enter(mutex);
76656 for(i=0; i<p->nVar; i++){
76657 sqlite3VdbeMemRelease(&p->aVar[i]);
76658 p->aVar[i].flags = MEM_Null;
76659 }
76660 assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
76661 if( p->expmask ){
76662 p->expired = 1;
76663 }
76664 sqlite3_mutex_leave(mutex);
76665 return rc;
@@ -77134,15 +76727,12 @@
77134 */
77135 assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
77136 || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
77137 );
77138 assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
77139 if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
77140 && rc!=SQLITE_ROW
77141 && rc!=SQLITE_DONE
77142 ){
77143 /* If this statement was prepared using saved SQL and an
77144 ** error has occurred, then return the error code in p->rc to the
77145 ** caller. Set the error code in the database handle to the same value.
77146 */
77147 rc = sqlite3VdbeTransferError(p);
77148 }
@@ -77777,11 +77367,11 @@
77777 ** parameter in the WHERE clause might influence the choice of query plan
77778 ** for a statement, then the statement will be automatically recompiled,
77779 ** as if there had been a schema change, on the first sqlite3_step() call
77780 ** following any change to the bindings of that parameter.
77781 */
77782 assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );
77783 if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
77784 p->expired = 1;
77785 }
77786 return SQLITE_OK;
77787 }
@@ -77807,14 +77397,12 @@
77807 pVar = &p->aVar[i-1];
77808 rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
77809 if( rc==SQLITE_OK && encoding!=0 ){
77810 rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
77811 }
77812 if( rc ){
77813 sqlite3Error(p->db, rc);
77814 rc = sqlite3ApiExit(p->db, rc);
77815 }
77816 }
77817 sqlite3_mutex_leave(p->db->mutex);
77818 }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){
77819 xDel((void*)zData);
77820 }
@@ -78043,15 +77631,15 @@
78043 Vdbe *pFrom = (Vdbe*)pFromStmt;
78044 Vdbe *pTo = (Vdbe*)pToStmt;
78045 if( pFrom->nVar!=pTo->nVar ){
78046 return SQLITE_ERROR;
78047 }
78048 assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );
78049 if( pTo->expmask ){
78050 pTo->expired = 1;
78051 }
78052 assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );
78053 if( pFrom->expmask ){
78054 pFrom->expired = 1;
78055 }
78056 return sqlite3TransferBindings(pFromStmt, pToStmt);
78057 }
@@ -78117,23 +77705,12 @@
78117 if( !pStmt ){
78118 (void)SQLITE_MISUSE_BKPT;
78119 return 0;
78120 }
78121 #endif
78122 if( op==SQLITE_STMTSTATUS_MEMUSED ){
78123 sqlite3 *db = pVdbe->db;
78124 sqlite3_mutex_enter(db->mutex);
78125 v = 0;
78126 db->pnBytesFreed = (int*)&v;
78127 sqlite3VdbeClearObject(db, pVdbe);
78128 sqlite3DbFree(db, pVdbe);
78129 db->pnBytesFreed = 0;
78130 sqlite3_mutex_leave(db->mutex);
78131 }else{
78132 v = pVdbe->aCounter[op];
78133 if( resetFlag ) pVdbe->aCounter[op] = 0;
78134 }
78135 return (int)v;
78136 }
78137
78138 /*
78139 ** Return the SQL associated with a prepared statement
@@ -79284,11 +78861,11 @@
79284 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
79285 u8 encoding = ENC(db); /* The database encoding */
79286 int iCompare = 0; /* Result of last comparison */
79287 unsigned nVmStep = 0; /* Number of virtual machine steps */
79288 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
79289 unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
79290 #endif
79291 Mem *aMem = p->aMem; /* Copy of p->aMem */
79292 Mem *pIn1 = 0; /* 1st input operand */
79293 Mem *pIn2 = 0; /* 2nd input operand */
79294 Mem *pIn3 = 0; /* 3rd input operand */
@@ -79316,12 +78893,10 @@
79316 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
79317 if( db->xProgress ){
79318 u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];
79319 assert( 0 < db->nProgressOps );
79320 nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);
79321 }else{
79322 nProgressLimit = 0xffffffff;
79323 }
79324 #endif
79325 #ifdef SQLITE_DEBUG
79326 sqlite3BeginBenignMalloc();
79327 if( p->pc==0
@@ -79495,11 +79070,11 @@
79495 ** of VDBE ops have been executed (either since this invocation of
79496 ** sqlite3VdbeExec() or since last time the progress callback was called).
79497 ** If the progress callback returns non-zero, exit the virtual machine with
79498 ** a return code SQLITE_ABORT.
79499 */
79500 if( nVmStep>=nProgressLimit && db->xProgress!=0 ){
79501 assert( db->nProgressOps!=0 );
79502 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
79503 if( db->xProgress(db->pProgressArg) ){
79504 rc = SQLITE_INTERRUPT;
79505 goto abort_due_to_error;
@@ -80037,11 +79612,11 @@
80037
80038 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
80039 /* Run the progress counter just before returning.
80040 */
80041 if( db->xProgress!=0
80042 && nVmStep>=nProgressLimit
80043 && db->xProgress(db->pProgressArg)!=0
80044 ){
80045 rc = SQLITE_INTERRUPT;
80046 goto abort_due_to_error;
80047 }
@@ -81208,13 +80783,11 @@
81208 Mem *pReg; /* PseudoTable input register */
81209
81210 pC = p->apCsr[pOp->p1];
81211 p2 = pOp->p2;
81212
81213 /* If the cursor cache is stale (meaning it is not currently point at
81214 ** the correct row) then bring it up-to-date by doing the necessary
81215 ** B-Tree seek. */
81216 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
81217 if( rc ) goto abort_due_to_error;
81218
81219 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
81220 pDest = &aMem[pOp->p3];
@@ -82692,35 +82265,21 @@
82692 sqlite3_search_count++;
82693 #endif
82694 if( oc>=OP_SeekGE ){ assert( oc==OP_SeekGE || oc==OP_SeekGT );
82695 if( res<0 || (res==0 && oc==OP_SeekGT) ){
82696 res = 0;
82697 rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
82698 if( rc!=SQLITE_OK ){
82699 if( rc==SQLITE_DONE ){
82700 rc = SQLITE_OK;
82701 res = 1;
82702 }else{
82703 goto abort_due_to_error;
82704 }
82705 }
82706 }else{
82707 res = 0;
82708 }
82709 }else{
82710 assert( oc==OP_SeekLT || oc==OP_SeekLE );
82711 if( res>0 || (res==0 && oc==OP_SeekLT) ){
82712 res = 0;
82713 rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);
82714 if( rc!=SQLITE_OK ){
82715 if( rc==SQLITE_DONE ){
82716 rc = SQLITE_OK;
82717 res = 1;
82718 }else{
82719 goto abort_due_to_error;
82720 }
82721 }
82722 }else{
82723 /* res might be negative because the table is empty. Check to
82724 ** see if this is the case.
82725 */
82726 res = sqlite3BtreeEof(pC->uc.pCursor);
@@ -83822,14 +83381,16 @@
83822 ** invoked. This opcode advances the cursor to the next sorted
83823 ** record, or jumps to P2 if there are no more sorted records.
83824 */
83825 case OP_SorterNext: { /* jump */
83826 VdbeCursor *pC;
 
83827
83828 pC = p->apCsr[pOp->p1];
83829 assert( isSorter(pC) );
83830 rc = sqlite3VdbeSorterNext(db, pC);
 
83831 goto next_tail;
83832 case OP_PrevIfOpen: /* jump */
83833 case OP_NextIfOpen: /* jump */
83834 if( p->apCsr[pOp->p1]==0 ) break;
83835 /* Fall through */
@@ -83836,13 +83397,16 @@
83836 case OP_Prev: /* jump */
83837 case OP_Next: /* jump */
83838 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
83839 assert( pOp->p5<ArraySize(p->aCounter) );
83840 pC = p->apCsr[pOp->p1];
 
83841 assert( pC!=0 );
83842 assert( pC->deferredMoveto==0 );
83843 assert( pC->eCurType==CURTYPE_BTREE );
 
 
83844 assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
83845 assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
83846 assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
83847 assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
83848
@@ -83853,25 +83417,25 @@
83853 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
83854 assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
83855 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
83856 || pC->seekOp==OP_Last );
83857
83858 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
83859 next_tail:
83860 pC->cacheStatus = CACHE_STALE;
83861 VdbeBranchTaken(rc==SQLITE_OK,2);
83862 if( rc==SQLITE_OK ){
 
83863 pC->nullRow = 0;
83864 p->aCounter[pOp->p5]++;
83865 #ifdef SQLITE_TEST
83866 sqlite3_search_count++;
83867 #endif
83868 goto jump_to_p2_and_check_for_interrupt;
 
 
83869 }
83870 if( rc!=SQLITE_DONE ) goto abort_due_to_error;
83871 rc = SQLITE_OK;
83872 pC->nullRow = 1;
83873 goto check_for_interrupt;
83874 }
83875
83876 /* Opcode: IdxInsert P1 P2 P3 P4 P5
83877 ** Synopsis: key=r[P2]
@@ -83978,12 +83542,12 @@
83978 pC->cacheStatus = CACHE_STALE;
83979 pC->seekResult = 0;
83980 break;
83981 }
83982
83983 /* Opcode: DeferredSeek P1 * P3 P4 *
83984 ** Synopsis: Move P3 to P1.rowid if needed
83985 **
83986 ** P1 is an open index cursor and P3 is a cursor on the corresponding
83987 ** table. This opcode does a deferred seek of the P3 table cursor
83988 ** to the row that corresponds to the current row of P1.
83989 **
@@ -84006,15 +83570,15 @@
84006 ** the end of the index key pointed to by cursor P1. This integer should be
84007 ** the rowid of the table entry to which this index entry points.
84008 **
84009 ** See also: Rowid, MakeRecord.
84010 */
84011 case OP_DeferredSeek:
84012 case OP_IdxRowid: { /* out2 */
84013 VdbeCursor *pC; /* The P1 index cursor */
84014 VdbeCursor *pTabCur; /* The P2 table cursor (OP_DeferredSeek only) */
84015 i64 rowid; /* Rowid that P1 current points to */
84016
84017 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
84018 pC = p->apCsr[pOp->p1];
84019 assert( pC!=0 );
84020 assert( pC->eCurType==CURTYPE_BTREE );
@@ -84036,11 +83600,11 @@
84036 rowid = 0; /* Not needed. Only used to silence a warning. */
84037 rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);
84038 if( rc!=SQLITE_OK ){
84039 goto abort_due_to_error;
84040 }
84041 if( pOp->opcode==OP_DeferredSeek ){
84042 assert( pOp->p3>=0 && pOp->p3<p->nCursor );
84043 pTabCur = p->apCsr[pOp->p3];
84044 assert( pTabCur!=0 );
84045 assert( pTabCur->eCurType==CURTYPE_BTREE );
84046 assert( pTabCur->uc.pCursor!=0 );
@@ -85282,11 +84846,11 @@
85282 ** P4 contains a pointer to the name of the table being locked. This is only
85283 ** used to generate an error message if the lock cannot be obtained.
85284 */
85285 case OP_TableLock: {
85286 u8 isWriteLock = (u8)pOp->p3;
85287 if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){
85288 int p1 = pOp->p1;
85289 assert( p1>=0 && p1<db->nDb );
85290 assert( DbMaskTest(p->btreeMask, p1) );
85291 assert( isWriteLock==0 || isWriteLock==1 );
85292 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85790,11 +85354,10 @@
85790 if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
85791 }
85792 pOp->p1 = 0;
85793 }
85794 pOp->p1++;
85795 p->aCounter[SQLITE_STMTSTATUS_RUN]++;
85796 goto jump_to_p2;
85797 }
85798
85799 #ifdef SQLITE_ENABLE_CURSOR_HINTS
85800 /* Opcode: CursorHint P1 * * P4 *
@@ -87264,13 +86827,13 @@
87264
87265 int n1;
87266 int n2;
87267 int res;
87268
87269 getVarint32(&p1[1], n1);
87270 getVarint32(&p2[1], n2);
87271 res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);
87272 if( res==0 ){
87273 res = n1 - n2;
87274 }
87275
87276 if( res==0 ){
@@ -89061,17 +88624,13 @@
89061 vdbeSorterRewindDebug("rewinddone");
89062 return rc;
89063 }
89064
89065 /*
89066 ** Advance to the next element in the sorter. Return value:
89067 **
89068 ** SQLITE_OK success
89069 ** SQLITE_DONE end of data
89070 ** otherwise some kind of error.
89071 */
89072 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr){
89073 VdbeSorter *pSorter;
89074 int rc; /* Return code */
89075
89076 assert( pCsr->eCurType==CURTYPE_SORTER );
89077 pSorter = pCsr->uc.pSorter;
@@ -89081,26 +88640,25 @@
89081 assert( pSorter->bUseThreads==0 || pSorter->pReader );
89082 assert( pSorter->bUseThreads==1 || pSorter->pMerger );
89083 #if SQLITE_MAX_WORKER_THREADS>0
89084 if( pSorter->bUseThreads ){
89085 rc = vdbePmaReaderNext(pSorter->pReader);
89086 if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;
89087 }else
89088 #endif
89089 /*if( !pSorter->bUseThreads )*/ {
89090 int res = 0;
89091 assert( pSorter->pMerger!=0 );
89092 assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );
89093 rc = vdbeMergeEngineStep(pSorter->pMerger, &res);
89094 if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;
89095 }
89096 }else{
89097 SorterRecord *pFree = pSorter->list.pList;
89098 pSorter->list.pList = pFree->u.pNext;
89099 pFree->u.pNext = 0;
89100 if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);
89101 rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;
 
89102 }
89103 return rc;
89104 }
89105
89106 /*
@@ -89750,37 +89308,44 @@
89750 ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
89751 ** on the compound select chain, p->pPrior.
89752 **
89753 ** If it is not NULL, the xSelectCallback() callback is invoked before
89754 ** the walk of the expressions and FROM clause. The xSelectCallback2()
89755 ** method is invoked following the walk of the expressions and FROM clause,
89756 ** but only if both xSelectCallback and xSelectCallback2 are both non-NULL
89757 ** and if the expressions and FROM clause both return WRC_Continue;
89758 **
89759 ** Return WRC_Continue under normal conditions. Return WRC_Abort if
89760 ** there is an abort request.
89761 **
89762 ** If the Walker does not have an xSelectCallback() then this routine
89763 ** is a no-op returning WRC_Continue.
89764 */
89765 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
89766 int rc;
89767 if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
89768 do{
89769 rc = pWalker->xSelectCallback(pWalker, p);
89770 if( rc ) return rc & WRC_Abort;
 
 
 
 
 
 
89771 if( sqlite3WalkSelectExpr(pWalker, p)
89772 || sqlite3WalkSelectFrom(pWalker, p)
89773 ){
 
89774 return WRC_Abort;
89775 }
89776 if( pWalker->xSelectCallback2 ){
89777 pWalker->xSelectCallback2(pWalker, p);
89778 }
89779 p = p->pPrior;
89780 }while( p!=0 );
89781 return WRC_Continue;
 
89782 }
89783
89784 /************** End of walker.c **********************************************/
89785 /************** Begin file resolve.c *****************************************/
89786 /*
@@ -90693,11 +90258,11 @@
90693 /* Try to match the ORDER BY expression against an expression
90694 ** in the result set. Return an 1-based index of the matching
90695 ** result-set entry.
90696 */
90697 for(i=0; i<pEList->nExpr; i++){
90698 if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){
90699 return i+1;
90700 }
90701 }
90702
90703 /* If no match, return 0. */
@@ -90927,11 +90492,11 @@
90927 pItem->u.x.iOrderByCol = 0;
90928 if( sqlite3ResolveExprNames(pNC, pE) ){
90929 return 1;
90930 }
90931 for(j=0; j<pSelect->pEList->nExpr; j++){
90932 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90933 pItem->u.x.iOrderByCol = j+1;
90934 }
90935 }
90936 }
90937 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -91213,33 +90778,41 @@
91213 Expr *pExpr /* The expression to be analyzed. */
91214 ){
91215 u16 savedHasAgg;
91216 Walker w;
91217
91218 if( pExpr==0 ) return SQLITE_OK;
 
 
 
 
 
 
 
 
 
91219 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);
91220 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);
91221 w.pParse = pNC->pParse;
91222 w.xExprCallback = resolveExprStep;
91223 w.xSelectCallback = resolveSelectStep;
91224 w.xSelectCallback2 = 0;
 
 
91225 w.u.pNC = pNC;
91226 #if SQLITE_MAX_EXPR_DEPTH>0
91227 w.pParse->nHeight += pExpr->nHeight;
91228 if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
91229 return SQLITE_ERROR;
91230 }
91231 #endif
91232 sqlite3WalkExpr(&w, pExpr);
91233 #if SQLITE_MAX_EXPR_DEPTH>0
91234 w.pParse->nHeight -= pExpr->nHeight;
91235 #endif
 
 
 
91236 if( pNC->ncFlags & NC_HasAgg ){
91237 ExprSetProperty(pExpr, EP_Agg);
91238 }
91239 pNC->ncFlags |= savedHasAgg;
91240 return pNC->nErr>0 || w.pParse->nErr>0;
91241 }
91242
91243 /*
91244 ** Resolve all names for all expression in an expression list. This is
91245 ** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -91276,13 +90849,13 @@
91276 NameContext *pOuterNC /* Name context for parent SELECT statement */
91277 ){
91278 Walker w;
91279
91280 assert( p!=0 );
 
91281 w.xExprCallback = resolveExprStep;
91282 w.xSelectCallback = resolveSelectStep;
91283 w.xSelectCallback2 = 0;
91284 w.pParse = pParse;
91285 w.u.pNC = pOuterNC;
91286 sqlite3WalkSelect(&w, p);
91287 }
91288
@@ -92811,13 +92384,11 @@
92811 }
92812 pList = pNew;
92813 pList->nAlloc *= 2;
92814 }
92815 pItem = &pList->a[pList->nExpr++];
92816 assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) );
92817 assert( offsetof(struct ExprList_item,pExpr)==0 );
92818 memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName));
92819 pItem->pExpr = pExpr;
92820 return pList;
92821
92822 no_mem:
92823 /* Avoid leaking memory if malloc has failed. */
@@ -93097,16 +92668,14 @@
93097 pWalker->eCode = 0;
93098 return WRC_Abort;
93099 }
93100 static int exprIsConst(Expr *p, int initFlag, int iCur){
93101 Walker w;
 
93102 w.eCode = initFlag;
93103 w.xExprCallback = exprNodeIsConstant;
93104 w.xSelectCallback = selectNodeIsConstant;
93105 #ifdef SQLITE_DEBUG
93106 w.xSelectCallback2 = sqlite3SelectWalkAssert2;
93107 #endif
93108 w.u.iCur = iCur;
93109 sqlite3WalkExpr(&w, p);
93110 return w.eCode;
93111 }
93112
@@ -93152,11 +92721,11 @@
93152
93153 /* Check if pExpr is identical to any GROUP BY term. If so, consider
93154 ** it constant. */
93155 for(i=0; i<pGroupBy->nExpr; i++){
93156 Expr *p = pGroupBy->a[i].pExpr;
93157 if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){
93158 CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
93159 if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
93160 return WRC_Prune;
93161 }
93162 }
@@ -93190,13 +92759,13 @@
93190 ** optimization, so we take the easy way out and simply require the
93191 ** GROUP BY to use the BINARY collating sequence.
93192 */
93193 SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){
93194 Walker w;
 
93195 w.eCode = 1;
93196 w.xExprCallback = exprNodeIsConstantOrGroupBy;
93197 w.xSelectCallback = 0;
93198 w.u.pGroupBy = pGroupBy;
93199 w.pParse = pParse;
93200 sqlite3WalkExpr(&w, p);
93201 return w.eCode;
93202 }
@@ -93220,16 +92789,14 @@
93220 ** Walk an expression tree. Return 1 if the expression contains a
93221 ** subquery of some kind. Return 0 if there are no subqueries.
93222 */
93223 SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){
93224 Walker w;
 
93225 w.eCode = 1;
93226 w.xExprCallback = sqlite3ExprWalkNoop;
93227 w.xSelectCallback = selectNodeIsConstant;
93228 #ifdef SQLITE_DEBUG
93229 w.xSelectCallback2 = sqlite3SelectWalkAssert2;
93230 #endif
93231 sqlite3WalkExpr(&w, p);
93232 return w.eCode==0;
93233 }
93234 #endif
93235
@@ -95428,11 +94995,11 @@
95428 p = pParse->pConstExpr;
95429 if( regDest<0 && p ){
95430 struct ExprList_item *pItem;
95431 int i;
95432 for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95433 if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){
95434 return pItem->u.iConstExprReg;
95435 }
95436 }
95437 }
95438 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95983,45 +95550,10 @@
95983 sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
95984 }
95985 sqlite3ExprDelete(db, pCopy);
95986 }
95987
95988 /*
95989 ** Expression pVar is guaranteed to be an SQL variable. pExpr may be any
95990 ** type of expression.
95991 **
95992 ** If pExpr is a simple SQL value - an integer, real, string, blob
95993 ** or NULL value - then the VDBE currently being prepared is configured
95994 ** to re-prepare each time a new value is bound to variable pVar.
95995 **
95996 ** Additionally, if pExpr is a simple SQL value and the value is the
95997 ** same as that currently bound to variable pVar, non-zero is returned.
95998 ** Otherwise, if the values are not the same or if pExpr is not a simple
95999 ** SQL value, zero is returned.
96000 */
96001 static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){
96002 int res = 0;
96003 int iVar;
96004 sqlite3_value *pL, *pR = 0;
96005
96006 sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
96007 if( pR ){
96008 iVar = pVar->iColumn;
96009 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
96010 pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);
96011 if( pL ){
96012 if( sqlite3_value_type(pL)==SQLITE_TEXT ){
96013 sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
96014 }
96015 res = 0==sqlite3MemCompare(pL, pR, 0);
96016 }
96017 sqlite3ValueFree(pR);
96018 sqlite3ValueFree(pL);
96019 }
96020
96021 return res;
96022 }
96023
96024 /*
96025 ** Do a deep comparison of two expression trees. Return 0 if the two
96026 ** expressions are completely identical. Return 1 if they differ only
96027 ** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -96040,38 +95572,28 @@
96040 ** expressions are the same. But if you get a 0 or 1 return, then you
96041 ** can be sure the expressions are the same. In the places where
96042 ** this routine is used, it does not hurt to get an extra 2 - that
96043 ** just might result in some slightly slower code. But returning
96044 ** an incorrect 0 or 1 could lead to a malfunction.
96045 **
96046 ** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
96047 ** pParse->pReprepare can be matched against literals in pB. The
96048 ** pParse->pVdbe->expmask bitmask is updated for each variable referenced.
96049 ** If pParse is NULL (the normal case) then any TK_VARIABLE term in
96050 ** Argument pParse should normally be NULL. If it is not NULL and pA or
96051 ** pB causes a return value of 2.
96052 */
96053 SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
96054 u32 combinedFlags;
96055 if( pA==0 || pB==0 ){
96056 return pB==pA ? 0 : 2;
96057 }
96058 if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){
96059 return 0;
96060 }
96061 combinedFlags = pA->flags | pB->flags;
96062 if( combinedFlags & EP_IntValue ){
96063 if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
96064 return 0;
96065 }
96066 return 2;
96067 }
96068 if( pA->op!=pB->op ){
96069 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){
96070 return 1;
96071 }
96072 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){
96073 return 1;
96074 }
96075 return 2;
96076 }
96077 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -96082,12 +95604,12 @@
96082 }
96083 }
96084 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
96085 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
96086 if( combinedFlags & EP_xIsSelect ) return 2;
96087 if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
96088 if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
96089 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
96090 if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
96091 if( pA->iColumn!=pB->iColumn ) return 2;
96092 if( pA->iTable!=pB->iTable
96093 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -96118,21 +95640,21 @@
96118 if( pA->nExpr!=pB->nExpr ) return 1;
96119 for(i=0; i<pA->nExpr; i++){
96120 Expr *pExprA = pA->a[i].pExpr;
96121 Expr *pExprB = pB->a[i].pExpr;
96122 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
96123 if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;
96124 }
96125 return 0;
96126 }
96127
96128 /*
96129 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
96130 ** are ignored.
96131 */
96132 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
96133 return sqlite3ExprCompare(0,
96134 sqlite3ExprSkipCollate(pA),
96135 sqlite3ExprSkipCollate(pB),
96136 iTab);
96137 }
96138
@@ -96150,33 +95672,28 @@
96150 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
96151 **
96152 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
96153 ** Expr.iTable<0 then assume a table number given by iTab.
96154 **
96155 ** If pParse is not NULL, then the values of bound variables in pE1 are
96156 ** compared against literal values in pE2 and pParse->pVdbe->expmask is
96157 ** modified to record which bound variables are referenced. If pParse
96158 ** is NULL, then false will be returned if pE1 contains any bound variables.
96159 **
96160 ** When in doubt, return false. Returning true might give a performance
96161 ** improvement. Returning false might cause a performance reduction, but
96162 ** it will always give the correct answer and is hence always safe.
96163 */
96164 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
96165 if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){
96166 return 1;
96167 }
96168 if( pE2->op==TK_OR
96169 && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)
96170 || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )
96171 ){
96172 return 1;
96173 }
96174 if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
96175 Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
96176 testcase( pX!=pE1->pLeft );
96177 if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
96178 }
96179 return 0;
96180 }
96181
96182 /*
@@ -96280,12 +95797,12 @@
96280 */
96281 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
96282 Walker w;
96283 struct SrcCount cnt;
96284 assert( pExpr->op==TK_AGG_FUNCTION );
 
96285 w.xExprCallback = exprSrcCount;
96286 w.xSelectCallback = 0;
96287 w.u.pSrcCount = &cnt;
96288 cnt.pSrc = pSrcList;
96289 cnt.nThis = 0;
96290 cnt.nOther = 0;
96291 sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -96413,11 +95930,11 @@
96413 /* Check to see if pExpr is a duplicate of another aggregate
96414 ** function that is already in the pAggInfo structure
96415 */
96416 struct AggInfo_func *pItem = pAggInfo->aFunc;
96417 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
96418 if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){
96419 break;
96420 }
96421 }
96422 if( i>=pAggInfo->nFunc ){
96423 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96453,18 +95970,14 @@
96453 }
96454 }
96455 return WRC_Continue;
96456 }
96457 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
 
96458 UNUSED_PARAMETER(pSelect);
96459 pWalker->walkerDepth++;
96460 return WRC_Continue;
96461 }
96462 static void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){
96463 UNUSED_PARAMETER(pSelect);
96464 pWalker->walkerDepth--;
96465 }
96466
96467 /*
96468 ** Analyze the pExpr expression looking for aggregate functions and
96469 ** for variables that need to be added to AggInfo object that pNC->pAggInfo
96470 ** points to. Additional entries are made on the AggInfo object as
@@ -96473,14 +95986,13 @@
96473 ** This routine should only be called after the expression has been
96474 ** analyzed by sqlite3ResolveExprNames().
96475 */
96476 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
96477 Walker w;
 
96478 w.xExprCallback = analyzeAggregate;
96479 w.xSelectCallback = analyzeAggregatesInSelect;
96480 w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
96481 w.walkerDepth = 0;
96482 w.u.pNC = pNC;
96483 assert( pNC->pSrcList!=0 );
96484 sqlite3WalkExpr(&w, pExpr);
96485 }
96486
@@ -96970,11 +96482,11 @@
96970 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
96971 **
96972 ** Or, if zName is not a system table, zero is returned.
96973 */
96974 static int isSystemTable(Parse *pParse, const char *zName){
96975 if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96976 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
96977 return 1;
96978 }
96979 return 0;
96980 }
@@ -99389,12 +98901,11 @@
99389 const char *zName;
99390 const char *zFile;
99391 char *zPath = 0;
99392 char *zErr = 0;
99393 unsigned int flags;
99394 Db *aNew; /* New array of Db pointers */
99395 Db *pNew; /* Db object for the newly attached database */
99396 char *zErrDyn = 0;
99397 sqlite3_vfs *pVfs;
99398
99399 UNUSED_PARAMETER(NotUsed);
99400
@@ -99438,12 +98949,12 @@
99438 }else{
99439 aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
99440 if( aNew==0 ) return;
99441 }
99442 db->aDb = aNew;
99443 pNew = &db->aDb[db->nDb];
99444 memset(pNew, 0, sizeof(*pNew));
99445
99446 /* Open the database file. If the btree is successfully opened, use
99447 ** it to obtain the database schema. At this point the schema may
99448 ** or may not be initialized.
99449 */
@@ -99455,41 +98966,41 @@
99455 sqlite3_free(zErr);
99456 return;
99457 }
99458 assert( pVfs );
99459 flags |= SQLITE_OPEN_MAIN_DB;
99460 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
99461 sqlite3_free( zPath );
99462 db->nDb++;
99463 db->skipBtreeMutex = 0;
99464 if( rc==SQLITE_CONSTRAINT ){
99465 rc = SQLITE_ERROR;
99466 zErrDyn = sqlite3MPrintf(db, "database is already attached");
99467 }else if( rc==SQLITE_OK ){
99468 Pager *pPager;
99469 pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);
99470 if( !pNew->pSchema ){
99471 rc = SQLITE_NOMEM_BKPT;
99472 }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){
99473 zErrDyn = sqlite3MPrintf(db,
99474 "attached databases must use the same text encoding as main database");
99475 rc = SQLITE_ERROR;
99476 }
99477 sqlite3BtreeEnter(pNew->pBt);
99478 pPager = sqlite3BtreePager(pNew->pBt);
99479 sqlite3PagerLockingMode(pPager, db->dfltLockMode);
99480 sqlite3BtreeSecureDelete(pNew->pBt,
99481 sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
99482 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
99483 sqlite3BtreeSetPagerFlags(pNew->pBt,
99484 PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
99485 #endif
99486 sqlite3BtreeLeave(pNew->pBt);
99487 }
99488 pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
99489 pNew->zDbSName = sqlite3DbStrDup(db, zName);
99490 if( rc==SQLITE_OK && pNew->zDbSName==0 ){
99491 rc = SQLITE_NOMEM_BKPT;
99492 }
99493
99494
99495 #ifdef SQLITE_HAS_CODEC
@@ -101122,15 +100633,11 @@
101122 }
101123 pTable->zName = zName;
101124 pTable->iPKey = -1;
101125 pTable->pSchema = db->aDb[iDb].pSchema;
101126 pTable->nTabRef = 1;
101127 #ifdef SQLITE_DEFAULT_ROWEST
101128 pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);
101129 #else
101130 pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
101131 #endif
101132 assert( pParse->pNewTable==0 );
101133 pParse->pNewTable = pTable;
101134
101135 /* If this is the magic sqlite_sequence table used by autoincrement,
101136 ** then record a pointer to this table in the main database structure
@@ -104368,13 +103875,11 @@
104368 for(j=0; j<pIdx->nKeyCol; j++){
104369 char *zCol;
104370 assert( pIdx->aiColumn[j]>=0 );
104371 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
104372 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
104373 sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
104374 sqlite3StrAccumAppend(&errMsg, ".", 1);
104375 sqlite3StrAccumAppendAll(&errMsg, zCol);
104376 }
104377 }
104378 zErr = sqlite3StrAccumFinish(&errMsg);
104379 sqlite3HaltConstraint(pParse,
104380 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -105479,11 +104984,11 @@
105479 ** It is easier just to erase the whole table. Prior to version 3.6.5,
105480 ** this optimization caused the row change count (the value returned by
105481 ** API function sqlite3_count_changes) to be set incorrectly.
105482 **
105483 ** The "rcauth==SQLITE_OK" terms is the
105484 ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
105485 ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but
105486 ** the truncate optimization is disabled and all rows are deleted
105487 ** individually.
105488 */
105489 if( rcauth==SQLITE_OK
@@ -105585,11 +105090,11 @@
105585 sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,
105586 sqlite3IndexAffinityStr(pParse->db, pPk), nPk);
105587 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);
105588 }else{
105589 /* Add the rowid of the row to be deleted to the RowSet */
105590 nKey = 1; /* OP_DeferredSeek always uses a single rowid */
105591 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);
105592 }
105593 }
105594
105595 /* If this DELETE cannot use the ONEPASS strategy, this is the
@@ -108539,16 +108044,14 @@
108539 sqlite3ResolveExprNames(&sNameContext, pWhere);
108540
108541 /* Create VDBE to loop through the entries in pSrc that match the WHERE
108542 ** clause. For each row found, increment either the deferred or immediate
108543 ** foreign key constraint counter. */
108544 if( pParse->nErr==0 ){
108545 pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
108546 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
108547 if( pWInfo ){
108548 sqlite3WhereEnd(pWInfo);
108549 }
108550 }
108551
108552 /* Clean up the WHERE clause constructed above. */
108553 sqlite3ExprDelete(db, pWhere);
108554 if( iFkIfZero ){
@@ -109851,14 +109354,14 @@
109851 Trigger *pTrigger; /* List of triggers on pTab, if required */
109852 int tmask; /* Mask of trigger times */
109853 #endif
109854
109855 db = pParse->db;
 
109856 if( pParse->nErr || db->mallocFailed ){
109857 goto insert_cleanup;
109858 }
109859 dest.iSDParm = 0; /* Suppress a harmless compiler warning */
109860
109861 /* If the Select object is really just a simple VALUES() list with a
109862 ** single row (the common case) then keep that one row of values
109863 ** and discard the other (unused) parts of the pSelect object
109864 */
@@ -111228,11 +110731,11 @@
111228 if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
111229 return 0; /* Different columns indexed */
111230 }
111231 if( pSrc->aiColumn[i]==XN_EXPR ){
111232 assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
111233 if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,
111234 pDest->aColExpr->a[i].pExpr, -1)!=0 ){
111235 return 0; /* Different expressions in the index */
111236 }
111237 }
111238 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111240,11 +110743,11 @@
111240 }
111241 if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
111242 return 0; /* Different collating sequences */
111243 }
111244 }
111245 if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
111246 return 0; /* Different WHERE clauses */
111247 }
111248
111249 /* If no test above fails then the indices must be compatible */
111250 return 1;
@@ -111720,12 +111223,15 @@
111720 if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111721 sqlite3DbFree(db, azCols);
111722
111723 rc = sqlite3ApiExit(db, rc);
111724 if( rc!=SQLITE_OK && pzErrMsg ){
111725 *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));
111726 if( *pzErrMsg==0 ){
 
 
 
111727 rc = SQLITE_NOMEM_BKPT;
111728 sqlite3Error(db, SQLITE_NOMEM);
111729 }
111730 }else if( pzErrMsg ){
111731 *pzErrMsg = 0;
@@ -113398,11 +112904,11 @@
113398 /* iArg: */ 0 },
113399 #endif
113400 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113401 {/* zName: */ "foreign_key_check",
113402 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
113403 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
113404 /* ColNames: */ 39, 4,
113405 /* iArg: */ 0 },
113406 #endif
113407 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
113408 {/* zName: */ "foreign_key_list",
@@ -113485,11 +112991,11 @@
113485 /* iArg: */ 1 },
113486 #endif
113487 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
113488 {/* zName: */ "integrity_check",
113489 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
113490 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
113491 /* ColNames: */ 0, 0,
113492 /* iArg: */ 0 },
113493 #endif
113494 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113495 {/* zName: */ "journal_mode",
@@ -113580,20 +113086,20 @@
113580 /* iArg: */ SQLITE_QueryOnly },
113581 #endif
113582 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
113583 {/* zName: */ "quick_check",
113584 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
113585 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
113586 /* ColNames: */ 0, 0,
113587 /* iArg: */ 0 },
113588 #endif
113589 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113590 {/* zName: */ "read_uncommitted",
113591 /* ePragTyp: */ PragTyp_FLAG,
113592 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113593 /* ColNames: */ 0, 0,
113594 /* iArg: */ SQLITE_ReadUncommit },
113595 {/* zName: */ "recursive_triggers",
113596 /* ePragTyp: */ PragTyp_FLAG,
113597 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113598 /* ColNames: */ 0, 0,
113599 /* iArg: */ SQLITE_RecTriggers },
@@ -113741,11 +113247,11 @@
113741 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113742 {/* zName: */ "writable_schema",
113743 /* ePragTyp: */ PragTyp_FLAG,
113744 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113745 /* ColNames: */ 0, 0,
113746 /* iArg: */ SQLITE_WriteSchema },
113747 #endif
113748 };
113749 /* Number of pragmas: 60 on by default, 74 total. */
113750
113751 /************** End of pragma.h **********************************************/
@@ -116183,11 +115689,11 @@
116183 InitData *pData, /* Initialization context */
116184 const char *zObj, /* Object being parsed at the point of error */
116185 const char *zExtra /* Error information */
116186 ){
116187 sqlite3 *db = pData->db;
116188 if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
116189 char *z;
116190 if( zObj==0 ) zObj = "?";
116191 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
116192 if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
116193 sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116470,12 +115976,12 @@
116470 }
116471 if( db->mallocFailed ){
116472 rc = SQLITE_NOMEM_BKPT;
116473 sqlite3ResetAllSchemasOfConnection(db);
116474 }
116475 if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
116476 /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
116477 ** the schema loaded, even if errors occurred. In this situation the
116478 ** current sqlite3_prepare() operation will fail, but the following one
116479 ** will attempt to compile the supplied statement against whatever subset
116480 ** of the schema was loaded before the error occurred. The primary
116481 ** purpose of this is to allow access to the sqlite_master table
@@ -116671,11 +116177,11 @@
116671 */
116672 static int sqlite3Prepare(
116673 sqlite3 *db, /* Database handle. */
116674 const char *zSql, /* UTF-8 encoded SQL statement. */
116675 int nBytes, /* Length of zSql in bytes. */
116676 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116677 Vdbe *pReprepare, /* VM being reprepared */
116678 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116679 const char **pzTail /* OUT: End of parsed string */
116680 ){
116681 char *zErrMsg = 0; /* Error message */
@@ -116688,18 +116194,10 @@
116688 sParse.pReprepare = pReprepare;
116689 assert( ppStmt && *ppStmt==0 );
116690 /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116691 assert( sqlite3_mutex_held(db->mutex) );
116692
116693 /* For a long-term use prepared statement avoid the use of
116694 ** lookaside memory.
116695 */
116696 if( prepFlags & SQLITE_PREPARE_PERSISTENT ){
116697 sParse.disableLookaside++;
116698 db->lookaside.bDisable++;
116699 }
116700
116701 /* Check to verify that it is possible to get a read lock on all
116702 ** database schemas. The inability to get a read lock indicates that
116703 ** some other database connection is holding a write-lock, which in
116704 ** turn means that the other connection has made uncommitted changes
116705 ** to the schema.
@@ -116727,11 +116225,11 @@
116727 assert( sqlite3BtreeHoldsMutex(pBt) );
116728 rc = sqlite3BtreeSchemaLocked(pBt);
116729 if( rc ){
116730 const char *zDb = db->aDb[i].zDbSName;
116731 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116732 testcase( db->flags & SQLITE_ReadUncommit );
116733 goto end_prepare;
116734 }
116735 }
116736 }
116737
@@ -116795,11 +116293,12 @@
116795 }
116796 }
116797 #endif
116798
116799 if( db->init.busy==0 ){
116800 sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);
 
116801 }
116802 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116803 sqlite3VdbeFinalize(sParse.pVdbe);
116804 assert(!(*ppStmt));
116805 }else{
@@ -116829,11 +116328,11 @@
116829 }
116830 static int sqlite3LockAndPrepare(
116831 sqlite3 *db, /* Database handle. */
116832 const char *zSql, /* UTF-8 encoded SQL statement. */
116833 int nBytes, /* Length of zSql in bytes. */
116834 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116835 Vdbe *pOld, /* VM being reprepared */
116836 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116837 const char **pzTail /* OUT: End of parsed string */
116838 ){
116839 int rc;
@@ -116845,14 +116344,14 @@
116845 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116846 return SQLITE_MISUSE_BKPT;
116847 }
116848 sqlite3_mutex_enter(db->mutex);
116849 sqlite3BtreeEnterAll(db);
116850 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116851 if( rc==SQLITE_SCHEMA ){
116852 sqlite3_finalize(*ppStmt);
116853 rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
116854 }
116855 sqlite3BtreeLeaveAll(db);
116856 sqlite3_mutex_leave(db->mutex);
116857 assert( rc==SQLITE_OK || *ppStmt==0 );
116858 return rc;
@@ -116869,19 +116368,17 @@
116869 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116870 int rc;
116871 sqlite3_stmt *pNew;
116872 const char *zSql;
116873 sqlite3 *db;
116874 u8 prepFlags;
116875
116876 assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116877 zSql = sqlite3_sql((sqlite3_stmt *)p);
116878 assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116879 db = sqlite3VdbeDb(p);
116880 assert( sqlite3_mutex_held(db->mutex) );
116881 prepFlags = sqlite3VdbePrepareFlags(p);
116882 rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);
116883 if( rc ){
116884 if( rc==SQLITE_NOMEM ){
116885 sqlite3OomFault(db);
116886 }
116887 assert( pNew==0 );
@@ -116923,27 +116420,11 @@
116923 int nBytes, /* Length of zSql in bytes. */
116924 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116925 const char **pzTail /* OUT: End of parsed string */
116926 ){
116927 int rc;
116928 rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,
116929 ppStmt,pzTail);
116930 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116931 return rc;
116932 }
116933 SQLITE_API int sqlite3_prepare_v3(
116934 sqlite3 *db, /* Database handle. */
116935 const char *zSql, /* UTF-8 encoded SQL statement. */
116936 int nBytes, /* Length of zSql in bytes. */
116937 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116938 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116939 const char **pzTail /* OUT: End of parsed string */
116940 ){
116941 int rc;
116942 rc = sqlite3LockAndPrepare(db,zSql,nBytes,
116943 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
116944 0,ppStmt,pzTail);
116945 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116946 return rc;
116947 }
116948
116949
@@ -116953,11 +116434,11 @@
116953 */
116954 static int sqlite3Prepare16(
116955 sqlite3 *db, /* Database handle. */
116956 const void *zSql, /* UTF-16 encoded SQL statement. */
116957 int nBytes, /* Length of zSql in bytes. */
116958 u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
116959 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116960 const void **pzTail /* OUT: End of parsed string */
116961 ){
116962 /* This function currently works by first transforming the UTF-16
116963 ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116981,11 +116462,11 @@
116981 nBytes = sz;
116982 }
116983 sqlite3_mutex_enter(db->mutex);
116984 zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116985 if( zSql8 ){
116986 rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);
116987 }
116988
116989 if( zTail8 && pzTail ){
116990 /* If sqlite3_prepare returns a tail pointer, we calculate the
116991 ** equivalent pointer into the UTF-16 string by counting the unicode
@@ -117027,26 +116508,11 @@
117027 int nBytes, /* Length of zSql in bytes. */
117028 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117029 const void **pzTail /* OUT: End of parsed string */
117030 ){
117031 int rc;
117032 rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);
117033 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117034 return rc;
117035 }
117036 SQLITE_API int sqlite3_prepare16_v3(
117037 sqlite3 *db, /* Database handle. */
117038 const void *zSql, /* UTF-16 encoded SQL statement. */
117039 int nBytes, /* Length of zSql in bytes. */
117040 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_* flags */
117041 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
117042 const void **pzTail /* OUT: End of parsed string */
117043 ){
117044 int rc;
117045 rc = sqlite3Prepare16(db,zSql,nBytes,
117046 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),
117047 ppStmt,pzTail);
117048 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
117049 return rc;
117050 }
117051
117052 #endif /* SQLITE_OMIT_UTF16 */
@@ -118084,11 +117550,11 @@
118084 /*
118085 ** Allocate a KeyInfo object sufficient for an index of N key columns and
118086 ** X extra columns.
118087 */
118088 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
118089 int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);
118090 KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
118091 if( p ){
118092 p->aSortOrder = (u8*)&p->aColl[N+X];
118093 p->nField = (u16)N;
118094 p->nXField = (u16)X;
@@ -120258,16 +119724,13 @@
120258 ifNullRow.pLeft = pCopy;
120259 ifNullRow.iTable = pSubst->iNewTable;
120260 pCopy = &ifNullRow;
120261 }
120262 pNew = sqlite3ExprDup(db, pCopy, 0);
120263 if( pNew && pSubst->isLeftJoin ){
120264 ExprSetProperty(pNew, EP_CanBeNull);
120265 }
120266 if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
120267 pNew->iRightJoinTable = pExpr->iRightJoinTable;
120268 ExprSetProperty(pNew, EP_FromJoin);
120269 }
120270 sqlite3ExprDelete(db, pExpr);
120271 pExpr = pNew;
120272 }
120273 }
@@ -120556,11 +120019,11 @@
120556 **
120557 ** which is not at all the same thing.
120558 **
120559 ** If the subquery is the right operand of a LEFT JOIN, then the outer
120560 ** query cannot be an aggregate. This is an artifact of the way aggregates
120561 ** are processed - there is no mechanism to determine if the LEFT JOIN
120562 ** table should be all-NULL.
120563 **
120564 ** See also tickets #306, #350, and #3300.
120565 */
120566 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
@@ -121667,29 +121130,10 @@
121667 UNUSED_PARAMETER2(NotUsed, NotUsed2);
121668 return WRC_Continue;
121669 }
121670
121671 /*
121672 ** No-op routine for the parse-tree walker for SELECT statements.
121673 ** subquery in the parser tree.
121674 */
121675 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
121676 UNUSED_PARAMETER2(NotUsed, NotUsed2);
121677 return WRC_Continue;
121678 }
121679
121680 #if SQLITE_DEBUG
121681 /*
121682 ** Always assert. This xSelectCallback2 implementation proves that the
121683 ** xSelectCallback2 is never invoked.
121684 */
121685 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker *NotUsed, Select *NotUsed2){
121686 UNUSED_PARAMETER2(NotUsed, NotUsed2);
121687 assert( 0 );
121688 }
121689 #endif
121690 /*
121691 ** This routine "expands" a SELECT statement and all of its subqueries.
121692 ** For additional information on what it means to "expand" a SELECT
121693 ** statement, see the comment on the selectExpand worker callback above.
121694 **
121695 ** Expanding a SELECT statement is the first step in processing a
@@ -121700,15 +121144,15 @@
121700 ** The calling function can detect the problem by looking at pParse->nErr
121701 ** and/or pParse->db->mallocFailed.
121702 */
121703 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
121704 Walker w;
 
121705 w.xExprCallback = sqlite3ExprWalkNoop;
121706 w.pParse = pParse;
121707 if( pParse->hasCompound ){
121708 w.xSelectCallback = convertCompoundSelectToSubquery;
121709 w.xSelectCallback2 = 0;
121710 sqlite3WalkSelect(&w, pSelect);
121711 }
121712 w.xSelectCallback = selectExpander;
121713 w.xSelectCallback2 = selectPopWith;
121714 sqlite3WalkSelect(&w, pSelect);
@@ -121764,11 +121208,11 @@
121764 ** Use this routine after name resolution.
121765 */
121766 static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
121767 #ifndef SQLITE_OMIT_SUBQUERY
121768 Walker w;
121769 w.xSelectCallback = sqlite3SelectWalkNoop;
121770 w.xSelectCallback2 = selectAddSubqueryTypeInfo;
121771 w.xExprCallback = sqlite3ExprWalkNoop;
121772 w.pParse = pParse;
121773 sqlite3WalkSelect(&w, pSelect);
121774 #endif
@@ -122058,13 +121502,11 @@
122058 if( pItem->pSelect==0 ) continue;
122059 if( pItem->fg.viaCoroutine ) continue;
122060 if( pItem->zName==0 ) continue;
122061 if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
122062 if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
122063 if( sqlite3ExprCompare(0,
122064 pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
122065 ){
122066 /* The view was modified by some other optimization such as
122067 ** pushDownWhereTerms() */
122068 continue;
122069 }
122070 return pItem;
@@ -122347,13 +121789,10 @@
122347 VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName));
122348 }
122349 pPrior = isSelfJoinView(pTabList, pItem);
122350 if( pPrior ){
122351 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
122352 explainSetInteger(pItem->iSelectId, pPrior->iSelectId);
122353 assert( pPrior->pSelect!=0 );
122354 pSub->nSelectRow = pPrior->pSelect->nSelectRow;
122355 }else{
122356 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
122357 explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
122358 sqlite3Select(pParse, pSub, &dest);
122359 }
@@ -123509,11 +122948,10 @@
123509 /* Make an entry in the sqlite_master table */
123510 v = sqlite3GetVdbe(pParse);
123511 if( v==0 ) goto triggerfinish_cleanup;
123512 sqlite3BeginWriteOperation(pParse, 0, iDb);
123513 z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
123514 testcase( z==0 );
123515 sqlite3NestedParse(pParse,
123516 "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
123517 db->aDb[iDb].zDbSName, MASTER_NAME, zName,
123518 pTrig->table, z);
123519 sqlite3DbFree(db, z);
@@ -125377,11 +124815,11 @@
125377 #ifdef SQLITE_HAS_CODEC
125378 if( db->nextPagesize ){
125379 extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
125380 int nKey;
125381 char *zKey;
125382 sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey);
125383 if( nKey ) db->nextPagesize = 0;
125384 }
125385 #endif
125386
125387 sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
@@ -128317,14 +127755,14 @@
128317 ** function generates code to do a deferred seek of cursor iCur to the
128318 ** rowid stored in register iRowid.
128319 **
128320 ** Normally, this is just:
128321 **
128322 ** OP_DeferredSeek $iCur $iRowid
128323 **
128324 ** However, if the scan currently being coded is a branch of an OR-loop and
128325 ** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek
128326 ** is set to iIdxCur and P4 is set to point to an array of integers
128327 ** containing one entry for each column of the table cursor iCur is open
128328 ** on. For each table column, if the column is the i'th column of the
128329 ** index, then the corresponding array entry is set to (i+1). If the column
128330 ** does not appear in the index at all, the array entry is set to 0.
@@ -128339,11 +127777,11 @@
128339 Vdbe *v = pParse->pVdbe; /* Vdbe to generate code within */
128340
128341 assert( iIdxCur>0 );
128342 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
128343
128344 sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur);
128345 if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
128346 && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
128347 ){
128348 int i;
128349 Table *pTab = pIdx->pTable;
@@ -128409,11 +127847,11 @@
128409 ** If pExpr matches, then transform it into a reference to the index column
128410 ** that contains the value of pExpr.
128411 */
128412 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
128413 IdxExprTrans *pX = p->u.pIdxTrans;
128414 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
128415 pExpr->op = TK_COLUMN;
128416 pExpr->iTable = pX->iIdxCur;
128417 pExpr->iColumn = pX->iIdxCol;
128418 pExpr->pTab = 0;
128419 return WRC_Prune;
@@ -129703,11 +129141,11 @@
129703 pList = pExpr->x.pList;
129704 pLeft = pList->a[1].pExpr;
129705
129706 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129707 op = pRight->op;
129708 if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
129709 Vdbe *pReprepare = pParse->pReprepare;
129710 int iCol = pRight->iColumn;
129711 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129712 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129713 z = (char *)sqlite3_value_text(pVal);
@@ -129893,12 +129331,12 @@
129893 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129894 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129895 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129896 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129897 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129898 if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129899 if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;
129900 /* If we reach this point, it means the two subterms can be combined */
129901 if( (eOp & (eOp-1))!=0 ){
129902 if( eOp & (WO_LT|WO_LE) ){
129903 eOp = WO_LE;
129904 }else{
@@ -130665,13 +130103,10 @@
130665 prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130666 if( (prereqExpr & prereqColumn)==0 ){
130667 Expr *pNewExpr;
130668 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130669 0, sqlite3ExprDup(db, pRight, 0));
130670 if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
130671 ExprSetProperty(pNewExpr, EP_FromJoin);
130672 }
130673 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130674 testcase( idxNew==0 );
130675 pNewTerm = &pWC->a[idxNew];
130676 pNewTerm->prereqRight = prereqExpr;
130677 pNewTerm->leftCursor = pLeft->iTable;
@@ -132144,11 +131579,11 @@
132144 iGap = (iGap*2)/3;
132145 }else{
132146 iGap = iGap/3;
132147 }
132148 aStat[0] = iLower + iGap;
132149 aStat[1] = pIdx->aAvgEq[nField-1];
132150 }
132151
132152 /* Restore the pRec->nField value before returning. */
132153 pRec->nField = nField;
132154 return i;
@@ -132897,21 +132332,20 @@
132897 }
132898 }
132899
132900 /*
132901 ** Search the list of WhereLoops in *ppPrev looking for one that can be
132902 ** replaced by pTemplate.
132903 **
132904 ** Return NULL if pTemplate does not belong on the WhereLoop list.
132905 ** In other words if pTemplate ought to be dropped from further consideration.
132906 **
132907 ** If pX is a WhereLoop that pTemplate can replace, then return the
132908 ** link that points to pX.
132909 **
132910 ** If pTemplate cannot replace any existing element of the list but needs
132911 ** to be added to the list as a new entry, then return a pointer to the
132912 ** tail of the list.
132913 */
132914 static WhereLoop **whereLoopFindLesser(
132915 WhereLoop **ppPrev,
132916 const WhereLoop *pTemplate
132917 ){
@@ -133052,14 +132486,12 @@
133052 #if WHERETRACE_ENABLED /* 0x8 */
133053 if( sqlite3WhereTrace & 0x8 ){
133054 if( p!=0 ){
133055 sqlite3DebugPrintf("replace: ");
133056 whereLoopPrint(p, pBuilder->pWC);
133057 sqlite3DebugPrintf(" with: ");
133058 }else{
133059 sqlite3DebugPrintf(" add: ");
133060 }
 
133061 whereLoopPrint(pTemplate, pBuilder->pWC);
133062 }
133063 #endif
133064 if( p==0 ){
133065 /* Allocate a new WhereLoop to add to the end of the list */
@@ -133606,11 +133038,11 @@
133606 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133607 }
133608 }else if( (aColExpr = pIndex->aColExpr)!=0 ){
133609 for(jj=0; jj<pIndex->nKeyCol; jj++){
133610 if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133611 if( sqlite3ExprCompare(0, pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133612 return 1;
133613 }
133614 }
133615 }
133616 }
@@ -133639,20 +133071,18 @@
133639 ** in the current query. Return true if it can be and false if not.
133640 */
133641 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133642 int i;
133643 WhereTerm *pTerm;
133644 Parse *pParse = pWC->pWInfo->pParse;
133645 while( pWhere->op==TK_AND ){
133646 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133647 pWhere = pWhere->pRight;
133648 }
133649 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
133650 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133651 Expr *pExpr = pTerm->pExpr;
133652 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133653 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
133654 ){
133655 return 1;
133656 }
133657 }
133658 return 0;
@@ -134627,12 +134057,11 @@
134627 if( iColumn>=(-1) ){
134628 if( pOBExpr->op!=TK_COLUMN ) continue;
134629 if( pOBExpr->iTable!=iCur ) continue;
134630 if( pOBExpr->iColumn!=iColumn ) continue;
134631 }else{
134632 if( sqlite3ExprCompare(0,
134633 pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
134634 continue;
134635 }
134636 }
134637 if( iColumn>=0 ){
134638 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134927,11 +134356,10 @@
134927 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134928 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134929 rUnsorted, rCost));
134930 }else{
134931 rCost = rUnsorted;
134932 rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
134933 }
134934
134935 /* Check to see if pWLoop should be added to the set of
134936 ** mxChoice best-so-far paths.
134937 **
@@ -134959,12 +134387,12 @@
134959 /* The current candidate is no better than any of the mxChoice
134960 ** paths currently in the best-so-far buffer. So discard
134961 ** this candidate as not viable. */
134962 #ifdef WHERETRACE_ENABLED /* 0x4 */
134963 if( sqlite3WhereTrace&0x4 ){
134964 sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n",
134965 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134966 isOrdered>=0 ? isOrdered+'0' : '?');
134967 }
134968 #endif
134969 continue;
134970 }
@@ -134978,40 +134406,30 @@
134978 jj = mxI;
134979 }
134980 pTo = &aTo[jj];
134981 #ifdef WHERETRACE_ENABLED /* 0x4 */
134982 if( sqlite3WhereTrace&0x4 ){
134983 sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n",
134984 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
134985 isOrdered>=0 ? isOrdered+'0' : '?');
134986 }
134987 #endif
134988 }else{
134989 /* Control reaches here if best-so-far path pTo=aTo[jj] covers the
134990 ** same set of loops and has the same isOrdered setting as the
134991 ** candidate path. Check to see if the candidate should replace
134992 ** pTo or if the candidate should be skipped.
134993 **
134994 ** The conditional is an expanded vector comparison equivalent to:
134995 ** (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
134996 */
134997 if( pTo->rCost<rCost
134998 || (pTo->rCost==rCost
134999 && (pTo->nRow<nOut
135000 || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
135001 )
135002 )
135003 ){
135004 #ifdef WHERETRACE_ENABLED /* 0x4 */
135005 if( sqlite3WhereTrace&0x4 ){
135006 sqlite3DebugPrintf(
135007 "Skip %s cost=%-3d,%3d,%3d order=%c",
135008 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
135009 isOrdered>=0 ? isOrdered+'0' : '?');
135010 sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n",
135011 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
135012 pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
135013 }
135014 #endif
135015 /* Discard the candidate path from further consideration */
135016 testcase( pTo->rCost==rCost );
135017 continue;
@@ -135020,16 +134438,16 @@
135020 /* Control reaches here if the candidate path is better than the
135021 ** pTo path. Replace pTo with the candidate. */
135022 #ifdef WHERETRACE_ENABLED /* 0x4 */
135023 if( sqlite3WhereTrace&0x4 ){
135024 sqlite3DebugPrintf(
135025 "Update %s cost=%-3d,%3d,%3d order=%c",
135026 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
135027 isOrdered>=0 ? isOrdered+'0' : '?');
135028 sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n",
135029 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
135030 pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
135031 }
135032 #endif
135033 }
135034 /* pWLoop is a winner. Add it to the set of best so far */
135035 pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
@@ -135250,35 +134668,10 @@
135250 return 1;
135251 }
135252 return 0;
135253 }
135254
135255 /*
135256 ** Helper function for exprIsDeterministic().
135257 */
135258 static int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){
135259 if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){
135260 pWalker->eCode = 0;
135261 return WRC_Abort;
135262 }
135263 return WRC_Continue;
135264 }
135265
135266 /*
135267 ** Return true if the expression contains no non-deterministic SQL
135268 ** functions. Do not consider non-deterministic SQL functions that are
135269 ** part of sub-select statements.
135270 */
135271 static int exprIsDeterministic(Expr *p){
135272 Walker w;
135273 memset(&w, 0, sizeof(w));
135274 w.eCode = 1;
135275 w.xExprCallback = exprNodeIsDeterministic;
135276 sqlite3WalkExpr(&w, p);
135277 return w.eCode;
135278 }
135279
135280 /*
135281 ** Generate the beginning of the loop used for WHERE clause processing.
135282 ** The return value is a pointer to an opaque structure that contains
135283 ** information needed to terminate the loop. Later, the calling routine
135284 ** should invoke sqlite3WhereEnd() with the return value of this function
@@ -135473,10 +134866,21 @@
135473 */
135474 initMaskSet(pMaskSet);
135475 sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
135476 sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
135477
 
 
 
 
 
 
 
 
 
 
 
135478 /* Special case: No FROM clause
135479 */
135480 if( nTabList==0 ){
135481 if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
135482 if( wctrlFlags & WHERE_WANT_DISTINCT ){
@@ -135511,29 +134915,10 @@
135511
135512 /* Analyze all of the subexpressions. */
135513 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
135514 if( db->mallocFailed ) goto whereBeginError;
135515
135516 /* Special case: WHERE terms that do not refer to any tables in the join
135517 ** (constant expressions). Evaluate each such term, and jump over all the
135518 ** generated code if the result is not true.
135519 **
135520 ** Do not do this if the expression contains non-deterministic functions
135521 ** that are not within a sub-select. This is not strictly required, but
135522 ** preserves SQLite's legacy behaviour in the following two cases:
135523 **
135524 ** FROM ... WHERE random()>0; -- eval random() once per row
135525 ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
135526 */
135527 for(ii=0; ii<sWLB.pWC->nTerm; ii++){
135528 WhereTerm *pT = &sWLB.pWC->a[ii];
135529 if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
135530 sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);
135531 pT->wtFlags |= TERM_CODED;
135532 }
135533 }
135534
135535 if( wctrlFlags & WHERE_WANT_DISTINCT ){
135536 if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
135537 /* The DISTINCT marking is pointless. Ignore it. */
135538 pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
135539 }else if( pOrderBy==0 ){
@@ -135566,11 +134951,11 @@
135566 WhereLoop *p;
135567 int i;
135568 static const char zLabel[] = "0123456789abcdefghijklmnopqrstuvwyxz"
135569 "ABCDEFGHIJKLMNOPQRSTUVWYXZ";
135570 for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){
135571 p->cId = zLabel[i%(sizeof(zLabel)-1)];
135572 whereLoopPrint(p, sWLB.pWC);
135573 }
135574 }
135575 #endif
135576
@@ -136349,19 +135734,19 @@
136349 #define sqlite3ParserARG_PDECL ,Parse *pParse
136350 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136351 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
136352 #define YYFALLBACK 1
136353 #define YYNSTATE 456
136354 #define YYNRULE 331
136355 #define YY_MAX_SHIFT 455
136356 #define YY_MIN_SHIFTREDUCE 667
136357 #define YY_MAX_SHIFTREDUCE 997
136358 #define YY_MIN_REDUCE 998
136359 #define YY_MAX_REDUCE 1328
136360 #define YY_ERROR_ACTION 1329
136361 #define YY_ACCEPT_ACTION 1330
136362 #define YY_NO_ACTION 1331
136363 /************* End control #defines *******************************************/
136364
136365 /* Define the yytestcase() macro to be a no-op if is not already defined
136366 ** otherwise.
136367 **
@@ -136431,167 +135816,167 @@
136431 ** yy_default[] Default action for each state.
136432 **
136433 *********** Begin parsing tables **********************************************/
136434 #define YY_ACTTAB_COUNT (1566)
136435 static const YYACTIONTYPE yy_action[] = {
136436 /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
136437 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136438 /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439 /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
136440 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136441 /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136442 /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136443 /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444 /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445 /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446 /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448 /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449 /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136450 /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136451 /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452 /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453 /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454 /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455 /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456 /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
136457 /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136458 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459 /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460 /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461 /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462 /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
136463 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136464 /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465 /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466 /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467 /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468 /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469 /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470 /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471 /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472 /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473 /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474 /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475 /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476 /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477 /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
136478 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136479 /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480 /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481 /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482 /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483 /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484 /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136485 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136486 /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487 /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488 /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489 /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490 /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491 /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492 /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136493 /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136494 /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495 /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496 /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497 /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498 /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499 /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
136500 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136501 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502 /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503 /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504 /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505 /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506 /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507 /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508 /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509 /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510 /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511 /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512 /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136513 /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136514 /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515 /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516 /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517 /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518 /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520 /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
136521 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136522 /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523 /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524 /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525 /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
136526 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136527 /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136528 /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136529 /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530 /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531 /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532 /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136533 /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136534 /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535 /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536 /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537 /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538 /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
136539 /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136540 /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541 /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542 /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
136543 /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136544 /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545 /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546 /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547 /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548 /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
136549 /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136550 /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551 /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552 /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553 /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554 /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555 /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
136556 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136557 /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558 /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559 /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560 /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561 /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562 /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563 /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564 /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565 /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566 /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567 /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568 /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569 /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570 /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571 /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572 /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573 /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574 /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575 /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576 /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577 /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
136578 /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136579 /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580 /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
136581 /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136582 /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583 /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584 /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585 /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586 /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587 /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588 /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589 /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590 /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591 /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592 /* 1560 */ 87, 312, 309, 945, 1288, 1287,
136593 };
136594 static const YYCODETYPE yy_lookahead[] = {
136595 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136596 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136597 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136840,56 +136225,56 @@
136840 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136841 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136842 /* 320 */ 1280, 1281, 1264, 1269, 1283,
136843 };
136844 static const YYACTIONTYPE yy_default[] = {
136845 /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846 /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847 /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848 /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849 /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850 /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851 /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852 /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853 /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854 /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855 /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856 /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857 /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858 /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859 /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860 /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861 /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862 /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863 /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864 /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865 /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866 /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867 /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868 /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869 /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870 /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871 /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872 /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873 /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874 /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875 /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876 /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877 /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878 /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879 /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880 /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881 /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882 /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883 /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884 /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885 /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886 /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887 /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888 /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889 /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890 /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
136891 };
136892 /********** End of lemon-generated parsing tables *****************************/
136893
136894 /* The next table maps tokens (terminal symbols) into fallback tokens.
136895 ** If a construct like the following:
@@ -137019,11 +136404,10 @@
137019 int yystksz; /* Current side of the stack */
137020 yyStackEntry *yystack; /* The parser's stack */
137021 yyStackEntry yystk0; /* First stack entry */
137022 #else
137023 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
137024 yyStackEntry *yystackEnd; /* Last entry in the stack */
137025 #endif
137026 };
137027 typedef struct yyParser yyParser;
137028
137029 #ifndef NDEBUG
@@ -137358,113 +136742,114 @@
137358 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137359 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137360 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137361 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137362 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137363 /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364 /* 229 */ "trigger_time ::= INSTEAD OF",
137365 /* 230 */ "trigger_time ::=",
137366 /* 231 */ "trigger_event ::= DELETE|INSERT",
137367 /* 232 */ "trigger_event ::= UPDATE",
137368 /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369 /* 234 */ "when_clause ::=",
137370 /* 235 */ "when_clause ::= WHEN expr",
137371 /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372 /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373 /* 238 */ "trnm ::= nm DOT nm",
137374 /* 239 */ "tridxby ::= INDEXED BY nm",
137375 /* 240 */ "tridxby ::= NOT INDEXED",
137376 /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377 /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378 /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379 /* 244 */ "trigger_cmd ::= select",
137380 /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381 /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382 /* 247 */ "raisetype ::= ROLLBACK",
137383 /* 248 */ "raisetype ::= ABORT",
137384 /* 249 */ "raisetype ::= FAIL",
137385 /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386 /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387 /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388 /* 253 */ "key_opt ::=",
137389 /* 254 */ "key_opt ::= KEY expr",
137390 /* 255 */ "cmd ::= REINDEX",
137391 /* 256 */ "cmd ::= REINDEX nm dbnm",
137392 /* 257 */ "cmd ::= ANALYZE",
137393 /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394 /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395 /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396 /* 261 */ "add_column_fullname ::= fullname",
137397 /* 262 */ "cmd ::= create_vtab",
137398 /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399 /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400 /* 265 */ "vtabarg ::=",
137401 /* 266 */ "vtabargtoken ::= ANY",
137402 /* 267 */ "vtabargtoken ::= lp anylist RP",
137403 /* 268 */ "lp ::= LP",
137404 /* 269 */ "with ::=",
137405 /* 270 */ "with ::= WITH wqlist",
137406 /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407 /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408 /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409 /* 274 */ "input ::= cmdlist",
137410 /* 275 */ "cmdlist ::= cmdlist ecmd",
137411 /* 276 */ "cmdlist ::= ecmd",
137412 /* 277 */ "ecmd ::= SEMI",
137413 /* 278 */ "ecmd ::= explain cmdx SEMI",
137414 /* 279 */ "explain ::=",
137415 /* 280 */ "trans_opt ::=",
137416 /* 281 */ "trans_opt ::= TRANSACTION",
137417 /* 282 */ "trans_opt ::= TRANSACTION nm",
137418 /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419 /* 284 */ "savepoint_opt ::=",
137420 /* 285 */ "cmd ::= create_table create_table_args",
137421 /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422 /* 287 */ "columnlist ::= columnname carglist",
137423 /* 288 */ "nm ::= ID|INDEXED",
137424 /* 289 */ "nm ::= STRING",
137425 /* 290 */ "nm ::= JOIN_KW",
137426 /* 291 */ "typetoken ::= typename",
137427 /* 292 */ "typename ::= ID|STRING",
137428 /* 293 */ "signed ::= plus_num",
137429 /* 294 */ "signed ::= minus_num",
137430 /* 295 */ "carglist ::= carglist ccons",
137431 /* 296 */ "carglist ::=",
137432 /* 297 */ "ccons ::= NULL onconf",
137433 /* 298 */ "conslist_opt ::= COMMA conslist",
137434 /* 299 */ "conslist ::= conslist tconscomma tcons",
137435 /* 300 */ "conslist ::= tcons",
137436 /* 301 */ "tconscomma ::=",
137437 /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438 /* 303 */ "resolvetype ::= raisetype",
137439 /* 304 */ "selectnowith ::= oneselect",
137440 /* 305 */ "oneselect ::= values",
137441 /* 306 */ "sclp ::= selcollist COMMA",
137442 /* 307 */ "as ::= ID|STRING",
137443 /* 308 */ "expr ::= term",
137444 /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445 /* 310 */ "exprlist ::= nexprlist",
137446 /* 311 */ "nmnum ::= plus_num",
137447 /* 312 */ "nmnum ::= nm",
137448 /* 313 */ "nmnum ::= ON",
137449 /* 314 */ "nmnum ::= DELETE",
137450 /* 315 */ "nmnum ::= DEFAULT",
137451 /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452 /* 317 */ "foreach_clause ::=",
137453 /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454 /* 319 */ "trnm ::= nm",
137455 /* 320 */ "tridxby ::=",
137456 /* 321 */ "database_kw_opt ::= DATABASE",
137457 /* 322 */ "database_kw_opt ::=",
137458 /* 323 */ "kwcolumn_opt ::=",
137459 /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460 /* 325 */ "vtabarglist ::= vtabarg",
137461 /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462 /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463 /* 328 */ "anylist ::=",
137464 /* 329 */ "anylist ::= anylist LP anylist RP",
137465 /* 330 */ "anylist ::= anylist ANY",
 
137466 };
137467 #endif /* NDEBUG */
137468
137469
137470 #if YYSTACKDEPTH<=0
@@ -137529,11 +136914,10 @@
137529 pParser->yyerrcnt = -1;
137530 #endif
137531 pParser->yytos = pParser->yystack;
137532 pParser->yystack[0].stateno = 0;
137533 pParser->yystack[0].major = 0;
137534 pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137535 }
137536
137537 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137538 /*
137539 ** This function allocates a new parser.
@@ -137872,11 +137256,11 @@
137872 yypParser->yyhwm++;
137873 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137874 }
137875 #endif
137876 #if YYSTACKDEPTH>0
137877 if( yypParser->yytos>yypParser->yystackEnd ){
137878 yypParser->yytos--;
137879 yyStackOverflow(yypParser);
137880 return;
137881 }
137882 #else
@@ -137900,344 +137284,345 @@
137900
137901 /* The following table contains information about every rule that
137902 ** is used during the reduce.
137903 */
137904 static const struct {
137905 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137906 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
137907 } yyRuleInfo[] = {
137908 { 147, -1 },
137909 { 147, -3 },
137910 { 148, -1 },
137911 { 149, -3 },
137912 { 150, 0 },
137913 { 150, -1 },
137914 { 150, -1 },
137915 { 150, -1 },
137916 { 149, -2 },
137917 { 149, -2 },
137918 { 149, -2 },
137919 { 149, -2 },
137920 { 149, -3 },
137921 { 149, -5 },
137922 { 154, -6 },
137923 { 156, -1 },
137924 { 158, 0 },
137925 { 158, -3 },
137926 { 157, -1 },
137927 { 157, 0 },
137928 { 155, -5 },
137929 { 155, -2 },
137930 { 162, 0 },
137931 { 162, -2 },
137932 { 164, -2 },
137933 { 166, 0 },
137934 { 166, -4 },
137935 { 166, -6 },
137936 { 167, -2 },
137937 { 171, -2 },
137938 { 171, -2 },
137939 { 171, -4 },
137940 { 171, -3 },
137941 { 171, -3 },
137942 { 171, -2 },
137943 { 171, -3 },
137944 { 171, -5 },
137945 { 171, -2 },
137946 { 171, -4 },
137947 { 171, -4 },
137948 { 171, -1 },
137949 { 171, -2 },
137950 { 176, 0 },
137951 { 176, -1 },
137952 { 178, 0 },
137953 { 178, -2 },
137954 { 180, -2 },
137955 { 180, -3 },
137956 { 180, -3 },
137957 { 180, -3 },
137958 { 181, -2 },
137959 { 181, -2 },
137960 { 181, -1 },
137961 { 181, -1 },
137962 { 181, -2 },
137963 { 179, -3 },
137964 { 179, -2 },
137965 { 182, 0 },
137966 { 182, -2 },
137967 { 182, -2 },
137968 { 161, 0 },
137969 { 184, -1 },
137970 { 185, -2 },
137971 { 185, -7 },
137972 { 185, -5 },
137973 { 185, -5 },
137974 { 185, -10 },
137975 { 188, 0 },
137976 { 174, 0 },
137977 { 174, -3 },
137978 { 189, 0 },
137979 { 189, -2 },
137980 { 190, -1 },
137981 { 190, -1 },
137982 { 149, -4 },
137983 { 192, -2 },
137984 { 192, 0 },
137985 { 149, -9 },
137986 { 149, -4 },
137987 { 149, -1 },
137988 { 163, -2 },
137989 { 194, -3 },
137990 { 197, -1 },
137991 { 197, -2 },
137992 { 197, -1 },
137993 { 195, -9 },
137994 { 206, -4 },
137995 { 206, -5 },
137996 { 198, -1 },
137997 { 198, -1 },
137998 { 198, 0 },
137999 { 209, 0 },
138000 { 199, -3 },
138001 { 199, -2 },
138002 { 199, -4 },
138003 { 210, -2 },
138004 { 210, 0 },
138005 { 200, 0 },
138006 { 200, -2 },
138007 { 212, -2 },
138008 { 212, 0 },
138009 { 211, -7 },
138010 { 211, -9 },
138011 { 211, -7 },
138012 { 211, -7 },
138013 { 159, 0 },
138014 { 159, -2 },
138015 { 193, -2 },
138016 { 213, -1 },
138017 { 213, -2 },
138018 { 213, -3 },
138019 { 213, -4 },
138020 { 215, -2 },
138021 { 215, 0 },
138022 { 214, 0 },
138023 { 214, -3 },
138024 { 214, -2 },
138025 { 216, -4 },
138026 { 216, 0 },
138027 { 204, 0 },
138028 { 204, -3 },
138029 { 186, -4 },
138030 { 186, -2 },
138031 { 175, -1 },
138032 { 175, -1 },
138033 { 175, 0 },
138034 { 202, 0 },
138035 { 202, -3 },
138036 { 203, 0 },
138037 { 203, -2 },
138038 { 205, 0 },
138039 { 205, -2 },
138040 { 205, -4 },
138041 { 205, -4 },
138042 { 149, -6 },
138043 { 201, 0 },
138044 { 201, -2 },
138045 { 149, -8 },
138046 { 218, -5 },
138047 { 218, -7 },
138048 { 218, -3 },
138049 { 218, -5 },
138050 { 149, -6 },
138051 { 149, -7 },
138052 { 219, -2 },
138053 { 219, -1 },
138054 { 220, 0 },
138055 { 220, -3 },
138056 { 217, -3 },
138057 { 217, -1 },
138058 { 173, -3 },
138059 { 172, -1 },
138060 { 173, -1 },
138061 { 173, -1 },
138062 { 173, -3 },
138063 { 173, -5 },
138064 { 172, -1 },
138065 { 172, -1 },
138066 { 172, -1 },
138067 { 173, -1 },
138068 { 173, -3 },
138069 { 173, -6 },
138070 { 173, -5 },
138071 { 173, -4 },
138072 { 172, -1 },
138073 { 173, -5 },
138074 { 173, -3 },
138075 { 173, -3 },
138076 { 173, -3 },
138077 { 173, -3 },
138078 { 173, -3 },
138079 { 173, -3 },
138080 { 173, -3 },
138081 { 173, -3 },
138082 { 221, -2 },
138083 { 173, -3 },
138084 { 173, -5 },
138085 { 173, -2 },
138086 { 173, -3 },
138087 { 173, -3 },
138088 { 173, -4 },
138089 { 173, -2 },
138090 { 173, -2 },
138091 { 173, -2 },
138092 { 173, -2 },
138093 { 222, -1 },
138094 { 222, -2 },
138095 { 173, -5 },
138096 { 223, -1 },
138097 { 223, -2 },
138098 { 173, -5 },
138099 { 173, -3 },
138100 { 173, -5 },
138101 { 173, -5 },
138102 { 173, -4 },
138103 { 173, -5 },
138104 { 226, -5 },
138105 { 226, -4 },
138106 { 227, -2 },
138107 { 227, 0 },
138108 { 225, -1 },
138109 { 225, 0 },
138110 { 208, 0 },
138111 { 207, -3 },
138112 { 207, -1 },
138113 { 224, 0 },
138114 { 224, -3 },
138115 { 149, -12 },
138116 { 228, -1 },
138117 { 228, 0 },
138118 { 177, 0 },
138119 { 177, -3 },
138120 { 187, -5 },
138121 { 187, -3 },
138122 { 229, 0 },
138123 { 229, -2 },
138124 { 149, -4 },
138125 { 149, -1 },
138126 { 149, -2 },
138127 { 149, -3 },
138128 { 149, -5 },
138129 { 149, -6 },
138130 { 149, -5 },
138131 { 149, -6 },
138132 { 169, -2 },
138133 { 170, -2 },
138134 { 149, -5 },
138135 { 231, -11 },
138136 { 233, -1 },
138137 { 233, -2 },
 
138138 { 233, 0 },
138139 { 234, -1 },
138140 { 234, -1 },
138141 { 234, -3 },
138142 { 236, 0 },
138143 { 236, -2 },
138144 { 232, -3 },
138145 { 232, -2 },
138146 { 238, -3 },
138147 { 239, -3 },
138148 { 239, -2 },
138149 { 237, -7 },
138150 { 237, -5 },
138151 { 237, -5 },
138152 { 237, -1 },
138153 { 173, -4 },
138154 { 173, -6 },
138155 { 191, -1 },
138156 { 191, -1 },
138157 { 191, -1 },
138158 { 149, -4 },
138159 { 149, -6 },
138160 { 149, -3 },
138161 { 241, 0 },
138162 { 241, -2 },
138163 { 149, -1 },
138164 { 149, -3 },
138165 { 149, -1 },
138166 { 149, -3 },
138167 { 149, -6 },
138168 { 149, -7 },
138169 { 242, -1 },
138170 { 149, -1 },
138171 { 149, -4 },
138172 { 244, -8 },
138173 { 246, 0 },
138174 { 247, -1 },
138175 { 247, -3 },
138176 { 248, -1 },
138177 { 196, 0 },
138178 { 196, -2 },
138179 { 196, -3 },
138180 { 250, -6 },
138181 { 250, -8 },
138182 { 144, -1 },
138183 { 145, -2 },
138184 { 145, -1 },
138185 { 146, -1 },
138186 { 146, -3 },
138187 { 147, 0 },
138188 { 151, 0 },
138189 { 151, -1 },
138190 { 151, -2 },
138191 { 153, -1 },
138192 { 153, 0 },
138193 { 149, -2 },
138194 { 160, -4 },
138195 { 160, -2 },
138196 { 152, -1 },
138197 { 152, -1 },
138198 { 152, -1 },
138199 { 166, -1 },
138200 { 167, -1 },
138201 { 168, -1 },
138202 { 168, -1 },
138203 { 165, -2 },
138204 { 165, 0 },
138205 { 171, -2 },
138206 { 161, -2 },
138207 { 183, -3 },
138208 { 183, -1 },
138209 { 184, 0 },
138210 { 188, -1 },
138211 { 190, -1 },
138212 { 194, -1 },
138213 { 195, -1 },
138214 { 209, -2 },
138215 { 210, -1 },
138216 { 173, -1 },
138217 { 221, -1 },
138218 { 208, -1 },
138219 { 230, -1 },
138220 { 230, -1 },
138221 { 230, -1 },
138222 { 230, -1 },
138223 { 230, -1 },
138224 { 169, -1 },
138225 { 235, 0 },
138226 { 235, -3 },
138227 { 238, -1 },
138228 { 239, 0 },
138229 { 240, -1 },
138230 { 240, 0 },
138231 { 243, 0 },
138232 { 243, -1 },
138233 { 245, -1 },
138234 { 245, -3 },
138235 { 246, -2 },
138236 { 249, 0 },
138237 { 249, -4 },
138238 { 249, -2 },
138239 };
138240
138241 static void yy_accept(yyParser*); /* Forward Declaration */
138242
138243 /*
@@ -138256,11 +137641,11 @@
138256 yymsp = yypParser->yytos;
138257 #ifndef NDEBUG
138258 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
138259 yysize = yyRuleInfo[yyruleno].nrhs;
138260 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
138261 yyRuleName[yyruleno], yymsp[yysize].stateno);
138262 }
138263 #endif /* NDEBUG */
138264
138265 /* Check that the stack is large enough to grow by a single entry
138266 ** if the RHS of the rule is empty. This ensures that there is room
@@ -138271,11 +137656,11 @@
138271 yypParser->yyhwm++;
138272 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
138273 }
138274 #endif
138275 #if YYSTACKDEPTH>0
138276 if( yypParser->yytos>=yypParser->yystackEnd ){
138277 yyStackOverflow(yypParser);
138278 return;
138279 }
138280 #else
138281 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139230,11 +138615,11 @@
139230 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139231 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139232 }
139233 break;
139234 case 208: /* uniqueflag ::= UNIQUE */
139235 case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
139236 {yymsp[0].minor.yy194 = OE_Abort;}
139237 break;
139238 case 209: /* uniqueflag ::= */
139239 {yymsp[1].minor.yy194 = OE_None;}
139240 break;
@@ -139284,269 +138669,268 @@
139284 {
139285 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139286 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139287 }
139288 break;
139289 case 228: /* trigger_time ::= BEFORE|AFTER */
139290 { yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139291 break;
139292 case 229: /* trigger_time ::= INSTEAD OF */
 
 
 
139293 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
139294 break;
139295 case 230: /* trigger_time ::= */
139296 { yymsp[1].minor.yy194 = TK_BEFORE; }
139297 break;
139298 case 231: /* trigger_event ::= DELETE|INSERT */
139299 case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
139300 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139301 break;
139302 case 233: /* trigger_event ::= UPDATE OF idlist */
139303 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139304 break;
139305 case 234: /* when_clause ::= */
139306 case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
139307 { yymsp[1].minor.yy72 = 0; }
139308 break;
139309 case 235: /* when_clause ::= WHEN expr */
139310 case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
139311 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139312 break;
139313 case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139314 {
139315 assert( yymsp[-2].minor.yy145!=0 );
139316 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139317 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139318 }
139319 break;
139320 case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
139321 {
139322 assert( yymsp[-1].minor.yy145!=0 );
139323 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139324 }
139325 break;
139326 case 238: /* trnm ::= nm DOT nm */
139327 {
139328 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139329 sqlite3ErrorMsg(pParse,
139330 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139331 "statements within triggers");
139332 }
139333 break;
139334 case 239: /* tridxby ::= INDEXED BY nm */
139335 {
139336 sqlite3ErrorMsg(pParse,
139337 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139338 "within triggers");
139339 }
139340 break;
139341 case 240: /* tridxby ::= NOT INDEXED */
139342 {
139343 sqlite3ErrorMsg(pParse,
139344 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139345 "within triggers");
139346 }
139347 break;
139348 case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139349 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139350 break;
139351 case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139352 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139353 break;
139354 case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139355 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139356 break;
139357 case 244: /* trigger_cmd ::= select */
139358 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139359 break;
139360 case 245: /* expr ::= RAISE LP IGNORE RP */
139361 {
139362 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139363 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139364 if( yymsp[-3].minor.yy190.pExpr ){
139365 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139366 }
139367 }
139368 break;
139369 case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
139370 {
139371 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139372 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139373 if( yymsp[-5].minor.yy190.pExpr ) {
139374 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139375 }
139376 }
139377 break;
139378 case 247: /* raisetype ::= ROLLBACK */
139379 {yymsp[0].minor.yy194 = OE_Rollback;}
139380 break;
139381 case 249: /* raisetype ::= FAIL */
139382 {yymsp[0].minor.yy194 = OE_Fail;}
139383 break;
139384 case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
139385 {
139386 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139387 }
139388 break;
139389 case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139390 {
139391 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139392 }
139393 break;
139394 case 252: /* cmd ::= DETACH database_kw_opt expr */
139395 {
139396 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139397 }
139398 break;
139399 case 255: /* cmd ::= REINDEX */
139400 {sqlite3Reindex(pParse, 0, 0);}
139401 break;
139402 case 256: /* cmd ::= REINDEX nm dbnm */
139403 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139404 break;
139405 case 257: /* cmd ::= ANALYZE */
139406 {sqlite3Analyze(pParse, 0, 0);}
139407 break;
139408 case 258: /* cmd ::= ANALYZE nm dbnm */
139409 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139410 break;
139411 case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139412 {
139413 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139414 }
139415 break;
139416 case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139417 {
139418 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139419 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139420 }
139421 break;
139422 case 261: /* add_column_fullname ::= fullname */
139423 {
139424 disableLookaside(pParse);
139425 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139426 }
139427 break;
139428 case 262: /* cmd ::= create_vtab */
139429 {sqlite3VtabFinishParse(pParse,0);}
139430 break;
139431 case 263: /* cmd ::= create_vtab LP vtabarglist RP */
139432 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139433 break;
139434 case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139435 {
139436 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139437 }
139438 break;
139439 case 265: /* vtabarg ::= */
139440 {sqlite3VtabArgInit(pParse);}
139441 break;
139442 case 266: /* vtabargtoken ::= ANY */
139443 case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444 case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
139445 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139446 break;
139447 case 269: /* with ::= */
139448 {yymsp[1].minor.yy285 = 0;}
139449 break;
139450 case 270: /* with ::= WITH wqlist */
139451 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139452 break;
139453 case 271: /* with ::= WITH RECURSIVE wqlist */
139454 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139455 break;
139456 case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
139457 {
139458 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139459 }
139460 break;
139461 case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139462 {
139463 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139464 }
139465 break;
139466 default:
139467 /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468 /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469 /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470 /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471 /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472 /* (279) explain ::= */ yytestcase(yyruleno==279);
139473 /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474 /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475 /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476 /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477 /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478 /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479 /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480 /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481 /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482 /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483 /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484 /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485 /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486 /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487 /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488 /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489 /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490 /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491 /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492 /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493 /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494 /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495 /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496 /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497 /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498 /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499 /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500 /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501 /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502 /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503 /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504 /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505 /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506 /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507 /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508 /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509 /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510 /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511 /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512 /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513 /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514 /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515 /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516 /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517 /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518 /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519 /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520 /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521 /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522 /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523 /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
139524 break;
139525 /********** End reduce actions ************************************************/
139526 };
139527 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139528 yygoto = yyRuleInfo[yyruleno].lhs;
139529 yysize = yyRuleInfo[yyruleno].nrhs;
139530 yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
139531
139532 /* There are no SHIFTREDUCE actions on nonterminals because the table
139533 ** generator has simplified them to pure REDUCE actions. */
139534 assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
139535
139536 /* It is not possible for a REDUCE to be followed by an error */
139537 assert( yyact!=YY_ERROR_ACTION );
139538
139539 if( yyact==YY_ACCEPT_ACTION ){
139540 yypParser->yytos += yysize;
139541 yy_accept(yypParser);
139542 }else{
139543 yymsp += yysize+1;
139544 yypParser->yytos = yymsp;
139545 yymsp->stateno = (YYACTIONTYPE)yyact;
139546 yymsp->major = (YYCODETYPE)yygoto;
139547 yyTraceShift(yypParser, yyact);
 
 
 
 
139548 }
139549 }
139550
139551 /*
139552 ** The following code executes when the parse fails
@@ -141110,13 +140494,10 @@
141110 /************** Continuing where we left off in main.c ***********************/
141111 #endif
141112 #ifdef SQLITE_ENABLE_JSON1
141113 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
141114 #endif
141115 #ifdef SQLITE_ENABLE_STMTVTAB
141116 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
141117 #endif
141118 #ifdef SQLITE_ENABLE_FTS5
141119 SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
141120 #endif
141121
141122 #ifndef SQLITE_AMALGAMATION
@@ -141896,11 +141277,10 @@
141896 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141897 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141898 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141899 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141900 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
141901 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
141902 };
141903 unsigned int i;
141904 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141905 for(i=0; i<ArraySize(aFlagOp); i++){
141906 if( aFlagOp[i].op==op ){
@@ -141953,11 +141333,10 @@
141953 int rc, n;
141954 n = nKey1<nKey2 ? nKey1 : nKey2;
141955 /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares
141956 ** strings byte by byte using the memcmp() function from the standard C
141957 ** library. */
141958 assert( pKey1 && pKey2 );
141959 rc = memcmp(pKey1, pKey2, n);
141960 if( rc==0 ){
141961 if( padFlag
141962 && allSpaces(((char*)pKey1)+n, nKey1-n)
141963 && allSpaces(((char*)pKey2)+n, nKey2-n)
@@ -144002,13 +143381,10 @@
144002 | SQLITE_CellSizeCk
144003 #endif
144004 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
144005 | SQLITE_Fts3Tokenizer
144006 #endif
144007 #if defined(SQLITE_ENABLE_QPSG)
144008 | SQLITE_EnableQPSG
144009 #endif
144010 ;
144011 sqlite3HashInit(&db->aCollSeq);
144012 #ifndef SQLITE_OMIT_VIRTUALTABLE
144013 sqlite3HashInit(&db->aModule);
144014 #endif
@@ -144141,16 +143517,10 @@
144141
144142 #ifdef SQLITE_ENABLE_JSON1
144143 if( !db->mallocFailed && rc==SQLITE_OK){
144144 rc = sqlite3Json1Init(db);
144145 }
144146 #endif
144147
144148 #ifdef SQLITE_ENABLE_STMTVTAB
144149 if( !db->mallocFailed && rc==SQLITE_OK){
144150 rc = sqlite3StmtVtabInit(db);
144151 }
144152 #endif
144153
144154 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
144155 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
144156 ** mode. Doing nothing at all also makes NORMAL the default.
@@ -144433,16 +143803,10 @@
144433 SQLITE_PRIVATE int sqlite3CantopenError(int lineno){
144434 testcase( sqlite3GlobalConfig.xLog!=0 );
144435 return reportError(SQLITE_CANTOPEN, lineno, "cannot open file");
144436 }
144437 #ifdef SQLITE_DEBUG
144438 SQLITE_PRIVATE int sqlite3CorruptPgnoError(int lineno, Pgno pgno){
144439 char zMsg[100];
144440 sqlite3_snprintf(sizeof(zMsg), zMsg, "database corruption page %d", pgno);
144441 testcase( sqlite3GlobalConfig.xLog!=0 );
144442 return reportError(SQLITE_CORRUPT, lineno, zMsg);
144443 }
144444 SQLITE_PRIVATE int sqlite3NomemError(int lineno){
144445 testcase( sqlite3GlobalConfig.xLog!=0 );
144446 return reportError(SQLITE_NOMEM, lineno, "OOM");
144447 }
144448 SQLITE_PRIVATE int sqlite3IoerrnomemError(int lineno){
@@ -145198,62 +144562,10 @@
145198 SQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
145199 sqlite3_free(pSnapshot);
145200 }
145201 #endif /* SQLITE_ENABLE_SNAPSHOT */
145202
145203 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
145204 /*
145205 ** Given the name of a compile-time option, return true if that option
145206 ** was used and false if not.
145207 **
145208 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
145209 ** is not required for a match.
145210 */
145211 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
145212 int i, n;
145213 int nOpt;
145214 const char **azCompileOpt;
145215
145216 #if SQLITE_ENABLE_API_ARMOR
145217 if( zOptName==0 ){
145218 (void)SQLITE_MISUSE_BKPT;
145219 return 0;
145220 }
145221 #endif
145222
145223 azCompileOpt = sqlite3CompileOptions(&nOpt);
145224
145225 if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
145226 n = sqlite3Strlen30(zOptName);
145227
145228 /* Since nOpt is normally in single digits, a linear search is
145229 ** adequate. No need for a binary search. */
145230 for(i=0; i<nOpt; i++){
145231 if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0
145232 && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0
145233 ){
145234 return 1;
145235 }
145236 }
145237 return 0;
145238 }
145239
145240 /*
145241 ** Return the N-th compile-time option string. If N is out of range,
145242 ** return a NULL pointer.
145243 */
145244 SQLITE_API const char *sqlite3_compileoption_get(int N){
145245 int nOpt;
145246 const char **azCompileOpt;
145247 azCompileOpt = sqlite3CompileOptions(&nOpt);
145248 if( N>=0 && N<nOpt ){
145249 return azCompileOpt[N];
145250 }
145251 return 0;
145252 }
145253 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
145254
145255 /************** End of main.c ************************************************/
145256 /************** Begin file notify.c ******************************************/
145257 /*
145258 ** 2009 March 3
145259 **
@@ -148237,11 +147549,11 @@
148237 pCsr->pStmt = p->pSeekStmt;
148238 p->pSeekStmt = 0;
148239 }else{
148240 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
148241 if( !zSql ) return SQLITE_NOMEM;
148242 rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
148243 sqlite3_free(zSql);
148244 }
148245 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
148246 }
148247 return rc;
@@ -149774,11 +149086,11 @@
149774 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149775 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149776 );
149777 }
149778 if( zSql ){
149779 rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
149780 sqlite3_free(zSql);
149781 }else{
149782 rc = SQLITE_NOMEM;
149783 }
149784 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156981,12 +156293,11 @@
156981 zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156982 }
156983 if( !zSql ){
156984 rc = SQLITE_NOMEM;
156985 }else{
156986 rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
156987 &pStmt, NULL);
156988 sqlite3_free(zSql);
156989 assert( rc==SQLITE_OK || pStmt==0 );
156990 p->aStmt[eStmt] = pStmt;
156991 }
156992 }
@@ -168092,12 +167403,11 @@
168092
168093 rc = rtreeQueryStat1(db, pRtree);
168094 for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
168095 char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
168096 if( zSql ){
168097 rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
168098 appStmt[i], 0);
168099 }else{
168100 rc = SQLITE_NOMEM;
168101 }
168102 sqlite3_free(zSql);
168103 }
@@ -169855,14 +169165,14 @@
169855 ** as fully applied. Otherwise, assuming no error has occurred, save the
169856 ** current state of the RBU update appliation to the RBU database.
169857 **
169858 ** If an error has already occurred as part of an sqlite3rbu_step()
169859 ** or sqlite3rbu_open() call, or if one occurs within this function, an
169860 ** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,
169861 ** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted
169862 ** English language error message. It is the responsibility of the caller to
169863 ** eventually free any such buffer using sqlite3_free().
169864 **
169865 ** Otherwise, if no error occurs, this function returns SQLITE_OK if the
169866 ** update has been partially applied, or SQLITE_DONE if it has been
169867 ** completely applied.
169868 */
@@ -173714,15 +173024,11 @@
173714 sqlite3_free(p->aBuf);
173715 sqlite3_free(p->aFrame);
173716
173717 rbuEditErrmsg(p);
173718 rc = p->rc;
173719 if( pzErrmsg ){
173720 *pzErrmsg = p->zErrmsg;
173721 }else{
173722 sqlite3_free(p->zErrmsg);
173723 }
173724 sqlite3_free(p->zState);
173725 sqlite3_free(p);
173726 }else{
173727 rc = SQLITE_NOMEM;
173728 *pzErrmsg = 0;
@@ -178276,16 +177582,15 @@
178276
178277 sessionDiscardData(&p->in);
178278 p->in.iCurrent = p->in.iNext;
178279
178280 op = p->in.aData[p->in.iNext++];
178281 while( op=='T' || op=='P' ){
178282 p->bPatchset = (op=='P');
178283 if( sessionChangesetReadTblhdr(p) ) return p->rc;
178284 if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
178285 p->in.iCurrent = p->in.iNext;
178286 if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
178287 op = p->in.aData[p->in.iNext++];
178288 }
178289
178290 p->op = op;
178291 p->bIndirect = p->in.aData[p->in.iNext++];
@@ -184139,16 +183444,16 @@
184139 ** fts5yy_default[] Default action for each state.
184140 **
184141 *********** Begin parsing tables **********************************************/
184142 #define fts5YY_ACTTAB_COUNT (98)
184143 static const fts5YYACTIONTYPE fts5yy_action[] = {
184144 /* 0 */ 105, 19, 90, 6, 26, 93, 92, 24, 24, 17,
184145 /* 10 */ 90, 6, 26, 16, 92, 54, 24, 18, 90, 6,
184146 /* 20 */ 26, 10, 92, 12, 24, 75, 86, 90, 6, 26,
184147 /* 30 */ 13, 92, 75, 24, 20, 90, 6, 26, 101, 92,
184148 /* 40 */ 56, 24, 27, 90, 6, 26, 100, 92, 21, 24,
184149 /* 50 */ 23, 15, 30, 11, 1, 91, 22, 25, 9, 92,
184150 /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
184151 /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
184152 /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
184153 /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
184154 };
@@ -184249,11 +183554,10 @@
184249 int fts5yystksz; /* Current side of the stack */
184250 fts5yyStackEntry *fts5yystack; /* The parser's stack */
184251 fts5yyStackEntry fts5yystk0; /* First stack entry */
184252 #else
184253 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
184254 fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */
184255 #endif
184256 };
184257 typedef struct fts5yyParser fts5yyParser;
184258
184259 #ifndef NDEBUG
@@ -184399,11 +183703,10 @@
184399 pParser->fts5yyerrcnt = -1;
184400 #endif
184401 pParser->fts5yytos = pParser->fts5yystack;
184402 pParser->fts5yystack[0].stateno = 0;
184403 pParser->fts5yystack[0].major = 0;
184404 pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184405 }
184406
184407 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184408 /*
184409 ** This function allocates a new parser.
@@ -184698,11 +184001,11 @@
184698 fts5yypParser->fts5yyhwm++;
184699 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184700 }
184701 #endif
184702 #if fts5YYSTACKDEPTH>0
184703 if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){
184704 fts5yypParser->fts5yytos--;
184705 fts5yyStackOverflow(fts5yypParser);
184706 return;
184707 }
184708 #else
@@ -184726,39 +184029,39 @@
184726
184727 /* The following table contains information about every rule that
184728 ** is used during the reduce.
184729 */
184730 static const struct {
184731 fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184732 signed char nrhs; /* Negative of the number of RHS symbols in the rule */
184733 } fts5yyRuleInfo[] = {
184734 { 16, -1 },
184735 { 20, -4 },
184736 { 20, -3 },
184737 { 20, -1 },
184738 { 20, -2 },
184739 { 21, -2 },
184740 { 21, -1 },
184741 { 17, -3 },
184742 { 17, -3 },
184743 { 17, -3 },
184744 { 17, -5 },
184745 { 17, -3 },
184746 { 17, -1 },
184747 { 19, -1 },
184748 { 19, -2 },
184749 { 18, -1 },
184750 { 18, -3 },
184751 { 22, -1 },
184752 { 22, -5 },
184753 { 23, -1 },
184754 { 23, -2 },
184755 { 25, 0 },
184756 { 25, -2 },
184757 { 24, -4 },
184758 { 24, -2 },
184759 { 26, -1 },
184760 { 26, 0 },
184761 };
184762
184763 static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184764
@@ -184778,11 +184081,11 @@
184778 fts5yymsp = fts5yypParser->fts5yytos;
184779 #ifndef NDEBUG
184780 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184781 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184782 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184783 fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
184784 }
184785 #endif /* NDEBUG */
184786
184787 /* Check that the stack is large enough to grow by a single entry
184788 ** if the RHS of the rule is empty. This ensures that there is room
@@ -184793,11 +184096,11 @@
184793 fts5yypParser->fts5yyhwm++;
184794 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184795 }
184796 #endif
184797 #if fts5YYSTACKDEPTH>0
184798 if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
184799 fts5yyStackOverflow(fts5yypParser);
184800 return;
184801 }
184802 #else
184803 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184960,28 +184263,24 @@
184960 /********** End reduce actions ************************************************/
184961 };
184962 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184963 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184964 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184965 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184966
184967 /* There are no SHIFTREDUCE actions on nonterminals because the table
184968 ** generator has simplified them to pure REDUCE actions. */
184969 assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );
184970
184971 /* It is not possible for a REDUCE to be followed by an error */
184972 assert( fts5yyact!=fts5YY_ERROR_ACTION );
184973
184974 if( fts5yyact==fts5YY_ACCEPT_ACTION ){
184975 fts5yypParser->fts5yytos += fts5yysize;
184976 fts5yy_accept(fts5yypParser);
184977 }else{
184978 fts5yymsp += fts5yysize+1;
184979 fts5yypParser->fts5yytos = fts5yymsp;
184980 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184981 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184982 fts5yyTraceShift(fts5yypParser, fts5yyact);
 
 
 
 
184983 }
184984 }
184985
184986 /*
184987 ** The following code executes when the parse fails
@@ -190274,15 +189573,14 @@
190274 if( !apNew ) return SQLITE_NOMEM;
190275 memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
190276
190277 for(i=0; i<pHash->nSlot; i++){
190278 while( apOld[i] ){
190279 unsigned int iHash;
190280 Fts5HashEntry *p = apOld[i];
190281 apOld[i] = p->pHashNext;
190282 iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p),
190283 (int)strlen(fts5EntryKey(p)));
190284 p->pHashNext = apNew[iHash];
190285 apNew[iHash] = p;
190286 }
190287 }
190288
@@ -190581,11 +189879,11 @@
190581 const char *pTerm, int nTerm, /* Query term */
190582 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
190583 int *pnDoclist /* OUT: Size of doclist in bytes */
190584 ){
190585 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
190586 char *zKey = 0;
190587 Fts5HashEntry *p;
190588
190589 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
190590 zKey = fts5EntryKey(p);
190591 if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
@@ -191369,12 +190667,11 @@
191369 sqlite3_stmt **ppStmt,
191370 char *zSql
191371 ){
191372 if( p->rc==SQLITE_OK ){
191373 if( zSql ){
191374 p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
191375 SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
191376 }else{
191377 p->rc = SQLITE_NOMEM;
191378 }
191379 }
191380 sqlite3_free(zSql);
@@ -191419,12 +190716,11 @@
191419 pConfig->zDb, pConfig->zName
191420 );
191421 if( zSql==0 ){
191422 rc = SQLITE_NOMEM;
191423 }else{
191424 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
191425 SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
191426 sqlite3_free(zSql);
191427 }
191428 if( rc!=SQLITE_OK ){
191429 p->rc = rc;
191430 return;
@@ -198019,12 +197315,11 @@
198019 va_start(ap, zFmt);
198020 zSql = sqlite3_vmprintf(zFmt, ap);
198021 if( zSql==0 ){
198022 rc = SQLITE_NOMEM;
198023 }else{
198024 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198025 SQLITE_PREPARE_PERSISTENT, &pRet, 0);
198026 if( rc!=SQLITE_OK ){
198027 *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
198028 }
198029 sqlite3_free(zSql);
198030 }
@@ -198156,12 +197451,11 @@
198156
198157 if( zRankArgs ){
198158 char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
198159 if( zSql ){
198160 sqlite3_stmt *pStmt = 0;
198161 rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
198162 SQLITE_PREPARE_PERSISTENT, &pStmt, 0);
198163 sqlite3_free(zSql);
198164 assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
198165 if( rc==SQLITE_OK ){
198166 if( SQLITE_ROW==sqlite3_step(pStmt) ){
198167 int nByte;
@@ -199766,11 +199060,11 @@
199766 int nArg, /* Number of args */
199767 sqlite3_value **apUnused /* Function arguments */
199768 ){
199769 assert( nArg==0 );
199770 UNUSED_PARAM2(nArg, apUnused);
199771 sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
199772 }
199773
199774 static int fts5Init(sqlite3 *db){
199775 static const sqlite3_module fts5Mod = {
199776 /* iVersion */ 2,
@@ -200020,12 +199314,11 @@
200020 }
200021
200022 if( zSql==0 ){
200023 rc = SQLITE_NOMEM;
200024 }else{
200025 rc = sqlite3_prepare_v3(pC->db, zSql, -1,
200026 SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
200027 sqlite3_free(zSql);
200028 if( rc!=SQLITE_OK && pzErrMsg ){
200029 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
200030 }
200031 }
@@ -203621,325 +202914,5 @@
203621
203622
203623 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
203624
203625 /************** End of fts5.c ************************************************/
203626 /************** Begin file stmt.c ********************************************/
203627 /*
203628 ** 2017-05-31
203629 **
203630 ** The author disclaims copyright to this source code. In place of
203631 ** a legal notice, here is a blessing:
203632 **
203633 ** May you do good and not evil.
203634 ** May you find forgiveness for yourself and forgive others.
203635 ** May you share freely, never taking more than you give.
203636 **
203637 *************************************************************************
203638 **
203639 ** This file demonstrates an eponymous virtual table that returns information
203640 ** about all prepared statements for the database connection.
203641 **
203642 ** Usage example:
203643 **
203644 ** .load ./stmt
203645 ** .mode line
203646 ** .header on
203647 ** SELECT * FROM stmt;
203648 */
203649 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)
203650 #if !defined(SQLITEINT_H)
203651 /* #include "sqlite3ext.h" */
203652 #endif
203653 SQLITE_EXTENSION_INIT1
203654 /* #include <assert.h> */
203655 /* #include <string.h> */
203656
203657 #ifndef SQLITE_OMIT_VIRTUALTABLE
203658
203659 /*
203660 ** The following macros are used to cast pointers to integers.
203661 ** The way you do this varies from one compiler
203662 ** to the next, so we have developed the following set of #if statements
203663 ** to generate appropriate macros for a wide range of compilers.
203664 */
203665 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
203666 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))
203667 #elif !defined(__GNUC__) /* Works for compilers other than LLVM */
203668 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0))
203669 #elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
203670 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X))
203671 #else /* Generates a warning - but it always works */
203672 # define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X))
203673 #endif
203674
203675
203676 /* stmt_vtab is a subclass of sqlite3_vtab which will
203677 ** serve as the underlying representation of a stmt virtual table
203678 */
203679 typedef struct stmt_vtab stmt_vtab;
203680 struct stmt_vtab {
203681 sqlite3_vtab base; /* Base class - must be first */
203682 sqlite3 *db; /* Database connection for this stmt vtab */
203683 };
203684
203685 /* stmt_cursor is a subclass of sqlite3_vtab_cursor which will
203686 ** serve as the underlying representation of a cursor that scans
203687 ** over rows of the result
203688 */
203689 typedef struct stmt_cursor stmt_cursor;
203690 struct stmt_cursor {
203691 sqlite3_vtab_cursor base; /* Base class - must be first */
203692 sqlite3 *db; /* Database connection for this cursor */
203693 sqlite3_stmt *pStmt; /* Statement cursor is currently pointing at */
203694 sqlite3_int64 iRowid; /* The rowid */
203695 };
203696
203697 /*
203698 ** The stmtConnect() method is invoked to create a new
203699 ** stmt_vtab that describes the generate_stmt virtual table.
203700 **
203701 ** Think of this routine as the constructor for stmt_vtab objects.
203702 **
203703 ** All this routine needs to do is:
203704 **
203705 ** (1) Allocate the stmt_vtab object and initialize all fields.
203706 **
203707 ** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708 ** result set of queries against generate_stmt will look like.
203709 */
203710 static int stmtConnect(
203711 sqlite3 *db,
203712 void *pAux,
203713 int argc, const char *const*argv,
203714 sqlite3_vtab **ppVtab,
203715 char **pzErr
203716 ){
203717 stmt_vtab *pNew;
203718 int rc;
203719
203720 /* Column numbers */
203721 #define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */
203722 #define STMT_COLUMN_SQL 1 /* SQL for the statement */
203723 #define STMT_COLUMN_NCOL 2 /* Number of result columns */
203724 #define STMT_COLUMN_RO 3 /* True if read-only */
203725 #define STMT_COLUMN_BUSY 4 /* True if currently busy */
203726 #define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */
203727 #define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */
203728 #define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */
203729 #define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */
203730 #define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */
203731 #define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */
203732 #define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */
203733
203734
203735 rc = sqlite3_declare_vtab(db,
203736 "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
203737 "reprep,run,mem)");
203738 if( rc==SQLITE_OK ){
203739 pNew = sqlite3_malloc( sizeof(*pNew) );
203740 *ppVtab = (sqlite3_vtab*)pNew;
203741 if( pNew==0 ) return SQLITE_NOMEM;
203742 memset(pNew, 0, sizeof(*pNew));
203743 pNew->db = db;
203744 }
203745 return rc;
203746 }
203747
203748 /*
203749 ** This method is the destructor for stmt_cursor objects.
203750 */
203751 static int stmtDisconnect(sqlite3_vtab *pVtab){
203752 sqlite3_free(pVtab);
203753 return SQLITE_OK;
203754 }
203755
203756 /*
203757 ** Constructor for a new stmt_cursor object.
203758 */
203759 static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
203760 stmt_cursor *pCur;
203761 pCur = sqlite3_malloc( sizeof(*pCur) );
203762 if( pCur==0 ) return SQLITE_NOMEM;
203763 memset(pCur, 0, sizeof(*pCur));
203764 pCur->db = ((stmt_vtab*)p)->db;
203765 *ppCursor = &pCur->base;
203766 return SQLITE_OK;
203767 }
203768
203769 /*
203770 ** Destructor for a stmt_cursor.
203771 */
203772 static int stmtClose(sqlite3_vtab_cursor *cur){
203773 sqlite3_free(cur);
203774 return SQLITE_OK;
203775 }
203776
203777
203778 /*
203779 ** Advance a stmt_cursor to its next row of output.
203780 */
203781 static int stmtNext(sqlite3_vtab_cursor *cur){
203782 stmt_cursor *pCur = (stmt_cursor*)cur;
203783 pCur->iRowid++;
203784 pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);
203785 return SQLITE_OK;
203786 }
203787
203788 /*
203789 ** Return values of columns for the row at which the stmt_cursor
203790 ** is currently pointing.
203791 */
203792 static int stmtColumn(
203793 sqlite3_vtab_cursor *cur, /* The cursor */
203794 sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
203795 int i /* Which column to return */
203796 ){
203797 stmt_cursor *pCur = (stmt_cursor*)cur;
203798 switch( i ){
203799 case STMT_COLUMN_PTR: {
203800 sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt));
203801 break;
203802 }
203803 case STMT_COLUMN_SQL: {
203804 sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
203805 break;
203806 }
203807 case STMT_COLUMN_NCOL: {
203808 sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));
203809 break;
203810 }
203811 case STMT_COLUMN_RO: {
203812 sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));
203813 break;
203814 }
203815 case STMT_COLUMN_BUSY: {
203816 sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
203817 break;
203818 }
203819 case STMT_COLUMN_MEM: {
203820 i = SQLITE_STMTSTATUS_MEMUSED +
203821 STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
203822 /* Fall thru */
203823 }
203824 case STMT_COLUMN_NSCAN:
203825 case STMT_COLUMN_NSORT:
203826 case STMT_COLUMN_NAIDX:
203827 case STMT_COLUMN_NSTEP:
203828 case STMT_COLUMN_REPREP:
203829 case STMT_COLUMN_RUN: {
203830 sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
203831 i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
203832 break;
203833 }
203834 }
203835 return SQLITE_OK;
203836 }
203837
203838 /*
203839 ** Return the rowid for the current row. In this implementation, the
203840 ** rowid is the same as the output value.
203841 */
203842 static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
203843 stmt_cursor *pCur = (stmt_cursor*)cur;
203844 *pRowid = pCur->iRowid;
203845 return SQLITE_OK;
203846 }
203847
203848 /*
203849 ** Return TRUE if the cursor has been moved off of the last
203850 ** row of output.
203851 */
203852 static int stmtEof(sqlite3_vtab_cursor *cur){
203853 stmt_cursor *pCur = (stmt_cursor*)cur;
203854 return pCur->pStmt==0;
203855 }
203856
203857 /*
203858 ** This method is called to "rewind" the stmt_cursor object back
203859 ** to the first row of output. This method is always called at least
203860 ** once prior to any call to stmtColumn() or stmtRowid() or
203861 ** stmtEof().
203862 */
203863 static int stmtFilter(
203864 sqlite3_vtab_cursor *pVtabCursor,
203865 int idxNum, const char *idxStr,
203866 int argc, sqlite3_value **argv
203867 ){
203868 stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;
203869 pCur->pStmt = 0;
203870 pCur->iRowid = 0;
203871 return stmtNext(pVtabCursor);
203872 }
203873
203874 /*
203875 ** SQLite will invoke this method one or more times while planning a query
203876 ** that uses the generate_stmt virtual table. This routine needs to create
203877 ** a query plan for each invocation and compute an estimated cost for that
203878 ** plan.
203879 */
203880 static int stmtBestIndex(
203881 sqlite3_vtab *tab,
203882 sqlite3_index_info *pIdxInfo
203883 ){
203884 pIdxInfo->estimatedCost = (double)500;
203885 pIdxInfo->estimatedRows = 500;
203886 return SQLITE_OK;
203887 }
203888
203889 /*
203890 ** This following structure defines all the methods for the
203891 ** generate_stmt virtual table.
203892 */
203893 static sqlite3_module stmtModule = {
203894 0, /* iVersion */
203895 0, /* xCreate */
203896 stmtConnect, /* xConnect */
203897 stmtBestIndex, /* xBestIndex */
203898 stmtDisconnect, /* xDisconnect */
203899 0, /* xDestroy */
203900 stmtOpen, /* xOpen - open a cursor */
203901 stmtClose, /* xClose - close a cursor */
203902 stmtFilter, /* xFilter - configure scan constraints */
203903 stmtNext, /* xNext - advance a cursor */
203904 stmtEof, /* xEof - check for end of scan */
203905 stmtColumn, /* xColumn - read data */
203906 stmtRowid, /* xRowid - read data */
203907 0, /* xUpdate */
203908 0, /* xBegin */
203909 0, /* xSync */
203910 0, /* xCommit */
203911 0, /* xRollback */
203912 0, /* xFindMethod */
203913 0, /* xRename */
203914 };
203915
203916 #endif /* SQLITE_OMIT_VIRTUALTABLE */
203917
203918 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
203919 int rc = SQLITE_OK;
203920 #ifndef SQLITE_OMIT_VIRTUALTABLE
203921 rc = sqlite3_create_module(db, "stmt", &stmtModule, 0);
203922 #endif
203923 return rc;
203924 }
203925
203926 #ifndef SQLITE_CORE
203927 #ifdef _WIN32
203928 __declspec(dllexport)
203929 #endif
203930 SQLITE_API int sqlite3_stmt_init(
203931 sqlite3 *db,
203932 char **pzErrMsg,
203933 const sqlite3_api_routines *pApi
203934 ){
203935 int rc = SQLITE_OK;
203936 SQLITE_EXTENSION_INIT2(pApi);
203937 #ifndef SQLITE_OMIT_VIRTUALTABLE
203938 rc = sqlite3StmtVtabInit(db);
203939 #endif
203940 return rc;
203941 }
203942 #endif /* SQLITE_CORE */
203943 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
203944
203945 /************** End of stmt.c ************************************************/
203946
--- 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.19.3. 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.
@@ -20,762 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25 /************** Begin file sqliteInt.h ***************************************/
26 /*
27 ** 2001 September 15
28 **
29 ** The author disclaims copyright to this source code. In place of
@@ -1026,11 +274,11 @@
274 ** MinGW.
275 */
276 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
277 /************** Begin file sqlite3.h *****************************************/
278 /*
279 ** 2001 September 15
280 **
281 ** The author disclaims copyright to this source code. In place of
282 ** a legal notice, here is a blessing:
283 **
284 ** May you do good and not evil.
@@ -1148,13 +396,13 @@
396 **
397 ** See also: [sqlite3_libversion()],
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.19.3"
402 #define SQLITE_VERSION_NUMBER 3019003
403 #define SQLITE_SOURCE_ID "2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -1262,11 +510,11 @@
510 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
511 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
512 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
513 ** and [sqlite3_close_v2()] are its destructors. There are many other
514 ** interfaces (such as
515 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
516 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
517 ** sqlite3 object.
518 */
519 typedef struct sqlite3 sqlite3;
520
@@ -1366,11 +614,11 @@
614 /*
615 ** CAPI3REF: One-Step Query Execution Interface
616 ** METHOD: sqlite3
617 **
618 ** The sqlite3_exec() interface is a convenience wrapper around
619 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
620 ** that allows an application to run multiple statements of SQL
621 ** without having to use a lot of C code.
622 **
623 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
624 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -3034,31 +2282,19 @@
2282 ** default) to enable them. The second parameter is a pointer to an integer
2283 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2284 ** have been disabled - 0 if they are not disabled, 1 if they are.
2285 ** </dd>
2286 **
 
 
 
 
 
 
 
 
 
 
 
2287 ** </dl>
2288 */
2289 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2290 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2291 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2292 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2293 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2294 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2295 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
 
2296
2297
2298 /*
2299 ** CAPI3REF: Enable Or Disable Extended Result Codes
2300 ** METHOD: sqlite3
@@ -3718,26 +2954,25 @@
2954 **
2955 ** ^This routine registers an authorizer callback with a particular
2956 ** [database connection], supplied in the first argument.
2957 ** ^The authorizer callback is invoked as SQL statements are being compiled
2958 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2959 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
 
2960 ** points during the compilation process, as logic is being created
2961 ** to perform various actions, the authorizer callback is invoked to
2962 ** see if those actions are allowed. ^The authorizer callback should
2963 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2964 ** specific action but allow the SQL statement to continue to be
2965 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2966 ** rejected with an error. ^If the authorizer callback returns
2967 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2968 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2969 ** the authorizer will fail with an error message.
2970 **
2971 ** When the callback returns [SQLITE_OK], that means the operation
2972 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2973 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2974 ** authorizer will fail with an error message explaining that
2975 ** access is denied.
2976 **
2977 ** ^The first parameter to the authorizer callback is a copy of the third
2978 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -3784,23 +3019,23 @@
3019 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3020 ** The authorizer is disabled by default.
3021 **
3022 ** The authorizer callback must not do anything that will modify
3023 ** the database connection that invoked the authorizer callback.
3024 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3025 ** database connections for the meaning of "modify" in this paragraph.
3026 **
3027 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3028 ** statement might be re-prepared during [sqlite3_step()] due to a
3029 ** schema change. Hence, the application should ensure that the
3030 ** correct authorizer callback remains in place during the [sqlite3_step()].
3031 **
3032 ** ^Note that the authorizer callback is invoked only during
3033 ** [sqlite3_prepare()] or its variants. Authorization is not
3034 ** performed during statement evaluation in [sqlite3_step()], unless
3035 ** as stated in the previous paragraph, sqlite3_step() invokes
3036 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3037 */
3038 SQLITE_API int sqlite3_set_authorizer(
3039 sqlite3*,
3040 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
3041 void *pUserData
@@ -4032,11 +3267,11 @@
3267 ** interrupted. This feature can be used to implement a
3268 ** "Cancel" button on a GUI progress dialog box.
3269 **
3270 ** The progress handler callback must not do anything that will modify
3271 ** the database connection that invoked the progress handler.
3272 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3273 ** database connections for the meaning of "modify" in this paragraph.
3274 **
3275 */
3276 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3277
@@ -4386,11 +3621,11 @@
3621 ** prepared statement before it can be run.
3622 **
3623 ** The life-cycle of a prepared statement object usually goes like this:
3624 **
3625 ** <ol>
3626 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3627 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3628 ** interfaces.
3629 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3630 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3631 ** to step 2. Do this zero or more times.
@@ -4468,11 +3703,11 @@
3703 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3704 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3705 **
3706 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3707 ** <dd>The maximum number of instructions in a virtual machine program
3708 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3709 ** the equivalent tries to allocate space for more than this many opcodes
3710 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3711 **
3712 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3713 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -4508,61 +3743,28 @@
3743 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3744 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3745 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3746 #define SQLITE_LIMIT_WORKER_THREADS 11
3747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3748
3749 /*
3750 ** CAPI3REF: Compiling An SQL Statement
3751 ** KEYWORDS: {SQL statement compiler}
3752 ** METHOD: sqlite3
3753 ** CONSTRUCTOR: sqlite3_stmt
3754 **
3755 ** To execute an SQL query, it must first be compiled into a byte-code
3756 ** program using one of these routines.
 
 
 
 
 
 
 
 
 
 
 
3757 **
3758 ** The first argument, "db", is a [database connection] obtained from a
3759 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3760 ** [sqlite3_open16()]. The database connection must not have been closed.
3761 **
3762 ** The second argument, "zSql", is the statement to be compiled, encoded
3763 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3764 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3765 ** use UTF-16.
 
3766 **
3767 ** ^If the nByte argument is negative, then zSql is read up to the
3768 ** first zero terminator. ^If nByte is positive, then it is the
3769 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3770 ** statement is generated.
@@ -4585,15 +3787,14 @@
3787 ** ppStmt may not be NULL.
3788 **
3789 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
3790 ** otherwise an [error code] is returned.
3791 **
3792 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3793 ** recommended for all new programs. The two older interfaces are retained
3794 ** for backwards compatibility, but their use is discouraged.
3795 ** ^In the "v2" interfaces, the prepared statement
 
3796 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
3797 ** original SQL text. This causes the [sqlite3_step()] interface to
3798 ** behave differently in three ways:
3799 **
3800 ** <ol>
@@ -4622,16 +3823,10 @@
3823 ** ^The specific value of WHERE-clause [parameter] might influence the
3824 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3825 ** or [GLOB] operator or if the parameter is compared to an indexed column
3826 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3827 ** </li>
 
 
 
 
 
 
3828 ** </ol>
3829 */
3830 SQLITE_API int sqlite3_prepare(
3831 sqlite3 *db, /* Database handle */
3832 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -4642,18 +3837,10 @@
3837 SQLITE_API int sqlite3_prepare_v2(
3838 sqlite3 *db, /* Database handle */
3839 const char *zSql, /* SQL statement, UTF-8 encoded */
3840 int nByte, /* Maximum length of zSql in bytes. */
3841 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
 
 
 
 
 
 
 
 
3842 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3843 );
3844 SQLITE_API int sqlite3_prepare16(
3845 sqlite3 *db, /* Database handle */
3846 const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -4666,27 +3853,18 @@
3853 const void *zSql, /* SQL statement, UTF-16 encoded */
3854 int nByte, /* Maximum length of zSql in bytes. */
3855 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3856 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3857 );
 
 
 
 
 
 
 
 
3858
3859 /*
3860 ** CAPI3REF: Retrieving Statement SQL
3861 ** METHOD: sqlite3_stmt
3862 **
3863 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3864 ** SQL text used to create [prepared statement] P if P was
3865 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
3866 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3867 ** string containing the SQL text of prepared statement P with
3868 ** [bound parameters] expanded.
3869 **
3870 ** ^(For example, if a prepared statement is created using the SQL
@@ -4828,11 +4006,11 @@
4006 ** CAPI3REF: Binding Values To Prepared Statements
4007 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
4008 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
4009 ** METHOD: sqlite3_stmt
4010 **
4011 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
4012 ** literals may be replaced by a [parameter] that matches one of following
4013 ** templates:
4014 **
4015 ** <ul>
4016 ** <li> ?
@@ -4847,11 +4025,11 @@
4025 ** parameters (also called "host parameter names" or "SQL parameters")
4026 ** can be set using the sqlite3_bind_*() routines defined here.
4027 **
4028 ** ^The first argument to the sqlite3_bind_*() routines is always
4029 ** a pointer to the [sqlite3_stmt] object returned from
4030 ** [sqlite3_prepare_v2()] or its variants.
4031 **
4032 ** ^The second argument is the index of the SQL parameter to be set.
4033 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4034 ** SQL parameter is used more than once, second and subsequent
4035 ** occurrences have the same index as the first occurrence.
@@ -4984,12 +4162,12 @@
4162 ** ^The first host parameter has an index of 1, not 0.
4163 **
4164 ** ^If the value N is out of range or if the N-th parameter is
4165 ** nameless, then NULL is returned. ^The returned string is
4166 ** always in UTF-8 encoding even if the named parameter was
4167 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
4168 ** [sqlite3_prepare16_v2()].
4169 **
4170 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4171 ** [sqlite3_bind_parameter_count()], and
4172 ** [sqlite3_bind_parameter_index()].
4173 */
@@ -5002,12 +4180,11 @@
4180 ** ^Return the index of an SQL parameter given its name. ^The
4181 ** index value returned is suitable for use as the second
4182 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
4183 ** is returned if no matching parameter is found. ^The parameter
4184 ** name must be given in UTF-8 even if the original statement
4185 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 
4186 **
4187 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
4188 ** [sqlite3_bind_parameter_count()], and
4189 ** [sqlite3_bind_parameter_name()].
4190 */
@@ -5157,22 +4334,20 @@
4334
4335 /*
4336 ** CAPI3REF: Evaluate An SQL Statement
4337 ** METHOD: sqlite3_stmt
4338 **
4339 ** After a [prepared statement] has been prepared using either
4340 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
 
4341 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
4342 ** must be called one or more times to evaluate the statement.
4343 **
4344 ** The details of the behavior of the sqlite3_step() interface depend
4345 ** on whether the statement was prepared using the newer "v2" interface
4346 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4347 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4348 ** new "v2" interface is recommended for new applications but the legacy
 
4349 ** interface will continue to be supported.
4350 **
4351 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
4352 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
4353 ** ^With the "v2" interface, any of the other [result codes] or
@@ -5229,15 +4404,14 @@
4404 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
4405 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
4406 ** specific [error codes] that better describes the error.
4407 ** We admit that this is a goofy design. The problem has been fixed
4408 ** with the "v2" interface. If you prepare all of your SQL statements
4409 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
 
4410 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4411 ** then the more specific [error codes] are returned directly
4412 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4413 */
4414 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4415
4416 /*
4417 ** CAPI3REF: Number of columns in a result set
@@ -5298,11 +4472,11 @@
4472 ** METHOD: sqlite3_stmt
4473 **
4474 ** ^These routines return information about a single column of the current
4475 ** result row of a query. ^In every case the first argument is a pointer
4476 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4477 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
4478 ** and the second argument is the index of the column for which information
4479 ** should be returned. ^The leftmost column of the result set has the index 0.
4480 ** ^The number of columns in the result can be determined using
4481 ** [sqlite3_column_count()].
4482 **
@@ -6422,11 +5596,11 @@
5596 **
5597 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5598 ** to which a [prepared statement] belongs. ^The [database connection]
5599 ** returned by sqlite3_db_handle is the same [database connection]
5600 ** that was the first argument
5601 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5602 ** create the statement in the first place.
5603 */
5604 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5605
5606 /*
@@ -6498,11 +5672,11 @@
5672 ** the database connection that invoked the callback. Any actions
5673 ** to modify the database connection must be deferred until after the
5674 ** completion of the [sqlite3_step()] call that triggered the commit
5675 ** or rollback hook in the first place.
5676 ** Note that running any other SQL statements, including SELECT statements,
5677 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
5678 ** the database connections for the meaning of "modify" in this paragraph.
5679 **
5680 ** ^Registering a NULL function disables the callback.
5681 **
5682 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -6558,11 +5732,11 @@
5732 **
5733 ** The update hook implementation must not do anything that will modify
5734 ** the database connection that invoked the update hook. Any actions
5735 ** to modify the database connection must be deferred until after the
5736 ** completion of the [sqlite3_step()] call that triggered the update hook.
5737 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
5738 ** database connections for the meaning of "modify" in this paragraph.
5739 **
5740 ** ^The sqlite3_update_hook(D,C,P) function
5741 ** returns the P argument from the previous call
5742 ** on the same [database connection] D, or NULL for
@@ -6721,13 +5895,11 @@
5895 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5896 ** SQLITE_ERROR and if the specified column does not exist.
5897 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5898 ** NULL pointer, then this routine simply checks for the existence of the
5899 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5900 ** does not.
 
 
5901 **
5902 ** ^The column is identified by the second, third and fourth parameters to
5903 ** this function. ^(The second parameter is either the name of the database
5904 ** (i.e. "main", "temp", or an attached database) containing the specified
5905 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -8236,38 +7408,17 @@
7408 ** by the prepared statement if that number is less than or equal
7409 ** to 2147483647. The number of virtual machine operations can be
7410 ** used as a proxy for the total work done by the prepared statement.
7411 ** If the number of virtual machine operations exceeds 2147483647
7412 ** then the value returned by this statement status code is undefined.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7413 ** </dd>
7414 ** </dl>
7415 */
7416 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7417 #define SQLITE_STMTSTATUS_SORT 2
7418 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7419 #define SQLITE_STMTSTATUS_VM_STEP 4
 
 
 
7420
7421 /*
7422 ** CAPI3REF: Custom Page Cache Object
7423 **
7424 ** The sqlite3_pcache type is opaque. It is implemented by
@@ -11630,13 +10781,12 @@
10781
10782 /*
10783 ** Include the configuration header output by 'configure' if we're using the
10784 ** autoconf-based build
10785 */
10786 #ifdef _HAVE_SQLITE_CONFIG_H
10787 #include "config.h"
 
10788 #endif
10789
10790 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
10791 /************** Begin file sqliteLimit.h *************************************/
10792 /*
@@ -11942,15 +11092,10 @@
11092 ** threads can use SQLite as long as no two threads try to use the same
11093 ** database connection at the same time.
11094 **
11095 ** Older versions of SQLite used an optional THREADSAFE macro.
11096 ** We support that for legacy.
 
 
 
 
 
11097 */
11098 #if !defined(SQLITE_THREADSAFE)
11099 # if defined(THREADSAFE)
11100 # define SQLITE_THREADSAFE THREADSAFE
11101 # else
@@ -12537,10 +11682,11 @@
11682 ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
11683 ** on the command-line
11684 */
11685 #ifndef SQLITE_TEMP_STORE
11686 # define SQLITE_TEMP_STORE 1
11687 # define SQLITE_TEMP_STORE_xc 1 /* Exclude from ctime.c */
11688 #endif
11689
11690 /*
11691 ** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
11692 ** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
@@ -12837,19 +11983,21 @@
11983 || defined(__DragonFly__)
11984 # define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
11985 # else
11986 # define SQLITE_MAX_MMAP_SIZE 0
11987 # endif
11988 # define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */
11989 #endif
11990
11991 /*
11992 ** The default MMAP_SIZE is zero on all platforms. Or, even if a larger
11993 ** default MMAP_SIZE is specified at compile-time, make sure that it does
11994 ** not exceed the maximum mmap size.
11995 */
11996 #ifndef SQLITE_DEFAULT_MMAP_SIZE
11997 # define SQLITE_DEFAULT_MMAP_SIZE 0
11998 # define SQLITE_DEFAULT_MMAP_SIZE_xc 1 /* Exclude from ctime.c */
11999 #endif
12000 #if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE
12001 # undef SQLITE_DEFAULT_MMAP_SIZE
12002 # define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE
12003 #endif
@@ -13330,13 +12478,13 @@
12478
12479 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
12480 int flags, int seekResult);
12481 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
12482 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
12483 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
12484 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
12485 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);
12486 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
12487 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
12488 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12489 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
12490
@@ -13483,11 +12631,11 @@
12631 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
12632 Table *pTab; /* Used when p4type is P4_TABLE */
12633 #ifdef SQLITE_ENABLE_CURSOR_HINTS
12634 Expr *pExpr; /* Used when p4type is P4_EXPR */
12635 #endif
12636 int (*xAdvance)(BtCursor *, int *);
12637 } p4;
12638 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
12639 char *zComment; /* Comment to improve readability */
12640 #endif
12641 #ifdef VDBE_PROFILE
@@ -13717,11 +12865,11 @@
12865 #define OP_Rowid 125 /* synopsis: r[P2]=rowid */
12866 #define OP_NullRow 126
12867 #define OP_SorterInsert 127 /* synopsis: key=r[P2] */
12868 #define OP_IdxInsert 128 /* synopsis: key=r[P2] */
12869 #define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */
12870 #define OP_Seek 130 /* synopsis: Move P3 to P1.rowid */
12871 #define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */
12872 #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12873 #define OP_Destroy 133
12874 #define OP_Clear 134
12875 #define OP_ResetSorter 135
@@ -13798,16 +12946,10 @@
12946 #define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */
12947
12948 /************** End of opcodes.h *********************************************/
12949 /************** Continuing where we left off in vdbe.h ***********************/
12950
 
 
 
 
 
 
12951 /*
12952 ** Prototypes for the VDBE interface. See comments on the implementation
12953 ** for a description of what each of these routines does.
12954 */
12955 SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);
@@ -13861,12 +13003,11 @@
13003 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
13004 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
13005 SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));
13006 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
13007 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
13008 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
 
13009 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
13010 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
13011 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
13012 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
13013 #ifndef SQLITE_OMIT_TRACE
@@ -14228,25 +13369,25 @@
13369 */
13370 struct PgHdr {
13371 sqlite3_pcache_page *pPage; /* Pcache object page handle */
13372 void *pData; /* Page data */
13373 void *pExtra; /* Extra content */
 
13374 PgHdr *pDirty; /* Transient list of dirty sorted by pgno */
13375 Pager *pPager; /* The pager this page is part of */
13376 Pgno pgno; /* Page number for this page */
13377 #ifdef SQLITE_CHECK_PAGES
13378 u32 pageHash; /* Hash of page content */
13379 #endif
13380 u16 flags; /* PGHDR flags defined below */
13381
13382 /**********************************************************************
13383 ** Elements above are public. All that follows is private to pcache.c
13384 ** and should not be accessed by other modules.
 
13385 */
13386 i16 nRef; /* Number of users of this page */
13387 PCache *pCache; /* Cache that owns this page */
13388
13389 PgHdr *pDirtyNext; /* Next element in list of dirty pages */
13390 PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */
13391 };
13392
13393 /* Bit values for PgHdr.flags */
@@ -15084,12 +14225,12 @@
14225 ** Value constraints (enforced via assert()):
14226 ** SQLITE_FullFSync == PAGER_FULLFSYNC
14227 ** SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
14228 ** SQLITE_CacheSpill == PAGER_CACHE_SPILL
14229 */
14230 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
14231 #define SQLITE_InternChanges 0x00000002 /* Uncommitted Hash table changes */
14232 #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */
14233 #define SQLITE_FullFSync 0x00000008 /* Use full fsync on the backend */
14234 #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */
14235 #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */
14236 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
@@ -15096,38 +14237,33 @@
14237 #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
14238 /* DELETE, or UPDATE and return */
14239 /* the count using a callback. */
14240 #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
14241 /* result set is empty */
14242 #define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
14243 #define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
14244 #define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
14245 #define SQLITE_VdbeAddopTrace 0x00001000 /* Trace sqlite3VdbeAddOp() calls */
14246 #define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
14247 #define SQLITE_ReadUncommitted 0x0004000 /* For shared-cache mode */
14248 #define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
14249 #define SQLITE_RecoveryMode 0x00010000 /* Ignore schema errors */
14250 #define SQLITE_ReverseOrder 0x00020000 /* Reverse unordered SELECTs */
14251 #define SQLITE_RecTriggers 0x00040000 /* Enable recursive triggers */
14252 #define SQLITE_ForeignKeys 0x00080000 /* Enforce foreign key constraints */
14253 #define SQLITE_AutoIndex 0x00100000 /* Enable automatic indexes */
14254 #define SQLITE_PreferBuiltin 0x00200000 /* Preference to built-in funcs */
14255 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
14256 #define SQLITE_LoadExtFunc 0x00800000 /* Enable load_extension() SQL func */
14257 #define SQLITE_EnableTrigger 0x01000000 /* True to enable triggers */
14258 #define SQLITE_DeferFKs 0x02000000 /* Defer all FK constraints */
14259 #define SQLITE_QueryOnly 0x04000000 /* Disable database changes */
14260 #define SQLITE_VdbeEQP 0x08000000 /* Debug EXPLAIN QUERY PLAN */
14261 #define SQLITE_Vacuum 0x10000000 /* Currently in a VACUUM */
14262 #define SQLITE_CellSizeCk 0x20000000 /* Check btree cell sizes on load */
14263 #define SQLITE_Fts3Tokenizer 0x40000000 /* Enable fts3_tokenizer(2) */
14264 #define SQLITE_NoCkptOnClose 0x80000000 /* No checkpoint on close()/DETACH */
 
 
 
 
 
14265
14266
14267 /*
14268 ** Bits of the sqlite3.dbOptFlags field that are used by the
14269 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -16006,11 +15142,11 @@
15142 ** The following are the meanings of bits in the Expr.flags field.
15143 */
15144 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
15145 #define EP_Agg 0x000002 /* Contains one or more aggregate functions */
15146 #define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
15147 #define EP_Error 0x000008 /* Expression contains one or more errors */
15148 #define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
15149 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
15150 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
15151 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
15152 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
@@ -16473,14 +15609,14 @@
15609 ** An instance of this object describes where to put of the results of
15610 ** a SELECT statement.
15611 */
15612 struct SelectDest {
15613 u8 eDest; /* How to dispose of the results. On of SRT_* above. */
15614 char *zAffSdst; /* Affinity used when eDest==SRT_Set */
15615 int iSDParm; /* A parameter used by the eDest disposal method */
15616 int iSdst; /* Base register where results are written */
15617 int nSdst; /* Number of registers allocated */
 
15618 ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
15619 };
15620
15621 /*
15622 ** During code generation of statements that do inserts into AUTOINCREMENT
@@ -16979,14 +16115,10 @@
16115 SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);
16116 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
16117 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
16118 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
16119 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
 
 
 
 
16120
16121 /*
16122 ** Return code from the parse-tree walking primitives and their
16123 ** callbacks.
16124 */
@@ -17044,18 +16176,15 @@
16176 #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
16177 #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
16178 #ifdef SQLITE_DEBUG
16179 SQLITE_PRIVATE int sqlite3NomemError(int);
16180 SQLITE_PRIVATE int sqlite3IoerrnomemError(int);
 
16181 # define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
16182 # define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
 
16183 #else
16184 # define SQLITE_NOMEM_BKPT SQLITE_NOMEM
16185 # define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
 
16186 #endif
16187
16188 /*
16189 ** FTS3 and FTS4 both require virtual table support
16190 */
@@ -17420,14 +16549,14 @@
16549 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
16550 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16551 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
16552 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
16553 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
16554 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
16555 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
16556 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
16557 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
16558 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
16559 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
16560 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
16561 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
16562 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -18012,12 +17141,10 @@
17141 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
17142 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
17143 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
17144 SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
17145
 
 
17146 #endif /* SQLITEINT_H */
17147
17148 /************** End of sqliteInt.h *******************************************/
17149 /************** Begin file global.c ******************************************/
17150 /*
@@ -18318,10 +17445,476 @@
17445 ** Name of the default collating sequence
17446 */
17447 SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
17448
17449 /************** End of global.c **********************************************/
17450 /************** Begin file ctime.c *******************************************/
17451 /*
17452 ** 2010 February 23
17453 **
17454 ** The author disclaims copyright to this source code. In place of
17455 ** a legal notice, here is a blessing:
17456 **
17457 ** May you do good and not evil.
17458 ** May you find forgiveness for yourself and forgive others.
17459 ** May you share freely, never taking more than you give.
17460 **
17461 *************************************************************************
17462 **
17463 ** This file implements routines used to report what compile-time options
17464 ** SQLite was built with.
17465 */
17466
17467 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
17468
17469 /* #include "sqliteInt.h" */
17470
17471 /*
17472 ** An array of names of all compile-time options. This array should
17473 ** be sorted A-Z.
17474 **
17475 ** This array looks large, but in a typical installation actually uses
17476 ** only a handful of compile-time options, so most times this array is usually
17477 ** rather short and uses little memory space.
17478 */
17479 static const char * const azCompileOpt[] = {
17480
17481 /* These macros are provided to "stringify" the value of the define
17482 ** for those options in which the value is meaningful. */
17483 #define CTIMEOPT_VAL_(opt) #opt
17484 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
17485
17486 #if SQLITE_32BIT_ROWID
17487 "32BIT_ROWID",
17488 #endif
17489 #if SQLITE_4_BYTE_ALIGNED_MALLOC
17490 "4_BYTE_ALIGNED_MALLOC",
17491 #endif
17492 #if SQLITE_CASE_SENSITIVE_LIKE
17493 "CASE_SENSITIVE_LIKE",
17494 #endif
17495 #if SQLITE_CHECK_PAGES
17496 "CHECK_PAGES",
17497 #endif
17498 #if defined(__clang__) && defined(__clang_major__)
17499 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
17500 CTIMEOPT_VAL(__clang_minor__) "."
17501 CTIMEOPT_VAL(__clang_patchlevel__),
17502 #elif defined(_MSC_VER)
17503 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
17504 #elif defined(__GNUC__) && defined(__VERSION__)
17505 "COMPILER=gcc-" __VERSION__,
17506 #endif
17507 #if SQLITE_COVERAGE_TEST
17508 "COVERAGE_TEST",
17509 #endif
17510 #ifdef SQLITE_DEBUG
17511 "DEBUG",
17512 #endif
17513 #if SQLITE_DEFAULT_LOCKING_MODE
17514 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17515 #endif
17516 #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
17517 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
17518 #endif
17519 #if SQLITE_DEFAULT_SYNCHRONOUS
17520 "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
17521 #endif
17522 #if SQLITE_DEFAULT_WAL_SYNCHRONOUS
17523 "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
17524 #endif
17525 #if SQLITE_DIRECT_OVERFLOW_READ
17526 "DIRECT_OVERFLOW_READ",
17527 #endif
17528 #if SQLITE_DISABLE_DIRSYNC
17529 "DISABLE_DIRSYNC",
17530 #endif
17531 #if SQLITE_DISABLE_LFS
17532 "DISABLE_LFS",
17533 #endif
17534 #if SQLITE_ENABLE_8_3_NAMES
17535 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
17536 #endif
17537 #if SQLITE_ENABLE_API_ARMOR
17538 "ENABLE_API_ARMOR",
17539 #endif
17540 #if SQLITE_ENABLE_ATOMIC_WRITE
17541 "ENABLE_ATOMIC_WRITE",
17542 #endif
17543 #if SQLITE_ENABLE_CEROD
17544 "ENABLE_CEROD",
17545 #endif
17546 #if SQLITE_ENABLE_COLUMN_METADATA
17547 "ENABLE_COLUMN_METADATA",
17548 #endif
17549 #if SQLITE_ENABLE_DBSTAT_VTAB
17550 "ENABLE_DBSTAT_VTAB",
17551 #endif
17552 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
17553 "ENABLE_EXPENSIVE_ASSERT",
17554 #endif
17555 #if SQLITE_ENABLE_FTS1
17556 "ENABLE_FTS1",
17557 #endif
17558 #if SQLITE_ENABLE_FTS2
17559 "ENABLE_FTS2",
17560 #endif
17561 #if SQLITE_ENABLE_FTS3
17562 "ENABLE_FTS3",
17563 #endif
17564 #if SQLITE_ENABLE_FTS3_PARENTHESIS
17565 "ENABLE_FTS3_PARENTHESIS",
17566 #endif
17567 #if SQLITE_ENABLE_FTS4
17568 "ENABLE_FTS4",
17569 #endif
17570 #if SQLITE_ENABLE_FTS5
17571 "ENABLE_FTS5",
17572 #endif
17573 #if SQLITE_ENABLE_ICU
17574 "ENABLE_ICU",
17575 #endif
17576 #if SQLITE_ENABLE_IOTRACE
17577 "ENABLE_IOTRACE",
17578 #endif
17579 #if SQLITE_ENABLE_JSON1
17580 "ENABLE_JSON1",
17581 #endif
17582 #if SQLITE_ENABLE_LOAD_EXTENSION
17583 "ENABLE_LOAD_EXTENSION",
17584 #endif
17585 #if SQLITE_ENABLE_LOCKING_STYLE
17586 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
17587 #endif
17588 #if SQLITE_ENABLE_MEMORY_MANAGEMENT
17589 "ENABLE_MEMORY_MANAGEMENT",
17590 #endif
17591 #if SQLITE_ENABLE_MEMSYS3
17592 "ENABLE_MEMSYS3",
17593 #endif
17594 #if SQLITE_ENABLE_MEMSYS5
17595 "ENABLE_MEMSYS5",
17596 #endif
17597 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
17598 "ENABLE_OVERSIZE_CELL_CHECK",
17599 #endif
17600 #if SQLITE_ENABLE_RTREE
17601 "ENABLE_RTREE",
17602 #endif
17603 #if defined(SQLITE_ENABLE_STAT4)
17604 "ENABLE_STAT4",
17605 #elif defined(SQLITE_ENABLE_STAT3)
17606 "ENABLE_STAT3",
17607 #endif
17608 #if SQLITE_ENABLE_UNLOCK_NOTIFY
17609 "ENABLE_UNLOCK_NOTIFY",
17610 #endif
17611 #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
17612 "ENABLE_UPDATE_DELETE_LIMIT",
17613 #endif
17614 #if defined(SQLITE_ENABLE_URI_00_ERROR)
17615 "ENABLE_URI_00_ERROR",
17616 #endif
17617 #if SQLITE_HAS_CODEC
17618 "HAS_CODEC",
17619 #endif
17620 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
17621 "HAVE_ISNAN",
17622 #endif
17623 #if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
17624 "HOMEGROWN_RECURSIVE_MUTEX",
17625 #endif
17626 #if SQLITE_IGNORE_AFP_LOCK_ERRORS
17627 "IGNORE_AFP_LOCK_ERRORS",
17628 #endif
17629 #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
17630 "IGNORE_FLOCK_LOCK_ERRORS",
17631 #endif
17632 #ifdef SQLITE_INT64_TYPE
17633 "INT64_TYPE",
17634 #endif
17635 #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
17636 "LIKE_DOESNT_MATCH_BLOBS",
17637 #endif
17638 #if SQLITE_LOCK_TRACE
17639 "LOCK_TRACE",
17640 #endif
17641 #if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)
17642 "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
17643 #endif
17644 #ifdef SQLITE_MAX_SCHEMA_RETRY
17645 "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
17646 #endif
17647 #if SQLITE_MEMDEBUG
17648 "MEMDEBUG",
17649 #endif
17650 #if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
17651 "MIXED_ENDIAN_64BIT_FLOAT",
17652 #endif
17653 #if SQLITE_NO_SYNC
17654 "NO_SYNC",
17655 #endif
17656 #if SQLITE_OMIT_ALTERTABLE
17657 "OMIT_ALTERTABLE",
17658 #endif
17659 #if SQLITE_OMIT_ANALYZE
17660 "OMIT_ANALYZE",
17661 #endif
17662 #if SQLITE_OMIT_ATTACH
17663 "OMIT_ATTACH",
17664 #endif
17665 #if SQLITE_OMIT_AUTHORIZATION
17666 "OMIT_AUTHORIZATION",
17667 #endif
17668 #if SQLITE_OMIT_AUTOINCREMENT
17669 "OMIT_AUTOINCREMENT",
17670 #endif
17671 #if SQLITE_OMIT_AUTOINIT
17672 "OMIT_AUTOINIT",
17673 #endif
17674 #if SQLITE_OMIT_AUTOMATIC_INDEX
17675 "OMIT_AUTOMATIC_INDEX",
17676 #endif
17677 #if SQLITE_OMIT_AUTORESET
17678 "OMIT_AUTORESET",
17679 #endif
17680 #if SQLITE_OMIT_AUTOVACUUM
17681 "OMIT_AUTOVACUUM",
17682 #endif
17683 #if SQLITE_OMIT_BETWEEN_OPTIMIZATION
17684 "OMIT_BETWEEN_OPTIMIZATION",
17685 #endif
17686 #if SQLITE_OMIT_BLOB_LITERAL
17687 "OMIT_BLOB_LITERAL",
17688 #endif
17689 #if SQLITE_OMIT_BTREECOUNT
17690 "OMIT_BTREECOUNT",
17691 #endif
17692 #if SQLITE_OMIT_CAST
17693 "OMIT_CAST",
17694 #endif
17695 #if SQLITE_OMIT_CHECK
17696 "OMIT_CHECK",
17697 #endif
17698 #if SQLITE_OMIT_COMPLETE
17699 "OMIT_COMPLETE",
17700 #endif
17701 #if SQLITE_OMIT_COMPOUND_SELECT
17702 "OMIT_COMPOUND_SELECT",
17703 #endif
17704 #if SQLITE_OMIT_CTE
17705 "OMIT_CTE",
17706 #endif
17707 #if SQLITE_OMIT_DATETIME_FUNCS
17708 "OMIT_DATETIME_FUNCS",
17709 #endif
17710 #if SQLITE_OMIT_DECLTYPE
17711 "OMIT_DECLTYPE",
17712 #endif
17713 #if SQLITE_OMIT_DEPRECATED
17714 "OMIT_DEPRECATED",
17715 #endif
17716 #if SQLITE_OMIT_DISKIO
17717 "OMIT_DISKIO",
17718 #endif
17719 #if SQLITE_OMIT_EXPLAIN
17720 "OMIT_EXPLAIN",
17721 #endif
17722 #if SQLITE_OMIT_FLAG_PRAGMAS
17723 "OMIT_FLAG_PRAGMAS",
17724 #endif
17725 #if SQLITE_OMIT_FLOATING_POINT
17726 "OMIT_FLOATING_POINT",
17727 #endif
17728 #if SQLITE_OMIT_FOREIGN_KEY
17729 "OMIT_FOREIGN_KEY",
17730 #endif
17731 #if SQLITE_OMIT_GET_TABLE
17732 "OMIT_GET_TABLE",
17733 #endif
17734 #if SQLITE_OMIT_INCRBLOB
17735 "OMIT_INCRBLOB",
17736 #endif
17737 #if SQLITE_OMIT_INTEGRITY_CHECK
17738 "OMIT_INTEGRITY_CHECK",
17739 #endif
17740 #if SQLITE_OMIT_LIKE_OPTIMIZATION
17741 "OMIT_LIKE_OPTIMIZATION",
17742 #endif
17743 #if SQLITE_OMIT_LOAD_EXTENSION
17744 "OMIT_LOAD_EXTENSION",
17745 #endif
17746 #if SQLITE_OMIT_LOCALTIME
17747 "OMIT_LOCALTIME",
17748 #endif
17749 #if SQLITE_OMIT_LOOKASIDE
17750 "OMIT_LOOKASIDE",
17751 #endif
17752 #if SQLITE_OMIT_MEMORYDB
17753 "OMIT_MEMORYDB",
17754 #endif
17755 #if SQLITE_OMIT_OR_OPTIMIZATION
17756 "OMIT_OR_OPTIMIZATION",
17757 #endif
17758 #if SQLITE_OMIT_PAGER_PRAGMAS
17759 "OMIT_PAGER_PRAGMAS",
17760 #endif
17761 #if SQLITE_OMIT_PRAGMA
17762 "OMIT_PRAGMA",
17763 #endif
17764 #if SQLITE_OMIT_PROGRESS_CALLBACK
17765 "OMIT_PROGRESS_CALLBACK",
17766 #endif
17767 #if SQLITE_OMIT_QUICKBALANCE
17768 "OMIT_QUICKBALANCE",
17769 #endif
17770 #if SQLITE_OMIT_REINDEX
17771 "OMIT_REINDEX",
17772 #endif
17773 #if SQLITE_OMIT_SCHEMA_PRAGMAS
17774 "OMIT_SCHEMA_PRAGMAS",
17775 #endif
17776 #if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
17777 "OMIT_SCHEMA_VERSION_PRAGMAS",
17778 #endif
17779 #if SQLITE_OMIT_SHARED_CACHE
17780 "OMIT_SHARED_CACHE",
17781 #endif
17782 #if SQLITE_OMIT_SUBQUERY
17783 "OMIT_SUBQUERY",
17784 #endif
17785 #if SQLITE_OMIT_TCL_VARIABLE
17786 "OMIT_TCL_VARIABLE",
17787 #endif
17788 #if SQLITE_OMIT_TEMPDB
17789 "OMIT_TEMPDB",
17790 #endif
17791 #if SQLITE_OMIT_TRACE
17792 "OMIT_TRACE",
17793 #endif
17794 #if SQLITE_OMIT_TRIGGER
17795 "OMIT_TRIGGER",
17796 #endif
17797 #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
17798 "OMIT_TRUNCATE_OPTIMIZATION",
17799 #endif
17800 #if SQLITE_OMIT_UTF16
17801 "OMIT_UTF16",
17802 #endif
17803 #if SQLITE_OMIT_VACUUM
17804 "OMIT_VACUUM",
17805 #endif
17806 #if SQLITE_OMIT_VIEW
17807 "OMIT_VIEW",
17808 #endif
17809 #if SQLITE_OMIT_VIRTUALTABLE
17810 "OMIT_VIRTUALTABLE",
17811 #endif
17812 #if SQLITE_OMIT_WAL
17813 "OMIT_WAL",
17814 #endif
17815 #if SQLITE_OMIT_WSD
17816 "OMIT_WSD",
17817 #endif
17818 #if SQLITE_OMIT_XFER_OPT
17819 "OMIT_XFER_OPT",
17820 #endif
17821 #if SQLITE_PERFORMANCE_TRACE
17822 "PERFORMANCE_TRACE",
17823 #endif
17824 #if SQLITE_PROXY_DEBUG
17825 "PROXY_DEBUG",
17826 #endif
17827 #if SQLITE_RTREE_INT_ONLY
17828 "RTREE_INT_ONLY",
17829 #endif
17830 #if SQLITE_SECURE_DELETE
17831 "SECURE_DELETE",
17832 #endif
17833 #if SQLITE_SMALL_STACK
17834 "SMALL_STACK",
17835 #endif
17836 #if SQLITE_SOUNDEX
17837 "SOUNDEX",
17838 #endif
17839 #if SQLITE_SYSTEM_MALLOC
17840 "SYSTEM_MALLOC",
17841 #endif
17842 #if SQLITE_TCL
17843 "TCL",
17844 #endif
17845 #if defined(SQLITE_TEMP_STORE) && !defined(SQLITE_TEMP_STORE_xc)
17846 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
17847 #endif
17848 #if SQLITE_TEST
17849 "TEST",
17850 #endif
17851 #if defined(SQLITE_THREADSAFE)
17852 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
17853 #endif
17854 #if SQLITE_UNTESTABLE
17855 "UNTESTABLE"
17856 #endif
17857 #if SQLITE_USE_ALLOCA
17858 "USE_ALLOCA",
17859 #endif
17860 #if SQLITE_USER_AUTHENTICATION
17861 "USER_AUTHENTICATION",
17862 #endif
17863 #if SQLITE_WIN32_MALLOC
17864 "WIN32_MALLOC",
17865 #endif
17866 #if SQLITE_ZERO_MALLOC
17867 "ZERO_MALLOC"
17868 #endif
17869 };
17870
17871 /*
17872 ** Given the name of a compile-time option, return true if that option
17873 ** was used and false if not.
17874 **
17875 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
17876 ** is not required for a match.
17877 */
17878 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
17879 int i, n;
17880
17881 #if SQLITE_ENABLE_API_ARMOR
17882 if( zOptName==0 ){
17883 (void)SQLITE_MISUSE_BKPT;
17884 return 0;
17885 }
17886 #endif
17887 if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
17888 n = sqlite3Strlen30(zOptName);
17889
17890 /* Since ArraySize(azCompileOpt) is normally in single digits, a
17891 ** linear search is adequate. No need for a binary search. */
17892 for(i=0; i<ArraySize(azCompileOpt); i++){
17893 if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0
17894 && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0
17895 ){
17896 return 1;
17897 }
17898 }
17899 return 0;
17900 }
17901
17902 /*
17903 ** Return the N-th compile-time option string. If N is out of range,
17904 ** return a NULL pointer.
17905 */
17906 SQLITE_API const char *sqlite3_compileoption_get(int N){
17907 if( N>=0 && N<ArraySize(azCompileOpt) ){
17908 return azCompileOpt[N];
17909 }
17910 return 0;
17911 }
17912
17913 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
17914
17915 /************** End of ctime.c ***********************************************/
17916 /************** Begin file status.c ******************************************/
17917 /*
17918 ** 2008 June 18
17919 **
17920 ** The author disclaims copyright to this source code. In place of
@@ -18721,22 +18314,22 @@
18314 int rcApp; /* errcode set by sqlite3_result_error_code() */
18315 #endif
18316 u16 nResColumn; /* Number of columns in one row of the result set */
18317 u8 errorAction; /* Recovery action to do in case of an error */
18318 u8 minWriteFileFormat; /* Minimum file format for writable database files */
 
18319 bft expired:1; /* True if the VM needs to be recompiled */
18320 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
18321 bft explain:2; /* True if EXPLAIN present on SQL command */
18322 bft changeCntOn:1; /* True to update the change-counter */
18323 bft runOnlyOnce:1; /* Automatically expire on reset */
18324 bft usesStmtJournal:1; /* True if uses a statement journal */
18325 bft readOnly:1; /* True for statements that do not write */
18326 bft bIsReader:1; /* True for statements that read */
18327 bft isPrepareV2:1; /* True if prepared with prepare_v2() */
18328 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
18329 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
18330 u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
18331 char *zSql; /* Text of the SQL statement that generated this */
18332 void *pFree; /* Free this when deleting the vdbe */
18333 VdbeFrame *pFrame; /* Parent frame */
18334 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
18335 int nFrame; /* Number of frames in pFrame list */
@@ -18845,11 +18438,11 @@
18438
18439 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
18440 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
18441 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
18442 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
18443 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);
18444 SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);
18445 SQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);
18446 SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);
18447
18448 #if !defined(SQLITE_OMIT_SHARED_CACHE)
@@ -30045,11 +29638,11 @@
29638 /* 125 */ "Rowid" OpHelp("r[P2]=rowid"),
29639 /* 126 */ "NullRow" OpHelp(""),
29640 /* 127 */ "SorterInsert" OpHelp("key=r[P2]"),
29641 /* 128 */ "IdxInsert" OpHelp("key=r[P2]"),
29642 /* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29643 /* 130 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29644 /* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29645 /* 132 */ "Real" OpHelp("r[P2]=P4"),
29646 /* 133 */ "Destroy" OpHelp(""),
29647 /* 134 */ "Clear" OpHelp(""),
29648 /* 135 */ "ResetSorter" OpHelp(""),
@@ -50575,11 +50168,11 @@
50168 assert( isOpen(pPager->fd) );
50169 assert( pPager->tempFile==0 );
50170 nPage = sqlite3WalDbsize(pPager->pWal);
50171
50172 /* If the number of pages in the database is not available from the
50173 ** WAL sub-system, determine the page counte based on the size of
50174 ** the database file. If the size of the database file is not an
50175 ** integer multiple of the page-size, round up the result.
50176 */
50177 if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){
50178 i64 n = 0; /* Size of db file in bytes */
@@ -50626,25 +50219,27 @@
50219 assert( pPager->eState==PAGER_OPEN );
50220 assert( pPager->eLock>=SHARED_LOCK );
50221
50222 if( !pPager->tempFile ){
50223 int isWal; /* True if WAL file exists */
50224 Pgno nPage; /* Size of the database file */
50225
50226 rc = pagerPagecount(pPager, &nPage);
50227 if( rc ) return rc;
50228 if( nPage==0 ){
50229 rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
50230 if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;
50231 isWal = 0;
50232 }else{
50233 rc = sqlite3OsAccess(
50234 pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
50235 );
50236 }
50237 if( rc==SQLITE_OK ){
50238 if( isWal ){
50239 testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
50240 rc = sqlite3PagerOpenWal(pPager, 0);
 
 
 
 
 
 
 
 
50241 }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
50242 pPager->journalMode = PAGER_JOURNALMODE_DELETE;
50243 }
50244 }
50245 }
@@ -52583,18 +52178,23 @@
52178 **
52179 ** There is a vanishingly small chance that a change will not be
52180 ** detected. The chance of an undetected change is so small that
52181 ** it can be neglected.
52182 */
52183 Pgno nPage = 0;
52184 char dbFileVers[sizeof(pPager->dbFileVers)];
52185
52186 rc = pagerPagecount(pPager, &nPage);
52187 if( rc ) goto failed;
52188
52189 if( nPage>0 ){
52190 IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
52191 rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
52192 if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
52193 goto failed;
52194 }
52195 }else{
52196 memset(dbFileVers, 0, sizeof(dbFileVers));
52197 }
52198
52199 if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){
52200 pager_reset(pPager);
@@ -59584,11 +59184,11 @@
59184 /* If this database is not shareable, or if the client is reading
59185 ** and has the read-uncommitted flag set, then no lock is required.
59186 ** Return true immediately.
59187 */
59188 if( (pBtree->sharable==0)
59189 || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))
59190 ){
59191 return 1;
59192 }
59193
59194 /* If the client is reading or writing an index and the schema is
@@ -59661,11 +59261,11 @@
59261 static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
59262 BtCursor *p;
59263 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
59264 if( p->pgnoRoot==iRoot
59265 && p->pBtree!=pBtree
59266 && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted)
59267 ){
59268 return 1;
59269 }
59270 }
59271 return 0;
@@ -59683,11 +59283,11 @@
59283 BtLock *pIter;
59284
59285 assert( sqlite3BtreeHoldsMutex(p) );
59286 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
59287 assert( p->db!=0 );
59288 assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 );
59289
59290 /* If requesting a write-lock, then the Btree must have an open write
59291 ** transaction on this file. And, obviously, for this to be so there
59292 ** must be an open write transaction on the file itself.
59293 */
@@ -59761,11 +59361,11 @@
59361
59362 /* A connection with the read-uncommitted flag set will never try to
59363 ** obtain a read-lock using this function. The only read-lock obtained
59364 ** by a connection in read-uncommitted mode is on the sqlite_master
59365 ** table, and that lock is obtained in BtreeBeginTrans(). */
59366 assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );
59367
59368 /* This function should only be called on a sharable b-tree after it
59369 ** has been determined that no other b-tree holds a conflicting lock. */
59370 assert( p->sharable );
59371 assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
@@ -60203,11 +59803,11 @@
59803 assert( nKey==(i64)(int)nKey );
59804 pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);
59805 if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
59806 sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
59807 if( pIdxKey->nField==0 ){
59808 rc = SQLITE_CORRUPT_BKPT;
59809 goto moveto_done;
59810 }
59811 }else{
59812 pIdxKey = 0;
59813 }
@@ -60432,11 +60032,11 @@
60032 assert( pEType!=0 );
60033 *pEType = pPtrmap[offset];
60034 if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
60035
60036 sqlite3PagerUnref(pDbPage);
60037 if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT;
60038 return SQLITE_OK;
60039 }
60040
60041 #else /* if defined SQLITE_OMIT_AUTOVACUUM */
60042 #define ptrmapPut(w,x,y,z,rc)
@@ -60817,11 +60417,11 @@
60417 u8 *pAddr;
60418 int sz2 = 0;
60419 int sz = get2byte(&data[iFree+2]);
60420 int top = get2byte(&data[hdr+5]);
60421 if( iFree2 ){
60422 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_BKPT;
60423 sz2 = get2byte(&data[iFree2+2]);
60424 assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
60425 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
60426 sz += sz2;
60427 }
@@ -60848,17 +60448,17 @@
60448 testcase( pc==iCellLast );
60449 /* These conditions have already been verified in btreeInitPage()
60450 ** if PRAGMA cell_size_check=ON.
60451 */
60452 if( pc<iCellFirst || pc>iCellLast ){
60453 return SQLITE_CORRUPT_BKPT;
60454 }
60455 assert( pc>=iCellFirst && pc<=iCellLast );
60456 size = pPage->xCellSize(pPage, &src[pc]);
60457 cbrk -= size;
60458 if( cbrk<iCellFirst || pc+size>usableSize ){
60459 return SQLITE_CORRUPT_BKPT;
60460 }
60461 assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
60462 testcase( cbrk+size==usableSize );
60463 testcase( pc+size==usableSize );
60464 put2byte(pAddr, cbrk);
@@ -60874,11 +60474,11 @@
60474 }
60475 data[hdr+7] = 0;
60476
60477 defragment_out:
60478 if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){
60479 return SQLITE_CORRUPT_BKPT;
60480 }
60481 assert( cbrk>=iCellFirst );
60482 put2byte(&data[hdr+5], cbrk);
60483 data[hdr+1] = 0;
60484 data[hdr+2] = 0;
@@ -60913,11 +60513,11 @@
60513 do{
60514 int size; /* Size of the free slot */
60515 /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
60516 ** increasing offset. */
60517 if( pc>usableSize-4 || pc<iAddr+4 ){
60518 *pRc = SQLITE_CORRUPT_BKPT;
60519 return 0;
60520 }
60521 /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
60522 ** freeblock form a big-endian integer which is the size of the freeblock
60523 ** in bytes, including the 4-byte header. */
@@ -60924,11 +60524,11 @@
60524 size = get2byte(&aData[pc+2]);
60525 if( (x = size - nByte)>=0 ){
60526 testcase( x==4 );
60527 testcase( x==3 );
60528 if( pc < pPg->cellOffset+2*pPg->nCell || size+pc > usableSize ){
60529 *pRc = SQLITE_CORRUPT_BKPT;
60530 return 0;
60531 }else if( x<4 ){
60532 /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
60533 ** number of bytes in fragments may not exceed 60. */
60534 if( aData[hdr+7]>57 ) return 0;
@@ -60991,11 +60591,11 @@
60591 assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */
60592 if( gap>top ){
60593 if( top==0 && pPage->pBt->usableSize==65536 ){
60594 top = 65536;
60595 }else{
60596 return SQLITE_CORRUPT_BKPT;
60597 }
60598 }
60599
60600 /* If there is enough space between gap and top for one more cell pointer
60601 ** array entry offset, and if the freelist is not empty, then search the
@@ -61087,15 +60687,15 @@
60687 iFreeBlk = 0; /* Shortcut for the case when the freelist is empty */
60688 }else{
60689 while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){
60690 if( iFreeBlk<iPtr+4 ){
60691 if( iFreeBlk==0 ) break;
60692 return SQLITE_CORRUPT_BKPT;
60693 }
60694 iPtr = iFreeBlk;
60695 }
60696 if( iFreeBlk>iLast ) return SQLITE_CORRUPT_BKPT;
60697 assert( iFreeBlk>iPtr || iFreeBlk==0 );
60698
60699 /* At this point:
60700 ** iFreeBlk: First freeblock after iStart, or zero if none
60701 ** iPtr: The address of a pointer to iFreeBlk
@@ -61102,15 +60702,13 @@
60702 **
60703 ** Check to see if iFreeBlk should be coalesced onto the end of iStart.
60704 */
60705 if( iFreeBlk && iEnd+3>=iFreeBlk ){
60706 nFrag = iFreeBlk - iEnd;
60707 if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_BKPT;
60708 iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
60709 if( iEnd > pPage->pBt->usableSize ) return SQLITE_CORRUPT_BKPT;
 
 
60710 iSize = iEnd - iStart;
60711 iFreeBlk = get2byte(&data[iFreeBlk]);
60712 }
60713
60714 /* If iPtr is another freeblock (that is, if iPtr is not the freelist
@@ -61118,24 +60716,24 @@
60716 ** coalesced onto the end of iPtr.
60717 */
60718 if( iPtr>hdr+1 ){
60719 int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);
60720 if( iPtrEnd+3>=iStart ){
60721 if( iPtrEnd>iStart ) return SQLITE_CORRUPT_BKPT;
60722 nFrag += iStart - iPtrEnd;
60723 iSize = iEnd - iPtr;
60724 iStart = iPtr;
60725 }
60726 }
60727 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_BKPT;
60728 data[hdr+7] -= nFrag;
60729 }
60730 if( iStart==get2byte(&data[hdr+5]) ){
60731 /* The new freeblock is at the beginning of the cell content area,
60732 ** so just extend the cell content area rather than create another
60733 ** freelist entry */
60734 if( iPtr!=hdr+1 ) return SQLITE_CORRUPT_BKPT;
60735 put2byte(&data[hdr+1], iFreeBlk);
60736 put2byte(&data[hdr+5], iEnd);
60737 }else{
60738 /* Insert the new freeblock into the freelist */
60739 put2byte(&data[iPtr], iStart);
@@ -61199,11 +60797,11 @@
60797 pPage->maxLocal = pBt->maxLocal;
60798 pPage->minLocal = pBt->minLocal;
60799 }else{
60800 /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
60801 ** an error. */
60802 return SQLITE_CORRUPT_BKPT;
60803 }
60804 pPage->max1bytePayload = pBt->max1bytePayload;
60805 return SQLITE_OK;
60806 }
60807
@@ -61215,140 +60813,138 @@
60813 ** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not
60814 ** guarantee that the page is well-formed. It only shows that
60815 ** we failed to detect any corruption.
60816 */
60817 static int btreeInitPage(MemPage *pPage){
 
 
 
 
 
 
 
 
 
 
60818
60819 assert( pPage->pBt!=0 );
60820 assert( pPage->pBt->db!=0 );
60821 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
60822 assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );
60823 assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );
60824 assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );
60825
60826 if( !pPage->isInit ){
60827 int pc; /* Address of a freeblock within pPage->aData[] */
60828 u8 hdr; /* Offset to beginning of page header */
60829 u8 *data; /* Equal to pPage->aData */
60830 BtShared *pBt; /* The main btree structure */
60831 int usableSize; /* Amount of usable space on each page */
60832 u16 cellOffset; /* Offset from start of page to first cell pointer */
60833 int nFree; /* Number of unused bytes on the page */
60834 int top; /* First byte of the cell content area */
60835 int iCellFirst; /* First allowable cell or freeblock offset */
60836 int iCellLast; /* Last possible cell or freeblock offset */
60837
60838 pBt = pPage->pBt;
60839
60840 hdr = pPage->hdrOffset;
60841 data = pPage->aData;
60842 /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating
60843 ** the b-tree page type. */
60844 if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;
60845 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
60846 pPage->maskPage = (u16)(pBt->pageSize - 1);
60847 pPage->nOverflow = 0;
60848 usableSize = pBt->usableSize;
60849 pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;
60850 pPage->aDataEnd = &data[usableSize];
60851 pPage->aCellIdx = &data[cellOffset];
60852 pPage->aDataOfst = &data[pPage->childPtrSize];
60853 /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates
60854 ** the start of the cell content area. A zero value for this integer is
60855 ** interpreted as 65536. */
60856 top = get2byteNotZero(&data[hdr+5]);
60857 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
60858 ** number of cells on the page. */
60859 pPage->nCell = get2byte(&data[hdr+3]);
60860 if( pPage->nCell>MX_CELL(pBt) ){
60861 /* To many cells for a single page. The page must be corrupt */
60862 return SQLITE_CORRUPT_BKPT;
60863 }
60864 testcase( pPage->nCell==MX_CELL(pBt) );
60865 /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
60866 ** possible for a root page of a table that contains no rows) then the
60867 ** offset to the cell content area will equal the page size minus the
60868 ** bytes of reserved space. */
60869 assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );
60870
60871 /* A malformed database page might cause us to read past the end
60872 ** of page when parsing a cell.
60873 **
60874 ** The following block of code checks early to see if a cell extends
60875 ** past the end of a page boundary and causes SQLITE_CORRUPT to be
60876 ** returned if it does.
60877 */
60878 iCellFirst = cellOffset + 2*pPage->nCell;
60879 iCellLast = usableSize - 4;
60880 if( pBt->db->flags & SQLITE_CellSizeCk ){
60881 int i; /* Index into the cell pointer array */
60882 int sz; /* Size of a cell */
60883
60884 if( !pPage->leaf ) iCellLast--;
60885 for(i=0; i<pPage->nCell; i++){
60886 pc = get2byteAligned(&data[cellOffset+i*2]);
60887 testcase( pc==iCellFirst );
60888 testcase( pc==iCellLast );
60889 if( pc<iCellFirst || pc>iCellLast ){
60890 return SQLITE_CORRUPT_BKPT;
60891 }
60892 sz = pPage->xCellSize(pPage, &data[pc]);
60893 testcase( pc+sz==usableSize );
60894 if( pc+sz>usableSize ){
60895 return SQLITE_CORRUPT_BKPT;
60896 }
60897 }
60898 if( !pPage->leaf ) iCellLast++;
60899 }
60900
60901 /* Compute the total free space on the page
60902 ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the
60903 ** start of the first freeblock on the page, or is zero if there are no
60904 ** freeblocks. */
60905 pc = get2byte(&data[hdr+1]);
60906 nFree = data[hdr+7] + top; /* Init nFree to non-freeblock free space */
60907 if( pc>0 ){
60908 u32 next, size;
60909 if( pc<iCellFirst ){
60910 /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will
60911 ** always be at least one cell before the first freeblock.
60912 */
60913 return SQLITE_CORRUPT_BKPT;
60914 }
60915 while( 1 ){
60916 if( pc>iCellLast ){
60917 return SQLITE_CORRUPT_BKPT; /* Freeblock off the end of the page */
60918 }
60919 next = get2byte(&data[pc]);
60920 size = get2byte(&data[pc+2]);
60921 nFree = nFree + size;
60922 if( next<=pc+size+3 ) break;
60923 pc = next;
60924 }
60925 if( next>0 ){
60926 return SQLITE_CORRUPT_BKPT; /* Freeblock not in ascending order */
60927 }
60928 if( pc+size>(unsigned int)usableSize ){
60929 return SQLITE_CORRUPT_BKPT; /* Last freeblock extends past page end */
60930 }
60931 }
60932
60933 /* At this point, nFree contains the sum of the offset to the start
60934 ** of the cell-content area plus the number of free bytes within
60935 ** the cell-content area. If this is greater than the usable-size
60936 ** of the page, then the page must be corrupted. This check also
60937 ** serves to verify that the offset to the start of the cell-content
60938 ** area, according to the page header, lies within the page.
60939 */
60940 if( nFree>usableSize ){
60941 return SQLITE_CORRUPT_BKPT;
60942 }
60943 pPage->nFree = (u16)(nFree - iCellFirst);
60944 pPage->isInit = 1;
60945 }
60946 return SQLITE_OK;
60947 }
60948
60949 /*
60950 ** Set up a raw page so that it looks like a database page holding
@@ -61508,11 +61104,11 @@
61104 assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
61105
61106 /* If obtaining a child page for a cursor, we must verify that the page is
61107 ** compatible with the root page. */
61108 if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
61109 rc = SQLITE_CORRUPT_BKPT;
61110 releasePage(*ppPage);
61111 goto getAndInitPage_error;
61112 }
61113 return SQLITE_OK;
61114
@@ -62453,11 +62049,11 @@
62049 freeTempSpace(pBt);
62050 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
62051 pageSize-usableSize);
62052 return rc;
62053 }
62054 if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){
62055 rc = SQLITE_CORRUPT_BKPT;
62056 goto page1_init_failed;
62057 }
62058 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
62059 ** be less than 480. In other words, if the page size is 512, then the
@@ -62796,11 +62392,11 @@
62392 int rc; /* Return code */
62393 BtShared *pBt = pPage->pBt;
62394 Pgno pgno = pPage->pgno;
62395
62396 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
62397 rc = btreeInitPage(pPage);
62398 if( rc!=SQLITE_OK ) return rc;
62399 nCell = pPage->nCell;
62400
62401 for(i=0; i<nCell; i++){
62402 u8 *pCell = findCell(pPage, i);
@@ -62839,19 +62435,19 @@
62435 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
62436 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
62437 if( eType==PTRMAP_OVERFLOW2 ){
62438 /* The pointer is always the first 4 bytes of the page in this case. */
62439 if( get4byte(pPage->aData)!=iFrom ){
62440 return SQLITE_CORRUPT_BKPT;
62441 }
62442 put4byte(pPage->aData, iTo);
62443 }else{
62444 int i;
62445 int nCell;
62446 int rc;
62447
62448 rc = btreeInitPage(pPage);
62449 if( rc ) return rc;
62450 nCell = pPage->nCell;
62451
62452 for(i=0; i<nCell; i++){
62453 u8 *pCell = findCell(pPage, i);
@@ -62858,11 +62454,11 @@
62454 if( eType==PTRMAP_OVERFLOW1 ){
62455 CellInfo info;
62456 pPage->xParseCell(pPage, pCell, &info);
62457 if( info.nLocal<info.nPayload ){
62458 if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){
62459 return SQLITE_CORRUPT_BKPT;
62460 }
62461 if( iFrom==get4byte(pCell+info.nSize-4) ){
62462 put4byte(pCell+info.nSize-4, iTo);
62463 break;
62464 }
@@ -62876,11 +62472,11 @@
62472 }
62473
62474 if( i==nCell ){
62475 if( eType!=PTRMAP_BTREE ||
62476 get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){
62477 return SQLITE_CORRUPT_BKPT;
62478 }
62479 put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);
62480 }
62481 }
62482 return SQLITE_OK;
@@ -63984,11 +63580,11 @@
63580 /* Trying to read or write past the end of the data is an error. The
63581 ** conditional above is really:
63582 ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
63583 ** but is recast into its current form to avoid integer overflow problems
63584 */
63585 return SQLITE_CORRUPT_BKPT;
63586 }
63587
63588 /* Check if data must be read/written to/from the btree page itself. */
63589 if( offset<pCur->info.nLocal ){
63590 int a = amt;
@@ -64131,12 +63727,11 @@
63727 iIdx++;
63728 }
63729 }
63730
63731 if( rc==SQLITE_OK && amt>0 ){
63732 return SQLITE_CORRUPT_BKPT; /* Overflow chain ends prematurely */
 
63733 }
63734 return rc;
63735 }
63736
63737 /*
@@ -64398,11 +63993,11 @@
63993 ** if pCur->iPage>=0). But this is not so if the database is corrupted
63994 ** in such a way that page pRoot is linked into a second b-tree table
63995 ** (or the freelist). */
63996 assert( pRoot->intKey==1 || pRoot->intKey==0 );
63997 if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
63998 return SQLITE_CORRUPT_BKPT;
63999 }
64000
64001 skip_init:
64002 pCur->ix = 0;
64003 pCur->info.nSize = 0;
@@ -64603,23 +64198,20 @@
64198 return SQLITE_OK;
64199 }
64200 /* If the requested key is one more than the previous key, then
64201 ** try to get there using sqlite3BtreeNext() rather than a full
64202 ** binary search. This is an optimization only. The correct answer
64203 ** is still obtained without this ase, only a little more slowely */
64204 if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
64205 *pRes = 0;
64206 rc = sqlite3BtreeNext(pCur, pRes);
64207 if( rc ) return rc;
64208 if( *pRes==0 ){
64209 getCellInfo(pCur);
64210 if( pCur->info.nKey==intKey ){
64211 return SQLITE_OK;
64212 }
 
 
 
 
64213 }
64214 }
64215 }
64216 }
64217
@@ -64671,13 +64263,11 @@
64263 for(;;){
64264 i64 nCellKey;
64265 pCell = findCellPastPtr(pPage, idx);
64266 if( pPage->intKeyLeaf ){
64267 while( 0x80 <= *(pCell++) ){
64268 if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
 
 
64269 }
64270 }
64271 getVarint(pCell, (u64*)&nCellKey);
64272 if( nCellKey<intKey ){
64273 lwr = idx+1;
@@ -64746,11 +64336,11 @@
64336 testcase( nCell<0 ); /* True if key size is 2^32 or more */
64337 testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
64338 testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
64339 testcase( nCell==2 ); /* Minimum legal index key size */
64340 if( nCell<2 ){
64341 rc = SQLITE_CORRUPT_BKPT;
64342 goto moveto_finish;
64343 }
64344 pCellKey = sqlite3Malloc( nCell+18 );
64345 if( pCellKey==0 ){
64346 rc = SQLITE_NOMEM_BKPT;
@@ -64851,44 +64441,47 @@
64441 }
64442 return n;
64443 }
64444
64445 /*
64446 ** Advance the cursor to the next entry in the database. If
64447 ** successful then set *pRes=0. If the cursor
64448 ** was already pointing to the last entry in the database before
64449 ** this routine was called, then set *pRes=1.
 
 
64450 **
64451 ** The main entry point is sqlite3BtreeNext(). That routine is optimized
64452 ** for the common case of merely incrementing the cell counter BtCursor.aiIdx
64453 ** to the next cell on the current page. The (slower) btreeNext() helper
64454 ** routine is called when it is necessary to move to a different page or
64455 ** to restore the cursor.
64456 **
64457 ** The calling function will set *pRes to 0 or 1. The initial *pRes value
64458 ** will be 1 if the cursor being stepped corresponds to an SQL index and
64459 ** if this routine could have been skipped if that SQL index had been
64460 ** a unique index. Otherwise the caller will have set *pRes to zero.
64461 ** Zero is the common case. The btree implementation is free to use the
64462 ** initial *pRes value as a hint to improve performance, but the current
64463 ** SQLite btree implementation does not. (Note that the comdb2 btree
64464 ** implementation does use this hint, however.)
64465 */
64466 static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){
64467 int rc;
64468 int idx;
64469 MemPage *pPage;
64470
64471 assert( cursorOwnsBtShared(pCur) );
64472 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64473 assert( *pRes==0 );
64474 if( pCur->eState!=CURSOR_VALID ){
64475 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
64476 rc = restoreCursorPosition(pCur);
64477 if( rc!=SQLITE_OK ){
64478 return rc;
64479 }
64480 if( CURSOR_INVALID==pCur->eState ){
64481 *pRes = 1;
64482 return SQLITE_OK;
64483 }
64484 if( pCur->skipNext ){
64485 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
64486 pCur->eState = CURSOR_VALID;
64487 if( pCur->skipNext>0 ){
@@ -64916,18 +64509,19 @@
64509 if( rc ) return rc;
64510 return moveToLeftmost(pCur);
64511 }
64512 do{
64513 if( pCur->iPage==0 ){
64514 *pRes = 1;
64515 pCur->eState = CURSOR_INVALID;
64516 return SQLITE_OK;
64517 }
64518 moveToParent(pCur);
64519 pPage = pCur->apPage[pCur->iPage];
64520 }while( pCur->ix>=pPage->nCell );
64521 if( pPage->intKey ){
64522 return sqlite3BtreeNext(pCur, pRes);
64523 }else{
64524 return SQLITE_OK;
64525 }
64526 }
64527 if( pPage->leaf ){
@@ -64934,66 +64528,71 @@
64528 return SQLITE_OK;
64529 }else{
64530 return moveToLeftmost(pCur);
64531 }
64532 }
64533 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
64534 MemPage *pPage;
64535 assert( cursorOwnsBtShared(pCur) );
64536 assert( pRes!=0 );
64537 assert( *pRes==0 || *pRes==1 );
64538 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64539 pCur->info.nSize = 0;
64540 pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
64541 *pRes = 0;
64542 if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, pRes);
64543 pPage = pCur->apPage[pCur->iPage];
64544 if( (++pCur->ix)>=pPage->nCell ){
64545 pCur->ix--;
64546 return btreeNext(pCur, pRes);
64547 }
64548 if( pPage->leaf ){
64549 return SQLITE_OK;
64550 }else{
64551 return moveToLeftmost(pCur);
64552 }
64553 }
64554
64555 /*
64556 ** Step the cursor to the back to the previous entry in the database. If
64557 ** successful then set *pRes=0. If the cursor
64558 ** was already pointing to the first entry in the database before
64559 ** this routine was called, then set *pRes=1.
 
 
64560 **
64561 ** The main entry point is sqlite3BtreePrevious(). That routine is optimized
64562 ** for the common case of merely decrementing the cell counter BtCursor.aiIdx
64563 ** to the previous cell on the current page. The (slower) btreePrevious()
64564 ** helper routine is called when it is necessary to move to a different page
64565 ** or to restore the cursor.
64566 **
64567 ** The calling function will set *pRes to 0 or 1. The initial *pRes value
64568 ** will be 1 if the cursor being stepped corresponds to an SQL index and
64569 ** if this routine could have been skipped if that SQL index had been
64570 ** a unique index. Otherwise the caller will have set *pRes to zero.
64571 ** Zero is the common case. The btree implementation is free to use the
64572 ** initial *pRes value as a hint to improve performance, but the current
64573 ** SQLite btree implementation does not. (Note that the comdb2 btree
64574 ** implementation does use this hint, however.)
64575 */
64576 static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){
64577 int rc;
64578 MemPage *pPage;
64579
64580 assert( cursorOwnsBtShared(pCur) );
64581 assert( pRes!=0 );
64582 assert( *pRes==0 );
64583 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64584 assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
64585 assert( pCur->info.nSize==0 );
64586 if( pCur->eState!=CURSOR_VALID ){
64587 rc = restoreCursorPosition(pCur);
64588 if( rc!=SQLITE_OK ){
64589 return rc;
64590 }
64591 if( CURSOR_INVALID==pCur->eState ){
64592 *pRes = 1;
64593 return SQLITE_OK;
64594 }
64595 if( pCur->skipNext ){
64596 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
64597 pCur->eState = CURSOR_VALID;
64598 if( pCur->skipNext<0 ){
@@ -65013,38 +64612,41 @@
64612 rc = moveToRightmost(pCur);
64613 }else{
64614 while( pCur->ix==0 ){
64615 if( pCur->iPage==0 ){
64616 pCur->eState = CURSOR_INVALID;
64617 *pRes = 1;
64618 return SQLITE_OK;
64619 }
64620 moveToParent(pCur);
64621 }
64622 assert( pCur->info.nSize==0 );
64623 assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );
64624
64625 pCur->ix--;
64626 pPage = pCur->apPage[pCur->iPage];
64627 if( pPage->intKey && !pPage->leaf ){
64628 rc = sqlite3BtreePrevious(pCur, pRes);
64629 }else{
64630 rc = SQLITE_OK;
64631 }
64632 }
64633 return rc;
64634 }
64635 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
64636 assert( cursorOwnsBtShared(pCur) );
64637 assert( pRes!=0 );
64638 assert( *pRes==0 || *pRes==1 );
64639 assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
64640 *pRes = 0;
64641 pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);
64642 pCur->info.nSize = 0;
64643 if( pCur->eState!=CURSOR_VALID
64644 || pCur->ix==0
64645 || pCur->apPage[pCur->iPage]->leaf==0
64646 ){
64647 return btreePrevious(pCur, pRes);
64648 }
64649 pCur->ix--;
64650 return SQLITE_OK;
64651 }
64652
@@ -65148,11 +64750,11 @@
64750 ** the freelist is empty. */
64751 iTrunk = get4byte(&pPage1->aData[32]);
64752 }
64753 testcase( iTrunk==mxPage );
64754 if( iTrunk>mxPage || nSearch++ > n ){
64755 rc = SQLITE_CORRUPT_BKPT;
64756 }else{
64757 rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
64758 }
64759 if( rc ){
64760 pTrunk = 0;
@@ -65177,11 +64779,11 @@
64779 *ppPage = pTrunk;
64780 pTrunk = 0;
64781 TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
64782 }else if( k>(u32)(pBt->usableSize/4 - 2) ){
64783 /* Value of k is out of range. Database corruption */
64784 rc = SQLITE_CORRUPT_BKPT;
64785 goto end_allocate_page;
64786 #ifndef SQLITE_OMIT_AUTOVACUUM
64787 }else if( searchList
64788 && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE))
64789 ){
@@ -65211,11 +64813,11 @@
64813 ** page in this case.
64814 */
64815 MemPage *pNewTrunk;
64816 Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);
64817 if( iNewTrunk>mxPage ){
64818 rc = SQLITE_CORRUPT_BKPT;
64819 goto end_allocate_page;
64820 }
64821 testcase( iNewTrunk==mxPage );
64822 rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);
64823 if( rc!=SQLITE_OK ){
@@ -65276,11 +64878,11 @@
64878 }
64879
64880 iPage = get4byte(&aData[8+closest*4]);
64881 testcase( iPage==mxPage );
64882 if( iPage>mxPage ){
64883 rc = SQLITE_CORRUPT_BKPT;
64884 goto end_allocate_page;
64885 }
64886 testcase( iPage==mxPage );
64887 if( !searchList
64888 || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE))
@@ -65546,12 +65148,11 @@
65148 pPage->xParseCell(pPage, pCell, pInfo);
65149 if( pInfo->nLocal==pInfo->nPayload ){
65150 return SQLITE_OK; /* No overflow pages. Return without doing anything */
65151 }
65152 if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){
65153 return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */
 
65154 }
65155 ovflPgno = get4byte(pCell + pInfo->nSize - 4);
65156 assert( pBt->usableSize > 4 );
65157 ovflPageSize = pBt->usableSize - 4;
65158 nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;
@@ -67762,12 +67363,12 @@
67363 ** from the internal node. The 'previous' entry is used for this instead
67364 ** of the 'next' entry, as the previous entry is always a part of the
67365 ** sub-tree headed by the child page of the cell being deleted. This makes
67366 ** balancing the tree following the delete operation easier. */
67367 if( !pPage->leaf ){
67368 int notUsed = 0;
67369 rc = sqlite3BtreePrevious(pCur, &notUsed);
67370 if( rc ) return rc;
67371 }
67372
67373 /* Save the positions of any other cursors open on this table before
67374 ** making any modifications. */
@@ -71423,11 +71024,11 @@
71024 if( enc!=SQLITE_UTF8 ){
71025 rc = sqlite3VdbeChangeEncoding(pVal, enc);
71026 }
71027 }else if( op==TK_UMINUS ) {
71028 /* This branch happens for multiple negative signs. Ex: -(-5) */
71029 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
71030 && pVal!=0
71031 ){
71032 sqlite3VdbeMemNumerify(pVal);
71033 if( pVal->flags & MEM_Real ){
71034 pVal->u.r = -pVal->u.r;
@@ -71580,25 +71181,28 @@
71181 sqlite3 *db = pParse->db;
71182
71183 /* Skip over any TK_COLLATE nodes */
71184 pExpr = sqlite3ExprSkipCollate(pExpr);
71185
 
71186 if( !pExpr ){
71187 pVal = valueNew(db, pAlloc);
71188 if( pVal ){
71189 sqlite3VdbeMemSetNull((Mem*)pVal);
71190 }
71191 }else if( pExpr->op==TK_VARIABLE
71192 || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
71193 ){
71194 Vdbe *v;
71195 int iBindVar = pExpr->iColumn;
71196 sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
71197 if( (v = pParse->pReprepare)!=0 ){
71198 pVal = valueNew(db, pAlloc);
71199 if( pVal ){
71200 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
71201 if( rc==SQLITE_OK ){
71202 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
71203 }
71204 pVal->db = pParse->db;
71205 }
71206 }
71207 }else{
71208 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
@@ -71868,18 +71472,20 @@
71472 }
71473
71474 /*
71475 ** Remember the SQL string for a prepared statement.
71476 */
71477 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71478 assert( isPrepareV2==1 || isPrepareV2==0 );
71479 if( p==0 ) return;
71480 if( !isPrepareV2 ) p->expmask = 0;
71481 #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71482 if( !isPrepareV2 ) return;
71483 #endif
71484 assert( p->zSql==0 );
71485 p->zSql = sqlite3DbStrNDup(p->db, z, n);
71486 p->isPrepareV2 = (u8)isPrepareV2;
71487 }
71488
71489 /*
71490 ** Swap all content between two VDBE structures.
71491 */
@@ -71897,14 +71503,12 @@
71503 pA->pPrev = pB->pPrev;
71504 pB->pPrev = pTmp;
71505 zTmp = pA->zSql;
71506 pA->zSql = pB->zSql;
71507 pB->zSql = zTmp;
71508 pB->isPrepareV2 = pA->isPrepareV2;
71509 pB->expmask = pA->expmask;
 
 
 
71510 }
71511
71512 /*
71513 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71514 ** than its current size. nOp is guaranteed to be less than or equal
@@ -73974,22 +73578,21 @@
73578 ** statement. This is now set at compile time, rather than during
73579 ** execution of the vdbe program so that sqlite3_column_count() can
73580 ** be called on an SQL statement before sqlite3_step().
73581 */
73582 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
73583 Mem *pColName;
73584 int n;
73585 sqlite3 *db = p->db;
73586
73587 releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
73588 sqlite3DbFree(db, p->aColName);
 
 
73589 n = nResColumn*COLNAME_N;
73590 p->nResColumn = (u16)nResColumn;
73591 p->aColName = pColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );
73592 if( p->aColName==0 ) return;
73593 initMemArray(p->aColName, n, p->db, MEM_Null);
73594 }
73595
73596 /*
73597 ** Set the name of the idx'th column to be returned by the SQL statement.
73598 ** zName must be a pointer to a nul terminated string.
@@ -74635,14 +74238,14 @@
74238 sqlite3BeginBenignMalloc();
74239 if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);
74240 sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
74241 sqlite3EndBenignMalloc();
74242 db->bBenignMalloc--;
74243 db->errCode = rc;
74244 }else{
74245 sqlite3Error(db, rc);
74246 }
 
74247 return rc;
74248 }
74249
74250 #ifdef SQLITE_ENABLE_SQLLOG
74251 /*
@@ -75546,24 +75149,23 @@
75149 ** comparison function directly */
75150 return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
75151 }else{
75152 int rc;
75153 const void *v1, *v2;
75154 int n1, n2;
75155 Mem c1;
75156 Mem c2;
75157 sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
75158 sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
75159 sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
75160 sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
75161 v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
75162 n1 = v1==0 ? 0 : c1.n;
75163 v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
75164 n2 = v2==0 ? 0 : c2.n;
75165 rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
75166 if( (v1==0 || v2==0) && prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
 
 
 
75167 sqlite3VdbeMemRelease(&c1);
75168 sqlite3VdbeMemRelease(&c2);
75169 return rc;
75170 }
75171 }
@@ -76344,17 +75946,10 @@
75946 */
75947 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
75948 return v->db;
75949 }
75950
 
 
 
 
 
 
 
75951 /*
75952 ** Return a pointer to an sqlite3_value structure containing the value bound
75953 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
75954 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
75955 ** constants) to the value before returning it.
@@ -76363,11 +75958,10 @@
75958 */
75959 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
75960 assert( iVar>0 );
75961 if( v ){
75962 Mem *pMem = &v->aVar[iVar-1];
 
75963 if( 0==(pMem->flags & MEM_Null) ){
75964 sqlite3_value *pRet = sqlite3ValueNew(v->db);
75965 if( pRet ){
75966 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
75967 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
@@ -76383,11 +75977,10 @@
75977 ** to sqlite3_reoptimize() that re-preparing the statement may result
75978 ** in a better query plan.
75979 */
75980 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
75981 assert( iVar>0 );
 
75982 if( iVar>=32 ){
75983 v->expmask |= 0x80000000;
75984 }else{
75985 v->expmask |= ((u32)1 << (iVar-1));
75986 }
@@ -76655,11 +76248,11 @@
76248 sqlite3_mutex_enter(mutex);
76249 for(i=0; i<p->nVar; i++){
76250 sqlite3VdbeMemRelease(&p->aVar[i]);
76251 p->aVar[i].flags = MEM_Null;
76252 }
76253 assert( p->isPrepareV2 || p->expmask==0 );
76254 if( p->expmask ){
76255 p->expired = 1;
76256 }
76257 sqlite3_mutex_leave(mutex);
76258 return rc;
@@ -77134,15 +76727,12 @@
76727 */
76728 assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
76729 || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
76730 );
76731 assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
76732 if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
76733 /* If this statement was prepared using sqlite3_prepare_v2(), and an
 
 
 
76734 ** error has occurred, then return the error code in p->rc to the
76735 ** caller. Set the error code in the database handle to the same value.
76736 */
76737 rc = sqlite3VdbeTransferError(p);
76738 }
@@ -77777,11 +77367,11 @@
77367 ** parameter in the WHERE clause might influence the choice of query plan
77368 ** for a statement, then the statement will be automatically recompiled,
77369 ** as if there had been a schema change, on the first sqlite3_step() call
77370 ** following any change to the bindings of that parameter.
77371 */
77372 assert( p->isPrepareV2 || p->expmask==0 );
77373 if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
77374 p->expired = 1;
77375 }
77376 return SQLITE_OK;
77377 }
@@ -77807,14 +77397,12 @@
77397 pVar = &p->aVar[i-1];
77398 rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
77399 if( rc==SQLITE_OK && encoding!=0 ){
77400 rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
77401 }
77402 sqlite3Error(p->db, rc);
77403 rc = sqlite3ApiExit(p->db, rc);
 
 
77404 }
77405 sqlite3_mutex_leave(p->db->mutex);
77406 }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){
77407 xDel((void*)zData);
77408 }
@@ -78043,15 +77631,15 @@
77631 Vdbe *pFrom = (Vdbe*)pFromStmt;
77632 Vdbe *pTo = (Vdbe*)pToStmt;
77633 if( pFrom->nVar!=pTo->nVar ){
77634 return SQLITE_ERROR;
77635 }
77636 assert( pTo->isPrepareV2 || pTo->expmask==0 );
77637 if( pTo->expmask ){
77638 pTo->expired = 1;
77639 }
77640 assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
77641 if( pFrom->expmask ){
77642 pFrom->expired = 1;
77643 }
77644 return sqlite3TransferBindings(pFromStmt, pToStmt);
77645 }
@@ -78117,23 +77705,12 @@
77705 if( !pStmt ){
77706 (void)SQLITE_MISUSE_BKPT;
77707 return 0;
77708 }
77709 #endif
77710 v = pVdbe->aCounter[op];
77711 if( resetFlag ) pVdbe->aCounter[op] = 0;
 
 
 
 
 
 
 
 
 
 
 
77712 return (int)v;
77713 }
77714
77715 /*
77716 ** Return the SQL associated with a prepared statement
@@ -79284,11 +78861,11 @@
78861 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
78862 u8 encoding = ENC(db); /* The database encoding */
78863 int iCompare = 0; /* Result of last comparison */
78864 unsigned nVmStep = 0; /* Number of virtual machine steps */
78865 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
78866 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
78867 #endif
78868 Mem *aMem = p->aMem; /* Copy of p->aMem */
78869 Mem *pIn1 = 0; /* 1st input operand */
78870 Mem *pIn2 = 0; /* 2nd input operand */
78871 Mem *pIn3 = 0; /* 3rd input operand */
@@ -79316,12 +78893,10 @@
78893 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
78894 if( db->xProgress ){
78895 u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];
78896 assert( 0 < db->nProgressOps );
78897 nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);
 
 
78898 }
78899 #endif
78900 #ifdef SQLITE_DEBUG
78901 sqlite3BeginBenignMalloc();
78902 if( p->pc==0
@@ -79495,11 +79070,11 @@
79070 ** of VDBE ops have been executed (either since this invocation of
79071 ** sqlite3VdbeExec() or since last time the progress callback was called).
79072 ** If the progress callback returns non-zero, exit the virtual machine with
79073 ** a return code SQLITE_ABORT.
79074 */
79075 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
79076 assert( db->nProgressOps!=0 );
79077 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
79078 if( db->xProgress(db->pProgressArg) ){
79079 rc = SQLITE_INTERRUPT;
79080 goto abort_due_to_error;
@@ -80037,11 +79612,11 @@
79612
79613 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
79614 /* Run the progress counter just before returning.
79615 */
79616 if( db->xProgress!=0
79617 && nVmStep>=nProgressLimit
79618 && db->xProgress(db->pProgressArg)!=0
79619 ){
79620 rc = SQLITE_INTERRUPT;
79621 goto abort_due_to_error;
79622 }
@@ -81208,13 +80783,11 @@
80783 Mem *pReg; /* PseudoTable input register */
80784
80785 pC = p->apCsr[pOp->p1];
80786 p2 = pOp->p2;
80787
80788 /* If the cursor cache is stale, bring it up-to-date */
 
 
80789 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
80790 if( rc ) goto abort_due_to_error;
80791
80792 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
80793 pDest = &aMem[pOp->p3];
@@ -82692,35 +82265,21 @@
82265 sqlite3_search_count++;
82266 #endif
82267 if( oc>=OP_SeekGE ){ assert( oc==OP_SeekGE || oc==OP_SeekGT );
82268 if( res<0 || (res==0 && oc==OP_SeekGT) ){
82269 res = 0;
82270 rc = sqlite3BtreeNext(pC->uc.pCursor, &res);
82271 if( rc!=SQLITE_OK ) goto abort_due_to_error;
 
 
 
 
 
 
 
82272 }else{
82273 res = 0;
82274 }
82275 }else{
82276 assert( oc==OP_SeekLT || oc==OP_SeekLE );
82277 if( res>0 || (res==0 && oc==OP_SeekLT) ){
82278 res = 0;
82279 rc = sqlite3BtreePrevious(pC->uc.pCursor, &res);
82280 if( rc!=SQLITE_OK ) goto abort_due_to_error;
 
 
 
 
 
 
 
82281 }else{
82282 /* res might be negative because the table is empty. Check to
82283 ** see if this is the case.
82284 */
82285 res = sqlite3BtreeEof(pC->uc.pCursor);
@@ -83822,14 +83381,16 @@
83381 ** invoked. This opcode advances the cursor to the next sorted
83382 ** record, or jumps to P2 if there are no more sorted records.
83383 */
83384 case OP_SorterNext: { /* jump */
83385 VdbeCursor *pC;
83386 int res;
83387
83388 pC = p->apCsr[pOp->p1];
83389 assert( isSorter(pC) );
83390 res = 0;
83391 rc = sqlite3VdbeSorterNext(db, pC, &res);
83392 goto next_tail;
83393 case OP_PrevIfOpen: /* jump */
83394 case OP_NextIfOpen: /* jump */
83395 if( p->apCsr[pOp->p1]==0 ) break;
83396 /* Fall through */
@@ -83836,13 +83397,16 @@
83397 case OP_Prev: /* jump */
83398 case OP_Next: /* jump */
83399 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
83400 assert( pOp->p5<ArraySize(p->aCounter) );
83401 pC = p->apCsr[pOp->p1];
83402 res = pOp->p3;
83403 assert( pC!=0 );
83404 assert( pC->deferredMoveto==0 );
83405 assert( pC->eCurType==CURTYPE_BTREE );
83406 assert( res==0 || (res==1 && pC->isTable==0) );
83407 testcase( res==1 );
83408 assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
83409 assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
83410 assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );
83411 assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);
83412
@@ -83853,25 +83417,25 @@
83417 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);
83418 assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen
83419 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
83420 || pC->seekOp==OP_Last );
83421
83422 rc = pOp->p4.xAdvance(pC->uc.pCursor, &res);
83423 next_tail:
83424 pC->cacheStatus = CACHE_STALE;
83425 VdbeBranchTaken(res==0,2);
83426 if( rc ) goto abort_due_to_error;
83427 if( res==0 ){
83428 pC->nullRow = 0;
83429 p->aCounter[pOp->p5]++;
83430 #ifdef SQLITE_TEST
83431 sqlite3_search_count++;
83432 #endif
83433 goto jump_to_p2_and_check_for_interrupt;
83434 }else{
83435 pC->nullRow = 1;
83436 }
 
 
 
83437 goto check_for_interrupt;
83438 }
83439
83440 /* Opcode: IdxInsert P1 P2 P3 P4 P5
83441 ** Synopsis: key=r[P2]
@@ -83978,12 +83542,12 @@
83542 pC->cacheStatus = CACHE_STALE;
83543 pC->seekResult = 0;
83544 break;
83545 }
83546
83547 /* Opcode: Seek P1 * P3 P4 *
83548 ** Synopsis: Move P3 to P1.rowid
83549 **
83550 ** P1 is an open index cursor and P3 is a cursor on the corresponding
83551 ** table. This opcode does a deferred seek of the P3 table cursor
83552 ** to the row that corresponds to the current row of P1.
83553 **
@@ -84006,15 +83570,15 @@
83570 ** the end of the index key pointed to by cursor P1. This integer should be
83571 ** the rowid of the table entry to which this index entry points.
83572 **
83573 ** See also: Rowid, MakeRecord.
83574 */
83575 case OP_Seek:
83576 case OP_IdxRowid: { /* out2 */
83577 VdbeCursor *pC; /* The P1 index cursor */
83578 VdbeCursor *pTabCur; /* The P2 table cursor (OP_Seek only) */
83579 i64 rowid; /* Rowid that P1 current points to */
83580
83581 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
83582 pC = p->apCsr[pOp->p1];
83583 assert( pC!=0 );
83584 assert( pC->eCurType==CURTYPE_BTREE );
@@ -84036,11 +83600,11 @@
83600 rowid = 0; /* Not needed. Only used to silence a warning. */
83601 rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);
83602 if( rc!=SQLITE_OK ){
83603 goto abort_due_to_error;
83604 }
83605 if( pOp->opcode==OP_Seek ){
83606 assert( pOp->p3>=0 && pOp->p3<p->nCursor );
83607 pTabCur = p->apCsr[pOp->p3];
83608 assert( pTabCur!=0 );
83609 assert( pTabCur->eCurType==CURTYPE_BTREE );
83610 assert( pTabCur->uc.pCursor!=0 );
@@ -85282,11 +84846,11 @@
84846 ** P4 contains a pointer to the name of the table being locked. This is only
84847 ** used to generate an error message if the lock cannot be obtained.
84848 */
84849 case OP_TableLock: {
84850 u8 isWriteLock = (u8)pOp->p3;
84851 if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){
84852 int p1 = pOp->p1;
84853 assert( p1>=0 && p1<db->nDb );
84854 assert( DbMaskTest(p->btreeMask, p1) );
84855 assert( isWriteLock==0 || isWriteLock==1 );
84856 rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
@@ -85790,11 +85354,10 @@
85354 if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
85355 }
85356 pOp->p1 = 0;
85357 }
85358 pOp->p1++;
 
85359 goto jump_to_p2;
85360 }
85361
85362 #ifdef SQLITE_ENABLE_CURSOR_HINTS
85363 /* Opcode: CursorHint P1 * * P4 *
@@ -87264,13 +86827,13 @@
86827
86828 int n1;
86829 int n2;
86830 int res;
86831
86832 getVarint32(&p1[1], n1); n1 = (n1 - 13) / 2;
86833 getVarint32(&p2[1], n2); n2 = (n2 - 13) / 2;
86834 res = memcmp(v1, v2, MIN(n1, n2));
86835 if( res==0 ){
86836 res = n1 - n2;
86837 }
86838
86839 if( res==0 ){
@@ -89061,17 +88624,13 @@
88624 vdbeSorterRewindDebug("rewinddone");
88625 return rc;
88626 }
88627
88628 /*
88629 ** Advance to the next element in the sorter.
 
 
 
 
88630 */
88631 SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){
88632 VdbeSorter *pSorter;
88633 int rc; /* Return code */
88634
88635 assert( pCsr->eCurType==CURTYPE_SORTER );
88636 pSorter = pCsr->uc.pSorter;
@@ -89081,26 +88640,25 @@
88640 assert( pSorter->bUseThreads==0 || pSorter->pReader );
88641 assert( pSorter->bUseThreads==1 || pSorter->pMerger );
88642 #if SQLITE_MAX_WORKER_THREADS>0
88643 if( pSorter->bUseThreads ){
88644 rc = vdbePmaReaderNext(pSorter->pReader);
88645 *pbEof = (pSorter->pReader->pFd==0);
88646 }else
88647 #endif
88648 /*if( !pSorter->bUseThreads )*/ {
 
88649 assert( pSorter->pMerger!=0 );
88650 assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );
88651 rc = vdbeMergeEngineStep(pSorter->pMerger, pbEof);
 
88652 }
88653 }else{
88654 SorterRecord *pFree = pSorter->list.pList;
88655 pSorter->list.pList = pFree->u.pNext;
88656 pFree->u.pNext = 0;
88657 if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);
88658 *pbEof = !pSorter->list.pList;
88659 rc = SQLITE_OK;
88660 }
88661 return rc;
88662 }
88663
88664 /*
@@ -89750,37 +89308,44 @@
89308 ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
89309 ** on the compound select chain, p->pPrior.
89310 **
89311 ** If it is not NULL, the xSelectCallback() callback is invoked before
89312 ** the walk of the expressions and FROM clause. The xSelectCallback2()
89313 ** method, if it is not NULL, is invoked following the walk of the
89314 ** expressions and FROM clause.
 
89315 **
89316 ** Return WRC_Continue under normal conditions. Return WRC_Abort if
89317 ** there is an abort request.
89318 **
89319 ** If the Walker does not have an xSelectCallback() then this routine
89320 ** is a no-op returning WRC_Continue.
89321 */
89322 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
89323 int rc;
89324 if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){
89325 return WRC_Continue;
89326 }
89327 rc = WRC_Continue;
89328 pWalker->walkerDepth++;
89329 while( p ){
89330 if( pWalker->xSelectCallback ){
89331 rc = pWalker->xSelectCallback(pWalker, p);
89332 if( rc ) break;
89333 }
89334 if( sqlite3WalkSelectExpr(pWalker, p)
89335 || sqlite3WalkSelectFrom(pWalker, p)
89336 ){
89337 pWalker->walkerDepth--;
89338 return WRC_Abort;
89339 }
89340 if( pWalker->xSelectCallback2 ){
89341 pWalker->xSelectCallback2(pWalker, p);
89342 }
89343 p = p->pPrior;
89344 }
89345 pWalker->walkerDepth--;
89346 return rc & WRC_Abort;
89347 }
89348
89349 /************** End of walker.c **********************************************/
89350 /************** Begin file resolve.c *****************************************/
89351 /*
@@ -90693,11 +90258,11 @@
90258 /* Try to match the ORDER BY expression against an expression
90259 ** in the result set. Return an 1-based index of the matching
90260 ** result-set entry.
90261 */
90262 for(i=0; i<pEList->nExpr; i++){
90263 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
90264 return i+1;
90265 }
90266 }
90267
90268 /* If no match, return 0. */
@@ -90927,11 +90492,11 @@
90492 pItem->u.x.iOrderByCol = 0;
90493 if( sqlite3ResolveExprNames(pNC, pE) ){
90494 return 1;
90495 }
90496 for(j=0; j<pSelect->pEList->nExpr; j++){
90497 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
90498 pItem->u.x.iOrderByCol = j+1;
90499 }
90500 }
90501 }
90502 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -91213,33 +90778,41 @@
90778 Expr *pExpr /* The expression to be analyzed. */
90779 ){
90780 u16 savedHasAgg;
90781 Walker w;
90782
90783 if( pExpr==0 ) return 0;
90784 #if SQLITE_MAX_EXPR_DEPTH>0
90785 {
90786 Parse *pParse = pNC->pParse;
90787 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){
90788 return 1;
90789 }
90790 pParse->nHeight += pExpr->nHeight;
90791 }
90792 #endif
90793 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);
90794 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);
90795 w.pParse = pNC->pParse;
90796 w.xExprCallback = resolveExprStep;
90797 w.xSelectCallback = resolveSelectStep;
90798 w.xSelectCallback2 = 0;
90799 w.walkerDepth = 0;
90800 w.eCode = 0;
90801 w.u.pNC = pNC;
 
 
 
 
 
 
90802 sqlite3WalkExpr(&w, pExpr);
90803 #if SQLITE_MAX_EXPR_DEPTH>0
90804 pNC->pParse->nHeight -= pExpr->nHeight;
90805 #endif
90806 if( pNC->nErr>0 || w.pParse->nErr>0 ){
90807 ExprSetProperty(pExpr, EP_Error);
90808 }
90809 if( pNC->ncFlags & NC_HasAgg ){
90810 ExprSetProperty(pExpr, EP_Agg);
90811 }
90812 pNC->ncFlags |= savedHasAgg;
90813 return ExprHasProperty(pExpr, EP_Error);
90814 }
90815
90816 /*
90817 ** Resolve all names for all expression in an expression list. This is
90818 ** just like sqlite3ResolveExprNames() except that it works for an expression
@@ -91276,13 +90849,13 @@
90849 NameContext *pOuterNC /* Name context for parent SELECT statement */
90850 ){
90851 Walker w;
90852
90853 assert( p!=0 );
90854 memset(&w, 0, sizeof(w));
90855 w.xExprCallback = resolveExprStep;
90856 w.xSelectCallback = resolveSelectStep;
 
90857 w.pParse = pParse;
90858 w.u.pNC = pOuterNC;
90859 sqlite3WalkSelect(&w, p);
90860 }
90861
@@ -92811,13 +92384,11 @@
92384 }
92385 pList = pNew;
92386 pList->nAlloc *= 2;
92387 }
92388 pItem = &pList->a[pList->nExpr++];
92389 memset(pItem, 0, sizeof(*pItem));
 
 
92390 pItem->pExpr = pExpr;
92391 return pList;
92392
92393 no_mem:
92394 /* Avoid leaking memory if malloc has failed. */
@@ -93097,16 +92668,14 @@
92668 pWalker->eCode = 0;
92669 return WRC_Abort;
92670 }
92671 static int exprIsConst(Expr *p, int initFlag, int iCur){
92672 Walker w;
92673 memset(&w, 0, sizeof(w));
92674 w.eCode = initFlag;
92675 w.xExprCallback = exprNodeIsConstant;
92676 w.xSelectCallback = selectNodeIsConstant;
 
 
 
92677 w.u.iCur = iCur;
92678 sqlite3WalkExpr(&w, p);
92679 return w.eCode;
92680 }
92681
@@ -93152,11 +92721,11 @@
92721
92722 /* Check if pExpr is identical to any GROUP BY term. If so, consider
92723 ** it constant. */
92724 for(i=0; i<pGroupBy->nExpr; i++){
92725 Expr *p = pGroupBy->a[i].pExpr;
92726 if( sqlite3ExprCompare(pExpr, p, -1)<2 ){
92727 CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p);
92728 if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){
92729 return WRC_Prune;
92730 }
92731 }
@@ -93190,13 +92759,13 @@
92759 ** optimization, so we take the easy way out and simply require the
92760 ** GROUP BY to use the BINARY collating sequence.
92761 */
92762 SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){
92763 Walker w;
92764 memset(&w, 0, sizeof(w));
92765 w.eCode = 1;
92766 w.xExprCallback = exprNodeIsConstantOrGroupBy;
 
92767 w.u.pGroupBy = pGroupBy;
92768 w.pParse = pParse;
92769 sqlite3WalkExpr(&w, p);
92770 return w.eCode;
92771 }
@@ -93220,16 +92789,14 @@
92789 ** Walk an expression tree. Return 1 if the expression contains a
92790 ** subquery of some kind. Return 0 if there are no subqueries.
92791 */
92792 SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){
92793 Walker w;
92794 memset(&w, 0, sizeof(w));
92795 w.eCode = 1;
92796 w.xExprCallback = sqlite3ExprWalkNoop;
92797 w.xSelectCallback = selectNodeIsConstant;
 
 
 
92798 sqlite3WalkExpr(&w, p);
92799 return w.eCode==0;
92800 }
92801 #endif
92802
@@ -95428,11 +94995,11 @@
94995 p = pParse->pConstExpr;
94996 if( regDest<0 && p ){
94997 struct ExprList_item *pItem;
94998 int i;
94999 for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){
95000 if( pItem->reusable && sqlite3ExprCompare(pItem->pExpr,pExpr,-1)==0 ){
95001 return pItem->u.iConstExprReg;
95002 }
95003 }
95004 }
95005 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
@@ -95983,45 +95550,10 @@
95550 sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);
95551 }
95552 sqlite3ExprDelete(db, pCopy);
95553 }
95554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95555
95556 /*
95557 ** Do a deep comparison of two expression trees. Return 0 if the two
95558 ** expressions are completely identical. Return 1 if they differ only
95559 ** by a COLLATE operator at the top level. Return 2 if there are differences
@@ -96040,38 +95572,28 @@
95572 ** expressions are the same. But if you get a 0 or 1 return, then you
95573 ** can be sure the expressions are the same. In the places where
95574 ** this routine is used, it does not hurt to get an extra 2 - that
95575 ** just might result in some slightly slower code. But returning
95576 ** an incorrect 0 or 1 could lead to a malfunction.
 
 
 
 
 
 
 
95577 */
95578 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
95579 u32 combinedFlags;
95580 if( pA==0 || pB==0 ){
95581 return pB==pA ? 0 : 2;
95582 }
 
 
 
95583 combinedFlags = pA->flags | pB->flags;
95584 if( combinedFlags & EP_IntValue ){
95585 if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){
95586 return 0;
95587 }
95588 return 2;
95589 }
95590 if( pA->op!=pB->op ){
95591 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
95592 return 1;
95593 }
95594 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
95595 return 1;
95596 }
95597 return 2;
95598 }
95599 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
@@ -96082,12 +95604,12 @@
95604 }
95605 }
95606 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
95607 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
95608 if( combinedFlags & EP_xIsSelect ) return 2;
95609 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
95610 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
95611 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
95612 if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
95613 if( pA->iColumn!=pB->iColumn ) return 2;
95614 if( pA->iTable!=pB->iTable
95615 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
@@ -96118,21 +95640,21 @@
95640 if( pA->nExpr!=pB->nExpr ) return 1;
95641 for(i=0; i<pA->nExpr; i++){
95642 Expr *pExprA = pA->a[i].pExpr;
95643 Expr *pExprB = pB->a[i].pExpr;
95644 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
95645 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
95646 }
95647 return 0;
95648 }
95649
95650 /*
95651 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
95652 ** are ignored.
95653 */
95654 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
95655 return sqlite3ExprCompare(
95656 sqlite3ExprSkipCollate(pA),
95657 sqlite3ExprSkipCollate(pB),
95658 iTab);
95659 }
95660
@@ -96150,33 +95672,28 @@
95672 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
95673 **
95674 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
95675 ** Expr.iTable<0 then assume a table number given by iTab.
95676 **
 
 
 
 
 
95677 ** When in doubt, return false. Returning true might give a performance
95678 ** improvement. Returning false might cause a performance reduction, but
95679 ** it will always give the correct answer and is hence always safe.
95680 */
95681 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
95682 if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
95683 return 1;
95684 }
95685 if( pE2->op==TK_OR
95686 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
95687 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
95688 ){
95689 return 1;
95690 }
95691 if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){
95692 Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
95693 testcase( pX!=pE1->pLeft );
95694 if( sqlite3ExprCompare(pX, pE2->pLeft, iTab)==0 ) return 1;
95695 }
95696 return 0;
95697 }
95698
95699 /*
@@ -96280,12 +95797,12 @@
95797 */
95798 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
95799 Walker w;
95800 struct SrcCount cnt;
95801 assert( pExpr->op==TK_AGG_FUNCTION );
95802 memset(&w, 0, sizeof(w));
95803 w.xExprCallback = exprSrcCount;
 
95804 w.u.pSrcCount = &cnt;
95805 cnt.pSrc = pSrcList;
95806 cnt.nThis = 0;
95807 cnt.nOther = 0;
95808 sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -96413,11 +95930,11 @@
95930 /* Check to see if pExpr is a duplicate of another aggregate
95931 ** function that is already in the pAggInfo structure
95932 */
95933 struct AggInfo_func *pItem = pAggInfo->aFunc;
95934 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
95935 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
95936 break;
95937 }
95938 }
95939 if( i>=pAggInfo->nFunc ){
95940 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -96453,18 +95970,14 @@
95970 }
95971 }
95972 return WRC_Continue;
95973 }
95974 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
95975 UNUSED_PARAMETER(pWalker);
95976 UNUSED_PARAMETER(pSelect);
 
95977 return WRC_Continue;
95978 }
 
 
 
 
95979
95980 /*
95981 ** Analyze the pExpr expression looking for aggregate functions and
95982 ** for variables that need to be added to AggInfo object that pNC->pAggInfo
95983 ** points to. Additional entries are made on the AggInfo object as
@@ -96473,14 +95986,13 @@
95986 ** This routine should only be called after the expression has been
95987 ** analyzed by sqlite3ResolveExprNames().
95988 */
95989 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
95990 Walker w;
95991 memset(&w, 0, sizeof(w));
95992 w.xExprCallback = analyzeAggregate;
95993 w.xSelectCallback = analyzeAggregatesInSelect;
 
 
95994 w.u.pNC = pNC;
95995 assert( pNC->pSrcList!=0 );
95996 sqlite3WalkExpr(&w, pExpr);
95997 }
95998
@@ -96970,11 +96482,11 @@
96482 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
96483 **
96484 ** Or, if zName is not a system table, zero is returned.
96485 */
96486 static int isSystemTable(Parse *pParse, const char *zName){
96487 if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
96488 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
96489 return 1;
96490 }
96491 return 0;
96492 }
@@ -99389,12 +98901,11 @@
98901 const char *zName;
98902 const char *zFile;
98903 char *zPath = 0;
98904 char *zErr = 0;
98905 unsigned int flags;
98906 Db *aNew;
 
98907 char *zErrDyn = 0;
98908 sqlite3_vfs *pVfs;
98909
98910 UNUSED_PARAMETER(NotUsed);
98911
@@ -99438,12 +98949,12 @@
98949 }else{
98950 aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
98951 if( aNew==0 ) return;
98952 }
98953 db->aDb = aNew;
98954 aNew = &db->aDb[db->nDb];
98955 memset(aNew, 0, sizeof(*aNew));
98956
98957 /* Open the database file. If the btree is successfully opened, use
98958 ** it to obtain the database schema. At this point the schema may
98959 ** or may not be initialized.
98960 */
@@ -99455,41 +98966,41 @@
98966 sqlite3_free(zErr);
98967 return;
98968 }
98969 assert( pVfs );
98970 flags |= SQLITE_OPEN_MAIN_DB;
98971 rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags);
98972 sqlite3_free( zPath );
98973 db->nDb++;
98974 db->skipBtreeMutex = 0;
98975 if( rc==SQLITE_CONSTRAINT ){
98976 rc = SQLITE_ERROR;
98977 zErrDyn = sqlite3MPrintf(db, "database is already attached");
98978 }else if( rc==SQLITE_OK ){
98979 Pager *pPager;
98980 aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);
98981 if( !aNew->pSchema ){
98982 rc = SQLITE_NOMEM_BKPT;
98983 }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){
98984 zErrDyn = sqlite3MPrintf(db,
98985 "attached databases must use the same text encoding as main database");
98986 rc = SQLITE_ERROR;
98987 }
98988 sqlite3BtreeEnter(aNew->pBt);
98989 pPager = sqlite3BtreePager(aNew->pBt);
98990 sqlite3PagerLockingMode(pPager, db->dfltLockMode);
98991 sqlite3BtreeSecureDelete(aNew->pBt,
98992 sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
98993 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
98994 sqlite3BtreeSetPagerFlags(aNew->pBt,
98995 PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
98996 #endif
98997 sqlite3BtreeLeave(aNew->pBt);
98998 }
98999 aNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
99000 aNew->zDbSName = sqlite3DbStrDup(db, zName);
99001 if( rc==SQLITE_OK && aNew->zDbSName==0 ){
99002 rc = SQLITE_NOMEM_BKPT;
99003 }
99004
99005
99006 #ifdef SQLITE_HAS_CODEC
@@ -101122,15 +100633,11 @@
100633 }
100634 pTable->zName = zName;
100635 pTable->iPKey = -1;
100636 pTable->pSchema = db->aDb[iDb].pSchema;
100637 pTable->nTabRef = 1;
 
 
 
100638 pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
 
100639 assert( pParse->pNewTable==0 );
100640 pParse->pNewTable = pTable;
100641
100642 /* If this is the magic sqlite_sequence table used by autoincrement,
100643 ** then record a pointer to this table in the main database structure
@@ -104368,13 +103875,11 @@
103875 for(j=0; j<pIdx->nKeyCol; j++){
103876 char *zCol;
103877 assert( pIdx->aiColumn[j]>=0 );
103878 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
103879 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
103880 sqlite3XPrintf(&errMsg, "%s.%s", pTab->zName, zCol);
 
 
103881 }
103882 }
103883 zErr = sqlite3StrAccumFinish(&errMsg);
103884 sqlite3HaltConstraint(pParse,
103885 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
@@ -105479,11 +104984,11 @@
104984 ** It is easier just to erase the whole table. Prior to version 3.6.5,
104985 ** this optimization caused the row change count (the value returned by
104986 ** API function sqlite3_count_changes) to be set incorrectly.
104987 **
104988 ** The "rcauth==SQLITE_OK" terms is the
104989 ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
104990 ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but
104991 ** the truncate optimization is disabled and all rows are deleted
104992 ** individually.
104993 */
104994 if( rcauth==SQLITE_OK
@@ -105585,11 +105090,11 @@
105090 sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,
105091 sqlite3IndexAffinityStr(pParse->db, pPk), nPk);
105092 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);
105093 }else{
105094 /* Add the rowid of the row to be deleted to the RowSet */
105095 nKey = 1; /* OP_Seek always uses a single rowid */
105096 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);
105097 }
105098 }
105099
105100 /* If this DELETE cannot use the ONEPASS strategy, this is the
@@ -108539,16 +108044,14 @@
108044 sqlite3ResolveExprNames(&sNameContext, pWhere);
108045
108046 /* Create VDBE to loop through the entries in pSrc that match the WHERE
108047 ** clause. For each row found, increment either the deferred or immediate
108048 ** foreign key constraint counter. */
108049 pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
108050 sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
108051 if( pWInfo ){
108052 sqlite3WhereEnd(pWInfo);
 
 
108053 }
108054
108055 /* Clean up the WHERE clause constructed above. */
108056 sqlite3ExprDelete(db, pWhere);
108057 if( iFkIfZero ){
@@ -109851,14 +109354,14 @@
109354 Trigger *pTrigger; /* List of triggers on pTab, if required */
109355 int tmask; /* Mask of trigger times */
109356 #endif
109357
109358 db = pParse->db;
109359 memset(&dest, 0, sizeof(dest));
109360 if( pParse->nErr || db->mallocFailed ){
109361 goto insert_cleanup;
109362 }
 
109363
109364 /* If the Select object is really just a simple VALUES() list with a
109365 ** single row (the common case) then keep that one row of values
109366 ** and discard the other (unused) parts of the pSelect object
109367 */
@@ -111228,11 +110731,11 @@
110731 if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){
110732 return 0; /* Different columns indexed */
110733 }
110734 if( pSrc->aiColumn[i]==XN_EXPR ){
110735 assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );
110736 if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr,
110737 pDest->aColExpr->a[i].pExpr, -1)!=0 ){
110738 return 0; /* Different expressions in the index */
110739 }
110740 }
110741 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
@@ -111240,11 +110743,11 @@
110743 }
110744 if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
110745 return 0; /* Different collating sequences */
110746 }
110747 }
110748 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
110749 return 0; /* Different WHERE clauses */
110750 }
110751
110752 /* If no test above fails then the indices must be compatible */
110753 return 1;
@@ -111720,12 +111223,15 @@
111223 if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
111224 sqlite3DbFree(db, azCols);
111225
111226 rc = sqlite3ApiExit(db, rc);
111227 if( rc!=SQLITE_OK && pzErrMsg ){
111228 int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
111229 *pzErrMsg = sqlite3Malloc(nErrMsg);
111230 if( *pzErrMsg ){
111231 memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
111232 }else{
111233 rc = SQLITE_NOMEM_BKPT;
111234 sqlite3Error(db, SQLITE_NOMEM);
111235 }
111236 }else if( pzErrMsg ){
111237 *pzErrMsg = 0;
@@ -113398,11 +112904,11 @@
112904 /* iArg: */ 0 },
112905 #endif
112906 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112907 {/* zName: */ "foreign_key_check",
112908 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
112909 /* ePragFlg: */ PragFlg_NeedSchema,
112910 /* ColNames: */ 39, 4,
112911 /* iArg: */ 0 },
112912 #endif
112913 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
112914 {/* zName: */ "foreign_key_list",
@@ -113485,11 +112991,11 @@
112991 /* iArg: */ 1 },
112992 #endif
112993 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
112994 {/* zName: */ "integrity_check",
112995 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
112996 /* ePragFlg: */ PragFlg_NeedSchema,
112997 /* ColNames: */ 0, 0,
112998 /* iArg: */ 0 },
112999 #endif
113000 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113001 {/* zName: */ "journal_mode",
@@ -113580,20 +113086,20 @@
113086 /* iArg: */ SQLITE_QueryOnly },
113087 #endif
113088 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
113089 {/* zName: */ "quick_check",
113090 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
113091 /* ePragFlg: */ PragFlg_NeedSchema,
113092 /* ColNames: */ 0, 0,
113093 /* iArg: */ 0 },
113094 #endif
113095 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113096 {/* zName: */ "read_uncommitted",
113097 /* ePragTyp: */ PragTyp_FLAG,
113098 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113099 /* ColNames: */ 0, 0,
113100 /* iArg: */ SQLITE_ReadUncommitted },
113101 {/* zName: */ "recursive_triggers",
113102 /* ePragTyp: */ PragTyp_FLAG,
113103 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113104 /* ColNames: */ 0, 0,
113105 /* iArg: */ SQLITE_RecTriggers },
@@ -113741,11 +113247,11 @@
113247 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113248 {/* zName: */ "writable_schema",
113249 /* ePragTyp: */ PragTyp_FLAG,
113250 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113251 /* ColNames: */ 0, 0,
113252 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
113253 #endif
113254 };
113255 /* Number of pragmas: 60 on by default, 74 total. */
113256
113257 /************** End of pragma.h **********************************************/
@@ -116183,11 +115689,11 @@
115689 InitData *pData, /* Initialization context */
115690 const char *zObj, /* Object being parsed at the point of error */
115691 const char *zExtra /* Error information */
115692 ){
115693 sqlite3 *db = pData->db;
115694 if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){
115695 char *z;
115696 if( zObj==0 ) zObj = "?";
115697 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
115698 if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
115699 sqlite3DbFree(db, *pData->pzErrMsg);
@@ -116470,12 +115976,12 @@
115976 }
115977 if( db->mallocFailed ){
115978 rc = SQLITE_NOMEM_BKPT;
115979 sqlite3ResetAllSchemasOfConnection(db);
115980 }
115981 if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){
115982 /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider
115983 ** the schema loaded, even if errors occurred. In this situation the
115984 ** current sqlite3_prepare() operation will fail, but the following one
115985 ** will attempt to compile the supplied statement against whatever subset
115986 ** of the schema was loaded before the error occurred. The primary
115987 ** purpose of this is to allow access to the sqlite_master table
@@ -116671,11 +116177,11 @@
116177 */
116178 static int sqlite3Prepare(
116179 sqlite3 *db, /* Database handle. */
116180 const char *zSql, /* UTF-8 encoded SQL statement. */
116181 int nBytes, /* Length of zSql in bytes. */
116182 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116183 Vdbe *pReprepare, /* VM being reprepared */
116184 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116185 const char **pzTail /* OUT: End of parsed string */
116186 ){
116187 char *zErrMsg = 0; /* Error message */
@@ -116688,18 +116194,10 @@
116194 sParse.pReprepare = pReprepare;
116195 assert( ppStmt && *ppStmt==0 );
116196 /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
116197 assert( sqlite3_mutex_held(db->mutex) );
116198
 
 
 
 
 
 
 
 
116199 /* Check to verify that it is possible to get a read lock on all
116200 ** database schemas. The inability to get a read lock indicates that
116201 ** some other database connection is holding a write-lock, which in
116202 ** turn means that the other connection has made uncommitted changes
116203 ** to the schema.
@@ -116727,11 +116225,11 @@
116225 assert( sqlite3BtreeHoldsMutex(pBt) );
116226 rc = sqlite3BtreeSchemaLocked(pBt);
116227 if( rc ){
116228 const char *zDb = db->aDb[i].zDbSName;
116229 sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb);
116230 testcase( db->flags & SQLITE_ReadUncommitted );
116231 goto end_prepare;
116232 }
116233 }
116234 }
116235
@@ -116795,11 +116293,12 @@
116293 }
116294 }
116295 #endif
116296
116297 if( db->init.busy==0 ){
116298 Vdbe *pVdbe = sParse.pVdbe;
116299 sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag);
116300 }
116301 if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){
116302 sqlite3VdbeFinalize(sParse.pVdbe);
116303 assert(!(*ppStmt));
116304 }else{
@@ -116829,11 +116328,11 @@
116328 }
116329 static int sqlite3LockAndPrepare(
116330 sqlite3 *db, /* Database handle. */
116331 const char *zSql, /* UTF-8 encoded SQL statement. */
116332 int nBytes, /* Length of zSql in bytes. */
116333 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
116334 Vdbe *pOld, /* VM being reprepared */
116335 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116336 const char **pzTail /* OUT: End of parsed string */
116337 ){
116338 int rc;
@@ -116845,14 +116344,14 @@
116344 if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
116345 return SQLITE_MISUSE_BKPT;
116346 }
116347 sqlite3_mutex_enter(db->mutex);
116348 sqlite3BtreeEnterAll(db);
116349 rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116350 if( rc==SQLITE_SCHEMA ){
116351 sqlite3_finalize(*ppStmt);
116352 rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);
116353 }
116354 sqlite3BtreeLeaveAll(db);
116355 sqlite3_mutex_leave(db->mutex);
116356 assert( rc==SQLITE_OK || *ppStmt==0 );
116357 return rc;
@@ -116869,19 +116368,17 @@
116368 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
116369 int rc;
116370 sqlite3_stmt *pNew;
116371 const char *zSql;
116372 sqlite3 *db;
 
116373
116374 assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );
116375 zSql = sqlite3_sql((sqlite3_stmt *)p);
116376 assert( zSql!=0 ); /* Reprepare only called for prepare_v2() statements */
116377 db = sqlite3VdbeDb(p);
116378 assert( sqlite3_mutex_held(db->mutex) );
116379 rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);
 
116380 if( rc ){
116381 if( rc==SQLITE_NOMEM ){
116382 sqlite3OomFault(db);
116383 }
116384 assert( pNew==0 );
@@ -116923,27 +116420,11 @@
116420 int nBytes, /* Length of zSql in bytes. */
116421 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116422 const char **pzTail /* OUT: End of parsed string */
116423 ){
116424 int rc;
116425 rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116426 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116427 return rc;
116428 }
116429
116430
@@ -116953,11 +116434,11 @@
116434 */
116435 static int sqlite3Prepare16(
116436 sqlite3 *db, /* Database handle. */
116437 const void *zSql, /* UTF-16 encoded SQL statement. */
116438 int nBytes, /* Length of zSql in bytes. */
116439 int saveSqlFlag, /* True to save SQL text into the sqlite3_stmt */
116440 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116441 const void **pzTail /* OUT: End of parsed string */
116442 ){
116443 /* This function currently works by first transforming the UTF-16
116444 ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
@@ -116981,11 +116462,11 @@
116462 nBytes = sz;
116463 }
116464 sqlite3_mutex_enter(db->mutex);
116465 zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
116466 if( zSql8 ){
116467 rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
116468 }
116469
116470 if( zTail8 && pzTail ){
116471 /* If sqlite3_prepare returns a tail pointer, we calculate the
116472 ** equivalent pointer into the UTF-16 string by counting the unicode
@@ -117027,26 +116508,11 @@
116508 int nBytes, /* Length of zSql in bytes. */
116509 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
116510 const void **pzTail /* OUT: End of parsed string */
116511 ){
116512 int rc;
116513 rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116514 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
116515 return rc;
116516 }
116517
116518 #endif /* SQLITE_OMIT_UTF16 */
@@ -118084,11 +117550,11 @@
117550 /*
117551 ** Allocate a KeyInfo object sufficient for an index of N key columns and
117552 ** X extra columns.
117553 */
117554 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
117555 int nExtra = (N+X)*(sizeof(CollSeq*)+1);
117556 KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);
117557 if( p ){
117558 p->aSortOrder = (u8*)&p->aColl[N+X];
117559 p->nField = (u16)N;
117560 p->nXField = (u16)X;
@@ -120258,16 +119724,13 @@
119724 ifNullRow.pLeft = pCopy;
119725 ifNullRow.iTable = pSubst->iNewTable;
119726 pCopy = &ifNullRow;
119727 }
119728 pNew = sqlite3ExprDup(db, pCopy, 0);
119729 if( pNew && (pExpr->flags & EP_FromJoin) ){
 
 
 
119730 pNew->iRightJoinTable = pExpr->iRightJoinTable;
119731 pNew->flags |= EP_FromJoin;
119732 }
119733 sqlite3ExprDelete(db, pExpr);
119734 pExpr = pNew;
119735 }
119736 }
@@ -120556,11 +120019,11 @@
120019 **
120020 ** which is not at all the same thing.
120021 **
120022 ** If the subquery is the right operand of a LEFT JOIN, then the outer
120023 ** query cannot be an aggregate. This is an artifact of the way aggregates
120024 ** are processed - there is not mechanism to determine if the LEFT JOIN
120025 ** table should be all-NULL.
120026 **
120027 ** See also tickets #306, #350, and #3300.
120028 */
120029 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
@@ -121667,29 +121130,10 @@
121130 UNUSED_PARAMETER2(NotUsed, NotUsed2);
121131 return WRC_Continue;
121132 }
121133
121134 /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121135 ** This routine "expands" a SELECT statement and all of its subqueries.
121136 ** For additional information on what it means to "expand" a SELECT
121137 ** statement, see the comment on the selectExpand worker callback above.
121138 **
121139 ** Expanding a SELECT statement is the first step in processing a
@@ -121700,15 +121144,15 @@
121144 ** The calling function can detect the problem by looking at pParse->nErr
121145 ** and/or pParse->db->mallocFailed.
121146 */
121147 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
121148 Walker w;
121149 memset(&w, 0, sizeof(w));
121150 w.xExprCallback = sqlite3ExprWalkNoop;
121151 w.pParse = pParse;
121152 if( pParse->hasCompound ){
121153 w.xSelectCallback = convertCompoundSelectToSubquery;
 
121154 sqlite3WalkSelect(&w, pSelect);
121155 }
121156 w.xSelectCallback = selectExpander;
121157 w.xSelectCallback2 = selectPopWith;
121158 sqlite3WalkSelect(&w, pSelect);
@@ -121764,11 +121208,11 @@
121208 ** Use this routine after name resolution.
121209 */
121210 static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
121211 #ifndef SQLITE_OMIT_SUBQUERY
121212 Walker w;
121213 memset(&w, 0, sizeof(w));
121214 w.xSelectCallback2 = selectAddSubqueryTypeInfo;
121215 w.xExprCallback = sqlite3ExprWalkNoop;
121216 w.pParse = pParse;
121217 sqlite3WalkSelect(&w, pSelect);
121218 #endif
@@ -122058,13 +121502,11 @@
121502 if( pItem->pSelect==0 ) continue;
121503 if( pItem->fg.viaCoroutine ) continue;
121504 if( pItem->zName==0 ) continue;
121505 if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
121506 if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
121507 if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){
 
 
121508 /* The view was modified by some other optimization such as
121509 ** pushDownWhereTerms() */
121510 continue;
121511 }
121512 return pItem;
@@ -122347,13 +121789,10 @@
121789 VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName));
121790 }
121791 pPrior = isSelfJoinView(pTabList, pItem);
121792 if( pPrior ){
121793 sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);
 
 
 
121794 }else{
121795 sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
121796 explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);
121797 sqlite3Select(pParse, pSub, &dest);
121798 }
@@ -123509,11 +122948,10 @@
122948 /* Make an entry in the sqlite_master table */
122949 v = sqlite3GetVdbe(pParse);
122950 if( v==0 ) goto triggerfinish_cleanup;
122951 sqlite3BeginWriteOperation(pParse, 0, iDb);
122952 z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
 
122953 sqlite3NestedParse(pParse,
122954 "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
122955 db->aDb[iDb].zDbSName, MASTER_NAME, zName,
122956 pTrig->table, z);
122957 sqlite3DbFree(db, z);
@@ -125377,11 +124815,11 @@
124815 #ifdef SQLITE_HAS_CODEC
124816 if( db->nextPagesize ){
124817 extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
124818 int nKey;
124819 char *zKey;
124820 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
124821 if( nKey ) db->nextPagesize = 0;
124822 }
124823 #endif
124824
124825 sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
@@ -128317,14 +127755,14 @@
127755 ** function generates code to do a deferred seek of cursor iCur to the
127756 ** rowid stored in register iRowid.
127757 **
127758 ** Normally, this is just:
127759 **
127760 ** OP_Seek $iCur $iRowid
127761 **
127762 ** However, if the scan currently being coded is a branch of an OR-loop and
127763 ** the statement currently being coded is a SELECT, then P3 of the OP_Seek
127764 ** is set to iIdxCur and P4 is set to point to an array of integers
127765 ** containing one entry for each column of the table cursor iCur is open
127766 ** on. For each table column, if the column is the i'th column of the
127767 ** index, then the corresponding array entry is set to (i+1). If the column
127768 ** does not appear in the index at all, the array entry is set to 0.
@@ -128339,11 +127777,11 @@
127777 Vdbe *v = pParse->pVdbe; /* Vdbe to generate code within */
127778
127779 assert( iIdxCur>0 );
127780 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
127781
127782 sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur);
127783 if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
127784 && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)
127785 ){
127786 int i;
127787 Table *pTab = pIdx->pTable;
@@ -128409,11 +127847,11 @@
127847 ** If pExpr matches, then transform it into a reference to the index column
127848 ** that contains the value of pExpr.
127849 */
127850 static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
127851 IdxExprTrans *pX = p->u.pIdxTrans;
127852 if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
127853 pExpr->op = TK_COLUMN;
127854 pExpr->iTable = pX->iIdxCur;
127855 pExpr->iColumn = pX->iIdxCol;
127856 pExpr->pTab = 0;
127857 return WRC_Prune;
@@ -129703,11 +129141,11 @@
129141 pList = pExpr->x.pList;
129142 pLeft = pList->a[1].pExpr;
129143
129144 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
129145 op = pRight->op;
129146 if( op==TK_VARIABLE ){
129147 Vdbe *pReprepare = pParse->pReprepare;
129148 int iCol = pRight->iColumn;
129149 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
129150 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
129151 z = (char *)sqlite3_value_text(pVal);
@@ -129893,12 +129331,12 @@
129331 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
129332 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
129333 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
129334 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
129335 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
129336 if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
129337 if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
129338 /* If we reach this point, it means the two subterms can be combined */
129339 if( (eOp & (eOp-1))!=0 ){
129340 if( eOp & (WO_LT|WO_LE) ){
129341 eOp = WO_LE;
129342 }else{
@@ -130665,13 +130103,10 @@
130103 prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);
130104 if( (prereqExpr & prereqColumn)==0 ){
130105 Expr *pNewExpr;
130106 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
130107 0, sqlite3ExprDup(db, pRight, 0));
 
 
 
130108 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
130109 testcase( idxNew==0 );
130110 pNewTerm = &pWC->a[idxNew];
130111 pNewTerm->prereqRight = prereqExpr;
130112 pNewTerm->leftCursor = pLeft->iTable;
@@ -132144,11 +131579,11 @@
131579 iGap = (iGap*2)/3;
131580 }else{
131581 iGap = iGap/3;
131582 }
131583 aStat[0] = iLower + iGap;
131584 aStat[1] = pIdx->aAvgEq[iCol];
131585 }
131586
131587 /* Restore the pRec->nField value before returning. */
131588 pRec->nField = nField;
131589 return i;
@@ -132897,21 +132332,20 @@
132332 }
132333 }
132334
132335 /*
132336 ** Search the list of WhereLoops in *ppPrev looking for one that can be
132337 ** supplanted by pTemplate.
132338 **
132339 ** Return NULL if the WhereLoop list contains an entry that can supplant
132340 ** pTemplate, in other words if pTemplate does not belong on the list.
132341 **
132342 ** If pX is a WhereLoop that pTemplate can supplant, then return the
132343 ** link that points to pX.
132344 **
132345 ** If pTemplate cannot supplant any existing element of the list but needs
132346 ** to be added to the list, then return a pointer to the tail of the list.
 
132347 */
132348 static WhereLoop **whereLoopFindLesser(
132349 WhereLoop **ppPrev,
132350 const WhereLoop *pTemplate
132351 ){
@@ -133052,14 +132486,12 @@
132486 #if WHERETRACE_ENABLED /* 0x8 */
132487 if( sqlite3WhereTrace & 0x8 ){
132488 if( p!=0 ){
132489 sqlite3DebugPrintf("replace: ");
132490 whereLoopPrint(p, pBuilder->pWC);
 
 
 
132491 }
132492 sqlite3DebugPrintf(" add: ");
132493 whereLoopPrint(pTemplate, pBuilder->pWC);
132494 }
132495 #endif
132496 if( p==0 ){
132497 /* Allocate a new WhereLoop to add to the end of the list */
@@ -133606,11 +133038,11 @@
133038 if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
133039 }
133040 }else if( (aColExpr = pIndex->aColExpr)!=0 ){
133041 for(jj=0; jj<pIndex->nKeyCol; jj++){
133042 if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;
133043 if( sqlite3ExprCompare(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){
133044 return 1;
133045 }
133046 }
133047 }
133048 }
@@ -133639,20 +133071,18 @@
133071 ** in the current query. Return true if it can be and false if not.
133072 */
133073 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
133074 int i;
133075 WhereTerm *pTerm;
 
133076 while( pWhere->op==TK_AND ){
133077 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
133078 pWhere = pWhere->pRight;
133079 }
 
133080 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
133081 Expr *pExpr = pTerm->pExpr;
133082 if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
133083 && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
133084 ){
133085 return 1;
133086 }
133087 }
133088 return 0;
@@ -134627,12 +134057,11 @@
134057 if( iColumn>=(-1) ){
134058 if( pOBExpr->op!=TK_COLUMN ) continue;
134059 if( pOBExpr->iTable!=iCur ) continue;
134060 if( pOBExpr->iColumn!=iColumn ) continue;
134061 }else{
134062 if( sqlite3ExprCompare(pOBExpr,pIndex->aColExpr->a[j].pExpr,iCur) ){
 
134063 continue;
134064 }
134065 }
134066 if( iColumn>=0 ){
134067 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
@@ -134927,11 +134356,10 @@
134356 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
134357 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
134358 rUnsorted, rCost));
134359 }else{
134360 rCost = rUnsorted;
 
134361 }
134362
134363 /* Check to see if pWLoop should be added to the set of
134364 ** mxChoice best-so-far paths.
134365 **
@@ -134959,12 +134387,12 @@
134387 /* The current candidate is no better than any of the mxChoice
134388 ** paths currently in the best-so-far buffer. So discard
134389 ** this candidate as not viable. */
134390 #ifdef WHERETRACE_ENABLED /* 0x4 */
134391 if( sqlite3WhereTrace&0x4 ){
134392 sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n",
134393 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134394 isOrdered>=0 ? isOrdered+'0' : '?');
134395 }
134396 #endif
134397 continue;
134398 }
@@ -134978,40 +134406,30 @@
134406 jj = mxI;
134407 }
134408 pTo = &aTo[jj];
134409 #ifdef WHERETRACE_ENABLED /* 0x4 */
134410 if( sqlite3WhereTrace&0x4 ){
134411 sqlite3DebugPrintf("New %s cost=%-3d,%3d order=%c\n",
134412 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134413 isOrdered>=0 ? isOrdered+'0' : '?');
134414 }
134415 #endif
134416 }else{
134417 /* Control reaches here if best-so-far path pTo=aTo[jj] covers the
134418 ** same set of loops and has the sam isOrdered setting as the
134419 ** candidate path. Check to see if the candidate should replace
134420 ** pTo or if the candidate should be skipped */
134421 if( pTo->rCost<rCost || (pTo->rCost==rCost && pTo->nRow<=nOut) ){
 
 
 
 
 
 
 
 
 
 
134422 #ifdef WHERETRACE_ENABLED /* 0x4 */
134423 if( sqlite3WhereTrace&0x4 ){
134424 sqlite3DebugPrintf(
134425 "Skip %s cost=%-3d,%3d order=%c",
134426 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134427 isOrdered>=0 ? isOrdered+'0' : '?');
134428 sqlite3DebugPrintf(" vs %s cost=%-3d,%d order=%c\n",
134429 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
134430 pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
134431 }
134432 #endif
134433 /* Discard the candidate path from further consideration */
134434 testcase( pTo->rCost==rCost );
134435 continue;
@@ -135020,16 +134438,16 @@
134438 /* Control reaches here if the candidate path is better than the
134439 ** pTo path. Replace pTo with the candidate. */
134440 #ifdef WHERETRACE_ENABLED /* 0x4 */
134441 if( sqlite3WhereTrace&0x4 ){
134442 sqlite3DebugPrintf(
134443 "Update %s cost=%-3d,%3d order=%c",
134444 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
134445 isOrdered>=0 ? isOrdered+'0' : '?');
134446 sqlite3DebugPrintf(" was %s cost=%-3d,%3d order=%c\n",
134447 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
134448 pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
134449 }
134450 #endif
134451 }
134452 /* pWLoop is a winner. Add it to the set of best so far */
134453 pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
@@ -135250,35 +134668,10 @@
134668 return 1;
134669 }
134670 return 0;
134671 }
134672
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134673 /*
134674 ** Generate the beginning of the loop used for WHERE clause processing.
134675 ** The return value is a pointer to an opaque structure that contains
134676 ** information needed to terminate the loop. Later, the calling routine
134677 ** should invoke sqlite3WhereEnd() with the return value of this function
@@ -135473,10 +134866,21 @@
134866 */
134867 initMaskSet(pMaskSet);
134868 sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
134869 sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
134870
134871 /* Special case: a WHERE clause that is constant. Evaluate the
134872 ** expression and either jump over all of the code or fall thru.
134873 */
134874 for(ii=0; ii<sWLB.pWC->nTerm; ii++){
134875 if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){
134876 sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak,
134877 SQLITE_JUMPIFNULL);
134878 sWLB.pWC->a[ii].wtFlags |= TERM_CODED;
134879 }
134880 }
134881
134882 /* Special case: No FROM clause
134883 */
134884 if( nTabList==0 ){
134885 if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
134886 if( wctrlFlags & WHERE_WANT_DISTINCT ){
@@ -135511,29 +134915,10 @@
134915
134916 /* Analyze all of the subexpressions. */
134917 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
134918 if( db->mallocFailed ) goto whereBeginError;
134919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134920 if( wctrlFlags & WHERE_WANT_DISTINCT ){
134921 if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
134922 /* The DISTINCT marking is pointless. Ignore it. */
134923 pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
134924 }else if( pOrderBy==0 ){
@@ -135566,11 +134951,11 @@
134951 WhereLoop *p;
134952 int i;
134953 static const char zLabel[] = "0123456789abcdefghijklmnopqrstuvwyxz"
134954 "ABCDEFGHIJKLMNOPQRSTUVWYXZ";
134955 for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){
134956 p->cId = zLabel[i%sizeof(zLabel)];
134957 whereLoopPrint(p, sWLB.pWC);
134958 }
134959 }
134960 #endif
134961
@@ -136349,19 +135734,19 @@
135734 #define sqlite3ParserARG_PDECL ,Parse *pParse
135735 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
135736 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
135737 #define YYFALLBACK 1
135738 #define YYNSTATE 456
135739 #define YYNRULE 332
135740 #define YY_MAX_SHIFT 455
135741 #define YY_MIN_SHIFTREDUCE 668
135742 #define YY_MAX_SHIFTREDUCE 999
135743 #define YY_MIN_REDUCE 1000
135744 #define YY_MAX_REDUCE 1331
135745 #define YY_ERROR_ACTION 1332
135746 #define YY_ACCEPT_ACTION 1333
135747 #define YY_NO_ACTION 1334
135748 /************* End control #defines *******************************************/
135749
135750 /* Define the yytestcase() macro to be a no-op if is not already defined
135751 ** otherwise.
135752 **
@@ -136431,167 +135816,167 @@
135816 ** yy_default[] Default action for each state.
135817 **
135818 *********** Begin parsing tables **********************************************/
135819 #define YY_ACTTAB_COUNT (1566)
135820 static const YYACTIONTYPE yy_action[] = {
135821 /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98,
135822 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
135823 /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813,
135824 /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96,
135825 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
135826 /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97,
135827 /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
135828 /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262,
135829 /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791,
135830 /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95,
135831 /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96,
135832 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813,
135833 /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90,
135834 /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
135835 /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
135836 /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75,
135837 /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262,
135838 /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371,
135839 /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824,
135840 /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380,
135841 /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845,
135842 /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
135843 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132,
135844 /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93,
135845 /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334,
135846 /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845,
135847 /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96,
135848 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
135849 /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888,
135850 /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959,
135851 /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978,
135852 /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702,
135853 /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99,
135854 /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
135855 /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94,
135856 /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231,
135857 /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25,
135858 /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74,
135859 /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813,
135860 /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415,
135861 /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856,
135862 /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96,
135863 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
135864 /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262,
135865 /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959,
135866 /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711,
135867 /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447,
135868 /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178,
135869 /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97,
135870 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
135871 /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916,
135872 /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157,
135873 /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415,
135874 /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777,
135875 /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52,
135876 /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90,
135877 /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98,
135878 /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
135879 /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450,
135880 /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420,
135881 /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36,
135882 /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425,
135883 /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326,
135884 /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845,
135885 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
135886 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846,
135887 /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350,
135888 /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327,
135889 /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978,
135890 /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776,
135891 /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99,
135892 /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
135893 /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94,
135894 /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978,
135895 /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675,
135896 /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99,
135897 /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98,
135898 /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
135899 /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450,
135900 /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228,
135901 /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31,
135902 /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44,
135903 /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268,
135904 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856,
135905 /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96,
135906 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
135907 /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48,
135908 /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245,
135909 /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817,
135910 /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124,
135911 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
135912 /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
135913 /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
135914 /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817,
135915 /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944,
135916 /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107,
135917 /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97,
135918 /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
135919 /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742,
135920 /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133,
135921 /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121,
135922 /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97,
135923 /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95,
135924 /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
135925 /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263,
135926 /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112,
135927 /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97,
135928 /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
135929 /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345,
135930 /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709,
135931 /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110,
135932 /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97,
135933 /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95,
135934 /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
135935 /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785,
135936 /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55,
135937 /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709,
135938 /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120,
135939 /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26,
135940 /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390,
135941 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
135942 /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730,
135943 /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819,
135944 /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3,
135945 /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824,
135946 /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951,
135947 /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7,
135948 /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713,
135949 /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205,
135950 /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144,
135951 /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366,
135952 /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140,
135953 /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683,
135954 /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383,
135955 /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824,
135956 /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271,
135957 /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85,
135958 /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711,
135959 /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724,
135960 /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290,
135961 /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827,
135962 /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434,
135963 /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
135964 /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217,
135965 /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669,
135966 /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
135967 /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889,
135968 /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63,
135969 /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13,
135970 /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19,
135971 /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722,
135972 /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830,
135973 /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220,
135974 /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18,
135975 /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163,
135976 /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695,
135977 /* 1560 */ 87, 312, 309, 947, 1291, 1290,
135978 };
135979 static const YYCODETYPE yy_lookahead[] = {
135980 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
135981 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
135982 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136840,56 +136225,56 @@
136225 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136226 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136227 /* 320 */ 1280, 1281, 1264, 1269, 1283,
136228 };
136229 static const YYACTIONTYPE yy_default[] = {
136230 /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
136231 /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
136232 /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
136233 /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
136234 /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
136235 /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
136236 /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136237 /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136238 /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136239 /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136240 /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
136241 /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
136242 /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
136243 /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136244 /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136245 /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
136246 /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
136247 /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136248 /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
136249 /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136250 /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
136251 /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
136252 /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
136253 /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
136254 /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
136255 /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
136256 /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
136257 /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
136258 /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
136259 /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
136260 /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
136261 /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
136262 /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
136263 /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
136264 /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136265 /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
136266 /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136267 /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
136268 /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
136269 /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136270 /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
136271 /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
136272 /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
136273 /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
136274 /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
136275 /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
136276 };
136277 /********** End of lemon-generated parsing tables *****************************/
136278
136279 /* The next table maps tokens (terminal symbols) into fallback tokens.
136280 ** If a construct like the following:
@@ -137019,11 +136404,10 @@
136404 int yystksz; /* Current side of the stack */
136405 yyStackEntry *yystack; /* The parser's stack */
136406 yyStackEntry yystk0; /* First stack entry */
136407 #else
136408 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
 
136409 #endif
136410 };
136411 typedef struct yyParser yyParser;
136412
136413 #ifndef NDEBUG
@@ -137358,113 +136742,114 @@
136742 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
136743 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
136744 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
136745 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
136746 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
136747 /* 228 */ "trigger_time ::= BEFORE",
136748 /* 229 */ "trigger_time ::= AFTER",
136749 /* 230 */ "trigger_time ::= INSTEAD OF",
136750 /* 231 */ "trigger_time ::=",
136751 /* 232 */ "trigger_event ::= DELETE|INSERT",
136752 /* 233 */ "trigger_event ::= UPDATE",
136753 /* 234 */ "trigger_event ::= UPDATE OF idlist",
136754 /* 235 */ "when_clause ::=",
136755 /* 236 */ "when_clause ::= WHEN expr",
136756 /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
136757 /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
136758 /* 239 */ "trnm ::= nm DOT nm",
136759 /* 240 */ "tridxby ::= INDEXED BY nm",
136760 /* 241 */ "tridxby ::= NOT INDEXED",
136761 /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
136762 /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
136763 /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
136764 /* 245 */ "trigger_cmd ::= select",
136765 /* 246 */ "expr ::= RAISE LP IGNORE RP",
136766 /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
136767 /* 248 */ "raisetype ::= ROLLBACK",
136768 /* 249 */ "raisetype ::= ABORT",
136769 /* 250 */ "raisetype ::= FAIL",
136770 /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
136771 /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
136772 /* 253 */ "cmd ::= DETACH database_kw_opt expr",
136773 /* 254 */ "key_opt ::=",
136774 /* 255 */ "key_opt ::= KEY expr",
136775 /* 256 */ "cmd ::= REINDEX",
136776 /* 257 */ "cmd ::= REINDEX nm dbnm",
136777 /* 258 */ "cmd ::= ANALYZE",
136778 /* 259 */ "cmd ::= ANALYZE nm dbnm",
136779 /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
136780 /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
136781 /* 262 */ "add_column_fullname ::= fullname",
136782 /* 263 */ "cmd ::= create_vtab",
136783 /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
136784 /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
136785 /* 266 */ "vtabarg ::=",
136786 /* 267 */ "vtabargtoken ::= ANY",
136787 /* 268 */ "vtabargtoken ::= lp anylist RP",
136788 /* 269 */ "lp ::= LP",
136789 /* 270 */ "with ::=",
136790 /* 271 */ "with ::= WITH wqlist",
136791 /* 272 */ "with ::= WITH RECURSIVE wqlist",
136792 /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
136793 /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
136794 /* 275 */ "input ::= cmdlist",
136795 /* 276 */ "cmdlist ::= cmdlist ecmd",
136796 /* 277 */ "cmdlist ::= ecmd",
136797 /* 278 */ "ecmd ::= SEMI",
136798 /* 279 */ "ecmd ::= explain cmdx SEMI",
136799 /* 280 */ "explain ::=",
136800 /* 281 */ "trans_opt ::=",
136801 /* 282 */ "trans_opt ::= TRANSACTION",
136802 /* 283 */ "trans_opt ::= TRANSACTION nm",
136803 /* 284 */ "savepoint_opt ::= SAVEPOINT",
136804 /* 285 */ "savepoint_opt ::=",
136805 /* 286 */ "cmd ::= create_table create_table_args",
136806 /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
136807 /* 288 */ "columnlist ::= columnname carglist",
136808 /* 289 */ "nm ::= ID|INDEXED",
136809 /* 290 */ "nm ::= STRING",
136810 /* 291 */ "nm ::= JOIN_KW",
136811 /* 292 */ "typetoken ::= typename",
136812 /* 293 */ "typename ::= ID|STRING",
136813 /* 294 */ "signed ::= plus_num",
136814 /* 295 */ "signed ::= minus_num",
136815 /* 296 */ "carglist ::= carglist ccons",
136816 /* 297 */ "carglist ::=",
136817 /* 298 */ "ccons ::= NULL onconf",
136818 /* 299 */ "conslist_opt ::= COMMA conslist",
136819 /* 300 */ "conslist ::= conslist tconscomma tcons",
136820 /* 301 */ "conslist ::= tcons",
136821 /* 302 */ "tconscomma ::=",
136822 /* 303 */ "defer_subclause_opt ::= defer_subclause",
136823 /* 304 */ "resolvetype ::= raisetype",
136824 /* 305 */ "selectnowith ::= oneselect",
136825 /* 306 */ "oneselect ::= values",
136826 /* 307 */ "sclp ::= selcollist COMMA",
136827 /* 308 */ "as ::= ID|STRING",
136828 /* 309 */ "expr ::= term",
136829 /* 310 */ "likeop ::= LIKE_KW|MATCH",
136830 /* 311 */ "exprlist ::= nexprlist",
136831 /* 312 */ "nmnum ::= plus_num",
136832 /* 313 */ "nmnum ::= nm",
136833 /* 314 */ "nmnum ::= ON",
136834 /* 315 */ "nmnum ::= DELETE",
136835 /* 316 */ "nmnum ::= DEFAULT",
136836 /* 317 */ "plus_num ::= INTEGER|FLOAT",
136837 /* 318 */ "foreach_clause ::=",
136838 /* 319 */ "foreach_clause ::= FOR EACH ROW",
136839 /* 320 */ "trnm ::= nm",
136840 /* 321 */ "tridxby ::=",
136841 /* 322 */ "database_kw_opt ::= DATABASE",
136842 /* 323 */ "database_kw_opt ::=",
136843 /* 324 */ "kwcolumn_opt ::=",
136844 /* 325 */ "kwcolumn_opt ::= COLUMNKW",
136845 /* 326 */ "vtabarglist ::= vtabarg",
136846 /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
136847 /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
136848 /* 329 */ "anylist ::=",
136849 /* 330 */ "anylist ::= anylist LP anylist RP",
136850 /* 331 */ "anylist ::= anylist ANY",
136851 };
136852 #endif /* NDEBUG */
136853
136854
136855 #if YYSTACKDEPTH<=0
@@ -137529,11 +136914,10 @@
136914 pParser->yyerrcnt = -1;
136915 #endif
136916 pParser->yytos = pParser->yystack;
136917 pParser->yystack[0].stateno = 0;
136918 pParser->yystack[0].major = 0;
 
136919 }
136920
136921 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
136922 /*
136923 ** This function allocates a new parser.
@@ -137872,11 +137256,11 @@
137256 yypParser->yyhwm++;
137257 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
137258 }
137259 #endif
137260 #if YYSTACKDEPTH>0
137261 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
137262 yypParser->yytos--;
137263 yyStackOverflow(yypParser);
137264 return;
137265 }
137266 #else
@@ -137900,344 +137284,345 @@
137284
137285 /* The following table contains information about every rule that
137286 ** is used during the reduce.
137287 */
137288 static const struct {
137289 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
137290 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
137291 } yyRuleInfo[] = {
137292 { 147, 1 },
137293 { 147, 3 },
137294 { 148, 1 },
137295 { 149, 3 },
137296 { 150, 0 },
137297 { 150, 1 },
137298 { 150, 1 },
137299 { 150, 1 },
137300 { 149, 2 },
137301 { 149, 2 },
137302 { 149, 2 },
137303 { 149, 2 },
137304 { 149, 3 },
137305 { 149, 5 },
137306 { 154, 6 },
137307 { 156, 1 },
137308 { 158, 0 },
137309 { 158, 3 },
137310 { 157, 1 },
137311 { 157, 0 },
137312 { 155, 5 },
137313 { 155, 2 },
137314 { 162, 0 },
137315 { 162, 2 },
137316 { 164, 2 },
137317 { 166, 0 },
137318 { 166, 4 },
137319 { 166, 6 },
137320 { 167, 2 },
137321 { 171, 2 },
137322 { 171, 2 },
137323 { 171, 4 },
137324 { 171, 3 },
137325 { 171, 3 },
137326 { 171, 2 },
137327 { 171, 3 },
137328 { 171, 5 },
137329 { 171, 2 },
137330 { 171, 4 },
137331 { 171, 4 },
137332 { 171, 1 },
137333 { 171, 2 },
137334 { 176, 0 },
137335 { 176, 1 },
137336 { 178, 0 },
137337 { 178, 2 },
137338 { 180, 2 },
137339 { 180, 3 },
137340 { 180, 3 },
137341 { 180, 3 },
137342 { 181, 2 },
137343 { 181, 2 },
137344 { 181, 1 },
137345 { 181, 1 },
137346 { 181, 2 },
137347 { 179, 3 },
137348 { 179, 2 },
137349 { 182, 0 },
137350 { 182, 2 },
137351 { 182, 2 },
137352 { 161, 0 },
137353 { 184, 1 },
137354 { 185, 2 },
137355 { 185, 7 },
137356 { 185, 5 },
137357 { 185, 5 },
137358 { 185, 10 },
137359 { 188, 0 },
137360 { 174, 0 },
137361 { 174, 3 },
137362 { 189, 0 },
137363 { 189, 2 },
137364 { 190, 1 },
137365 { 190, 1 },
137366 { 149, 4 },
137367 { 192, 2 },
137368 { 192, 0 },
137369 { 149, 9 },
137370 { 149, 4 },
137371 { 149, 1 },
137372 { 163, 2 },
137373 { 194, 3 },
137374 { 197, 1 },
137375 { 197, 2 },
137376 { 197, 1 },
137377 { 195, 9 },
137378 { 206, 4 },
137379 { 206, 5 },
137380 { 198, 1 },
137381 { 198, 1 },
137382 { 198, 0 },
137383 { 209, 0 },
137384 { 199, 3 },
137385 { 199, 2 },
137386 { 199, 4 },
137387 { 210, 2 },
137388 { 210, 0 },
137389 { 200, 0 },
137390 { 200, 2 },
137391 { 212, 2 },
137392 { 212, 0 },
137393 { 211, 7 },
137394 { 211, 9 },
137395 { 211, 7 },
137396 { 211, 7 },
137397 { 159, 0 },
137398 { 159, 2 },
137399 { 193, 2 },
137400 { 213, 1 },
137401 { 213, 2 },
137402 { 213, 3 },
137403 { 213, 4 },
137404 { 215, 2 },
137405 { 215, 0 },
137406 { 214, 0 },
137407 { 214, 3 },
137408 { 214, 2 },
137409 { 216, 4 },
137410 { 216, 0 },
137411 { 204, 0 },
137412 { 204, 3 },
137413 { 186, 4 },
137414 { 186, 2 },
137415 { 175, 1 },
137416 { 175, 1 },
137417 { 175, 0 },
137418 { 202, 0 },
137419 { 202, 3 },
137420 { 203, 0 },
137421 { 203, 2 },
137422 { 205, 0 },
137423 { 205, 2 },
137424 { 205, 4 },
137425 { 205, 4 },
137426 { 149, 6 },
137427 { 201, 0 },
137428 { 201, 2 },
137429 { 149, 8 },
137430 { 218, 5 },
137431 { 218, 7 },
137432 { 218, 3 },
137433 { 218, 5 },
137434 { 149, 6 },
137435 { 149, 7 },
137436 { 219, 2 },
137437 { 219, 1 },
137438 { 220, 0 },
137439 { 220, 3 },
137440 { 217, 3 },
137441 { 217, 1 },
137442 { 173, 3 },
137443 { 172, 1 },
137444 { 173, 1 },
137445 { 173, 1 },
137446 { 173, 3 },
137447 { 173, 5 },
137448 { 172, 1 },
137449 { 172, 1 },
137450 { 172, 1 },
137451 { 173, 1 },
137452 { 173, 3 },
137453 { 173, 6 },
137454 { 173, 5 },
137455 { 173, 4 },
137456 { 172, 1 },
137457 { 173, 5 },
137458 { 173, 3 },
137459 { 173, 3 },
137460 { 173, 3 },
137461 { 173, 3 },
137462 { 173, 3 },
137463 { 173, 3 },
137464 { 173, 3 },
137465 { 173, 3 },
137466 { 221, 2 },
137467 { 173, 3 },
137468 { 173, 5 },
137469 { 173, 2 },
137470 { 173, 3 },
137471 { 173, 3 },
137472 { 173, 4 },
137473 { 173, 2 },
137474 { 173, 2 },
137475 { 173, 2 },
137476 { 173, 2 },
137477 { 222, 1 },
137478 { 222, 2 },
137479 { 173, 5 },
137480 { 223, 1 },
137481 { 223, 2 },
137482 { 173, 5 },
137483 { 173, 3 },
137484 { 173, 5 },
137485 { 173, 5 },
137486 { 173, 4 },
137487 { 173, 5 },
137488 { 226, 5 },
137489 { 226, 4 },
137490 { 227, 2 },
137491 { 227, 0 },
137492 { 225, 1 },
137493 { 225, 0 },
137494 { 208, 0 },
137495 { 207, 3 },
137496 { 207, 1 },
137497 { 224, 0 },
137498 { 224, 3 },
137499 { 149, 12 },
137500 { 228, 1 },
137501 { 228, 0 },
137502 { 177, 0 },
137503 { 177, 3 },
137504 { 187, 5 },
137505 { 187, 3 },
137506 { 229, 0 },
137507 { 229, 2 },
137508 { 149, 4 },
137509 { 149, 1 },
137510 { 149, 2 },
137511 { 149, 3 },
137512 { 149, 5 },
137513 { 149, 6 },
137514 { 149, 5 },
137515 { 149, 6 },
137516 { 169, 2 },
137517 { 170, 2 },
137518 { 149, 5 },
137519 { 231, 11 },
137520 { 233, 1 },
137521 { 233, 1 },
137522 { 233, 2 },
137523 { 233, 0 },
137524 { 234, 1 },
137525 { 234, 1 },
137526 { 234, 3 },
137527 { 236, 0 },
137528 { 236, 2 },
137529 { 232, 3 },
137530 { 232, 2 },
137531 { 238, 3 },
137532 { 239, 3 },
137533 { 239, 2 },
137534 { 237, 7 },
137535 { 237, 5 },
137536 { 237, 5 },
137537 { 237, 1 },
137538 { 173, 4 },
137539 { 173, 6 },
137540 { 191, 1 },
137541 { 191, 1 },
137542 { 191, 1 },
137543 { 149, 4 },
137544 { 149, 6 },
137545 { 149, 3 },
137546 { 241, 0 },
137547 { 241, 2 },
137548 { 149, 1 },
137549 { 149, 3 },
137550 { 149, 1 },
137551 { 149, 3 },
137552 { 149, 6 },
137553 { 149, 7 },
137554 { 242, 1 },
137555 { 149, 1 },
137556 { 149, 4 },
137557 { 244, 8 },
137558 { 246, 0 },
137559 { 247, 1 },
137560 { 247, 3 },
137561 { 248, 1 },
137562 { 196, 0 },
137563 { 196, 2 },
137564 { 196, 3 },
137565 { 250, 6 },
137566 { 250, 8 },
137567 { 144, 1 },
137568 { 145, 2 },
137569 { 145, 1 },
137570 { 146, 1 },
137571 { 146, 3 },
137572 { 147, 0 },
137573 { 151, 0 },
137574 { 151, 1 },
137575 { 151, 2 },
137576 { 153, 1 },
137577 { 153, 0 },
137578 { 149, 2 },
137579 { 160, 4 },
137580 { 160, 2 },
137581 { 152, 1 },
137582 { 152, 1 },
137583 { 152, 1 },
137584 { 166, 1 },
137585 { 167, 1 },
137586 { 168, 1 },
137587 { 168, 1 },
137588 { 165, 2 },
137589 { 165, 0 },
137590 { 171, 2 },
137591 { 161, 2 },
137592 { 183, 3 },
137593 { 183, 1 },
137594 { 184, 0 },
137595 { 188, 1 },
137596 { 190, 1 },
137597 { 194, 1 },
137598 { 195, 1 },
137599 { 209, 2 },
137600 { 210, 1 },
137601 { 173, 1 },
137602 { 221, 1 },
137603 { 208, 1 },
137604 { 230, 1 },
137605 { 230, 1 },
137606 { 230, 1 },
137607 { 230, 1 },
137608 { 230, 1 },
137609 { 169, 1 },
137610 { 235, 0 },
137611 { 235, 3 },
137612 { 238, 1 },
137613 { 239, 0 },
137614 { 240, 1 },
137615 { 240, 0 },
137616 { 243, 0 },
137617 { 243, 1 },
137618 { 245, 1 },
137619 { 245, 3 },
137620 { 246, 2 },
137621 { 249, 0 },
137622 { 249, 4 },
137623 { 249, 2 },
137624 };
137625
137626 static void yy_accept(yyParser*); /* Forward Declaration */
137627
137628 /*
@@ -138256,11 +137641,11 @@
137641 yymsp = yypParser->yytos;
137642 #ifndef NDEBUG
137643 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
137644 yysize = yyRuleInfo[yyruleno].nrhs;
137645 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
137646 yyRuleName[yyruleno], yymsp[-yysize].stateno);
137647 }
137648 #endif /* NDEBUG */
137649
137650 /* Check that the stack is large enough to grow by a single entry
137651 ** if the RHS of the rule is empty. This ensures that there is room
@@ -138271,11 +137656,11 @@
137656 yypParser->yyhwm++;
137657 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
137658 }
137659 #endif
137660 #if YYSTACKDEPTH>0
137661 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
137662 yyStackOverflow(yypParser);
137663 return;
137664 }
137665 #else
137666 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
@@ -139230,11 +138615,11 @@
138615 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
138616 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
138617 }
138618 break;
138619 case 208: /* uniqueflag ::= UNIQUE */
138620 case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
138621 {yymsp[0].minor.yy194 = OE_Abort;}
138622 break;
138623 case 209: /* uniqueflag ::= */
138624 {yymsp[1].minor.yy194 = OE_None;}
138625 break;
@@ -139284,269 +138669,268 @@
138669 {
138670 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);
138671 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
138672 }
138673 break;
138674 case 228: /* trigger_time ::= BEFORE */
138675 { yymsp[0].minor.yy194 = TK_BEFORE; }
138676 break;
138677 case 229: /* trigger_time ::= AFTER */
138678 { yymsp[0].minor.yy194 = TK_AFTER; }
138679 break;
138680 case 230: /* trigger_time ::= INSTEAD OF */
138681 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
138682 break;
138683 case 231: /* trigger_time ::= */
138684 { yymsp[1].minor.yy194 = TK_BEFORE; }
138685 break;
138686 case 232: /* trigger_event ::= DELETE|INSERT */
138687 case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
138688 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
138689 break;
138690 case 234: /* trigger_event ::= UPDATE OF idlist */
138691 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
138692 break;
138693 case 235: /* when_clause ::= */
138694 case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
138695 { yymsp[1].minor.yy72 = 0; }
138696 break;
138697 case 236: /* when_clause ::= WHEN expr */
138698 case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
138699 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
138700 break;
138701 case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
138702 {
138703 assert( yymsp[-2].minor.yy145!=0 );
138704 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
138705 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
138706 }
138707 break;
138708 case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
138709 {
138710 assert( yymsp[-1].minor.yy145!=0 );
138711 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
138712 }
138713 break;
138714 case 239: /* trnm ::= nm DOT nm */
138715 {
138716 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
138717 sqlite3ErrorMsg(pParse,
138718 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
138719 "statements within triggers");
138720 }
138721 break;
138722 case 240: /* tridxby ::= INDEXED BY nm */
138723 {
138724 sqlite3ErrorMsg(pParse,
138725 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
138726 "within triggers");
138727 }
138728 break;
138729 case 241: /* tridxby ::= NOT INDEXED */
138730 {
138731 sqlite3ErrorMsg(pParse,
138732 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
138733 "within triggers");
138734 }
138735 break;
138736 case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
138737 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
138738 break;
138739 case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
138740 {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*/}
138741 break;
138742 case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
138743 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
138744 break;
138745 case 245: /* trigger_cmd ::= select */
138746 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
138747 break;
138748 case 246: /* expr ::= RAISE LP IGNORE RP */
138749 {
138750 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138751 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
138752 if( yymsp[-3].minor.yy190.pExpr ){
138753 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
138754 }
138755 }
138756 break;
138757 case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
138758 {
138759 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138760 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
138761 if( yymsp[-5].minor.yy190.pExpr ) {
138762 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
138763 }
138764 }
138765 break;
138766 case 248: /* raisetype ::= ROLLBACK */
138767 {yymsp[0].minor.yy194 = OE_Rollback;}
138768 break;
138769 case 250: /* raisetype ::= FAIL */
138770 {yymsp[0].minor.yy194 = OE_Fail;}
138771 break;
138772 case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
138773 {
138774 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
138775 }
138776 break;
138777 case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
138778 {
138779 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
138780 }
138781 break;
138782 case 253: /* cmd ::= DETACH database_kw_opt expr */
138783 {
138784 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
138785 }
138786 break;
138787 case 256: /* cmd ::= REINDEX */
138788 {sqlite3Reindex(pParse, 0, 0);}
138789 break;
138790 case 257: /* cmd ::= REINDEX nm dbnm */
138791 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
138792 break;
138793 case 258: /* cmd ::= ANALYZE */
138794 {sqlite3Analyze(pParse, 0, 0);}
138795 break;
138796 case 259: /* cmd ::= ANALYZE nm dbnm */
138797 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
138798 break;
138799 case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
138800 {
138801 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
138802 }
138803 break;
138804 case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
138805 {
138806 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
138807 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
138808 }
138809 break;
138810 case 262: /* add_column_fullname ::= fullname */
138811 {
138812 disableLookaside(pParse);
138813 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
138814 }
138815 break;
138816 case 263: /* cmd ::= create_vtab */
138817 {sqlite3VtabFinishParse(pParse,0);}
138818 break;
138819 case 264: /* cmd ::= create_vtab LP vtabarglist RP */
138820 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
138821 break;
138822 case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
138823 {
138824 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
138825 }
138826 break;
138827 case 266: /* vtabarg ::= */
138828 {sqlite3VtabArgInit(pParse);}
138829 break;
138830 case 267: /* vtabargtoken ::= ANY */
138831 case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
138832 case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
138833 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
138834 break;
138835 case 270: /* with ::= */
138836 {yymsp[1].minor.yy285 = 0;}
138837 break;
138838 case 271: /* with ::= WITH wqlist */
138839 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
138840 break;
138841 case 272: /* with ::= WITH RECURSIVE wqlist */
138842 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
138843 break;
138844 case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
138845 {
138846 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
138847 }
138848 break;
138849 case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
138850 {
138851 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
138852 }
138853 break;
138854 default:
138855 /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
138856 /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
138857 /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
138858 /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
138859 /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
138860 /* (280) explain ::= */ yytestcase(yyruleno==280);
138861 /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
138862 /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
138863 /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
138864 /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
138865 /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
138866 /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
138867 /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
138868 /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
138869 /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
138870 /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
138871 /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
138872 /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
138873 /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
138874 /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
138875 /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
138876 /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
138877 /* (297) carglist ::= */ yytestcase(yyruleno==297);
138878 /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
138879 /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
138880 /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
138881 /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
138882 /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
138883 /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
138884 /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
138885 /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
138886 /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
138887 /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
138888 /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
138889 /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
138890 /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
138891 /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
138892 /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
138893 /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
138894 /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
138895 /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
138896 /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
138897 /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
138898 /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
138899 /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
138900 /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
138901 /* (321) tridxby ::= */ yytestcase(yyruleno==321);
138902 /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
138903 /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
138904 /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
138905 /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
138906 /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
138907 /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
138908 /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
138909 /* (329) anylist ::= */ yytestcase(yyruleno==329);
138910 /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
138911 /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
138912 break;
138913 /********** End reduce actions ************************************************/
138914 };
138915 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
138916 yygoto = yyRuleInfo[yyruleno].lhs;
138917 yysize = yyRuleInfo[yyruleno].nrhs;
138918 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
138919 if( yyact <= YY_MAX_SHIFTREDUCE ){
138920 if( yyact>YY_MAX_SHIFT ){
138921 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
138922 }
138923 yymsp -= yysize-1;
 
 
 
 
 
 
 
 
138924 yypParser->yytos = yymsp;
138925 yymsp->stateno = (YYACTIONTYPE)yyact;
138926 yymsp->major = (YYCODETYPE)yygoto;
138927 yyTraceShift(yypParser, yyact);
138928 }else{
138929 assert( yyact == YY_ACCEPT_ACTION );
138930 yypParser->yytos -= yysize;
138931 yy_accept(yypParser);
138932 }
138933 }
138934
138935 /*
138936 ** The following code executes when the parse fails
@@ -141110,13 +140494,10 @@
140494 /************** Continuing where we left off in main.c ***********************/
140495 #endif
140496 #ifdef SQLITE_ENABLE_JSON1
140497 SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
140498 #endif
 
 
 
140499 #ifdef SQLITE_ENABLE_FTS5
140500 SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
140501 #endif
140502
140503 #ifndef SQLITE_AMALGAMATION
@@ -141896,11 +141277,10 @@
141277 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
141278 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
141279 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
141280 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
141281 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
 
141282 };
141283 unsigned int i;
141284 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
141285 for(i=0; i<ArraySize(aFlagOp); i++){
141286 if( aFlagOp[i].op==op ){
@@ -141953,11 +141333,10 @@
141333 int rc, n;
141334 n = nKey1<nKey2 ? nKey1 : nKey2;
141335 /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares
141336 ** strings byte by byte using the memcmp() function from the standard C
141337 ** library. */
 
141338 rc = memcmp(pKey1, pKey2, n);
141339 if( rc==0 ){
141340 if( padFlag
141341 && allSpaces(((char*)pKey1)+n, nKey1-n)
141342 && allSpaces(((char*)pKey2)+n, nKey2-n)
@@ -144002,13 +143381,10 @@
143381 | SQLITE_CellSizeCk
143382 #endif
143383 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
143384 | SQLITE_Fts3Tokenizer
143385 #endif
 
 
 
143386 ;
143387 sqlite3HashInit(&db->aCollSeq);
143388 #ifndef SQLITE_OMIT_VIRTUALTABLE
143389 sqlite3HashInit(&db->aModule);
143390 #endif
@@ -144141,16 +143517,10 @@
143517
143518 #ifdef SQLITE_ENABLE_JSON1
143519 if( !db->mallocFailed && rc==SQLITE_OK){
143520 rc = sqlite3Json1Init(db);
143521 }
 
 
 
 
 
 
143522 #endif
143523
143524 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
143525 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
143526 ** mode. Doing nothing at all also makes NORMAL the default.
@@ -144433,16 +143803,10 @@
143803 SQLITE_PRIVATE int sqlite3CantopenError(int lineno){
143804 testcase( sqlite3GlobalConfig.xLog!=0 );
143805 return reportError(SQLITE_CANTOPEN, lineno, "cannot open file");
143806 }
143807 #ifdef SQLITE_DEBUG
 
 
 
 
 
 
143808 SQLITE_PRIVATE int sqlite3NomemError(int lineno){
143809 testcase( sqlite3GlobalConfig.xLog!=0 );
143810 return reportError(SQLITE_NOMEM, lineno, "OOM");
143811 }
143812 SQLITE_PRIVATE int sqlite3IoerrnomemError(int lineno){
@@ -145198,62 +144562,10 @@
144562 SQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
144563 sqlite3_free(pSnapshot);
144564 }
144565 #endif /* SQLITE_ENABLE_SNAPSHOT */
144566
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144567 /************** End of main.c ************************************************/
144568 /************** Begin file notify.c ******************************************/
144569 /*
144570 ** 2009 March 3
144571 **
@@ -148237,11 +147549,11 @@
147549 pCsr->pStmt = p->pSeekStmt;
147550 p->pSeekStmt = 0;
147551 }else{
147552 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
147553 if( !zSql ) return SQLITE_NOMEM;
147554 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
147555 sqlite3_free(zSql);
147556 }
147557 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
147558 }
147559 return rc;
@@ -149774,11 +149086,11 @@
149086 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
149087 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
149088 );
149089 }
149090 if( zSql ){
149091 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
149092 sqlite3_free(zSql);
149093 }else{
149094 rc = SQLITE_NOMEM;
149095 }
149096 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -156981,12 +156293,11 @@
156293 zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
156294 }
156295 if( !zSql ){
156296 rc = SQLITE_NOMEM;
156297 }else{
156298 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);
 
156299 sqlite3_free(zSql);
156300 assert( rc==SQLITE_OK || pStmt==0 );
156301 p->aStmt[eStmt] = pStmt;
156302 }
156303 }
@@ -168092,12 +167403,11 @@
167403
167404 rc = rtreeQueryStat1(db, pRtree);
167405 for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){
167406 char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);
167407 if( zSql ){
167408 rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0);
 
167409 }else{
167410 rc = SQLITE_NOMEM;
167411 }
167412 sqlite3_free(zSql);
167413 }
@@ -169855,14 +169165,14 @@
169165 ** as fully applied. Otherwise, assuming no error has occurred, save the
169166 ** current state of the RBU update appliation to the RBU database.
169167 **
169168 ** If an error has already occurred as part of an sqlite3rbu_step()
169169 ** or sqlite3rbu_open() call, or if one occurs within this function, an
169170 ** SQLite error code is returned. Additionally, *pzErrmsg may be set to
169171 ** point to a buffer containing a utf-8 formatted English language error
169172 ** message. It is the responsibility of the caller to eventually free any
169173 ** such buffer using sqlite3_free().
169174 **
169175 ** Otherwise, if no error occurs, this function returns SQLITE_OK if the
169176 ** update has been partially applied, or SQLITE_DONE if it has been
169177 ** completely applied.
169178 */
@@ -173714,15 +173024,11 @@
173024 sqlite3_free(p->aBuf);
173025 sqlite3_free(p->aFrame);
173026
173027 rbuEditErrmsg(p);
173028 rc = p->rc;
173029 *pzErrmsg = p->zErrmsg;
 
 
 
 
173030 sqlite3_free(p->zState);
173031 sqlite3_free(p);
173032 }else{
173033 rc = SQLITE_NOMEM;
173034 *pzErrmsg = 0;
@@ -178276,16 +177582,15 @@
177582
177583 sessionDiscardData(&p->in);
177584 p->in.iCurrent = p->in.iNext;
177585
177586 op = p->in.aData[p->in.iNext++];
177587 if( op=='T' || op=='P' ){
177588 p->bPatchset = (op=='P');
177589 if( sessionChangesetReadTblhdr(p) ) return p->rc;
177590 if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
177591 p->in.iCurrent = p->in.iNext;
 
177592 op = p->in.aData[p->in.iNext++];
177593 }
177594
177595 p->op = op;
177596 p->bIndirect = p->in.aData[p->in.iNext++];
@@ -184139,16 +183444,16 @@
183444 ** fts5yy_default[] Default action for each state.
183445 **
183446 *********** Begin parsing tables **********************************************/
183447 #define fts5YY_ACTTAB_COUNT (98)
183448 static const fts5YYACTIONTYPE fts5yy_action[] = {
183449 /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17,
183450 /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6,
183451 /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26,
183452 /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65,
183453 /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24,
183454 /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65,
183455 /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77,
183456 /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12,
183457 /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32,
183458 /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14,
183459 };
@@ -184249,11 +183554,10 @@
183554 int fts5yystksz; /* Current side of the stack */
183555 fts5yyStackEntry *fts5yystack; /* The parser's stack */
183556 fts5yyStackEntry fts5yystk0; /* First stack entry */
183557 #else
183558 fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */
 
183559 #endif
183560 };
183561 typedef struct fts5yyParser fts5yyParser;
183562
183563 #ifndef NDEBUG
@@ -184399,11 +183703,10 @@
183703 pParser->fts5yyerrcnt = -1;
183704 #endif
183705 pParser->fts5yytos = pParser->fts5yystack;
183706 pParser->fts5yystack[0].stateno = 0;
183707 pParser->fts5yystack[0].major = 0;
 
183708 }
183709
183710 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
183711 /*
183712 ** This function allocates a new parser.
@@ -184698,11 +184001,11 @@
184001 fts5yypParser->fts5yyhwm++;
184002 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
184003 }
184004 #endif
184005 #if fts5YYSTACKDEPTH>0
184006 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){
184007 fts5yypParser->fts5yytos--;
184008 fts5yyStackOverflow(fts5yypParser);
184009 return;
184010 }
184011 #else
@@ -184726,39 +184029,39 @@
184029
184030 /* The following table contains information about every rule that
184031 ** is used during the reduce.
184032 */
184033 static const struct {
184034 fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
184035 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
184036 } fts5yyRuleInfo[] = {
184037 { 16, 1 },
184038 { 20, 4 },
184039 { 20, 3 },
184040 { 20, 1 },
184041 { 20, 2 },
184042 { 21, 2 },
184043 { 21, 1 },
184044 { 17, 3 },
184045 { 17, 3 },
184046 { 17, 3 },
184047 { 17, 5 },
184048 { 17, 3 },
184049 { 17, 1 },
184050 { 19, 1 },
184051 { 19, 2 },
184052 { 18, 1 },
184053 { 18, 3 },
184054 { 22, 1 },
184055 { 22, 5 },
184056 { 23, 1 },
184057 { 23, 2 },
184058 { 25, 0 },
184059 { 25, 2 },
184060 { 24, 4 },
184061 { 24, 2 },
184062 { 26, 1 },
184063 { 26, 0 },
184064 };
184065
184066 static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
184067
@@ -184778,11 +184081,11 @@
184081 fts5yymsp = fts5yypParser->fts5yytos;
184082 #ifndef NDEBUG
184083 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
184084 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184085 fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt,
184086 fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno);
184087 }
184088 #endif /* NDEBUG */
184089
184090 /* Check that the stack is large enough to grow by a single entry
184091 ** if the RHS of the rule is empty. This ensures that there is room
@@ -184793,11 +184096,11 @@
184096 fts5yypParser->fts5yyhwm++;
184097 assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
184098 }
184099 #endif
184100 #if fts5YYSTACKDEPTH>0
184101 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){
184102 fts5yyStackOverflow(fts5yypParser);
184103 return;
184104 }
184105 #else
184106 if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
@@ -184960,28 +184263,24 @@
184263 /********** End reduce actions ************************************************/
184264 };
184265 assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
184266 fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
184267 fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
184268 fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
184269 if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
184270 if( fts5yyact>fts5YY_MAX_SHIFT ){
184271 fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
184272 }
184273 fts5yymsp -= fts5yysize-1;
 
 
 
 
 
 
 
 
184274 fts5yypParser->fts5yytos = fts5yymsp;
184275 fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;
184276 fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;
184277 fts5yyTraceShift(fts5yypParser, fts5yyact);
184278 }else{
184279 assert( fts5yyact == fts5YY_ACCEPT_ACTION );
184280 fts5yypParser->fts5yytos -= fts5yysize;
184281 fts5yy_accept(fts5yypParser);
184282 }
184283 }
184284
184285 /*
184286 ** The following code executes when the parse fails
@@ -190274,15 +189573,14 @@
189573 if( !apNew ) return SQLITE_NOMEM;
189574 memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
189575
189576 for(i=0; i<pHash->nSlot; i++){
189577 while( apOld[i] ){
189578 int iHash;
189579 Fts5HashEntry *p = apOld[i];
189580 apOld[i] = p->pHashNext;
189581 iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), strlen(fts5EntryKey(p)));
 
189582 p->pHashNext = apNew[iHash];
189583 apNew[iHash] = p;
189584 }
189585 }
189586
@@ -190581,11 +189879,11 @@
189879 const char *pTerm, int nTerm, /* Query term */
189880 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
189881 int *pnDoclist /* OUT: Size of doclist in bytes */
189882 ){
189883 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
189884 char *zKey;
189885 Fts5HashEntry *p;
189886
189887 for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
189888 zKey = fts5EntryKey(p);
189889 if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
@@ -191369,12 +190667,11 @@
190667 sqlite3_stmt **ppStmt,
190668 char *zSql
190669 ){
190670 if( p->rc==SQLITE_OK ){
190671 if( zSql ){
190672 p->rc = sqlite3_prepare_v2(p->pConfig->db, zSql, -1, ppStmt, 0);
 
190673 }else{
190674 p->rc = SQLITE_NOMEM;
190675 }
190676 }
190677 sqlite3_free(zSql);
@@ -191419,12 +190716,11 @@
190716 pConfig->zDb, pConfig->zName
190717 );
190718 if( zSql==0 ){
190719 rc = SQLITE_NOMEM;
190720 }else{
190721 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p->pDeleter, 0);
 
190722 sqlite3_free(zSql);
190723 }
190724 if( rc!=SQLITE_OK ){
190725 p->rc = rc;
190726 return;
@@ -198019,12 +197315,11 @@
197315 va_start(ap, zFmt);
197316 zSql = sqlite3_vmprintf(zFmt, ap);
197317 if( zSql==0 ){
197318 rc = SQLITE_NOMEM;
197319 }else{
197320 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pRet, 0);
 
197321 if( rc!=SQLITE_OK ){
197322 *pConfig->pzErrmsg = sqlite3_mprintf("%s", sqlite3_errmsg(pConfig->db));
197323 }
197324 sqlite3_free(zSql);
197325 }
@@ -198156,12 +197451,11 @@
197451
197452 if( zRankArgs ){
197453 char *zSql = sqlite3Fts5Mprintf(&rc, "SELECT %s", zRankArgs);
197454 if( zSql ){
197455 sqlite3_stmt *pStmt = 0;
197456 rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pStmt, 0);
 
197457 sqlite3_free(zSql);
197458 assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
197459 if( rc==SQLITE_OK ){
197460 if( SQLITE_ROW==sqlite3_step(pStmt) ){
197461 int nByte;
@@ -199766,11 +199060,11 @@
199060 int nArg, /* Number of args */
199061 sqlite3_value **apUnused /* Function arguments */
199062 ){
199063 assert( nArg==0 );
199064 UNUSED_PARAM2(nArg, apUnused);
199065 sqlite3_result_text(pCtx, "fts5: 2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b", -1, SQLITE_TRANSIENT);
199066 }
199067
199068 static int fts5Init(sqlite3 *db){
199069 static const sqlite3_module fts5Mod = {
199070 /* iVersion */ 2,
@@ -200020,12 +199314,11 @@
199314 }
199315
199316 if( zSql==0 ){
199317 rc = SQLITE_NOMEM;
199318 }else{
199319 rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0);
 
199320 sqlite3_free(zSql);
199321 if( rc!=SQLITE_OK && pzErrMsg ){
199322 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
199323 }
199324 }
@@ -203621,325 +202914,5 @@
202914
202915
202916 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
202917
202918 /************** End of fts5.c ************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202919
+43 -140
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
11
/*
2
-** 2001-09-15
2
+** 2001 September 15
33
**
44
** The author disclaims copyright to this source code. In place of
55
** a legal notice, here is a blessing:
66
**
77
** May you do good and not evil.
@@ -119,13 +119,13 @@
119119
**
120120
** See also: [sqlite3_libversion()],
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124
-#define SQLITE_VERSION "3.20.0"
125
-#define SQLITE_VERSION_NUMBER 3020000
126
-#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
124
+#define SQLITE_VERSION "3.19.3"
125
+#define SQLITE_VERSION_NUMBER 3019003
126
+#define SQLITE_SOURCE_ID "2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -233,11 +233,11 @@
233233
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234234
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235235
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236236
** and [sqlite3_close_v2()] are its destructors. There are many other
237237
** interfaces (such as
238
-** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
238
+** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
239239
** [sqlite3_busy_timeout()] to name but three) that are methods on an
240240
** sqlite3 object.
241241
*/
242242
typedef struct sqlite3 sqlite3;
243243
@@ -337,11 +337,11 @@
337337
/*
338338
** CAPI3REF: One-Step Query Execution Interface
339339
** METHOD: sqlite3
340340
**
341341
** The sqlite3_exec() interface is a convenience wrapper around
342
-** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
342
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
343343
** that allows an application to run multiple statements of SQL
344344
** without having to use a lot of C code.
345345
**
346346
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347347
** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,31 +2005,19 @@
20052005
** default) to enable them. The second parameter is a pointer to an integer
20062006
** into which is written 0 or 1 to indicate whether checkpoints-on-close
20072007
** have been disabled - 0 if they are not disabled, 1 if they are.
20082008
** </dd>
20092009
**
2010
-** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011
-** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012
-** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013
-** a single SQL query statement will always use the same algorithm regardless
2014
-** of values of [bound parameters]. The QPSG disables some query optimizations
2015
-** that look at the values of bound parameters, which can make some queries
2016
-** slower. But the QPSG has the advantage of more predictable behavior. With
2017
-** the QPSG active, SQLite will always use the same query plan in the field as
2018
-** was used during testing in the lab.
2019
-** </dd>
2020
-**
20212010
** </dl>
20222011
*/
20232012
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
20242013
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
20252014
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
20262015
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
20272016
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
20282017
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
20292018
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2030
-#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
20312019
20322020
20332021
/*
20342022
** CAPI3REF: Enable Or Disable Extended Result Codes
20352023
** METHOD: sqlite3
@@ -2689,26 +2677,25 @@
26892677
**
26902678
** ^This routine registers an authorizer callback with a particular
26912679
** [database connection], supplied in the first argument.
26922680
** ^The authorizer callback is invoked as SQL statements are being compiled
26932681
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2694
-** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
2695
-** and [sqlite3_prepare16_v3()]. ^At various
2682
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
26962683
** points during the compilation process, as logic is being created
26972684
** to perform various actions, the authorizer callback is invoked to
26982685
** see if those actions are allowed. ^The authorizer callback should
26992686
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
27002687
** specific action but allow the SQL statement to continue to be
27012688
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
27022689
** rejected with an error. ^If the authorizer callback returns
27032690
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704
-** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2691
+** then the [sqlite3_prepare_v2()] or equivalent call that triggered
27052692
** the authorizer will fail with an error message.
27062693
**
27072694
** When the callback returns [SQLITE_OK], that means the operation
27082695
** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709
-** [sqlite3_prepare_v3()] or equivalent call that triggered the
2696
+** [sqlite3_prepare_v2()] or equivalent call that triggered the
27102697
** authorizer will fail with an error message explaining that
27112698
** access is denied.
27122699
**
27132700
** ^The first parameter to the authorizer callback is a copy of the third
27142701
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2742,23 @@
27552742
** previous call.)^ ^Disable the authorizer by installing a NULL callback.
27562743
** The authorizer is disabled by default.
27572744
**
27582745
** The authorizer callback must not do anything that will modify
27592746
** the database connection that invoked the authorizer callback.
2760
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2747
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
27612748
** database connections for the meaning of "modify" in this paragraph.
27622749
**
2763
-** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
2750
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
27642751
** statement might be re-prepared during [sqlite3_step()] due to a
27652752
** schema change. Hence, the application should ensure that the
27662753
** correct authorizer callback remains in place during the [sqlite3_step()].
27672754
**
27682755
** ^Note that the authorizer callback is invoked only during
27692756
** [sqlite3_prepare()] or its variants. Authorization is not
27702757
** performed during statement evaluation in [sqlite3_step()], unless
27712758
** as stated in the previous paragraph, sqlite3_step() invokes
2772
-** sqlite3_prepare_v3() to reprepare a statement after a schema change.
2759
+** sqlite3_prepare_v2() to reprepare a statement after a schema change.
27732760
*/
27742761
SQLITE_API int sqlite3_set_authorizer(
27752762
sqlite3*,
27762763
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
27772764
void *pUserData
@@ -3003,11 +2990,11 @@
30032990
** interrupted. This feature can be used to implement a
30042991
** "Cancel" button on a GUI progress dialog box.
30052992
**
30062993
** The progress handler callback must not do anything that will modify
30072994
** the database connection that invoked the progress handler.
3008
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2995
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
30092996
** database connections for the meaning of "modify" in this paragraph.
30102997
**
30112998
*/
30122999
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
30133000
@@ -3357,11 +3344,11 @@
33573344
** prepared statement before it can be run.
33583345
**
33593346
** The life-cycle of a prepared statement object usually goes like this:
33603347
**
33613348
** <ol>
3362
-** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3349
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
33633350
** <li> Bind values to [parameters] using the sqlite3_bind_*()
33643351
** interfaces.
33653352
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
33663353
** <li> Reset the prepared statement using [sqlite3_reset()] then go back
33673354
** to step 2. Do this zero or more times.
@@ -3439,11 +3426,11 @@
34393426
** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
34403427
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
34413428
**
34423429
** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
34433430
** <dd>The maximum number of instructions in a virtual machine program
3444
-** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3431
+** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
34453432
** the equivalent tries to allocate space for more than this many opcodes
34463433
** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
34473434
**
34483435
** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
34493436
** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3479,61 +3466,28 @@
34793466
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
34803467
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
34813468
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
34823469
#define SQLITE_LIMIT_WORKER_THREADS 11
34833470
3484
-/*
3485
-** CAPI3REF: Prepare Flags
3486
-**
3487
-** These constants define various flags that can be passed into
3488
-** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
3489
-** [sqlite3_prepare16_v3()] interfaces.
3490
-**
3491
-** New flags may be added in future releases of SQLite.
3492
-**
3493
-** <dl>
3494
-** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495
-** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496
-** and [sqlite3_prepare16_v3()]
3497
-** to optimize the resulting prepared statement to be retained for a
3498
-** relatively long amount of time.)^ ^Without this flag,
3499
-** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500
-** the prepared statement will be used just once or at most a few times
3501
-** and then destroyed using [sqlite3_finalize()] relatively soon.
3502
-** </dl>
3503
-*/
3504
-#define SQLITE_PREPARE_PERSISTENT 0x01
35053471
35063472
/*
35073473
** CAPI3REF: Compiling An SQL Statement
35083474
** KEYWORDS: {SQL statement compiler}
35093475
** METHOD: sqlite3
35103476
** CONSTRUCTOR: sqlite3_stmt
35113477
**
3512
-** To execute an SQL statement, it must first be compiled into a byte-code
3513
-** program using one of these routines. Or, in other words, these routines
3514
-** are constructors for the [prepared statement] object.
3515
-**
3516
-** The preferred routine to use is [sqlite3_prepare_v2()]. The
3517
-** [sqlite3_prepare()] interface is legacy and should be avoided.
3518
-** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
3519
-** for special purposes.
3520
-**
3521
-** The use of the UTF-8 interfaces is preferred, as SQLite currently
3522
-** does all parsing using UTF-8. The UTF-16 interfaces are provided
3523
-** as a convenience. The UTF-16 interfaces work by converting the
3524
-** input text into UTF-8, then invoking the corresponding UTF-8 interface.
3478
+** To execute an SQL query, it must first be compiled into a byte-code
3479
+** program using one of these routines.
35253480
**
35263481
** The first argument, "db", is a [database connection] obtained from a
35273482
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
35283483
** [sqlite3_open16()]. The database connection must not have been closed.
35293484
**
35303485
** The second argument, "zSql", is the statement to be compiled, encoded
3531
-** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
3532
-** and sqlite3_prepare_v3()
3533
-** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
3534
-** and sqlite3_prepare16_v3() use UTF-16.
3486
+** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3487
+** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3488
+** use UTF-16.
35353489
**
35363490
** ^If the nByte argument is negative, then zSql is read up to the
35373491
** first zero terminator. ^If nByte is positive, then it is the
35383492
** number of bytes read from zSql. ^If nByte is zero, then no prepared
35393493
** statement is generated.
@@ -3556,15 +3510,14 @@
35563510
** ppStmt may not be NULL.
35573511
**
35583512
** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
35593513
** otherwise an [error code] is returned.
35603514
**
3561
-** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
3562
-** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
3563
-** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
3564
-** are retained for backwards compatibility, but their use is discouraged.
3565
-** ^In the "vX" interfaces, the prepared statement
3515
+** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3516
+** recommended for all new programs. The two older interfaces are retained
3517
+** for backwards compatibility, but their use is discouraged.
3518
+** ^In the "v2" interfaces, the prepared statement
35663519
** that is returned (the [sqlite3_stmt] object) contains a copy of the
35673520
** original SQL text. This causes the [sqlite3_step()] interface to
35683521
** behave differently in three ways:
35693522
**
35703523
** <ol>
@@ -3593,16 +3546,10 @@
35933546
** ^The specific value of WHERE-clause [parameter] might influence the
35943547
** choice of query plan if the parameter is the left-hand side of a [LIKE]
35953548
** or [GLOB] operator or if the parameter is compared to an indexed column
35963549
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
35973550
** </li>
3598
-**
3599
-** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3600
-** the extra prepFlags parameter, which is a bit array consisting of zero or
3601
-** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
3602
-** sqlite3_prepare_v2() interface works exactly the same as
3603
-** sqlite3_prepare_v3() with a zero prepFlags parameter.
36043551
** </ol>
36053552
*/
36063553
SQLITE_API int sqlite3_prepare(
36073554
sqlite3 *db, /* Database handle */
36083555
const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3613,18 +3560,10 @@
36133560
SQLITE_API int sqlite3_prepare_v2(
36143561
sqlite3 *db, /* Database handle */
36153562
const char *zSql, /* SQL statement, UTF-8 encoded */
36163563
int nByte, /* Maximum length of zSql in bytes. */
36173564
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3618
- const char **pzTail /* OUT: Pointer to unused portion of zSql */
3619
-);
3620
-SQLITE_API int sqlite3_prepare_v3(
3621
- sqlite3 *db, /* Database handle */
3622
- const char *zSql, /* SQL statement, UTF-8 encoded */
3623
- int nByte, /* Maximum length of zSql in bytes. */
3624
- unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
3625
- sqlite3_stmt **ppStmt, /* OUT: Statement handle */
36263565
const char **pzTail /* OUT: Pointer to unused portion of zSql */
36273566
);
36283567
SQLITE_API int sqlite3_prepare16(
36293568
sqlite3 *db, /* Database handle */
36303569
const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -3637,27 +3576,18 @@
36373576
const void *zSql, /* SQL statement, UTF-16 encoded */
36383577
int nByte, /* Maximum length of zSql in bytes. */
36393578
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
36403579
const void **pzTail /* OUT: Pointer to unused portion of zSql */
36413580
);
3642
-SQLITE_API int sqlite3_prepare16_v3(
3643
- sqlite3 *db, /* Database handle */
3644
- const void *zSql, /* SQL statement, UTF-16 encoded */
3645
- int nByte, /* Maximum length of zSql in bytes. */
3646
- unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3647
- sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3648
- const void **pzTail /* OUT: Pointer to unused portion of zSql */
3649
-);
36503581
36513582
/*
36523583
** CAPI3REF: Retrieving Statement SQL
36533584
** METHOD: sqlite3_stmt
36543585
**
36553586
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
36563587
** SQL text used to create [prepared statement] P if P was
3657
-** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3658
-** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3588
+** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
36593589
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
36603590
** string containing the SQL text of prepared statement P with
36613591
** [bound parameters] expanded.
36623592
**
36633593
** ^(For example, if a prepared statement is created using the SQL
@@ -3799,11 +3729,11 @@
37993729
** CAPI3REF: Binding Values To Prepared Statements
38003730
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
38013731
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
38023732
** METHOD: sqlite3_stmt
38033733
**
3804
-** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
3734
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
38053735
** literals may be replaced by a [parameter] that matches one of following
38063736
** templates:
38073737
**
38083738
** <ul>
38093739
** <li> ?
@@ -3818,11 +3748,11 @@
38183748
** parameters (also called "host parameter names" or "SQL parameters")
38193749
** can be set using the sqlite3_bind_*() routines defined here.
38203750
**
38213751
** ^The first argument to the sqlite3_bind_*() routines is always
38223752
** a pointer to the [sqlite3_stmt] object returned from
3823
-** [sqlite3_prepare_v3()] or its variants.
3753
+** [sqlite3_prepare_v2()] or its variants.
38243754
**
38253755
** ^The second argument is the index of the SQL parameter to be set.
38263756
** ^The leftmost SQL parameter has an index of 1. ^When the same named
38273757
** SQL parameter is used more than once, second and subsequent
38283758
** occurrences have the same index as the first occurrence.
@@ -3955,12 +3885,12 @@
39553885
** ^The first host parameter has an index of 1, not 0.
39563886
**
39573887
** ^If the value N is out of range or if the N-th parameter is
39583888
** nameless, then NULL is returned. ^The returned string is
39593889
** always in UTF-8 encoding even if the named parameter was
3960
-** originally specified as UTF-16 in [sqlite3_prepare16()],
3961
-** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3890
+** originally specified as UTF-16 in [sqlite3_prepare16()] or
3891
+** [sqlite3_prepare16_v2()].
39623892
**
39633893
** See also: [sqlite3_bind_blob|sqlite3_bind()],
39643894
** [sqlite3_bind_parameter_count()], and
39653895
** [sqlite3_bind_parameter_index()].
39663896
*/
@@ -3973,12 +3903,11 @@
39733903
** ^Return the index of an SQL parameter given its name. ^The
39743904
** index value returned is suitable for use as the second
39753905
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
39763906
** is returned if no matching parameter is found. ^The parameter
39773907
** name must be given in UTF-8 even if the original statement
3978
-** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
3979
-** [sqlite3_prepare16_v3()].
3908
+** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
39803909
**
39813910
** See also: [sqlite3_bind_blob|sqlite3_bind()],
39823911
** [sqlite3_bind_parameter_count()], and
39833912
** [sqlite3_bind_parameter_name()].
39843913
*/
@@ -4128,22 +4057,20 @@
41284057
41294058
/*
41304059
** CAPI3REF: Evaluate An SQL Statement
41314060
** METHOD: sqlite3_stmt
41324061
**
4133
-** After a [prepared statement] has been prepared using any of
4134
-** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
4135
-** or [sqlite3_prepare16_v3()] or one of the legacy
4062
+** After a [prepared statement] has been prepared using either
4063
+** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
41364064
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
41374065
** must be called one or more times to evaluate the statement.
41384066
**
41394067
** The details of the behavior of the sqlite3_step() interface depend
4140
-** on whether the statement was prepared using the newer "vX" interfaces
4141
-** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
4142
-** [sqlite3_prepare16_v2()] or the older legacy
4143
-** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4144
-** new "vX" interface is recommended for new applications but the legacy
4068
+** on whether the statement was prepared using the newer "v2" interface
4069
+** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4070
+** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4071
+** new "v2" interface is recommended for new applications but the legacy
41454072
** interface will continue to be supported.
41464073
**
41474074
** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
41484075
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
41494076
** ^With the "v2" interface, any of the other [result codes] or
@@ -4200,15 +4127,14 @@
42004127
** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
42014128
** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
42024129
** specific [error codes] that better describes the error.
42034130
** We admit that this is a goofy design. The problem has been fixed
42044131
** with the "v2" interface. If you prepare all of your SQL statements
4205
-** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
4206
-** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
4132
+** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
42074133
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
42084134
** then the more specific [error codes] are returned directly
4209
-** by sqlite3_step(). The use of the "vX" interfaces is recommended.
4135
+** by sqlite3_step(). The use of the "v2" interface is recommended.
42104136
*/
42114137
SQLITE_API int sqlite3_step(sqlite3_stmt*);
42124138
42134139
/*
42144140
** CAPI3REF: Number of columns in a result set
@@ -4269,11 +4195,11 @@
42694195
** METHOD: sqlite3_stmt
42704196
**
42714197
** ^These routines return information about a single column of the current
42724198
** result row of a query. ^In every case the first argument is a pointer
42734199
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4274
-** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4200
+** that was returned from [sqlite3_prepare_v2()] or one of its variants)
42754201
** and the second argument is the index of the column for which information
42764202
** should be returned. ^The leftmost column of the result set has the index 0.
42774203
** ^The number of columns in the result can be determined using
42784204
** [sqlite3_column_count()].
42794205
**
@@ -5393,11 +5319,11 @@
53935319
**
53945320
** ^The sqlite3_db_handle interface returns the [database connection] handle
53955321
** to which a [prepared statement] belongs. ^The [database connection]
53965322
** returned by sqlite3_db_handle is the same [database connection]
53975323
** that was the first argument
5398
-** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5324
+** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
53995325
** create the statement in the first place.
54005326
*/
54015327
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
54025328
54035329
/*
@@ -5469,11 +5395,11 @@
54695395
** the database connection that invoked the callback. Any actions
54705396
** to modify the database connection must be deferred until after the
54715397
** completion of the [sqlite3_step()] call that triggered the commit
54725398
** or rollback hook in the first place.
54735399
** Note that running any other SQL statements, including SELECT statements,
5474
-** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5400
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
54755401
** the database connections for the meaning of "modify" in this paragraph.
54765402
**
54775403
** ^Registering a NULL function disables the callback.
54785404
**
54795405
** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5529,11 +5455,11 @@
55295455
**
55305456
** The update hook implementation must not do anything that will modify
55315457
** the database connection that invoked the update hook. Any actions
55325458
** to modify the database connection must be deferred until after the
55335459
** completion of the [sqlite3_step()] call that triggered the update hook.
5534
-** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5460
+** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
55355461
** database connections for the meaning of "modify" in this paragraph.
55365462
**
55375463
** ^The sqlite3_update_hook(D,C,P) function
55385464
** returns the P argument from the previous call
55395465
** on the same [database connection] D, or NULL for
@@ -5692,13 +5618,11 @@
56925618
** column exists. ^The sqlite3_table_column_metadata() interface returns
56935619
** SQLITE_ERROR and if the specified column does not exist.
56945620
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
56955621
** NULL pointer, then this routine simply checks for the existence of the
56965622
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5697
-** does not. If the table name parameter T in a call to
5698
-** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
5699
-** undefined behavior.
5623
+** does not.
57005624
**
57015625
** ^The column is identified by the second, third and fourth parameters to
57025626
** this function. ^(The second parameter is either the name of the database
57035627
** (i.e. "main", "temp", or an attached database) containing the specified
57045628
** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -7207,38 +7131,17 @@
72077131
** by the prepared statement if that number is less than or equal
72087132
** to 2147483647. The number of virtual machine operations can be
72097133
** used as a proxy for the total work done by the prepared statement.
72107134
** If the number of virtual machine operations exceeds 2147483647
72117135
** then the value returned by this statement status code is undefined.
7212
-**
7213
-** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7214
-** <dd>^This is the number of times that the prepare statement has been
7215
-** automatically regenerated due to schema changes or change to
7216
-** [bound parameters] that might affect the query plan.
7217
-**
7218
-** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7219
-** <dd>^This is the number of times that the prepared statement has
7220
-** been run. A single "run" for the purposes of this counter is one
7221
-** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
7222
-** The counter is incremented on the first [sqlite3_step()] call of each
7223
-** cycle.
7224
-**
7225
-** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
7226
-** <dd>^This is the approximate number of bytes of heap memory
7227
-** used to store the prepared statement. ^This value is not actually
7228
-** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
7229
-** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
72307136
** </dd>
72317137
** </dl>
72327138
*/
72337139
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
72347140
#define SQLITE_STMTSTATUS_SORT 2
72357141
#define SQLITE_STMTSTATUS_AUTOINDEX 3
72367142
#define SQLITE_STMTSTATUS_VM_STEP 4
7237
-#define SQLITE_STMTSTATUS_REPREPARE 5
7238
-#define SQLITE_STMTSTATUS_RUN 6
7239
-#define SQLITE_STMTSTATUS_MEMUSED 99
72407143
72417144
/*
72427145
** CAPI3REF: Custom Page Cache Object
72437146
**
72447147
** The sqlite3_pcache type is opaque. It is implemented by
72457148
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
1 /*
2 ** 2001-09-15
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v3()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v3()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,31 +2005,19 @@
2005 ** default) to enable them. The second parameter is a pointer to an integer
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
2010 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2011 ** <dd>The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2012 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2013 ** a single SQL query statement will always use the same algorithm regardless
2014 ** of values of [bound parameters]. The QPSG disables some query optimizations
2015 ** that look at the values of bound parameters, which can make some queries
2016 ** slower. But the QPSG has the advantage of more predictable behavior. With
2017 ** the QPSG active, SQLite will always use the same query plan in the field as
2018 ** was used during testing in the lab.
2019 ** </dd>
2020 **
2021 ** </dl>
2022 */
2023 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2024 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2025 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2026 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2027 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2028 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2029 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2030 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2031
2032
2033 /*
2034 ** CAPI3REF: Enable Or Disable Extended Result Codes
2035 ** METHOD: sqlite3
@@ -2689,26 +2677,25 @@
2689 **
2690 ** ^This routine registers an authorizer callback with a particular
2691 ** [database connection], supplied in the first argument.
2692 ** ^The authorizer callback is invoked as SQL statements are being compiled
2693 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2694 ** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
2695 ** and [sqlite3_prepare16_v3()]. ^At various
2696 ** points during the compilation process, as logic is being created
2697 ** to perform various actions, the authorizer callback is invoked to
2698 ** see if those actions are allowed. ^The authorizer callback should
2699 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2700 ** specific action but allow the SQL statement to continue to be
2701 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2702 ** rejected with an error. ^If the authorizer callback returns
2703 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2704 ** then the [sqlite3_prepare_v3()] or equivalent call that triggered
2705 ** the authorizer will fail with an error message.
2706 **
2707 ** When the callback returns [SQLITE_OK], that means the operation
2708 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2709 ** [sqlite3_prepare_v3()] or equivalent call that triggered the
2710 ** authorizer will fail with an error message explaining that
2711 ** access is denied.
2712 **
2713 ** ^The first parameter to the authorizer callback is a copy of the third
2714 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2742,23 @@
2755 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2756 ** The authorizer is disabled by default.
2757 **
2758 ** The authorizer callback must not do anything that will modify
2759 ** the database connection that invoked the authorizer callback.
2760 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
2761 ** database connections for the meaning of "modify" in this paragraph.
2762 **
2763 ** ^When [sqlite3_prepare_v3()] is used to prepare a statement, the
2764 ** statement might be re-prepared during [sqlite3_step()] due to a
2765 ** schema change. Hence, the application should ensure that the
2766 ** correct authorizer callback remains in place during the [sqlite3_step()].
2767 **
2768 ** ^Note that the authorizer callback is invoked only during
2769 ** [sqlite3_prepare()] or its variants. Authorization is not
2770 ** performed during statement evaluation in [sqlite3_step()], unless
2771 ** as stated in the previous paragraph, sqlite3_step() invokes
2772 ** sqlite3_prepare_v3() to reprepare a statement after a schema change.
2773 */
2774 SQLITE_API int sqlite3_set_authorizer(
2775 sqlite3*,
2776 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2777 void *pUserData
@@ -3003,11 +2990,11 @@
3003 ** interrupted. This feature can be used to implement a
3004 ** "Cancel" button on a GUI progress dialog box.
3005 **
3006 ** The progress handler callback must not do anything that will modify
3007 ** the database connection that invoked the progress handler.
3008 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
3009 ** database connections for the meaning of "modify" in this paragraph.
3010 **
3011 */
3012 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3013
@@ -3357,11 +3344,11 @@
3357 ** prepared statement before it can be run.
3358 **
3359 ** The life-cycle of a prepared statement object usually goes like this:
3360 **
3361 ** <ol>
3362 ** <li> Create the prepared statement object using [sqlite3_prepare_v3()].
3363 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3364 ** interfaces.
3365 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3366 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3367 ** to step 2. Do this zero or more times.
@@ -3439,11 +3426,11 @@
3439 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3440 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3441 **
3442 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3443 ** <dd>The maximum number of instructions in a virtual machine program
3444 ** used to implement an SQL statement. If [sqlite3_prepare_v3()] or
3445 ** the equivalent tries to allocate space for more than this many opcodes
3446 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3447 **
3448 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3449 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3479,61 +3466,28 @@
3479 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3480 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3481 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3482 #define SQLITE_LIMIT_WORKER_THREADS 11
3483
3484 /*
3485 ** CAPI3REF: Prepare Flags
3486 **
3487 ** These constants define various flags that can be passed into
3488 ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
3489 ** [sqlite3_prepare16_v3()] interfaces.
3490 **
3491 ** New flags may be added in future releases of SQLite.
3492 **
3493 ** <dl>
3494 ** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
3495 ** <dd>The SQLITE_PREPARE_PERSISTENT flag causes [sqlite3_prepare_v3()]
3496 ** and [sqlite3_prepare16_v3()]
3497 ** to optimize the resulting prepared statement to be retained for a
3498 ** relatively long amount of time.)^ ^Without this flag,
3499 ** [sqlite3_prepare_v3()] and [sqlite3_prepare16_v3()] assume that
3500 ** the prepared statement will be used just once or at most a few times
3501 ** and then destroyed using [sqlite3_finalize()] relatively soon.
3502 ** </dl>
3503 */
3504 #define SQLITE_PREPARE_PERSISTENT 0x01
3505
3506 /*
3507 ** CAPI3REF: Compiling An SQL Statement
3508 ** KEYWORDS: {SQL statement compiler}
3509 ** METHOD: sqlite3
3510 ** CONSTRUCTOR: sqlite3_stmt
3511 **
3512 ** To execute an SQL statement, it must first be compiled into a byte-code
3513 ** program using one of these routines. Or, in other words, these routines
3514 ** are constructors for the [prepared statement] object.
3515 **
3516 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
3517 ** [sqlite3_prepare()] interface is legacy and should be avoided.
3518 ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
3519 ** for special purposes.
3520 **
3521 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
3522 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
3523 ** as a convenience. The UTF-16 interfaces work by converting the
3524 ** input text into UTF-8, then invoking the corresponding UTF-8 interface.
3525 **
3526 ** The first argument, "db", is a [database connection] obtained from a
3527 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3528 ** [sqlite3_open16()]. The database connection must not have been closed.
3529 **
3530 ** The second argument, "zSql", is the statement to be compiled, encoded
3531 ** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
3532 ** and sqlite3_prepare_v3()
3533 ** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
3534 ** and sqlite3_prepare16_v3() use UTF-16.
3535 **
3536 ** ^If the nByte argument is negative, then zSql is read up to the
3537 ** first zero terminator. ^If nByte is positive, then it is the
3538 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3539 ** statement is generated.
@@ -3556,15 +3510,14 @@
3556 ** ppStmt may not be NULL.
3557 **
3558 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
3559 ** otherwise an [error code] is returned.
3560 **
3561 ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),
3562 ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.
3563 ** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())
3564 ** are retained for backwards compatibility, but their use is discouraged.
3565 ** ^In the "vX" interfaces, the prepared statement
3566 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
3567 ** original SQL text. This causes the [sqlite3_step()] interface to
3568 ** behave differently in three ways:
3569 **
3570 ** <ol>
@@ -3593,16 +3546,10 @@
3593 ** ^The specific value of WHERE-clause [parameter] might influence the
3594 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3595 ** or [GLOB] operator or if the parameter is compared to an indexed column
3596 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3597 ** </li>
3598 **
3599 ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
3600 ** the extra prepFlags parameter, which is a bit array consisting of zero or
3601 ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The
3602 ** sqlite3_prepare_v2() interface works exactly the same as
3603 ** sqlite3_prepare_v3() with a zero prepFlags parameter.
3604 ** </ol>
3605 */
3606 SQLITE_API int sqlite3_prepare(
3607 sqlite3 *db, /* Database handle */
3608 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3613,18 +3560,10 @@
3613 SQLITE_API int sqlite3_prepare_v2(
3614 sqlite3 *db, /* Database handle */
3615 const char *zSql, /* SQL statement, UTF-8 encoded */
3616 int nByte, /* Maximum length of zSql in bytes. */
3617 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3618 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3619 );
3620 SQLITE_API int sqlite3_prepare_v3(
3621 sqlite3 *db, /* Database handle */
3622 const char *zSql, /* SQL statement, UTF-8 encoded */
3623 int nByte, /* Maximum length of zSql in bytes. */
3624 unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */
3625 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3626 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3627 );
3628 SQLITE_API int sqlite3_prepare16(
3629 sqlite3 *db, /* Database handle */
3630 const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -3637,27 +3576,18 @@
3637 const void *zSql, /* SQL statement, UTF-16 encoded */
3638 int nByte, /* Maximum length of zSql in bytes. */
3639 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3640 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3641 );
3642 SQLITE_API int sqlite3_prepare16_v3(
3643 sqlite3 *db, /* Database handle */
3644 const void *zSql, /* SQL statement, UTF-16 encoded */
3645 int nByte, /* Maximum length of zSql in bytes. */
3646 unsigned int prepFalgs, /* Zero or more SQLITE_PREPARE_ flags */
3647 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3648 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3649 );
3650
3651 /*
3652 ** CAPI3REF: Retrieving Statement SQL
3653 ** METHOD: sqlite3_stmt
3654 **
3655 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3656 ** SQL text used to create [prepared statement] P if P was
3657 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3658 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3659 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3660 ** string containing the SQL text of prepared statement P with
3661 ** [bound parameters] expanded.
3662 **
3663 ** ^(For example, if a prepared statement is created using the SQL
@@ -3799,11 +3729,11 @@
3799 ** CAPI3REF: Binding Values To Prepared Statements
3800 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3801 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3802 ** METHOD: sqlite3_stmt
3803 **
3804 ** ^(In the SQL statement text input to [sqlite3_prepare_v3()] and its variants,
3805 ** literals may be replaced by a [parameter] that matches one of following
3806 ** templates:
3807 **
3808 ** <ul>
3809 ** <li> ?
@@ -3818,11 +3748,11 @@
3818 ** parameters (also called "host parameter names" or "SQL parameters")
3819 ** can be set using the sqlite3_bind_*() routines defined here.
3820 **
3821 ** ^The first argument to the sqlite3_bind_*() routines is always
3822 ** a pointer to the [sqlite3_stmt] object returned from
3823 ** [sqlite3_prepare_v3()] or its variants.
3824 **
3825 ** ^The second argument is the index of the SQL parameter to be set.
3826 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3827 ** SQL parameter is used more than once, second and subsequent
3828 ** occurrences have the same index as the first occurrence.
@@ -3955,12 +3885,12 @@
3955 ** ^The first host parameter has an index of 1, not 0.
3956 **
3957 ** ^If the value N is out of range or if the N-th parameter is
3958 ** nameless, then NULL is returned. ^The returned string is
3959 ** always in UTF-8 encoding even if the named parameter was
3960 ** originally specified as UTF-16 in [sqlite3_prepare16()],
3961 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3962 **
3963 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3964 ** [sqlite3_bind_parameter_count()], and
3965 ** [sqlite3_bind_parameter_index()].
3966 */
@@ -3973,12 +3903,11 @@
3973 ** ^Return the index of an SQL parameter given its name. ^The
3974 ** index value returned is suitable for use as the second
3975 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3976 ** is returned if no matching parameter is found. ^The parameter
3977 ** name must be given in UTF-8 even if the original statement
3978 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or
3979 ** [sqlite3_prepare16_v3()].
3980 **
3981 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3982 ** [sqlite3_bind_parameter_count()], and
3983 ** [sqlite3_bind_parameter_name()].
3984 */
@@ -4128,22 +4057,20 @@
4128
4129 /*
4130 ** CAPI3REF: Evaluate An SQL Statement
4131 ** METHOD: sqlite3_stmt
4132 **
4133 ** After a [prepared statement] has been prepared using any of
4134 ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],
4135 ** or [sqlite3_prepare16_v3()] or one of the legacy
4136 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
4137 ** must be called one or more times to evaluate the statement.
4138 **
4139 ** The details of the behavior of the sqlite3_step() interface depend
4140 ** on whether the statement was prepared using the newer "vX" interfaces
4141 ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],
4142 ** [sqlite3_prepare16_v2()] or the older legacy
4143 ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4144 ** new "vX" interface is recommended for new applications but the legacy
4145 ** interface will continue to be supported.
4146 **
4147 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
4148 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
4149 ** ^With the "v2" interface, any of the other [result codes] or
@@ -4200,15 +4127,14 @@
4200 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
4201 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
4202 ** specific [error codes] that better describes the error.
4203 ** We admit that this is a goofy design. The problem has been fixed
4204 ** with the "v2" interface. If you prepare all of your SQL statements
4205 ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]
4206 ** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead
4207 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4208 ** then the more specific [error codes] are returned directly
4209 ** by sqlite3_step(). The use of the "vX" interfaces is recommended.
4210 */
4211 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4212
4213 /*
4214 ** CAPI3REF: Number of columns in a result set
@@ -4269,11 +4195,11 @@
4269 ** METHOD: sqlite3_stmt
4270 **
4271 ** ^These routines return information about a single column of the current
4272 ** result row of a query. ^In every case the first argument is a pointer
4273 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4274 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
4275 ** and the second argument is the index of the column for which information
4276 ** should be returned. ^The leftmost column of the result set has the index 0.
4277 ** ^The number of columns in the result can be determined using
4278 ** [sqlite3_column_count()].
4279 **
@@ -5393,11 +5319,11 @@
5393 **
5394 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5395 ** to which a [prepared statement] belongs. ^The [database connection]
5396 ** returned by sqlite3_db_handle is the same [database connection]
5397 ** that was the first argument
5398 ** to the [sqlite3_prepare_v3()] call (or its variants) that was used to
5399 ** create the statement in the first place.
5400 */
5401 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5402
5403 /*
@@ -5469,11 +5395,11 @@
5469 ** the database connection that invoked the callback. Any actions
5470 ** to modify the database connection must be deferred until after the
5471 ** completion of the [sqlite3_step()] call that triggered the commit
5472 ** or rollback hook in the first place.
5473 ** Note that running any other SQL statements, including SELECT statements,
5474 ** or merely calling [sqlite3_prepare_v3()] and [sqlite3_step()] will modify
5475 ** the database connections for the meaning of "modify" in this paragraph.
5476 **
5477 ** ^Registering a NULL function disables the callback.
5478 **
5479 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5529,11 +5455,11 @@
5529 **
5530 ** The update hook implementation must not do anything that will modify
5531 ** the database connection that invoked the update hook. Any actions
5532 ** to modify the database connection must be deferred until after the
5533 ** completion of the [sqlite3_step()] call that triggered the update hook.
5534 ** Note that [sqlite3_prepare_v3()] and [sqlite3_step()] both modify their
5535 ** database connections for the meaning of "modify" in this paragraph.
5536 **
5537 ** ^The sqlite3_update_hook(D,C,P) function
5538 ** returns the P argument from the previous call
5539 ** on the same [database connection] D, or NULL for
@@ -5692,13 +5618,11 @@
5692 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5693 ** SQLITE_ERROR and if the specified column does not exist.
5694 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5695 ** NULL pointer, then this routine simply checks for the existence of the
5696 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5697 ** does not. If the table name parameter T in a call to
5698 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
5699 ** undefined behavior.
5700 **
5701 ** ^The column is identified by the second, third and fourth parameters to
5702 ** this function. ^(The second parameter is either the name of the database
5703 ** (i.e. "main", "temp", or an attached database) containing the specified
5704 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -7207,38 +7131,17 @@
7207 ** by the prepared statement if that number is less than or equal
7208 ** to 2147483647. The number of virtual machine operations can be
7209 ** used as a proxy for the total work done by the prepared statement.
7210 ** If the number of virtual machine operations exceeds 2147483647
7211 ** then the value returned by this statement status code is undefined.
7212 **
7213 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7214 ** <dd>^This is the number of times that the prepare statement has been
7215 ** automatically regenerated due to schema changes or change to
7216 ** [bound parameters] that might affect the query plan.
7217 **
7218 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7219 ** <dd>^This is the number of times that the prepared statement has
7220 ** been run. A single "run" for the purposes of this counter is one
7221 ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].
7222 ** The counter is incremented on the first [sqlite3_step()] call of each
7223 ** cycle.
7224 **
7225 ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
7226 ** <dd>^This is the approximate number of bytes of heap memory
7227 ** used to store the prepared statement. ^This value is not actually
7228 ** a counter, and so the resetFlg parameter to sqlite3_stmt_status()
7229 ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.
7230 ** </dd>
7231 ** </dl>
7232 */
7233 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7234 #define SQLITE_STMTSTATUS_SORT 2
7235 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7236 #define SQLITE_STMTSTATUS_VM_STEP 4
7237 #define SQLITE_STMTSTATUS_REPREPARE 5
7238 #define SQLITE_STMTSTATUS_RUN 6
7239 #define SQLITE_STMTSTATUS_MEMUSED 99
7240
7241 /*
7242 ** CAPI3REF: Custom Page Cache Object
7243 **
7244 ** The sqlite3_pcache type is opaque. It is implemented by
7245
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -1,7 +1,7 @@
1 /*
2 ** 2001 September 15
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.19.3"
125 #define SQLITE_VERSION_NUMBER 3019003
126 #define SQLITE_SOURCE_ID "2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -233,11 +233,11 @@
233 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
234 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
235 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
236 ** and [sqlite3_close_v2()] are its destructors. There are many other
237 ** interfaces (such as
238 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
239 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
240 ** sqlite3 object.
241 */
242 typedef struct sqlite3 sqlite3;
243
@@ -337,11 +337,11 @@
337 /*
338 ** CAPI3REF: One-Step Query Execution Interface
339 ** METHOD: sqlite3
340 **
341 ** The sqlite3_exec() interface is a convenience wrapper around
342 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
343 ** that allows an application to run multiple statements of SQL
344 ** without having to use a lot of C code.
345 **
346 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
347 ** semicolon-separate SQL statements passed into its 2nd argument,
@@ -2005,31 +2005,19 @@
2005 ** default) to enable them. The second parameter is a pointer to an integer
2006 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2007 ** have been disabled - 0 if they are not disabled, 1 if they are.
2008 ** </dd>
2009 **
 
 
 
 
 
 
 
 
 
 
 
2010 ** </dl>
2011 */
2012 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2013 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2014 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2015 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2016 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
2017 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2018 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
 
2019
2020
2021 /*
2022 ** CAPI3REF: Enable Or Disable Extended Result Codes
2023 ** METHOD: sqlite3
@@ -2689,26 +2677,25 @@
2677 **
2678 ** ^This routine registers an authorizer callback with a particular
2679 ** [database connection], supplied in the first argument.
2680 ** ^The authorizer callback is invoked as SQL statements are being compiled
2681 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2682 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
 
2683 ** points during the compilation process, as logic is being created
2684 ** to perform various actions, the authorizer callback is invoked to
2685 ** see if those actions are allowed. ^The authorizer callback should
2686 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2687 ** specific action but allow the SQL statement to continue to be
2688 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2689 ** rejected with an error. ^If the authorizer callback returns
2690 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2691 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2692 ** the authorizer will fail with an error message.
2693 **
2694 ** When the callback returns [SQLITE_OK], that means the operation
2695 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2696 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2697 ** authorizer will fail with an error message explaining that
2698 ** access is denied.
2699 **
2700 ** ^The first parameter to the authorizer callback is a copy of the third
2701 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
@@ -2755,23 +2742,23 @@
2742 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2743 ** The authorizer is disabled by default.
2744 **
2745 ** The authorizer callback must not do anything that will modify
2746 ** the database connection that invoked the authorizer callback.
2747 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2748 ** database connections for the meaning of "modify" in this paragraph.
2749 **
2750 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2751 ** statement might be re-prepared during [sqlite3_step()] due to a
2752 ** schema change. Hence, the application should ensure that the
2753 ** correct authorizer callback remains in place during the [sqlite3_step()].
2754 **
2755 ** ^Note that the authorizer callback is invoked only during
2756 ** [sqlite3_prepare()] or its variants. Authorization is not
2757 ** performed during statement evaluation in [sqlite3_step()], unless
2758 ** as stated in the previous paragraph, sqlite3_step() invokes
2759 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2760 */
2761 SQLITE_API int sqlite3_set_authorizer(
2762 sqlite3*,
2763 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2764 void *pUserData
@@ -3003,11 +2990,11 @@
2990 ** interrupted. This feature can be used to implement a
2991 ** "Cancel" button on a GUI progress dialog box.
2992 **
2993 ** The progress handler callback must not do anything that will modify
2994 ** the database connection that invoked the progress handler.
2995 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2996 ** database connections for the meaning of "modify" in this paragraph.
2997 **
2998 */
2999 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3000
@@ -3357,11 +3344,11 @@
3344 ** prepared statement before it can be run.
3345 **
3346 ** The life-cycle of a prepared statement object usually goes like this:
3347 **
3348 ** <ol>
3349 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3350 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
3351 ** interfaces.
3352 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3353 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3354 ** to step 2. Do this zero or more times.
@@ -3439,11 +3426,11 @@
3426 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
3427 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3428 **
3429 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
3430 ** <dd>The maximum number of instructions in a virtual machine program
3431 ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or
3432 ** the equivalent tries to allocate space for more than this many opcodes
3433 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
3434 **
3435 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
3436 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -3479,61 +3466,28 @@
3466 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
3467 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
3468 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
3469 #define SQLITE_LIMIT_WORKER_THREADS 11
3470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3471
3472 /*
3473 ** CAPI3REF: Compiling An SQL Statement
3474 ** KEYWORDS: {SQL statement compiler}
3475 ** METHOD: sqlite3
3476 ** CONSTRUCTOR: sqlite3_stmt
3477 **
3478 ** To execute an SQL query, it must first be compiled into a byte-code
3479 ** program using one of these routines.
 
 
 
 
 
 
 
 
 
 
 
3480 **
3481 ** The first argument, "db", is a [database connection] obtained from a
3482 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
3483 ** [sqlite3_open16()]. The database connection must not have been closed.
3484 **
3485 ** The second argument, "zSql", is the statement to be compiled, encoded
3486 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
3487 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
3488 ** use UTF-16.
 
3489 **
3490 ** ^If the nByte argument is negative, then zSql is read up to the
3491 ** first zero terminator. ^If nByte is positive, then it is the
3492 ** number of bytes read from zSql. ^If nByte is zero, then no prepared
3493 ** statement is generated.
@@ -3556,15 +3510,14 @@
3510 ** ppStmt may not be NULL.
3511 **
3512 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
3513 ** otherwise an [error code] is returned.
3514 **
3515 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
3516 ** recommended for all new programs. The two older interfaces are retained
3517 ** for backwards compatibility, but their use is discouraged.
3518 ** ^In the "v2" interfaces, the prepared statement
 
3519 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
3520 ** original SQL text. This causes the [sqlite3_step()] interface to
3521 ** behave differently in three ways:
3522 **
3523 ** <ol>
@@ -3593,16 +3546,10 @@
3546 ** ^The specific value of WHERE-clause [parameter] might influence the
3547 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3548 ** or [GLOB] operator or if the parameter is compared to an indexed column
3549 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3550 ** </li>
 
 
 
 
 
 
3551 ** </ol>
3552 */
3553 SQLITE_API int sqlite3_prepare(
3554 sqlite3 *db, /* Database handle */
3555 const char *zSql, /* SQL statement, UTF-8 encoded */
@@ -3613,18 +3560,10 @@
3560 SQLITE_API int sqlite3_prepare_v2(
3561 sqlite3 *db, /* Database handle */
3562 const char *zSql, /* SQL statement, UTF-8 encoded */
3563 int nByte, /* Maximum length of zSql in bytes. */
3564 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
 
 
 
 
 
 
 
 
3565 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3566 );
3567 SQLITE_API int sqlite3_prepare16(
3568 sqlite3 *db, /* Database handle */
3569 const void *zSql, /* SQL statement, UTF-16 encoded */
@@ -3637,27 +3576,18 @@
3576 const void *zSql, /* SQL statement, UTF-16 encoded */
3577 int nByte, /* Maximum length of zSql in bytes. */
3578 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3579 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3580 );
 
 
 
 
 
 
 
 
3581
3582 /*
3583 ** CAPI3REF: Retrieving Statement SQL
3584 ** METHOD: sqlite3_stmt
3585 **
3586 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
3587 ** SQL text used to create [prepared statement] P if P was
3588 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
3589 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3590 ** string containing the SQL text of prepared statement P with
3591 ** [bound parameters] expanded.
3592 **
3593 ** ^(For example, if a prepared statement is created using the SQL
@@ -3799,11 +3729,11 @@
3729 ** CAPI3REF: Binding Values To Prepared Statements
3730 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3731 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3732 ** METHOD: sqlite3_stmt
3733 **
3734 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3735 ** literals may be replaced by a [parameter] that matches one of following
3736 ** templates:
3737 **
3738 ** <ul>
3739 ** <li> ?
@@ -3818,11 +3748,11 @@
3748 ** parameters (also called "host parameter names" or "SQL parameters")
3749 ** can be set using the sqlite3_bind_*() routines defined here.
3750 **
3751 ** ^The first argument to the sqlite3_bind_*() routines is always
3752 ** a pointer to the [sqlite3_stmt] object returned from
3753 ** [sqlite3_prepare_v2()] or its variants.
3754 **
3755 ** ^The second argument is the index of the SQL parameter to be set.
3756 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3757 ** SQL parameter is used more than once, second and subsequent
3758 ** occurrences have the same index as the first occurrence.
@@ -3955,12 +3885,12 @@
3885 ** ^The first host parameter has an index of 1, not 0.
3886 **
3887 ** ^If the value N is out of range or if the N-th parameter is
3888 ** nameless, then NULL is returned. ^The returned string is
3889 ** always in UTF-8 encoding even if the named parameter was
3890 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
3891 ** [sqlite3_prepare16_v2()].
3892 **
3893 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3894 ** [sqlite3_bind_parameter_count()], and
3895 ** [sqlite3_bind_parameter_index()].
3896 */
@@ -3973,12 +3903,11 @@
3903 ** ^Return the index of an SQL parameter given its name. ^The
3904 ** index value returned is suitable for use as the second
3905 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3906 ** is returned if no matching parameter is found. ^The parameter
3907 ** name must be given in UTF-8 even if the original statement
3908 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
 
3909 **
3910 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3911 ** [sqlite3_bind_parameter_count()], and
3912 ** [sqlite3_bind_parameter_name()].
3913 */
@@ -4128,22 +4057,20 @@
4057
4058 /*
4059 ** CAPI3REF: Evaluate An SQL Statement
4060 ** METHOD: sqlite3_stmt
4061 **
4062 ** After a [prepared statement] has been prepared using either
4063 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
 
4064 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
4065 ** must be called one or more times to evaluate the statement.
4066 **
4067 ** The details of the behavior of the sqlite3_step() interface depend
4068 ** on whether the statement was prepared using the newer "v2" interface
4069 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
4070 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
4071 ** new "v2" interface is recommended for new applications but the legacy
 
4072 ** interface will continue to be supported.
4073 **
4074 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
4075 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
4076 ** ^With the "v2" interface, any of the other [result codes] or
@@ -4200,15 +4127,14 @@
4127 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call
4128 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
4129 ** specific [error codes] that better describes the error.
4130 ** We admit that this is a goofy design. The problem has been fixed
4131 ** with the "v2" interface. If you prepare all of your SQL statements
4132 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
 
4133 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4134 ** then the more specific [error codes] are returned directly
4135 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4136 */
4137 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4138
4139 /*
4140 ** CAPI3REF: Number of columns in a result set
@@ -4269,11 +4195,11 @@
4195 ** METHOD: sqlite3_stmt
4196 **
4197 ** ^These routines return information about a single column of the current
4198 ** result row of a query. ^In every case the first argument is a pointer
4199 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4200 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
4201 ** and the second argument is the index of the column for which information
4202 ** should be returned. ^The leftmost column of the result set has the index 0.
4203 ** ^The number of columns in the result can be determined using
4204 ** [sqlite3_column_count()].
4205 **
@@ -5393,11 +5319,11 @@
5319 **
5320 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5321 ** to which a [prepared statement] belongs. ^The [database connection]
5322 ** returned by sqlite3_db_handle is the same [database connection]
5323 ** that was the first argument
5324 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5325 ** create the statement in the first place.
5326 */
5327 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5328
5329 /*
@@ -5469,11 +5395,11 @@
5395 ** the database connection that invoked the callback. Any actions
5396 ** to modify the database connection must be deferred until after the
5397 ** completion of the [sqlite3_step()] call that triggered the commit
5398 ** or rollback hook in the first place.
5399 ** Note that running any other SQL statements, including SELECT statements,
5400 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
5401 ** the database connections for the meaning of "modify" in this paragraph.
5402 **
5403 ** ^Registering a NULL function disables the callback.
5404 **
5405 ** ^When the commit hook callback routine returns zero, the [COMMIT]
@@ -5529,11 +5455,11 @@
5455 **
5456 ** The update hook implementation must not do anything that will modify
5457 ** the database connection that invoked the update hook. Any actions
5458 ** to modify the database connection must be deferred until after the
5459 ** completion of the [sqlite3_step()] call that triggered the update hook.
5460 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
5461 ** database connections for the meaning of "modify" in this paragraph.
5462 **
5463 ** ^The sqlite3_update_hook(D,C,P) function
5464 ** returns the P argument from the previous call
5465 ** on the same [database connection] D, or NULL for
@@ -5692,13 +5618,11 @@
5618 ** column exists. ^The sqlite3_table_column_metadata() interface returns
5619 ** SQLITE_ERROR and if the specified column does not exist.
5620 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
5621 ** NULL pointer, then this routine simply checks for the existence of the
5622 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
5623 ** does not.
 
 
5624 **
5625 ** ^The column is identified by the second, third and fourth parameters to
5626 ** this function. ^(The second parameter is either the name of the database
5627 ** (i.e. "main", "temp", or an attached database) containing the specified
5628 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
@@ -7207,38 +7131,17 @@
7131 ** by the prepared statement if that number is less than or equal
7132 ** to 2147483647. The number of virtual machine operations can be
7133 ** used as a proxy for the total work done by the prepared statement.
7134 ** If the number of virtual machine operations exceeds 2147483647
7135 ** then the value returned by this statement status code is undefined.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7136 ** </dd>
7137 ** </dl>
7138 */
7139 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
7140 #define SQLITE_STMTSTATUS_SORT 2
7141 #define SQLITE_STMTSTATUS_AUTOINDEX 3
7142 #define SQLITE_STMTSTATUS_VM_STEP 4
 
 
 
7143
7144 /*
7145 ** CAPI3REF: Custom Page Cache Object
7146 **
7147 ** The sqlite3_pcache type is opaque. It is implemented by
7148
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,11 +1,11 @@
11
<title>Change Log</title>
22
33
<a name='v2_3'></a>
44
<h2>Changes for Version 2.3 (2017-07-21)</h2>
55
6
- * Update the built-in SQLite to version 3.20.0 (beta).
6
+ * Update the built-in SQLite to version 3.19.3.
77
* Update internal Unicode character tables, used in regular expression
88
handling, from version 9.0 to 10.0.
99
* Show the last-sync-URL on the [/help?cmd=/urllist|/urllist] page.
1010
* Added the "Event Summary" activity report.
1111
[/reports?type=ci&view=lastchng|example]
1212
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,11 +1,11 @@
1 <title>Change Log</title>
2
3 <a name='v2_3'></a>
4 <h2>Changes for Version 2.3 (2017-07-21)</h2>
5
6 * Update the built-in SQLite to version 3.20.0 (beta).
7 * Update internal Unicode character tables, used in regular expression
8 handling, from version 9.0 to 10.0.
9 * Show the last-sync-URL on the [/help?cmd=/urllist|/urllist] page.
10 * Added the "Event Summary" activity report.
11 [/reports?type=ci&view=lastchng|example]
12
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,11 +1,11 @@
1 <title>Change Log</title>
2
3 <a name='v2_3'></a>
4 <h2>Changes for Version 2.3 (2017-07-21)</h2>
5
6 * Update the built-in SQLite to version 3.19.3.
7 * Update internal Unicode character tables, used in regular expression
8 handling, from version 9.0 to 10.0.
9 * Show the last-sync-URL on the [/help?cmd=/urllist|/urllist] page.
10 * Added the "Event Summary" activity report.
11 [/reports?type=ci&view=lastchng|example]
12

Keyboard Shortcuts

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