Fossil SCM

Merged with trunk.

vor0nwe 2018-11-13 20:52 vor0nwe-wiki-wysiwyg merge
Commit c70d8abea76aab19a53468f9c64e54487c88b156a69a2a0fa80dffed71d71526
--- src/backoffice.c
+++ src/backoffice.c
@@ -393,10 +393,17 @@
393393
}else{
394394
/* We need to run backup to be (at a minimum) on-deck */
395395
backofficeDb = fossil_strdup(g.zRepositoryName);
396396
}
397397
}
398
+
399
+/*
400
+** Call this routine to disable backoffice
401
+*/
402
+void backoffice_disable(void){
403
+ backofficeDb = "x";
404
+}
398405
399406
/*
400407
** Check for errors prior to running backoffice_thread() or backoffice_run().
401408
*/
402409
static void backoffice_error_check_one(int *pOnce){
@@ -431,10 +438,11 @@
431438
sqlite3_uint64 idSelf;
432439
int lastWarning = 0;
433440
int warningDelay = 30;
434441
static int once = 0;
435442
443
+ if( sqlite3_db_readonly(g.db, 0) ) return;
436444
backoffice_error_check_one(&once);
437445
idSelf = backofficeProcessId();
438446
while(1){
439447
tmNow = time(0);
440448
db_begin_write();
441449
--- src/backoffice.c
+++ src/backoffice.c
@@ -393,10 +393,17 @@
393 }else{
394 /* We need to run backup to be (at a minimum) on-deck */
395 backofficeDb = fossil_strdup(g.zRepositoryName);
396 }
397 }
 
 
 
 
 
 
 
398
399 /*
400 ** Check for errors prior to running backoffice_thread() or backoffice_run().
401 */
402 static void backoffice_error_check_one(int *pOnce){
@@ -431,10 +438,11 @@
431 sqlite3_uint64 idSelf;
432 int lastWarning = 0;
433 int warningDelay = 30;
434 static int once = 0;
435
 
436 backoffice_error_check_one(&once);
437 idSelf = backofficeProcessId();
438 while(1){
439 tmNow = time(0);
440 db_begin_write();
441
--- src/backoffice.c
+++ src/backoffice.c
@@ -393,10 +393,17 @@
393 }else{
394 /* We need to run backup to be (at a minimum) on-deck */
395 backofficeDb = fossil_strdup(g.zRepositoryName);
396 }
397 }
398
399 /*
400 ** Call this routine to disable backoffice
401 */
402 void backoffice_disable(void){
403 backofficeDb = "x";
404 }
405
406 /*
407 ** Check for errors prior to running backoffice_thread() or backoffice_run().
408 */
409 static void backoffice_error_check_one(int *pOnce){
@@ -431,10 +438,11 @@
438 sqlite3_uint64 idSelf;
439 int lastWarning = 0;
440 int warningDelay = 30;
441 static int once = 0;
442
443 if( sqlite3_db_readonly(g.db, 0) ) return;
444 backoffice_error_check_one(&once);
445 idSelf = backofficeProcessId();
446 while(1){
447 tmNow = time(0);
448 db_begin_write();
449
--- src/bisect.c
+++ src/bisect.c
@@ -385,15 +385,18 @@
385385
bisect_path();
386386
pMid = path_midpoint();
387387
if( pMid==0 ){
388388
fossil_print("bisect complete\n");
389389
}else{
390
+ int nSpan = path_length();
391
+ int nStep = path_search_depth();
390392
g.argv[1] = "update";
391393
g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid);
392394
g.argc = 3;
393395
g.fNoSync = 1;
394396
update_cmd();
397
+ fossil_print("span: %d steps-remaining: %d\n", nSpan, nStep);
395398
}
396399
397400
if( strncmp(zDisplay,"chart",m)==0 ){
398401
bisect_chart(1);
399402
}else if( strncmp(zDisplay, "log", m)==0 ){
400403
--- src/bisect.c
+++ src/bisect.c
@@ -385,15 +385,18 @@
385 bisect_path();
386 pMid = path_midpoint();
387 if( pMid==0 ){
388 fossil_print("bisect complete\n");
389 }else{
 
 
390 g.argv[1] = "update";
391 g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid);
392 g.argc = 3;
393 g.fNoSync = 1;
394 update_cmd();
 
395 }
396
397 if( strncmp(zDisplay,"chart",m)==0 ){
398 bisect_chart(1);
399 }else if( strncmp(zDisplay, "log", m)==0 ){
400
--- src/bisect.c
+++ src/bisect.c
@@ -385,15 +385,18 @@
385 bisect_path();
386 pMid = path_midpoint();
387 if( pMid==0 ){
388 fossil_print("bisect complete\n");
389 }else{
390 int nSpan = path_length();
391 int nStep = path_search_depth();
392 g.argv[1] = "update";
393 g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid);
394 g.argc = 3;
395 g.fNoSync = 1;
396 update_cmd();
397 fossil_print("span: %d steps-remaining: %d\n", nSpan, nStep);
398 }
399
400 if( strncmp(zDisplay,"chart",m)==0 ){
401 bisect_chart(1);
402 }else if( strncmp(zDisplay, "log", m)==0 ){
403
+75 -57
--- src/branch.c
+++ src/branch.c
@@ -178,21 +178,64 @@
178178
db_end_transaction(0);
179179
180180
/* Do an autosync push, if requested */
181181
if( !isPrivate ) autosync_loop(SYNC_PUSH, db_get_int("autosync-tries",1),0);
182182
}
183
+
184
+/*
185
+** Create a TEMP table named "tmp_brlist" with 7 columns:
186
+**
187
+** name Name of the branch
188
+** mtime Time of last checkin on this branch
189
+** isclosed True if the branch is closed
190
+** mergeto Another branch this branch was merged into
191
+** nckin Number of checkins on this branch
192
+** ckin Hash of the last checkin on this branch
193
+** bgclr Background color for this branch
194
+*/
195
+static const char createBrlistQuery[] =
196
+@ CREATE TEMP TABLE IF NOT EXISTS tmp_brlist AS
197
+@ SELECT
198
+@ tagxref.value AS name,
199
+@ max(event.mtime) AS mtime,
200
+@ EXISTS(SELECT 1 FROM tagxref AS tx
201
+@ WHERE tx.rid=tagxref.rid
202
+@ AND tx.tagid=(SELECT tagid FROM tag WHERE tagname='closed')
203
+@ AND tx.tagtype>0) AS isclosed,
204
+@ (SELECT tagxref.value
205
+@ FROM plink CROSS JOIN tagxref
206
+@ WHERE plink.pid=event.objid
207
+@ AND tagxref.rid=plink.cid
208
+@ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch')
209
+@ AND tagtype>0) AS mergeto,
210
+@ count(*) AS nckin,
211
+@ (SELECT uuid FROM blob WHERE rid=tagxref.rid) AS ckin,
212
+@ event.bgcolor AS bgclr
213
+@ FROM tagxref, tag, event
214
+@ WHERE tagxref.tagid=tag.tagid
215
+@ AND tagxref.tagtype>0
216
+@ AND tag.tagname='branch'
217
+@ AND event.objid=tagxref.rid
218
+@ GROUP BY 1;
219
+;
220
+
221
+/* Call this routine to create the TEMP table */
222
+static void brlist_create_temp_table(void){
223
+ db_multi_exec(createBrlistQuery/*works-like:""*/);
224
+}
225
+
183226
184227
#if INTERFACE
185228
/*
186229
** Allows bits in the mBplqFlags parameter to branch_prepare_list_query().
187230
*/
188231
#define BRL_CLOSED_ONLY 0x001 /* Show only closed branches */
189232
#define BRL_OPEN_ONLY 0x002 /* Show only open branches */
190233
#define BRL_BOTH 0x003 /* Show both open and closed branches */
191234
#define BRL_OPEN_CLOSED_MASK 0x003
192
-#define BRL_MTIME 0x004 /* Include lastest check-in time */
193
-#define BRL_ORDERBY_MTIME 0x008 /* Sort by MTIME. (otherwise sort by name)*/
235
+#define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
236
+#define BRL_REVERSE 0x008 /* Reverse the sort order */
194237
195238
#endif /* INTERFACE */
196239
197240
/*
198241
** Prepare a query that will list branches.
@@ -200,47 +243,43 @@
200243
** If (which<0) then the query pulls only closed branches. If
201244
** (which>0) then the query pulls all (closed and opened)
202245
** branches. Else the query pulls currently-opened branches.
203246
*/
204247
void branch_prepare_list_query(Stmt *pQuery, int brFlags){
248
+ Blob sql;
249
+ blob_init(&sql, 0, 0);
250
+ brlist_create_temp_table();
205251
switch( brFlags & BRL_OPEN_CLOSED_MASK ){
206252
case BRL_CLOSED_ONLY: {
207
- db_prepare(pQuery,
208
- "SELECT value FROM tagxref"
209
- " WHERE tagid=%d AND value NOT NULL "
210
- "EXCEPT "
211
- "SELECT value FROM tagxref"
212
- " WHERE tagid=%d"
213
- " AND rid IN leaf"
214
- " AND NOT %z"
215
- " ORDER BY value COLLATE nocase /*sort*/",
216
- TAG_BRANCH, TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
253
+ blob_append_sql(&sql,
254
+ "SELECT name FROM tmp_brlist WHERE isclosed"
217255
);
218256
break;
219257
}
220258
case BRL_BOTH: {
221
- db_prepare(pQuery,
222
- "SELECT DISTINCT value FROM tagxref"
223
- " WHERE tagid=%d AND value NOT NULL"
224
- " AND rid IN leaf"
225
- " ORDER BY value COLLATE nocase /*sort*/",
226
- TAG_BRANCH
259
+ blob_append_sql(&sql,
260
+ "SELECT name FROM tmp_brlist"
227261
);
228262
break;
229263
}
230264
case BRL_OPEN_ONLY: {
231
- db_prepare(pQuery,
232
- "SELECT DISTINCT value FROM tagxref"
233
- " WHERE tagid=%d AND value NOT NULL"
234
- " AND rid IN leaf"
235
- " AND NOT %z"
236
- " ORDER BY value COLLATE nocase /*sort*/",
237
- TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
265
+ blob_append_sql(&sql,
266
+ "SELECT name FROM tmp_brlist WHERE NOT isclosed"
238267
);
239268
break;
240269
}
241270
}
271
+ if( brFlags & BRL_ORDERBY_MTIME ){
272
+ blob_append_sql(&sql, " ORDER BY -mtime");
273
+ }else{
274
+ blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
275
+ }
276
+ if( brFlags & BRL_REVERSE ){
277
+ blob_append_sql(&sql," DESC");
278
+ }
279
+ db_prepare_blob(pQuery, &sql);
280
+ blob_reset(&sql);
242281
}
243282
244283
/*
245284
** If the branch named in the argument is open, return a RID for one of
246285
** the open leaves of that branch. If the branch does not exists or is
@@ -276,15 +315,17 @@
276315
**
277316
** fossil branch info BRANCH-NAME
278317
**
279318
** Print information about a branch
280319
**
281
-** fossil branch list|ls ?-a|--all|-c|--closed?
320
+** fossil branch list|ls ?OPTIONS?
282321
**
283
-** List all branches. Use -a or --all to list all branches and
284
-** -c or --closed to list all closed branches. The default is to
285
-** show only open branches.
322
+** List all branches. Options:
323
+** -a|--all List all branches. Default show only open branches
324
+** -c|--closed List closed branches.
325
+** -r Reverse the sort order
326
+** -t Show recently changed branches first
286327
**
287328
** fossil branch new BRANCH-NAME BASIS ?OPTIONS?
288329
**
289330
** Create a new branch BRANCH-NAME off of check-in BASIS.
290331
** Supported options for this subcommand include:
@@ -345,10 +386,12 @@
345386
int vid;
346387
char *zCurrent = 0;
347388
int brFlags = BRL_OPEN_ONLY;
348389
if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
349390
if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
391
+ if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
392
+ if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
350393
351394
if( g.localOpen ){
352395
vid = db_lget_int("checkout", 0);
353396
zCurrent = db_text(0, "SELECT value FROM tagxref"
354397
" WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
@@ -366,36 +409,10 @@
366409
fossil_fatal("branch subcommand should be one of: "
367410
"current info list ls new");
368411
}
369412
}
370413
371
-static const char brlistQuery[] =
372
-@ SELECT
373
-@ tagxref.value,
374
-@ max(event.mtime),
375
-@ EXISTS(SELECT 1 FROM tagxref AS tx
376
-@ WHERE tx.rid=tagxref.rid
377
-@ AND tx.tagid=(SELECT tagid FROM tag WHERE tagname='closed')
378
-@ AND tx.tagtype>0),
379
-@ (SELECT tagxref.value
380
-@ FROM plink CROSS JOIN tagxref
381
-@ WHERE plink.pid=event.objid
382
-@ AND tagxref.rid=plink.cid
383
-@ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch')
384
-@ AND tagtype>0),
385
-@ count(*),
386
-@ (SELECT uuid FROM blob WHERE rid=tagxref.rid),
387
-@ event.bgcolor
388
-@ FROM tagxref, tag, event
389
-@ WHERE tagxref.tagid=tag.tagid
390
-@ AND tagxref.tagtype>0
391
-@ AND tag.tagname='branch'
392
-@ AND event.objid=tagxref.rid
393
-@ GROUP BY 1
394
-@ ORDER BY 2 DESC;
395
-;
396
-
397414
/*
398415
** This is the new-style branch-list page that shows the branch names
399416
** together with their ages (time of last check-in) and whether or not
400417
** they are closed or merged to another branch.
401418
**
@@ -411,11 +428,12 @@
411428
style_header("Branches");
412429
style_adunit_config(ADUNIT_RIGHT_OK);
413430
style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
414431
login_anonymous_available();
415432
416
- db_prepare(&q, brlistQuery/*works-like:""*/);
433
+ brlist_create_temp_table();
434
+ db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
417435
rNow = db_double(0.0, "SELECT julianday('now')");
418436
@ <div class="brlist">
419437
@ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
420438
@ <thead><tr>
421439
@ <th>Branch Name</th>
@@ -446,11 +464,11 @@
446464
@ <tr style="background-color:%s(zBgClr)">
447465
}else{
448466
@ <tr>
449467
}
450468
@ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
451
- @ <td data-sortkey="%016llx(-iMtime)">%s(zAge)</td>
469
+ @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
452470
@ <td>%d(nCkin)</td>
453471
fossil_free(zAge);
454472
@ <td>%s(isClosed?"closed":"")</td>
455473
if( zMergeTo ){
456474
@ <td>merged into
457475
--- src/branch.c
+++ src/branch.c
@@ -178,21 +178,64 @@
178 db_end_transaction(0);
179
180 /* Do an autosync push, if requested */
181 if( !isPrivate ) autosync_loop(SYNC_PUSH, db_get_int("autosync-tries",1),0);
182 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
184 #if INTERFACE
185 /*
186 ** Allows bits in the mBplqFlags parameter to branch_prepare_list_query().
187 */
188 #define BRL_CLOSED_ONLY 0x001 /* Show only closed branches */
189 #define BRL_OPEN_ONLY 0x002 /* Show only open branches */
190 #define BRL_BOTH 0x003 /* Show both open and closed branches */
191 #define BRL_OPEN_CLOSED_MASK 0x003
192 #define BRL_MTIME 0x004 /* Include lastest check-in time */
193 #define BRL_ORDERBY_MTIME 0x008 /* Sort by MTIME. (otherwise sort by name)*/
194
195 #endif /* INTERFACE */
196
197 /*
198 ** Prepare a query that will list branches.
@@ -200,47 +243,43 @@
200 ** If (which<0) then the query pulls only closed branches. If
201 ** (which>0) then the query pulls all (closed and opened)
202 ** branches. Else the query pulls currently-opened branches.
203 */
204 void branch_prepare_list_query(Stmt *pQuery, int brFlags){
 
 
 
205 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
206 case BRL_CLOSED_ONLY: {
207 db_prepare(pQuery,
208 "SELECT value FROM tagxref"
209 " WHERE tagid=%d AND value NOT NULL "
210 "EXCEPT "
211 "SELECT value FROM tagxref"
212 " WHERE tagid=%d"
213 " AND rid IN leaf"
214 " AND NOT %z"
215 " ORDER BY value COLLATE nocase /*sort*/",
216 TAG_BRANCH, TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
217 );
218 break;
219 }
220 case BRL_BOTH: {
221 db_prepare(pQuery,
222 "SELECT DISTINCT value FROM tagxref"
223 " WHERE tagid=%d AND value NOT NULL"
224 " AND rid IN leaf"
225 " ORDER BY value COLLATE nocase /*sort*/",
226 TAG_BRANCH
227 );
228 break;
229 }
230 case BRL_OPEN_ONLY: {
231 db_prepare(pQuery,
232 "SELECT DISTINCT value FROM tagxref"
233 " WHERE tagid=%d AND value NOT NULL"
234 " AND rid IN leaf"
235 " AND NOT %z"
236 " ORDER BY value COLLATE nocase /*sort*/",
237 TAG_BRANCH, leaf_is_closed_sql("tagxref.rid")
238 );
239 break;
240 }
241 }
 
 
 
 
 
 
 
 
 
 
242 }
243
244 /*
245 ** If the branch named in the argument is open, return a RID for one of
246 ** the open leaves of that branch. If the branch does not exists or is
@@ -276,15 +315,17 @@
276 **
277 ** fossil branch info BRANCH-NAME
278 **
279 ** Print information about a branch
280 **
281 ** fossil branch list|ls ?-a|--all|-c|--closed?
282 **
283 ** List all branches. Use -a or --all to list all branches and
284 ** -c or --closed to list all closed branches. The default is to
285 ** show only open branches.
 
 
286 **
287 ** fossil branch new BRANCH-NAME BASIS ?OPTIONS?
288 **
289 ** Create a new branch BRANCH-NAME off of check-in BASIS.
290 ** Supported options for this subcommand include:
@@ -345,10 +386,12 @@
345 int vid;
346 char *zCurrent = 0;
347 int brFlags = BRL_OPEN_ONLY;
348 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
349 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
 
 
350
351 if( g.localOpen ){
352 vid = db_lget_int("checkout", 0);
353 zCurrent = db_text(0, "SELECT value FROM tagxref"
354 " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
@@ -366,36 +409,10 @@
366 fossil_fatal("branch subcommand should be one of: "
367 "current info list ls new");
368 }
369 }
370
371 static const char brlistQuery[] =
372 @ SELECT
373 @ tagxref.value,
374 @ max(event.mtime),
375 @ EXISTS(SELECT 1 FROM tagxref AS tx
376 @ WHERE tx.rid=tagxref.rid
377 @ AND tx.tagid=(SELECT tagid FROM tag WHERE tagname='closed')
378 @ AND tx.tagtype>0),
379 @ (SELECT tagxref.value
380 @ FROM plink CROSS JOIN tagxref
381 @ WHERE plink.pid=event.objid
382 @ AND tagxref.rid=plink.cid
383 @ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch')
384 @ AND tagtype>0),
385 @ count(*),
386 @ (SELECT uuid FROM blob WHERE rid=tagxref.rid),
387 @ event.bgcolor
388 @ FROM tagxref, tag, event
389 @ WHERE tagxref.tagid=tag.tagid
390 @ AND tagxref.tagtype>0
391 @ AND tag.tagname='branch'
392 @ AND event.objid=tagxref.rid
393 @ GROUP BY 1
394 @ ORDER BY 2 DESC;
395 ;
396
397 /*
398 ** This is the new-style branch-list page that shows the branch names
399 ** together with their ages (time of last check-in) and whether or not
400 ** they are closed or merged to another branch.
401 **
@@ -411,11 +428,12 @@
411 style_header("Branches");
412 style_adunit_config(ADUNIT_RIGHT_OK);
413 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
414 login_anonymous_available();
415
416 db_prepare(&q, brlistQuery/*works-like:""*/);
 
417 rNow = db_double(0.0, "SELECT julianday('now')");
418 @ <div class="brlist">
419 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
420 @ <thead><tr>
421 @ <th>Branch Name</th>
@@ -446,11 +464,11 @@
446 @ <tr style="background-color:%s(zBgClr)">
447 }else{
448 @ <tr>
449 }
450 @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
451 @ <td data-sortkey="%016llx(-iMtime)">%s(zAge)</td>
452 @ <td>%d(nCkin)</td>
453 fossil_free(zAge);
454 @ <td>%s(isClosed?"closed":"")</td>
455 if( zMergeTo ){
456 @ <td>merged into
457
--- src/branch.c
+++ src/branch.c
@@ -178,21 +178,64 @@
178 db_end_transaction(0);
179
180 /* Do an autosync push, if requested */
181 if( !isPrivate ) autosync_loop(SYNC_PUSH, db_get_int("autosync-tries",1),0);
182 }
183
184 /*
185 ** Create a TEMP table named "tmp_brlist" with 7 columns:
186 **
187 ** name Name of the branch
188 ** mtime Time of last checkin on this branch
189 ** isclosed True if the branch is closed
190 ** mergeto Another branch this branch was merged into
191 ** nckin Number of checkins on this branch
192 ** ckin Hash of the last checkin on this branch
193 ** bgclr Background color for this branch
194 */
195 static const char createBrlistQuery[] =
196 @ CREATE TEMP TABLE IF NOT EXISTS tmp_brlist AS
197 @ SELECT
198 @ tagxref.value AS name,
199 @ max(event.mtime) AS mtime,
200 @ EXISTS(SELECT 1 FROM tagxref AS tx
201 @ WHERE tx.rid=tagxref.rid
202 @ AND tx.tagid=(SELECT tagid FROM tag WHERE tagname='closed')
203 @ AND tx.tagtype>0) AS isclosed,
204 @ (SELECT tagxref.value
205 @ FROM plink CROSS JOIN tagxref
206 @ WHERE plink.pid=event.objid
207 @ AND tagxref.rid=plink.cid
208 @ AND tagxref.tagid=(SELECT tagid FROM tag WHERE tagname='branch')
209 @ AND tagtype>0) AS mergeto,
210 @ count(*) AS nckin,
211 @ (SELECT uuid FROM blob WHERE rid=tagxref.rid) AS ckin,
212 @ event.bgcolor AS bgclr
213 @ FROM tagxref, tag, event
214 @ WHERE tagxref.tagid=tag.tagid
215 @ AND tagxref.tagtype>0
216 @ AND tag.tagname='branch'
217 @ AND event.objid=tagxref.rid
218 @ GROUP BY 1;
219 ;
220
221 /* Call this routine to create the TEMP table */
222 static void brlist_create_temp_table(void){
223 db_multi_exec(createBrlistQuery/*works-like:""*/);
224 }
225
226
227 #if INTERFACE
228 /*
229 ** Allows bits in the mBplqFlags parameter to branch_prepare_list_query().
230 */
231 #define BRL_CLOSED_ONLY 0x001 /* Show only closed branches */
232 #define BRL_OPEN_ONLY 0x002 /* Show only open branches */
233 #define BRL_BOTH 0x003 /* Show both open and closed branches */
234 #define BRL_OPEN_CLOSED_MASK 0x003
235 #define BRL_ORDERBY_MTIME 0x004 /* Sort by MTIME. (otherwise sort by name)*/
236 #define BRL_REVERSE 0x008 /* Reverse the sort order */
237
238 #endif /* INTERFACE */
239
240 /*
241 ** Prepare a query that will list branches.
@@ -200,47 +243,43 @@
243 ** If (which<0) then the query pulls only closed branches. If
244 ** (which>0) then the query pulls all (closed and opened)
245 ** branches. Else the query pulls currently-opened branches.
246 */
247 void branch_prepare_list_query(Stmt *pQuery, int brFlags){
248 Blob sql;
249 blob_init(&sql, 0, 0);
250 brlist_create_temp_table();
251 switch( brFlags & BRL_OPEN_CLOSED_MASK ){
252 case BRL_CLOSED_ONLY: {
253 blob_append_sql(&sql,
254 "SELECT name FROM tmp_brlist WHERE isclosed"
 
 
 
 
 
 
 
 
255 );
256 break;
257 }
258 case BRL_BOTH: {
259 blob_append_sql(&sql,
260 "SELECT name FROM tmp_brlist"
 
 
 
 
261 );
262 break;
263 }
264 case BRL_OPEN_ONLY: {
265 blob_append_sql(&sql,
266 "SELECT name FROM tmp_brlist WHERE NOT isclosed"
 
 
 
 
 
267 );
268 break;
269 }
270 }
271 if( brFlags & BRL_ORDERBY_MTIME ){
272 blob_append_sql(&sql, " ORDER BY -mtime");
273 }else{
274 blob_append_sql(&sql, " ORDER BY name COLLATE nocase");
275 }
276 if( brFlags & BRL_REVERSE ){
277 blob_append_sql(&sql," DESC");
278 }
279 db_prepare_blob(pQuery, &sql);
280 blob_reset(&sql);
281 }
282
283 /*
284 ** If the branch named in the argument is open, return a RID for one of
285 ** the open leaves of that branch. If the branch does not exists or is
@@ -276,15 +315,17 @@
315 **
316 ** fossil branch info BRANCH-NAME
317 **
318 ** Print information about a branch
319 **
320 ** fossil branch list|ls ?OPTIONS?
321 **
322 ** List all branches. Options:
323 ** -a|--all List all branches. Default show only open branches
324 ** -c|--closed List closed branches.
325 ** -r Reverse the sort order
326 ** -t Show recently changed branches first
327 **
328 ** fossil branch new BRANCH-NAME BASIS ?OPTIONS?
329 **
330 ** Create a new branch BRANCH-NAME off of check-in BASIS.
331 ** Supported options for this subcommand include:
@@ -345,10 +386,12 @@
386 int vid;
387 char *zCurrent = 0;
388 int brFlags = BRL_OPEN_ONLY;
389 if( find_option("all","a",0)!=0 ) brFlags = BRL_BOTH;
390 if( find_option("closed","c",0)!=0 ) brFlags = BRL_CLOSED_ONLY;
391 if( find_option("t",0,0)!=0 ) brFlags |= BRL_ORDERBY_MTIME;
392 if( find_option("r",0,0)!=0 ) brFlags |= BRL_REVERSE;
393
394 if( g.localOpen ){
395 vid = db_lget_int("checkout", 0);
396 zCurrent = db_text(0, "SELECT value FROM tagxref"
397 " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH);
@@ -366,36 +409,10 @@
409 fossil_fatal("branch subcommand should be one of: "
410 "current info list ls new");
411 }
412 }
413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414 /*
415 ** This is the new-style branch-list page that shows the branch names
416 ** together with their ages (time of last check-in) and whether or not
417 ** they are closed or merged to another branch.
418 **
@@ -411,11 +428,12 @@
428 style_header("Branches");
429 style_adunit_config(ADUNIT_RIGHT_OK);
430 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
431 login_anonymous_available();
432
433 brlist_create_temp_table();
434 db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
435 rNow = db_double(0.0, "SELECT julianday('now')");
436 @ <div class="brlist">
437 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
438 @ <thead><tr>
439 @ <th>Branch Name</th>
@@ -446,11 +464,11 @@
464 @ <tr style="background-color:%s(zBgClr)">
465 }else{
466 @ <tr>
467 }
468 @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
469 @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td>
470 @ <td>%d(nCkin)</td>
471 fossil_free(zAge);
472 @ <td>%s(isClosed?"closed":"")</td>
473 if( zMergeTo ){
474 @ <td>merged into
475
--- src/forum.c
+++ src/forum.c
@@ -973,10 +973,16 @@
973973
return;
974974
}
975975
style_header("Forum");
976976
if( g.perm.WrForum ){
977977
style_submenu_element("New Thread","%R/forumnew");
978
+ }else{
979
+ /* Can't combine this with previous case using the ternary operator
980
+ * because that causes an error yelling about "non-constant format"
981
+ * with some compilers. I can't see it, since both expressions have
982
+ * the same format, but I'm no C spec lawyer. */
983
+ style_submenu_element("New Thread","%R/login");
978984
}
979985
if( g.perm.ModForum && moderation_needed() ){
980986
style_submenu_element("Moderation Requests", "%R/modreq");
981987
}
982988
if( (srchFlags & SRCH_FORUM)!=0 ){
983989
--- src/forum.c
+++ src/forum.c
@@ -973,10 +973,16 @@
973 return;
974 }
975 style_header("Forum");
976 if( g.perm.WrForum ){
977 style_submenu_element("New Thread","%R/forumnew");
 
 
 
 
 
 
978 }
979 if( g.perm.ModForum && moderation_needed() ){
980 style_submenu_element("Moderation Requests", "%R/modreq");
981 }
982 if( (srchFlags & SRCH_FORUM)!=0 ){
983
--- src/forum.c
+++ src/forum.c
@@ -973,10 +973,16 @@
973 return;
974 }
975 style_header("Forum");
976 if( g.perm.WrForum ){
977 style_submenu_element("New Thread","%R/forumnew");
978 }else{
979 /* Can't combine this with previous case using the ternary operator
980 * because that causes an error yelling about "non-constant format"
981 * with some compilers. I can't see it, since both expressions have
982 * the same format, but I'm no C spec lawyer. */
983 style_submenu_element("New Thread","%R/login");
984 }
985 if( g.perm.ModForum && moderation_needed() ){
986 style_submenu_element("Moderation Requests", "%R/modreq");
987 }
988 if( (srchFlags & SRCH_FORUM)!=0 ){
989
+1 -144
--- src/main.c
+++ src/main.c
@@ -1297,154 +1297,10 @@
12971297
}
12981298
#endif
12991299
return zRepo;
13001300
}
13011301
1302
-/*
1303
-** Generate a web-page that lists all repositories located under the
1304
-** g.zRepositoryName directory and return non-zero.
1305
-**
1306
-** For the special case when g.zRepositoryName a non-chroot-jail "/",
1307
-** compose the list using the "repo:" entries in the global_config
1308
-** table of the configuration database. These entries comprise all
1309
-** of the repositories known to the "all" command. The special case
1310
-** processing is disallowed for chroot jails because g.zRepositoryName
1311
-** is always "/" inside a chroot jail and so it cannot be used as a flag
1312
-** to signal the special processing in that case. The special case
1313
-** processing is intended for the "fossil all ui" command which never
1314
-** runs in a chroot jail anyhow.
1315
-**
1316
-** Or, if no repositories can be located beneath g.zRepositoryName,
1317
-** return 0.
1318
-*/
1319
-static int repo_list_page(void){
1320
- Blob base;
1321
- int n = 0;
1322
- int allRepo;
1323
-
1324
- assert( g.db==0 );
1325
- if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
1326
- /* For the special case of the "repository directory" being "/",
1327
- ** show all of the repositories named in the ~/.fossil database.
1328
- **
1329
- ** On unix systems, then entries are of the form "repo:/home/..."
1330
- ** and on Windows systems they are like on unix, starting with a "/"
1331
- ** or they can begin with a drive letter: "repo:C:/Users/...". In either
1332
- ** case, we want returned path to omit any initial "/".
1333
- */
1334
- db_open_config(1, 0);
1335
- db_multi_exec(
1336
- "CREATE TEMP VIEW sfile AS"
1337
- " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config"
1338
- " WHERE name GLOB 'repo:*'"
1339
- );
1340
- allRepo = 1;
1341
- }else{
1342
- /* The default case: All repositories under the g.zRepositoryName
1343
- ** directory.
1344
- */
1345
- blob_init(&base, g.zRepositoryName, -1);
1346
- sqlite3_open(":memory:", &g.db);
1347
- db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
1348
- db_multi_exec("CREATE TABLE vfile(pathname);");
1349
- vfile_scan(&base, blob_size(&base), 0, 0, 0);
1350
- db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
1351
- allRepo = 0;
1352
- }
1353
- @ <html>
1354
- @ <head>
1355
- @ <base href="%s(g.zBaseURL)/" />
1356
- @ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1357
- @ <title>Repository List</title>
1358
- @ </head>
1359
- @ <body>
1360
- n = db_int(0, "SELECT count(*) FROM sfile");
1361
- if( n>0 ){
1362
- Stmt q;
1363
- sqlite3_int64 iNow, iMTime;
1364
- @ <h1 align="center">Fossil Repositories</h1>
1365
- @ <table border="0" class="sortable" data-init-sort="1" \
1366
- @ data-column-types="tnk"><thead>
1367
- @ <tr><th>Filename<th width="20"><th>Last Modified</tr>
1368
- @ </thead><tbody>
1369
- db_prepare(&q, "SELECT pathname"
1370
- " FROM sfile ORDER BY pathname COLLATE nocase;");
1371
- iNow = db_int64(0, "SELECT strftime('%%s','now')");
1372
- while( db_step(&q)==SQLITE_ROW ){
1373
- const char *zName = db_column_text(&q, 0);
1374
- int nName = (int)strlen(zName);
1375
- char *zUrl;
1376
- char *zAge;
1377
- char *zFull;
1378
- if( nName<7 ) continue;
1379
- zUrl = sqlite3_mprintf("%.*s", nName-7, zName);
1380
- if( zName[0]=='/'
1381
-#ifdef _WIN32
1382
- || sqlite3_strglob("[a-zA-Z]:/*", zName)==0
1383
-#endif
1384
- ){
1385
- zFull = mprintf("%s", zName);
1386
- }else if ( allRepo ){
1387
- zFull = mprintf("/%s", zName);
1388
- }else{
1389
- zFull = mprintf("%s/%s", g.zRepositoryName, zName);
1390
- }
1391
- iMTime = file_mtime(zFull, ExtFILE);
1392
- fossil_free(zFull);
1393
- if( iMTime<=0 ){
1394
- zAge = mprintf("...");
1395
- }else{
1396
- zAge = human_readable_age((iNow - iMTime)/86400.0);
1397
- }
1398
- if( sqlite3_strglob("*.fossil", zName)!=0 ){
1399
- /* The "fossil server DIRECTORY" and "fossil ui DIRECTORY" commands
1400
- ** do not work for repositories whose names do not end in ".fossil".
1401
- ** So do not hyperlink those cases. */
1402
- @ <tr><td>%h(zName)
1403
- } else if( sqlite3_strglob("*/.*", zName)==0 ){
1404
- /* Do not show hidden repos */
1405
- @ <tr><td>%h(zName) (hidden)
1406
- } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){
1407
- @ <tr><td><a href="%R/%T(zUrl)/home" target="_blank">/%h(zName)</a>
1408
- }else{
1409
- @ <tr><td><a href="%R/%T(zUrl)/home" target="_blank">%h(zName)</a>
1410
- }
1411
- @ <td></td><td data-sortkey='%010llx(iNow - iMTime)'>%h(zAge)</tr>
1412
- fossil_free(zAge);
1413
- sqlite3_free(zUrl);
1414
- }
1415
- @ </tbody></table>
1416
- }else{
1417
- @ <h1>No Repositories Found</h1>
1418
- }
1419
- @ <script>%s(builtin_text("sorttable.js"))</script>
1420
- @ </body>
1421
- @ </html>
1422
- cgi_reply();
1423
- sqlite3_close(g.db);
1424
- g.db = 0;
1425
- return n;
1426
-}
1427
-
1428
-/*
1429
-** COMMAND: test-list-page
1430
-**
1431
-** Usage: %fossil test-list-page DIRECTORY
1432
-**
1433
-** Show all repositories underneath DIRECTORY. Or if DIRECTORY is "/"
1434
-** show all repositories in the ~/.fossil file.
1435
-*/
1436
-void test_list_page(void){
1437
- if( g.argc<3 ){
1438
- g.zRepositoryName = "/";
1439
- }else{
1440
- g.zRepositoryName = g.argv[2];
1441
- }
1442
- g.httpOut = stdout;
1443
- repo_list_page();
1444
-}
1445
-
14461302
/*
14471303
** Called whenever a crash is encountered while processing a webpage.
14481304
*/
14491305
void sigsegv_handler(int x){
14501306
#if HAVE_BACKTRACE
@@ -2377,10 +2233,11 @@
23772233
g.useLocalauth = find_option("localauth", 0, 0)!=0;
23782234
g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
23792235
g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
23802236
zInFile = find_option("in",0,1);
23812237
if( zInFile ){
2238
+ backoffice_disable();
23822239
g.httpIn = fossil_fopen(zInFile, "rb");
23832240
if( g.httpIn==0 ) fossil_fatal("cannot open \"%s\" for reading", zInFile);
23842241
}else{
23852242
g.httpIn = stdin;
23862243
}
23872244
--- src/main.c
+++ src/main.c
@@ -1297,154 +1297,10 @@
1297 }
1298 #endif
1299 return zRepo;
1300 }
1301
1302 /*
1303 ** Generate a web-page that lists all repositories located under the
1304 ** g.zRepositoryName directory and return non-zero.
1305 **
1306 ** For the special case when g.zRepositoryName a non-chroot-jail "/",
1307 ** compose the list using the "repo:" entries in the global_config
1308 ** table of the configuration database. These entries comprise all
1309 ** of the repositories known to the "all" command. The special case
1310 ** processing is disallowed for chroot jails because g.zRepositoryName
1311 ** is always "/" inside a chroot jail and so it cannot be used as a flag
1312 ** to signal the special processing in that case. The special case
1313 ** processing is intended for the "fossil all ui" command which never
1314 ** runs in a chroot jail anyhow.
1315 **
1316 ** Or, if no repositories can be located beneath g.zRepositoryName,
1317 ** return 0.
1318 */
1319 static int repo_list_page(void){
1320 Blob base;
1321 int n = 0;
1322 int allRepo;
1323
1324 assert( g.db==0 );
1325 if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
1326 /* For the special case of the "repository directory" being "/",
1327 ** show all of the repositories named in the ~/.fossil database.
1328 **
1329 ** On unix systems, then entries are of the form "repo:/home/..."
1330 ** and on Windows systems they are like on unix, starting with a "/"
1331 ** or they can begin with a drive letter: "repo:C:/Users/...". In either
1332 ** case, we want returned path to omit any initial "/".
1333 */
1334 db_open_config(1, 0);
1335 db_multi_exec(
1336 "CREATE TEMP VIEW sfile AS"
1337 " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config"
1338 " WHERE name GLOB 'repo:*'"
1339 );
1340 allRepo = 1;
1341 }else{
1342 /* The default case: All repositories under the g.zRepositoryName
1343 ** directory.
1344 */
1345 blob_init(&base, g.zRepositoryName, -1);
1346 sqlite3_open(":memory:", &g.db);
1347 db_multi_exec("CREATE TABLE sfile(pathname TEXT);");
1348 db_multi_exec("CREATE TABLE vfile(pathname);");
1349 vfile_scan(&base, blob_size(&base), 0, 0, 0);
1350 db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'");
1351 allRepo = 0;
1352 }
1353 @ <html>
1354 @ <head>
1355 @ <base href="%s(g.zBaseURL)/" />
1356 @ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1357 @ <title>Repository List</title>
1358 @ </head>
1359 @ <body>
1360 n = db_int(0, "SELECT count(*) FROM sfile");
1361 if( n>0 ){
1362 Stmt q;
1363 sqlite3_int64 iNow, iMTime;
1364 @ <h1 align="center">Fossil Repositories</h1>
1365 @ <table border="0" class="sortable" data-init-sort="1" \
1366 @ data-column-types="tnk"><thead>
1367 @ <tr><th>Filename<th width="20"><th>Last Modified</tr>
1368 @ </thead><tbody>
1369 db_prepare(&q, "SELECT pathname"
1370 " FROM sfile ORDER BY pathname COLLATE nocase;");
1371 iNow = db_int64(0, "SELECT strftime('%%s','now')");
1372 while( db_step(&q)==SQLITE_ROW ){
1373 const char *zName = db_column_text(&q, 0);
1374 int nName = (int)strlen(zName);
1375 char *zUrl;
1376 char *zAge;
1377 char *zFull;
1378 if( nName<7 ) continue;
1379 zUrl = sqlite3_mprintf("%.*s", nName-7, zName);
1380 if( zName[0]=='/'
1381 #ifdef _WIN32
1382 || sqlite3_strglob("[a-zA-Z]:/*", zName)==0
1383 #endif
1384 ){
1385 zFull = mprintf("%s", zName);
1386 }else if ( allRepo ){
1387 zFull = mprintf("/%s", zName);
1388 }else{
1389 zFull = mprintf("%s/%s", g.zRepositoryName, zName);
1390 }
1391 iMTime = file_mtime(zFull, ExtFILE);
1392 fossil_free(zFull);
1393 if( iMTime<=0 ){
1394 zAge = mprintf("...");
1395 }else{
1396 zAge = human_readable_age((iNow - iMTime)/86400.0);
1397 }
1398 if( sqlite3_strglob("*.fossil", zName)!=0 ){
1399 /* The "fossil server DIRECTORY" and "fossil ui DIRECTORY" commands
1400 ** do not work for repositories whose names do not end in ".fossil".
1401 ** So do not hyperlink those cases. */
1402 @ <tr><td>%h(zName)
1403 } else if( sqlite3_strglob("*/.*", zName)==0 ){
1404 /* Do not show hidden repos */
1405 @ <tr><td>%h(zName) (hidden)
1406 } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){
1407 @ <tr><td><a href="%R/%T(zUrl)/home" target="_blank">/%h(zName)</a>
1408 }else{
1409 @ <tr><td><a href="%R/%T(zUrl)/home" target="_blank">%h(zName)</a>
1410 }
1411 @ <td></td><td data-sortkey='%010llx(iNow - iMTime)'>%h(zAge)</tr>
1412 fossil_free(zAge);
1413 sqlite3_free(zUrl);
1414 }
1415 @ </tbody></table>
1416 }else{
1417 @ <h1>No Repositories Found</h1>
1418 }
1419 @ <script>%s(builtin_text("sorttable.js"))</script>
1420 @ </body>
1421 @ </html>
1422 cgi_reply();
1423 sqlite3_close(g.db);
1424 g.db = 0;
1425 return n;
1426 }
1427
1428 /*
1429 ** COMMAND: test-list-page
1430 **
1431 ** Usage: %fossil test-list-page DIRECTORY
1432 **
1433 ** Show all repositories underneath DIRECTORY. Or if DIRECTORY is "/"
1434 ** show all repositories in the ~/.fossil file.
1435 */
1436 void test_list_page(void){
1437 if( g.argc<3 ){
1438 g.zRepositoryName = "/";
1439 }else{
1440 g.zRepositoryName = g.argv[2];
1441 }
1442 g.httpOut = stdout;
1443 repo_list_page();
1444 }
1445
1446 /*
1447 ** Called whenever a crash is encountered while processing a webpage.
1448 */
1449 void sigsegv_handler(int x){
1450 #if HAVE_BACKTRACE
@@ -2377,10 +2233,11 @@
2377 g.useLocalauth = find_option("localauth", 0, 0)!=0;
2378 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2379 g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
2380 zInFile = find_option("in",0,1);
2381 if( zInFile ){
 
2382 g.httpIn = fossil_fopen(zInFile, "rb");
2383 if( g.httpIn==0 ) fossil_fatal("cannot open \"%s\" for reading", zInFile);
2384 }else{
2385 g.httpIn = stdin;
2386 }
2387
--- src/main.c
+++ src/main.c
@@ -1297,154 +1297,10 @@
1297 }
1298 #endif
1299 return zRepo;
1300 }
1301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1302 /*
1303 ** Called whenever a crash is encountered while processing a webpage.
1304 */
1305 void sigsegv_handler(int x){
1306 #if HAVE_BACKTRACE
@@ -2377,10 +2233,11 @@
2233 g.useLocalauth = find_option("localauth", 0, 0)!=0;
2234 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
2235 g.fNoHttpCompress = find_option("nocompress",0,0)!=0;
2236 zInFile = find_option("in",0,1);
2237 if( zInFile ){
2238 backoffice_disable();
2239 g.httpIn = fossil_fopen(zInFile, "rb");
2240 if( g.httpIn==0 ) fossil_fatal("cannot open \"%s\" for reading", zInFile);
2241 }else{
2242 g.httpIn = stdin;
2243 }
2244
+12
--- src/main.mk
+++ src/main.mk
@@ -104,10 +104,11 @@
104104
$(SRCDIR)/printf.c \
105105
$(SRCDIR)/publish.c \
106106
$(SRCDIR)/purge.c \
107107
$(SRCDIR)/rebuild.c \
108108
$(SRCDIR)/regexp.c \
109
+ $(SRCDIR)/repolist.c \
109110
$(SRCDIR)/report.c \
110111
$(SRCDIR)/rss.c \
111112
$(SRCDIR)/schema.c \
112113
$(SRCDIR)/search.c \
113114
$(SRCDIR)/security_audit.c \
@@ -314,10 +315,11 @@
314315
$(OBJDIR)/printf_.c \
315316
$(OBJDIR)/publish_.c \
316317
$(OBJDIR)/purge_.c \
317318
$(OBJDIR)/rebuild_.c \
318319
$(OBJDIR)/regexp_.c \
320
+ $(OBJDIR)/repolist_.c \
319321
$(OBJDIR)/report_.c \
320322
$(OBJDIR)/rss_.c \
321323
$(OBJDIR)/schema_.c \
322324
$(OBJDIR)/search_.c \
323325
$(OBJDIR)/security_audit_.c \
@@ -451,10 +453,11 @@
451453
$(OBJDIR)/printf.o \
452454
$(OBJDIR)/publish.o \
453455
$(OBJDIR)/purge.o \
454456
$(OBJDIR)/rebuild.o \
455457
$(OBJDIR)/regexp.o \
458
+ $(OBJDIR)/repolist.o \
456459
$(OBJDIR)/report.o \
457460
$(OBJDIR)/rss.o \
458461
$(OBJDIR)/schema.o \
459462
$(OBJDIR)/search.o \
460463
$(OBJDIR)/security_audit.o \
@@ -784,10 +787,11 @@
784787
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
785788
$(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
786789
$(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
787790
$(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
788791
$(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
792
+ $(OBJDIR)/repolist_.c:$(OBJDIR)/repolist.h \
789793
$(OBJDIR)/report_.c:$(OBJDIR)/report.h \
790794
$(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
791795
$(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
792796
$(OBJDIR)/search_.c:$(OBJDIR)/search.h \
793797
$(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -1555,10 +1559,18 @@
15551559
15561560
$(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
15571561
$(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
15581562
15591563
$(OBJDIR)/regexp.h: $(OBJDIR)/headers
1564
+
1565
+$(OBJDIR)/repolist_.c: $(SRCDIR)/repolist.c $(OBJDIR)/translate
1566
+ $(OBJDIR)/translate $(SRCDIR)/repolist.c >$@
1567
+
1568
+$(OBJDIR)/repolist.o: $(OBJDIR)/repolist_.c $(OBJDIR)/repolist.h $(SRCDIR)/config.h
1569
+ $(XTCC) -o $(OBJDIR)/repolist.o -c $(OBJDIR)/repolist_.c
1570
+
1571
+$(OBJDIR)/repolist.h: $(OBJDIR)/headers
15601572
15611573
$(OBJDIR)/report_.c: $(SRCDIR)/report.c $(OBJDIR)/translate
15621574
$(OBJDIR)/translate $(SRCDIR)/report.c >$@
15631575
15641576
$(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
15651577
--- src/main.mk
+++ src/main.mk
@@ -104,10 +104,11 @@
104 $(SRCDIR)/printf.c \
105 $(SRCDIR)/publish.c \
106 $(SRCDIR)/purge.c \
107 $(SRCDIR)/rebuild.c \
108 $(SRCDIR)/regexp.c \
 
109 $(SRCDIR)/report.c \
110 $(SRCDIR)/rss.c \
111 $(SRCDIR)/schema.c \
112 $(SRCDIR)/search.c \
113 $(SRCDIR)/security_audit.c \
@@ -314,10 +315,11 @@
314 $(OBJDIR)/printf_.c \
315 $(OBJDIR)/publish_.c \
316 $(OBJDIR)/purge_.c \
317 $(OBJDIR)/rebuild_.c \
318 $(OBJDIR)/regexp_.c \
 
319 $(OBJDIR)/report_.c \
320 $(OBJDIR)/rss_.c \
321 $(OBJDIR)/schema_.c \
322 $(OBJDIR)/search_.c \
323 $(OBJDIR)/security_audit_.c \
@@ -451,10 +453,11 @@
451 $(OBJDIR)/printf.o \
452 $(OBJDIR)/publish.o \
453 $(OBJDIR)/purge.o \
454 $(OBJDIR)/rebuild.o \
455 $(OBJDIR)/regexp.o \
 
456 $(OBJDIR)/report.o \
457 $(OBJDIR)/rss.o \
458 $(OBJDIR)/schema.o \
459 $(OBJDIR)/search.o \
460 $(OBJDIR)/security_audit.o \
@@ -784,10 +787,11 @@
784 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
785 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
786 $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
787 $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
788 $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
 
789 $(OBJDIR)/report_.c:$(OBJDIR)/report.h \
790 $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
791 $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
792 $(OBJDIR)/search_.c:$(OBJDIR)/search.h \
793 $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -1555,10 +1559,18 @@
1555
1556 $(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
1557 $(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
1558
1559 $(OBJDIR)/regexp.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
1560
1561 $(OBJDIR)/report_.c: $(SRCDIR)/report.c $(OBJDIR)/translate
1562 $(OBJDIR)/translate $(SRCDIR)/report.c >$@
1563
1564 $(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
1565
--- src/main.mk
+++ src/main.mk
@@ -104,10 +104,11 @@
104 $(SRCDIR)/printf.c \
105 $(SRCDIR)/publish.c \
106 $(SRCDIR)/purge.c \
107 $(SRCDIR)/rebuild.c \
108 $(SRCDIR)/regexp.c \
109 $(SRCDIR)/repolist.c \
110 $(SRCDIR)/report.c \
111 $(SRCDIR)/rss.c \
112 $(SRCDIR)/schema.c \
113 $(SRCDIR)/search.c \
114 $(SRCDIR)/security_audit.c \
@@ -314,10 +315,11 @@
315 $(OBJDIR)/printf_.c \
316 $(OBJDIR)/publish_.c \
317 $(OBJDIR)/purge_.c \
318 $(OBJDIR)/rebuild_.c \
319 $(OBJDIR)/regexp_.c \
320 $(OBJDIR)/repolist_.c \
321 $(OBJDIR)/report_.c \
322 $(OBJDIR)/rss_.c \
323 $(OBJDIR)/schema_.c \
324 $(OBJDIR)/search_.c \
325 $(OBJDIR)/security_audit_.c \
@@ -451,10 +453,11 @@
453 $(OBJDIR)/printf.o \
454 $(OBJDIR)/publish.o \
455 $(OBJDIR)/purge.o \
456 $(OBJDIR)/rebuild.o \
457 $(OBJDIR)/regexp.o \
458 $(OBJDIR)/repolist.o \
459 $(OBJDIR)/report.o \
460 $(OBJDIR)/rss.o \
461 $(OBJDIR)/schema.o \
462 $(OBJDIR)/search.o \
463 $(OBJDIR)/security_audit.o \
@@ -784,10 +787,11 @@
787 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
788 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
789 $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
790 $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
791 $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
792 $(OBJDIR)/repolist_.c:$(OBJDIR)/repolist.h \
793 $(OBJDIR)/report_.c:$(OBJDIR)/report.h \
794 $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
795 $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
796 $(OBJDIR)/search_.c:$(OBJDIR)/search.h \
797 $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -1555,10 +1559,18 @@
1559
1560 $(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
1561 $(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
1562
1563 $(OBJDIR)/regexp.h: $(OBJDIR)/headers
1564
1565 $(OBJDIR)/repolist_.c: $(SRCDIR)/repolist.c $(OBJDIR)/translate
1566 $(OBJDIR)/translate $(SRCDIR)/repolist.c >$@
1567
1568 $(OBJDIR)/repolist.o: $(OBJDIR)/repolist_.c $(OBJDIR)/repolist.h $(SRCDIR)/config.h
1569 $(XTCC) -o $(OBJDIR)/repolist.o -c $(OBJDIR)/repolist_.c
1570
1571 $(OBJDIR)/repolist.h: $(OBJDIR)/headers
1572
1573 $(OBJDIR)/report_.c: $(SRCDIR)/report.c $(OBJDIR)/translate
1574 $(OBJDIR)/translate $(SRCDIR)/report.c >$@
1575
1576 $(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
1577
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1903,10 +1903,22 @@
19031903
pFirst = pFirst->pNext;
19041904
}
19051905
return 1;
19061906
}
19071907
1908
+/*
1909
+** Return TRUE if pFirst is the first token of a static assert.
1910
+*/
1911
+static int isStaticAssert(Token *pFirst){
1912
+ if( (pFirst->nText==13 && strncmp(pFirst->zText, "static_assert", 13)==0)
1913
+ || (pFirst->nText==14 && strncmp(pFirst->zText, "_Static_assert", 14)==0)
1914
+ ){
1915
+ return 1;
1916
+ }else{
1917
+ return 0;
1918
+ }
1919
+}
19081920
19091921
/*
19101922
** This routine is called whenever we encounter a ";" or "=". The stuff
19111923
** between pFirst and pLast constitutes either a typedef or a global
19121924
** variable definition. Do the right thing.
@@ -1961,10 +1973,12 @@
19611973
return nErr;
19621974
}
19631975
}else if( flags & PS_Method ){
19641976
/* Methods are declared by their class. Don't declare separately. */
19651977
return nErr;
1978
+ }else if( isStaticAssert(pFirst) ){
1979
+ return 0;
19661980
}
19671981
isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd);
19681982
if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0
19691983
&& (flags & PS_Extern)==0 ){
19701984
fprintf(stderr,"%s:%d: Can't define a variable in this context\n",
19711985
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1903,10 +1903,22 @@
1903 pFirst = pFirst->pNext;
1904 }
1905 return 1;
1906 }
1907
 
 
 
 
 
 
 
 
 
 
 
 
1908
1909 /*
1910 ** This routine is called whenever we encounter a ";" or "=". The stuff
1911 ** between pFirst and pLast constitutes either a typedef or a global
1912 ** variable definition. Do the right thing.
@@ -1961,10 +1973,12 @@
1961 return nErr;
1962 }
1963 }else if( flags & PS_Method ){
1964 /* Methods are declared by their class. Don't declare separately. */
1965 return nErr;
 
 
1966 }
1967 isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd);
1968 if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0
1969 && (flags & PS_Extern)==0 ){
1970 fprintf(stderr,"%s:%d: Can't define a variable in this context\n",
1971
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1903,10 +1903,22 @@
1903 pFirst = pFirst->pNext;
1904 }
1905 return 1;
1906 }
1907
1908 /*
1909 ** Return TRUE if pFirst is the first token of a static assert.
1910 */
1911 static int isStaticAssert(Token *pFirst){
1912 if( (pFirst->nText==13 && strncmp(pFirst->zText, "static_assert", 13)==0)
1913 || (pFirst->nText==14 && strncmp(pFirst->zText, "_Static_assert", 14)==0)
1914 ){
1915 return 1;
1916 }else{
1917 return 0;
1918 }
1919 }
1920
1921 /*
1922 ** This routine is called whenever we encounter a ";" or "=". The stuff
1923 ** between pFirst and pLast constitutes either a typedef or a global
1924 ** variable definition. Do the right thing.
@@ -1961,10 +1973,12 @@
1973 return nErr;
1974 }
1975 }else if( flags & PS_Method ){
1976 /* Methods are declared by their class. Don't declare separately. */
1977 return nErr;
1978 }else if( isStaticAssert(pFirst) ){
1979 return 0;
1980 }
1981 isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd);
1982 if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0
1983 && (flags & PS_Extern)==0 ){
1984 fprintf(stderr,"%s:%d: Can't define a variable in this context\n",
1985
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -114,10 +114,11 @@
114114
printf
115115
publish
116116
purge
117117
rebuild
118118
regexp
119
+ repolist
119120
report
120121
rss
121122
schema
122123
search
123124
security_audit
124125
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -114,10 +114,11 @@
114 printf
115 publish
116 purge
117 rebuild
118 regexp
 
119 report
120 rss
121 schema
122 search
123 security_audit
124
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -114,10 +114,11 @@
114 printf
115 publish
116 purge
117 rebuild
118 regexp
119 repolist
120 report
121 rss
122 schema
123 search
124 security_audit
125
+10
--- src/path.c
+++ src/path.c
@@ -192,10 +192,20 @@
192192
int i;
193193
if( path.nStep<2 ) return 0;
194194
for(p=path.pEnd, i=0; p && i<path.nStep/2; p=p->pFrom, i++){}
195195
return p;
196196
}
197
+
198
+/*
199
+** Return an estimate of the number of comparisons remaining in order
200
+** to bisect path. This is based on the log2() of path.nStep.
201
+*/
202
+int path_search_depth(void){
203
+ int i, j;
204
+ for(i=0, j=1; j<path.nStep; i++, j+=j){}
205
+ return i;
206
+}
197207
198208
/*
199209
** Compute the shortest path between two check-ins and then transfer
200210
** that path into the "ancestor" table. This is a utility used by
201211
** both /annotate and /finfo. See also: compute_direct_ancestors().
202212
203213
ADDED src/repolist.c
--- src/path.c
+++ src/path.c
@@ -192,10 +192,20 @@
192 int i;
193 if( path.nStep<2 ) return 0;
194 for(p=path.pEnd, i=0; p && i<path.nStep/2; p=p->pFrom, i++){}
195 return p;
196 }
 
 
 
 
 
 
 
 
 
 
197
198 /*
199 ** Compute the shortest path between two check-ins and then transfer
200 ** that path into the "ancestor" table. This is a utility used by
201 ** both /annotate and /finfo. See also: compute_direct_ancestors().
202
203 DDED src/repolist.c
--- src/path.c
+++ src/path.c
@@ -192,10 +192,20 @@
192 int i;
193 if( path.nStep<2 ) return 0;
194 for(p=path.pEnd, i=0; p && i<path.nStep/2; p=p->pFrom, i++){}
195 return p;
196 }
197
198 /*
199 ** Return an estimate of the number of comparisons remaining in order
200 ** to bisect path. This is based on the log2() of path.nStep.
201 */
202 int path_search_depth(void){
203 int i, j;
204 for(i=0, j=1; j<path.nStep; i++, j+=j){}
205 return i;
206 }
207
208 /*
209 ** Compute the shortest path between two check-ins and then transfer
210 ** that path into the "ancestor" table. This is a utility used by
211 ** both /annotate and /finfo. See also: compute_direct_ancestors().
212
213 DDED src/repolist.c
--- a/src/repolist.c
+++ b/src/repolist.c
@@ -0,0 +1,39 @@
1
+/*
2
+** Copyright (c) 2018 D. Richard Hipp
3
+**
4
+** This program is free software; you can redistribute it and/or
5
+** modify it under the terms of thint/* Assert t_cmd
6
+**
7
+**
8
+**
9
+**
10
+** This is an expensive routine in that it has to open and close if(&& !pRepo->zRepoName);
11
+ }/*
12
+** Copyright (c) right (c) 2018 D. Richard Hipp
13
+**
14
+** This program is free software; you can redistribute it and/or
15
+** modify it under the terms of thint/* Assert t_cmd>0 )%R%Relse{
16
+"<h1>No Repositories Found</h1>\n"<style>
17
+ style_render_
18
+*/
19
+voidValid = 0;
20
+
21
+ int n = 0;
22
+ int allRepo;@ <html>
23
+ @ <head>
24
+@ </head>
25
+ @ <body><table border="0" class="sortable" data-init-sort="1" \
26
+ @ data-column-types="tntnk"><thead>
27
+ @ <tr><th>Filename<th width="20">\
28
+ @ "20">\
29
+ @ <th>Last Modified@ <tr><td valign="top">\@ %h(zName)idden repos */
30
+ @ <a href="%R/%T(zUrl)/home" tar@ <a href="%R/%T(zUrl)/home" ta@ <td></td>@ <td></td(iAge)'>%h(zAge)</tr>*
31
+** Copyright (c) 2018 D. Richard 018 D. Richard Hipp
32
+**
33
+** This pro
34
+ }
35
+@ </body>
36
+ @ </html>
37
+ cgi_reply()g.db);
38
+ g.db = 0(pRepo->zRepoName, &dbzAge = mprintf("...");
39
+iAge = 0}returnreturnsqlite3_close(db);1
--- a/src/repolist.c
+++ b/src/repolist.c
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/repolist.c
+++ b/src/repolist.c
@@ -0,0 +1,39 @@
1 /*
2 ** Copyright (c) 2018 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of thint/* Assert t_cmd
6 **
7 **
8 **
9 **
10 ** This is an expensive routine in that it has to open and close if(&& !pRepo->zRepoName);
11 }/*
12 ** Copyright (c) right (c) 2018 D. Richard Hipp
13 **
14 ** This program is free software; you can redistribute it and/or
15 ** modify it under the terms of thint/* Assert t_cmd>0 )%R%Relse{
16 "<h1>No Repositories Found</h1>\n"<style>
17 style_render_
18 */
19 voidValid = 0;
20
21 int n = 0;
22 int allRepo;@ <html>
23 @ <head>
24 @ </head>
25 @ <body><table border="0" class="sortable" data-init-sort="1" \
26 @ data-column-types="tntnk"><thead>
27 @ <tr><th>Filename<th width="20">\
28 @ "20">\
29 @ <th>Last Modified@ <tr><td valign="top">\@ %h(zName)idden repos */
30 @ <a href="%R/%T(zUrl)/home" tar@ <a href="%R/%T(zUrl)/home" ta@ <td></td>@ <td></td(iAge)'>%h(zAge)</tr>*
31 ** Copyright (c) 2018 D. Richard 018 D. Richard Hipp
32 **
33 ** This pro
34 }
35 @ </body>
36 @ </html>
37 cgi_reply()g.db);
38 g.db = 0(pRepo->zRepoName, &dbzAge = mprintf("...");
39 iAge = 0}returnreturnsqlite3_close(db);1
+294 -166
--- src/shell.c
+++ src/shell.c
@@ -1315,11 +1315,11 @@
13151315
** May you find forgiveness for yourself and forgive others.
13161316
** May you share freely, never taking more than you give.
13171317
**
13181318
******************************************************************************
13191319
**
1320
-** This SQLite extension implements a functions that compute SHA1 hashes.
1320
+** This SQLite extension implements functions that compute SHA3 hashes.
13211321
** Two SQL functions are implemented:
13221322
**
13231323
** sha3(X,SIZE)
13241324
** sha3_query(Y,SIZE)
13251325
**
@@ -2908,11 +2908,12 @@
29082908
0, /* xRollback */
29092909
0, /* xFindMethod */
29102910
0, /* xRename */
29112911
0, /* xSavepoint */
29122912
0, /* xRelease */
2913
- 0 /* xRollbackTo */
2913
+ 0, /* xRollbackTo */
2914
+ 0, /* xShadowName */
29142915
};
29152916
29162917
int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0);
29172918
return rc;
29182919
}
@@ -3416,11 +3417,12 @@
34163417
0, /* xRollback */
34173418
0, /* xFindMethod */
34183419
0, /* xRename */
34193420
0, /* xSavepoint */
34203421
0, /* xRelease */
3421
- 0 /* xRollbackTo */
3422
+ 0, /* xRollbackTo */
3423
+ 0 /* xShadowName */
34223424
};
34233425
34243426
#endif /* SQLITE_OMIT_VIRTUALTABLE */
34253427
34263428
int sqlite3CompletionVtabInit(sqlite3 *db){
@@ -7134,10 +7136,11 @@
71347136
0, /* xFindFunction - function overloading */
71357137
0, /* xRename - rename the table */
71367138
0, /* xSavepoint */
71377139
0, /* xRelease */
71387140
0, /* xRollbackTo */
7141
+ 0, /* xShadowName */
71397142
};
71407143
71417144
return sqlite3_create_module(p->dbv, "expert", &expertModule, (void*)p);
71427145
}
71437146
/*
@@ -8558,15 +8561,16 @@
85588561
#define AUTOEQP_trigger 2 /* On and also show plans for triggers */
85598562
#define AUTOEQP_full 3 /* Show full EXPLAIN */
85608563
85618564
/* Allowed values for ShellState.openMode
85628565
*/
8563
-#define SHELL_OPEN_UNSPEC 0 /* No open-mode specified */
8564
-#define SHELL_OPEN_NORMAL 1 /* Normal database file */
8565
-#define SHELL_OPEN_APPENDVFS 2 /* Use appendvfs */
8566
-#define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
8567
-#define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
8566
+#define SHELL_OPEN_UNSPEC 0 /* No open-mode specified */
8567
+#define SHELL_OPEN_NORMAL 1 /* Normal database file */
8568
+#define SHELL_OPEN_APPENDVFS 2 /* Use appendvfs */
8569
+#define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
8570
+#define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
8571
+#define SHELL_OPEN_DESERIALIZE 5 /* Open using sqlite3_deserialize() */
85688572
85698573
/*
85708574
** These are the allowed shellFlgs values
85718575
*/
85728576
#define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -8772,11 +8776,11 @@
87728776
goto edit_func_end;
87738777
}
87748778
if( bBin ){
87758779
sqlite3_result_blob64(context, p, sz, sqlite3_free);
87768780
}else{
8777
- int i, j;
8781
+ sqlite3_int64 i, j;
87788782
if( hasCRNL ){
87798783
/* If the original contains \r\n then do no conversions back to \n */
87808784
j = sz;
87818785
}else{
87828786
/* If the file did not originally contain \r\n then convert any new
@@ -10834,141 +10838,242 @@
1083410838
}
1083510839
return rc;
1083610840
}
1083710841
1083810842
/*
10839
-** Text of a help message
10843
+** Text of help messages.
10844
+**
10845
+** The help text for each individual command begins with a line that starts
10846
+** with ".". Subsequent lines are supplimental information.
10847
+**
10848
+** There must be two or more spaces between the end of the command and the
10849
+** start of the description of what that command does.
1084010850
*/
10841
-static char zHelp[] =
10851
+static const char *(azHelp[]) = {
1084210852
#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
10843
- ".archive ... Manage SQL archives: \".archive --help\" for details\n"
10853
+ ".archive ... Manage SQL archives",
10854
+ " Each command must have exactly one of the following options:",
10855
+ " -c, --create Create a new archive",
10856
+ " -u, --update Update or add files to an existing archive",
10857
+ " -t, --list List contents of archive",
10858
+ " -x, --extract Extract files from archive",
10859
+ " Optional arguments:",
10860
+ " -v, --verbose Print each filename as it is processed",
10861
+ " -f FILE, --file FILE Operate on archive FILE (default is current db)",
10862
+ " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS",
10863
+ " -C DIR, --directory DIR Change to directory DIR to read/extract files",
10864
+ " -n, --dryrun Show the SQL that would have occurred",
10865
+ " Examples:",
10866
+ " .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar",
10867
+ " .ar -tf archive.sar # List members of archive.sar",
10868
+ " .ar -xvf archive.sar # Verbosely extract files from archive.sar",
10869
+ " See also:",
10870
+ " http://sqlite.org/cli.html#sqlar_archive_support",
1084410871
#endif
1084510872
#ifndef SQLITE_OMIT_AUTHORIZATION
10846
- ".auth ON|OFF Show authorizer callbacks\n"
10873
+ ".auth ON|OFF Show authorizer callbacks",
1084710874
#endif
10848
- ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
10849
- " Add \"--append\" to open using appendvfs.\n"
10850
- ".bail on|off Stop after hitting an error. Default OFF\n"
10851
- ".binary on|off Turn binary output on or off. Default OFF\n"
10852
- ".cd DIRECTORY Change the working directory to DIRECTORY\n"
10853
- ".changes on|off Show number of rows changed by SQL\n"
10854
- ".check GLOB Fail if output since .testcase does not match\n"
10855
- ".clone NEWDB Clone data into NEWDB from the existing database\n"
10856
- ".databases List names and files of attached databases\n"
10857
- ".dbconfig ?op? ?val? List or change sqlite3_db_config() options\n"
10858
- ".dbinfo ?DB? Show status information about the database\n"
10859
- ".dump ?TABLE? ... Dump the database in an SQL text format\n"
10860
- " If TABLE specified, only dump tables matching\n"
10861
- " LIKE pattern TABLE.\n"
10862
- ".echo on|off Turn command echo on or off\n"
10863
- ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
10864
- ".excel Display the output of next command in a spreadsheet\n"
10865
- ".exit Exit this program\n"
10866
- ".expert EXPERIMENTAL. Suggest indexes for specified queries\n"
10875
+ ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
10876
+ " --append Use the appendvfs",
10877
+ ".bail on|off Stop after hitting an error. Default OFF",
10878
+ ".binary on|off Turn binary output on or off. Default OFF",
10879
+ ".cd DIRECTORY Change the working directory to DIRECTORY",
10880
+ ".changes on|off Show number of rows changed by SQL",
10881
+ ".check GLOB Fail if output since .testcase does not match",
10882
+ ".clone NEWDB Clone data into NEWDB from the existing database",
10883
+ ".databases List names and files of attached databases",
10884
+ ".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
10885
+ ".dbinfo ?DB? Show status information about the database",
10886
+ ".dump ?TABLE? ... Render all database content as SQL",
10887
+ " Options:",
10888
+ " --preserve-rowids Include ROWID values in the output",
10889
+ " --newlines Allow unescaped newline characters in output",
10890
+ " TABLE is LIKE pattern for the tables to dump",
10891
+ ".echo on|off Turn command echo on or off",
10892
+ ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN",
10893
+ ".excel Display the output of next command in a spreadsheet",
10894
+ ".exit ?CODE? Exit this program with return-code CODE",
10895
+ ".expert EXPERIMENTAL. Suggest indexes for specified queries",
1086710896
/* Because explain mode comes on automatically now, the ".explain" mode
1086810897
** is removed from the help screen. It is still supported for legacy, however */
10869
-/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/
10870
- ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
10871
- ".headers on|off Turn display of headers on or off\n"
10872
- ".help Show this message\n"
10873
- ".import FILE TABLE Import data from FILE into TABLE\n"
10874
-#ifndef SQLITE_OMIT_TEST_CONTROL
10875
- ".imposter INDEX TABLE Create imposter table TABLE on index INDEX\n"
10876
-#endif
10877
- ".indexes ?TABLE? Show names of all indexes\n"
10878
- " If TABLE specified, only show indexes for tables\n"
10879
- " matching LIKE pattern TABLE.\n"
10880
-#ifdef SQLITE_ENABLE_IOTRACE
10881
- ".iotrace FILE Enable I/O diagnostic logging to FILE\n"
10882
-#endif
10883
- ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n"
10884
- ".lint OPTIONS Report potential schema issues. Options:\n"
10885
- " fkey-indexes Find missing foreign key indexes\n"
10886
-#ifndef SQLITE_OMIT_LOAD_EXTENSION
10887
- ".load FILE ?ENTRY? Load an extension library\n"
10888
-#endif
10889
- ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
10890
- ".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
10891
- " ascii Columns/rows delimited by 0x1F and 0x1E\n"
10892
- " csv Comma-separated values\n"
10893
- " column Left-aligned columns. (See .width)\n"
10894
- " html HTML <table> code\n"
10895
- " insert SQL insert statements for TABLE\n"
10896
- " line One value per line\n"
10897
- " list Values delimited by \"|\"\n"
10898
- " quote Escape answers as for SQL\n"
10899
- " tabs Tab-separated values\n"
10900
- " tcl TCL list elements\n"
10901
- ".nullvalue STRING Use STRING in place of NULL values\n"
10902
- ".once (-e|-x|FILE) Output for the next SQL command only to FILE\n"
10903
- " or invoke system text editor (-e) or spreadsheet (-x)\n"
10904
- " on the output.\n"
10905
- ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\n"
10906
- " The --new option starts with an empty file\n"
10907
- " Other options: --readonly --append --zip\n"
10908
- ".output ?FILE? Send output to FILE or stdout\n"
10909
- ".print STRING... Print literal STRING\n"
10910
- ".prompt MAIN CONTINUE Replace the standard prompts\n"
10911
- ".quit Exit this program\n"
10912
- ".read FILENAME Execute SQL in FILENAME\n"
10913
- ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
10914
- ".save FILE Write in-memory database into FILE\n"
10915
- ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
10916
- ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n"
10917
- " Add --indent for pretty-printing\n"
10918
- ".selftest ?--init? Run tests defined in the SELFTEST table\n"
10919
- ".separator COL ?ROW? Change the column separator and optionally the row\n"
10920
- " separator for both the output mode and .import\n"
10921
-#if defined(SQLITE_ENABLE_SESSION)
10922
- ".session CMD ... Create or control sessions\n"
10923
-#endif
10924
- ".sha3sum ?OPTIONS...? Compute a SHA3 hash of database content\n"
10925
-#ifndef SQLITE_NOHAVE_SYSTEM
10926
- ".shell CMD ARGS... Run CMD ARGS... in a system shell\n"
10927
-#endif
10928
- ".show Show the current values for various settings\n"
10929
- ".stats ?on|off? Show stats or turn stats on or off\n"
10930
-#ifndef SQLITE_NOHAVE_SYSTEM
10931
- ".system CMD ARGS... Run CMD ARGS... in a system shell\n"
10932
-#endif
10933
- ".tables ?TABLE? List names of tables\n"
10934
- " If TABLE specified, only list tables matching\n"
10935
- " LIKE pattern TABLE.\n"
10936
- ".testcase NAME Begin redirecting output to 'testcase-out.txt'\n"
10937
- ".timeout MS Try opening locked tables for MS milliseconds\n"
10938
- ".timer on|off Turn SQL timer on or off\n"
10939
- ".trace FILE|off Output each SQL statement as it is run\n"
10940
- ".vfsinfo ?AUX? Information about the top-level VFS\n"
10941
- ".vfslist List all available VFSes\n"
10942
- ".vfsname ?AUX? Print the name of the VFS stack\n"
10943
- ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"
10944
- " Negative values right-justify\n"
10945
-;
10946
-
10947
-#if defined(SQLITE_ENABLE_SESSION)
10948
-/*
10949
-** Print help information for the ".sessions" command
10950
-*/
10951
-void session_help(ShellState *p){
10952
- raw_printf(p->out,
10953
- ".session ?NAME? SUBCOMMAND ?ARGS...?\n"
10954
- "If ?NAME? is omitted, the first defined session is used.\n"
10955
- "Subcommands:\n"
10956
- " attach TABLE Attach TABLE\n"
10957
- " changeset FILE Write a changeset into FILE\n"
10958
- " close Close one session\n"
10959
- " enable ?BOOLEAN? Set or query the enable bit\n"
10960
- " filter GLOB... Reject tables matching GLOBs\n"
10961
- " indirect ?BOOLEAN? Mark or query the indirect status\n"
10962
- " isempty Query whether the session is empty\n"
10963
- " list List currently open session names\n"
10964
- " open DB NAME Open a new session on DB\n"
10965
- " patchset FILE Write a patchset into FILE\n"
10966
- );
10967
-}
10968
-#endif
10969
-
10898
+/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
10899
+ ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
10900
+ ".headers on|off Turn display of headers on or off",
10901
+ ".help ?-all? ?PATTERN? Show help text for PATTERN",
10902
+ ".import FILE TABLE Import data from FILE into TABLE",
10903
+#ifndef SQLITE_OMIT_TEST_CONTROL
10904
+ ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
10905
+#endif
10906
+ ".indexes ?TABLE? Show names of indexes",
10907
+ " If TABLE is specified, only show indexes for",
10908
+ " tables matching TABLE using the LIKE operator.",
10909
+#ifdef SQLITE_ENABLE_IOTRACE
10910
+ ".iotrace FILE Enable I/O diagnostic logging to FILE",
10911
+#endif
10912
+ ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
10913
+ ".lint OPTIONS Report potential schema issues.",
10914
+ " Options:",
10915
+ " fkey-indexes Find missing foreign key indexes",
10916
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
10917
+ ".load FILE ?ENTRY? Load an extension library",
10918
+#endif
10919
+ ".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
10920
+ ".mode MODE ?TABLE? Set output mode",
10921
+ " MODE is one of:",
10922
+ " ascii Columns/rows delimited by 0x1F and 0x1E",
10923
+ " csv Comma-separated values",
10924
+ " column Left-aligned columns. (See .width)",
10925
+ " html HTML <table> code",
10926
+ " insert SQL insert statements for TABLE",
10927
+ " line One value per line",
10928
+ " list Values delimited by \"|\"",
10929
+ " quote Escape answers as for SQL",
10930
+ " tabs Tab-separated values",
10931
+ " tcl TCL list elements",
10932
+ ".nullvalue STRING Use STRING in place of NULL values",
10933
+ ".once (-e|-x|FILE) Output for the next SQL command only to FILE",
10934
+ " If FILE begins with '|' then open as a pipe",
10935
+ " Other options:",
10936
+ " -e Invoke system text editor",
10937
+ " -x Open in a spreadsheet",
10938
+ ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
10939
+ " Options:",
10940
+ " --append Use appendvfs to append database to the end of FILE",
10941
+#ifdef SQLITE_ENABLE_DESERIALIZE
10942
+ " --deserialize Load into memory useing sqlite3_deserialize()",
10943
+#endif
10944
+ " --new Initialize FILE to an empty database",
10945
+ " --readonly Open FILE readonly",
10946
+ " --zip FILE is a ZIP archive",
10947
+ ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
10948
+ " If FILE begins with '|' then open it as a pipe.",
10949
+ ".print STRING... Print literal STRING",
10950
+ ".prompt MAIN CONTINUE Replace the standard prompts",
10951
+ ".quit Exit this program",
10952
+ ".read FILE Read input from FILE",
10953
+ ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
10954
+ ".save FILE Write in-memory database into FILE",
10955
+ ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
10956
+ ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
10957
+ " Options:",
10958
+ " --indent Try to pretty-print the schema",
10959
+ ".selftest ?OPTIONS? Run tests defined in the SELFTEST table",
10960
+ " Options:",
10961
+ " --init Create a new SELFTEST table",
10962
+ " -v Verbose output",
10963
+ ".separator COL ?ROW? Change the column and row separators",
10964
+#if defined(SQLITE_ENABLE_SESSION)
10965
+ ".session ?NAME? CMD ... Create or control sessions",
10966
+ " Subcommands:",
10967
+ " attach TABLE Attach TABLE",
10968
+ " changeset FILE Write a changeset into FILE",
10969
+ " close Close one session",
10970
+ " enable ?BOOLEAN? Set or query the enable bit",
10971
+ " filter GLOB... Reject tables matching GLOBs",
10972
+ " indirect ?BOOLEAN? Mark or query the indirect status",
10973
+ " isempty Query whether the session is empty",
10974
+ " list List currently open session names",
10975
+ " open DB NAME Open a new session on DB",
10976
+ " patchset FILE Write a patchset into FILE",
10977
+ " If ?NAME? is omitted, the first defined session is used.",
10978
+#endif
10979
+ ".sha3sum ... Compute a SHA3 hash of database content",
10980
+ " Options:",
10981
+ " --schema Also hash the sqlite_master table",
10982
+ " --sha3-224 Use the sha3-224 algorithm",
10983
+ " --sha3-256 Use the sha3-256 algorithm. This is the default.",
10984
+ " --sha3-384 Use the sha3-384 algorithm",
10985
+ " --sha3-512 Use the sha3-512 algorithm",
10986
+ " Any other argument is a LIKE pattern for tables to hash",
10987
+#ifndef SQLITE_NOHAVE_SYSTEM
10988
+ ".shell CMD ARGS... Run CMD ARGS... in a system shell",
10989
+#endif
10990
+ ".show Show the current values for various settings",
10991
+ ".stats ?on|off? Show stats or turn stats on or off",
10992
+#ifndef SQLITE_NOHAVE_SYSTEM
10993
+ ".system CMD ARGS... Run CMD ARGS... in a system shell",
10994
+#endif
10995
+ ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
10996
+ ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
10997
+ ".timeout MS Try opening locked tables for MS milliseconds",
10998
+ ".timer on|off Turn SQL timer on or off",
10999
+ ".trace FILE|off Output each SQL statement as it is run",
11000
+ ".vfsinfo ?AUX? Information about the top-level VFS",
11001
+ ".vfslist List all available VFSes",
11002
+ ".vfsname ?AUX? Print the name of the VFS stack",
11003
+ ".width NUM1 NUM2 ... Set column widths for \"column\" mode",
11004
+ " Negative values right-justify",
11005
+};
11006
+
11007
+/*
11008
+** Output help text.
11009
+**
11010
+** zPattern describes the set of commands for which help text is provided.
11011
+** If zPattern is NULL, then show all commands, but only give a one-line
11012
+** description of each.
11013
+**
11014
+** Return the number of matches.
11015
+*/
11016
+static int showHelp(FILE *out, const char *zPattern){
11017
+ int i = 0;
11018
+ int j = 0;
11019
+ int n = 0;
11020
+ char *zPat;
11021
+ if( zPattern==0
11022
+ || zPattern[0]=='0'
11023
+ || strcmp(zPattern,"-a")==0
11024
+ || strcmp(zPattern,"-all")==0
11025
+ ){
11026
+ /* Show all commands, but only one line per command */
11027
+ if( zPattern==0 ) zPattern = "";
11028
+ for(i=0; i<ArraySize(azHelp); i++){
11029
+ if( azHelp[i][0]=='.' || zPattern[0] ){
11030
+ utf8_printf(out, "%s\n", azHelp[i]);
11031
+ n++;
11032
+ }
11033
+ }
11034
+ }else{
11035
+ /* Look for commands that for which zPattern is an exact prefix */
11036
+ zPat = sqlite3_mprintf(".%s*", zPattern);
11037
+ for(i=0; i<ArraySize(azHelp); i++){
11038
+ if( sqlite3_strglob(zPat, azHelp[i])==0 ){
11039
+ utf8_printf(out, "%s\n", azHelp[i]);
11040
+ j = i+1;
11041
+ n++;
11042
+ }
11043
+ }
11044
+ sqlite3_free(zPat);
11045
+ if( n ){
11046
+ if( n==1 ){
11047
+ /* when zPattern is a prefix of exactly one command, then include the
11048
+ ** details of that command, which should begin at offset j */
11049
+ while( j<ArraySize(azHelp)-1 && azHelp[j][0]!='.' ){
11050
+ utf8_printf(out, "%s\n", azHelp[j]);
11051
+ j++;
11052
+ }
11053
+ }
11054
+ return n;
11055
+ }
11056
+ /* Look for commands that contain zPattern anywhere. Show the complete
11057
+ ** text of all commands that match. */
11058
+ zPat = sqlite3_mprintf("%%%s%%", zPattern);
11059
+ for(i=0; i<ArraySize(azHelp); i++){
11060
+ if( azHelp[i][0]=='.' ) j = i;
11061
+ if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
11062
+ utf8_printf(out, "%s\n", azHelp[j]);
11063
+ while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]!='.' ){
11064
+ j++;
11065
+ utf8_printf(out, "%s\n", azHelp[j]);
11066
+ }
11067
+ i = j;
11068
+ n++;
11069
+ }
11070
+ }
11071
+ sqlite3_free(zPat);
11072
+ }
11073
+ return n;
11074
+}
1097011075
1097111076
/* Forward reference */
1097211077
static int process_input(ShellState *p, FILE *in);
1097311078
1097411079
/*
@@ -10994,11 +11099,11 @@
1099411099
if( in==0 ) return 0;
1099511100
fseek(in, 0, SEEK_END);
1099611101
nIn = ftell(in);
1099711102
rewind(in);
1099811103
pBuf = sqlite3_malloc64( nIn+1 );
10999
- if( pBuf==0 ) return 0;
11104
+ if( pBuf==0 ){ fclose(in); return 0; }
1100011105
nRead = fread(pBuf, nIn, 1, in);
1100111106
fclose(in);
1100211107
if( nRead!=1 ){
1100311108
sqlite3_free(pBuf);
1100411109
return 0;
@@ -11074,10 +11179,15 @@
1107411179
return SHELL_OPEN_ZIPFILE;
1107511180
}else{
1107611181
return SHELL_OPEN_NORMAL;
1107711182
}
1107811183
}
11184
+ n = fread(zBuf, 16, 1, f);
11185
+ if( n==1 && memcmp(zBuf, "SQLite format 3", 16)==0 ){
11186
+ fclose(f);
11187
+ return SHELL_OPEN_NORMAL;
11188
+ }
1107911189
fseek(f, -25, SEEK_END);
1108011190
n = fread(zBuf, 25, 1, f);
1108111191
if( n==1 && memcmp(zBuf, "Start-Of-SQLite3-", 17)==0 ){
1108211192
rc = SHELL_OPEN_APPENDVFS;
1108311193
}else{
@@ -11124,10 +11234,14 @@
1112411234
switch( p->openMode ){
1112511235
case SHELL_OPEN_APPENDVFS: {
1112611236
sqlite3_open_v2(p->zDbFilename, &p->db,
1112711237
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
1112811238
break;
11239
+ }
11240
+ case SHELL_OPEN_DESERIALIZE: {
11241
+ sqlite3_open(0, &p->db);
11242
+ break;
1112911243
}
1113011244
case SHELL_OPEN_ZIPFILE: {
1113111245
sqlite3_open(":memory:", &p->db);
1113211246
break;
1113311247
}
@@ -11174,10 +11288,22 @@
1117411288
char *zSql = sqlite3_mprintf(
1117511289
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
1117611290
sqlite3_exec(p->db, zSql, 0, 0, 0);
1117711291
sqlite3_free(zSql);
1117811292
}
11293
+#ifdef SQLITE_ENABLE_DESERIALIZE
11294
+ else if( p->openMode==SHELL_OPEN_DESERIALIZE ){
11295
+ int nData = 0;
11296
+ unsigned char *aData = (unsigned char*)readFile(p->zDbFilename, &nData);
11297
+ int rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
11298
+ SQLITE_DESERIALIZE_RESIZEABLE |
11299
+ SQLITE_DESERIALIZE_FREEONCLOSE);
11300
+ if( rc ){
11301
+ utf8_printf(stderr, "Error: sqlite3_deserialize() returns %d\n", rc);
11302
+ }
11303
+ }
11304
+#endif
1117911305
}
1118011306
}
1118111307
1118211308
/*
1118311309
** Attempt to close the databaes connection. Report errors.
@@ -12378,10 +12504,11 @@
1237812504
if( *pRc==SQLITE_OK ){
1237912505
va_list ap;
1238012506
char *z;
1238112507
va_start(ap, zFmt);
1238212508
z = sqlite3_vmprintf(zFmt, ap);
12509
+ va_end(ap);
1238312510
if( z==0 ){
1238412511
*pRc = SQLITE_NOMEM;
1238512512
}else{
1238612513
shellPrepare(db, pRc, z, ppStmt);
1238712514
sqlite3_free(z);
@@ -12440,36 +12567,11 @@
1244012567
1244112568
/*
1244212569
** Print a usage message for the .ar command to stderr and return SQLITE_ERROR.
1244312570
*/
1244412571
static int arUsage(FILE *f){
12445
- raw_printf(f,
12446
-"\n"
12447
-"Usage: .ar [OPTION...] [FILE...]\n"
12448
-"The .ar command manages sqlar archives.\n"
12449
-"\n"
12450
-"Examples:\n"
12451
-" .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar\n"
12452
-" .ar -tf archive.sar # List members of archive.sar\n"
12453
-" .ar -xvf archive.sar # Verbosely extract files from archive.sar\n"
12454
-"\n"
12455
-"Each command line must feature exactly one command option:\n"
12456
-" -c, --create Create a new archive\n"
12457
-" -u, --update Update or add files to an existing archive\n"
12458
-" -t, --list List contents of archive\n"
12459
-" -x, --extract Extract files from archive\n"
12460
-"\n"
12461
-"And zero or more optional options:\n"
12462
-" -v, --verbose Print each filename as it is processed\n"
12463
-" -f FILE, --file FILE Operate on archive FILE (default is current db)\n"
12464
-" -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS\n"
12465
-" -C DIR, --directory DIR Change to directory DIR to read/extract files\n"
12466
-" -n, --dryrun Show the SQL that would have occurred\n"
12467
-"\n"
12468
-"See also: http://sqlite.org/cli.html#sqlar_archive_support\n"
12469
-"\n"
12470
-);
12572
+ showHelp(f,"archive");
1247112573
return SQLITE_ERROR;
1247212574
}
1247312575
1247412576
/*
1247512577
** Print an error message for the .ar command to stderr and return
@@ -12572,10 +12674,11 @@
1257212674
};
1257312675
int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch);
1257412676
struct ArSwitch *pEnd = &aSwitch[nSwitch];
1257512677
1257612678
if( nArg<=1 ){
12679
+ utf8_printf(stderr, "Wrong number of arguments. Usage:\n");
1257712680
return arUsage(stderr);
1257812681
}else{
1257912682
char *z = azArg[1];
1258012683
if( z[0]!='-' ){
1258112684
/* Traditional style [tar] invocation */
@@ -13343,19 +13446,23 @@
1334313446
rc = 1;
1334413447
}
1334513448
}else
1334613449
1334713450
if( c=='d' && n>=3 && strncmp(azArg[0], "dbconfig", n)==0 ){
13348
- static const struct DbConfigChoices {const char *zName; int op;} aDbConfig[] = {
13451
+ static const struct DbConfigChoices {
13452
+ const char *zName;
13453
+ int op;
13454
+ } aDbConfig[] = {
1334913455
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
1335013456
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
1335113457
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
1335213458
{ "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
1335313459
{ "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
1335413460
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
1335513461
{ "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
1335613462
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
13463
+ { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
1335713464
};
1335813465
int ii, v;
1335913466
open_db(p, 0);
1336013467
for(ii=0; ii<ArraySize(aDbConfig); ii++){
1336113468
if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -13590,11 +13697,18 @@
1359013697
rc = 1;
1359113698
}
1359213699
}else
1359313700
1359413701
if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
13595
- utf8_printf(p->out, "%s", zHelp);
13702
+ if( nArg>=2 ){
13703
+ n = showHelp(p->out, azArg[1]);
13704
+ if( n==0 ){
13705
+ utf8_printf(p->out, "Nothing matches '%s'\n", azArg[1]);
13706
+ }
13707
+ }else{
13708
+ showHelp(p->out, 0);
13709
+ }
1359613710
}else
1359713711
1359813712
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
1359913713
char *zTable; /* Insert data into this table */
1360013714
char *zFile; /* Name of file to extra content from */
@@ -14067,10 +14181,14 @@
1406714181
#endif
1406814182
}else if( optionMatch(z, "append") ){
1406914183
p->openMode = SHELL_OPEN_APPENDVFS;
1407014184
}else if( optionMatch(z, "readonly") ){
1407114185
p->openMode = SHELL_OPEN_READONLY;
14186
+#ifdef SQLITE_ENABLE_DESERIALIZE
14187
+ }else if( optionMatch(z, "deserialize") ){
14188
+ p->openMode = SHELL_OPEN_DESERIALIZE;
14189
+#endif
1407214190
}else if( z[0]=='-' ){
1407314191
utf8_printf(stderr, "unknown option: %s\n", z);
1407414192
rc = 1;
1407514193
goto meta_command_exit;
1407614194
}
@@ -14594,11 +14712,11 @@
1459414712
p->nSession++;
1459514713
pSession->zName = sqlite3_mprintf("%s", zName);
1459614714
}else
1459714715
/* If no command name matches, show a syntax error */
1459814716
session_syntax_error:
14599
- session_help(p);
14717
+ showHelp(p->out, "session");
1460014718
}else
1460114719
#endif
1460214720
1460314721
#ifdef SQLITE_DEBUG
1460414722
/* Undocumented commands for internal testing. Subject to change
@@ -16035,10 +16153,14 @@
1603516153
}else if( strcmp(z,"-zip")==0 ){
1603616154
data.openMode = SHELL_OPEN_ZIPFILE;
1603716155
#endif
1603816156
}else if( strcmp(z,"-append")==0 ){
1603916157
data.openMode = SHELL_OPEN_APPENDVFS;
16158
+#ifdef SQLITE_ENABLE_DESERIALIZE
16159
+ }else if( strcmp(z,"-deserialize")==0 ){
16160
+ data.openMode = SHELL_OPEN_DESERIALIZE;
16161
+#endif
1604016162
}else if( strcmp(z,"-readonly")==0 ){
1604116163
data.openMode = SHELL_OPEN_READONLY;
1604216164
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
1604316165
}else if( strncmp(z, "-A",2)==0 ){
1604416166
/* All remaining command-line arguments are passed to the ".archive"
@@ -16130,10 +16252,14 @@
1613016252
}else if( strcmp(z,"-zip")==0 ){
1613116253
data.openMode = SHELL_OPEN_ZIPFILE;
1613216254
#endif
1613316255
}else if( strcmp(z,"-append")==0 ){
1613416256
data.openMode = SHELL_OPEN_APPENDVFS;
16257
+#ifdef SQLITE_ENABLE_DESERIALIZE
16258
+ }else if( strcmp(z,"-deserialize")==0 ){
16259
+ data.openMode = SHELL_OPEN_DESERIALIZE;
16260
+#endif
1613516261
}else if( strcmp(z,"-readonly")==0 ){
1613616262
data.openMode = SHELL_OPEN_READONLY;
1613716263
}else if( strcmp(z,"-ascii")==0 ){
1613816264
data.mode = MODE_Ascii;
1613916265
sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
@@ -16274,11 +16400,11 @@
1627416400
}else{
1627516401
/* Run commands received from standard input
1627616402
*/
1627716403
if( stdin_is_interactive ){
1627816404
char *zHome;
16279
- char *zHistory = 0;
16405
+ char *zHistory;
1628016406
int nHistory;
1628116407
printf(
1628216408
"SQLite version %s %.19s\n" /*extra-version-info*/
1628316409
"Enter \".help\" for usage hints.\n",
1628416410
sqlite3_libversion(), sqlite3_sourceid()
@@ -16287,12 +16413,14 @@
1628716413
printf("Connected to a ");
1628816414
printBold("transient in-memory database");
1628916415
printf(".\nUse \".open FILENAME\" to reopen on a "
1629016416
"persistent database.\n");
1629116417
}
16292
- zHome = find_home_dir(0);
16293
- if( zHome ){
16418
+ zHistory = getenv("SQLITE_HISTORY");
16419
+ if( zHistory ){
16420
+ zHistory = strdup(zHistory);
16421
+ }else if( (zHome = find_home_dir(0))!=0 ){
1629416422
nHistory = strlen30(zHome) + 20;
1629516423
if( (zHistory = malloc(nHistory))!=0 ){
1629616424
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
1629716425
}
1629816426
}
1629916427
--- src/shell.c
+++ src/shell.c
@@ -1315,11 +1315,11 @@
1315 ** May you find forgiveness for yourself and forgive others.
1316 ** May you share freely, never taking more than you give.
1317 **
1318 ******************************************************************************
1319 **
1320 ** This SQLite extension implements a functions that compute SHA1 hashes.
1321 ** Two SQL functions are implemented:
1322 **
1323 ** sha3(X,SIZE)
1324 ** sha3_query(Y,SIZE)
1325 **
@@ -2908,11 +2908,12 @@
2908 0, /* xRollback */
2909 0, /* xFindMethod */
2910 0, /* xRename */
2911 0, /* xSavepoint */
2912 0, /* xRelease */
2913 0 /* xRollbackTo */
 
2914 };
2915
2916 int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0);
2917 return rc;
2918 }
@@ -3416,11 +3417,12 @@
3416 0, /* xRollback */
3417 0, /* xFindMethod */
3418 0, /* xRename */
3419 0, /* xSavepoint */
3420 0, /* xRelease */
3421 0 /* xRollbackTo */
 
3422 };
3423
3424 #endif /* SQLITE_OMIT_VIRTUALTABLE */
3425
3426 int sqlite3CompletionVtabInit(sqlite3 *db){
@@ -7134,10 +7136,11 @@
7134 0, /* xFindFunction - function overloading */
7135 0, /* xRename - rename the table */
7136 0, /* xSavepoint */
7137 0, /* xRelease */
7138 0, /* xRollbackTo */
 
7139 };
7140
7141 return sqlite3_create_module(p->dbv, "expert", &expertModule, (void*)p);
7142 }
7143 /*
@@ -8558,15 +8561,16 @@
8558 #define AUTOEQP_trigger 2 /* On and also show plans for triggers */
8559 #define AUTOEQP_full 3 /* Show full EXPLAIN */
8560
8561 /* Allowed values for ShellState.openMode
8562 */
8563 #define SHELL_OPEN_UNSPEC 0 /* No open-mode specified */
8564 #define SHELL_OPEN_NORMAL 1 /* Normal database file */
8565 #define SHELL_OPEN_APPENDVFS 2 /* Use appendvfs */
8566 #define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
8567 #define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
 
8568
8569 /*
8570 ** These are the allowed shellFlgs values
8571 */
8572 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -8772,11 +8776,11 @@
8772 goto edit_func_end;
8773 }
8774 if( bBin ){
8775 sqlite3_result_blob64(context, p, sz, sqlite3_free);
8776 }else{
8777 int i, j;
8778 if( hasCRNL ){
8779 /* If the original contains \r\n then do no conversions back to \n */
8780 j = sz;
8781 }else{
8782 /* If the file did not originally contain \r\n then convert any new
@@ -10834,141 +10838,242 @@
10834 }
10835 return rc;
10836 }
10837
10838 /*
10839 ** Text of a help message
 
 
 
 
 
 
10840 */
10841 static char zHelp[] =
10842 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
10843 ".archive ... Manage SQL archives: \".archive --help\" for details\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10844 #endif
10845 #ifndef SQLITE_OMIT_AUTHORIZATION
10846 ".auth ON|OFF Show authorizer callbacks\n"
10847 #endif
10848 ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
10849 " Add \"--append\" to open using appendvfs.\n"
10850 ".bail on|off Stop after hitting an error. Default OFF\n"
10851 ".binary on|off Turn binary output on or off. Default OFF\n"
10852 ".cd DIRECTORY Change the working directory to DIRECTORY\n"
10853 ".changes on|off Show number of rows changed by SQL\n"
10854 ".check GLOB Fail if output since .testcase does not match\n"
10855 ".clone NEWDB Clone data into NEWDB from the existing database\n"
10856 ".databases List names and files of attached databases\n"
10857 ".dbconfig ?op? ?val? List or change sqlite3_db_config() options\n"
10858 ".dbinfo ?DB? Show status information about the database\n"
10859 ".dump ?TABLE? ... Dump the database in an SQL text format\n"
10860 " If TABLE specified, only dump tables matching\n"
10861 " LIKE pattern TABLE.\n"
10862 ".echo on|off Turn command echo on or off\n"
10863 ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
10864 ".excel Display the output of next command in a spreadsheet\n"
10865 ".exit Exit this program\n"
10866 ".expert EXPERIMENTAL. Suggest indexes for specified queries\n"
 
 
10867 /* Because explain mode comes on automatically now, the ".explain" mode
10868 ** is removed from the help screen. It is still supported for legacy, however */
10869 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/
10870 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
10871 ".headers on|off Turn display of headers on or off\n"
10872 ".help Show this message\n"
10873 ".import FILE TABLE Import data from FILE into TABLE\n"
10874 #ifndef SQLITE_OMIT_TEST_CONTROL
10875 ".imposter INDEX TABLE Create imposter table TABLE on index INDEX\n"
10876 #endif
10877 ".indexes ?TABLE? Show names of all indexes\n"
10878 " If TABLE specified, only show indexes for tables\n"
10879 " matching LIKE pattern TABLE.\n"
10880 #ifdef SQLITE_ENABLE_IOTRACE
10881 ".iotrace FILE Enable I/O diagnostic logging to FILE\n"
10882 #endif
10883 ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n"
10884 ".lint OPTIONS Report potential schema issues. Options:\n"
10885 " fkey-indexes Find missing foreign key indexes\n"
10886 #ifndef SQLITE_OMIT_LOAD_EXTENSION
10887 ".load FILE ?ENTRY? Load an extension library\n"
10888 #endif
10889 ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
10890 ".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
10891 " ascii Columns/rows delimited by 0x1F and 0x1E\n"
10892 " csv Comma-separated values\n"
10893 " column Left-aligned columns. (See .width)\n"
10894 " html HTML <table> code\n"
10895 " insert SQL insert statements for TABLE\n"
10896 " line One value per line\n"
10897 " list Values delimited by \"|\"\n"
10898 " quote Escape answers as for SQL\n"
10899 " tabs Tab-separated values\n"
10900 " tcl TCL list elements\n"
10901 ".nullvalue STRING Use STRING in place of NULL values\n"
10902 ".once (-e|-x|FILE) Output for the next SQL command only to FILE\n"
10903 " or invoke system text editor (-e) or spreadsheet (-x)\n"
10904 " on the output.\n"
10905 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\n"
10906 " The --new option starts with an empty file\n"
10907 " Other options: --readonly --append --zip\n"
10908 ".output ?FILE? Send output to FILE or stdout\n"
10909 ".print STRING... Print literal STRING\n"
10910 ".prompt MAIN CONTINUE Replace the standard prompts\n"
10911 ".quit Exit this program\n"
10912 ".read FILENAME Execute SQL in FILENAME\n"
10913 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
10914 ".save FILE Write in-memory database into FILE\n"
10915 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
10916 ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n"
10917 " Add --indent for pretty-printing\n"
10918 ".selftest ?--init? Run tests defined in the SELFTEST table\n"
10919 ".separator COL ?ROW? Change the column separator and optionally the row\n"
10920 " separator for both the output mode and .import\n"
10921 #if defined(SQLITE_ENABLE_SESSION)
10922 ".session CMD ... Create or control sessions\n"
10923 #endif
10924 ".sha3sum ?OPTIONS...? Compute a SHA3 hash of database content\n"
10925 #ifndef SQLITE_NOHAVE_SYSTEM
10926 ".shell CMD ARGS... Run CMD ARGS... in a system shell\n"
10927 #endif
10928 ".show Show the current values for various settings\n"
10929 ".stats ?on|off? Show stats or turn stats on or off\n"
10930 #ifndef SQLITE_NOHAVE_SYSTEM
10931 ".system CMD ARGS... Run CMD ARGS... in a system shell\n"
10932 #endif
10933 ".tables ?TABLE? List names of tables\n"
10934 " If TABLE specified, only list tables matching\n"
10935 " LIKE pattern TABLE.\n"
10936 ".testcase NAME Begin redirecting output to 'testcase-out.txt'\n"
10937 ".timeout MS Try opening locked tables for MS milliseconds\n"
10938 ".timer on|off Turn SQL timer on or off\n"
10939 ".trace FILE|off Output each SQL statement as it is run\n"
10940 ".vfsinfo ?AUX? Information about the top-level VFS\n"
10941 ".vfslist List all available VFSes\n"
10942 ".vfsname ?AUX? Print the name of the VFS stack\n"
10943 ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"
10944 " Negative values right-justify\n"
10945 ;
10946
10947 #if defined(SQLITE_ENABLE_SESSION)
10948 /*
10949 ** Print help information for the ".sessions" command
10950 */
10951 void session_help(ShellState *p){
10952 raw_printf(p->out,
10953 ".session ?NAME? SUBCOMMAND ?ARGS...?\n"
10954 "If ?NAME? is omitted, the first defined session is used.\n"
10955 "Subcommands:\n"
10956 " attach TABLE Attach TABLE\n"
10957 " changeset FILE Write a changeset into FILE\n"
10958 " close Close one session\n"
10959 " enable ?BOOLEAN? Set or query the enable bit\n"
10960 " filter GLOB... Reject tables matching GLOBs\n"
10961 " indirect ?BOOLEAN? Mark or query the indirect status\n"
10962 " isempty Query whether the session is empty\n"
10963 " list List currently open session names\n"
10964 " open DB NAME Open a new session on DB\n"
10965 " patchset FILE Write a patchset into FILE\n"
10966 );
10967 }
10968 #endif
10969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10970
10971 /* Forward reference */
10972 static int process_input(ShellState *p, FILE *in);
10973
10974 /*
@@ -10994,11 +11099,11 @@
10994 if( in==0 ) return 0;
10995 fseek(in, 0, SEEK_END);
10996 nIn = ftell(in);
10997 rewind(in);
10998 pBuf = sqlite3_malloc64( nIn+1 );
10999 if( pBuf==0 ) return 0;
11000 nRead = fread(pBuf, nIn, 1, in);
11001 fclose(in);
11002 if( nRead!=1 ){
11003 sqlite3_free(pBuf);
11004 return 0;
@@ -11074,10 +11179,15 @@
11074 return SHELL_OPEN_ZIPFILE;
11075 }else{
11076 return SHELL_OPEN_NORMAL;
11077 }
11078 }
 
 
 
 
 
11079 fseek(f, -25, SEEK_END);
11080 n = fread(zBuf, 25, 1, f);
11081 if( n==1 && memcmp(zBuf, "Start-Of-SQLite3-", 17)==0 ){
11082 rc = SHELL_OPEN_APPENDVFS;
11083 }else{
@@ -11124,10 +11234,14 @@
11124 switch( p->openMode ){
11125 case SHELL_OPEN_APPENDVFS: {
11126 sqlite3_open_v2(p->zDbFilename, &p->db,
11127 SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
11128 break;
 
 
 
 
11129 }
11130 case SHELL_OPEN_ZIPFILE: {
11131 sqlite3_open(":memory:", &p->db);
11132 break;
11133 }
@@ -11174,10 +11288,22 @@
11174 char *zSql = sqlite3_mprintf(
11175 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
11176 sqlite3_exec(p->db, zSql, 0, 0, 0);
11177 sqlite3_free(zSql);
11178 }
 
 
 
 
 
 
 
 
 
 
 
 
11179 }
11180 }
11181
11182 /*
11183 ** Attempt to close the databaes connection. Report errors.
@@ -12378,10 +12504,11 @@
12378 if( *pRc==SQLITE_OK ){
12379 va_list ap;
12380 char *z;
12381 va_start(ap, zFmt);
12382 z = sqlite3_vmprintf(zFmt, ap);
 
12383 if( z==0 ){
12384 *pRc = SQLITE_NOMEM;
12385 }else{
12386 shellPrepare(db, pRc, z, ppStmt);
12387 sqlite3_free(z);
@@ -12440,36 +12567,11 @@
12440
12441 /*
12442 ** Print a usage message for the .ar command to stderr and return SQLITE_ERROR.
12443 */
12444 static int arUsage(FILE *f){
12445 raw_printf(f,
12446 "\n"
12447 "Usage: .ar [OPTION...] [FILE...]\n"
12448 "The .ar command manages sqlar archives.\n"
12449 "\n"
12450 "Examples:\n"
12451 " .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar\n"
12452 " .ar -tf archive.sar # List members of archive.sar\n"
12453 " .ar -xvf archive.sar # Verbosely extract files from archive.sar\n"
12454 "\n"
12455 "Each command line must feature exactly one command option:\n"
12456 " -c, --create Create a new archive\n"
12457 " -u, --update Update or add files to an existing archive\n"
12458 " -t, --list List contents of archive\n"
12459 " -x, --extract Extract files from archive\n"
12460 "\n"
12461 "And zero or more optional options:\n"
12462 " -v, --verbose Print each filename as it is processed\n"
12463 " -f FILE, --file FILE Operate on archive FILE (default is current db)\n"
12464 " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS\n"
12465 " -C DIR, --directory DIR Change to directory DIR to read/extract files\n"
12466 " -n, --dryrun Show the SQL that would have occurred\n"
12467 "\n"
12468 "See also: http://sqlite.org/cli.html#sqlar_archive_support\n"
12469 "\n"
12470 );
12471 return SQLITE_ERROR;
12472 }
12473
12474 /*
12475 ** Print an error message for the .ar command to stderr and return
@@ -12572,10 +12674,11 @@
12572 };
12573 int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch);
12574 struct ArSwitch *pEnd = &aSwitch[nSwitch];
12575
12576 if( nArg<=1 ){
 
12577 return arUsage(stderr);
12578 }else{
12579 char *z = azArg[1];
12580 if( z[0]!='-' ){
12581 /* Traditional style [tar] invocation */
@@ -13343,19 +13446,23 @@
13343 rc = 1;
13344 }
13345 }else
13346
13347 if( c=='d' && n>=3 && strncmp(azArg[0], "dbconfig", n)==0 ){
13348 static const struct DbConfigChoices {const char *zName; int op;} aDbConfig[] = {
 
 
 
13349 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
13350 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
13351 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
13352 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
13353 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
13354 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
13355 { "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
13356 { "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
 
13357 };
13358 int ii, v;
13359 open_db(p, 0);
13360 for(ii=0; ii<ArraySize(aDbConfig); ii++){
13361 if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -13590,11 +13697,18 @@
13590 rc = 1;
13591 }
13592 }else
13593
13594 if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
13595 utf8_printf(p->out, "%s", zHelp);
 
 
 
 
 
 
 
13596 }else
13597
13598 if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
13599 char *zTable; /* Insert data into this table */
13600 char *zFile; /* Name of file to extra content from */
@@ -14067,10 +14181,14 @@
14067 #endif
14068 }else if( optionMatch(z, "append") ){
14069 p->openMode = SHELL_OPEN_APPENDVFS;
14070 }else if( optionMatch(z, "readonly") ){
14071 p->openMode = SHELL_OPEN_READONLY;
 
 
 
 
14072 }else if( z[0]=='-' ){
14073 utf8_printf(stderr, "unknown option: %s\n", z);
14074 rc = 1;
14075 goto meta_command_exit;
14076 }
@@ -14594,11 +14712,11 @@
14594 p->nSession++;
14595 pSession->zName = sqlite3_mprintf("%s", zName);
14596 }else
14597 /* If no command name matches, show a syntax error */
14598 session_syntax_error:
14599 session_help(p);
14600 }else
14601 #endif
14602
14603 #ifdef SQLITE_DEBUG
14604 /* Undocumented commands for internal testing. Subject to change
@@ -16035,10 +16153,14 @@
16035 }else if( strcmp(z,"-zip")==0 ){
16036 data.openMode = SHELL_OPEN_ZIPFILE;
16037 #endif
16038 }else if( strcmp(z,"-append")==0 ){
16039 data.openMode = SHELL_OPEN_APPENDVFS;
 
 
 
 
16040 }else if( strcmp(z,"-readonly")==0 ){
16041 data.openMode = SHELL_OPEN_READONLY;
16042 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
16043 }else if( strncmp(z, "-A",2)==0 ){
16044 /* All remaining command-line arguments are passed to the ".archive"
@@ -16130,10 +16252,14 @@
16130 }else if( strcmp(z,"-zip")==0 ){
16131 data.openMode = SHELL_OPEN_ZIPFILE;
16132 #endif
16133 }else if( strcmp(z,"-append")==0 ){
16134 data.openMode = SHELL_OPEN_APPENDVFS;
 
 
 
 
16135 }else if( strcmp(z,"-readonly")==0 ){
16136 data.openMode = SHELL_OPEN_READONLY;
16137 }else if( strcmp(z,"-ascii")==0 ){
16138 data.mode = MODE_Ascii;
16139 sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
@@ -16274,11 +16400,11 @@
16274 }else{
16275 /* Run commands received from standard input
16276 */
16277 if( stdin_is_interactive ){
16278 char *zHome;
16279 char *zHistory = 0;
16280 int nHistory;
16281 printf(
16282 "SQLite version %s %.19s\n" /*extra-version-info*/
16283 "Enter \".help\" for usage hints.\n",
16284 sqlite3_libversion(), sqlite3_sourceid()
@@ -16287,12 +16413,14 @@
16287 printf("Connected to a ");
16288 printBold("transient in-memory database");
16289 printf(".\nUse \".open FILENAME\" to reopen on a "
16290 "persistent database.\n");
16291 }
16292 zHome = find_home_dir(0);
16293 if( zHome ){
 
 
16294 nHistory = strlen30(zHome) + 20;
16295 if( (zHistory = malloc(nHistory))!=0 ){
16296 sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
16297 }
16298 }
16299
--- src/shell.c
+++ src/shell.c
@@ -1315,11 +1315,11 @@
1315 ** May you find forgiveness for yourself and forgive others.
1316 ** May you share freely, never taking more than you give.
1317 **
1318 ******************************************************************************
1319 **
1320 ** This SQLite extension implements functions that compute SHA3 hashes.
1321 ** Two SQL functions are implemented:
1322 **
1323 ** sha3(X,SIZE)
1324 ** sha3_query(Y,SIZE)
1325 **
@@ -2908,11 +2908,12 @@
2908 0, /* xRollback */
2909 0, /* xFindMethod */
2910 0, /* xRename */
2911 0, /* xSavepoint */
2912 0, /* xRelease */
2913 0, /* xRollbackTo */
2914 0, /* xShadowName */
2915 };
2916
2917 int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0);
2918 return rc;
2919 }
@@ -3416,11 +3417,12 @@
3417 0, /* xRollback */
3418 0, /* xFindMethod */
3419 0, /* xRename */
3420 0, /* xSavepoint */
3421 0, /* xRelease */
3422 0, /* xRollbackTo */
3423 0 /* xShadowName */
3424 };
3425
3426 #endif /* SQLITE_OMIT_VIRTUALTABLE */
3427
3428 int sqlite3CompletionVtabInit(sqlite3 *db){
@@ -7134,10 +7136,11 @@
7136 0, /* xFindFunction - function overloading */
7137 0, /* xRename - rename the table */
7138 0, /* xSavepoint */
7139 0, /* xRelease */
7140 0, /* xRollbackTo */
7141 0, /* xShadowName */
7142 };
7143
7144 return sqlite3_create_module(p->dbv, "expert", &expertModule, (void*)p);
7145 }
7146 /*
@@ -8558,15 +8561,16 @@
8561 #define AUTOEQP_trigger 2 /* On and also show plans for triggers */
8562 #define AUTOEQP_full 3 /* Show full EXPLAIN */
8563
8564 /* Allowed values for ShellState.openMode
8565 */
8566 #define SHELL_OPEN_UNSPEC 0 /* No open-mode specified */
8567 #define SHELL_OPEN_NORMAL 1 /* Normal database file */
8568 #define SHELL_OPEN_APPENDVFS 2 /* Use appendvfs */
8569 #define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
8570 #define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
8571 #define SHELL_OPEN_DESERIALIZE 5 /* Open using sqlite3_deserialize() */
8572
8573 /*
8574 ** These are the allowed shellFlgs values
8575 */
8576 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -8772,11 +8776,11 @@
8776 goto edit_func_end;
8777 }
8778 if( bBin ){
8779 sqlite3_result_blob64(context, p, sz, sqlite3_free);
8780 }else{
8781 sqlite3_int64 i, j;
8782 if( hasCRNL ){
8783 /* If the original contains \r\n then do no conversions back to \n */
8784 j = sz;
8785 }else{
8786 /* If the file did not originally contain \r\n then convert any new
@@ -10834,141 +10838,242 @@
10838 }
10839 return rc;
10840 }
10841
10842 /*
10843 ** Text of help messages.
10844 **
10845 ** The help text for each individual command begins with a line that starts
10846 ** with ".". Subsequent lines are supplimental information.
10847 **
10848 ** There must be two or more spaces between the end of the command and the
10849 ** start of the description of what that command does.
10850 */
10851 static const char *(azHelp[]) = {
10852 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
10853 ".archive ... Manage SQL archives",
10854 " Each command must have exactly one of the following options:",
10855 " -c, --create Create a new archive",
10856 " -u, --update Update or add files to an existing archive",
10857 " -t, --list List contents of archive",
10858 " -x, --extract Extract files from archive",
10859 " Optional arguments:",
10860 " -v, --verbose Print each filename as it is processed",
10861 " -f FILE, --file FILE Operate on archive FILE (default is current db)",
10862 " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS",
10863 " -C DIR, --directory DIR Change to directory DIR to read/extract files",
10864 " -n, --dryrun Show the SQL that would have occurred",
10865 " Examples:",
10866 " .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar",
10867 " .ar -tf archive.sar # List members of archive.sar",
10868 " .ar -xvf archive.sar # Verbosely extract files from archive.sar",
10869 " See also:",
10870 " http://sqlite.org/cli.html#sqlar_archive_support",
10871 #endif
10872 #ifndef SQLITE_OMIT_AUTHORIZATION
10873 ".auth ON|OFF Show authorizer callbacks",
10874 #endif
10875 ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
10876 " --append Use the appendvfs",
10877 ".bail on|off Stop after hitting an error. Default OFF",
10878 ".binary on|off Turn binary output on or off. Default OFF",
10879 ".cd DIRECTORY Change the working directory to DIRECTORY",
10880 ".changes on|off Show number of rows changed by SQL",
10881 ".check GLOB Fail if output since .testcase does not match",
10882 ".clone NEWDB Clone data into NEWDB from the existing database",
10883 ".databases List names and files of attached databases",
10884 ".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
10885 ".dbinfo ?DB? Show status information about the database",
10886 ".dump ?TABLE? ... Render all database content as SQL",
10887 " Options:",
10888 " --preserve-rowids Include ROWID values in the output",
10889 " --newlines Allow unescaped newline characters in output",
10890 " TABLE is LIKE pattern for the tables to dump",
10891 ".echo on|off Turn command echo on or off",
10892 ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN",
10893 ".excel Display the output of next command in a spreadsheet",
10894 ".exit ?CODE? Exit this program with return-code CODE",
10895 ".expert EXPERIMENTAL. Suggest indexes for specified queries",
10896 /* Because explain mode comes on automatically now, the ".explain" mode
10897 ** is removed from the help screen. It is still supported for legacy, however */
10898 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
10899 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
10900 ".headers on|off Turn display of headers on or off",
10901 ".help ?-all? ?PATTERN? Show help text for PATTERN",
10902 ".import FILE TABLE Import data from FILE into TABLE",
10903 #ifndef SQLITE_OMIT_TEST_CONTROL
10904 ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
10905 #endif
10906 ".indexes ?TABLE? Show names of indexes",
10907 " If TABLE is specified, only show indexes for",
10908 " tables matching TABLE using the LIKE operator.",
10909 #ifdef SQLITE_ENABLE_IOTRACE
10910 ".iotrace FILE Enable I/O diagnostic logging to FILE",
10911 #endif
10912 ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
10913 ".lint OPTIONS Report potential schema issues.",
10914 " Options:",
10915 " fkey-indexes Find missing foreign key indexes",
10916 #ifndef SQLITE_OMIT_LOAD_EXTENSION
10917 ".load FILE ?ENTRY? Load an extension library",
10918 #endif
10919 ".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
10920 ".mode MODE ?TABLE? Set output mode",
10921 " MODE is one of:",
10922 " ascii Columns/rows delimited by 0x1F and 0x1E",
10923 " csv Comma-separated values",
10924 " column Left-aligned columns. (See .width)",
10925 " html HTML <table> code",
10926 " insert SQL insert statements for TABLE",
10927 " line One value per line",
10928 " list Values delimited by \"|\"",
10929 " quote Escape answers as for SQL",
10930 " tabs Tab-separated values",
10931 " tcl TCL list elements",
10932 ".nullvalue STRING Use STRING in place of NULL values",
10933 ".once (-e|-x|FILE) Output for the next SQL command only to FILE",
10934 " If FILE begins with '|' then open as a pipe",
10935 " Other options:",
10936 " -e Invoke system text editor",
10937 " -x Open in a spreadsheet",
10938 ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
10939 " Options:",
10940 " --append Use appendvfs to append database to the end of FILE",
10941 #ifdef SQLITE_ENABLE_DESERIALIZE
10942 " --deserialize Load into memory useing sqlite3_deserialize()",
10943 #endif
10944 " --new Initialize FILE to an empty database",
10945 " --readonly Open FILE readonly",
10946 " --zip FILE is a ZIP archive",
10947 ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
10948 " If FILE begins with '|' then open it as a pipe.",
10949 ".print STRING... Print literal STRING",
10950 ".prompt MAIN CONTINUE Replace the standard prompts",
10951 ".quit Exit this program",
10952 ".read FILE Read input from FILE",
10953 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
10954 ".save FILE Write in-memory database into FILE",
10955 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
10956 ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
10957 " Options:",
10958 " --indent Try to pretty-print the schema",
10959 ".selftest ?OPTIONS? Run tests defined in the SELFTEST table",
10960 " Options:",
10961 " --init Create a new SELFTEST table",
10962 " -v Verbose output",
10963 ".separator COL ?ROW? Change the column and row separators",
10964 #if defined(SQLITE_ENABLE_SESSION)
10965 ".session ?NAME? CMD ... Create or control sessions",
10966 " Subcommands:",
10967 " attach TABLE Attach TABLE",
10968 " changeset FILE Write a changeset into FILE",
10969 " close Close one session",
10970 " enable ?BOOLEAN? Set or query the enable bit",
10971 " filter GLOB... Reject tables matching GLOBs",
10972 " indirect ?BOOLEAN? Mark or query the indirect status",
10973 " isempty Query whether the session is empty",
10974 " list List currently open session names",
10975 " open DB NAME Open a new session on DB",
10976 " patchset FILE Write a patchset into FILE",
10977 " If ?NAME? is omitted, the first defined session is used.",
10978 #endif
10979 ".sha3sum ... Compute a SHA3 hash of database content",
10980 " Options:",
10981 " --schema Also hash the sqlite_master table",
10982 " --sha3-224 Use the sha3-224 algorithm",
10983 " --sha3-256 Use the sha3-256 algorithm. This is the default.",
10984 " --sha3-384 Use the sha3-384 algorithm",
10985 " --sha3-512 Use the sha3-512 algorithm",
10986 " Any other argument is a LIKE pattern for tables to hash",
10987 #ifndef SQLITE_NOHAVE_SYSTEM
10988 ".shell CMD ARGS... Run CMD ARGS... in a system shell",
10989 #endif
10990 ".show Show the current values for various settings",
10991 ".stats ?on|off? Show stats or turn stats on or off",
10992 #ifndef SQLITE_NOHAVE_SYSTEM
10993 ".system CMD ARGS... Run CMD ARGS... in a system shell",
10994 #endif
10995 ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
10996 ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
10997 ".timeout MS Try opening locked tables for MS milliseconds",
10998 ".timer on|off Turn SQL timer on or off",
10999 ".trace FILE|off Output each SQL statement as it is run",
11000 ".vfsinfo ?AUX? Information about the top-level VFS",
11001 ".vfslist List all available VFSes",
11002 ".vfsname ?AUX? Print the name of the VFS stack",
11003 ".width NUM1 NUM2 ... Set column widths for \"column\" mode",
11004 " Negative values right-justify",
11005 };
11006
11007 /*
11008 ** Output help text.
11009 **
11010 ** zPattern describes the set of commands for which help text is provided.
11011 ** If zPattern is NULL, then show all commands, but only give a one-line
11012 ** description of each.
11013 **
11014 ** Return the number of matches.
11015 */
11016 static int showHelp(FILE *out, const char *zPattern){
11017 int i = 0;
11018 int j = 0;
11019 int n = 0;
11020 char *zPat;
11021 if( zPattern==0
11022 || zPattern[0]=='0'
11023 || strcmp(zPattern,"-a")==0
11024 || strcmp(zPattern,"-all")==0
11025 ){
11026 /* Show all commands, but only one line per command */
11027 if( zPattern==0 ) zPattern = "";
11028 for(i=0; i<ArraySize(azHelp); i++){
11029 if( azHelp[i][0]=='.' || zPattern[0] ){
11030 utf8_printf(out, "%s\n", azHelp[i]);
11031 n++;
11032 }
11033 }
11034 }else{
11035 /* Look for commands that for which zPattern is an exact prefix */
11036 zPat = sqlite3_mprintf(".%s*", zPattern);
11037 for(i=0; i<ArraySize(azHelp); i++){
11038 if( sqlite3_strglob(zPat, azHelp[i])==0 ){
11039 utf8_printf(out, "%s\n", azHelp[i]);
11040 j = i+1;
11041 n++;
11042 }
11043 }
11044 sqlite3_free(zPat);
11045 if( n ){
11046 if( n==1 ){
11047 /* when zPattern is a prefix of exactly one command, then include the
11048 ** details of that command, which should begin at offset j */
11049 while( j<ArraySize(azHelp)-1 && azHelp[j][0]!='.' ){
11050 utf8_printf(out, "%s\n", azHelp[j]);
11051 j++;
11052 }
11053 }
11054 return n;
11055 }
11056 /* Look for commands that contain zPattern anywhere. Show the complete
11057 ** text of all commands that match. */
11058 zPat = sqlite3_mprintf("%%%s%%", zPattern);
11059 for(i=0; i<ArraySize(azHelp); i++){
11060 if( azHelp[i][0]=='.' ) j = i;
11061 if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
11062 utf8_printf(out, "%s\n", azHelp[j]);
11063 while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]!='.' ){
11064 j++;
11065 utf8_printf(out, "%s\n", azHelp[j]);
11066 }
11067 i = j;
11068 n++;
11069 }
11070 }
11071 sqlite3_free(zPat);
11072 }
11073 return n;
11074 }
11075
11076 /* Forward reference */
11077 static int process_input(ShellState *p, FILE *in);
11078
11079 /*
@@ -10994,11 +11099,11 @@
11099 if( in==0 ) return 0;
11100 fseek(in, 0, SEEK_END);
11101 nIn = ftell(in);
11102 rewind(in);
11103 pBuf = sqlite3_malloc64( nIn+1 );
11104 if( pBuf==0 ){ fclose(in); return 0; }
11105 nRead = fread(pBuf, nIn, 1, in);
11106 fclose(in);
11107 if( nRead!=1 ){
11108 sqlite3_free(pBuf);
11109 return 0;
@@ -11074,10 +11179,15 @@
11179 return SHELL_OPEN_ZIPFILE;
11180 }else{
11181 return SHELL_OPEN_NORMAL;
11182 }
11183 }
11184 n = fread(zBuf, 16, 1, f);
11185 if( n==1 && memcmp(zBuf, "SQLite format 3", 16)==0 ){
11186 fclose(f);
11187 return SHELL_OPEN_NORMAL;
11188 }
11189 fseek(f, -25, SEEK_END);
11190 n = fread(zBuf, 25, 1, f);
11191 if( n==1 && memcmp(zBuf, "Start-Of-SQLite3-", 17)==0 ){
11192 rc = SHELL_OPEN_APPENDVFS;
11193 }else{
@@ -11124,10 +11234,14 @@
11234 switch( p->openMode ){
11235 case SHELL_OPEN_APPENDVFS: {
11236 sqlite3_open_v2(p->zDbFilename, &p->db,
11237 SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
11238 break;
11239 }
11240 case SHELL_OPEN_DESERIALIZE: {
11241 sqlite3_open(0, &p->db);
11242 break;
11243 }
11244 case SHELL_OPEN_ZIPFILE: {
11245 sqlite3_open(":memory:", &p->db);
11246 break;
11247 }
@@ -11174,10 +11288,22 @@
11288 char *zSql = sqlite3_mprintf(
11289 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename);
11290 sqlite3_exec(p->db, zSql, 0, 0, 0);
11291 sqlite3_free(zSql);
11292 }
11293 #ifdef SQLITE_ENABLE_DESERIALIZE
11294 else if( p->openMode==SHELL_OPEN_DESERIALIZE ){
11295 int nData = 0;
11296 unsigned char *aData = (unsigned char*)readFile(p->zDbFilename, &nData);
11297 int rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
11298 SQLITE_DESERIALIZE_RESIZEABLE |
11299 SQLITE_DESERIALIZE_FREEONCLOSE);
11300 if( rc ){
11301 utf8_printf(stderr, "Error: sqlite3_deserialize() returns %d\n", rc);
11302 }
11303 }
11304 #endif
11305 }
11306 }
11307
11308 /*
11309 ** Attempt to close the databaes connection. Report errors.
@@ -12378,10 +12504,11 @@
12504 if( *pRc==SQLITE_OK ){
12505 va_list ap;
12506 char *z;
12507 va_start(ap, zFmt);
12508 z = sqlite3_vmprintf(zFmt, ap);
12509 va_end(ap);
12510 if( z==0 ){
12511 *pRc = SQLITE_NOMEM;
12512 }else{
12513 shellPrepare(db, pRc, z, ppStmt);
12514 sqlite3_free(z);
@@ -12440,36 +12567,11 @@
12567
12568 /*
12569 ** Print a usage message for the .ar command to stderr and return SQLITE_ERROR.
12570 */
12571 static int arUsage(FILE *f){
12572 showHelp(f,"archive");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12573 return SQLITE_ERROR;
12574 }
12575
12576 /*
12577 ** Print an error message for the .ar command to stderr and return
@@ -12572,10 +12674,11 @@
12674 };
12675 int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch);
12676 struct ArSwitch *pEnd = &aSwitch[nSwitch];
12677
12678 if( nArg<=1 ){
12679 utf8_printf(stderr, "Wrong number of arguments. Usage:\n");
12680 return arUsage(stderr);
12681 }else{
12682 char *z = azArg[1];
12683 if( z[0]!='-' ){
12684 /* Traditional style [tar] invocation */
@@ -13343,19 +13446,23 @@
13446 rc = 1;
13447 }
13448 }else
13449
13450 if( c=='d' && n>=3 && strncmp(azArg[0], "dbconfig", n)==0 ){
13451 static const struct DbConfigChoices {
13452 const char *zName;
13453 int op;
13454 } aDbConfig[] = {
13455 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
13456 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
13457 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
13458 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
13459 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
13460 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
13461 { "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
13462 { "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
13463 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
13464 };
13465 int ii, v;
13466 open_db(p, 0);
13467 for(ii=0; ii<ArraySize(aDbConfig); ii++){
13468 if( nArg>1 && strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
@@ -13590,11 +13697,18 @@
13697 rc = 1;
13698 }
13699 }else
13700
13701 if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
13702 if( nArg>=2 ){
13703 n = showHelp(p->out, azArg[1]);
13704 if( n==0 ){
13705 utf8_printf(p->out, "Nothing matches '%s'\n", azArg[1]);
13706 }
13707 }else{
13708 showHelp(p->out, 0);
13709 }
13710 }else
13711
13712 if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
13713 char *zTable; /* Insert data into this table */
13714 char *zFile; /* Name of file to extra content from */
@@ -14067,10 +14181,14 @@
14181 #endif
14182 }else if( optionMatch(z, "append") ){
14183 p->openMode = SHELL_OPEN_APPENDVFS;
14184 }else if( optionMatch(z, "readonly") ){
14185 p->openMode = SHELL_OPEN_READONLY;
14186 #ifdef SQLITE_ENABLE_DESERIALIZE
14187 }else if( optionMatch(z, "deserialize") ){
14188 p->openMode = SHELL_OPEN_DESERIALIZE;
14189 #endif
14190 }else if( z[0]=='-' ){
14191 utf8_printf(stderr, "unknown option: %s\n", z);
14192 rc = 1;
14193 goto meta_command_exit;
14194 }
@@ -14594,11 +14712,11 @@
14712 p->nSession++;
14713 pSession->zName = sqlite3_mprintf("%s", zName);
14714 }else
14715 /* If no command name matches, show a syntax error */
14716 session_syntax_error:
14717 showHelp(p->out, "session");
14718 }else
14719 #endif
14720
14721 #ifdef SQLITE_DEBUG
14722 /* Undocumented commands for internal testing. Subject to change
@@ -16035,10 +16153,14 @@
16153 }else if( strcmp(z,"-zip")==0 ){
16154 data.openMode = SHELL_OPEN_ZIPFILE;
16155 #endif
16156 }else if( strcmp(z,"-append")==0 ){
16157 data.openMode = SHELL_OPEN_APPENDVFS;
16158 #ifdef SQLITE_ENABLE_DESERIALIZE
16159 }else if( strcmp(z,"-deserialize")==0 ){
16160 data.openMode = SHELL_OPEN_DESERIALIZE;
16161 #endif
16162 }else if( strcmp(z,"-readonly")==0 ){
16163 data.openMode = SHELL_OPEN_READONLY;
16164 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
16165 }else if( strncmp(z, "-A",2)==0 ){
16166 /* All remaining command-line arguments are passed to the ".archive"
@@ -16130,10 +16252,14 @@
16252 }else if( strcmp(z,"-zip")==0 ){
16253 data.openMode = SHELL_OPEN_ZIPFILE;
16254 #endif
16255 }else if( strcmp(z,"-append")==0 ){
16256 data.openMode = SHELL_OPEN_APPENDVFS;
16257 #ifdef SQLITE_ENABLE_DESERIALIZE
16258 }else if( strcmp(z,"-deserialize")==0 ){
16259 data.openMode = SHELL_OPEN_DESERIALIZE;
16260 #endif
16261 }else if( strcmp(z,"-readonly")==0 ){
16262 data.openMode = SHELL_OPEN_READONLY;
16263 }else if( strcmp(z,"-ascii")==0 ){
16264 data.mode = MODE_Ascii;
16265 sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
@@ -16274,11 +16400,11 @@
16400 }else{
16401 /* Run commands received from standard input
16402 */
16403 if( stdin_is_interactive ){
16404 char *zHome;
16405 char *zHistory;
16406 int nHistory;
16407 printf(
16408 "SQLite version %s %.19s\n" /*extra-version-info*/
16409 "Enter \".help\" for usage hints.\n",
16410 sqlite3_libversion(), sqlite3_sourceid()
@@ -16287,12 +16413,14 @@
16413 printf("Connected to a ");
16414 printBold("transient in-memory database");
16415 printf(".\nUse \".open FILENAME\" to reopen on a "
16416 "persistent database.\n");
16417 }
16418 zHistory = getenv("SQLITE_HISTORY");
16419 if( zHistory ){
16420 zHistory = strdup(zHistory);
16421 }else if( (zHome = find_home_dir(0))!=0 ){
16422 nHistory = strlen30(zHome) + 20;
16423 if( (zHistory = malloc(nHistory))!=0 ){
16424 sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
16425 }
16426 }
16427
+4 -2
--- src/skins.c
+++ src/skins.c
@@ -676,15 +676,17 @@
676676
if( fossil_strcmp(zLabel, "current")==0 ){
677677
zResult = db_get(zFile, "");
678678
}else if( sqlite3_strglob("draft[1-9]", zLabel)==0 ){
679679
zResult = db_get_mprintf("", "%s-%s", zLabel, zFile);
680680
}else{
681
- while( 1 ){
681
+ int i;
682
+ for(i=0; i<2; i++){
682683
char *zKey = mprintf("skins/%s/%s.txt", zLabel, zFile);
683684
zResult = builtin_text(zKey);
684685
fossil_free(zKey);
685
- if( zResult!=0 || fossil_strcmp(zLabel,"default")==0 ) break;
686
+ if( zResult!=0 ) break;
687
+ zLabel = "default";
686688
}
687689
}
688690
return zResult;
689691
}
690692
691693
--- src/skins.c
+++ src/skins.c
@@ -676,15 +676,17 @@
676 if( fossil_strcmp(zLabel, "current")==0 ){
677 zResult = db_get(zFile, "");
678 }else if( sqlite3_strglob("draft[1-9]", zLabel)==0 ){
679 zResult = db_get_mprintf("", "%s-%s", zLabel, zFile);
680 }else{
681 while( 1 ){
 
682 char *zKey = mprintf("skins/%s/%s.txt", zLabel, zFile);
683 zResult = builtin_text(zKey);
684 fossil_free(zKey);
685 if( zResult!=0 || fossil_strcmp(zLabel,"default")==0 ) break;
 
686 }
687 }
688 return zResult;
689 }
690
691
--- src/skins.c
+++ src/skins.c
@@ -676,15 +676,17 @@
676 if( fossil_strcmp(zLabel, "current")==0 ){
677 zResult = db_get(zFile, "");
678 }else if( sqlite3_strglob("draft[1-9]", zLabel)==0 ){
679 zResult = db_get_mprintf("", "%s-%s", zLabel, zFile);
680 }else{
681 int i;
682 for(i=0; i<2; i++){
683 char *zKey = mprintf("skins/%s/%s.txt", zLabel, zFile);
684 zResult = builtin_text(zKey);
685 fossil_free(zKey);
686 if( zResult!=0 ) break;
687 zLabel = "default";
688 }
689 }
690 return zResult;
691 }
692
693
+2140 -879
--- 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.25.2. By combining all the individual C code files into this
3
+** version 3.26.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -257,10 +257,13 @@
257257
#if SQLITE_ENABLE_FTS4
258258
"ENABLE_FTS4",
259259
#endif
260260
#if SQLITE_ENABLE_FTS5
261261
"ENABLE_FTS5",
262
+#endif
263
+#if SQLITE_ENABLE_GEOPOLY
264
+ "ENABLE_GEOPOLY",
262265
#endif
263266
#if SQLITE_ENABLE_HIDDEN_COLUMNS
264267
"ENABLE_HIDDEN_COLUMNS",
265268
#endif
266269
#if SQLITE_ENABLE_ICU
@@ -287,10 +290,13 @@
287290
#if SQLITE_ENABLE_MEMSYS5
288291
"ENABLE_MEMSYS5",
289292
#endif
290293
#if SQLITE_ENABLE_MULTIPLEX
291294
"ENABLE_MULTIPLEX",
295
+#endif
296
+#if SQLITE_ENABLE_NORMALIZE
297
+ "ENABLE_NORMALIZE",
292298
#endif
293299
#if SQLITE_ENABLE_NULL_TRIM
294300
"ENABLE_NULL_TRIM",
295301
#endif
296302
#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
@@ -1154,13 +1160,13 @@
11541160
**
11551161
** See also: [sqlite3_libversion()],
11561162
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11571163
** [sqlite_version()] and [sqlite_source_id()].
11581164
*/
1159
-#define SQLITE_VERSION "3.25.2"
1160
-#define SQLITE_VERSION_NUMBER 3025002
1161
-#define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7"
1165
+#define SQLITE_VERSION "3.26.0"
1166
+#define SQLITE_VERSION_NUMBER 3026000
1167
+#define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513"
11621168
11631169
/*
11641170
** CAPI3REF: Run-Time Library Version Numbers
11651171
** KEYWORDS: sqlite3_version sqlite3_sourceid
11661172
**
@@ -3048,10 +3054,11 @@
30483054
** the call worked. ^The [sqlite3_db_config()] interface will return a
30493055
** non-zero [error code] if a discontinued or unsupported configuration option
30503056
** is invoked.
30513057
**
30523058
** <dl>
3059
+** [[SQLITE_DBCONFIG_LOOKASIDE]]
30533060
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
30543061
** <dd> ^This option takes three additional arguments that determine the
30553062
** [lookaside memory allocator] configuration for the [database connection].
30563063
** ^The first argument (the third parameter to [sqlite3_db_config()] is a
30573064
** pointer to a memory buffer to use for lookaside memory.
@@ -3070,10 +3077,11 @@
30703077
** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
30713078
** Any attempt to change the lookaside memory configuration when lookaside
30723079
** memory is in use leaves the configuration unchanged and returns
30733080
** [SQLITE_BUSY].)^</dd>
30743081
**
3082
+** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
30753083
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
30763084
** <dd> ^This option is used to enable or disable the enforcement of
30773085
** [foreign key constraints]. There should be two additional arguments.
30783086
** The first argument is an integer which is 0 to disable FK enforcement,
30793087
** positive to enable FK enforcement or negative to leave FK enforcement
@@ -3080,10 +3088,11 @@
30803088
** unchanged. The second parameter is a pointer to an integer into which
30813089
** is written 0 or 1 to indicate whether FK enforcement is off or on
30823090
** following this call. The second parameter may be a NULL pointer, in
30833091
** which case the FK enforcement setting is not reported back. </dd>
30843092
**
3093
+** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]
30853094
** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
30863095
** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
30873096
** There should be two additional arguments.
30883097
** The first argument is an integer which is 0 to disable triggers,
30893098
** positive to enable triggers or negative to leave the setting unchanged.
@@ -3090,10 +3099,11 @@
30903099
** The second parameter is a pointer to an integer into which
30913100
** is written 0 or 1 to indicate whether triggers are disabled or enabled
30923101
** following this call. The second parameter may be a NULL pointer, in
30933102
** which case the trigger setting is not reported back. </dd>
30943103
**
3104
+** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
30953105
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
30963106
** <dd> ^This option is used to enable or disable the two-argument
30973107
** version of the [fts3_tokenizer()] function which is part of the
30983108
** [FTS3] full-text search engine extension.
30993109
** There should be two additional arguments.
@@ -3103,10 +3113,11 @@
31033113
** The second parameter is a pointer to an integer into which
31043114
** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
31053115
** following this call. The second parameter may be a NULL pointer, in
31063116
** which case the new setting is not reported back. </dd>
31073117
**
3118
+** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]
31083119
** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
31093120
** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
31103121
** interface independently of the [load_extension()] SQL function.
31113122
** The [sqlite3_enable_load_extension()] API enables or disables both the
31123123
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -3120,19 +3131,20 @@
31203131
** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
31213132
** is disabled or enabled following this call. The second parameter may
31223133
** be a NULL pointer, in which case the new setting is not reported back.
31233134
** </dd>
31243135
**
3125
-** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
3136
+** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
31263137
** <dd> ^This option is used to change the name of the "main" database
31273138
** schema. ^The sole argument is a pointer to a constant UTF8 string
31283139
** which will become the new schema name in place of "main". ^SQLite
31293140
** does not make a copy of the new main schema name string, so the application
31303141
** must ensure that the argument passed into this DBCONFIG option is unchanged
31313142
** until after the database connection closes.
31323143
** </dd>
31333144
**
3145
+** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
31343146
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
31353147
** <dd> Usually, when a database in wal mode is closed or detached from a
31363148
** database handle, SQLite checks if this will mean that there are now no
31373149
** connections at all to the database. If so, it performs a checkpoint
31383150
** operation before closing the connection. This option may be used to
@@ -3142,11 +3154,11 @@
31423154
** The second parameter is a pointer to an integer
31433155
** into which is written 0 or 1 to indicate whether checkpoints-on-close
31443156
** have been disabled - 0 if they are not disabled, 1 if they are.
31453157
** </dd>
31463158
**
3147
-** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3159
+** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
31483160
** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
31493161
** the [query planner stability guarantee] (QPSG). When the QPSG is active,
31503162
** a single SQL query statement will always use the same algorithm regardless
31513163
** of values of [bound parameters].)^ The QPSG disables some query optimizations
31523164
** that look at the values of bound parameters, which can make some queries
@@ -3158,11 +3170,11 @@
31583170
** unchanged. The second parameter is a pointer to an integer into which
31593171
** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
31603172
** following this call.
31613173
** </dd>
31623174
**
3163
-** <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
3175
+** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
31643176
** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
31653177
** include output for any operations performed by trigger programs. This
31663178
** option is used to set or clear (the default) a flag that governs this
31673179
** behavior. The first parameter passed to this operation is an integer -
31683180
** positive to enable output for trigger programs, or zero to disable it,
@@ -3170,11 +3182,11 @@
31703182
** The second parameter is a pointer to an integer into which is written
31713183
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
31723184
** it is not disabled, 1 if it is.
31733185
** </dd>
31743186
**
3175
-** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
3187
+** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
31763188
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
31773189
** [VACUUM] in order to reset a database back to an empty database
31783190
** with no schema and no content. The following process works even for
31793191
** a badly corrupted database file:
31803192
** <ol>
@@ -3189,10 +3201,22 @@
31893201
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
31903202
** </ol>
31913203
** Because resetting a database is destructive and irreversible, the
31923204
** process requires the use of this obscure API and multiple steps to help
31933205
** ensure that it does not happen by accident.
3206
+**
3207
+** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
3208
+** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
3209
+** "defensive" flag for a database connection. When the defensive
3210
+** flag is enabled, language features that allow ordinary SQL to
3211
+** deliberately corrupt the database file are disabled. The disabled
3212
+** features include but are not limited to the following:
3213
+** <ul>
3214
+** <li> The [PRAGMA writable_schema=ON] statement.
3215
+** <li> Writes to the [sqlite_dbpage] virtual table.
3216
+** <li> Direct writes to [shadow tables].
3217
+** </ul>
31943218
** </dd>
31953219
** </dl>
31963220
*/
31973221
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
31983222
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -3202,11 +3226,12 @@
32023226
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
32033227
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
32043228
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
32053229
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
32063230
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
3207
-#define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
3231
+#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3232
+#define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
32083233
32093234
/*
32103235
** CAPI3REF: Enable Or Disable Extended Result Codes
32113236
** METHOD: sqlite3
32123237
**
@@ -4640,13 +4665,23 @@
46404665
** be used just once or at most a few times and then destroyed using
46414666
** [sqlite3_finalize()] relatively soon. The current implementation acts
46424667
** on this hint by avoiding the use of [lookaside memory] so as not to
46434668
** deplete the limited store of lookaside memory. Future versions of
46444669
** SQLite may act on this hint differently.
4670
+**
4671
+** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
4672
+** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
4673
+** representation of the SQL statement should be calculated and then
4674
+** associated with the prepared statement, which can be obtained via
4675
+** the [sqlite3_normalized_sql()] interface. The semantics used to
4676
+** normalize a SQL statement are unspecified and subject to change.
4677
+** At a minimum, literal values will be replaced with suitable
4678
+** placeholders.
46454679
** </dl>
46464680
*/
46474681
#define SQLITE_PREPARE_PERSISTENT 0x01
4682
+#define SQLITE_PREPARE_NORMALIZE 0x02
46484683
46494684
/*
46504685
** CAPI3REF: Compiling An SQL Statement
46514686
** KEYWORDS: {SQL statement compiler}
46524687
** METHOD: sqlite3
@@ -4800,10 +4835,15 @@
48004835
** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
48014836
** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
48024837
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
48034838
** string containing the SQL text of prepared statement P with
48044839
** [bound parameters] expanded.
4840
+** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8
4841
+** string containing the normalized SQL text of prepared statement P. The
4842
+** semantics used to normalize a SQL statement are unspecified and subject
4843
+** to change. At a minimum, literal values will be replaced with suitable
4844
+** placeholders.
48054845
**
48064846
** ^(For example, if a prepared statement is created using the SQL
48074847
** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
48084848
** and parameter :xyz is unbound, then sqlite3_sql() will return
48094849
** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -4815,18 +4855,20 @@
48154855
**
48164856
** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
48174857
** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
48184858
** option causes sqlite3_expanded_sql() to always return NULL.
48194859
**
4820
-** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
4821
-** automatically freed when the prepared statement is finalized.
4860
+** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
4861
+** are managed by SQLite and are automatically freed when the prepared
4862
+** statement is finalized.
48224863
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
48234864
** is obtained from [sqlite3_malloc()] and must be free by the application
48244865
** by passing it to [sqlite3_free()].
48254866
*/
48264867
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
48274868
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4869
+SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
48284870
48294871
/*
48304872
** CAPI3REF: Determine If An SQL Statement Writes The Database
48314873
** METHOD: sqlite3_stmt
48324874
**
@@ -7312,10 +7354,13 @@
73127354
/* The methods above are in version 1 of the sqlite_module object. Those
73137355
** below are for version 2 and greater. */
73147356
int (*xSavepoint)(sqlite3_vtab *pVTab, int);
73157357
int (*xRelease)(sqlite3_vtab *pVTab, int);
73167358
int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
7359
+ /* The methods above are in versions 1 and 2 of the sqlite_module object.
7360
+ ** Those below are for version 3 and greater. */
7361
+ int (*xShadowName)(const char*);
73177362
};
73187363
73197364
/*
73207365
** CAPI3REF: Virtual Table Indexing Information
73217366
** KEYWORDS: sqlite3_index_info
@@ -9646,10 +9691,11 @@
96469691
** These macros define the various options to the
96479692
** [sqlite3_vtab_config()] interface that [virtual table] implementations
96489693
** can use to customize and optimize their behavior.
96499694
**
96509695
** <dl>
9696
+** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]
96519697
** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
96529698
** <dd>Calls of the form
96539699
** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
96549700
** where X is an integer. If X is zero, then the [virtual table] whose
96559701
** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -10911,16 +10957,42 @@
1091110957
** an application iterates through a changeset using an iterator created by
1091210958
** this function, all changes that relate to a single table are visited
1091310959
** consecutively. There is no chance that the iterator will visit a change
1091410960
** the applies to table X, then one for table Y, and then later on visit
1091510961
** another change for table X.
10962
+**
10963
+** The behavior of sqlite3changeset_start_v2() and its streaming equivalent
10964
+** may be modified by passing a combination of
10965
+** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.
10966
+**
10967
+** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>
10968
+** and therefore subject to change.
1091610969
*/
1091710970
SQLITE_API int sqlite3changeset_start(
1091810971
sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
1091910972
int nChangeset, /* Size of changeset blob in bytes */
1092010973
void *pChangeset /* Pointer to blob containing changeset */
1092110974
);
10975
+SQLITE_API int sqlite3changeset_start_v2(
10976
+ sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
10977
+ int nChangeset, /* Size of changeset blob in bytes */
10978
+ void *pChangeset, /* Pointer to blob containing changeset */
10979
+ int flags /* SESSION_CHANGESETSTART_* flags */
10980
+);
10981
+
10982
+/*
10983
+** CAPI3REF: Flags for sqlite3changeset_start_v2
10984
+**
10985
+** The following flags may passed via the 4th parameter to
10986
+** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
10987
+**
10988
+** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
10989
+** Invert the changeset while iterating through it. This is equivalent to
10990
+** inverting a changeset using sqlite3changeset_invert() before applying it.
10991
+** It is an error to specify this flag with a patchset.
10992
+*/
10993
+#define SQLITE_CHANGESETSTART_INVERT 0x0002
1092210994
1092310995
1092410996
/*
1092510997
** CAPI3REF: Advance A Changeset Iterator
1092610998
** METHOD: sqlite3_changeset_iter
@@ -11571,11 +11643,11 @@
1157111643
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1157211644
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1157311645
),
1157411646
void *pCtx, /* First argument passed to xConflict */
1157511647
void **ppRebase, int *pnRebase, /* OUT: Rebase data */
11576
- int flags /* Combination of SESSION_APPLY_* flags */
11648
+ int flags /* SESSION_CHANGESETAPPLY_* flags */
1157711649
);
1157811650
1157911651
/*
1158011652
** CAPI3REF: Flags for sqlite3changeset_apply_v2
1158111653
**
@@ -11589,12 +11661,18 @@
1158911661
** SAVEPOINT is committed if the changeset or patchset is successfully
1159011662
** applied, or rolled back if an error occurs. Specifying this flag
1159111663
** causes the sessions module to omit this savepoint. In this case, if the
1159211664
** caller has an open transaction or savepoint when apply_v2() is called,
1159311665
** it may revert the partially applied changeset by rolling it back.
11666
+**
11667
+** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
11668
+** Invert the changeset before applying it. This is equivalent to inverting
11669
+** a changeset using sqlite3changeset_invert() before applying it. It is
11670
+** an error to specify this flag with a patchset.
1159411671
*/
1159511672
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
11673
+#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
1159611674
1159711675
/*
1159811676
** CAPI3REF: Constants Passed To The Conflict Handler
1159911677
**
1160011678
** Values that may be passed as the second argument to a conflict-handler.
@@ -11983,10 +12061,16 @@
1198312061
);
1198412062
SQLITE_API int sqlite3changeset_start_strm(
1198512063
sqlite3_changeset_iter **pp,
1198612064
int (*xInput)(void *pIn, void *pData, int *pnData),
1198712065
void *pIn
12066
+);
12067
+SQLITE_API int sqlite3changeset_start_v2_strm(
12068
+ sqlite3_changeset_iter **pp,
12069
+ int (*xInput)(void *pIn, void *pData, int *pnData),
12070
+ void *pIn,
12071
+ int flags
1198812072
);
1198912073
SQLITE_API int sqlite3session_changeset_strm(
1199012074
sqlite3_session *pSession,
1199112075
int (*xOutput)(void *pOut, const void *pData, int nData),
1199212076
void *pOut
@@ -12010,10 +12094,49 @@
1201012094
void *pIn,
1201112095
int (*xOutput)(void *pOut, const void *pData, int nData),
1201212096
void *pOut
1201312097
);
1201412098
12099
+/*
12100
+** CAPI3REF: Configure global parameters
12101
+**
12102
+** The sqlite3session_config() interface is used to make global configuration
12103
+** changes to the sessions module in order to tune it to the specific needs
12104
+** of the application.
12105
+**
12106
+** The sqlite3session_config() interface is not threadsafe. If it is invoked
12107
+** while any other thread is inside any other sessions method then the
12108
+** results are undefined. Furthermore, if it is invoked after any sessions
12109
+** related objects have been created, the results are also undefined.
12110
+**
12111
+** The first argument to the sqlite3session_config() function must be one
12112
+** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The
12113
+** interpretation of the (void*) value passed as the second parameter and
12114
+** the effect of calling this function depends on the value of the first
12115
+** parameter.
12116
+**
12117
+** <dl>
12118
+** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>
12119
+** By default, the sessions module streaming interfaces attempt to input
12120
+** and output data in approximately 1 KiB chunks. This operand may be used
12121
+** to set and query the value of this configuration setting. The pointer
12122
+** passed as the second argument must point to a value of type (int).
12123
+** If this value is greater than 0, it is used as the new streaming data
12124
+** chunk size for both input and output. Before returning, the (int) value
12125
+** pointed to by pArg is set to the final value of the streaming interface
12126
+** chunk size.
12127
+** </dl>
12128
+**
12129
+** This function returns SQLITE_OK if successful, or an SQLite error code
12130
+** otherwise.
12131
+*/
12132
+SQLITE_API int sqlite3session_config(int op, void *pArg);
12133
+
12134
+/*
12135
+** CAPI3REF: Values for sqlite3session_config().
12136
+*/
12137
+#define SQLITE_SESSION_CONFIG_STRMSIZE 1
1201512138
1201612139
/*
1201712140
** Make sure we can call this stuff from C++.
1201812141
*/
1201912142
#if 0
@@ -16036,16 +16159,18 @@
1603616159
/*
1603716160
** A hash table for built-in function definitions. (Application-defined
1603816161
** functions use a regular table table from hash.h.)
1603916162
**
1604016163
** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
16041
-** Collisions are on the FuncDef.u.pHash chain.
16164
+** Collisions are on the FuncDef.u.pHash chain. Use the SQLITE_FUNC_HASH()
16165
+** macro to compute a hash on the function name.
1604216166
*/
1604316167
#define SQLITE_FUNC_HASH_SZ 23
1604416168
struct FuncDefHash {
1604516169
FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
1604616170
};
16171
+#define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)
1604716172
1604816173
#ifdef SQLITE_USER_AUTHENTICATION
1604916174
/*
1605016175
** Information held in the "sqlite3" database connection object and used
1605116176
** to manage user authentication.
@@ -16102,11 +16227,11 @@
1610216227
CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
1610316228
sqlite3_mutex *mutex; /* Connection mutex */
1610416229
Db *aDb; /* All backends */
1610516230
int nDb; /* Number of backends currently in use */
1610616231
u32 mDbFlags; /* flags recording internal state */
16107
- u32 flags; /* flags settable by pragmas. See below */
16232
+ u64 flags; /* flags settable by pragmas. See below */
1610816233
i64 lastRowid; /* ROWID of most recent insert (see above) */
1610916234
i64 szMmap; /* Default mmap_size setting */
1611016235
u32 nSchemaLock; /* Do not reset the schema when non-zero */
1611116236
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
1611216237
int errCode; /* Most recent error code (SQLITE_*) */
@@ -16268,18 +16393,21 @@
1626816393
#define SQLITE_Fts3Tokenizer 0x00400000 /* Enable fts3_tokenizer(2) */
1626916394
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
1627016395
#define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
1627116396
#define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
1627216397
#define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
16398
+#define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/
16399
+#define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */
1627316400
1627416401
/* Flags used only if debugging */
16402
+#define HI(X) ((u64)(X)<<32)
1627516403
#ifdef SQLITE_DEBUG
16276
-#define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
16277
-#define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
16278
-#define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
16279
-#define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
16280
-#define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
16404
+#define SQLITE_SqlTrace HI(0x0001) /* Debug print SQL as it executes */
16405
+#define SQLITE_VdbeListing HI(0x0002) /* Debug listings of VDBE progs */
16406
+#define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
16407
+#define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
16408
+#define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
1628116409
#endif
1628216410
1628316411
/*
1628416412
** Allowed values for sqlite3.mDbFlags
1628516413
*/
@@ -16674,10 +16802,13 @@
1667416802
** by an instance of the following structure.
1667516803
*/
1667616804
struct Table {
1667716805
char *zName; /* Name of the table or view */
1667816806
Column *aCol; /* Information about each column */
16807
+#ifdef SQLITE_ENABLE_NORMALIZE
16808
+ Hash *pColHash; /* All columns indexed by name */
16809
+#endif
1667916810
Index *pIndex; /* List of SQL indexes on this table. */
1668016811
Select *pSelect; /* NULL for tables. Points to definition if a view. */
1668116812
FKey *pFKey; /* Linked list of all foreign keys in this table */
1668216813
char *zColAff; /* String defining the affinity of each column */
1668316814
ExprList *pCheck; /* All CHECK constraints */
@@ -16724,10 +16855,11 @@
1672416855
#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
1672516856
#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
1672616857
#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
1672716858
** Index.aiRowLogEst[] values */
1672816859
#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
16860
+#define TF_Shadow 0x0400 /* True for a shadow table */
1672916861
1673016862
/*
1673116863
** Test to see whether or not a table is a virtual table. This is
1673216864
** done as a macro so that it will be optimized out when virtual
1673316865
** table support is omitted from the build.
@@ -17010,10 +17142,16 @@
1701017142
tRowcnt *anEq; /* Est. number of rows where the key equals this sample */
1701117143
tRowcnt *anLt; /* Est. number of rows where key is less than this sample */
1701217144
tRowcnt *anDLt; /* Est. number of distinct keys less than this sample */
1701317145
};
1701417146
17147
+/*
17148
+** Possible values to use within the flags argument to sqlite3GetToken().
17149
+*/
17150
+#define SQLITE_TOKEN_QUOTED 0x1 /* Token is a quoted identifier. */
17151
+#define SQLITE_TOKEN_KEYWORD 0x2 /* Token is a keyword. */
17152
+
1701517153
/*
1701617154
** Each token coming out of the lexer is an instance of
1701717155
** this structure. Tokens are also used as part of an expression.
1701817156
**
1701917157
** The memory that "z" points to is owned by other objects. Take care
@@ -17191,15 +17329,15 @@
1719117329
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
1719217330
u8 op2; /* TK_REGISTER: original value of Expr.op
1719317331
** TK_COLUMN: the value of p5 for OP_Column
1719417332
** TK_AGG_FUNCTION: nesting depth */
1719517333
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17196
- Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
17197
- ** for a column of an index on an expression */
17198
-#ifndef SQLITE_OMIT_WINDOWFUNC
17199
- Window *pWin; /* Window definition for window functions */
17200
-#endif
17334
+ union {
17335
+ Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17336
+ ** for a column of an index on an expression */
17337
+ Window *pWin; /* TK_FUNCTION: Window definition for the func */
17338
+ } y;
1720117339
};
1720217340
1720317341
/*
1720417342
** The following are the meanings of bits in the Expr.flags field.
1720517343
*/
@@ -17225,10 +17363,11 @@
1722517363
#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
1722617364
#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
1722717365
#define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
1722817366
#define EP_Alias 0x400000 /* Is an alias for a result set column */
1722917367
#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17368
+#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
1723017369
1723117370
/*
1723217371
** The EP_Propagate mask is a set of properties that automatically propagate
1723317372
** upwards into parent nodes.
1723417373
*/
@@ -17910,10 +18049,11 @@
1791018049
** OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
1791118050
** OPFLAG_AUXDELETE == BTREE_AUXDELETE
1791218051
*/
1791318052
#define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
1791418053
/* Also used in P2 (not P5) of OP_Delete */
18054
+#define OPFLAG_NOCHNG 0x01 /* OP_VColumn nochange for UPDATE */
1791518055
#define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */
1791618056
#define OPFLAG_LASTROWID 0x20 /* Set to update db->lastRowid */
1791718057
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
1791818058
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
1791918059
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
@@ -18381,10 +18521,11 @@
1838118521
/*
1838218522
** Internal function prototypes
1838318523
*/
1838418524
SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
1838518525
SQLITE_PRIVATE int sqlite3Strlen30(const char*);
18526
+#define sqlite3Strlen30NN(C) (strlen(C)&0x3fffffff)
1838618527
SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*);
1838718528
#define sqlite3StrNICmp sqlite3_strnicmp
1838818529
1838918530
SQLITE_PRIVATE int sqlite3MallocInit(void);
1839018531
SQLITE_PRIVATE void sqlite3MallocEnd(void);
@@ -18497,10 +18638,11 @@
1849718638
1849818639
#if defined(SQLITE_DEBUG)
1849918640
SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
1850018641
SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
1850118642
SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
18643
+SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView*, const SrcList*);
1850218644
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
1850318645
SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
1850418646
#ifndef SQLITE_OMIT_WINDOWFUNC
1850518647
SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
1850618648
SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
@@ -18729,15 +18871,19 @@
1872918871
#endif
1873018872
SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
1873118873
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
1873218874
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
1873318875
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
18876
+#ifdef SQLITE_ENABLE_NORMALIZE
18877
+SQLITE_PRIVATE int sqlite3IsRowidN(const char*, int);
18878
+#endif
1873418879
SQLITE_PRIVATE void sqlite3GenerateRowDelete(
1873518880
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
1873618881
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
1873718882
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
1873818883
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
18884
+SQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(Expr*,int*,int);
1873918885
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
1874018886
u8,u8,int,int*,int*,Upsert*);
1874118887
#ifdef SQLITE_ENABLE_NULL_TRIM
1874218888
SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
1874318889
#else
@@ -18754,10 +18900,13 @@
1875418900
SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
1875518901
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
1875618902
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
1875718903
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
1875818904
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
18905
+#ifdef SQLITE_ENABLE_NORMALIZE
18906
+SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(int,const char*,int);
18907
+#endif
1875918908
SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
1876018909
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
1876118910
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
1876218911
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
1876318912
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18911,10 +19060,11 @@
1891119060
SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
1891219061
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
1891319062
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
1891419063
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
1891519064
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
19065
+SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
1891619066
SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
1891719067
SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
1891819068
SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
1891919069
SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
1892019070
SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
@@ -18957,10 +19107,13 @@
1895719107
SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
1895819108
SQLITE_PRIVATE void sqlite3AlterFunctions(void);
1895919109
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
1896019110
SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
1896119111
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
19112
+#ifdef SQLITE_ENABLE_NORMALIZE
19113
+SQLITE_PRIVATE int sqlite3GetTokenNormalized(const unsigned char *, int *, int *);
19114
+#endif
1896219115
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
1896319116
SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
1896419117
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
1896519118
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1896619119
SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
@@ -19114,10 +19267,13 @@
1911419267
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
1911519268
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
1911619269
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
1911719270
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
1911819271
SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
19272
+#ifdef SQLITE_ENABLE_NORMALIZE
19273
+SQLITE_PRIVATE void sqlite3Normalize(Vdbe*, const char*, int, u8);
19274
+#endif
1911919275
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
1912019276
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
1912119277
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
1912219278
SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
1912319279
SQLITE_PRIVATE const char *sqlite3JournalModename(int);
@@ -20066,10 +20222,13 @@
2006620222
bft bIsReader:1; /* True for statements that read */
2006720223
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
2006820224
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
2006920225
u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
2007020226
char *zSql; /* Text of the SQL statement that generated this */
20227
+#ifdef SQLITE_ENABLE_NORMALIZE
20228
+ char *zNormSql; /* Normalization of the associated SQL statement */
20229
+#endif
2007120230
void *pFree; /* Free this when deleting the vdbe */
2007220231
VdbeFrame *pFrame; /* Parent frame */
2007320232
VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
2007420233
int nFrame; /* Number of frames in pFrame list */
2007520234
u32 expmask; /* Binding to these vars invalidates VM */
@@ -28294,10 +28453,46 @@
2829428453
}
2829528454
sqlite3TreeViewPop(pView);
2829628455
}
2829728456
}
2829828457
28458
+/*
28459
+** Generate a human-readable description of a SrcList object.
28460
+*/
28461
+SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){
28462
+ int i;
28463
+ for(i=0; i<pSrc->nSrc; i++){
28464
+ const struct SrcList_item *pItem = &pSrc->a[i];
28465
+ StrAccum x;
28466
+ char zLine[100];
28467
+ sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28468
+ sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28469
+ if( pItem->zDatabase ){
28470
+ sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28471
+ }else if( pItem->zName ){
28472
+ sqlite3_str_appendf(&x, " %s", pItem->zName);
28473
+ }
28474
+ if( pItem->pTab ){
28475
+ sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
28476
+ }
28477
+ if( pItem->zAlias ){
28478
+ sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
28479
+ }
28480
+ if( pItem->fg.jointype & JT_LEFT ){
28481
+ sqlite3_str_appendf(&x, " LEFT-JOIN");
28482
+ }
28483
+ sqlite3StrAccumFinish(&x);
28484
+ sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1);
28485
+ if( pItem->pSelect ){
28486
+ sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
28487
+ }
28488
+ if( pItem->fg.isTabFunc ){
28489
+ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
28490
+ }
28491
+ sqlite3TreeViewPop(pView);
28492
+ }
28493
+}
2829928494
2830028495
/*
2830128496
** Generate a human-readable description of a Select object.
2830228497
*/
2830328498
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
@@ -28348,43 +28543,13 @@
2834828543
}
2834928544
sqlite3TreeViewPop(pView);
2835028545
}
2835128546
#endif
2835228547
if( p->pSrc && p->pSrc->nSrc ){
28353
- int i;
2835428548
pView = sqlite3TreeViewPush(pView, (n--)>0);
2835528549
sqlite3TreeViewLine(pView, "FROM");
28356
- for(i=0; i<p->pSrc->nSrc; i++){
28357
- struct SrcList_item *pItem = &p->pSrc->a[i];
28358
- StrAccum x;
28359
- char zLine[100];
28360
- sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28361
- sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28362
- if( pItem->zDatabase ){
28363
- sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28364
- }else if( pItem->zName ){
28365
- sqlite3_str_appendf(&x, " %s", pItem->zName);
28366
- }
28367
- if( pItem->pTab ){
28368
- sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
28369
- }
28370
- if( pItem->zAlias ){
28371
- sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
28372
- }
28373
- if( pItem->fg.jointype & JT_LEFT ){
28374
- sqlite3_str_appendf(&x, " LEFT-JOIN");
28375
- }
28376
- sqlite3StrAccumFinish(&x);
28377
- sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1);
28378
- if( pItem->pSelect ){
28379
- sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
28380
- }
28381
- if( pItem->fg.isTabFunc ){
28382
- sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
28383
- }
28384
- sqlite3TreeViewPop(pView);
28385
- }
28550
+ sqlite3TreeViewSrcList(pView, p->pSrc);
2838628551
sqlite3TreeViewPop(pView);
2838728552
}
2838828553
if( p->pWhere ){
2838928554
sqlite3TreeViewItem(pView, "WHERE", (n--)>0);
2839028555
sqlite3TreeViewExpr(pView, p->pWhere, 0);
@@ -28670,11 +28835,11 @@
2867028835
pFarg = 0;
2867128836
pWin = 0;
2867228837
}else{
2867328838
pFarg = pExpr->x.pList;
2867428839
#ifndef SQLITE_OMIT_WINDOWFUNC
28675
- pWin = pExpr->pWin;
28840
+ pWin = pExpr->y.pWin;
2867628841
#else
2867728842
pWin = 0;
2867828843
#endif
2867928844
}
2868028845
if( pExpr->op==TK_AGG_FUNCTION ){
@@ -31498,10 +31663,24 @@
3149831663
h += sqlite3UpperToLower[c];
3149931664
h *= 0x9e3779b1;
3150031665
}
3150131666
return h;
3150231667
}
31668
+#ifdef SQLITE_ENABLE_NORMALIZE
31669
+static unsigned int strHashN(const char *z, int n){
31670
+ unsigned int h = 0;
31671
+ int i;
31672
+ for(i=0; i<n; i++){
31673
+ /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
31674
+ ** 0x9e3779b1 is 2654435761 which is the closest prime number to
31675
+ ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
31676
+ h += sqlite3UpperToLower[z[i]];
31677
+ h *= 0x9e3779b1;
31678
+ }
31679
+ return h;
31680
+}
31681
+#endif /* SQLITE_ENABLE_NORMALIZE */
3150331682
3150431683
3150531684
/* Link pNew element into the hash table pH. If pEntry!=0 then also
3150631685
** insert pNew into the pEntry hash bucket.
3150731686
*/
@@ -31609,10 +31788,44 @@
3160931788
}
3161031789
elem = elem->next;
3161131790
}
3161231791
return &nullElement;
3161331792
}
31793
+#ifdef SQLITE_ENABLE_NORMALIZE
31794
+static HashElem *findElementWithHashN(
31795
+ const Hash *pH, /* The pH to be searched */
31796
+ const char *pKey, /* The key we are searching for */
31797
+ int nKey, /* Number of key bytes to use */
31798
+ unsigned int *pHash /* Write the hash value here */
31799
+){
31800
+ HashElem *elem; /* Used to loop thru the element list */
31801
+ int count; /* Number of elements left to test */
31802
+ unsigned int h; /* The computed hash */
31803
+ static HashElem nullElement = { 0, 0, 0, 0 };
31804
+
31805
+ if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
31806
+ struct _ht *pEntry;
31807
+ h = strHashN(pKey, nKey) % pH->htsize;
31808
+ pEntry = &pH->ht[h];
31809
+ elem = pEntry->chain;
31810
+ count = pEntry->count;
31811
+ }else{
31812
+ h = 0;
31813
+ elem = pH->first;
31814
+ count = pH->count;
31815
+ }
31816
+ if( pHash ) *pHash = h;
31817
+ while( count-- ){
31818
+ assert( elem!=0 );
31819
+ if( sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){
31820
+ return elem;
31821
+ }
31822
+ elem = elem->next;
31823
+ }
31824
+ return &nullElement;
31825
+}
31826
+#endif /* SQLITE_ENABLE_NORMALIZE */
3161431827
3161531828
/* Remove a single entry from the hash table given a pointer to that
3161631829
** element and a hash on the element's key.
3161731830
*/
3161831831
static void removeElementGivenHash(
@@ -31653,10 +31866,18 @@
3165331866
SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
3165431867
assert( pH!=0 );
3165531868
assert( pKey!=0 );
3165631869
return findElementWithHash(pH, pKey, 0)->data;
3165731870
}
31871
+#ifdef SQLITE_ENABLE_NORMALIZE
31872
+SQLITE_PRIVATE void *sqlite3HashFindN(const Hash *pH, const char *pKey, int nKey){
31873
+ assert( pH!=0 );
31874
+ assert( pKey!=0 );
31875
+ assert( nKey>=0 );
31876
+ return findElementWithHashN(pH, pKey, nKey, 0)->data;
31877
+}
31878
+#endif /* SQLITE_ENABLE_NORMALIZE */
3165831879
3165931880
/* Insert an element into the hash table pH. The key is pKey
3166031881
** and the data is "data".
3166131882
**
3166231883
** If no element exists with a matching key, then a new
@@ -32035,16 +32256,14 @@
3203532256
** Allowed values of unixFile.fsFlags
3203632257
*/
3203732258
#define SQLITE_FSFLAGS_IS_MSDOS 0x1
3203832259
3203932260
/*
32040
-** If we are to be thread-safe, include the pthreads header and define
32041
-** the SQLITE_UNIX_THREADS macro.
32261
+** If we are to be thread-safe, include the pthreads header.
3204232262
*/
3204332263
#if SQLITE_THREADSAFE
3204432264
/* # include <pthread.h> */
32045
-# define SQLITE_UNIX_THREADS 1
3204632265
#endif
3204732266
3204832267
/*
3204932268
** Default permissions when creating a new file
3205032269
*/
@@ -33216,12 +33435,11 @@
3321633435
#endif
3321733436
};
3321833437
3321933438
/*
3322033439
** An instance of the following structure is allocated for each open
33221
-** inode. Or, on LinuxThreads, there is one of these structures for
33222
-** each inode opened by each thread.
33440
+** inode.
3322333441
**
3322433442
** A single inode can have multiple file descriptors, so each unixFile
3322533443
** structure contains a pointer to an instance of this object and this
3322633444
** object keeps a count of the number of unixFile pointing to it.
3322733445
**
@@ -33263,17 +33481,20 @@
3326333481
#endif
3326433482
};
3326533483
3326633484
/*
3326733485
** A lists of all unixInodeInfo objects.
33486
+**
33487
+** Must hold unixBigLock in order to read or write this variable.
3326833488
*/
3326933489
static unixInodeInfo *inodeList = 0; /* All unixInodeInfo objects */
3327033490
3327133491
#ifdef SQLITE_DEBUG
3327233492
/*
33273
-** True if the inode mutex is held, or not. Used only within assert()
33274
-** to help verify correct mutex usage.
33493
+** True if the inode mutex (on the unixFile.pFileMutex field) is held, or not.
33494
+** This routine is used only within assert() to help verify correct mutex
33495
+** usage.
3327533496
*/
3327633497
int unixFileMutexHeld(unixFile *pFile){
3327733498
assert( pFile->pInode );
3327833499
return sqlite3_mutex_held(pFile->pInode->pLockMutex);
3327933500
}
@@ -33397,12 +33618,12 @@
3339733618
}
3339833619
3339933620
/*
3340033621
** Release a unixInodeInfo structure previously allocated by findInodeInfo().
3340133622
**
33402
-** The mutex entered using the unixEnterMutex() function must be held
33403
-** when this function is called.
33623
+** The global mutex must be held when this routine is called, but the mutex
33624
+** on the inode being deleted must NOT be held.
3340433625
*/
3340533626
static void releaseInodeInfo(unixFile *pFile){
3340633627
unixInodeInfo *pInode = pFile->pInode;
3340733628
assert( unixMutexHeld() );
3340833629
assert( unixFileMutexNotheld(pFile) );
@@ -33433,12 +33654,11 @@
3343333654
/*
3343433655
** Given a file descriptor, locate the unixInodeInfo object that
3343533656
** describes that file descriptor. Create a new one if necessary. The
3343633657
** return value might be uninitialized if an error occurs.
3343733658
**
33438
-** The mutex entered using the unixEnterMutex() function must be held
33439
-** when this function is called.
33659
+** The global mutex must held when calling this routine.
3344033660
**
3344133661
** Return an appropriate error code.
3344233662
*/
3344333663
static int findInodeInfo(
3344433664
unixFile *pFile, /* Unix file with file desc used in the key */
@@ -33495,10 +33715,11 @@
3349533715
#if OS_VXWORKS
3349633716
fileId.pId = pFile->pId;
3349733717
#else
3349833718
fileId.ino = (u64)statbuf.st_ino;
3349933719
#endif
33720
+ assert( unixMutexHeld() );
3350033721
pInode = inodeList;
3350133722
while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
3350233723
pInode = pInode->pNext;
3350333724
}
3350433725
if( pInode==0 ){
@@ -33514,10 +33735,11 @@
3351433735
sqlite3_free(pInode);
3351533736
return SQLITE_NOMEM_BKPT;
3351633737
}
3351733738
}
3351833739
pInode->nRef = 1;
33740
+ assert( unixMutexHeld() );
3351933741
pInode->pNext = inodeList;
3352033742
pInode->pPrev = 0;
3352133743
if( inodeList ) inodeList->pPrev = pInode;
3352233744
inodeList = pInode;
3352333745
}else{
@@ -36311,22 +36533,22 @@
3631136533
**
3631236534
** nRef
3631336535
**
3631436536
** The following fields are read-only after the object is created:
3631536537
**
36316
-** fid
36538
+** hShm
3631736539
** zFilename
3631836540
**
36319
-** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and
36541
+** Either unixShmNode.pShmMutex must be held or unixShmNode.nRef==0 and
3632036542
** unixMutexHeld() is true when reading or writing any other field
3632136543
** in this structure.
3632236544
*/
3632336545
struct unixShmNode {
3632436546
unixInodeInfo *pInode; /* unixInodeInfo that owns this SHM node */
36325
- sqlite3_mutex *mutex; /* Mutex to access this object */
36547
+ sqlite3_mutex *pShmMutex; /* Mutex to access this object */
3632636548
char *zFilename; /* Name of the mmapped file */
36327
- int h; /* Open file descriptor */
36549
+ int hShm; /* Open file descriptor */
3632836550
int szRegion; /* Size of shared-memory regions */
3632936551
u16 nRegion; /* Size of array apRegion */
3633036552
u8 isReadonly; /* True if read-only */
3633136553
u8 isUnlocked; /* True if no DMS lock held */
3633236554
char **apRegion; /* Array of mapped shared-memory regions */
@@ -36344,20 +36566,20 @@
3634436566
** open shared memory connection.
3634536567
**
3634636568
** The following fields are initialized when this object is created and
3634736569
** are read-only thereafter:
3634836570
**
36349
-** unixShm.pFile
36571
+** unixShm.pShmNode
3635036572
** unixShm.id
3635136573
**
36352
-** All other fields are read/write. The unixShm.pFile->mutex must be held
36353
-** while accessing any read/write fields.
36574
+** All other fields are read/write. The unixShm.pShmNode->pShmMutex must
36575
+** be held while accessing any read/write fields.
3635436576
*/
3635536577
struct unixShm {
3635636578
unixShmNode *pShmNode; /* The underlying unixShmNode object */
3635736579
unixShm *pNext; /* Next unixShm with the same unixShmNode */
36358
- u8 hasMutex; /* True if holding the unixShmNode mutex */
36580
+ u8 hasMutex; /* True if holding the unixShmNode->pShmMutex */
3635936581
u8 id; /* Id of this connection within its unixShmNode */
3636036582
u16 sharedMask; /* Mask of shared locks held */
3636136583
u16 exclMask; /* Mask of exclusive locks held */
3636236584
};
3636336585
@@ -36383,25 +36605,26 @@
3638336605
struct flock f; /* The posix advisory locking structure */
3638436606
int rc = SQLITE_OK; /* Result code form fcntl() */
3638536607
3638636608
/* Access to the unixShmNode object is serialized by the caller */
3638736609
pShmNode = pFile->pInode->pShmNode;
36388
- assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->mutex) );
36610
+ assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) );
36611
+ assert( pShmNode->nRef>0 || unixMutexHeld() );
3638936612
3639036613
/* Shared locks never span more than one byte */
3639136614
assert( n==1 || lockType!=F_RDLCK );
3639236615
3639336616
/* Locks are within range */
3639436617
assert( n>=1 && n<=SQLITE_SHM_NLOCK );
3639536618
36396
- if( pShmNode->h>=0 ){
36619
+ if( pShmNode->hShm>=0 ){
3639736620
/* Initialize the locking parameters */
3639836621
f.l_type = lockType;
3639936622
f.l_whence = SEEK_SET;
3640036623
f.l_start = ofst;
3640136624
f.l_len = n;
36402
- rc = osSetPosixAdvisoryLock(pShmNode->h, &f, pFile);
36625
+ rc = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile);
3640336626
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
3640436627
}
3640536628
3640636629
/* Update the global lock state and do debug tracing */
3640736630
#ifdef SQLITE_DEBUG
@@ -36469,22 +36692,22 @@
3646936692
assert( unixMutexHeld() );
3647036693
if( p && ALWAYS(p->nRef==0) ){
3647136694
int nShmPerMap = unixShmRegionPerMap();
3647236695
int i;
3647336696
assert( p->pInode==pFd->pInode );
36474
- sqlite3_mutex_free(p->mutex);
36697
+ sqlite3_mutex_free(p->pShmMutex);
3647536698
for(i=0; i<p->nRegion; i+=nShmPerMap){
36476
- if( p->h>=0 ){
36699
+ if( p->hShm>=0 ){
3647736700
osMunmap(p->apRegion[i], p->szRegion);
3647836701
}else{
3647936702
sqlite3_free(p->apRegion[i]);
3648036703
}
3648136704
}
3648236705
sqlite3_free(p->apRegion);
36483
- if( p->h>=0 ){
36484
- robust_close(pFd, p->h, __LINE__);
36485
- p->h = -1;
36706
+ if( p->hShm>=0 ){
36707
+ robust_close(pFd, p->hShm, __LINE__);
36708
+ p->hShm = -1;
3648636709
}
3648736710
p->pInode->pShmNode = 0;
3648836711
sqlite3_free(p);
3648936712
}
3649036713
}
@@ -36522,19 +36745,24 @@
3652236745
** system crash, the database itself may also become corrupt. */
3652336746
lock.l_whence = SEEK_SET;
3652436747
lock.l_start = UNIX_SHM_DMS;
3652536748
lock.l_len = 1;
3652636749
lock.l_type = F_WRLCK;
36527
- if( osFcntl(pShmNode->h, F_GETLK, &lock)!=0 ) {
36750
+ if( osFcntl(pShmNode->hShm, F_GETLK, &lock)!=0 ) {
3652836751
rc = SQLITE_IOERR_LOCK;
3652936752
}else if( lock.l_type==F_UNLCK ){
3653036753
if( pShmNode->isReadonly ){
3653136754
pShmNode->isUnlocked = 1;
3653236755
rc = SQLITE_READONLY_CANTINIT;
3653336756
}else{
3653436757
rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);
36535
- if( rc==SQLITE_OK && robust_ftruncate(pShmNode->h, 0) ){
36758
+ /* The first connection to attach must truncate the -shm file. We
36759
+ ** truncate to 3 bytes (an arbitrary small number, less than the
36760
+ ** -shm header size) rather than 0 as a system debugging aid, to
36761
+ ** help detect if a -shm file truncation is legitimate or is the work
36762
+ ** or a rogue process. */
36763
+ if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 3) ){
3653636764
rc = unixLogError(SQLITE_IOERR_SHMOPEN,"ftruncate",pShmNode->zFilename);
3653736765
}
3653836766
}
3653936767
}else if( lock.l_type==F_WRLCK ){
3654036768
rc = SQLITE_BUSY;
@@ -36636,28 +36864,28 @@
3663636864
(u32)sStat.st_ino, (u32)sStat.st_dev);
3663736865
#else
3663836866
sqlite3_snprintf(nShmFilename, zShm, "%s-shm", zBasePath);
3663936867
sqlite3FileSuffix3(pDbFd->zPath, zShm);
3664036868
#endif
36641
- pShmNode->h = -1;
36869
+ pShmNode->hShm = -1;
3664236870
pDbFd->pInode->pShmNode = pShmNode;
3664336871
pShmNode->pInode = pDbFd->pInode;
3664436872
if( sqlite3GlobalConfig.bCoreMutex ){
36645
- pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
36646
- if( pShmNode->mutex==0 ){
36873
+ pShmNode->pShmMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
36874
+ if( pShmNode->pShmMutex==0 ){
3664736875
rc = SQLITE_NOMEM_BKPT;
3664836876
goto shm_open_err;
3664936877
}
3665036878
}
3665136879
3665236880
if( pInode->bProcessLock==0 ){
3665336881
if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
36654
- pShmNode->h = robust_open(zShm, O_RDWR|O_CREAT, (sStat.st_mode&0777));
36882
+ pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777));
3665536883
}
36656
- if( pShmNode->h<0 ){
36657
- pShmNode->h = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
36658
- if( pShmNode->h<0 ){
36884
+ if( pShmNode->hShm<0 ){
36885
+ pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
36886
+ if( pShmNode->hShm<0 ){
3665936887
rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
3666036888
goto shm_open_err;
3666136889
}
3666236890
pShmNode->isReadonly = 1;
3666336891
}
@@ -36664,11 +36892,11 @@
3666436892
3666536893
/* If this process is running as root, make sure that the SHM file
3666636894
** is owned by the same user that owns the original database. Otherwise,
3666736895
** the original owner will not be able to connect.
3666836896
*/
36669
- robustFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);
36897
+ robustFchown(pShmNode->hShm, sStat.st_uid, sStat.st_gid);
3667036898
3667136899
rc = unixLockSharedMemory(pDbFd, pShmNode);
3667236900
if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
3667336901
}
3667436902
}
@@ -36684,17 +36912,17 @@
3668436912
3668536913
/* The reference count on pShmNode has already been incremented under
3668636914
** the cover of the unixEnterMutex() mutex and the pointer from the
3668736915
** new (struct unixShm) object to the pShmNode has been set. All that is
3668836916
** left to do is to link the new object into the linked list starting
36689
- ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex
36690
- ** mutex.
36917
+ ** at pShmNode->pFirst. This must be done while holding the
36918
+ ** pShmNode->pShmMutex.
3669136919
*/
36692
- sqlite3_mutex_enter(pShmNode->mutex);
36920
+ sqlite3_mutex_enter(pShmNode->pShmMutex);
3669336921
p->pNext = pShmNode->pFirst;
3669436922
pShmNode->pFirst = p;
36695
- sqlite3_mutex_leave(pShmNode->mutex);
36923
+ sqlite3_mutex_leave(pShmNode->pShmMutex);
3669636924
return rc;
3669736925
3669836926
/* Jump here on any error */
3669936927
shm_open_err:
3670036928
unixShmPurge(pDbFd); /* This call frees pShmNode if required */
@@ -36742,20 +36970,20 @@
3674236970
if( rc!=SQLITE_OK ) return rc;
3674336971
}
3674436972
3674536973
p = pDbFd->pShm;
3674636974
pShmNode = p->pShmNode;
36747
- sqlite3_mutex_enter(pShmNode->mutex);
36975
+ sqlite3_mutex_enter(pShmNode->pShmMutex);
3674836976
if( pShmNode->isUnlocked ){
3674936977
rc = unixLockSharedMemory(pDbFd, pShmNode);
3675036978
if( rc!=SQLITE_OK ) goto shmpage_out;
3675136979
pShmNode->isUnlocked = 0;
3675236980
}
3675336981
assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
3675436982
assert( pShmNode->pInode==pDbFd->pInode );
36755
- assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
36756
- assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
36983
+ assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );
36984
+ assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );
3675736985
3675836986
/* Minimum number of regions required to be mapped. */
3675936987
nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;
3676036988
3676136989
if( pShmNode->nRegion<nReqRegion ){
@@ -36763,16 +36991,16 @@
3676336991
int nByte = nReqRegion*szRegion; /* Minimum required file size */
3676436992
struct stat sStat; /* Used by fstat() */
3676536993
3676636994
pShmNode->szRegion = szRegion;
3676736995
36768
- if( pShmNode->h>=0 ){
36996
+ if( pShmNode->hShm>=0 ){
3676936997
/* The requested region is not mapped into this processes address space.
3677036998
** Check to see if it has been allocated (i.e. if the wal-index file is
3677136999
** large enough to contain the requested region).
3677237000
*/
36773
- if( osFstat(pShmNode->h, &sStat) ){
37001
+ if( osFstat(pShmNode->hShm, &sStat) ){
3677437002
rc = SQLITE_IOERR_SHMSIZE;
3677537003
goto shmpage_out;
3677637004
}
3677737005
3677837006
if( sStat.st_size<nByte ){
@@ -36796,11 +37024,11 @@
3679637024
3679737025
/* Write to the last byte of each newly allocated or extended page */
3679837026
assert( (nByte % pgsz)==0 );
3679937027
for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){
3680037028
int x = 0;
36801
- if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, "", 1, &x)!=1 ){
37029
+ if( seekAndWriteFd(pShmNode->hShm, iPg*pgsz + pgsz-1,"",1,&x)!=1 ){
3680237030
const char *zFile = pShmNode->zFilename;
3680337031
rc = unixLogError(SQLITE_IOERR_SHMSIZE, "write", zFile);
3680437032
goto shmpage_out;
3680537033
}
3680637034
}
@@ -36819,26 +37047,26 @@
3681937047
pShmNode->apRegion = apNew;
3682037048
while( pShmNode->nRegion<nReqRegion ){
3682137049
int nMap = szRegion*nShmPerMap;
3682237050
int i;
3682337051
void *pMem;
36824
- if( pShmNode->h>=0 ){
37052
+ if( pShmNode->hShm>=0 ){
3682537053
pMem = osMmap(0, nMap,
3682637054
pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
36827
- MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion
37055
+ MAP_SHARED, pShmNode->hShm, szRegion*(i64)pShmNode->nRegion
3682837056
);
3682937057
if( pMem==MAP_FAILED ){
3683037058
rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
3683137059
goto shmpage_out;
3683237060
}
3683337061
}else{
36834
- pMem = sqlite3_malloc64(szRegion);
37062
+ pMem = sqlite3_malloc64(nMap);
3683537063
if( pMem==0 ){
3683637064
rc = SQLITE_NOMEM_BKPT;
3683737065
goto shmpage_out;
3683837066
}
36839
- memset(pMem, 0, szRegion);
37067
+ memset(pMem, 0, nMap);
3684037068
}
3684137069
3684237070
for(i=0; i<nShmPerMap; i++){
3684337071
pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
3684437072
}
@@ -36851,11 +37079,11 @@
3685137079
*pp = pShmNode->apRegion[iRegion];
3685237080
}else{
3685337081
*pp = 0;
3685437082
}
3685537083
if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;
36856
- sqlite3_mutex_leave(pShmNode->mutex);
37084
+ sqlite3_mutex_leave(pShmNode->pShmMutex);
3685737085
return rc;
3685837086
}
3685937087
3686037088
/*
3686137089
** Change the lock state for a shared-memory segment.
@@ -36885,16 +37113,16 @@
3688537113
assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
3688637114
|| flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
3688737115
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
3688837116
|| flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
3688937117
assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
36890
- assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
36891
- assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
37118
+ assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );
37119
+ assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );
3689237120
3689337121
mask = (1<<(ofst+n)) - (1<<ofst);
3689437122
assert( n>1 || mask==(1<<ofst) );
36895
- sqlite3_mutex_enter(pShmNode->mutex);
37123
+ sqlite3_mutex_enter(pShmNode->pShmMutex);
3689637124
if( flags & SQLITE_SHM_UNLOCK ){
3689737125
u16 allMask = 0; /* Mask of locks held by siblings */
3689837126
3689937127
/* See if any siblings hold this same lock */
3690037128
for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
@@ -36963,11 +37191,11 @@
3696337191
assert( (p->sharedMask & mask)==0 );
3696437192
p->exclMask |= mask;
3696537193
}
3696637194
}
3696737195
}
36968
- sqlite3_mutex_leave(pShmNode->mutex);
37196
+ sqlite3_mutex_leave(pShmNode->pShmMutex);
3696937197
OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
3697037198
p->id, osGetpid(0), p->sharedMask, p->exclMask));
3697137199
return rc;
3697237200
}
3697337201
@@ -37013,27 +37241,27 @@
3701337241
assert( pShmNode==pDbFd->pInode->pShmNode );
3701437242
assert( pShmNode->pInode==pDbFd->pInode );
3701537243
3701637244
/* Remove connection p from the set of connections associated
3701737245
** with pShmNode */
37018
- sqlite3_mutex_enter(pShmNode->mutex);
37246
+ sqlite3_mutex_enter(pShmNode->pShmMutex);
3701937247
for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
3702037248
*pp = p->pNext;
3702137249
3702237250
/* Free the connection p */
3702337251
sqlite3_free(p);
3702437252
pDbFd->pShm = 0;
37025
- sqlite3_mutex_leave(pShmNode->mutex);
37253
+ sqlite3_mutex_leave(pShmNode->pShmMutex);
3702637254
3702737255
/* If pShmNode->nRef has reached 0, then close the underlying
3702837256
** shared-memory file, too */
3702937257
assert( unixFileMutexNotheld(pDbFd) );
3703037258
unixEnterMutex();
3703137259
assert( pShmNode->nRef>0 );
3703237260
pShmNode->nRef--;
3703337261
if( pShmNode->nRef==0 ){
37034
- if( deleteFlag && pShmNode->h>=0 ){
37262
+ if( deleteFlag && pShmNode->hShm>=0 ){
3703537263
osUnlink(pShmNode->zFilename);
3703637264
}
3703737265
unixShmPurge(pDbFd);
3703837266
}
3703937267
unixLeaveMutex();
@@ -47321,11 +47549,11 @@
4732147549
** pDirtyTail to the last (oldest).
4732247550
**
4732347551
** The PCache.pSynced variable is used to optimize searching for a dirty
4732447552
** page to eject from the cache mid-transaction. It is better to eject
4732547553
** a page that does not require a journal sync than one that does.
47326
-** Therefore, pSynced is maintained to that it *almost* always points
47554
+** Therefore, pSynced is maintained so that it *almost* always points
4732747555
** to either the oldest page in the pDirty/pDirtyTail list that has a
4732847556
** clear PGHDR_NEED_SYNC flag or to a page that is older than this one
4732947557
** (so that the right page to eject can be found by following pDirtyPrev
4733047558
** pointers).
4733147559
*/
@@ -57104,10 +57332,11 @@
5710457332
void *(*xCodec)(void*,void*,Pgno,int),
5710557333
void (*xCodecSizeChng)(void*,int,int),
5710657334
void (*xCodecFree)(void*),
5710757335
void *pCodec
5710857336
){
57337
+ pager_reset(pPager);
5710957338
if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
5711057339
pPager->xCodec = pPager->memDb ? 0 : xCodec;
5711157340
pPager->xCodecSizeChng = xCodecSizeChng;
5711257341
pPager->xCodecFree = xCodecFree;
5711357342
pPager->pCodec = pCodec;
@@ -65764,11 +65993,11 @@
6576465993
freeTempSpace(pBt);
6576565994
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
6576665995
pageSize-usableSize);
6576765996
return rc;
6576865997
}
65769
- if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
65998
+ if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
6577065999
rc = SQLITE_CORRUPT_BKPT;
6577166000
goto page1_init_failed;
6577266001
}
6577366002
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
6577466003
** be less than 480. In other words, if the page size is 512, then the
@@ -66238,10 +66467,11 @@
6623866467
6623966468
assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 ||
6624066469
eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );
6624166470
assert( sqlite3_mutex_held(pBt->mutex) );
6624266471
assert( pDbPage->pBt==pBt );
66472
+ if( iDbPage<3 ) return SQLITE_CORRUPT_BKPT;
6624366473
6624466474
/* Move page iDbPage from its current location to page number iFreePage */
6624566475
TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
6624666476
iDbPage, iFreePage, iPtrPage, eType));
6624766477
rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
@@ -74033,11 +74263,12 @@
7403374263
sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
7403474264
}else{
7403574265
assert( fg & MEM_Real );
7403674266
sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
7403774267
}
74038
- pMem->n = sqlite3Strlen30(pMem->z);
74268
+ assert( pMem->z!=0 );
74269
+ pMem->n = sqlite3Strlen30NN(pMem->z);
7403974270
pMem->enc = SQLITE_UTF8;
7404074271
pMem->flags |= MEM_Str|MEM_Term;
7404174272
if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
7404274273
sqlite3VdbeChangeEncoding(pMem, enc);
7404374274
return SQLITE_OK;
@@ -75608,10 +75839,17 @@
7560875839
if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
7560975840
p->expmask = 0;
7561075841
}
7561175842
assert( p->zSql==0 );
7561275843
p->zSql = sqlite3DbStrNDup(p->db, z, n);
75844
+#ifdef SQLITE_ENABLE_NORMALIZE
75845
+ assert( p->zNormSql==0 );
75846
+ if( p->zSql && (prepFlags & SQLITE_PREPARE_NORMALIZE)!=0 ){
75847
+ sqlite3Normalize(p, p->zSql, n, prepFlags);
75848
+ assert( p->zNormSql!=0 || p->db->mallocFailed );
75849
+ }
75850
+#endif
7561375851
}
7561475852
7561575853
/*
7561675854
** Swap all content between two VDBE structures.
7561775855
*/
@@ -75629,10 +75867,15 @@
7562975867
pA->pPrev = pB->pPrev;
7563075868
pB->pPrev = pTmp;
7563175869
zTmp = pA->zSql;
7563275870
pA->zSql = pB->zSql;
7563375871
pB->zSql = zTmp;
75872
+#ifdef SQLITE_ENABLE_NORMALIZE
75873
+ zTmp = pA->zNormSql;
75874
+ pA->zNormSql = pB->zNormSql;
75875
+ pB->zNormSql = zTmp;
75876
+#endif
7563475877
pB->expmask = pA->expmask;
7563575878
pB->prepFlags = pA->prepFlags;
7563675879
memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
7563775880
pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
7563875881
}
@@ -78700,10 +78943,13 @@
7870078943
sqlite3DbFree(db, p->pFree);
7870178944
}
7870278945
vdbeFreeOpArray(db, p->aOp, p->nOp);
7870378946
sqlite3DbFree(db, p->aColName);
7870478947
sqlite3DbFree(db, p->zSql);
78948
+#ifdef SQLITE_ENABLE_NORMALIZE
78949
+ sqlite3DbFree(db, p->zNormSql);
78950
+#endif
7870578951
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
7870678952
{
7870778953
int i;
7870878954
for(i=0; i<p->nScan; i++){
7870978955
sqlite3DbFree(db, p->aScan[i].zName);
@@ -80101,11 +80347,13 @@
8010180347
8010280348
/* The index entry must begin with a header size */
8010380349
(void)getVarint32((u8*)m.z, szHdr);
8010480350
testcase( szHdr==3 );
8010580351
testcase( szHdr==m.n );
80106
- if( unlikely(szHdr<3 || (int)szHdr>m.n) ){
80352
+ testcase( szHdr>0x7fffffff );
80353
+ assert( m.n>=0 );
80354
+ if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
8010780355
goto idx_rowid_corruption;
8010880356
}
8010980357
8011080358
/* The last field of the index should be an integer - the ROWID.
8011180359
** Verify that the last entry really is an integer. */
@@ -82112,10 +82360,20 @@
8211282360
}
8211382361
return z;
8211482362
#endif
8211582363
}
8211682364
82365
+#ifdef SQLITE_ENABLE_NORMALIZE
82366
+/*
82367
+** Return the normalized SQL associated with a prepared statement.
82368
+*/
82369
+SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){
82370
+ Vdbe *p = (Vdbe *)pStmt;
82371
+ return p ? p->zNormSql : 0;
82372
+}
82373
+#endif /* SQLITE_ENABLE_NORMALIZE */
82374
+
8211782375
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
8211882376
/*
8211982377
** Allocate and populate an UnpackedRecord structure based on the serialized
8212082378
** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
8212182379
** if successful, or a NULL pointer if an OOM error is encountered.
@@ -85551,21 +85809,29 @@
8555185809
nVarint = sqlite3VarintLen(nHdr);
8555285810
nHdr += nVarint;
8555385811
if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
8555485812
}
8555585813
nByte = nHdr+nData;
85556
- if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
85557
- goto too_big;
85558
- }
8555985814
8556085815
/* Make sure the output register has a buffer large enough to store
8556185816
** the new record. The output register (pOp->p3) is not allowed to
8556285817
** be one of the input registers (because the following call to
8556385818
** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).
8556485819
*/
85565
- if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){
85566
- goto no_mem;
85820
+ if( nByte+nZero<=pOut->szMalloc ){
85821
+ /* The output register is already large enough to hold the record.
85822
+ ** No error checks or buffer enlargement is required */
85823
+ pOut->z = pOut->zMalloc;
85824
+ }else{
85825
+ /* Need to make sure that the output is not too big and then enlarge
85826
+ ** the output register to hold the full result */
85827
+ if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
85828
+ goto too_big;
85829
+ }
85830
+ if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){
85831
+ goto no_mem;
85832
+ }
8556785833
}
8556885834
zNewRecord = (u8 *)pOut->z;
8556985835
8557085836
/* Write the record */
8557185837
i = putVarint32(zNewRecord, nHdr);
@@ -88417,11 +88683,11 @@
8841788683
}else
8841888684
#endif
8841988685
{
8842088686
zMaster = MASTER_NAME;
8842188687
initData.db = db;
88422
- initData.iDb = pOp->p1;
88688
+ initData.iDb = iDb;
8842388689
initData.pzErrMsg = &p->zErrMsg;
8842488690
initData.mInitFlags = 0;
8842588691
zSql = sqlite3MPrintf(db,
8842688692
"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
8842788693
db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
@@ -89614,14 +89880,15 @@
8961489880
** Store in register P3 the value of the P2-th column of
8961589881
** the current row of the virtual-table of cursor P1.
8961689882
**
8961789883
** If the VColumn opcode is being used to fetch the value of
8961889884
** an unchanging column during an UPDATE operation, then the P5
89619
-** value is 1. Otherwise, P5 is 0. The P5 value is returned
89620
-** by sqlite3_vtab_nochange() routine and can be used
89621
-** by virtual table implementations to return special "no-change"
89622
-** marks which can be more efficient, depending on the virtual table.
89885
+** value is OPFLAG_NOCHNG. This will cause the sqlite3_vtab_nochange()
89886
+** function to return true inside the xColumn method of the virtual
89887
+** table implementation. The P5 column might also contain other
89888
+** bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are
89889
+** unused by OP_VColumn.
8962389890
*/
8962489891
case OP_VColumn: {
8962589892
sqlite3_vtab *pVtab;
8962689893
const sqlite3_module *pModule;
8962789894
Mem *pDest;
@@ -89639,11 +89906,12 @@
8963989906
pVtab = pCur->uc.pVCur->pVtab;
8964089907
pModule = pVtab->pModule;
8964189908
assert( pModule->xColumn );
8964289909
memset(&sContext, 0, sizeof(sContext));
8964389910
sContext.pOut = pDest;
89644
- if( pOp->p5 ){
89911
+ testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );
89912
+ if( pOp->p5 & OPFLAG_NOCHNG ){
8964589913
sqlite3VdbeMemSetNull(pDest);
8964689914
pDest->flags = MEM_Null|MEM_Zero;
8964789915
pDest->u.nZero = 0;
8964889916
}else{
8964989917
MemSetTypeFlag(pDest, MEM_Null);
@@ -93998,12 +94266,12 @@
9399894266
if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
9399994267
}else if( pExpr->x.pList ){
9400094268
if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
9400194269
}
9400294270
#ifndef SQLITE_OMIT_WINDOWFUNC
94003
- if( !ExprHasProperty(pExpr, EP_Reduced) && pExpr->pWin ){
94004
- Window *pWin = pExpr->pWin;
94271
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
94272
+ Window *pWin = pExpr->y.pWin;
9400594273
if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
9400694274
if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
9400794275
if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
9400894276
}
9400994277
#endif
@@ -94272,11 +94540,11 @@
9427294540
**
9427394541
** pExpr->iDb Set the index in db->aDb[] of the database X
9427494542
** (even if X is implied).
9427594543
** pExpr->iTable Set to the cursor number for the table obtained
9427694544
** from pSrcList.
94277
-** pExpr->pTab Points to the Table structure of X.Y (even if
94545
+** pExpr->y.pTab Points to the Table structure of X.Y (even if
9427894546
** X and/or Y are implied.)
9427994547
** pExpr->iColumn Set to the column number within the table.
9428094548
** pExpr->op Set to TK_COLUMN.
9428194549
** pExpr->pLeft Any expression this points to is deleted
9428294550
** pExpr->pRight Any expression this points to is deleted.
@@ -94316,11 +94584,10 @@
9431694584
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
9431794585
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
9431894586
9431994587
/* Initialize the node to no-match */
9432094588
pExpr->iTable = -1;
94321
- pExpr->pTab = 0;
9432294589
ExprSetVVAProperty(pExpr, EP_NoReduce);
9432394590
9432494591
/* Translate the schema name in zDb into a pointer to the corresponding
9432594592
** schema. If not found, pSchema will remain NULL and nothing will match
9432694593
** resulting in an appropriate error message toward the end of this routine
@@ -94378,11 +94645,11 @@
9437894645
assert( zTabName!=0 );
9437994646
if( sqlite3StrICmp(zTabName, zTab)!=0 ){
9438094647
continue;
9438194648
}
9438294649
if( IN_RENAME_OBJECT && pItem->zAlias ){
94383
- sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->pTab);
94650
+ sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
9438494651
}
9438594652
}
9438694653
if( 0==(cntTab++) ){
9438794654
pMatch = pItem;
9438894655
}
@@ -94404,17 +94671,17 @@
9440494671
}
9440594672
}
9440694673
}
9440794674
if( pMatch ){
9440894675
pExpr->iTable = pMatch->iCursor;
94409
- pExpr->pTab = pMatch->pTab;
94676
+ pExpr->y.pTab = pMatch->pTab;
9441094677
/* RIGHT JOIN not (yet) supported */
9441194678
assert( (pMatch->fg.jointype & JT_RIGHT)==0 );
9441294679
if( (pMatch->fg.jointype & JT_LEFT)!=0 ){
9441394680
ExprSetProperty(pExpr, EP_CanBeNull);
9441494681
}
94415
- pSchema = pExpr->pTab->pSchema;
94682
+ pSchema = pExpr->y.pTab->pSchema;
9441694683
}
9441794684
} /* if( pSrcList ) */
9441894685
9441994686
#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
9442094687
/* If we have not already resolved the name, then maybe
@@ -94467,11 +94734,11 @@
9446794734
#ifndef SQLITE_OMIT_UPSERT
9446894735
if( pExpr->iTable==2 ){
9446994736
testcase( iCol==(-1) );
9447094737
if( IN_RENAME_OBJECT ){
9447194738
pExpr->iColumn = iCol;
94472
- pExpr->pTab = pTab;
94739
+ pExpr->y.pTab = pTab;
9447394740
eNewExprOp = TK_COLUMN;
9447494741
}else{
9447594742
pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
9447694743
eNewExprOp = TK_REGISTER;
9447794744
ExprSetProperty(pExpr, EP_Alias);
@@ -94489,11 +94756,11 @@
9448994756
}else{
9449094757
testcase( iCol==31 );
9449194758
testcase( iCol==32 );
9449294759
pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
9449394760
}
94494
- pExpr->pTab = pTab;
94761
+ pExpr->y.pTab = pTab;
9449594762
pExpr->iColumn = (i16)iCol;
9449694763
eNewExprOp = TK_TRIGGER;
9449794764
#endif /* SQLITE_OMIT_TRIGGER */
9449894765
}
9449994766
}
@@ -94589,11 +94856,11 @@
9458994856
*/
9459094857
if( cnt==0 && zTab==0 ){
9459194858
assert( pExpr->op==TK_ID );
9459294859
if( ExprHasProperty(pExpr,EP_DblQuoted) ){
9459394860
pExpr->op = TK_STRING;
94594
- pExpr->pTab = 0;
94861
+ pExpr->y.pTab = 0;
9459594862
return WRC_Prune;
9459694863
}
9459794864
if( sqlite3ExprIdToTrueFalse(pExpr) ){
9459894865
return WRC_Prune;
9459994866
}
@@ -94667,13 +94934,13 @@
9466794934
*/
9466894935
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
9466994936
Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
9467094937
if( p ){
9467194938
struct SrcList_item *pItem = &pSrc->a[iSrc];
94672
- p->pTab = pItem->pTab;
94939
+ p->y.pTab = pItem->pTab;
9467394940
p->iTable = pItem->iCursor;
94674
- if( p->pTab->iPKey==iCol ){
94941
+ if( p->y.pTab->iPKey==iCol ){
9467594942
p->iColumn = -1;
9467694943
}else{
9467794944
p->iColumn = (ynVar)iCol;
9467894945
testcase( iCol==BMS );
9467994946
testcase( iCol==BMS-1 );
@@ -94759,11 +95026,11 @@
9475995026
struct SrcList_item *pItem;
9476095027
assert( pSrcList && pSrcList->nSrc==1 );
9476195028
pItem = pSrcList->a;
9476295029
assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
9476395030
pExpr->op = TK_COLUMN;
94764
- pExpr->pTab = pItem->pTab;
95031
+ pExpr->y.pTab = pItem->pTab;
9476595032
pExpr->iTable = pItem->iCursor;
9476695033
pExpr->iColumn = -1;
9476795034
pExpr->affinity = SQLITE_AFF_INTEGER;
9476895035
break;
9476995036
}
@@ -94803,13 +95070,11 @@
9480395070
}
9480495071
zTable = pLeft->u.zToken;
9480595072
zColumn = pRight->u.zToken;
9480695073
if( IN_RENAME_OBJECT ){
9480795074
sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
94808
- }
94809
- if( IN_RENAME_OBJECT ){
94810
- sqlite3RenameTokenRemap(pParse, (void*)&pExpr->pTab, (void*)pLeft);
95075
+ sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft);
9481195076
}
9481295077
}
9481395078
return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
9481495079
}
9481595080
@@ -94895,22 +95160,22 @@
9489595160
#ifndef SQLITE_OMIT_WINDOWFUNC
9489695161
assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
9489795162
|| (pDef->xValue==0 && pDef->xInverse==0)
9489895163
|| (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
9489995164
);
94900
- if( pDef && pDef->xValue==0 && pExpr->pWin ){
95165
+ if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
9490195166
sqlite3ErrorMsg(pParse,
9490295167
"%.*s() may not be used as a window function", nId, zId
9490395168
);
9490495169
pNC->nErr++;
9490595170
}else if(
9490695171
(is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94907
- || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94908
- || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
95172
+ || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)
95173
+ || (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)
9490995174
){
9491095175
const char *zType;
94911
- if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
95176
+ if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){
9491295177
zType = "window";
9491395178
}else{
9491495179
zType = "aggregate";
9491595180
}
9491695181
sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -94936,30 +95201,30 @@
9493695201
nId, zId);
9493795202
pNC->nErr++;
9493895203
}
9493995204
if( is_agg ){
9494095205
#ifndef SQLITE_OMIT_WINDOWFUNC
94941
- pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
95206
+ pNC->ncFlags &= ~(pExpr->y.pWin ? NC_AllowWin : NC_AllowAgg);
9494295207
#else
9494395208
pNC->ncFlags &= ~NC_AllowAgg;
9494495209
#endif
9494595210
}
9494695211
}
9494795212
sqlite3WalkExprList(pWalker, pList);
9494895213
if( is_agg ){
9494995214
#ifndef SQLITE_OMIT_WINDOWFUNC
94950
- if( pExpr->pWin ){
95215
+ if( pExpr->y.pWin ){
9495195216
Select *pSel = pNC->pWinSelect;
94952
- sqlite3WalkExprList(pWalker, pExpr->pWin->pPartition);
94953
- sqlite3WalkExprList(pWalker, pExpr->pWin->pOrderBy);
94954
- sqlite3WalkExpr(pWalker, pExpr->pWin->pFilter);
94955
- sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->pWin, pDef);
95217
+ sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
95218
+ sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
95219
+ sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
95220
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
9495695221
if( 0==pSel->pWin
94957
- || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->pWin)
95222
+ || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
9495895223
){
94959
- pExpr->pWin->pNextWin = pSel->pWin;
94960
- pSel->pWin = pExpr->pWin;
95224
+ pExpr->y.pWin->pNextWin = pSel->pWin;
95225
+ pSel->pWin = pExpr->y.pWin;
9496195226
}
9496295227
pNC->ncFlags |= NC_AllowWin;
9496395228
}else
9496495229
#endif /* SQLITE_OMIT_WINDOWFUNC */
9496595230
{
@@ -95378,17 +95643,17 @@
9537895643
return 1;
9537995644
}
9538095645
for(j=0; j<pSelect->pEList->nExpr; j++){
9538195646
if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
9538295647
#ifndef SQLITE_OMIT_WINDOWFUNC
95383
- if( pE->pWin ){
95648
+ if( ExprHasProperty(pE, EP_WinFunc) ){
9538495649
/* Since this window function is being changed into a reference
9538595650
** to the same window function the result set, remove the instance
9538695651
** of this window function from the Select.pWin list. */
9538795652
Window **pp;
9538895653
for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
95389
- if( *pp==pE->pWin ){
95654
+ if( *pp==pE->y.pWin ){
9539095655
*pp = (*pp)->pNextWin;
9539195656
}
9539295657
}
9539395658
}
9539495659
#endif
@@ -95847,12 +96112,12 @@
9584796112
if( op==TK_CAST ){
9584896113
assert( !ExprHasProperty(pExpr, EP_IntValue) );
9584996114
return sqlite3AffinityType(pExpr->u.zToken, 0);
9585096115
}
9585196116
#endif
95852
- if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){
95853
- return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
96117
+ if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){
96118
+ return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
9585496119
}
9585596120
if( op==TK_SELECT_COLUMN ){
9585696121
assert( pExpr->pLeft->flags&EP_xIsSelect );
9585796122
return sqlite3ExprAffinity(
9585896123
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
@@ -95932,17 +96197,17 @@
9593296197
while( p ){
9593396198
int op = p->op;
9593496199
if( p->flags & EP_Generic ) break;
9593596200
if( (op==TK_AGG_COLUMN || op==TK_COLUMN
9593696201
|| op==TK_REGISTER || op==TK_TRIGGER)
95937
- && p->pTab!=0
96202
+ && p->y.pTab!=0
9593896203
){
95939
- /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
96204
+ /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
9594096205
** a TK_COLUMN but was previously evaluated and cached in a register */
9594196206
int j = p->iColumn;
9594296207
if( j>=0 ){
95943
- const char *zColl = p->pTab->aCol[j].zColl;
96208
+ const char *zColl = p->y.pTab->aCol[j].zColl;
9594496209
pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
9594596210
}
9594696211
break;
9594796212
}
9594896213
if( op==TK_CAST || op==TK_UPLUS ){
@@ -96841,10 +97106,14 @@
9684197106
*/
9684297107
static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
9684397108
assert( p!=0 );
9684497109
/* Sanity check: Assert that the IntValue is non-negative if it exists */
9684597110
assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
97111
+
97112
+ assert( !ExprHasProperty(p, EP_WinFunc) || p->y.pWin!=0 || db->mallocFailed );
97113
+ assert( p->op!=TK_FUNCTION || ExprHasProperty(p, EP_TokenOnly|EP_Reduced)
97114
+ || p->y.pWin==0 || ExprHasProperty(p, EP_WinFunc) );
9684697115
#ifdef SQLITE_DEBUG
9684797116
if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){
9684897117
assert( p->pLeft==0 );
9684997118
assert( p->pRight==0 );
9685097119
assert( p->x.pSelect==0 );
@@ -96859,12 +97128,13 @@
9685997128
}else if( ExprHasProperty(p, EP_xIsSelect) ){
9686097129
sqlite3SelectDelete(db, p->x.pSelect);
9686197130
}else{
9686297131
sqlite3ExprListDelete(db, p->x.pList);
9686397132
}
96864
- if( !ExprHasProperty(p, EP_Reduced) ){
96865
- sqlite3WindowDelete(db, p->pWin);
97133
+ if( ExprHasProperty(p, EP_WinFunc) ){
97134
+ assert( p->op==TK_FUNCTION );
97135
+ sqlite3WindowDelete(db, p->y.pWin);
9686697136
}
9686797137
}
9686897138
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
9686997139
if( !ExprHasProperty(p, EP_Static) ){
9687097140
sqlite3DbFreeNN(db, p);
@@ -96924,11 +97194,11 @@
9692497194
assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
9692597195
assert( EXPR_FULLSIZE<=0xfff );
9692697196
assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
9692797197
if( 0==flags || p->op==TK_SELECT_COLUMN
9692897198
#ifndef SQLITE_OMIT_WINDOWFUNC
96929
- || p->pWin
97199
+ || ExprHasProperty(p, EP_WinFunc)
9693097200
#endif
9693197201
){
9693297202
nSize = EXPR_FULLSIZE;
9693397203
}else{
9693497204
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
@@ -96951,11 +97221,11 @@
9695197221
** string is defined.)
9695297222
*/
9695397223
static int dupedExprNodeSize(Expr *p, int flags){
9695497224
int nByte = dupedExprStructSize(p, flags) & 0xfff;
9695597225
if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
96956
- nByte += sqlite3Strlen30(p->u.zToken)+1;
97226
+ nByte += sqlite3Strlen30NN(p->u.zToken)+1;
9695797227
}
9695897228
return ROUND8(nByte);
9695997229
}
9696097230
9696197231
/*
@@ -97054,26 +97324,28 @@
9705497324
pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);
9705597325
}
9705697326
}
9705797327
9705897328
/* Fill in pNew->pLeft and pNew->pRight. */
97059
- zAlloc += dupedExprNodeSize(p, dupFlags);
97060
- if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
97329
+ if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){
97330
+ zAlloc += dupedExprNodeSize(p, dupFlags);
9706197331
if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
9706297332
pNew->pLeft = p->pLeft ?
9706397333
exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
9706497334
pNew->pRight = p->pRight ?
9706597335
exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
9706697336
}
97067
- }else{
9706897337
#ifndef SQLITE_OMIT_WINDOWFUNC
97069
- if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
97070
- pNew->pWin = 0;
97071
- }else{
97072
- pNew->pWin = sqlite3WindowDup(db, pNew, p->pWin);
97338
+ if( ExprHasProperty(p, EP_WinFunc) ){
97339
+ pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);
97340
+ assert( ExprHasProperty(pNew, EP_WinFunc) );
9707397341
}
9707497342
#endif /* SQLITE_OMIT_WINDOWFUNC */
97343
+ if( pzBuffer ){
97344
+ *pzBuffer = zAlloc;
97345
+ }
97346
+ }else{
9707597347
if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
9707697348
if( pNew->op==TK_SELECT_COLUMN ){
9707797349
pNew->pLeft = p->pLeft;
9707897350
assert( p->iColumn==0 || p->pRight==0 );
9707997351
assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -97081,13 +97353,10 @@
9708197353
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
9708297354
}
9708397355
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
9708497356
}
9708597357
}
97086
- if( pzBuffer ){
97087
- *pzBuffer = zAlloc;
97088
- }
9708997358
}
9709097359
return pNew;
9709197360
}
9709297361
9709397362
/*
@@ -97878,12 +98147,12 @@
9787898147
case TK_FLOAT:
9787998148
case TK_BLOB:
9788098149
return 0;
9788198150
case TK_COLUMN:
9788298151
return ExprHasProperty(p, EP_CanBeNull) ||
97883
- p->pTab==0 || /* Reference to column of index on expression */
97884
- (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);
98152
+ p->y.pTab==0 || /* Reference to column of index on expression */
98153
+ (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0);
9788598154
default:
9788698155
return 1;
9788798156
}
9788898157
}
9788998158
@@ -97934,10 +98203,18 @@
9793498203
if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1;
9793598204
if( sqlite3StrICmp(z, "ROWID")==0 ) return 1;
9793698205
if( sqlite3StrICmp(z, "OID")==0 ) return 1;
9793798206
return 0;
9793898207
}
98208
+#ifdef SQLITE_ENABLE_NORMALIZE
98209
+SQLITE_PRIVATE int sqlite3IsRowidN(const char *z, int n){
98210
+ if( sqlite3StrNICmp(z, "_ROWID_", n)==0 ) return 1;
98211
+ if( sqlite3StrNICmp(z, "ROWID", n)==0 ) return 1;
98212
+ if( sqlite3StrNICmp(z, "OID", n)==0 ) return 1;
98213
+ return 0;
98214
+}
98215
+#endif
9793998216
9794098217
/*
9794198218
** pX is the RHS of an IN operator. If pX is a SELECT statement
9794298219
** that can be simplified to a direct table access, then return
9794398220
** a pointer to the SELECT statement. If pX is not a SELECT statement,
@@ -99167,11 +99444,11 @@
9916799444
** expresssion. However, make sure the constant has the correct
9916899445
** datatype by applying the Affinity of the table column to the
9916999446
** constant.
9917099447
*/
9917199448
int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
99172
- int aff = sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
99449
+ int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
9917399450
if( aff!=SQLITE_AFF_BLOB ){
9917499451
static const char zAff[] = "B\000C\000D\000E";
9917599452
assert( SQLITE_AFF_BLOB=='A' );
9917699453
assert( SQLITE_AFF_TEXT=='B' );
9917799454
if( iReg!=target ){
@@ -99191,11 +99468,11 @@
9919199468
/* Coding an expression that is part of an index where column names
9919299469
** in the index refer to the table to which the index belongs */
9919399470
iTab = pParse->iSelfTab - 1;
9919499471
}
9919599472
}
99196
- return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
99473
+ return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
9919799474
pExpr->iColumn, iTab, target,
9919899475
pExpr->op2);
9919999476
}
9920099477
case TK_INTEGER: {
9920199478
codeInteger(pParse, pExpr, 0, target);
@@ -99405,12 +99682,12 @@
9940599682
sqlite3 *db = pParse->db; /* The database connection */
9940699683
u8 enc = ENC(db); /* The text encoding used by this database */
9940799684
CollSeq *pColl = 0; /* A collating sequence */
9940899685
9940999686
#ifndef SQLITE_OMIT_WINDOWFUNC
99410
- if( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) && pExpr->pWin ){
99411
- return pExpr->pWin->regResult;
99687
+ if( ExprHasProperty(pExpr, EP_WinFunc) ){
99688
+ return pExpr->y.pWin->regResult;
9941299689
}
9941399690
#endif
9941499691
9941599692
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
9941699693
/* SQL functions can be expensive. So try to move constant functions
@@ -99649,11 +99926,11 @@
9964999926
**
9965099927
** p1==0 -> old.rowid p1==3 -> new.rowid
9965199928
** p1==1 -> old.a p1==4 -> new.a
9965299929
** p1==2 -> old.b p1==5 -> new.b
9965399930
*/
99654
- Table *pTab = pExpr->pTab;
99931
+ Table *pTab = pExpr->y.pTab;
9965599932
int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
9965699933
9965799934
assert( pExpr->iTable==0 || pExpr->iTable==1 );
9965899935
assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
9965999936
assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
@@ -99660,11 +99937,11 @@
9966099937
assert( p1>=0 && p1<(pTab->nCol*2+2) );
9966199938
9966299939
sqlite3VdbeAddOp2(v, OP_Param, p1, target);
9966399940
VdbeComment((v, "r[%d]=%s.%s", target,
9966499941
(pExpr->iTable ? "new" : "old"),
99665
- (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName)
99942
+ (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[pExpr->iColumn].zName)
9966699943
));
9966799944
9966899945
#ifndef SQLITE_OMIT_FLOATING_POINT
9966999946
/* If the column has REAL affinity, it may currently be stored as an
9967099947
** integer. Use OP_RealAffinity to make sure it is really real.
@@ -100511,10 +100788,24 @@
100511100788
return 2;
100512100789
}
100513100790
if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
100514100791
if( pA->op==TK_FUNCTION ){
100515100792
if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
100793
+#ifndef SQLITE_OMIT_WINDOWFUNC
100794
+ /* Justification for the assert():
100795
+ ** window functions have p->op==TK_FUNCTION but aggregate functions
100796
+ ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100797
+ ** function and a window function should have failed before reaching
100798
+ ** this point. And, it is not possible to have a window function and
100799
+ ** a scalar function with the same name and number of arguments. So
100800
+ ** if we reach this point, either A and B both window functions or
100801
+ ** neither are a window functions. */
100802
+ assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) );
100803
+ if( ExprHasProperty(pA,EP_WinFunc) ){
100804
+ if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
100805
+ }
100806
+#endif
100516100807
}else if( pA->op==TK_COLLATE ){
100517100808
if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
100518100809
}else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
100519100810
return 2;
100520100811
}
@@ -100530,25 +100821,10 @@
100530100821
if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
100531100822
if( pA->iColumn!=pB->iColumn ) return 2;
100532100823
if( pA->iTable!=pB->iTable
100533100824
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
100534100825
}
100535
-#ifndef SQLITE_OMIT_WINDOWFUNC
100536
- /* Justification for the assert():
100537
- ** window functions have p->op==TK_FUNCTION but aggregate functions
100538
- ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100539
- ** function and a window function should have failed before reaching
100540
- ** this point. And, it is not possible to have a window function and
100541
- ** a scalar function with the same name and number of arguments. So
100542
- ** if we reach this point, either A and B both window functions or
100543
- ** neither are a window functions. */
100544
- assert( (pA->pWin==0)==(pB->pWin==0) );
100545
-
100546
- if( pA->pWin!=0 ){
100547
- if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
100548
- }
100549
-#endif
100550100826
}
100551100827
return 0;
100552100828
}
100553100829
100554100830
/*
@@ -100685,12 +100961,12 @@
100685100961
testcase( pExpr->op==TK_NE );
100686100962
testcase( pExpr->op==TK_LT );
100687100963
testcase( pExpr->op==TK_LE );
100688100964
testcase( pExpr->op==TK_GT );
100689100965
testcase( pExpr->op==TK_GE );
100690
- if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
100691
- || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
100966
+ if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
100967
+ || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
100692100968
){
100693100969
return WRC_Prune;
100694100970
}
100695100971
default:
100696100972
return WRC_Continue;
@@ -100917,11 +101193,11 @@
100917101193
}
100918101194
if( (k>=pAggInfo->nColumn)
100919101195
&& (k = addAggInfoColumn(pParse->db, pAggInfo))>=0
100920101196
){
100921101197
pCol = &pAggInfo->aCol[k];
100922
- pCol->pTab = pExpr->pTab;
101198
+ pCol->pTab = pExpr->y.pTab;
100923101199
pCol->iTable = pExpr->iTable;
100924101200
pCol->iColumn = pExpr->iColumn;
100925101201
pCol->iMem = ++pParse->nMem;
100926101202
pCol->iSorterColumn = -1;
100927101203
pCol->pExpr = pExpr;
@@ -101936,11 +102212,11 @@
101936102212
&& pWalker->pParse->pTriggerTab==p->pTab
101937102213
){
101938102214
renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101939102215
}else if( pExpr->op==TK_COLUMN
101940102216
&& pExpr->iColumn==p->iCol
101941
- && p->pTab==pExpr->pTab
102217
+ && p->pTab==pExpr->y.pTab
101942102218
){
101943102219
renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101944102220
}
101945102221
return WRC_Continue;
101946102222
}
@@ -102194,13 +102470,18 @@
102194102470
assert( pNew->pTabSchema );
102195102471
pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
102196102472
db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName
102197102473
);
102198102474
pParse->eTriggerOp = pNew->op;
102475
+ /* ALWAYS() because if the table of the trigger does not exist, the
102476
+ ** error would have been hit before this point */
102477
+ if( ALWAYS(pParse->pTriggerTab) ){
102478
+ rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
102479
+ }
102199102480
102200102481
/* Resolve symbols in WHEN clause */
102201
- if( pNew->pWhen ){
102482
+ if( rc==SQLITE_OK && pNew->pWhen ){
102202102483
rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
102203102484
}
102204102485
102205102486
for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
102206102487
if( pStep->pSelect ){
@@ -102474,12 +102755,12 @@
102474102755
/*
102475102756
** Walker expression callback used by "RENAME TABLE".
102476102757
*/
102477102758
static int renameTableExprCb(Walker *pWalker, Expr *pExpr){
102478102759
RenameCtx *p = pWalker->u.pRename;
102479
- if( pExpr->op==TK_COLUMN && p->pTab==pExpr->pTab ){
102480
- renameTokenFind(pWalker->pParse, p, (void*)&pExpr->pTab);
102760
+ if( pExpr->op==TK_COLUMN && p->pTab==pExpr->y.pTab ){
102761
+ renameTokenFind(pWalker->pParse, p, (void*)&pExpr->y.pTab);
102481102762
}
102482102763
return WRC_Continue;
102483102764
}
102484102765
102485102766
/*
@@ -102572,11 +102853,11 @@
102572102853
sqlite3WalkSelect(&sWalker, pTab->pSelect);
102573102854
}
102574102855
}else{
102575102856
/* Modify any FK definitions to point to the new table. */
102576102857
#ifndef SQLITE_OMIT_FOREIGN_KEY
102577
- if( db->flags & SQLITE_ForeignKeys ){
102858
+ if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
102578102859
FKey *pFKey;
102579102860
for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102580102861
if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102581102862
renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102582102863
}
@@ -105457,10 +105738,11 @@
105457105738
int iSrc; /* Index in pTabList->a[] of table being read */
105458105739
int iDb; /* The index of the database the expression refers to */
105459105740
int iCol; /* Index of column in table */
105460105741
105461105742
assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
105743
+ assert( !IN_RENAME_OBJECT || db->xAuth==0 );
105462105744
if( db->xAuth==0 ) return;
105463105745
iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
105464105746
if( iDb<0 ){
105465105747
/* An attempt to read a column out of a subquery or other
105466105748
** temporary table. */
@@ -105513,10 +105795,11 @@
105513105795
int rc;
105514105796
105515105797
/* Don't do any authorization checks if the database is initialising
105516105798
** or if the parser is being invoked from within sqlite3_declare_vtab.
105517105799
*/
105800
+ assert( !IN_RENAME_OBJECT || db->xAuth==0 );
105518105801
if( db->init.busy || IN_SPECIAL_PARSE ){
105519105802
return SQLITE_OK;
105520105803
}
105521105804
105522105805
if( db->xAuth==0 ){
@@ -105936,21 +106219,19 @@
105936106219
105937106220
p = sqlite3FindTable(db, zName, zDbase);
105938106221
if( p==0 ){
105939106222
const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
105940106223
#ifndef SQLITE_OMIT_VIRTUALTABLE
105941
- if( sqlite3FindDbName(db, zDbase)<1 ){
105942
- /* If zName is the not the name of a table in the schema created using
105943
- ** CREATE, then check to see if it is the name of an virtual table that
105944
- ** can be an eponymous virtual table. */
105945
- Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
105946
- if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
105947
- pMod = sqlite3PragmaVtabRegister(db, zName);
105948
- }
105949
- if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
105950
- return pMod->pEpoTab;
105951
- }
106224
+ /* If zName is the not the name of a table in the schema created using
106225
+ ** CREATE, then check to see if it is the name of an virtual table that
106226
+ ** can be an eponymous virtual table. */
106227
+ Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
106228
+ if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
106229
+ pMod = sqlite3PragmaVtabRegister(db, zName);
106230
+ }
106231
+ if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
106232
+ return pMod->pEpoTab;
105952106233
}
105953106234
#endif
105954106235
if( (flags & LOCATE_NOERR)==0 ){
105955106236
if( zDbase ){
105956106237
sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
@@ -106213,10 +106494,16 @@
106213106494
/* Delete any foreign keys attached to this table. */
106214106495
sqlite3FkDelete(db, pTable);
106215106496
106216106497
/* Delete the Table structure itself.
106217106498
*/
106499
+#ifdef SQLITE_ENABLE_NORMALIZE
106500
+ if( pTable->pColHash ){
106501
+ sqlite3HashClear(pTable->pColHash);
106502
+ sqlite3_free(pTable->pColHash);
106503
+ }
106504
+#endif
106218106505
sqlite3DeleteColumnNames(db, pTable);
106219106506
sqlite3DbFree(db, pTable->zName);
106220106507
sqlite3DbFree(db, pTable->zColAff);
106221106508
sqlite3SelectDelete(db, pTable->pSelect);
106222106509
sqlite3ExprListDelete(db, pTable->pCheck);
@@ -106370,10 +106657,24 @@
106370106657
iDb = db->init.iDb;
106371106658
*pUnqual = pName1;
106372106659
}
106373106660
return iDb;
106374106661
}
106662
+
106663
+/*
106664
+** True if PRAGMA writable_schema is ON
106665
+*/
106666
+SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){
106667
+ testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==0 );
106668
+ testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106669
+ SQLITE_WriteSchema );
106670
+ testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106671
+ SQLITE_Defensive );
106672
+ testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106673
+ (SQLITE_WriteSchema|SQLITE_Defensive) );
106674
+ return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema;
106675
+}
106375106676
106376106677
/*
106377106678
** This routine is used to check if the UTF-8 string zName is a legal
106378106679
** unqualified name for a new schema object (table, index, view or
106379106680
** trigger). All names are legal except those that begin with the string
@@ -106380,11 +106681,11 @@
106380106681
** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
106381106682
** is reserved for internal use.
106382106683
*/
106383106684
SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){
106384106685
if( !pParse->db->init.busy && pParse->nested==0
106385
- && (pParse->db->flags & SQLITE_WriteSchema)==0
106686
+ && sqlite3WritableSchema(pParse->db)==0
106386106687
&& 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
106387106688
sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
106388106689
return SQLITE_ERROR;
106389106690
}
106390106691
return SQLITE_OK;
@@ -107455,10 +107756,36 @@
107455107756
}else{
107456107757
pPk->nColumn = pTab->nCol;
107457107758
}
107458107759
recomputeColumnsNotIndexed(pPk);
107459107760
}
107761
+
107762
+/*
107763
+** Return true if zName is a shadow table name in the current database
107764
+** connection.
107765
+**
107766
+** zName is temporarily modified while this routine is running, but is
107767
+** restored to its original value prior to this routine returning.
107768
+*/
107769
+static int isShadowTableName(sqlite3 *db, char *zName){
107770
+ char *zTail; /* Pointer to the last "_" in zName */
107771
+ Table *pTab; /* Table that zName is a shadow of */
107772
+ Module *pMod; /* Module for the virtual table */
107773
+
107774
+ zTail = strrchr(zName, '_');
107775
+ if( zTail==0 ) return 0;
107776
+ *zTail = 0;
107777
+ pTab = sqlite3FindTable(db, zName, 0);
107778
+ *zTail = '_';
107779
+ if( pTab==0 ) return 0;
107780
+ if( !IsVirtual(pTab) ) return 0;
107781
+ pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
107782
+ if( pMod==0 ) return 0;
107783
+ if( pMod->pModule->iVersion<3 ) return 0;
107784
+ if( pMod->pModule->xShadowName==0 ) return 0;
107785
+ return pMod->pModule->xShadowName(zTail+1);
107786
+}
107460107787
107461107788
/*
107462107789
** This routine is called to report the final ")" that terminates
107463107790
** a CREATE TABLE statement.
107464107791
**
@@ -107494,10 +107821,14 @@
107494107821
return;
107495107822
}
107496107823
assert( !db->mallocFailed );
107497107824
p = pParse->pNewTable;
107498107825
if( p==0 ) return;
107826
+
107827
+ if( pSelect==0 && isShadowTableName(db, p->zName) ){
107828
+ p->tabFlags |= TF_Shadow;
107829
+ }
107499107830
107500107831
/* If the db->init.busy is 1 it means we are reading the SQL off the
107501107832
** "sqlite_master" or "sqlite_temp_master" table on the disk.
107502107833
** So do not write to the disk again. Extract the root page number
107503107834
** for the table from the db->init.newTnum field. (The page number
@@ -108002,11 +108333,11 @@
108002108333
** erasing iTable (this can happen with an auto-vacuum database).
108003108334
*/
108004108335
static void destroyRootPage(Parse *pParse, int iTable, int iDb){
108005108336
Vdbe *v = sqlite3GetVdbe(pParse);
108006108337
int r1 = sqlite3GetTempReg(pParse);
108007
- assert( iTable>1 );
108338
+ if( iTable<2 ) sqlite3ErrorMsg(pParse, "corrupt schema");
108008108339
sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
108009108340
sqlite3MayAbort(pParse);
108010108341
#ifndef SQLITE_OMIT_AUTOVACUUM
108011108342
/* OP_Destroy stores an in integer r1. If this integer
108012108343
** is non-zero, then it is the root page number of a table moved to
@@ -110457,10 +110788,25 @@
110457110788
return p;
110458110789
}
110459110790
}
110460110791
return 0;
110461110792
}
110793
+#ifdef SQLITE_ENABLE_NORMALIZE
110794
+SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(
110795
+ int h, /* Hash of the name */
110796
+ const char *zFunc, /* Name of function */
110797
+ int nFunc /* Length of the name */
110798
+){
110799
+ FuncDef *p;
110800
+ for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){
110801
+ if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 ){
110802
+ return p;
110803
+ }
110804
+ }
110805
+ return 0;
110806
+}
110807
+#endif /* SQLITE_ENABLE_NORMALIZE */
110462110808
110463110809
/*
110464110810
** Insert a new FuncDef into a FuncDefHash hash table.
110465110811
*/
110466110812
SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
@@ -110470,11 +110816,11 @@
110470110816
int i;
110471110817
for(i=0; i<nDef; i++){
110472110818
FuncDef *pOther;
110473110819
const char *zName = aDef[i].zName;
110474110820
int nName = sqlite3Strlen30(zName);
110475
- int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;
110821
+ int h = SQLITE_FUNC_HASH(zName[0], nName);
110476110822
assert( zName[0]>='a' && zName[0]<='z' );
110477110823
pOther = functionSearch(h, zName);
110478110824
if( pOther ){
110479110825
assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
110480110826
aDef[i].pNext = pOther->pNext;
@@ -110549,11 +110895,11 @@
110549110895
** new function. But the FuncDefs for built-in functions are read-only.
110550110896
** So we must not search for built-ins when creating a new function.
110551110897
*/
110552110898
if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
110553110899
bestScore = 0;
110554
- h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;
110900
+ h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);
110555110901
p = functionSearch(h, zName);
110556110902
while( p ){
110557110903
int score = matchQuality(p, nArg, enc);
110558110904
if( score>bestScore ){
110559110905
pBest = p;
@@ -110696,37 +111042,52 @@
110696111042
if( sqlite3IndexedByLookup(pParse, pItem) ){
110697111043
pTab = 0;
110698111044
}
110699111045
return pTab;
110700111046
}
111047
+
111048
+/* Return true if table pTab is read-only.
111049
+**
111050
+** A table is read-only if any of the following are true:
111051
+**
111052
+** 1) It is a virtual table and no implementation of the xUpdate method
111053
+** has been provided
111054
+**
111055
+** 2) It is a system table (i.e. sqlite_master), this call is not
111056
+** part of a nested parse and writable_schema pragma has not
111057
+** been specified
111058
+**
111059
+** 3) The table is a shadow table, the database connection is in
111060
+** defensive mode, and the current sqlite3_prepare()
111061
+** is for a top-level SQL statement.
111062
+*/
111063
+static int tabIsReadOnly(Parse *pParse, Table *pTab){
111064
+ sqlite3 *db;
111065
+ if( IsVirtual(pTab) ){
111066
+ return sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0;
111067
+ }
111068
+ if( (pTab->tabFlags & (TF_Readonly|TF_Shadow))==0 ) return 0;
111069
+ db = pParse->db;
111070
+ if( (pTab->tabFlags & TF_Readonly)!=0 ){
111071
+ return sqlite3WritableSchema(db)==0 && pParse->nested==0;
111072
+ }
111073
+ assert( pTab->tabFlags & TF_Shadow );
111074
+ return (db->flags & SQLITE_Defensive)!=0
111075
+ && db->nVdbeExec==0
111076
+ && db->pVtabCtx==0;
111077
+}
110701111078
110702111079
/*
110703111080
** Check to make sure the given table is writable. If it is not
110704111081
** writable, generate an error message and return 1. If it is
110705111082
** writable return 0;
110706111083
*/
110707111084
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
110708
- /* A table is not writable under the following circumstances:
110709
- **
110710
- ** 1) It is a virtual table and no implementation of the xUpdate method
110711
- ** has been provided, or
110712
- ** 2) It is a system table (i.e. sqlite_master), this call is not
110713
- ** part of a nested parse and writable_schema pragma has not
110714
- ** been specified.
110715
- **
110716
- ** In either case leave an error message in pParse and return non-zero.
110717
- */
110718
- if( ( IsVirtual(pTab)
110719
- && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 )
110720
- || ( (pTab->tabFlags & TF_Readonly)!=0
110721
- && (pParse->db->flags & SQLITE_WriteSchema)==0
110722
- && pParse->nested==0 )
110723
- ){
111085
+ if( tabIsReadOnly(pParse, pTab) ){
110724111086
sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
110725111087
return 1;
110726111088
}
110727
-
110728111089
#ifndef SQLITE_OMIT_VIEW
110729111090
if( !viewOk && pTab->pSelect ){
110730111091
sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
110731111092
return 1;
110732111093
}
@@ -114126,11 +114487,11 @@
114126114487
int iCursor, /* The open cursor on the table */
114127114488
i16 iCol /* The column that is wanted */
114128114489
){
114129114490
Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);
114130114491
if( pExpr ){
114131
- pExpr->pTab = pTab;
114492
+ pExpr->y.pTab = pTab;
114132114493
pExpr->iTable = iCursor;
114133114494
pExpr->iColumn = iCol;
114134114495
}
114135114496
return pExpr;
114136114497
}
@@ -115202,11 +115563,12 @@
115202115563
do{
115203115564
zColAff[i--] = 0;
115204115565
}while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );
115205115566
pTab->zColAff = zColAff;
115206115567
}
115207
- i = sqlite3Strlen30(zColAff);
115568
+ assert( zColAff!=0 );
115569
+ i = sqlite3Strlen30NN(zColAff);
115208115570
if( i ){
115209115571
if( iReg ){
115210115572
sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);
115211115573
}else{
115212115574
sqlite3VdbeChangeP4(v, -1, zColAff, i);
@@ -116182,18 +116544,19 @@
116182116544
#ifdef tmask
116183116545
#undef tmask
116184116546
#endif
116185116547
116186116548
/*
116187
-** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()
116549
+** Meanings of bits in of pWalker->eCode for
116550
+** sqlite3ExprReferencesUpdatedColumn()
116188116551
*/
116189116552
#define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
116190116553
#define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */
116191116554
116192
-/* This is the Walker callback from checkConstraintUnchanged(). Set
116193
-** bit 0x01 of pWalker->eCode if
116194
-** pWalker->eCode to 0 if this expression node references any of the
116555
+/* This is the Walker callback from sqlite3ExprReferencesUpdatedColumn().
116556
+* Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this
116557
+** expression node references any of the
116195116558
** columns that are being modifed by an UPDATE statement.
116196116559
*/
116197116560
static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
116198116561
if( pExpr->op==TK_COLUMN ){
116199116562
assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
@@ -116211,16 +116574,25 @@
116211116574
/*
116212116575
** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
116213116576
** only columns that are modified by the UPDATE are those for which
116214116577
** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
116215116578
**
116216
-** Return true if CHECK constraint pExpr does not use any of the
116579
+** Return true if CHECK constraint pExpr uses any of the
116217116580
** changing columns (or the rowid if it is changing). In other words,
116218
-** return true if this CHECK constraint can be skipped when validating
116581
+** return true if this CHECK constraint must be validated for
116219116582
** the new row in the UPDATE statement.
116583
+**
116584
+** 2018-09-15: pExpr might also be an expression for an index-on-expressions.
116585
+** The operation of this routine is the same - return true if an only if
116586
+** the expression uses one or more of columns identified by the second and
116587
+** third arguments.
116220116588
*/
116221
-static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
116589
+SQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(
116590
+ Expr *pExpr, /* The expression to be checked */
116591
+ int *aiChng, /* aiChng[x]>=0 if column x changed by the UPDATE */
116592
+ int chngRowid /* True if UPDATE changes the rowid */
116593
+){
116222116594
Walker w;
116223116595
memset(&w, 0, sizeof(w));
116224116596
w.eCode = 0;
116225116597
w.xExprCallback = checkConstraintExprNode;
116226116598
w.u.aiCol = aiChng;
@@ -116231,11 +116603,11 @@
116231116603
}
116232116604
testcase( w.eCode==0 );
116233116605
testcase( w.eCode==CKCNSTRNT_COLUMN );
116234116606
testcase( w.eCode==CKCNSTRNT_ROWID );
116235116607
testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
116236
- return !w.eCode;
116608
+ return w.eCode!=0;
116237116609
}
116238116610
116239116611
/*
116240116612
** Generate code to do constraint checks prior to an INSERT or an UPDATE
116241116613
** on table pTab.
@@ -116437,11 +116809,17 @@
116437116809
pParse->iSelfTab = -(regNewData+1);
116438116810
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
116439116811
for(i=0; i<pCheck->nExpr; i++){
116440116812
int allOk;
116441116813
Expr *pExpr = pCheck->a[i].pExpr;
116442
- if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
116814
+ if( aiChng
116815
+ && !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng)
116816
+ ){
116817
+ /* The check constraints do not reference any of the columns being
116818
+ ** updated so there is no point it verifying the check constraint */
116819
+ continue;
116820
+ }
116443116821
allOk = sqlite3VdbeMakeLabel(v);
116444116822
sqlite3VdbeVerifyAbortable(v, onError);
116445116823
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
116446116824
if( onError==OE_Ignore ){
116447116825
sqlite3VdbeGoto(v, ignoreDest);
@@ -117938,16 +118316,19 @@
117938118316
void (*str_appendchar)(sqlite3_str*, int N, char C);
117939118317
void (*str_reset)(sqlite3_str*);
117940118318
int (*str_errcode)(sqlite3_str*);
117941118319
int (*str_length)(sqlite3_str*);
117942118320
char *(*str_value)(sqlite3_str*);
118321
+ /* Version 3.25.0 and later */
117943118322
int (*create_window_function)(sqlite3*,const char*,int,int,void*,
117944118323
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
117945118324
void (*xFinal)(sqlite3_context*),
117946118325
void (*xValue)(sqlite3_context*),
117947118326
void (*xInv)(sqlite3_context*,int,sqlite3_value**),
117948118327
void(*xDestroy)(void*));
118328
+ /* Version 3.26.0 and later */
118329
+ const char *(*normalized_sql)(sqlite3_stmt*);
117949118330
};
117950118331
117951118332
/*
117952118333
** This is the function signature used for all extension entry points. It
117953118334
** is also defined in the file "loadext.c".
@@ -118231,10 +118612,12 @@
118231118612
#define sqlite3_str_errcode sqlite3_api->str_errcode
118232118613
#define sqlite3_str_length sqlite3_api->str_length
118233118614
#define sqlite3_str_value sqlite3_api->str_value
118234118615
/* Version 3.25.0 and later */
118235118616
#define sqlite3_create_window_function sqlite3_api->create_window_function
118617
+/* Version 3.26.0 and later */
118618
+#define sqlite3_normalized_sql sqlite3_api->normalized_sql
118236118619
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118237118620
118238118621
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118239118622
/* This case when the file really is being compiled as a loadable
118240118623
** extension */
@@ -118686,11 +119069,17 @@
118686119069
sqlite3_str_reset,
118687119070
sqlite3_str_errcode,
118688119071
sqlite3_str_length,
118689119072
sqlite3_str_value,
118690119073
/* Version 3.25.0 and later */
118691
- sqlite3_create_window_function
119074
+ sqlite3_create_window_function,
119075
+ /* Version 3.26.0 and later */
119076
+#ifdef SQLITE_ENABLE_NORMALIZE
119077
+ sqlite3_normalized_sql
119078
+#else
119079
+ 0
119080
+#endif
118692119081
};
118693119082
118694119083
/*
118695119084
** Attempt to load an SQLite extension library contained in the file
118696119085
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -119136,14 +119525,13 @@
119136119525
#define PragTyp_WAL_AUTOCHECKPOINT 38
119137119526
#define PragTyp_WAL_CHECKPOINT 39
119138119527
#define PragTyp_ACTIVATE_EXTENSIONS 40
119139119528
#define PragTyp_HEXKEY 41
119140119529
#define PragTyp_KEY 42
119141
-#define PragTyp_REKEY 43
119142
-#define PragTyp_LOCK_STATUS 44
119143
-#define PragTyp_PARSER_TRACE 45
119144
-#define PragTyp_STATS 46
119530
+#define PragTyp_LOCK_STATUS 43
119531
+#define PragTyp_PARSER_TRACE 44
119532
+#define PragTyp_STATS 45
119145119533
119146119534
/* Property flags associated with various pragma. */
119147119535
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
119148119536
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
119149119537
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -119156,72 +119544,71 @@
119156119544
/* Names of columns for pragmas that return multi-column result
119157119545
** or that return single-column results where the name of the
119158119546
** result column is different from the name of the pragma
119159119547
*/
119160119548
static const char *const pragCName[] = {
119161
- /* 0 */ "cache_size", /* Used by: default_cache_size */
119162
- /* 1 */ "cid", /* Used by: table_info */
119163
- /* 2 */ "name",
119164
- /* 3 */ "type",
119165
- /* 4 */ "notnull",
119166
- /* 5 */ "dflt_value",
119167
- /* 6 */ "pk",
119168
- /* 7 */ "tbl", /* Used by: stats */
119169
- /* 8 */ "idx",
119170
- /* 9 */ "wdth",
119171
- /* 10 */ "hght",
119172
- /* 11 */ "flgs",
119173
- /* 12 */ "seqno", /* Used by: index_info */
119174
- /* 13 */ "cid",
119175
- /* 14 */ "name",
119549
+ /* 0 */ "id", /* Used by: foreign_key_list */
119550
+ /* 1 */ "seq",
119551
+ /* 2 */ "table",
119552
+ /* 3 */ "from",
119553
+ /* 4 */ "to",
119554
+ /* 5 */ "on_update",
119555
+ /* 6 */ "on_delete",
119556
+ /* 7 */ "match",
119557
+ /* 8 */ "cid", /* Used by: table_xinfo */
119558
+ /* 9 */ "name",
119559
+ /* 10 */ "type",
119560
+ /* 11 */ "notnull",
119561
+ /* 12 */ "dflt_value",
119562
+ /* 13 */ "pk",
119563
+ /* 14 */ "hidden",
119564
+ /* table_info reuses 8 */
119176119565
/* 15 */ "seqno", /* Used by: index_xinfo */
119177119566
/* 16 */ "cid",
119178119567
/* 17 */ "name",
119179119568
/* 18 */ "desc",
119180119569
/* 19 */ "coll",
119181119570
/* 20 */ "key",
119182
- /* 21 */ "seq", /* Used by: index_list */
119183
- /* 22 */ "name",
119184
- /* 23 */ "unique",
119185
- /* 24 */ "origin",
119186
- /* 25 */ "partial",
119187
- /* 26 */ "seq", /* Used by: database_list */
119571
+ /* 21 */ "tbl", /* Used by: stats */
119572
+ /* 22 */ "idx",
119573
+ /* 23 */ "wdth",
119574
+ /* 24 */ "hght",
119575
+ /* 25 */ "flgs",
119576
+ /* 26 */ "seq", /* Used by: index_list */
119188119577
/* 27 */ "name",
119189
- /* 28 */ "file",
119190
- /* 29 */ "name", /* Used by: function_list */
119191
- /* 30 */ "builtin",
119192
- /* 31 */ "name", /* Used by: module_list pragma_list */
119193
- /* 32 */ "seq", /* Used by: collation_list */
119194
- /* 33 */ "name",
119195
- /* 34 */ "id", /* Used by: foreign_key_list */
119196
- /* 35 */ "seq",
119197
- /* 36 */ "table",
119198
- /* 37 */ "from",
119199
- /* 38 */ "to",
119200
- /* 39 */ "on_update",
119201
- /* 40 */ "on_delete",
119202
- /* 41 */ "match",
119203
- /* 42 */ "table", /* Used by: foreign_key_check */
119204
- /* 43 */ "rowid",
119205
- /* 44 */ "parent",
119206
- /* 45 */ "fkid",
119207
- /* 46 */ "busy", /* Used by: wal_checkpoint */
119208
- /* 47 */ "log",
119209
- /* 48 */ "checkpointed",
119210
- /* 49 */ "timeout", /* Used by: busy_timeout */
119211
- /* 50 */ "database", /* Used by: lock_status */
119212
- /* 51 */ "status",
119578
+ /* 28 */ "unique",
119579
+ /* 29 */ "origin",
119580
+ /* 30 */ "partial",
119581
+ /* 31 */ "table", /* Used by: foreign_key_check */
119582
+ /* 32 */ "rowid",
119583
+ /* 33 */ "parent",
119584
+ /* 34 */ "fkid",
119585
+ /* index_info reuses 15 */
119586
+ /* 35 */ "seq", /* Used by: database_list */
119587
+ /* 36 */ "name",
119588
+ /* 37 */ "file",
119589
+ /* 38 */ "busy", /* Used by: wal_checkpoint */
119590
+ /* 39 */ "log",
119591
+ /* 40 */ "checkpointed",
119592
+ /* 41 */ "name", /* Used by: function_list */
119593
+ /* 42 */ "builtin",
119594
+ /* collation_list reuses 26 */
119595
+ /* 43 */ "database", /* Used by: lock_status */
119596
+ /* 44 */ "status",
119597
+ /* 45 */ "cache_size", /* Used by: default_cache_size */
119598
+ /* module_list pragma_list reuses 9 */
119599
+ /* 46 */ "timeout", /* Used by: busy_timeout */
119213119600
};
119214119601
119215119602
/* Definitions of all built-in pragmas */
119216119603
typedef struct PragmaName {
119217119604
const char *const zName; /* Name of pragma */
119218119605
u8 ePragTyp; /* PragTyp_XXX value */
119219119606
u8 mPragFlg; /* Zero or more PragFlg_XXX values */
119220119607
u8 iPragCName; /* Start of column names in pragCName[] */
119221119608
u8 nPragCName; /* Num of col names. 0 means use pragma name */
119222
- u32 iArg; /* Extra argument */
119609
+ u64 iArg; /* Extra argument */
119223119610
} PragmaName;
119224119611
static const PragmaName aPragmaName[] = {
119225119612
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
119226119613
{/* zName: */ "activate_extensions",
119227119614
/* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
@@ -119253,11 +119640,11 @@
119253119640
#endif
119254119641
#endif
119255119642
{/* zName: */ "busy_timeout",
119256119643
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
119257119644
/* ePragFlg: */ PragFlg_Result0,
119258
- /* ColNames: */ 49, 1,
119645
+ /* ColNames: */ 46, 1,
119259119646
/* iArg: */ 0 },
119260119647
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119261119648
{/* zName: */ "cache_size",
119262119649
/* ePragTyp: */ PragTyp_CACHE_SIZE,
119263119650
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -119290,11 +119677,11 @@
119290119677
#endif
119291119678
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119292119679
{/* zName: */ "collation_list",
119293119680
/* ePragTyp: */ PragTyp_COLLATION_LIST,
119294119681
/* ePragFlg: */ PragFlg_Result0,
119295
- /* ColNames: */ 32, 2,
119682
+ /* ColNames: */ 26, 2,
119296119683
/* iArg: */ 0 },
119297119684
#endif
119298119685
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
119299119686
{/* zName: */ "compile_options",
119300119687
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -119325,18 +119712,18 @@
119325119712
#endif
119326119713
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119327119714
{/* zName: */ "database_list",
119328119715
/* ePragTyp: */ PragTyp_DATABASE_LIST,
119329119716
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119330
- /* ColNames: */ 26, 3,
119717
+ /* ColNames: */ 35, 3,
119331119718
/* iArg: */ 0 },
119332119719
#endif
119333119720
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
119334119721
{/* zName: */ "default_cache_size",
119335119722
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
119336119723
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
119337
- /* ColNames: */ 0, 1,
119724
+ /* ColNames: */ 45, 1,
119338119725
/* iArg: */ 0 },
119339119726
#endif
119340119727
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119341119728
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119342119729
{/* zName: */ "defer_foreign_keys",
@@ -119362,18 +119749,18 @@
119362119749
#endif
119363119750
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119364119751
{/* zName: */ "foreign_key_check",
119365119752
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
119366119753
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119367
- /* ColNames: */ 42, 4,
119754
+ /* ColNames: */ 31, 4,
119368119755
/* iArg: */ 0 },
119369119756
#endif
119370119757
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
119371119758
{/* zName: */ "foreign_key_list",
119372119759
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
119373119760
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119374
- /* ColNames: */ 34, 8,
119761
+ /* ColNames: */ 0, 8,
119375119762
/* iArg: */ 0 },
119376119763
#endif
119377119764
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119378119765
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119379119766
{/* zName: */ "foreign_keys",
@@ -119405,25 +119792,25 @@
119405119792
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119406119793
#if defined(SQLITE_INTROSPECTION_PRAGMAS)
119407119794
{/* zName: */ "function_list",
119408119795
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
119409119796
/* ePragFlg: */ PragFlg_Result0,
119410
- /* ColNames: */ 29, 2,
119797
+ /* ColNames: */ 41, 2,
119411119798
/* iArg: */ 0 },
119412119799
#endif
119413119800
#endif
119414119801
#if defined(SQLITE_HAS_CODEC)
119415119802
{/* zName: */ "hexkey",
119416119803
/* ePragTyp: */ PragTyp_HEXKEY,
119417119804
/* ePragFlg: */ 0,
119418119805
/* ColNames: */ 0, 0,
119419
- /* iArg: */ 0 },
119806
+ /* iArg: */ 2 },
119420119807
{/* zName: */ "hexrekey",
119421119808
/* ePragTyp: */ PragTyp_HEXKEY,
119422119809
/* ePragFlg: */ 0,
119423119810
/* ColNames: */ 0, 0,
119424
- /* iArg: */ 0 },
119811
+ /* iArg: */ 3 },
119425119812
#endif
119426119813
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119427119814
#if !defined(SQLITE_OMIT_CHECK)
119428119815
{/* zName: */ "ignore_check_constraints",
119429119816
/* ePragTyp: */ PragTyp_FLAG,
@@ -119441,16 +119828,16 @@
119441119828
#endif
119442119829
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119443119830
{/* zName: */ "index_info",
119444119831
/* ePragTyp: */ PragTyp_INDEX_INFO,
119445119832
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119446
- /* ColNames: */ 12, 3,
119833
+ /* ColNames: */ 15, 3,
119447119834
/* iArg: */ 0 },
119448119835
{/* zName: */ "index_list",
119449119836
/* ePragTyp: */ PragTyp_INDEX_LIST,
119450119837
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119451
- /* ColNames: */ 21, 5,
119838
+ /* ColNames: */ 26, 5,
119452119839
/* iArg: */ 0 },
119453119840
{/* zName: */ "index_xinfo",
119454119841
/* ePragTyp: */ PragTyp_INDEX_INFO,
119455119842
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119456119843
/* ColNames: */ 15, 6,
@@ -119503,11 +119890,11 @@
119503119890
#endif
119504119891
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
119505119892
{/* zName: */ "lock_status",
119506119893
/* ePragTyp: */ PragTyp_LOCK_STATUS,
119507119894
/* ePragFlg: */ PragFlg_Result0,
119508
- /* ColNames: */ 50, 2,
119895
+ /* ColNames: */ 43, 2,
119509119896
/* iArg: */ 0 },
119510119897
#endif
119511119898
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119512119899
{/* zName: */ "locking_mode",
119513119900
/* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -119529,11 +119916,11 @@
119529119916
#if !defined(SQLITE_OMIT_VIRTUALTABLE)
119530119917
#if defined(SQLITE_INTROSPECTION_PRAGMAS)
119531119918
{/* zName: */ "module_list",
119532119919
/* ePragTyp: */ PragTyp_MODULE_LIST,
119533119920
/* ePragFlg: */ PragFlg_Result0,
119534
- /* ColNames: */ 31, 1,
119921
+ /* ColNames: */ 9, 1,
119535119922
/* iArg: */ 0 },
119536119923
#endif
119537119924
#endif
119538119925
#endif
119539119926
{/* zName: */ "optimize",
@@ -119562,11 +119949,11 @@
119562119949
#endif
119563119950
#if defined(SQLITE_INTROSPECTION_PRAGMAS)
119564119951
{/* zName: */ "pragma_list",
119565119952
/* ePragTyp: */ PragTyp_PRAGMA_LIST,
119566119953
/* ePragFlg: */ PragFlg_Result0,
119567
- /* ColNames: */ 31, 1,
119954
+ /* ColNames: */ 9, 1,
119568119955
/* iArg: */ 0 },
119569119956
#endif
119570119957
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119571119958
{/* zName: */ "query_only",
119572119959
/* ePragTyp: */ PragTyp_FLAG,
@@ -119593,14 +119980,14 @@
119593119980
/* ColNames: */ 0, 0,
119594119981
/* iArg: */ SQLITE_RecTriggers },
119595119982
#endif
119596119983
#if defined(SQLITE_HAS_CODEC)
119597119984
{/* zName: */ "rekey",
119598
- /* ePragTyp: */ PragTyp_REKEY,
119985
+ /* ePragTyp: */ PragTyp_KEY,
119599119986
/* ePragFlg: */ 0,
119600119987
/* ColNames: */ 0, 0,
119601
- /* iArg: */ 0 },
119988
+ /* iArg: */ 1 },
119602119989
#endif
119603119990
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119604119991
{/* zName: */ "reverse_unordered_selects",
119605119992
/* ePragTyp: */ PragTyp_FLAG,
119606119993
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119649,11 +120036,11 @@
119649120036
#endif
119650120037
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
119651120038
{/* zName: */ "stats",
119652120039
/* ePragTyp: */ PragTyp_STATS,
119653120040
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
119654
- /* ColNames: */ 7, 5,
120041
+ /* ColNames: */ 21, 5,
119655120042
/* iArg: */ 0 },
119656120043
#endif
119657120044
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119658120045
{/* zName: */ "synchronous",
119659120046
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -119663,12 +120050,17 @@
119663120050
#endif
119664120051
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119665120052
{/* zName: */ "table_info",
119666120053
/* ePragTyp: */ PragTyp_TABLE_INFO,
119667120054
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119668
- /* ColNames: */ 1, 6,
120055
+ /* ColNames: */ 8, 6,
119669120056
/* iArg: */ 0 },
120057
+ {/* zName: */ "table_xinfo",
120058
+ /* ePragTyp: */ PragTyp_TABLE_INFO,
120059
+ /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
120060
+ /* ColNames: */ 8, 7,
120061
+ /* iArg: */ 1 },
119670120062
#endif
119671120063
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119672120064
{/* zName: */ "temp_store",
119673120065
/* ePragTyp: */ PragTyp_TEMP_STORE,
119674120066
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119677,10 +120069,22 @@
119677120069
{/* zName: */ "temp_store_directory",
119678120070
/* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
119679120071
/* ePragFlg: */ PragFlg_NoColumns1,
119680120072
/* ColNames: */ 0, 0,
119681120073
/* iArg: */ 0 },
120074
+#endif
120075
+#if defined(SQLITE_HAS_CODEC)
120076
+ {/* zName: */ "textkey",
120077
+ /* ePragTyp: */ PragTyp_KEY,
120078
+ /* ePragFlg: */ 0,
120079
+ /* ColNames: */ 0, 0,
120080
+ /* iArg: */ 4 },
120081
+ {/* zName: */ "textrekey",
120082
+ /* ePragTyp: */ PragTyp_KEY,
120083
+ /* ePragFlg: */ 0,
120084
+ /* ColNames: */ 0, 0,
120085
+ /* iArg: */ 5 },
119682120086
#endif
119683120087
{/* zName: */ "threads",
119684120088
/* ePragTyp: */ PragTyp_THREADS,
119685120089
/* ePragFlg: */ PragFlg_Result0,
119686120090
/* ColNames: */ 0, 0,
@@ -119728,22 +120132,22 @@
119728120132
/* ColNames: */ 0, 0,
119729120133
/* iArg: */ 0 },
119730120134
{/* zName: */ "wal_checkpoint",
119731120135
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
119732120136
/* ePragFlg: */ PragFlg_NeedSchema,
119733
- /* ColNames: */ 46, 3,
120137
+ /* ColNames: */ 38, 3,
119734120138
/* iArg: */ 0 },
119735120139
#endif
119736120140
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119737120141
{/* zName: */ "writable_schema",
119738120142
/* ePragTyp: */ PragTyp_FLAG,
119739120143
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
119740120144
/* ColNames: */ 0, 0,
119741
- /* iArg: */ SQLITE_WriteSchema },
120145
+ /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
119742120146
#endif
119743120147
};
119744
-/* Number of pragmas: 61 on by default, 78 total. */
120148
+/* Number of pragmas: 62 on by default, 81 total. */
119745120149
119746120150
/************** End of pragma.h **********************************************/
119747120151
/************** Continuing where we left off in pragma.c *********************/
119748120152
119749120153
/*
@@ -120751,11 +121155,11 @@
120751121155
case PragTyp_FLAG: {
120752121156
if( zRight==0 ){
120753121157
setPragmaResultColumnNames(v, pPragma);
120754121158
returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );
120755121159
}else{
120756
- int mask = pPragma->iArg; /* Mask of bits to set or clear. */
121160
+ u64 mask = pPragma->iArg; /* Mask of bits to set or clear. */
120757121161
if( db->autoCommit==0 ){
120758121162
/* Foreign key support may not be enabled or disabled while not
120759121163
** in auto-commit mode. */
120760121164
mask &= ~(SQLITE_ForeignKeys);
120761121165
}
@@ -120804,15 +121208,16 @@
120804121208
if( pTab ){
120805121209
int i, k;
120806121210
int nHidden = 0;
120807121211
Column *pCol;
120808121212
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
120809
- pParse->nMem = 6;
121213
+ pParse->nMem = 7;
120810121214
sqlite3CodeVerifySchema(pParse, iDb);
120811121215
sqlite3ViewGetColumnNames(pParse, pTab);
120812121216
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
120813
- if( IsHiddenColumn(pCol) ){
121217
+ int isHidden = IsHiddenColumn(pCol);
121218
+ if( isHidden && pPragma->iArg==0 ){
120814121219
nHidden++;
120815121220
continue;
120816121221
}
120817121222
if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
120818121223
k = 0;
@@ -120820,17 +121225,18 @@
120820121225
k = 1;
120821121226
}else{
120822121227
for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
120823121228
}
120824121229
assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
120825
- sqlite3VdbeMultiLoad(v, 1, "issisi",
121230
+ sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
120826121231
i-nHidden,
120827121232
pCol->zName,
120828121233
sqlite3ColumnType(pCol,""),
120829121234
pCol->notNull ? 1 : 0,
120830121235
pCol->pDflt ? pCol->pDflt->u.zToken : 0,
120831
- k);
121236
+ k,
121237
+ isHidden);
120832121238
}
120833121239
}
120834121240
}
120835121241
break;
120836121242
@@ -121830,16 +122236,28 @@
121830122236
break;
121831122237
}
121832122238
#endif
121833122239
121834122240
#ifdef SQLITE_HAS_CODEC
122241
+ /* Pragma iArg
122242
+ ** ---------- ------
122243
+ ** key 0
122244
+ ** rekey 1
122245
+ ** hexkey 2
122246
+ ** hexrekey 3
122247
+ ** textkey 4
122248
+ ** textrekey 5
122249
+ */
121835122250
case PragTyp_KEY: {
121836
- if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
121837
- break;
121838
- }
121839
- case PragTyp_REKEY: {
121840
- if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
122251
+ if( zRight ){
122252
+ int n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1;
122253
+ if( (pPragma->iArg & 1)==0 ){
122254
+ sqlite3_key_v2(db, zDb, zRight, n);
122255
+ }else{
122256
+ sqlite3_rekey_v2(db, zDb, zRight, n);
122257
+ }
122258
+ }
121841122259
break;
121842122260
}
121843122261
case PragTyp_HEXKEY: {
121844122262
if( zRight ){
121845122263
u8 iByte;
@@ -121847,11 +122265,11 @@
121847122265
char zKey[40];
121848122266
for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
121849122267
iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
121850122268
if( (i&1)!=0 ) zKey[i/2] = iByte;
121851122269
}
121852
- if( (zLeft[3] & 0xf)==0xb ){
122270
+ if( (pPragma->iArg & 1)==0 ){
121853122271
sqlite3_key_v2(db, zDb, zKey, i/2);
121854122272
}else{
121855122273
sqlite3_rekey_v2(db, zDb, zKey, i/2);
121856122274
}
121857122275
}
@@ -122177,11 +122595,12 @@
122177122595
0, /* xRollback - rollback transaction */
122178122596
0, /* xFindFunction - function overloading */
122179122597
0, /* xRename - rename the table */
122180122598
0, /* xSavepoint */
122181122599
0, /* xRelease */
122182
- 0 /* xRollbackTo */
122600
+ 0, /* xRollbackTo */
122601
+ 0 /* xShadowName */
122183122602
};
122184122603
122185122604
/*
122186122605
** Check to see if zTabName is really the name of a pragma. If it is,
122187122606
** then register an eponymous virtual table for that pragma and return
@@ -122530,12 +122949,12 @@
122530122949
}
122531122950
if( db->mallocFailed ){
122532122951
rc = SQLITE_NOMEM_BKPT;
122533122952
sqlite3ResetAllSchemasOfConnection(db);
122534122953
}
122535
- if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
122536
- /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
122954
+ if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
122955
+ /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider
122537122956
** the schema loaded, even if errors occurred. In this situation the
122538122957
** current sqlite3_prepare() operation will fail, but the following one
122539122958
** will attempt to compile the supplied statement against whatever subset
122540122959
** of the schema was loaded before the error occurred. The primary
122541122960
** purpose of this is to allow access to the sqlite_master table
@@ -122912,10 +123331,298 @@
122912123331
assert( (rc&db->errMask)==rc );
122913123332
sqlite3_mutex_leave(db->mutex);
122914123333
return rc;
122915123334
}
122916123335
123336
+#ifdef SQLITE_ENABLE_NORMALIZE
123337
+/*
123338
+** Checks if the specified token is a table, column, or function name,
123339
+** based on the databases associated with the statement being prepared.
123340
+** If the function fails, zero is returned and pRc is filled with the
123341
+** error code.
123342
+*/
123343
+static int shouldTreatAsIdentifier(
123344
+ sqlite3 *db, /* Database handle. */
123345
+ const char *zToken, /* Pointer to start of token to be checked */
123346
+ int nToken, /* Length of token to be checked */
123347
+ int *pRc /* Pointer to error code upon failure */
123348
+){
123349
+ int bFound = 0; /* Non-zero if token is an identifier name. */
123350
+ int i, j; /* Database and column loop indexes. */
123351
+ Schema *pSchema; /* Schema for current database. */
123352
+ Hash *pHash; /* Hash table of tables for current database. */
123353
+ HashElem *e; /* Hash element for hash table iteration. */
123354
+ Table *pTab; /* Database table for columns being checked. */
123355
+
123356
+ if( sqlite3IsRowidN(zToken, nToken) ){
123357
+ return 1;
123358
+ }
123359
+ if( nToken>0 ){
123360
+ int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
123361
+ if( sqlite3FunctionSearchN(hash, zToken, nToken) ) return 1;
123362
+ }
123363
+ assert( db!=0 );
123364
+ sqlite3_mutex_enter(db->mutex);
123365
+ sqlite3BtreeEnterAll(db);
123366
+ for(i=0; i<db->nDb; i++){
123367
+ pHash = &db->aFunc;
123368
+ if( sqlite3HashFindN(pHash, zToken, nToken) ){
123369
+ bFound = 1;
123370
+ break;
123371
+ }
123372
+ pSchema = db->aDb[i].pSchema;
123373
+ if( pSchema==0 ) continue;
123374
+ pHash = &pSchema->tblHash;
123375
+ if( sqlite3HashFindN(pHash, zToken, nToken) ){
123376
+ bFound = 1;
123377
+ break;
123378
+ }
123379
+ for(e=sqliteHashFirst(pHash); e; e=sqliteHashNext(e)){
123380
+ pTab = sqliteHashData(e);
123381
+ if( pTab==0 ) continue;
123382
+ pHash = pTab->pColHash;
123383
+ if( pHash==0 ){
123384
+ pTab->pColHash = pHash = sqlite3_malloc(sizeof(Hash));
123385
+ if( pHash ){
123386
+ sqlite3HashInit(pHash);
123387
+ for(j=0; j<pTab->nCol; j++){
123388
+ Column *pCol = &pTab->aCol[j];
123389
+ sqlite3HashInsert(pHash, pCol->zName, pCol);
123390
+ }
123391
+ }else{
123392
+ *pRc = SQLITE_NOMEM_BKPT;
123393
+ bFound = 0;
123394
+ goto done;
123395
+ }
123396
+ }
123397
+ if( pHash && sqlite3HashFindN(pHash, zToken, nToken) ){
123398
+ bFound = 1;
123399
+ goto done;
123400
+ }
123401
+ }
123402
+ }
123403
+done:
123404
+ sqlite3BtreeLeaveAll(db);
123405
+ sqlite3_mutex_leave(db->mutex);
123406
+ return bFound;
123407
+}
123408
+
123409
+/*
123410
+** Attempt to estimate the final output buffer size needed for the fully
123411
+** normalized version of the specified SQL string. This should take into
123412
+** account any potential expansion that could occur (e.g. via IN clauses
123413
+** being expanded, etc). This size returned is the total number of bytes
123414
+** including the NUL terminator.
123415
+*/
123416
+static int estimateNormalizedSize(
123417
+ const char *zSql, /* The original SQL string */
123418
+ int nSql, /* Length of original SQL string */
123419
+ u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
123420
+){
123421
+ int nOut = nSql + 4;
123422
+ const char *z = zSql;
123423
+ while( nOut<nSql*5 ){
123424
+ while( z[0]!=0 && z[0]!='I' && z[0]!='i' ){ z++; }
123425
+ if( z[0]==0 ) break;
123426
+ z++;
123427
+ if( z[0]!='N' && z[0]!='n' ) break;
123428
+ z++;
123429
+ while( sqlite3Isspace(z[0]) ){ z++; }
123430
+ if( z[0]!='(' ) break;
123431
+ z++;
123432
+ nOut += 5; /* ?,?,? */
123433
+ }
123434
+ return nOut;
123435
+}
123436
+
123437
+/*
123438
+** Copy the current token into the output buffer while dealing with quoted
123439
+** identifiers. By default, all letters will be converted into lowercase.
123440
+** If the bUpper flag is set, uppercase will be used. The piOut argument
123441
+** will be used to update the target index into the output string.
123442
+*/
123443
+static void copyNormalizedToken(
123444
+ const char *zSql, /* The original SQL string */
123445
+ int iIn, /* Current index into the original SQL string */
123446
+ int nToken, /* Number of bytes in the current token */
123447
+ int tokenFlags, /* Flags returned by the tokenizer */
123448
+ char *zOut, /* The output string */
123449
+ int *piOut /* Pointer to target index into the output string */
123450
+){
123451
+ int bQuoted = tokenFlags & SQLITE_TOKEN_QUOTED;
123452
+ int bKeyword = tokenFlags & SQLITE_TOKEN_KEYWORD;
123453
+ int j = *piOut, k = 0;
123454
+ for(; k<nToken; k++){
123455
+ if( bQuoted ){
123456
+ if( k==0 && iIn>0 ){
123457
+ zOut[j++] = '"';
123458
+ continue;
123459
+ }else if( k==nToken-1 ){
123460
+ zOut[j++] = '"';
123461
+ continue;
123462
+ }
123463
+ }
123464
+ if( bKeyword ){
123465
+ zOut[j++] = sqlite3Toupper(zSql[iIn+k]);
123466
+ }else{
123467
+ zOut[j++] = sqlite3Tolower(zSql[iIn+k]);
123468
+ }
123469
+ }
123470
+ *piOut = j;
123471
+}
123472
+
123473
+/*
123474
+** Perform normalization of the SQL contained in the prepared statement and
123475
+** store the result in the zNormSql field. The schema for the associated
123476
+** databases are consulted while performing the normalization in order to
123477
+** determine if a token appears to be an identifier. All identifiers are
123478
+** left intact in the normalized SQL and all literals are replaced with a
123479
+** single '?'.
123480
+*/
123481
+SQLITE_PRIVATE void sqlite3Normalize(
123482
+ Vdbe *pVdbe, /* VM being reprepared */
123483
+ const char *zSql, /* The original SQL string */
123484
+ int nSql, /* Size of the input string in bytes */
123485
+ u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
123486
+){
123487
+ sqlite3 *db; /* Database handle. */
123488
+ char *z; /* The output string */
123489
+ int nZ; /* Size of the output string in bytes */
123490
+ int i; /* Next character to read from zSql[] */
123491
+ int j; /* Next character to fill in on z[] */
123492
+ int tokenType = 0; /* Type of the next token */
123493
+ int prevTokenType = 0; /* Type of the previous token, except spaces */
123494
+ int n; /* Size of the next token */
123495
+ int nParen = 0; /* Nesting level of parenthesis */
123496
+ Hash inHash; /* Table of parenthesis levels to output index. */
123497
+
123498
+ db = sqlite3VdbeDb(pVdbe);
123499
+ assert( db!=0 );
123500
+ assert( pVdbe->zNormSql==0 );
123501
+ if( zSql==0 ) return;
123502
+ nZ = estimateNormalizedSize(zSql, nSql, prepFlags);
123503
+ z = sqlite3DbMallocRawNN(db, nZ);
123504
+ if( z==0 ) return;
123505
+ sqlite3HashInit(&inHash);
123506
+ for(i=j=0; i<nSql && zSql[i]; i+=n){
123507
+ int flags = 0;
123508
+ if( tokenType!=TK_SPACE ) prevTokenType = tokenType;
123509
+ n = sqlite3GetTokenNormalized((unsigned char*)zSql+i, &tokenType, &flags);
123510
+ switch( tokenType ){
123511
+ case TK_SPACE: {
123512
+ break;
123513
+ }
123514
+ case TK_ILLEGAL: {
123515
+ sqlite3DbFree(db, z);
123516
+ sqlite3HashClear(&inHash);
123517
+ return;
123518
+ }
123519
+ case TK_STRING:
123520
+ case TK_INTEGER:
123521
+ case TK_FLOAT:
123522
+ case TK_VARIABLE:
123523
+ case TK_BLOB: {
123524
+ z[j++] = '?';
123525
+ break;
123526
+ }
123527
+ case TK_LP:
123528
+ case TK_RP: {
123529
+ if( tokenType==TK_LP ){
123530
+ nParen++;
123531
+ if( prevTokenType==TK_IN ){
123532
+ assert( nParen<nSql );
123533
+ sqlite3HashInsert(&inHash, zSql+nParen, SQLITE_INT_TO_PTR(j));
123534
+ }
123535
+ }else{
123536
+ int jj;
123537
+ assert( nParen<nSql );
123538
+ jj = SQLITE_PTR_TO_INT(sqlite3HashFind(&inHash, zSql+nParen));
123539
+ if( jj>0 ){
123540
+ sqlite3HashInsert(&inHash, zSql+nParen, 0);
123541
+ assert( jj+6<nZ );
123542
+ memcpy(z+jj+1, "?,?,?", 5);
123543
+ j = jj+6;
123544
+ assert( nZ-1-j>=0 );
123545
+ assert( nZ-1-j<nZ );
123546
+ memset(z+j, 0, nZ-1-j);
123547
+ }
123548
+ nParen--;
123549
+ }
123550
+ assert( nParen>=0 );
123551
+ /* Fall through */
123552
+ }
123553
+ case TK_MINUS:
123554
+ case TK_SEMI:
123555
+ case TK_PLUS:
123556
+ case TK_STAR:
123557
+ case TK_SLASH:
123558
+ case TK_REM:
123559
+ case TK_EQ:
123560
+ case TK_LE:
123561
+ case TK_NE:
123562
+ case TK_LSHIFT:
123563
+ case TK_LT:
123564
+ case TK_RSHIFT:
123565
+ case TK_GT:
123566
+ case TK_GE:
123567
+ case TK_BITOR:
123568
+ case TK_CONCAT:
123569
+ case TK_COMMA:
123570
+ case TK_BITAND:
123571
+ case TK_BITNOT:
123572
+ case TK_DOT:
123573
+ case TK_IN:
123574
+ case TK_IS:
123575
+ case TK_NOT:
123576
+ case TK_NULL:
123577
+ case TK_ID: {
123578
+ if( tokenType==TK_NULL ){
123579
+ if( prevTokenType==TK_IS || prevTokenType==TK_NOT ){
123580
+ /* NULL is a keyword in this case, not a literal value */
123581
+ }else{
123582
+ /* Here the NULL is a literal value */
123583
+ z[j++] = '?';
123584
+ break;
123585
+ }
123586
+ }
123587
+ if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){
123588
+ z[j++] = ' ';
123589
+ }
123590
+ if( tokenType==TK_ID ){
123591
+ int i2 = i, n2 = n, rc = SQLITE_OK;
123592
+ if( nParen>0 ){
123593
+ assert( nParen<nSql );
123594
+ sqlite3HashInsert(&inHash, zSql+nParen, 0);
123595
+ }
123596
+ if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; }
123597
+ if( shouldTreatAsIdentifier(db, zSql+i2, n2, &rc)==0 ){
123598
+ if( rc!=SQLITE_OK ){
123599
+ sqlite3DbFree(db, z);
123600
+ sqlite3HashClear(&inHash);
123601
+ return;
123602
+ }
123603
+ if( sqlite3_keyword_check(zSql+i2, n2)==0 ){
123604
+ z[j++] = '?';
123605
+ break;
123606
+ }
123607
+ }
123608
+ }
123609
+ copyNormalizedToken(zSql, i, n, flags, z, &j);
123610
+ break;
123611
+ }
123612
+ }
123613
+ }
123614
+ assert( j<nZ && "one" );
123615
+ while( j>0 && z[j-1]==' ' ){ j--; }
123616
+ if( j>0 && z[j-1]!=';' ){ z[j++] = ';'; }
123617
+ z[j] = 0;
123618
+ assert( j<nZ && "two" );
123619
+ pVdbe->zNormSql = z;
123620
+ sqlite3HashClear(&inHash);
123621
+}
123622
+#endif /* SQLITE_ENABLE_NORMALIZE */
123623
+
122917123624
/*
122918123625
** Rerun the compilation of a statement after a schema change.
122919123626
**
122920123627
** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,
122921123628
** if the statement cannot be recompiled because another connection has
@@ -123924,11 +124631,11 @@
123924124631
ExprList *pExtra = 0;
123925124632
for(i=0; i<pEList->nExpr; i++){
123926124633
struct ExprList_item *pItem = &pEList->a[i];
123927124634
if( pItem->u.x.iOrderByCol==0 ){
123928124635
Expr *pExpr = pItem->pExpr;
123929
- Table *pTab = pExpr->pTab;
124636
+ Table *pTab = pExpr->y.pTab;
123930124637
if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab)
123931124638
&& (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
123932124639
){
123933124640
int j;
123934124641
for(j=0; j<nDefer; j++){
@@ -123947,16 +124654,16 @@
123947124654
}
123948124655
for(k=0; k<nKey; k++){
123949124656
Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
123950124657
if( pNew ){
123951124658
pNew->iTable = pExpr->iTable;
123952
- pNew->pTab = pExpr->pTab;
124659
+ pNew->y.pTab = pExpr->y.pTab;
123953124660
pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
123954124661
pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
123955124662
}
123956124663
}
123957
- pSort->aDefer[nDefer].pTab = pExpr->pTab;
124664
+ pSort->aDefer[nDefer].pTab = pExpr->y.pTab;
123958124665
pSort->aDefer[nDefer].iCsr = pExpr->iTable;
123959124666
pSort->aDefer[nDefer].nKey = nKey;
123960124667
nDefer++;
123961124668
}
123962124669
}
@@ -124801,11 +125508,11 @@
124801125508
** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
124802125509
** branch below. */
124803125510
break;
124804125511
}
124805125512
124806
- assert( pTab && pExpr->pTab==pTab );
125513
+ assert( pTab && pExpr->y.pTab==pTab );
124807125514
if( pS ){
124808125515
/* The "table" is actually a sub-select or a view in the FROM clause
124809125516
** of the SELECT statement. Return the declaration type and origin
124810125517
** data for the result-set column of the sub-select.
124811125518
*/
@@ -124986,19 +125693,19 @@
124986125693
for(i=0; i<pEList->nExpr; i++){
124987125694
Expr *p = pEList->a[i].pExpr;
124988125695
124989125696
assert( p!=0 );
124990125697
assert( p->op!=TK_AGG_COLUMN ); /* Agg processing has not run yet */
124991
- assert( p->op!=TK_COLUMN || p->pTab!=0 ); /* Covering idx not yet coded */
125698
+ assert( p->op!=TK_COLUMN || p->y.pTab!=0 ); /* Covering idx not yet coded */
124992125699
if( pEList->a[i].zName ){
124993125700
/* An AS clause always takes first priority */
124994125701
char *zName = pEList->a[i].zName;
124995125702
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);
124996125703
}else if( srcName && p->op==TK_COLUMN ){
124997125704
char *zCol;
124998125705
int iCol = p->iColumn;
124999
- pTab = p->pTab;
125706
+ pTab = p->y.pTab;
125000125707
assert( pTab!=0 );
125001125708
if( iCol<0 ) iCol = pTab->iPKey;
125002125709
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
125003125710
if( iCol<0 ){
125004125711
zCol = "rowid";
@@ -125085,11 +125792,11 @@
125085125792
}
125086125793
assert( pColExpr->op!=TK_AGG_COLUMN );
125087125794
if( pColExpr->op==TK_COLUMN ){
125088125795
/* For columns use the column name name */
125089125796
int iCol = pColExpr->iColumn;
125090
- Table *pTab = pColExpr->pTab;
125797
+ Table *pTab = pColExpr->y.pTab;
125091125798
assert( pTab!=0 );
125092125799
if( iCol<0 ) iCol = pTab->iPKey;
125093125800
zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
125094125801
}else if( pColExpr->op==TK_ID ){
125095125802
assert( !ExprHasProperty(pColExpr, EP_IntValue) );
@@ -125438,10 +126145,17 @@
125438126145
int i; /* Loop counter */
125439126146
int rc; /* Result code */
125440126147
ExprList *pOrderBy; /* The ORDER BY clause */
125441126148
Expr *pLimit; /* Saved LIMIT and OFFSET */
125442126149
int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */
126150
+
126151
+#ifndef SQLITE_OMIT_WINDOWFUNC
126152
+ if( p->pWin ){
126153
+ sqlite3ErrorMsg(pParse, "cannot use window functions in recursive queries");
126154
+ return;
126155
+ }
126156
+#endif
125443126157
125444126158
/* Obtain authorization to do a recursive query */
125445126159
if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
125446126160
125447126161
/* Process the LIMIT and OFFSET clauses, if they exist */
@@ -127188,11 +127902,11 @@
127188127902
return 1;
127189127903
}
127190127904
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
127191127905
127192127906
/*
127193
-** A structure to keep track of all of the column values that fixed to
127907
+** A structure to keep track of all of the column values that are fixed to
127194127908
** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
127195127909
*/
127196127910
typedef struct WhereConst WhereConst;
127197127911
struct WhereConst {
127198127912
Parse *pParse; /* Parsing context */
@@ -127200,17 +127914,32 @@
127200127914
int nChng; /* Number of times a constant is propagated */
127201127915
Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
127202127916
};
127203127917
127204127918
/*
127205
-** Add a new entry to the pConst object
127919
+** Add a new entry to the pConst object. Except, do not add duplicate
127920
+** pColumn entires.
127206127921
*/
127207127922
static void constInsert(
127208
- WhereConst *pConst,
127209
- Expr *pColumn,
127210
- Expr *pValue
127923
+ WhereConst *pConst, /* The WhereConst into which we are inserting */
127924
+ Expr *pColumn, /* The COLUMN part of the constraint */
127925
+ Expr *pValue /* The VALUE part of the constraint */
127211127926
){
127927
+ int i;
127928
+ assert( pColumn->op==TK_COLUMN );
127929
+
127930
+ /* 2018-10-25 ticket [cf5ed20f]
127931
+ ** Make sure the same pColumn is not inserted more than once */
127932
+ for(i=0; i<pConst->nConst; i++){
127933
+ const Expr *pExpr = pConst->apExpr[i*2];
127934
+ assert( pExpr->op==TK_COLUMN );
127935
+ if( pExpr->iTable==pColumn->iTable
127936
+ && pExpr->iColumn==pColumn->iColumn
127937
+ ){
127938
+ return; /* Already present. Return without doing anything. */
127939
+ }
127940
+ }
127212127941
127213127942
pConst->nConst++;
127214127943
pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
127215127944
pConst->nConst*2*sizeof(Expr*));
127216127945
if( pConst->apExpr==0 ){
@@ -131187,10 +131916,61 @@
131187131916
if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
131188131917
sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
131189131918
}
131190131919
#endif
131191131920
}
131921
+
131922
+/*
131923
+** Check to see if column iCol of index pIdx references any of the
131924
+** columns defined by aXRef and chngRowid. Return true if it does
131925
+** and false if not. This is an optimization. False-positives are a
131926
+** performance degradation, but false-negatives can result in a corrupt
131927
+** index and incorrect answers.
131928
+**
131929
+** aXRef[j] will be non-negative if column j of the original table is
131930
+** being updated. chngRowid will be true if the rowid of the table is
131931
+** being updated.
131932
+*/
131933
+static int indexColumnIsBeingUpdated(
131934
+ Index *pIdx, /* The index to check */
131935
+ int iCol, /* Which column of the index to check */
131936
+ int *aXRef, /* aXRef[j]>=0 if column j is being updated */
131937
+ int chngRowid /* true if the rowid is being updated */
131938
+){
131939
+ i16 iIdxCol = pIdx->aiColumn[iCol];
131940
+ assert( iIdxCol!=XN_ROWID ); /* Cannot index rowid */
131941
+ if( iIdxCol>=0 ){
131942
+ return aXRef[iIdxCol]>=0;
131943
+ }
131944
+ assert( iIdxCol==XN_EXPR );
131945
+ assert( pIdx->aColExpr!=0 );
131946
+ assert( pIdx->aColExpr->a[iCol].pExpr!=0 );
131947
+ return sqlite3ExprReferencesUpdatedColumn(pIdx->aColExpr->a[iCol].pExpr,
131948
+ aXRef,chngRowid);
131949
+}
131950
+
131951
+/*
131952
+** Check to see if index pIdx is a partial index whose conditional
131953
+** expression might change values due to an UPDATE. Return true if
131954
+** the index is subject to change and false if the index is guaranteed
131955
+** to be unchanged. This is an optimization. False-positives are a
131956
+** performance degradation, but false-negatives can result in a corrupt
131957
+** index and incorrect answers.
131958
+**
131959
+** aXRef[j] will be non-negative if column j of the original table is
131960
+** being updated. chngRowid will be true if the rowid of the table is
131961
+** being updated.
131962
+*/
131963
+static int indexWhereClauseMightChange(
131964
+ Index *pIdx, /* The index to check */
131965
+ int *aXRef, /* aXRef[j]>=0 if column j is being updated */
131966
+ int chngRowid /* true if the rowid is being updated */
131967
+){
131968
+ if( pIdx->pPartIdxWhere==0 ) return 0;
131969
+ return sqlite3ExprReferencesUpdatedColumn(pIdx->pPartIdxWhere,
131970
+ aXRef, chngRowid);
131971
+}
131192131972
131193131973
/*
131194131974
** Process an UPDATE statement.
131195131975
**
131196131976
** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
@@ -131411,23 +132191,22 @@
131411132191
hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);
131412132192
131413132193
/* There is one entry in the aRegIdx[] array for each index on the table
131414132194
** being updated. Fill in aRegIdx[] with a register number that will hold
131415132195
** the key for accessing each index.
131416
- **
131417
- ** FIXME: Be smarter about omitting indexes that use expressions.
131418132196
*/
131419132197
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
131420132198
int reg;
131421
- if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){
132199
+ if( chngKey || hasFK>1 || pIdx==pPk
132200
+ || indexWhereClauseMightChange(pIdx,aXRef,chngRowid)
132201
+ ){
131422132202
reg = ++pParse->nMem;
131423132203
pParse->nMem += pIdx->nColumn;
131424132204
}else{
131425132205
reg = 0;
131426132206
for(i=0; i<pIdx->nKeyCol; i++){
131427
- i16 iIdxCol = pIdx->aiColumn[i];
131428
- if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){
132207
+ if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
131429132208
reg = ++pParse->nMem;
131430132209
pParse->nMem += pIdx->nColumn;
131431132210
if( (onError==OE_Replace)
131432132211
|| (onError==OE_Default && pIdx->onError==OE_Replace)
131433132212
){
@@ -131972,11 +132751,11 @@
131972132751
for(i=0; i<pTab->nCol; i++){
131973132752
if( aXRef[i]>=0 ){
131974132753
sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
131975132754
}else{
131976132755
sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
131977
- sqlite3VdbeChangeP5(v, 1); /* Enable sqlite3_vtab_nochange() */
132756
+ sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
131978132757
}
131979132758
}
131980132759
if( HasRowid(pTab) ){
131981132760
sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);
131982132761
if( pRowid ){
@@ -132473,11 +133252,12 @@
132473133252
saved_nChange = db->nChange;
132474133253
saved_nTotalChange = db->nTotalChange;
132475133254
saved_mTrace = db->mTrace;
132476133255
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
132477133256
db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;
132478
- db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_CountRows);
133257
+ db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder
133258
+ | SQLITE_Defensive | SQLITE_CountRows);
132479133259
db->mTrace = 0;
132480133260
132481133261
zDbMain = db->aDb[iDb].zDbSName;
132482133262
pMain = db->aDb[iDb].pBt;
132483133263
isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
@@ -133015,22 +133795,19 @@
133015133795
Token *pName1, /* Name of new table, or database name */
133016133796
Token *pName2, /* Name of new table or NULL */
133017133797
Token *pModuleName, /* Name of the module for the virtual table */
133018133798
int ifNotExists /* No error if the table already exists */
133019133799
){
133020
- int iDb; /* The database the table is being created in */
133021133800
Table *pTable; /* The new virtual table */
133022133801
sqlite3 *db; /* Database connection */
133023133802
133024133803
sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);
133025133804
pTable = pParse->pNewTable;
133026133805
if( pTable==0 ) return;
133027133806
assert( 0==pTable->pIndex );
133028133807
133029133808
db = pParse->db;
133030
- iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
133031
- assert( iDb>=0 );
133032133809
133033133810
assert( pTable->nModuleArg==0 );
133034133811
addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
133035133812
addModuleArgument(db, pTable, 0);
133036133813
addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
@@ -133046,10 +133823,12 @@
133046133823
** The first invocation, to obtain permission to INSERT a row into the
133047133824
** sqlite_master table, has already been made by sqlite3StartTable().
133048133825
** The second call, to obtain permission to create the table, is made now.
133049133826
*/
133050133827
if( pTable->azModuleArg ){
133828
+ int iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
133829
+ assert( iDb>=0 ); /* The database the table is being created in */
133051133830
sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
133052133831
pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);
133053133832
}
133054133833
#endif
133055133834
}
@@ -133740,11 +134519,11 @@
133740134519
int rc = 0;
133741134520
133742134521
/* Check to see the left operand is a column in a virtual table */
133743134522
if( NEVER(pExpr==0) ) return pDef;
133744134523
if( pExpr->op!=TK_COLUMN ) return pDef;
133745
- pTab = pExpr->pTab;
134524
+ pTab = pExpr->y.pTab;
133746134525
if( pTab==0 ) return pDef;
133747134526
if( !IsVirtual(pTab) ) return pDef;
133748134527
pVtab = sqlite3GetVTable(db, pTab)->pVtab;
133749134528
assert( pVtab!=0 );
133750134529
assert( pVtab->pModule!=0 );
@@ -134360,15 +135139,36 @@
134360135139
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
134361135140
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
134362135141
int nRecValid; /* Number of valid fields currently in pRec */
134363135142
#endif
134364135143
unsigned int bldFlags; /* SQLITE_BLDF_* flags */
135144
+ unsigned int iPlanLimit; /* Search limiter */
134365135145
};
134366135146
134367135147
/* Allowed values for WhereLoopBuider.bldFlags */
134368135148
#define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
134369135149
#define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
135150
+
135151
+/* The WhereLoopBuilder.iPlanLimit is used to limit the number of
135152
+** index+constraint combinations the query planner will consider for a
135153
+** particular query. If this parameter is unlimited, then certain
135154
+** pathological queries can spend excess time in the sqlite3WhereBegin()
135155
+** routine. The limit is high enough that is should not impact real-world
135156
+** queries.
135157
+**
135158
+** SQLITE_QUERY_PLANNER_LIMIT is the baseline limit. The limit is
135159
+** increased by SQLITE_QUERY_PLANNER_LIMIT_INCR before each term of the FROM
135160
+** clause is processed, so that every table in a join is guaranteed to be
135161
+** able to propose a some index+constraint combinations even if the initial
135162
+** baseline limit was exhausted by prior tables of the join.
135163
+*/
135164
+#ifndef SQLITE_QUERY_PLANNER_LIMIT
135165
+# define SQLITE_QUERY_PLANNER_LIMIT 20000
135166
+#endif
135167
+#ifndef SQLITE_QUERY_PLANNER_LIMIT_INCR
135168
+# define SQLITE_QUERY_PLANNER_LIMIT_INCR 1000
135169
+#endif
134370135170
134371135171
/*
134372135172
** The WHERE clause processing routine has two halves. The
134373135173
** first part does the start of the WHERE loop and the second
134374135174
** half does the tail of the WHERE loop. An instance of
@@ -134927,11 +135727,11 @@
134927135727
Select *pSelect; /* Pointer to the SELECT on the RHS */
134928135728
134929135729
for(i=iEq; i<pLoop->nLTerm; i++){
134930135730
if( pLoop->aLTerm[i]->pExpr==pX ){
134931135731
int iField = pLoop->aLTerm[i]->iField - 1;
134932
- assert( pOrigRhs->a[iField].pExpr!=0 );
135732
+ if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
134933135733
pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
134934135734
pOrigRhs->a[iField].pExpr = 0;
134935135735
assert( pOrigLhs->a[iField].pExpr!=0 );
134936135736
pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
134937135737
pOrigLhs->a[iField].pExpr = 0;
@@ -135619,11 +136419,11 @@
135619136419
IdxExprTrans *pX = p->u.pIdxTrans;
135620136420
if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
135621136421
pExpr->op = TK_COLUMN;
135622136422
pExpr->iTable = pX->iIdxCur;
135623136423
pExpr->iColumn = pX->iIdxCol;
135624
- pExpr->pTab = 0;
136424
+ pExpr->y.pTab = 0;
135625136425
return WRC_Prune;
135626136426
}else{
135627136427
return WRC_Continue;
135628136428
}
135629136429
}
@@ -137019,11 +137819,11 @@
137019137819
|| zNew[0]=='-'
137020137820
|| (zNew[0]+1=='0' && iTo==1)
137021137821
){
137022137822
if( pLeft->op!=TK_COLUMN
137023137823
|| sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
137024
- || IsVirtual(pLeft->pTab) /* Value might be numeric */
137824
+ || IsVirtual(pLeft->y.pTab) /* Value might be numeric */
137025137825
){
137026137826
sqlite3ExprDelete(db, pPrefix);
137027137827
sqlite3ValueFree(pVal);
137028137828
return 0;
137029137829
}
@@ -137120,11 +137920,11 @@
137120137920
**
137121137921
** vtab_column MATCH expression
137122137922
** MATCH(expression,vtab_column)
137123137923
*/
137124137924
pCol = pList->a[1].pExpr;
137125
- if( pCol->op==TK_COLUMN && IsVirtual(pCol->pTab) ){
137925
+ if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
137126137926
for(i=0; i<ArraySize(aOp); i++){
137127137927
if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
137128137928
*peOp2 = aOp[i].eOp2;
137129137929
*ppRight = pList->a[0].pExpr;
137130137930
*ppLeft = pCol;
@@ -137142,16 +137942,16 @@
137142137942
** Historically, xFindFunction expected to see lower-case function
137143137943
** names. But for this use case, xFindFunction is expected to deal
137144137944
** with function names in an arbitrary case.
137145137945
*/
137146137946
pCol = pList->a[0].pExpr;
137147
- if( pCol->op==TK_COLUMN && IsVirtual(pCol->pTab) ){
137947
+ if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
137148137948
sqlite3_vtab *pVtab;
137149137949
sqlite3_module *pMod;
137150137950
void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);
137151137951
void *pNotUsed;
137152
- pVtab = sqlite3GetVTable(db, pCol->pTab)->pVtab;
137952
+ pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab;
137153137953
assert( pVtab!=0 );
137154137954
assert( pVtab->pModule!=0 );
137155137955
pMod = (sqlite3_module *)pVtab->pModule;
137156137956
if( pMod->xFindFunction!=0 ){
137157137957
i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
@@ -137165,14 +137965,14 @@
137165137965
}
137166137966
}else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){
137167137967
int res = 0;
137168137968
Expr *pLeft = pExpr->pLeft;
137169137969
Expr *pRight = pExpr->pRight;
137170
- if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->pTab) ){
137970
+ if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->y.pTab) ){
137171137971
res++;
137172137972
}
137173
- if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->pTab) ){
137973
+ if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->y.pTab) ){
137174137974
res++;
137175137975
SWAP(Expr*, pLeft, pRight);
137176137976
}
137177137977
*ppLeft = pLeft;
137178137978
*ppRight = pRight;
@@ -138120,10 +138920,11 @@
138120138920
** Note that the virtual term must be tagged with TERM_VNULL.
138121138921
*/
138122138922
if( pExpr->op==TK_NOTNULL
138123138923
&& pExpr->pLeft->op==TK_COLUMN
138124138924
&& pExpr->pLeft->iColumn>=0
138925
+ && !ExprHasProperty(pExpr, EP_FromJoin)
138125138926
&& OptimizationEnabled(db, SQLITE_Stat34)
138126138927
){
138127138928
Expr *pNewExpr;
138128138929
Expr *pLeft = pExpr->pLeft;
138129138930
int idxNew;
@@ -138311,10 +139112,11 @@
138311139112
pTab = pItem->pTab;
138312139113
assert( pTab!=0 );
138313139114
pArgs = pItem->u1.pFuncArg;
138314139115
if( pArgs==0 ) return;
138315139116
for(j=k=0; j<pArgs->nExpr; j++){
139117
+ Expr *pRhs;
138316139118
while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}
138317139119
if( k>=pTab->nCol ){
138318139120
sqlite3ErrorMsg(pParse, "too many arguments on %s() - max %d",
138319139121
pTab->zName, j);
138320139122
return;
@@ -138321,13 +139123,14 @@
138321139123
}
138322139124
pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);
138323139125
if( pColRef==0 ) return;
138324139126
pColRef->iTable = pItem->iCursor;
138325139127
pColRef->iColumn = k++;
138326
- pColRef->pTab = pTab;
138327
- pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef,
138328
- sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0));
139128
+ pColRef->y.pTab = pTab;
139129
+ pRhs = sqlite3PExpr(pParse, TK_UPLUS,
139130
+ sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
139131
+ pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
138329139132
whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
138330139133
}
138331139134
}
138332139135
138333139136
/************** End of whereexpr.c *******************************************/
@@ -139186,11 +139989,10 @@
139186139989
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
139187139990
testcase( pParse->db->mallocFailed );
139188139991
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
139189139992
pTabItem->regResult, 1);
139190139993
sqlite3VdbeGoto(v, addrTop);
139191
- pTabItem->fg.viaCoroutine = 0;
139192139994
}else{
139193139995
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
139194139996
}
139195139997
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
139196139998
sqlite3VdbeJumpHere(v, addrTop);
@@ -140457,10 +141259,18 @@
140457141259
static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
140458141260
WhereLoop **ppPrev, *p;
140459141261
WhereInfo *pWInfo = pBuilder->pWInfo;
140460141262
sqlite3 *db = pWInfo->pParse->db;
140461141263
int rc;
141264
+
141265
+ /* Stop the search once we hit the query planner search limit */
141266
+ if( pBuilder->iPlanLimit==0 ){
141267
+ WHERETRACE(0xffffffff,("=== query planner search limit reached ===\n"));
141268
+ if( pBuilder->pOrSet ) pBuilder->pOrSet->n = 0;
141269
+ return SQLITE_DONE;
141270
+ }
141271
+ pBuilder->iPlanLimit--;
140462141272
140463141273
/* If pBuilder->pOrSet is defined, then only keep track of the costs
140464141274
** and prereqs.
140465141275
*/
140466141276
if( pBuilder->pOrSet!=0 ){
@@ -141864,13 +142674,15 @@
141864142674
u8 priorJointype = 0;
141865142675
141866142676
/* Loop over the tables in the join, from left to right */
141867142677
pNew = pBuilder->pNew;
141868142678
whereLoopInit(pNew);
142679
+ pBuilder->iPlanLimit = SQLITE_QUERY_PLANNER_LIMIT;
141869142680
for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
141870142681
Bitmask mUnusable = 0;
141871142682
pNew->iTab = iTab;
142683
+ pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
141872142684
pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
141873142685
if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){
141874142686
/* This condition is true when pItem is the FROM clause term on the
141875142687
** right-hand-side of a LEFT or CROSS JOIN. */
141876142688
mPrereq = mPrior;
@@ -141892,11 +142704,19 @@
141892142704
}
141893142705
if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
141894142706
rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
141895142707
}
141896142708
mPrior |= pNew->maskSelf;
141897
- if( rc || db->mallocFailed ) break;
142709
+ if( rc || db->mallocFailed ){
142710
+ if( rc==SQLITE_DONE ){
142711
+ /* We hit the query planner search limit set by iPlanLimit */
142712
+ sqlite3_log(SQLITE_WARNING, "abbreviated query algorithm search");
142713
+ rc = SQLITE_OK;
142714
+ }else{
142715
+ break;
142716
+ }
142717
+ }
141898142718
}
141899142719
141900142720
whereLoopClear(db, pNew);
141901142721
return rc;
141902142722
}
@@ -144274,16 +145094,16 @@
144274145094
}
144275145095
144276145096
switch( pExpr->op ){
144277145097
144278145098
case TK_FUNCTION:
144279
- if( pExpr->pWin==0 ){
145099
+ if( !ExprHasProperty(pExpr, EP_WinFunc) ){
144280145100
break;
144281145101
}else{
144282145102
Window *pWin;
144283145103
for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
144284
- if( pExpr->pWin==pWin ){
145104
+ if( pExpr->y.pWin==pWin ){
144285145105
assert( pWin->pOwner==pExpr );
144286145106
return WRC_Prune;
144287145107
}
144288145108
}
144289145109
}
@@ -144396,11 +145216,11 @@
144396145216
** are invoked in the correct order as described under "SELECT REWRITING"
144397145217
** at the top of this file.
144398145218
*/
144399145219
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
144400145220
int rc = SQLITE_OK;
144401
- if( p->pWin ){
145221
+ if( p->pWin && p->pPrior==0 ){
144402145222
Vdbe *v = sqlite3GetVdbe(pParse);
144403145223
sqlite3 *db = pParse->db;
144404145224
Select *pSub = 0; /* The subquery */
144405145225
SrcList *pSrc = p->pSrc;
144406145226
Expr *pWhere = p->pWhere;
@@ -144609,15 +145429,17 @@
144609145429
/*
144610145430
** Attach window object pWin to expression p.
144611145431
*/
144612145432
SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
144613145433
if( p ){
145434
+ assert( p->op==TK_FUNCTION );
144614145435
/* This routine is only called for the parser. If pWin was not
144615145436
** allocated due to an OOM, then the parser would fail before ever
144616145437
** invoking this routine */
144617145438
if( ALWAYS(pWin) ){
144618
- p->pWin = pWin;
145439
+ p->y.pWin = pWin;
145440
+ ExprSetProperty(p, EP_WinFunc);
144619145441
pWin->pOwner = p;
144620145442
if( p->flags & EP_Distinct ){
144621145443
sqlite3ErrorMsg(pParse,
144622145444
"DISTINCT is not supported for window functions");
144623145445
}
@@ -145776,11 +146598,11 @@
145776146598
** third argument. Set the Window.pOwner field of the new object to
145777146599
** pOwner.
145778146600
*/
145779146601
SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
145780146602
Window *pNew = 0;
145781
- if( p ){
146603
+ if( ALWAYS(p) ){
145782146604
pNew = sqlite3DbMallocZero(db, sizeof(Window));
145783146605
if( pNew ){
145784146606
pNew->zName = sqlite3DbStrDup(db, p->zName);
145785146607
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
145786146608
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
@@ -146029,17 +146851,14 @@
146029146851
p->flags = EP_Leaf;
146030146852
p->iAgg = -1;
146031146853
p->pLeft = p->pRight = 0;
146032146854
p->x.pList = 0;
146033146855
p->pAggInfo = 0;
146034
- p->pTab = 0;
146856
+ p->y.pTab = 0;
146035146857
p->op2 = 0;
146036146858
p->iTable = 0;
146037146859
p->iColumn = 0;
146038
-#ifndef SQLITE_OMIT_WINDOWFUNC
146039
- p->pWin = 0;
146040
-#endif
146041146860
p->u.zToken = (char*)&p[1];
146042146861
memcpy(p->u.zToken, t.z, t.n);
146043146862
p->u.zToken[t.n] = 0;
146044146863
if( sqlite3Isquote(p->u.zToken[0]) ){
146045146864
if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -146186,21 +147005,21 @@
146186147005
#define sqlite3ParserCTX_PDECL ,Parse *pParse
146187147006
#define sqlite3ParserCTX_PARAM ,pParse
146188147007
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
146189147008
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
146190147009
#define YYFALLBACK 1
146191
-#define YYNSTATE 521
147010
+#define YYNSTATE 525
146192147011
#define YYNRULE 367
146193147012
#define YYNTOKEN 155
146194
-#define YY_MAX_SHIFT 520
146195
-#define YY_MIN_SHIFTREDUCE 756
146196
-#define YY_MAX_SHIFTREDUCE 1122
146197
-#define YY_ERROR_ACTION 1123
146198
-#define YY_ACCEPT_ACTION 1124
146199
-#define YY_NO_ACTION 1125
146200
-#define YY_MIN_REDUCE 1126
146201
-#define YY_MAX_REDUCE 1492
147013
+#define YY_MAX_SHIFT 524
147014
+#define YY_MIN_SHIFTREDUCE 760
147015
+#define YY_MAX_SHIFTREDUCE 1126
147016
+#define YY_ERROR_ACTION 1127
147017
+#define YY_ACCEPT_ACTION 1128
147018
+#define YY_NO_ACTION 1129
147019
+#define YY_MIN_REDUCE 1130
147020
+#define YY_MAX_REDUCE 1496
146202147021
/************* End control #defines *******************************************/
146203147022
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
146204147023
146205147024
/* Define the yytestcase() macro to be a no-op if is not already defined
146206147025
** otherwise.
@@ -146265,211 +147084,211 @@
146265147084
** yy_default[] Default action for each state.
146266147085
**
146267147086
*********** Begin parsing tables **********************************************/
146268147087
#define YY_ACTTAB_COUNT (2009)
146269147088
static const YYACTIONTYPE yy_action[] = {
146270
- /* 0 */ 368, 105, 102, 197, 105, 102, 197, 515, 1124, 1,
146271
- /* 10 */ 1, 520, 2, 1128, 515, 1192, 1171, 1456, 275, 370,
146272
- /* 20 */ 127, 1389, 1197, 1197, 1192, 1166, 178, 1205, 64, 64,
146273
- /* 30 */ 477, 887, 322, 428, 348, 37, 37, 808, 362, 888,
146274
- /* 40 */ 509, 509, 509, 112, 113, 103, 1100, 1100, 953, 956,
146275
- /* 50 */ 946, 946, 110, 110, 111, 111, 111, 111, 365, 252,
146276
- /* 60 */ 252, 515, 252, 252, 497, 515, 309, 515, 459, 515,
146277
- /* 70 */ 1079, 491, 512, 478, 6, 512, 809, 134, 498, 228,
146278
- /* 80 */ 194, 428, 37, 37, 515, 208, 64, 64, 64, 64,
147089
+ /* 0 */ 372, 105, 102, 197, 105, 102, 197, 519, 1128, 1,
147090
+ /* 10 */ 1, 524, 2, 1132, 519, 1196, 1175, 1460, 275, 374,
147091
+ /* 20 */ 127, 1393, 1201, 1201, 1196, 1170, 178, 1209, 64, 64,
147092
+ /* 30 */ 481, 891, 326, 432, 352, 37, 37, 812, 366, 892,
147093
+ /* 40 */ 513, 513, 513, 112, 113, 103, 1104, 1104, 957, 960,
147094
+ /* 50 */ 950, 950, 110, 110, 111, 111, 111, 111, 369, 252,
147095
+ /* 60 */ 252, 519, 252, 252, 501, 519, 313, 519, 463, 519,
147096
+ /* 70 */ 1083, 495, 516, 482, 6, 516, 813, 134, 502, 228,
147097
+ /* 80 */ 194, 432, 37, 37, 519, 208, 64, 64, 64, 64,
146279147098
/* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
146280
- /* 100 */ 107, 106, 401, 258, 381, 13, 13, 398, 397, 428,
146281
- /* 110 */ 252, 252, 370, 476, 405, 1104, 1079, 1080, 1081, 386,
146282
- /* 120 */ 1106, 390, 497, 512, 497, 1423, 1419, 304, 1105, 307,
146283
- /* 130 */ 1256, 496, 370, 499, 16, 16, 112, 113, 103, 1100,
146284
- /* 140 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146285
- /* 150 */ 111, 262, 1107, 495, 1107, 401, 112, 113, 103, 1100,
146286
- /* 160 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146287
- /* 170 */ 111, 129, 1425, 343, 1420, 339, 1059, 492, 1057, 263,
146288
- /* 180 */ 73, 105, 102, 197, 994, 109, 109, 109, 109, 108,
146289
- /* 190 */ 108, 107, 107, 107, 106, 401, 370, 111, 111, 111,
146290
- /* 200 */ 111, 104, 492, 89, 1432, 109, 109, 109, 109, 108,
146291
- /* 210 */ 108, 107, 107, 107, 106, 401, 111, 111, 111, 111,
146292
- /* 220 */ 112, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
147099
+ /* 100 */ 107, 106, 405, 258, 385, 13, 13, 402, 401, 432,
147100
+ /* 110 */ 252, 252, 374, 480, 409, 1108, 1083, 1084, 1085, 390,
147101
+ /* 120 */ 1110, 394, 501, 516, 501, 1427, 1423, 308, 1109, 311,
147102
+ /* 130 */ 1260, 500, 374, 503, 16, 16, 112, 113, 103, 1104,
147103
+ /* 140 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147104
+ /* 150 */ 111, 262, 1111, 499, 1111, 405, 112, 113, 103, 1104,
147105
+ /* 160 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147106
+ /* 170 */ 111, 129, 1429, 347, 1424, 343, 1063, 496, 1061, 263,
147107
+ /* 180 */ 73, 105, 102, 197, 998, 109, 109, 109, 109, 108,
147108
+ /* 190 */ 108, 107, 107, 107, 106, 405, 374, 111, 111, 111,
147109
+ /* 200 */ 111, 104, 496, 89, 1436, 109, 109, 109, 109, 108,
147110
+ /* 210 */ 108, 107, 107, 107, 106, 405, 111, 111, 111, 111,
147111
+ /* 220 */ 112, 113, 103, 1104, 1104, 957, 960, 950, 950, 110,
146293147112
/* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
146294
- /* 240 */ 108, 107, 107, 107, 106, 401, 114, 108, 108, 107,
146295
- /* 250 */ 107, 107, 106, 401, 109, 109, 109, 109, 108, 108,
146296
- /* 260 */ 107, 107, 107, 106, 401, 152, 399, 399, 399, 109,
146297
- /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146298
- /* 280 */ 178, 493, 1412, 434, 1037, 1486, 1079, 515, 1486, 370,
146299
- /* 290 */ 421, 297, 357, 412, 74, 1079, 109, 109, 109, 109,
146300
- /* 300 */ 108, 108, 107, 107, 107, 106, 401, 1413, 37, 37,
146301
- /* 310 */ 1431, 274, 506, 112, 113, 103, 1100, 1100, 953, 956,
146302
- /* 320 */ 946, 946, 110, 110, 111, 111, 111, 111, 1436, 520,
146303
- /* 330 */ 2, 1128, 1079, 1080, 1081, 430, 275, 1079, 127, 366,
146304
- /* 340 */ 933, 1079, 1080, 1081, 220, 1205, 913, 458, 455, 454,
146305
- /* 350 */ 392, 167, 515, 1035, 152, 445, 924, 453, 152, 874,
146306
- /* 360 */ 923, 289, 109, 109, 109, 109, 108, 108, 107, 107,
146307
- /* 370 */ 107, 106, 401, 13, 13, 261, 853, 252, 252, 227,
146308
- /* 380 */ 106, 401, 370, 1079, 1080, 1081, 311, 388, 1079, 296,
146309
- /* 390 */ 512, 923, 923, 925, 231, 323, 1255, 1388, 1423, 490,
146310
- /* 400 */ 274, 506, 12, 208, 274, 506, 112, 113, 103, 1100,
146311
- /* 410 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146312
- /* 420 */ 111, 1440, 286, 1128, 288, 1079, 1097, 247, 275, 1098,
146313
- /* 430 */ 127, 387, 405, 389, 1079, 1080, 1081, 1205, 159, 238,
146314
- /* 440 */ 255, 321, 461, 316, 460, 225, 790, 105, 102, 197,
146315
- /* 450 */ 513, 314, 842, 842, 445, 109, 109, 109, 109, 108,
146316
- /* 460 */ 108, 107, 107, 107, 106, 401, 515, 514, 515, 252,
146317
- /* 470 */ 252, 1079, 1080, 1081, 435, 370, 1098, 933, 1460, 794,
146318
- /* 480 */ 274, 506, 512, 105, 102, 197, 336, 63, 63, 64,
146319
- /* 490 */ 64, 27, 790, 924, 287, 208, 1354, 923, 515, 112,
146320
- /* 500 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146321
- /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 401, 49,
146322
- /* 520 */ 49, 515, 28, 1079, 405, 497, 421, 297, 923, 923,
146323
- /* 530 */ 925, 186, 468, 1079, 467, 999, 999, 442, 515, 1079,
146324
- /* 540 */ 334, 515, 45, 45, 1083, 342, 173, 168, 109, 109,
146325
- /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 13,
146326
- /* 560 */ 13, 205, 13, 13, 252, 252, 1195, 1195, 370, 1079,
146327
- /* 570 */ 1080, 1081, 787, 265, 5, 359, 494, 512, 469, 1079,
146328
- /* 580 */ 1080, 1081, 398, 397, 1079, 1079, 1080, 1081, 3, 282,
146329
- /* 590 */ 1079, 1083, 112, 113, 103, 1100, 1100, 953, 956, 946,
146330
- /* 600 */ 946, 110, 110, 111, 111, 111, 111, 252, 252, 1015,
146331
- /* 610 */ 220, 1079, 873, 458, 455, 454, 943, 943, 954, 957,
146332
- /* 620 */ 512, 252, 252, 453, 1016, 1079, 445, 1107, 1209, 1107,
146333
- /* 630 */ 1079, 1080, 1081, 515, 512, 426, 1079, 1080, 1081, 1017,
146334
- /* 640 */ 512, 109, 109, 109, 109, 108, 108, 107, 107, 107,
146335
- /* 650 */ 106, 401, 1052, 515, 50, 50, 515, 1079, 1080, 1081,
146336
- /* 660 */ 828, 370, 1051, 379, 411, 1064, 1358, 207, 408, 773,
146337
- /* 670 */ 829, 1079, 1080, 1081, 64, 64, 322, 64, 64, 1302,
146338
- /* 680 */ 947, 411, 410, 1358, 1360, 112, 113, 103, 1100, 1100,
146339
- /* 690 */ 953, 956, 946, 946, 110, 110, 111, 111, 111, 111,
146340
- /* 700 */ 294, 482, 515, 1037, 1487, 515, 434, 1487, 354, 1120,
146341
- /* 710 */ 483, 996, 913, 485, 466, 996, 132, 178, 33, 450,
146342
- /* 720 */ 1203, 136, 406, 64, 64, 479, 64, 64, 419, 369,
146343
- /* 730 */ 283, 1146, 252, 252, 109, 109, 109, 109, 108, 108,
146344
- /* 740 */ 107, 107, 107, 106, 401, 512, 224, 440, 411, 266,
146345
- /* 750 */ 1358, 266, 252, 252, 370, 296, 416, 284, 934, 396,
146346
- /* 760 */ 976, 470, 400, 252, 252, 512, 9, 473, 231, 500,
146347
- /* 770 */ 354, 1036, 1035, 1488, 355, 374, 512, 1121, 112, 113,
146348
- /* 780 */ 103, 1100, 1100, 953, 956, 946, 946, 110, 110, 111,
146349
- /* 790 */ 111, 111, 111, 252, 252, 1015, 515, 1347, 295, 252,
146350
- /* 800 */ 252, 252, 252, 1098, 375, 249, 512, 445, 872, 322,
146351
- /* 810 */ 1016, 480, 512, 195, 512, 434, 273, 15, 15, 515,
146352
- /* 820 */ 314, 515, 95, 515, 93, 1017, 367, 109, 109, 109,
146353
- /* 830 */ 109, 108, 108, 107, 107, 107, 106, 401, 515, 1121,
146354
- /* 840 */ 39, 39, 51, 51, 52, 52, 503, 370, 515, 1204,
146355
- /* 850 */ 1098, 918, 439, 341, 133, 436, 223, 222, 221, 53,
146356
- /* 860 */ 53, 322, 1400, 761, 762, 763, 515, 370, 88, 54,
146357
- /* 870 */ 54, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146358
- /* 880 */ 110, 110, 111, 111, 111, 111, 407, 55, 55, 196,
146359
- /* 890 */ 515, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146360
- /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1149, 376,
146361
- /* 910 */ 515, 40, 40, 515, 872, 515, 993, 515, 993, 116,
147113
+ /* 240 */ 108, 107, 107, 107, 106, 405, 114, 108, 108, 107,
147114
+ /* 250 */ 107, 107, 106, 405, 109, 109, 109, 109, 108, 108,
147115
+ /* 260 */ 107, 107, 107, 106, 405, 152, 403, 403, 403, 109,
147116
+ /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147117
+ /* 280 */ 178, 497, 1416, 438, 1041, 1490, 1083, 519, 1490, 374,
147118
+ /* 290 */ 425, 301, 361, 416, 74, 1083, 109, 109, 109, 109,
147119
+ /* 300 */ 108, 108, 107, 107, 107, 106, 405, 1417, 37, 37,
147120
+ /* 310 */ 1435, 274, 510, 112, 113, 103, 1104, 1104, 957, 960,
147121
+ /* 320 */ 950, 950, 110, 110, 111, 111, 111, 111, 1440, 524,
147122
+ /* 330 */ 2, 1132, 1083, 1084, 1085, 434, 275, 1083, 127, 370,
147123
+ /* 340 */ 937, 1083, 1084, 1085, 220, 1209, 917, 462, 459, 458,
147124
+ /* 350 */ 396, 167, 519, 1039, 152, 449, 928, 457, 152, 878,
147125
+ /* 360 */ 927, 293, 109, 109, 109, 109, 108, 108, 107, 107,
147126
+ /* 370 */ 107, 106, 405, 13, 13, 261, 857, 252, 252, 227,
147127
+ /* 380 */ 106, 405, 374, 1083, 1084, 1085, 315, 392, 1083, 300,
147128
+ /* 390 */ 516, 927, 927, 929, 231, 327, 1259, 1392, 1427, 494,
147129
+ /* 400 */ 274, 510, 12, 208, 274, 510, 112, 113, 103, 1104,
147130
+ /* 410 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147131
+ /* 420 */ 111, 1444, 290, 1132, 292, 1083, 1101, 247, 275, 1102,
147132
+ /* 430 */ 127, 391, 409, 393, 1083, 1084, 1085, 1209, 159, 238,
147133
+ /* 440 */ 255, 325, 465, 320, 464, 225, 794, 105, 102, 197,
147134
+ /* 450 */ 517, 318, 846, 846, 449, 109, 109, 109, 109, 108,
147135
+ /* 460 */ 108, 107, 107, 107, 106, 405, 519, 518, 519, 252,
147136
+ /* 470 */ 252, 1083, 1084, 1085, 439, 374, 1102, 937, 1464, 798,
147137
+ /* 480 */ 274, 510, 516, 105, 102, 197, 340, 63, 63, 64,
147138
+ /* 490 */ 64, 27, 794, 928, 291, 208, 1358, 927, 519, 112,
147139
+ /* 500 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147140
+ /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 405, 49,
147141
+ /* 520 */ 49, 519, 28, 1083, 409, 501, 425, 301, 927, 927,
147142
+ /* 530 */ 929, 186, 472, 1083, 471, 1003, 1003, 446, 519, 1083,
147143
+ /* 540 */ 338, 519, 45, 45, 1087, 346, 173, 168, 109, 109,
147144
+ /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 13,
147145
+ /* 560 */ 13, 205, 13, 13, 252, 252, 1199, 1199, 374, 1083,
147146
+ /* 570 */ 1084, 1085, 791, 265, 5, 363, 498, 516, 473, 1083,
147147
+ /* 580 */ 1084, 1085, 402, 401, 1083, 1083, 1084, 1085, 3, 282,
147148
+ /* 590 */ 1083, 1087, 112, 113, 103, 1104, 1104, 957, 960, 950,
147149
+ /* 600 */ 950, 110, 110, 111, 111, 111, 111, 252, 252, 1019,
147150
+ /* 610 */ 220, 1083, 877, 462, 459, 458, 947, 947, 958, 961,
147151
+ /* 620 */ 516, 252, 252, 457, 1020, 1083, 449, 1111, 1213, 1111,
147152
+ /* 630 */ 1083, 1084, 1085, 519, 516, 430, 1083, 1084, 1085, 1021,
147153
+ /* 640 */ 516, 109, 109, 109, 109, 108, 108, 107, 107, 107,
147154
+ /* 650 */ 106, 405, 1056, 519, 50, 50, 519, 1083, 1084, 1085,
147155
+ /* 660 */ 832, 374, 1055, 383, 415, 1068, 1362, 207, 412, 777,
147156
+ /* 670 */ 833, 1083, 1084, 1085, 64, 64, 326, 64, 64, 1306,
147157
+ /* 680 */ 951, 415, 414, 1362, 1364, 112, 113, 103, 1104, 1104,
147158
+ /* 690 */ 957, 960, 950, 950, 110, 110, 111, 111, 111, 111,
147159
+ /* 700 */ 298, 486, 519, 1041, 1491, 519, 438, 1491, 358, 1124,
147160
+ /* 710 */ 487, 1000, 917, 489, 470, 1000, 132, 178, 33, 454,
147161
+ /* 720 */ 1207, 136, 410, 64, 64, 483, 64, 64, 423, 373,
147162
+ /* 730 */ 283, 1150, 252, 252, 109, 109, 109, 109, 108, 108,
147163
+ /* 740 */ 107, 107, 107, 106, 405, 516, 224, 444, 415, 266,
147164
+ /* 750 */ 1362, 266, 252, 252, 374, 300, 420, 286, 938, 400,
147165
+ /* 760 */ 980, 474, 404, 252, 252, 516, 9, 477, 231, 504,
147166
+ /* 770 */ 358, 1040, 1039, 1492, 359, 378, 516, 1125, 112, 113,
147167
+ /* 780 */ 103, 1104, 1104, 957, 960, 950, 950, 110, 110, 111,
147168
+ /* 790 */ 111, 111, 111, 252, 252, 1019, 519, 1351, 299, 252,
147169
+ /* 800 */ 252, 252, 252, 1102, 379, 249, 516, 449, 876, 326,
147170
+ /* 810 */ 1020, 484, 516, 195, 516, 438, 273, 15, 15, 519,
147171
+ /* 820 */ 318, 519, 95, 519, 93, 1021, 371, 109, 109, 109,
147172
+ /* 830 */ 109, 108, 108, 107, 107, 107, 106, 405, 519, 1125,
147173
+ /* 840 */ 39, 39, 51, 51, 52, 52, 507, 374, 519, 1208,
147174
+ /* 850 */ 1102, 922, 443, 345, 133, 440, 223, 222, 221, 53,
147175
+ /* 860 */ 53, 326, 1404, 765, 766, 767, 519, 374, 88, 54,
147176
+ /* 870 */ 54, 112, 113, 103, 1104, 1104, 957, 960, 950, 950,
147177
+ /* 880 */ 110, 110, 111, 111, 111, 111, 411, 55, 55, 196,
147178
+ /* 890 */ 519, 112, 113, 103, 1104, 1104, 957, 960, 950, 950,
147179
+ /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1153, 380,
147180
+ /* 910 */ 519, 40, 40, 519, 876, 519, 997, 519, 997, 116,
146362147181
/* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146363
- /* 930 */ 401, 41, 41, 515, 43, 43, 44, 44, 56, 56,
147182
+ /* 930 */ 405, 41, 41, 519, 43, 43, 44, 44, 56, 56,
146364147183
/* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146365
- /* 950 */ 401, 515, 379, 515, 57, 57, 515, 799, 515, 379,
146366
- /* 960 */ 515, 445, 200, 515, 323, 515, 1397, 515, 1459, 515,
146367
- /* 970 */ 1287, 817, 58, 58, 14, 14, 515, 59, 59, 118,
146368
- /* 980 */ 118, 60, 60, 515, 46, 46, 61, 61, 62, 62,
146369
- /* 990 */ 47, 47, 515, 190, 189, 91, 515, 140, 140, 515,
146370
- /* 1000 */ 394, 515, 277, 1200, 141, 141, 515, 1115, 515, 992,
146371
- /* 1010 */ 515, 992, 515, 69, 69, 370, 278, 48, 48, 259,
147184
+ /* 950 */ 405, 519, 383, 519, 57, 57, 519, 803, 519, 383,
147185
+ /* 960 */ 519, 449, 200, 519, 327, 519, 1401, 519, 1463, 519,
147186
+ /* 970 */ 1291, 821, 58, 58, 14, 14, 519, 59, 59, 118,
147187
+ /* 980 */ 118, 60, 60, 519, 46, 46, 61, 61, 62, 62,
147188
+ /* 990 */ 47, 47, 519, 190, 189, 91, 519, 140, 140, 519,
147189
+ /* 1000 */ 398, 519, 277, 1204, 141, 141, 519, 1119, 519, 996,
147190
+ /* 1010 */ 519, 996, 519, 69, 69, 374, 278, 48, 48, 259,
146372147191
/* 1020 */ 65, 65, 119, 119, 246, 246, 260, 66, 66, 120,
146373
- /* 1030 */ 120, 121, 121, 117, 117, 370, 515, 512, 383, 112,
146374
- /* 1040 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146375
- /* 1050 */ 111, 111, 111, 111, 515, 872, 515, 139, 139, 112,
146376
- /* 1060 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146377
- /* 1070 */ 111, 111, 111, 111, 1287, 138, 138, 125, 125, 515,
146378
- /* 1080 */ 12, 515, 281, 1287, 515, 445, 131, 1287, 109, 109,
146379
- /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146380
- /* 1100 */ 124, 124, 122, 122, 515, 123, 123, 515, 109, 109,
146381
- /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146382
- /* 1120 */ 68, 68, 463, 783, 515, 70, 70, 302, 67, 67,
146383
- /* 1130 */ 1032, 253, 253, 356, 1287, 191, 196, 1433, 465, 1301,
146384
- /* 1140 */ 38, 38, 384, 94, 512, 42, 42, 177, 848, 274,
146385
- /* 1150 */ 506, 385, 420, 847, 1356, 441, 508, 376, 377, 153,
146386
- /* 1160 */ 423, 872, 432, 370, 224, 251, 194, 887, 182, 293,
146387
- /* 1170 */ 783, 848, 88, 254, 466, 888, 847, 915, 807, 806,
146388
- /* 1180 */ 230, 1241, 910, 370, 17, 413, 797, 112, 113, 103,
146389
- /* 1190 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146390
- /* 1200 */ 111, 111, 395, 814, 815, 1175, 983, 112, 101, 103,
146391
- /* 1210 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146392
- /* 1220 */ 111, 111, 375, 422, 427, 429, 298, 230, 230, 88,
146393
- /* 1230 */ 1240, 451, 312, 797, 226, 88, 109, 109, 109, 109,
146394
- /* 1240 */ 108, 108, 107, 107, 107, 106, 401, 86, 433, 979,
146395
- /* 1250 */ 927, 881, 226, 983, 230, 415, 109, 109, 109, 109,
146396
- /* 1260 */ 108, 108, 107, 107, 107, 106, 401, 320, 845, 781,
146397
- /* 1270 */ 846, 100, 130, 100, 1403, 290, 370, 319, 1377, 1376,
146398
- /* 1280 */ 437, 1449, 299, 1237, 303, 306, 308, 310, 1188, 1174,
146399
- /* 1290 */ 1173, 1172, 315, 324, 325, 1228, 370, 927, 1249, 271,
146400
- /* 1300 */ 1286, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146401
- /* 1310 */ 110, 111, 111, 111, 111, 1224, 1235, 502, 501, 1292,
146402
- /* 1320 */ 1221, 1155, 103, 1100, 1100, 953, 956, 946, 946, 110,
146403
- /* 1330 */ 110, 111, 111, 111, 111, 1148, 1137, 1136, 1138, 1443,
146404
- /* 1340 */ 446, 244, 184, 98, 507, 188, 4, 353, 327, 109,
146405
- /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146406
- /* 1360 */ 510, 329, 331, 199, 414, 456, 292, 285, 318, 109,
146407
- /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146408
- /* 1380 */ 11, 1271, 1279, 402, 361, 192, 1171, 1351, 431, 505,
146409
- /* 1390 */ 346, 1350, 333, 98, 507, 504, 4, 187, 1446, 1115,
146410
- /* 1400 */ 233, 1396, 155, 1394, 1112, 152, 72, 75, 378, 425,
146411
- /* 1410 */ 510, 165, 149, 157, 933, 1276, 86, 30, 1268, 417,
146412
- /* 1420 */ 96, 96, 8, 160, 161, 162, 163, 97, 418, 402,
146413
- /* 1430 */ 517, 516, 449, 402, 923, 210, 358, 424, 1282, 438,
146414
- /* 1440 */ 169, 214, 360, 1345, 80, 504, 31, 444, 1365, 301,
146415
- /* 1450 */ 245, 274, 506, 216, 174, 305, 488, 447, 217, 462,
146416
- /* 1460 */ 1139, 487, 218, 363, 933, 923, 923, 925, 926, 24,
146417
- /* 1470 */ 96, 96, 1191, 1190, 1189, 391, 1182, 97, 1163, 402,
146418
- /* 1480 */ 517, 516, 799, 364, 923, 1162, 317, 1161, 98, 507,
146419
- /* 1490 */ 1181, 4, 1458, 472, 393, 269, 270, 475, 481, 1232,
146420
- /* 1500 */ 85, 1233, 326, 328, 232, 510, 495, 1231, 330, 98,
146421
- /* 1510 */ 507, 1230, 4, 486, 335, 923, 923, 925, 926, 24,
146422
- /* 1520 */ 1435, 1068, 404, 181, 336, 256, 510, 115, 402, 332,
146423
- /* 1530 */ 352, 352, 351, 241, 349, 1214, 1414, 770, 338, 10,
146424
- /* 1540 */ 504, 340, 272, 92, 1331, 1213, 87, 183, 484, 402,
146425
- /* 1550 */ 201, 488, 280, 239, 344, 345, 489, 1145, 29, 933,
146426
- /* 1560 */ 279, 504, 1074, 518, 240, 96, 96, 242, 243, 519,
146427
- /* 1570 */ 1134, 1129, 97, 154, 402, 517, 516, 372, 373, 923,
146428
- /* 1580 */ 933, 142, 143, 128, 1381, 267, 96, 96, 852, 757,
146429
- /* 1590 */ 203, 144, 403, 97, 1382, 402, 517, 516, 204, 1380,
146430
- /* 1600 */ 923, 146, 1379, 1159, 1158, 71, 1156, 276, 202, 185,
146431
- /* 1610 */ 923, 923, 925, 926, 24, 198, 257, 126, 991, 989,
146432
- /* 1620 */ 907, 98, 507, 156, 4, 145, 158, 206, 831, 209,
146433
- /* 1630 */ 291, 923, 923, 925, 926, 24, 1005, 911, 510, 164,
146434
- /* 1640 */ 147, 380, 371, 382, 166, 76, 77, 274, 506, 148,
146435
- /* 1650 */ 78, 79, 1008, 211, 212, 1004, 137, 213, 18, 300,
146436
- /* 1660 */ 230, 402, 997, 1109, 443, 215, 32, 170, 171, 772,
146437
- /* 1670 */ 409, 448, 319, 504, 219, 172, 452, 81, 19, 457,
146438
- /* 1680 */ 313, 20, 82, 268, 488, 150, 810, 179, 83, 487,
146439
- /* 1690 */ 464, 151, 933, 180, 959, 84, 1040, 34, 96, 96,
146440
- /* 1700 */ 471, 1041, 35, 474, 193, 97, 248, 402, 517, 516,
146441
- /* 1710 */ 1068, 404, 923, 250, 256, 880, 229, 175, 875, 352,
146442
- /* 1720 */ 352, 351, 241, 349, 100, 21, 770, 22, 1054, 1056,
146443
- /* 1730 */ 7, 98, 507, 1045, 4, 337, 1058, 23, 974, 201,
146444
- /* 1740 */ 176, 280, 88, 923, 923, 925, 926, 24, 510, 279,
146445
- /* 1750 */ 960, 958, 962, 1014, 963, 1013, 235, 234, 25, 36,
146446
- /* 1760 */ 99, 90, 507, 928, 4, 511, 350, 782, 26, 841,
146447
- /* 1770 */ 236, 402, 347, 1069, 237, 1125, 1125, 1451, 510, 203,
146448
- /* 1780 */ 1450, 1125, 1125, 504, 1125, 1125, 1125, 204, 1125, 1125,
146449
- /* 1790 */ 146, 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125,
146450
- /* 1800 */ 1125, 402, 933, 1125, 1125, 1125, 1125, 1125, 96, 96,
146451
- /* 1810 */ 1125, 1125, 1125, 504, 1125, 97, 1125, 402, 517, 516,
146452
- /* 1820 */ 1125, 1125, 923, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146453
- /* 1830 */ 1125, 371, 933, 1125, 1125, 1125, 274, 506, 96, 96,
146454
- /* 1840 */ 1125, 1125, 1125, 1125, 1125, 97, 1125, 402, 517, 516,
146455
- /* 1850 */ 1125, 1125, 923, 923, 923, 925, 926, 24, 1125, 409,
146456
- /* 1860 */ 1125, 1125, 1125, 256, 1125, 1125, 1125, 1125, 352, 352,
146457
- /* 1870 */ 351, 241, 349, 1125, 1125, 770, 1125, 1125, 1125, 1125,
146458
- /* 1880 */ 1125, 1125, 1125, 923, 923, 925, 926, 24, 201, 1125,
146459
- /* 1890 */ 280, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 279, 1125,
146460
- /* 1900 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146461
- /* 1910 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146462
- /* 1920 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 203, 1125,
146463
- /* 1930 */ 1125, 1125, 1125, 1125, 1125, 1125, 204, 1125, 1125, 146,
146464
- /* 1940 */ 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125, 1125,
146465
- /* 1950 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146466
- /* 1960 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146467
- /* 1970 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146468
- /* 1980 */ 371, 1125, 1125, 1125, 1125, 274, 506, 1125, 1125, 1125,
146469
- /* 1990 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146470
- /* 2000 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 409,
147192
+ /* 1030 */ 120, 121, 121, 117, 117, 374, 519, 516, 387, 112,
147193
+ /* 1040 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147194
+ /* 1050 */ 111, 111, 111, 111, 519, 876, 519, 139, 139, 112,
147195
+ /* 1060 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147196
+ /* 1070 */ 111, 111, 111, 111, 1291, 138, 138, 125, 125, 519,
147197
+ /* 1080 */ 12, 519, 281, 1291, 519, 449, 131, 1291, 109, 109,
147198
+ /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 519,
147199
+ /* 1100 */ 124, 124, 122, 122, 519, 123, 123, 519, 109, 109,
147200
+ /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 519,
147201
+ /* 1120 */ 68, 68, 467, 787, 519, 70, 70, 306, 67, 67,
147202
+ /* 1130 */ 1036, 253, 253, 360, 1291, 191, 196, 1437, 469, 1305,
147203
+ /* 1140 */ 38, 38, 388, 94, 516, 42, 42, 177, 852, 274,
147204
+ /* 1150 */ 510, 389, 424, 851, 1360, 445, 512, 380, 381, 153,
147205
+ /* 1160 */ 427, 876, 436, 374, 224, 251, 194, 891, 182, 297,
147206
+ /* 1170 */ 787, 852, 88, 254, 470, 892, 851, 919, 811, 810,
147207
+ /* 1180 */ 230, 1245, 914, 374, 17, 417, 801, 112, 113, 103,
147208
+ /* 1190 */ 1104, 1104, 957, 960, 950, 950, 110, 110, 111, 111,
147209
+ /* 1200 */ 111, 111, 399, 818, 819, 1179, 987, 112, 101, 103,
147210
+ /* 1210 */ 1104, 1104, 957, 960, 950, 950, 110, 110, 111, 111,
147211
+ /* 1220 */ 111, 111, 379, 426, 431, 433, 302, 230, 230, 88,
147212
+ /* 1230 */ 1244, 455, 316, 801, 226, 88, 109, 109, 109, 109,
147213
+ /* 1240 */ 108, 108, 107, 107, 107, 106, 405, 86, 437, 983,
147214
+ /* 1250 */ 931, 885, 226, 987, 230, 419, 109, 109, 109, 109,
147215
+ /* 1260 */ 108, 108, 107, 107, 107, 106, 405, 324, 849, 785,
147216
+ /* 1270 */ 850, 100, 130, 100, 1407, 294, 374, 323, 1381, 1380,
147217
+ /* 1280 */ 441, 1453, 303, 1241, 307, 310, 312, 314, 1192, 1178,
147218
+ /* 1290 */ 1177, 1176, 319, 328, 329, 1232, 374, 931, 1253, 271,
147219
+ /* 1300 */ 1290, 113, 103, 1104, 1104, 957, 960, 950, 950, 110,
147220
+ /* 1310 */ 110, 111, 111, 111, 111, 1228, 1239, 506, 505, 1296,
147221
+ /* 1320 */ 1225, 1159, 103, 1104, 1104, 957, 960, 950, 950, 110,
147222
+ /* 1330 */ 110, 111, 111, 111, 111, 1152, 1141, 1140, 1142, 1447,
147223
+ /* 1340 */ 450, 244, 184, 98, 511, 188, 4, 357, 331, 109,
147224
+ /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147225
+ /* 1360 */ 514, 333, 335, 199, 418, 460, 296, 289, 322, 109,
147226
+ /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147227
+ /* 1380 */ 11, 285, 1283, 406, 365, 192, 1175, 1355, 435, 509,
147228
+ /* 1390 */ 350, 1354, 337, 98, 511, 508, 4, 187, 1450, 1119,
147229
+ /* 1400 */ 233, 1400, 155, 1398, 1116, 152, 72, 75, 382, 429,
147230
+ /* 1410 */ 514, 165, 115, 499, 937, 1280, 1275, 30, 149, 157,
147231
+ /* 1420 */ 96, 96, 8, 284, 86, 288, 287, 97, 1272, 406,
147232
+ /* 1430 */ 521, 520, 421, 406, 927, 422, 453, 210, 160, 161,
147233
+ /* 1440 */ 162, 163, 362, 428, 1286, 508, 442, 214, 80, 364,
147234
+ /* 1450 */ 31, 274, 510, 169, 1349, 448, 492, 245, 1369, 216,
147235
+ /* 1460 */ 174, 491, 451, 309, 937, 927, 927, 929, 930, 24,
147236
+ /* 1470 */ 96, 96, 305, 217, 367, 466, 1143, 97, 218, 406,
147237
+ /* 1480 */ 521, 520, 1195, 1194, 927, 1193, 395, 803, 98, 511,
147238
+ /* 1490 */ 368, 4, 1186, 1167, 1185, 269, 1166, 321, 1165, 1462,
147239
+ /* 1500 */ 397, 270, 485, 476, 479, 514, 85, 232, 1236, 98,
147240
+ /* 1510 */ 511, 330, 4, 490, 340, 927, 927, 929, 930, 24,
147241
+ /* 1520 */ 1439, 1072, 408, 1237, 339, 256, 514, 1418, 406, 10,
147242
+ /* 1530 */ 356, 356, 355, 241, 353, 181, 92, 774, 1235, 1218,
147243
+ /* 1540 */ 508, 342, 87, 332, 334, 1217, 1234, 336, 344, 406,
147244
+ /* 1550 */ 201, 492, 280, 183, 488, 348, 493, 349, 239, 937,
147245
+ /* 1560 */ 279, 508, 1335, 29, 1149, 96, 96, 522, 1078, 272,
147246
+ /* 1570 */ 243, 240, 97, 242, 406, 521, 520, 523, 1138, 927,
147247
+ /* 1580 */ 937, 142, 1133, 1385, 143, 1386, 96, 96, 856, 376,
147248
+ /* 1590 */ 203, 761, 154, 97, 1384, 406, 521, 520, 204, 377,
147249
+ /* 1600 */ 927, 146, 144, 1383, 407, 1163, 1162, 128, 202, 71,
147250
+ /* 1610 */ 927, 927, 929, 930, 24, 267, 1160, 185, 276, 198,
147251
+ /* 1620 */ 257, 98, 511, 126, 4, 911, 995, 156, 993, 145,
147252
+ /* 1630 */ 206, 927, 927, 929, 930, 24, 158, 835, 514, 209,
147253
+ /* 1640 */ 295, 1009, 375, 164, 915, 147, 384, 274, 510, 386,
147254
+ /* 1650 */ 166, 76, 77, 78, 148, 1012, 211, 212, 1008, 137,
147255
+ /* 1660 */ 18, 406, 79, 213, 304, 1001, 1113, 230, 447, 215,
147256
+ /* 1670 */ 413, 171, 32, 508, 323, 776, 170, 452, 172, 219,
147257
+ /* 1680 */ 456, 81, 19, 20, 492, 317, 461, 82, 268, 491,
147258
+ /* 1690 */ 150, 814, 937, 179, 83, 468, 151, 180, 96, 96,
147259
+ /* 1700 */ 963, 84, 1044, 34, 475, 97, 1045, 406, 521, 520,
147260
+ /* 1710 */ 1072, 408, 927, 35, 256, 884, 478, 248, 193, 356,
147261
+ /* 1720 */ 356, 355, 241, 353, 250, 175, 774, 229, 879, 21,
147262
+ /* 1730 */ 100, 98, 511, 22, 4, 1058, 1049, 176, 341, 201,
147263
+ /* 1740 */ 7, 280, 1062, 927, 927, 929, 930, 24, 514, 279,
147264
+ /* 1750 */ 88, 1060, 23, 978, 964, 962, 966, 1018, 1017, 967,
147265
+ /* 1760 */ 235, 90, 511, 234, 4, 25, 36, 515, 932, 786,
147266
+ /* 1770 */ 845, 406, 99, 26, 236, 237, 351, 1455, 514, 203,
147267
+ /* 1780 */ 354, 1454, 1073, 508, 1129, 1129, 1129, 204, 1129, 1129,
147268
+ /* 1790 */ 146, 1129, 1129, 1129, 1129, 1129, 1129, 202, 1129, 1129,
147269
+ /* 1800 */ 1129, 406, 937, 1129, 1129, 1129, 1129, 1129, 96, 96,
147270
+ /* 1810 */ 1129, 1129, 1129, 508, 1129, 97, 1129, 406, 521, 520,
147271
+ /* 1820 */ 1129, 1129, 927, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147272
+ /* 1830 */ 1129, 375, 937, 1129, 1129, 1129, 274, 510, 96, 96,
147273
+ /* 1840 */ 1129, 1129, 1129, 1129, 1129, 97, 1129, 406, 521, 520,
147274
+ /* 1850 */ 1129, 1129, 927, 927, 927, 929, 930, 24, 1129, 413,
147275
+ /* 1860 */ 1129, 1129, 1129, 256, 1129, 1129, 1129, 1129, 356, 356,
147276
+ /* 1870 */ 355, 241, 353, 1129, 1129, 774, 1129, 1129, 1129, 1129,
147277
+ /* 1880 */ 1129, 1129, 1129, 927, 927, 929, 930, 24, 201, 1129,
147278
+ /* 1890 */ 280, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 279, 1129,
147279
+ /* 1900 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147280
+ /* 1910 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147281
+ /* 1920 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 203, 1129,
147282
+ /* 1930 */ 1129, 1129, 1129, 1129, 1129, 1129, 204, 1129, 1129, 146,
147283
+ /* 1940 */ 1129, 1129, 1129, 1129, 1129, 1129, 202, 1129, 1129, 1129,
147284
+ /* 1950 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147285
+ /* 1960 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147286
+ /* 1970 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147287
+ /* 1980 */ 375, 1129, 1129, 1129, 1129, 274, 510, 1129, 1129, 1129,
147288
+ /* 1990 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147289
+ /* 2000 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 413,
146471147290
};
146472147291
static const YYCODETYPE yy_lookahead[] = {
146473147292
/* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
146474147293
/* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
146475147294
/* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -146609,48 +147428,48 @@
146609147428
/* 1360 */ 36, 222, 222, 260, 226, 188, 256, 226, 187, 92,
146610147429
/* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
146611147430
/* 1380 */ 210, 213, 213, 59, 213, 196, 192, 187, 256, 244,
146612147431
/* 1390 */ 212, 187, 226, 19, 20, 71, 22, 210, 166, 60,
146613147432
/* 1400 */ 130, 170, 260, 170, 38, 81, 257, 257, 170, 104,
146614
- /* 1410 */ 36, 22, 43, 201, 90, 236, 138, 235, 213, 18,
146615
- /* 1420 */ 96, 97, 48, 204, 204, 204, 204, 103, 170, 105,
146616
- /* 1430 */ 106, 107, 18, 59, 110, 169, 213, 213, 201, 170,
146617
- /* 1440 */ 201, 169, 236, 213, 146, 71, 235, 62, 253, 252,
146618
- /* 1450 */ 170, 127, 128, 169, 22, 170, 82, 189, 169, 104,
146619
- /* 1460 */ 170, 87, 169, 189, 90, 141, 142, 143, 144, 145,
146620
- /* 1470 */ 96, 97, 186, 186, 186, 64, 194, 103, 186, 105,
146621
- /* 1480 */ 106, 107, 115, 189, 110, 188, 186, 186, 19, 20,
146622
- /* 1490 */ 194, 22, 186, 189, 102, 246, 246, 189, 133, 228,
146623
- /* 1500 */ 104, 228, 227, 227, 170, 36, 134, 228, 227, 19,
146624
- /* 1510 */ 20, 228, 22, 84, 271, 141, 142, 143, 144, 145,
146625
- /* 1520 */ 0, 1, 2, 216, 22, 5, 36, 137, 59, 227,
146626
- /* 1530 */ 10, 11, 12, 13, 14, 217, 269, 17, 216, 22,
146627
- /* 1540 */ 71, 170, 243, 146, 241, 217, 136, 215, 135, 59,
146628
- /* 1550 */ 30, 82, 32, 25, 214, 213, 87, 173, 26, 90,
146629
- /* 1560 */ 40, 71, 13, 172, 164, 96, 97, 164, 6, 162,
146630
- /* 1570 */ 162, 162, 103, 263, 105, 106, 107, 266, 266, 110,
146631
- /* 1580 */ 90, 176, 176, 190, 182, 190, 96, 97, 98, 4,
146632
- /* 1590 */ 70, 176, 3, 103, 182, 105, 106, 107, 78, 182,
146633
- /* 1600 */ 110, 81, 182, 182, 182, 182, 182, 151, 88, 22,
146634
- /* 1610 */ 141, 142, 143, 144, 145, 15, 89, 16, 23, 23,
146635
- /* 1620 */ 128, 19, 20, 139, 22, 119, 131, 24, 20, 133,
146636
- /* 1630 */ 16, 141, 142, 143, 144, 145, 1, 140, 36, 131,
146637
- /* 1640 */ 119, 61, 122, 37, 139, 53, 53, 127, 128, 119,
146638
- /* 1650 */ 53, 53, 105, 34, 130, 1, 5, 104, 22, 149,
146639
- /* 1660 */ 26, 59, 68, 75, 41, 130, 24, 68, 104, 20,
146640
- /* 1670 */ 150, 19, 120, 71, 114, 22, 67, 22, 22, 67,
146641
- /* 1680 */ 23, 22, 22, 67, 82, 37, 28, 23, 138, 87,
146642
- /* 1690 */ 22, 153, 90, 23, 23, 26, 23, 22, 96, 97,
146643
- /* 1700 */ 24, 23, 22, 24, 130, 103, 23, 105, 106, 107,
146644
- /* 1710 */ 1, 2, 110, 23, 5, 105, 34, 22, 132, 10,
146645
- /* 1720 */ 11, 12, 13, 14, 26, 34, 17, 34, 85, 83,
146646
- /* 1730 */ 44, 19, 20, 23, 22, 24, 75, 34, 23, 30,
146647
- /* 1740 */ 26, 32, 26, 141, 142, 143, 144, 145, 36, 40,
146648
- /* 1750 */ 23, 23, 23, 23, 11, 23, 22, 26, 22, 22,
146649
- /* 1760 */ 22, 19, 20, 23, 22, 26, 15, 23, 22, 124,
146650
- /* 1770 */ 130, 59, 23, 1, 130, 277, 277, 130, 36, 70,
146651
- /* 1780 */ 130, 277, 277, 71, 277, 277, 277, 78, 277, 277,
147433
+ /* 1410 */ 36, 22, 137, 134, 90, 236, 217, 235, 43, 201,
147434
+ /* 1420 */ 96, 97, 48, 216, 138, 213, 216, 103, 217, 105,
147435
+ /* 1430 */ 106, 107, 18, 59, 110, 170, 18, 169, 204, 204,
147436
+ /* 1440 */ 204, 204, 213, 213, 201, 71, 170, 169, 146, 236,
147437
+ /* 1450 */ 235, 127, 128, 201, 213, 62, 82, 170, 253, 169,
147438
+ /* 1460 */ 22, 87, 189, 170, 90, 141, 142, 143, 144, 145,
147439
+ /* 1470 */ 96, 97, 252, 169, 189, 104, 170, 103, 169, 105,
147440
+ /* 1480 */ 106, 107, 186, 186, 110, 186, 64, 115, 19, 20,
147441
+ /* 1490 */ 189, 22, 194, 186, 194, 246, 188, 186, 186, 186,
147442
+ /* 1500 */ 102, 246, 133, 189, 189, 36, 104, 170, 228, 19,
147443
+ /* 1510 */ 20, 227, 22, 84, 22, 141, 142, 143, 144, 145,
147444
+ /* 1520 */ 0, 1, 2, 228, 271, 5, 36, 269, 59, 22,
147445
+ /* 1530 */ 10, 11, 12, 13, 14, 216, 146, 17, 228, 217,
147446
+ /* 1540 */ 71, 216, 136, 227, 227, 217, 228, 227, 170, 59,
147447
+ /* 1550 */ 30, 82, 32, 215, 135, 214, 87, 213, 25, 90,
147448
+ /* 1560 */ 40, 71, 241, 26, 173, 96, 97, 172, 13, 243,
147449
+ /* 1570 */ 6, 164, 103, 164, 105, 106, 107, 162, 162, 110,
147450
+ /* 1580 */ 90, 176, 162, 182, 176, 182, 96, 97, 98, 266,
147451
+ /* 1590 */ 70, 4, 263, 103, 182, 105, 106, 107, 78, 266,
147452
+ /* 1600 */ 110, 81, 176, 182, 3, 182, 182, 190, 88, 182,
147453
+ /* 1610 */ 141, 142, 143, 144, 145, 190, 182, 22, 151, 15,
147454
+ /* 1620 */ 89, 19, 20, 16, 22, 128, 23, 139, 23, 119,
147455
+ /* 1630 */ 24, 141, 142, 143, 144, 145, 131, 20, 36, 133,
147456
+ /* 1640 */ 16, 1, 122, 131, 140, 119, 61, 127, 128, 37,
147457
+ /* 1650 */ 139, 53, 53, 53, 119, 105, 34, 130, 1, 5,
147458
+ /* 1660 */ 22, 59, 53, 104, 149, 68, 75, 26, 41, 130,
147459
+ /* 1670 */ 150, 104, 24, 71, 120, 20, 68, 19, 22, 114,
147460
+ /* 1680 */ 67, 22, 22, 22, 82, 23, 67, 22, 67, 87,
147461
+ /* 1690 */ 37, 28, 90, 23, 138, 22, 153, 23, 96, 97,
147462
+ /* 1700 */ 23, 26, 23, 22, 24, 103, 23, 105, 106, 107,
147463
+ /* 1710 */ 1, 2, 110, 22, 5, 105, 24, 23, 130, 10,
147464
+ /* 1720 */ 11, 12, 13, 14, 23, 22, 17, 34, 132, 34,
147465
+ /* 1730 */ 26, 19, 20, 34, 22, 85, 23, 26, 24, 30,
147466
+ /* 1740 */ 44, 32, 75, 141, 142, 143, 144, 145, 36, 40,
147467
+ /* 1750 */ 26, 83, 34, 23, 23, 23, 23, 23, 23, 11,
147468
+ /* 1760 */ 22, 19, 20, 26, 22, 22, 22, 26, 23, 23,
147469
+ /* 1770 */ 124, 59, 22, 22, 130, 130, 23, 130, 36, 70,
147470
+ /* 1780 */ 15, 130, 1, 71, 277, 277, 277, 78, 277, 277,
146652147471
/* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
146653147472
/* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
146654147473
/* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
146655147474
/* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
146656147475
/* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -146671,11 +147490,11 @@
146671147490
/* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
146672147491
/* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
146673147492
/* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
146674147493
/* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
146675147494
};
146676
-#define YY_SHIFT_COUNT (520)
147495
+#define YY_SHIFT_COUNT (524)
146677147496
#define YY_SHIFT_MIN (0)
146678147497
#define YY_SHIFT_MAX (1858)
146679147498
static const unsigned short int yy_shift_ofst[] = {
146680147499
/* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
146681147500
/* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -146703,39 +147522,39 @@
146703147522
/* 230 */ 531, 531, 744, 531, 531, 783, 531, 531, 531, 531,
146704147523
/* 240 */ 531, 531, 531, 531, 419, 682, 327, 370, 370, 370,
146705147524
/* 250 */ 370, 1029, 327, 327, 1024, 897, 856, 947, 1109, 706,
146706147525
/* 260 */ 706, 1143, 1109, 1109, 1143, 842, 945, 1118, 1136, 1136,
146707147526
/* 270 */ 1136, 706, 676, 400, 1047, 694, 1339, 1270, 1270, 1366,
146708
- /* 280 */ 1366, 1270, 1305, 1389, 1369, 1278, 1401, 1401, 1401, 1401,
146709
- /* 290 */ 1270, 1414, 1278, 1278, 1305, 1389, 1369, 1369, 1278, 1270,
146710
- /* 300 */ 1414, 1298, 1385, 1270, 1414, 1432, 1270, 1414, 1270, 1414,
146711
- /* 310 */ 1432, 1355, 1355, 1355, 1411, 1432, 1355, 1367, 1355, 1411,
146712
- /* 320 */ 1355, 1355, 1432, 1392, 1392, 1432, 1365, 1396, 1365, 1396,
146713
- /* 330 */ 1365, 1396, 1365, 1396, 1270, 1372, 1429, 1502, 1390, 1372,
146714
- /* 340 */ 1517, 1270, 1397, 1390, 1410, 1413, 1278, 1528, 1532, 1549,
146715
- /* 350 */ 1549, 1562, 1562, 1562, 2009, 2009, 2009, 2009, 2009, 2009,
147527
+ /* 280 */ 1366, 1270, 1305, 1389, 1275, 1279, 1375, 1275, 1279, 1286,
147528
+ /* 290 */ 1414, 1414, 1414, 1414, 1270, 1418, 1286, 1286, 1305, 1389,
147529
+ /* 300 */ 1375, 1375, 1286, 1270, 1418, 1302, 1393, 1270, 1418, 1438,
147530
+ /* 310 */ 1270, 1418, 1270, 1418, 1438, 1371, 1371, 1371, 1422, 1438,
147531
+ /* 320 */ 1371, 1372, 1371, 1422, 1371, 1371, 1438, 1398, 1398, 1438,
147532
+ /* 330 */ 1369, 1402, 1369, 1402, 1369, 1402, 1369, 1402, 1270, 1279,
147533
+ /* 340 */ 1429, 1492, 1275, 1279, 1507, 1270, 1390, 1275, 1406, 1419,
147534
+ /* 350 */ 1286, 1533, 1537, 1555, 1555, 1564, 1564, 1564, 2009, 2009,
146716147535
/* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
146717
- /* 370 */ 570, 345, 686, 748, 50, 740, 1064, 1107, 469, 537,
146718
- /* 380 */ 1042, 1146, 1162, 1154, 1201, 1202, 1203, 1208, 1209, 1127,
146719
- /* 390 */ 1069, 1196, 1157, 1147, 1226, 1228, 1245, 775, 868, 1246,
146720
- /* 400 */ 1247, 1191, 1151, 1585, 1589, 1587, 1456, 1600, 1527, 1601,
146721
- /* 410 */ 1595, 1596, 1492, 1484, 1506, 1603, 1495, 1608, 1496, 1614,
146722
- /* 420 */ 1635, 1508, 1497, 1521, 1580, 1606, 1505, 1592, 1593, 1597,
146723
- /* 430 */ 1598, 1530, 1547, 1619, 1524, 1654, 1651, 1636, 1553, 1510,
146724
- /* 440 */ 1594, 1634, 1599, 1588, 1623, 1535, 1564, 1642, 1649, 1652,
146725
- /* 450 */ 1552, 1560, 1653, 1609, 1655, 1656, 1657, 1659, 1612, 1658,
146726
- /* 460 */ 1660, 1616, 1648, 1664, 1550, 1668, 1538, 1670, 1671, 1669,
146727
- /* 470 */ 1673, 1675, 1676, 1678, 1680, 1679, 1574, 1683, 1690, 1610,
146728
- /* 480 */ 1682, 1695, 1586, 1698, 1691, 1698, 1693, 1643, 1661, 1646,
146729
- /* 490 */ 1686, 1710, 1711, 1714, 1716, 1703, 1715, 1698, 1727, 1728,
146730
- /* 500 */ 1729, 1730, 1731, 1732, 1734, 1743, 1736, 1737, 1740, 1744,
146731
- /* 510 */ 1738, 1746, 1739, 1645, 1640, 1644, 1647, 1650, 1749, 1751,
146732
- /* 520 */ 1772,
147536
+ /* 370 */ 2009, 2009, 2009, 2009, 570, 345, 686, 748, 50, 740,
147537
+ /* 380 */ 1064, 1107, 469, 537, 1042, 1146, 1162, 1154, 1201, 1202,
147538
+ /* 390 */ 1203, 1208, 1209, 1127, 1069, 1196, 1157, 1147, 1226, 1228,
147539
+ /* 400 */ 1245, 775, 868, 1246, 1247, 1191, 1151, 1587, 1601, 1595,
147540
+ /* 410 */ 1467, 1604, 1531, 1607, 1603, 1605, 1497, 1488, 1510, 1606,
147541
+ /* 420 */ 1505, 1617, 1506, 1624, 1640, 1512, 1504, 1526, 1585, 1612,
147542
+ /* 430 */ 1511, 1598, 1599, 1600, 1609, 1535, 1550, 1622, 1527, 1657,
147543
+ /* 440 */ 1654, 1638, 1559, 1515, 1597, 1641, 1608, 1591, 1627, 1539,
147544
+ /* 450 */ 1567, 1648, 1655, 1658, 1554, 1565, 1656, 1613, 1659, 1660,
147545
+ /* 460 */ 1662, 1661, 1619, 1663, 1665, 1621, 1653, 1670, 1556, 1673,
147546
+ /* 470 */ 1543, 1674, 1677, 1675, 1679, 1681, 1680, 1683, 1691, 1692,
147547
+ /* 480 */ 1588, 1694, 1701, 1610, 1693, 1703, 1596, 1704, 1695, 1704,
147548
+ /* 490 */ 1699, 1650, 1667, 1668, 1696, 1713, 1714, 1711, 1724, 1718,
147549
+ /* 500 */ 1730, 1704, 1731, 1732, 1733, 1734, 1737, 1735, 1738, 1748,
147550
+ /* 510 */ 1743, 1744, 1745, 1746, 1750, 1751, 1741, 1646, 1644, 1645,
147551
+ /* 520 */ 1647, 1651, 1753, 1765, 1781,
146733147552
};
146734
-#define YY_REDUCE_COUNT (369)
147553
+#define YY_REDUCE_COUNT (373)
146735147554
#define YY_REDUCE_MIN (-237)
146736
-#define YY_REDUCE_MAX (1424)
147555
+#define YY_REDUCE_MAX (1434)
146737147556
static const short yy_reduce_ofst[] = {
146738147557
/* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
146739147558
/* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
146740147559
/* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
146741147560
/* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -146761,74 +147580,75 @@
146761147580
/* 230 */ 1137, 1152, 1077, 1153, 1155, 1114, 1156, 304, 1158, 1172,
146762147581
/* 240 */ 1173, 1174, 1175, 1176, 1089, 1091, 1133, 1098, 1126, 1139,
146763147582
/* 250 */ 1140, 1070, 1133, 1133, 1170, 1163, 1186, 1103, 1168, 1138,
146764147583
/* 260 */ 1141, 1110, 1169, 1171, 1132, 1177, 1189, 1194, 1181, 1200,
146765147584
/* 270 */ 1204, 1166, 1145, 1178, 1187, 1232, 1142, 1231, 1233, 1149,
146766
- /* 280 */ 1150, 1238, 1179, 1182, 1212, 1205, 1219, 1220, 1221, 1222,
146767
- /* 290 */ 1258, 1266, 1223, 1224, 1206, 1211, 1237, 1239, 1230, 1269,
146768
- /* 300 */ 1272, 1195, 1197, 1280, 1284, 1268, 1285, 1289, 1290, 1293,
146769
- /* 310 */ 1274, 1286, 1287, 1288, 1282, 1294, 1292, 1297, 1300, 1296,
146770
- /* 320 */ 1301, 1306, 1304, 1249, 1250, 1308, 1271, 1275, 1273, 1276,
146771
- /* 330 */ 1279, 1281, 1283, 1302, 1334, 1307, 1243, 1267, 1318, 1322,
146772
- /* 340 */ 1303, 1371, 1299, 1328, 1332, 1340, 1342, 1384, 1391, 1400,
146773
- /* 350 */ 1403, 1407, 1408, 1409, 1311, 1312, 1310, 1405, 1402, 1412,
146774
- /* 360 */ 1417, 1420, 1406, 1393, 1395, 1421, 1422, 1423, 1424, 1415,
147585
+ /* 280 */ 1150, 1238, 1179, 1182, 1199, 1207, 1218, 1211, 1210, 1212,
147586
+ /* 290 */ 1234, 1235, 1236, 1237, 1265, 1268, 1229, 1230, 1213, 1215,
147587
+ /* 300 */ 1243, 1252, 1241, 1276, 1278, 1205, 1220, 1287, 1290, 1273,
147588
+ /* 310 */ 1293, 1304, 1306, 1309, 1285, 1296, 1297, 1299, 1298, 1301,
147589
+ /* 320 */ 1307, 1308, 1311, 1300, 1312, 1313, 1314, 1249, 1255, 1315,
147590
+ /* 330 */ 1280, 1284, 1295, 1316, 1310, 1317, 1318, 1320, 1337, 1319,
147591
+ /* 340 */ 1253, 1258, 1322, 1325, 1321, 1378, 1326, 1328, 1338, 1341,
147592
+ /* 350 */ 1344, 1391, 1395, 1407, 1409, 1415, 1416, 1420, 1323, 1333,
147593
+ /* 360 */ 1329, 1405, 1401, 1403, 1412, 1421, 1408, 1417, 1425, 1423,
147594
+ /* 370 */ 1424, 1427, 1434, 1426,
146775147595
};
146776147596
static const YYACTIONTYPE yy_default[] = {
146777
- /* 0 */ 1492, 1492, 1492, 1340, 1123, 1229, 1123, 1123, 1123, 1340,
146778
- /* 10 */ 1340, 1340, 1123, 1259, 1259, 1391, 1154, 1123, 1123, 1123,
146779
- /* 20 */ 1123, 1123, 1123, 1123, 1339, 1123, 1123, 1123, 1123, 1123,
146780
- /* 30 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1265, 1123,
146781
- /* 40 */ 1123, 1123, 1123, 1123, 1341, 1342, 1123, 1123, 1123, 1390,
146782
- /* 50 */ 1392, 1275, 1274, 1273, 1272, 1373, 1246, 1270, 1263, 1267,
146783
- /* 60 */ 1335, 1336, 1334, 1338, 1342, 1341, 1123, 1266, 1306, 1320,
146784
- /* 70 */ 1305, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146785
- /* 80 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146786
- /* 90 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146787
- /* 100 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146788
- /* 110 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1314, 1319, 1325,
146789
- /* 120 */ 1318, 1315, 1308, 1307, 1309, 1310, 1123, 1144, 1193, 1123,
146790
- /* 130 */ 1123, 1123, 1123, 1409, 1408, 1123, 1123, 1154, 1311, 1312,
146791
- /* 140 */ 1322, 1321, 1398, 1448, 1447, 1123, 1123, 1123, 1123, 1123,
146792
- /* 150 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146793
- /* 160 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146794
- /* 170 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1154, 1150, 1300,
146795
- /* 180 */ 1299, 1418, 1150, 1253, 1123, 1404, 1229, 1220, 1123, 1123,
146796
- /* 190 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146797
- /* 200 */ 1123, 1395, 1393, 1123, 1355, 1123, 1123, 1123, 1123, 1123,
146798
- /* 210 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146799
- /* 220 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146800
- /* 230 */ 1123, 1123, 1225, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146801
- /* 240 */ 1123, 1123, 1123, 1442, 1123, 1368, 1207, 1225, 1225, 1225,
146802
- /* 250 */ 1225, 1227, 1208, 1206, 1219, 1154, 1130, 1484, 1269, 1248,
146803
- /* 260 */ 1248, 1481, 1269, 1269, 1481, 1168, 1462, 1165, 1259, 1259,
146804
- /* 270 */ 1259, 1248, 1337, 1226, 1219, 1123, 1484, 1234, 1234, 1483,
146805
- /* 280 */ 1483, 1234, 1278, 1284, 1196, 1269, 1202, 1202, 1202, 1202,
146806
- /* 290 */ 1234, 1141, 1269, 1269, 1278, 1284, 1196, 1196, 1269, 1234,
146807
- /* 300 */ 1141, 1372, 1478, 1234, 1141, 1348, 1234, 1141, 1234, 1141,
146808
- /* 310 */ 1348, 1194, 1194, 1194, 1183, 1348, 1194, 1168, 1194, 1183,
146809
- /* 320 */ 1194, 1194, 1348, 1352, 1352, 1348, 1252, 1247, 1252, 1247,
146810
- /* 330 */ 1252, 1247, 1252, 1247, 1234, 1253, 1417, 1123, 1264, 1253,
146811
- /* 340 */ 1343, 1234, 1123, 1264, 1262, 1260, 1269, 1147, 1186, 1445,
146812
- /* 350 */ 1445, 1441, 1441, 1441, 1489, 1489, 1404, 1457, 1154, 1154,
146813
- /* 360 */ 1154, 1154, 1457, 1170, 1170, 1154, 1154, 1154, 1154, 1457,
146814
- /* 370 */ 1123, 1123, 1123, 1123, 1123, 1123, 1452, 1123, 1357, 1238,
146815
- /* 380 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146816
- /* 390 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146817
- /* 400 */ 1123, 1123, 1289, 1123, 1126, 1401, 1123, 1123, 1399, 1123,
146818
- /* 410 */ 1123, 1123, 1123, 1123, 1123, 1239, 1123, 1123, 1123, 1123,
146819
- /* 420 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146820
- /* 430 */ 1123, 1123, 1123, 1123, 1480, 1123, 1123, 1123, 1123, 1123,
146821
- /* 440 */ 1123, 1371, 1370, 1123, 1123, 1236, 1123, 1123, 1123, 1123,
146822
- /* 450 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146823
- /* 460 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146824
- /* 470 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146825
- /* 480 */ 1123, 1123, 1123, 1261, 1123, 1416, 1123, 1123, 1123, 1123,
146826
- /* 490 */ 1123, 1123, 1123, 1430, 1254, 1123, 1123, 1471, 1123, 1123,
146827
- /* 500 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146828
- /* 510 */ 1123, 1123, 1466, 1210, 1291, 1123, 1290, 1294, 1123, 1135,
146829
- /* 520 */ 1123,
147597
+ /* 0 */ 1496, 1496, 1496, 1344, 1127, 1233, 1127, 1127, 1127, 1344,
147598
+ /* 10 */ 1344, 1344, 1127, 1263, 1263, 1395, 1158, 1127, 1127, 1127,
147599
+ /* 20 */ 1127, 1127, 1127, 1127, 1343, 1127, 1127, 1127, 1127, 1127,
147600
+ /* 30 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1269, 1127,
147601
+ /* 40 */ 1127, 1127, 1127, 1127, 1345, 1346, 1127, 1127, 1127, 1394,
147602
+ /* 50 */ 1396, 1279, 1278, 1277, 1276, 1377, 1250, 1274, 1267, 1271,
147603
+ /* 60 */ 1339, 1340, 1338, 1342, 1346, 1345, 1127, 1270, 1310, 1324,
147604
+ /* 70 */ 1309, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147605
+ /* 80 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147606
+ /* 90 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147607
+ /* 100 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147608
+ /* 110 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1318, 1323, 1329,
147609
+ /* 120 */ 1322, 1319, 1312, 1311, 1313, 1314, 1127, 1148, 1197, 1127,
147610
+ /* 130 */ 1127, 1127, 1127, 1413, 1412, 1127, 1127, 1158, 1315, 1316,
147611
+ /* 140 */ 1326, 1325, 1402, 1452, 1451, 1127, 1127, 1127, 1127, 1127,
147612
+ /* 150 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147613
+ /* 160 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147614
+ /* 170 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1158, 1154, 1304,
147615
+ /* 180 */ 1303, 1422, 1154, 1257, 1127, 1408, 1233, 1224, 1127, 1127,
147616
+ /* 190 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147617
+ /* 200 */ 1127, 1399, 1397, 1127, 1359, 1127, 1127, 1127, 1127, 1127,
147618
+ /* 210 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147619
+ /* 220 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147620
+ /* 230 */ 1127, 1127, 1229, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147621
+ /* 240 */ 1127, 1127, 1127, 1446, 1127, 1372, 1211, 1229, 1229, 1229,
147622
+ /* 250 */ 1229, 1231, 1212, 1210, 1223, 1158, 1134, 1488, 1273, 1252,
147623
+ /* 260 */ 1252, 1485, 1273, 1273, 1485, 1172, 1466, 1169, 1263, 1263,
147624
+ /* 270 */ 1263, 1252, 1341, 1230, 1223, 1127, 1488, 1238, 1238, 1487,
147625
+ /* 280 */ 1487, 1238, 1282, 1288, 1268, 1257, 1200, 1268, 1257, 1273,
147626
+ /* 290 */ 1206, 1206, 1206, 1206, 1238, 1145, 1273, 1273, 1282, 1288,
147627
+ /* 300 */ 1200, 1200, 1273, 1238, 1145, 1376, 1482, 1238, 1145, 1352,
147628
+ /* 310 */ 1238, 1145, 1238, 1145, 1352, 1198, 1198, 1198, 1187, 1352,
147629
+ /* 320 */ 1198, 1172, 1198, 1187, 1198, 1198, 1352, 1356, 1356, 1352,
147630
+ /* 330 */ 1256, 1251, 1256, 1251, 1256, 1251, 1256, 1251, 1238, 1257,
147631
+ /* 340 */ 1421, 1127, 1268, 1257, 1347, 1238, 1127, 1268, 1266, 1264,
147632
+ /* 350 */ 1273, 1151, 1190, 1449, 1449, 1445, 1445, 1445, 1493, 1493,
147633
+ /* 360 */ 1408, 1461, 1158, 1158, 1158, 1158, 1461, 1174, 1174, 1158,
147634
+ /* 370 */ 1158, 1158, 1158, 1461, 1127, 1127, 1127, 1127, 1127, 1127,
147635
+ /* 380 */ 1456, 1127, 1361, 1242, 1127, 1127, 1127, 1127, 1127, 1127,
147636
+ /* 390 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147637
+ /* 400 */ 1127, 1127, 1127, 1127, 1127, 1127, 1293, 1127, 1130, 1405,
147638
+ /* 410 */ 1127, 1127, 1403, 1127, 1127, 1127, 1127, 1127, 1127, 1243,
147639
+ /* 420 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147640
+ /* 430 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1484, 1127,
147641
+ /* 440 */ 1127, 1127, 1127, 1127, 1127, 1375, 1374, 1127, 1127, 1240,
147642
+ /* 450 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147643
+ /* 460 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147644
+ /* 470 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147645
+ /* 480 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1265, 1127, 1420,
147646
+ /* 490 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1434, 1258, 1127,
147647
+ /* 500 */ 1127, 1475, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147648
+ /* 510 */ 1127, 1127, 1127, 1127, 1127, 1127, 1470, 1214, 1295, 1127,
147649
+ /* 520 */ 1294, 1298, 1127, 1139, 1127,
146830147650
};
146831147651
/********** End of lemon-generated parsing tables *****************************/
146832147652
146833147653
/* The next table maps tokens (terminal symbols) into fallback tokens.
146834147654
** If a construct like the following:
@@ -147448,14 +148268,14 @@
147448148268
/* 137 */ "having_opt ::= HAVING expr",
147449148269
/* 138 */ "limit_opt ::=",
147450148270
/* 139 */ "limit_opt ::= LIMIT expr",
147451148271
/* 140 */ "limit_opt ::= LIMIT expr OFFSET expr",
147452148272
/* 141 */ "limit_opt ::= LIMIT expr COMMA expr",
147453
- /* 142 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
148273
+ /* 142 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt",
147454148274
/* 143 */ "where_opt ::=",
147455148275
/* 144 */ "where_opt ::= WHERE expr",
147456
- /* 145 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
148276
+ /* 145 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt",
147457148277
/* 146 */ "setlist ::= setlist COMMA nm EQ expr",
147458148278
/* 147 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
147459148279
/* 148 */ "setlist ::= nm EQ expr",
147460148280
/* 149 */ "setlist ::= LP idlist RP EQ expr",
147461148281
/* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
@@ -148328,14 +149148,14 @@
148328149148
{ 215, -2 }, /* (137) having_opt ::= HAVING expr */
148329149149
{ 217, 0 }, /* (138) limit_opt ::= */
148330149150
{ 217, -2 }, /* (139) limit_opt ::= LIMIT expr */
148331149151
{ 217, -4 }, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
148332149152
{ 217, -4 }, /* (141) limit_opt ::= LIMIT expr COMMA expr */
148333
- { 160, -6 }, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
149153
+ { 160, -8 }, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt */
148334149154
{ 213, 0 }, /* (143) where_opt ::= */
148335149155
{ 213, -2 }, /* (144) where_opt ::= WHERE expr */
148336
- { 160, -8 }, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
149156
+ { 160, -10 }, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt */
148337149157
{ 233, -5 }, /* (146) setlist ::= setlist COMMA nm EQ expr */
148338149158
{ 233, -7 }, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
148339149159
{ 233, -3 }, /* (148) setlist ::= nm EQ expr */
148340149160
{ 233, -5 }, /* (149) setlist ::= LP idlist RP EQ expr */
148341149161
{ 160, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
@@ -149215,21 +150035,21 @@
149215150035
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
149216150036
break;
149217150037
case 141: /* limit_opt ::= LIMIT expr COMMA expr */
149218150038
{yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
149219150039
break;
149220
- case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
149221
-{
149222
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
149223
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
149224
-}
149225
- break;
149226
- case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
150040
+ case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt */
149227150041
{
149228150042
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
149229
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list");
149230
- sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
150043
+ sqlite3DeleteFrom(pParse,yymsp[-4].minor.yy135,yymsp[-2].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);
150044
+}
150045
+ break;
150046
+ case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt */
150047
+{
150048
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-5].minor.yy0);
150049
+ sqlite3ExprListCheckLength(pParse,yymsp[-3].minor.yy420,"set list");
150050
+ sqlite3Update(pParse,yymsp[-6].minor.yy135,yymsp[-3].minor.yy420,yymsp[-2].minor.yy18,yymsp[-7].minor.yy70,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,0);
149231150051
}
149232150052
break;
149233150053
case 146: /* setlist ::= setlist COMMA nm EQ expr */
149234150054
{
149235150055
yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
@@ -151197,10 +152017,77 @@
151197152017
while( IdChar(z[i]) ){ i++; }
151198152018
*tokenType = TK_ID;
151199152019
return i;
151200152020
}
151201152021
152022
+#ifdef SQLITE_ENABLE_NORMALIZE
152023
+/*
152024
+** Return the length (in bytes) of the token that begins at z[0].
152025
+** Store the token type in *tokenType before returning. If flags has
152026
+** SQLITE_TOKEN_NORMALIZE flag enabled, use the identifier token type
152027
+** for keywords. Add SQLITE_TOKEN_QUOTED to flags if the token was
152028
+** actually a quoted identifier. Add SQLITE_TOKEN_KEYWORD to flags
152029
+** if the token was recognized as a keyword; this is useful when the
152030
+** SQLITE_TOKEN_NORMALIZE flag is used, because it enables the caller
152031
+** to differentiate between a keyword being treated as an identifier
152032
+** (for normalization purposes) and an actual identifier.
152033
+*/
152034
+SQLITE_PRIVATE int sqlite3GetTokenNormalized(
152035
+ const unsigned char *z,
152036
+ int *tokenType,
152037
+ int *flags
152038
+){
152039
+ int n;
152040
+ unsigned char iClass = aiClass[*z];
152041
+ if( iClass==CC_KYWD ){
152042
+ int i;
152043
+ for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}
152044
+ if( IdChar(z[i]) ){
152045
+ /* This token started out using characters that can appear in keywords,
152046
+ ** but z[i] is a character not allowed within keywords, so this must
152047
+ ** be an identifier instead */
152048
+ i++;
152049
+ while( IdChar(z[i]) ){ i++; }
152050
+ *tokenType = TK_ID;
152051
+ return i;
152052
+ }
152053
+ *tokenType = TK_ID;
152054
+ n = keywordCode((char*)z, i, tokenType);
152055
+ /* If the token is no longer considered to be an identifier, then it is a
152056
+ ** keyword of some kind. Make the token back into an identifier and then
152057
+ ** set the SQLITE_TOKEN_KEYWORD flag. Several non-identifier tokens are
152058
+ ** used verbatim, including IN, IS, NOT, and NULL. */
152059
+ switch( *tokenType ){
152060
+ case TK_ID: {
152061
+ /* do nothing, handled by caller */
152062
+ break;
152063
+ }
152064
+ case TK_IN:
152065
+ case TK_IS:
152066
+ case TK_NOT:
152067
+ case TK_NULL: {
152068
+ *flags |= SQLITE_TOKEN_KEYWORD;
152069
+ break;
152070
+ }
152071
+ default: {
152072
+ *tokenType = TK_ID;
152073
+ *flags |= SQLITE_TOKEN_KEYWORD;
152074
+ break;
152075
+ }
152076
+ }
152077
+ }else{
152078
+ n = sqlite3GetToken(z, tokenType);
152079
+ /* If the token is considered to be an identifier and the character class
152080
+ ** of the first character is a quote, set the SQLITE_TOKEN_QUOTED flag. */
152081
+ if( *tokenType==TK_ID && (iClass==CC_QUOTE || iClass==CC_QUOTE2) ){
152082
+ *flags |= SQLITE_TOKEN_QUOTED;
152083
+ }
152084
+ }
152085
+ return n;
152086
+}
152087
+#endif /* SQLITE_ENABLE_NORMALIZE */
152088
+
151202152089
/*
151203152090
** Run the parser on the given SQL string. The parser structure is
151204152091
** passed in. An SQLITE_ status code is returned. If an error occurs
151205152092
** then an and attempt is made to write an error message into
151206152093
** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
@@ -152594,10 +153481,11 @@
152594153481
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
152595153482
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
152596153483
{ SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
152597153484
{ SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
152598153485
{ SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
153486
+ { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive },
152599153487
};
152600153488
unsigned int i;
152601153489
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
152602153490
for(i=0; i<ArraySize(aFlagOp); i++){
152603153491
if( aFlagOp[i].op==op ){
@@ -154820,10 +155708,13 @@
154820155708
#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
154821155709
| SQLITE_Fts3Tokenizer
154822155710
#endif
154823155711
#if defined(SQLITE_ENABLE_QPSG)
154824155712
| SQLITE_EnableQPSG
155713
+#endif
155714
+#if defined(SQLITE_DEFAULT_DEFENSIVE)
155715
+ | SQLITE_Defensive
154825155716
#endif
154826155717
;
154827155718
sqlite3HashInit(&db->aCollSeq);
154828155719
#ifndef SQLITE_OMIT_VIRTUALTABLE
154829155720
sqlite3HashInit(&db->aModule);
@@ -159159,11 +160050,11 @@
159159160050
){
159160160051
int rc = SQLITE_OK; /* Return code */
159161160052
const char *zCsr = zNode; /* Cursor to iterate through node */
159162160053
const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
159163160054
char *zBuffer = 0; /* Buffer to load terms into */
159164
- int nAlloc = 0; /* Size of allocated buffer */
160055
+ i64 nAlloc = 0; /* Size of allocated buffer */
159165160056
int isFirstTerm = 1; /* True when processing first term on page */
159166160057
sqlite3_int64 iChild; /* Block id of child node to descend to */
159167160058
159168160059
/* Skip over the 'height' varint that occurs at the start of every
159169160060
** interior node. Then load the blockid of the left-child of the b-tree
@@ -159197,18 +160088,18 @@
159197160088
}
159198160089
isFirstTerm = 0;
159199160090
zCsr += fts3GetVarint32(zCsr, &nSuffix);
159200160091
159201160092
assert( nPrefix>=0 && nSuffix>=0 );
159202
- if( &zCsr[nSuffix]>zEnd ){
160093
+ if( nPrefix>zCsr-zNode || nSuffix>zEnd-zCsr ){
159203160094
rc = FTS_CORRUPT_VTAB;
159204160095
goto finish_scan;
159205160096
}
159206
- if( nPrefix+nSuffix>nAlloc ){
160097
+ if( (i64)nPrefix+nSuffix>nAlloc ){
159207160098
char *zNew;
159208
- nAlloc = (nPrefix+nSuffix) * 2;
159209
- zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);
160099
+ nAlloc = ((i64)nPrefix+nSuffix) * 2;
160100
+ zNew = (char *)sqlite3_realloc64(zBuffer, nAlloc);
159210160101
if( !zNew ){
159211160102
rc = SQLITE_NOMEM;
159212160103
goto finish_scan;
159213160104
}
159214160105
zBuffer = zNew;
@@ -161183,13 +162074,28 @@
161183162074
assert( p->mxSavepoint >= iSavepoint );
161184162075
TESTONLY( p->mxSavepoint = iSavepoint );
161185162076
sqlite3Fts3PendingTermsClear(p);
161186162077
return SQLITE_OK;
161187162078
}
162079
+
162080
+/*
162081
+** Return true if zName is the extension on one of the shadow tables used
162082
+** by this module.
162083
+*/
162084
+static int fts3ShadowName(const char *zName){
162085
+ static const char *azName[] = {
162086
+ "content", "docsize", "segdir", "segments", "stat",
162087
+ };
162088
+ unsigned int i;
162089
+ for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
162090
+ if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
162091
+ }
162092
+ return 0;
162093
+}
161188162094
161189162095
static const sqlite3_module fts3Module = {
161190
- /* iVersion */ 2,
162096
+ /* iVersion */ 3,
161191162097
/* xCreate */ fts3CreateMethod,
161192162098
/* xConnect */ fts3ConnectMethod,
161193162099
/* xBestIndex */ fts3BestIndexMethod,
161194162100
/* xDisconnect */ fts3DisconnectMethod,
161195162101
/* xDestroy */ fts3DestroyMethod,
@@ -161208,10 +162114,11 @@
161208162114
/* xFindFunction */ fts3FindFunctionMethod,
161209162115
/* xRename */ fts3RenameMethod,
161210162116
/* xSavepoint */ fts3SavepointMethod,
161211162117
/* xRelease */ fts3ReleaseMethod,
161212162118
/* xRollbackTo */ fts3RollbackToMethod,
162119
+ /* xShadowName */ fts3ShadowName,
161213162120
};
161214162121
161215162122
/*
161216162123
** This function is registered as the module destructor (called when an
161217162124
** FTS3 enabled database connection is closed). It frees the memory
@@ -163839,11 +164746,12 @@
163839164746
0, /* xRollback */
163840164747
0, /* xFindFunction */
163841164748
0, /* xRename */
163842164749
0, /* xSavepoint */
163843164750
0, /* xRelease */
163844
- 0 /* xRollbackTo */
164751
+ 0, /* xRollbackTo */
164752
+ 0 /* xShadowName */
163845164753
};
163846164754
int rc; /* Return code */
163847164755
163848164756
rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0);
163849164757
return rc;
@@ -167398,11 +168306,12 @@
167398168306
0, /* xRollback */
167399168307
0, /* xFindFunction */
167400168308
0, /* xRename */
167401168309
0, /* xSavepoint */
167402168310
0, /* xRelease */
167403
- 0 /* xRollbackTo */
168311
+ 0, /* xRollbackTo */
168312
+ 0 /* xShadowName */
167404168313
};
167405168314
int rc; /* Return code */
167406168315
167407168316
rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
167408168317
return rc;
@@ -168786,19 +169695,23 @@
168786169695
168787169696
/* Because of the FTS3_NODE_PADDING bytes of padding, the following is
168788169697
** safe (no risk of overread) even if the node data is corrupted. */
168789169698
pNext += fts3GetVarint32(pNext, &nPrefix);
168790169699
pNext += fts3GetVarint32(pNext, &nSuffix);
168791
- if( nPrefix<0 || nSuffix<=0
168792
- || &pNext[nSuffix]>&pReader->aNode[pReader->nNode]
169700
+ if( nSuffix<=0
169701
+ || (&pReader->aNode[pReader->nNode] - pNext)<nSuffix
169702
+ || nPrefix>pReader->nTermAlloc
168793169703
){
168794169704
return FTS_CORRUPT_VTAB;
168795169705
}
168796169706
168797
- if( nPrefix+nSuffix>pReader->nTermAlloc ){
168798
- int nNew = (nPrefix+nSuffix)*2;
168799
- char *zNew = sqlite3_realloc(pReader->zTerm, nNew);
169707
+ /* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are
169708
+ ** between 0 and 0x7FFFFFFF. But the sum of the two may cause integer
169709
+ ** overflow - hence the (i64) casts. */
169710
+ if( (i64)nPrefix+nSuffix>(i64)pReader->nTermAlloc ){
169711
+ i64 nNew = ((i64)nPrefix+nSuffix)*2;
169712
+ char *zNew = sqlite3_realloc64(pReader->zTerm, nNew);
168800169713
if( !zNew ){
168801169714
return SQLITE_NOMEM;
168802169715
}
168803169716
pReader->zTerm = zNew;
168804169717
pReader->nTermAlloc = nNew;
@@ -168816,11 +169729,11 @@
168816169729
168817169730
/* Check that the doclist does not appear to extend past the end of the
168818169731
** b-tree node. And that the final byte of the doclist is 0x00. If either
168819169732
** of these statements is untrue, then the data structure is corrupt.
168820169733
*/
168821
- if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode]
169734
+ if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
168822169735
|| (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
168823169736
){
168824169737
return FTS_CORRUPT_VTAB;
168825169738
}
168826169739
return SQLITE_OK;
@@ -171142,25 +172055,30 @@
171142172055
if( bFirst==0 ){
171143172056
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
171144172057
}
171145172058
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
171146172059
172060
+ if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
172061
+ return SQLITE_CORRUPT_VTAB;
172062
+ }
171147172063
blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
171148172064
if( rc==SQLITE_OK ){
171149172065
memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
171150172066
p->term.n = nPrefix+nSuffix;
171151172067
p->iOff += nSuffix;
171152172068
if( p->iChild==0 ){
171153172069
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
172070
+ if( (p->nNode-p->iOff)<p->nDoclist ){
172071
+ return SQLITE_CORRUPT_VTAB;
172072
+ }
171154172073
p->aDoclist = &p->aNode[p->iOff];
171155172074
p->iOff += p->nDoclist;
171156172075
}
171157172076
}
171158172077
}
171159172078
171160172079
assert( p->iOff<=p->nNode );
171161
-
171162172080
return rc;
171163172081
}
171164172082
171165172083
/*
171166172084
** Release all dynamic resources held by node-reader object *p.
@@ -177960,11 +178878,12 @@
177960178878
0, /* xRollback */
177961178879
0, /* xFindMethod */
177962178880
0, /* xRename */
177963178881
0, /* xSavepoint */
177964178882
0, /* xRelease */
177965
- 0 /* xRollbackTo */
178883
+ 0, /* xRollbackTo */
178884
+ 0 /* xShadowName */
177966178885
};
177967178886
177968178887
/* The methods of the json_tree virtual table. */
177969178888
static sqlite3_module jsonTreeModule = {
177970178889
0, /* iVersion */
@@ -177987,11 +178906,12 @@
177987178906
0, /* xRollback */
177988178907
0, /* xFindMethod */
177989178908
0, /* xRename */
177990178909
0, /* xSavepoint */
177991178910
0, /* xRelease */
177992
- 0 /* xRollbackTo */
178911
+ 0, /* xRollbackTo */
178912
+ 0 /* xShadowName */
177993178913
};
177994178914
#endif /* SQLITE_OMIT_VIRTUALTABLE */
177995178915
177996178916
/****************************************************************************
177997178917
** The following routines are the only publically visible identifiers in this
@@ -181417,12 +182337,28 @@
181417182337
}
181418182338
181419182339
return rc;
181420182340
}
181421182341
182342
+
182343
+/*
182344
+** Return true if zName is the extension on one of the shadow tables used
182345
+** by this module.
182346
+*/
182347
+static int rtreeShadowName(const char *zName){
182348
+ static const char *azName[] = {
182349
+ "node", "parent", "rowid"
182350
+ };
182351
+ unsigned int i;
182352
+ for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
182353
+ if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
182354
+ }
182355
+ return 0;
182356
+}
182357
+
181422182358
static sqlite3_module rtreeModule = {
181423
- 2, /* iVersion */
182359
+ 3, /* iVersion */
181424182360
rtreeCreate, /* xCreate - create a table */
181425182361
rtreeConnect, /* xConnect - connect to an existing table */
181426182362
rtreeBestIndex, /* xBestIndex - Determine search strategy */
181427182363
rtreeDisconnect, /* xDisconnect - Disconnect from a table */
181428182364
rtreeDestroy, /* xDestroy - Drop a table */
@@ -181441,10 +182377,11 @@
181441182377
0, /* xFindFunction - function overloading */
181442182378
rtreeRename, /* xRename - rename the table */
181443182379
rtreeSavepoint, /* xSavepoint */
181444182380
0, /* xRelease */
181445182381
0, /* xRollbackTo */
182382
+ rtreeShadowName /* xShadowName */
181446182383
};
181447182384
181448182385
static int rtreeSqlInit(
181449182386
Rtree *pRtree,
181450182387
sqlite3 *db,
@@ -182431,17 +183368,27 @@
182431183368
** The on-disk representation consists of a 4-byte header followed by
182432183369
** the values. The 4-byte header is:
182433183370
**
182434183371
** encoding (1 byte) 0=big-endian, 1=little-endian
182435183372
** nvertex (3 bytes) Number of vertexes as a big-endian integer
183373
+**
183374
+** Enough space is allocated for 4 coordinates, to work around over-zealous
183375
+** warnings coming from some compiler (notably, clang). In reality, the size
183376
+** of each GeoPoly memory allocate is adjusted as necessary so that the
183377
+** GeoPoly.a[] array at the end is the appropriate size.
182436183378
*/
182437183379
typedef struct GeoPoly GeoPoly;
182438183380
struct GeoPoly {
182439183381
int nVertex; /* Number of vertexes */
182440183382
unsigned char hdr[4]; /* Header for on-disk representation */
182441
- GeoCoord a[2]; /* 2*nVertex values. X (longitude) first, then Y */
183383
+ GeoCoord a[8]; /* 2*nVertex values. X (longitude) first, then Y */
182442183384
};
183385
+
183386
+/* The size of a memory allocation needed for a GeoPoly object sufficient
183387
+** to hold N coordinate pairs.
183388
+*/
183389
+#define GEOPOLY_SZ(N) (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4))
182443183390
182444183391
/*
182445183392
** State of a parse of a GeoJSON input.
182446183393
*/
182447183394
typedef struct GeoParse GeoParse;
@@ -182463,11 +183410,11 @@
182463183410
a[2] = t;
182464183411
}
182465183412
182466183413
/* Skip whitespace. Return the next non-whitespace character. */
182467183414
static char geopolySkipSpace(GeoParse *p){
182468
- while( p->z[0] && safe_isspace(p->z[0]) ) p->z++;
183415
+ while( safe_isspace(p->z[0]) ) p->z++;
182469183416
return p->z[0];
182470183417
}
182471183418
182472183419
/* Parse out a number. Write the value into *pVal if pVal!=0.
182473183420
** return non-zero on success and zero if the next token is not a number.
@@ -182483,11 +183430,11 @@
182483183430
c = z[j];
182484183431
}
182485183432
if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
182486183433
for(;; j++){
182487183434
c = z[j];
182488
- if( c>='0' && c<='9' ) continue;
183435
+ if( safe_isdigit(c) ) continue;
182489183436
if( c=='.' ){
182490183437
if( z[j-1]=='-' ) return 0;
182491183438
if( seenDP ) return 0;
182492183439
seenDP = 1;
182493183440
continue;
@@ -182505,11 +183452,21 @@
182505183452
continue;
182506183453
}
182507183454
break;
182508183455
}
182509183456
if( z[j-1]<'0' ) return 0;
182510
- if( pVal ) *pVal = (GeoCoord)atof((const char*)p->z);
183457
+ if( pVal ){
183458
+#ifdef SQLITE_AMALGAMATION
183459
+ /* The sqlite3AtoF() routine is much much faster than atof(), if it
183460
+ ** is available */
183461
+ double r;
183462
+ (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);
183463
+ *pVal = r;
183464
+#else
183465
+ *pVal = (GeoCoord)atof((const char*)p->z);
183466
+#endif
183467
+ }
182511183468
p->z += j;
182512183469
return 1;
182513183470
}
182514183471
182515183472
/*
@@ -182563,16 +183520,14 @@
182563183520
&& s.nVertex>=4
182564183521
&& s.a[0]==s.a[s.nVertex*2-2]
182565183522
&& s.a[1]==s.a[s.nVertex*2-1]
182566183523
&& (s.z++, geopolySkipSpace(&s)==0)
182567183524
){
182568
- int nByte;
182569183525
GeoPoly *pOut;
182570183526
int x = 1;
182571183527
s.nVertex--; /* Remove the redundant vertex at the end */
182572
- nByte = sizeof(GeoPoly) * s.nVertex*2*sizeof(GeoCoord);
182573
- pOut = sqlite3_malloc64( nByte );
183528
+ pOut = sqlite3_malloc64( GEOPOLY_SZ(s.nVertex) );
182574183529
x = 1;
182575183530
if( pOut==0 ) goto parse_json_err;
182576183531
pOut->nVertex = s.nVertex;
182577183532
memcpy(pOut->a, s.a, s.nVertex*2*sizeof(GeoCoord));
182578183533
pOut->hdr[0] = *(unsigned char*)&x;
@@ -182770,10 +183725,31 @@
182770183725
sqlite3_result_blob(context, p->hdr,
182771183726
4+8*p->nVertex, SQLITE_TRANSIENT);
182772183727
sqlite3_free(p);
182773183728
}
182774183729
}
183730
+
183731
+/*
183732
+** Compute the area enclosed by the polygon.
183733
+**
183734
+** This routine can also be used to detect polygons that rotate in
183735
+** the wrong direction. Polygons are suppose to be counter-clockwise (CCW).
183736
+** This routine returns a negative value for clockwise (CW) polygons.
183737
+*/
183738
+static double geopolyArea(GeoPoly *p){
183739
+ double rArea = 0.0;
183740
+ int ii;
183741
+ for(ii=0; ii<p->nVertex-1; ii++){
183742
+ rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
183743
+ * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
183744
+ * 0.5;
183745
+ }
183746
+ rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
183747
+ * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
183748
+ * 0.5;
183749
+ return rArea;
183750
+}
182775183751
182776183752
/*
182777183753
** Implementation of the geopoly_area(X) function.
182778183754
**
182779183755
** If the input is a well-formed Geopoly BLOB then return the area
@@ -182786,24 +183762,109 @@
182786183762
int argc,
182787183763
sqlite3_value **argv
182788183764
){
182789183765
GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
182790183766
if( p ){
182791
- double rArea = 0.0;
182792
- int ii;
182793
- for(ii=0; ii<p->nVertex-1; ii++){
182794
- rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
182795
- * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
182796
- * 0.5;
182797
- }
182798
- rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
182799
- * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
182800
- * 0.5;
182801
- sqlite3_result_double(context, rArea);
183767
+ sqlite3_result_double(context, geopolyArea(p));
183768
+ sqlite3_free(p);
183769
+ }
183770
+}
183771
+
183772
+/*
183773
+** Implementation of the geopoly_ccw(X) function.
183774
+**
183775
+** If the rotation of polygon X is clockwise (incorrect) instead of
183776
+** counter-clockwise (the correct winding order according to RFC7946)
183777
+** then reverse the order of the vertexes in polygon X.
183778
+**
183779
+** In other words, this routine returns a CCW polygon regardless of the
183780
+** winding order of its input.
183781
+**
183782
+** Use this routine to sanitize historical inputs that that sometimes
183783
+** contain polygons that wind in the wrong direction.
183784
+*/
183785
+static void geopolyCcwFunc(
183786
+ sqlite3_context *context,
183787
+ int argc,
183788
+ sqlite3_value **argv
183789
+){
183790
+ GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
183791
+ if( p ){
183792
+ if( geopolyArea(p)<0.0 ){
183793
+ int ii, jj;
183794
+ for(ii=2, jj=p->nVertex*2 - 4; ii<jj; ii+=2, jj-=2){
183795
+ GeoCoord t = p->a[ii];
183796
+ p->a[ii] = p->a[jj];
183797
+ p->a[jj] = t;
183798
+ t = p->a[ii+1];
183799
+ p->a[ii+1] = p->a[jj+1];
183800
+ p->a[jj+1] = t;
183801
+ }
183802
+ }
183803
+ sqlite3_result_blob(context, p->hdr,
183804
+ 4+8*p->nVertex, SQLITE_TRANSIENT);
182802183805
sqlite3_free(p);
182803183806
}
182804183807
}
183808
+
183809
+#define GEOPOLY_PI 3.1415926535897932385
183810
+
183811
+/* Fast approximation for cosine(X) for X between -0.5*pi and 2*pi
183812
+*/
183813
+static double geopolyCosine(double r){
183814
+ assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI );
183815
+ if( r>=1.5*GEOPOLY_PI ){
183816
+ r -= 2.0*GEOPOLY_PI;
183817
+ }
183818
+ if( r>=0.5*GEOPOLY_PI ){
183819
+ return -geopolyCosine(r-GEOPOLY_PI);
183820
+ }else{
183821
+ double r2 = r*r;
183822
+ double r3 = r2*r;
183823
+ double r5 = r3*r2;
183824
+ return 0.9996949*r - 0.1656700*r3 + 0.0075134*r5;
183825
+ }
183826
+}
183827
+
183828
+/*
183829
+** Function: geopoly_regular(X,Y,R,N)
183830
+**
183831
+** Construct a simple, convex, regular polygon centered at X, Y
183832
+** with circumradius R and with N sides.
183833
+*/
183834
+static void geopolyRegularFunc(
183835
+ sqlite3_context *context,
183836
+ int argc,
183837
+ sqlite3_value **argv
183838
+){
183839
+ double x = sqlite3_value_double(argv[0]);
183840
+ double y = sqlite3_value_double(argv[1]);
183841
+ double r = sqlite3_value_double(argv[2]);
183842
+ int n = sqlite3_value_int(argv[3]);
183843
+ int i;
183844
+ GeoPoly *p;
183845
+
183846
+ if( n<3 || r<=0.0 ) return;
183847
+ if( n>1000 ) n = 1000;
183848
+ p = sqlite3_malloc64( sizeof(*p) + (n-1)*2*sizeof(GeoCoord) );
183849
+ if( p==0 ){
183850
+ sqlite3_result_error_nomem(context);
183851
+ return;
183852
+ }
183853
+ i = 1;
183854
+ p->hdr[0] = *(unsigned char*)&i;
183855
+ p->hdr[1] = 0;
183856
+ p->hdr[2] = (n>>8)&0xff;
183857
+ p->hdr[3] = n&0xff;
183858
+ for(i=0; i<n; i++){
183859
+ double rAngle = 2.0*GEOPOLY_PI*i/n;
183860
+ p->a[i*2] = x - r*geopolyCosine(rAngle-0.5*GEOPOLY_PI);
183861
+ p->a[i*2+1] = y + r*geopolyCosine(rAngle);
183862
+ }
183863
+ sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);
183864
+ sqlite3_free(p);
183865
+}
182805183866
182806183867
/*
182807183868
** If pPoly is a polygon, compute its bounding box. Then:
182808183869
**
182809183870
** (1) if aCoord!=0 store the bounding box in aCoord, returning NULL
@@ -182845,11 +183906,11 @@
182845183906
else if( r>mxY ) mxY = (float)r;
182846183907
}
182847183908
if( pRc ) *pRc = SQLITE_OK;
182848183909
if( aCoord==0 ){
182849183910
geopolyBboxFill:
182850
- pOut = sqlite3_realloc(p, sizeof(GeoPoly)+sizeof(GeoCoord)*6);
183911
+ pOut = sqlite3_realloc(p, GEOPOLY_SZ(4));
182851183912
if( pOut==0 ){
182852183913
sqlite3_free(p);
182853183914
if( context ) sqlite3_result_error_nomem(context);
182854183915
if( pRc ) *pRc = SQLITE_NOMEM;
182855183916
return 0;
@@ -183873,11 +184934,20 @@
183873184934
sqlite3_bind_int64(pUp, 1, cell.iRowid);
183874184935
assert( pRtree->nAux>=1 );
183875184936
if( sqlite3_value_nochange(aData[2]) ){
183876184937
sqlite3_bind_null(pUp, 2);
183877184938
}else{
183878
- sqlite3_bind_value(pUp, 2, aData[2]);
184939
+ GeoPoly *p = 0;
184940
+ if( sqlite3_value_type(aData[2])==SQLITE_TEXT
184941
+ && (p = geopolyFuncParam(0, aData[2], &rc))!=0
184942
+ && rc==SQLITE_OK
184943
+ ){
184944
+ sqlite3_bind_blob(pUp, 2, p->hdr, 4+8*p->nVertex, SQLITE_TRANSIENT);
184945
+ }else{
184946
+ sqlite3_bind_value(pUp, 2, aData[2]);
184947
+ }
184948
+ sqlite3_free(p);
183879184949
nChange = 1;
183880184950
}
183881184951
for(jj=1; jj<pRtree->nAux; jj++){
183882184952
nChange++;
183883184953
sqlite3_bind_value(pUp, jj+2, aData[jj+2]);
@@ -183917,11 +184987,11 @@
183917184987
return 0;
183918184988
}
183919184989
183920184990
183921184991
static sqlite3_module geopolyModule = {
183922
- 2, /* iVersion */
184992
+ 3, /* iVersion */
183923184993
geopolyCreate, /* xCreate - create a table */
183924184994
geopolyConnect, /* xConnect - connect to an existing table */
183925184995
geopolyBestIndex, /* xBestIndex - Determine search strategy */
183926184996
rtreeDisconnect, /* xDisconnect - Disconnect from a table */
183927184997
rtreeDestroy, /* xDestroy - Drop a table */
@@ -183940,29 +185010,33 @@
183940185010
geopolyFindFunction, /* xFindFunction - function overloading */
183941185011
rtreeRename, /* xRename - rename the table */
183942185012
rtreeSavepoint, /* xSavepoint */
183943185013
0, /* xRelease */
183944185014
0, /* xRollbackTo */
185015
+ rtreeShadowName /* xShadowName */
183945185016
};
183946185017
183947185018
static int sqlite3_geopoly_init(sqlite3 *db){
183948185019
int rc = SQLITE_OK;
183949185020
static const struct {
183950185021
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
183951
- int nArg;
185022
+ signed char nArg;
185023
+ unsigned char bPure;
183952185024
const char *zName;
183953185025
} aFunc[] = {
183954
- { geopolyAreaFunc, 1, "geopoly_area" },
183955
- { geopolyBlobFunc, 1, "geopoly_blob" },
183956
- { geopolyJsonFunc, 1, "geopoly_json" },
183957
- { geopolySvgFunc, -1, "geopoly_svg" },
183958
- { geopolyWithinFunc, 2, "geopoly_within" },
183959
- { geopolyContainsPointFunc, 3, "geopoly_contains_point" },
183960
- { geopolyOverlapFunc, 2, "geopoly_overlap" },
183961
- { geopolyDebugFunc, 1, "geopoly_debug" },
183962
- { geopolyBBoxFunc, 1, "geopoly_bbox" },
183963
- { geopolyXformFunc, 7, "geopoly_xform" },
185026
+ { geopolyAreaFunc, 1, 1, "geopoly_area" },
185027
+ { geopolyBlobFunc, 1, 1, "geopoly_blob" },
185028
+ { geopolyJsonFunc, 1, 1, "geopoly_json" },
185029
+ { geopolySvgFunc, -1, 1, "geopoly_svg" },
185030
+ { geopolyWithinFunc, 2, 1, "geopoly_within" },
185031
+ { geopolyContainsPointFunc, 3, 1, "geopoly_contains_point" },
185032
+ { geopolyOverlapFunc, 2, 1, "geopoly_overlap" },
185033
+ { geopolyDebugFunc, 1, 0, "geopoly_debug" },
185034
+ { geopolyBBoxFunc, 1, 1, "geopoly_bbox" },
185035
+ { geopolyXformFunc, 7, 1, "geopoly_xform" },
185036
+ { geopolyRegularFunc, 4, 1, "geopoly_regular" },
185037
+ { geopolyCcwFunc, 1, 1, "geopoly_ccw" },
183964185038
};
183965185039
static const struct {
183966185040
void (*xStep)(sqlite3_context*,int,sqlite3_value**);
183967185041
void (*xFinal)(sqlite3_context*);
183968185042
const char *zName;
@@ -183969,12 +185043,13 @@
183969185043
} aAgg[] = {
183970185044
{ geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox" },
183971185045
};
183972185046
int i;
183973185047
for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
185048
+ int enc = aFunc[i].bPure ? SQLITE_UTF8|SQLITE_DETERMINISTIC : SQLITE_UTF8;
183974185049
rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
183975
- SQLITE_UTF8, 0,
185050
+ enc, 0,
183976185051
aFunc[i].xFunc, 0, 0);
183977185052
}
183978185053
for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
183979185054
rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,
183980185055
0, aAgg[i].xStep, aAgg[i].xFinal);
@@ -185997,11 +187072,12 @@
185997187072
struct rbu_vfs {
185998187073
sqlite3_vfs base; /* rbu VFS shim methods */
185999187074
sqlite3_vfs *pRealVfs; /* Underlying VFS */
186000187075
sqlite3_mutex *mutex; /* Mutex to protect pMain */
186001187076
sqlite3rbu *pRbu; /* Owner RBU object */
186002
- rbu_file *pMain; /* Linked list of main db files */
187077
+ rbu_file *pMain; /* List of main db files */
187078
+ rbu_file *pMainRbu; /* List of main db files with pRbu!=0 */
186003187079
};
186004187080
186005187081
/*
186006187082
** Each file opened by an rbu VFS is represented by an instance of
186007187083
** the following structure.
@@ -186026,10 +187102,11 @@
186026187102
char *zDel; /* Delete this when closing file */
186027187103
186028187104
const char *zWal; /* Wal filename for this main db file */
186029187105
rbu_file *pWalFd; /* Wal file descriptor for this main db */
186030187106
rbu_file *pMainNext; /* Next MAIN_DB file */
187107
+ rbu_file *pMainRbuNext; /* Next MAIN_DB file with pRbu!=0 */
186031187108
};
186032187109
186033187110
/*
186034187111
** True for an RBU vacuum handle, or false otherwise.
186035187112
*/
@@ -189621,10 +190698,73 @@
189621190698
pFd->sz = nNew;
189622190699
assert( pRbu->szTemp>=0 );
189623190700
if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;
189624190701
return SQLITE_OK;
189625190702
}
190703
+
190704
+/*
190705
+** Add an item to the main-db lists, if it is not already present.
190706
+**
190707
+** There are two main-db lists. One for all file descriptors, and one
190708
+** for all file descriptors with rbu_file.pDb!=0. If the argument has
190709
+** rbu_file.pDb!=0, then it is assumed to already be present on the
190710
+** main list and is only added to the pDb!=0 list.
190711
+*/
190712
+static void rbuMainlistAdd(rbu_file *p){
190713
+ rbu_vfs *pRbuVfs = p->pRbuVfs;
190714
+ rbu_file *pIter;
190715
+ assert( (p->openFlags & SQLITE_OPEN_MAIN_DB) );
190716
+ sqlite3_mutex_enter(pRbuVfs->mutex);
190717
+ if( p->pRbu==0 ){
190718
+ for(pIter=pRbuVfs->pMain; pIter; pIter=pIter->pMainNext);
190719
+ p->pMainNext = pRbuVfs->pMain;
190720
+ pRbuVfs->pMain = p;
190721
+ }else{
190722
+ for(pIter=pRbuVfs->pMainRbu; pIter && pIter!=p; pIter=pIter->pMainRbuNext){}
190723
+ if( pIter==0 ){
190724
+ p->pMainRbuNext = pRbuVfs->pMainRbu;
190725
+ pRbuVfs->pMainRbu = p;
190726
+ }
190727
+ }
190728
+ sqlite3_mutex_leave(pRbuVfs->mutex);
190729
+}
190730
+
190731
+/*
190732
+** Remove an item from the main-db lists.
190733
+*/
190734
+static void rbuMainlistRemove(rbu_file *p){
190735
+ rbu_file **pp;
190736
+ sqlite3_mutex_enter(p->pRbuVfs->mutex);
190737
+ for(pp=&p->pRbuVfs->pMain; *pp && *pp!=p; pp=&((*pp)->pMainNext)){}
190738
+ if( *pp ) *pp = p->pMainNext;
190739
+ p->pMainNext = 0;
190740
+ for(pp=&p->pRbuVfs->pMainRbu; *pp && *pp!=p; pp=&((*pp)->pMainRbuNext)){}
190741
+ if( *pp ) *pp = p->pMainRbuNext;
190742
+ p->pMainRbuNext = 0;
190743
+ sqlite3_mutex_leave(p->pRbuVfs->mutex);
190744
+}
190745
+
190746
+/*
190747
+** Given that zWal points to a buffer containing a wal file name passed to
190748
+** either the xOpen() or xAccess() VFS method, search the main-db list for
190749
+** a file-handle opened by the same database connection on the corresponding
190750
+** database file.
190751
+**
190752
+** If parameter bRbu is true, only search for file-descriptors with
190753
+** rbu_file.pDb!=0.
190754
+*/
190755
+static rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal, int bRbu){
190756
+ rbu_file *pDb;
190757
+ sqlite3_mutex_enter(pRbuVfs->mutex);
190758
+ if( bRbu ){
190759
+ for(pDb=pRbuVfs->pMainRbu; pDb && pDb->zWal!=zWal; pDb=pDb->pMainRbuNext){}
190760
+ }else{
190761
+ for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}
190762
+ }
190763
+ sqlite3_mutex_leave(pRbuVfs->mutex);
190764
+ return pDb;
190765
+}
189626190766
189627190767
/*
189628190768
** Close an rbu file.
189629190769
*/
189630190770
static int rbuVfsClose(sqlite3_file *pFile){
@@ -189639,21 +190779,18 @@
189639190779
sqlite3_free(p->apShm);
189640190780
p->apShm = 0;
189641190781
sqlite3_free(p->zDel);
189642190782
189643190783
if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
189644
- rbu_file **pp;
189645
- sqlite3_mutex_enter(p->pRbuVfs->mutex);
189646
- for(pp=&p->pRbuVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext));
189647
- *pp = p->pMainNext;
189648
- sqlite3_mutex_leave(p->pRbuVfs->mutex);
190784
+ rbuMainlistRemove(p);
189649190785
rbuUnlockShm(p);
189650190786
p->pReal->pMethods->xShmUnmap(p->pReal, 0);
189651190787
}
189652190788
else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){
189653190789
rbuUpdateTempSize(p, 0);
189654190790
}
190791
+ assert( p->pMainNext==0 && p->pRbuVfs->pMain!=p );
189655190792
189656190793
/* Close the underlying file handle */
189657190794
rc = p->pReal->pMethods->xClose(p->pReal);
189658190795
return rc;
189659190796
}
@@ -189908,10 +191045,13 @@
189908191045
rc = SQLITE_ERROR;
189909191046
pRbu->zErrmsg = sqlite3_mprintf("rbu/zipvfs setup error");
189910191047
}else if( rc==SQLITE_NOTFOUND ){
189911191048
pRbu->pTargetFd = p;
189912191049
p->pRbu = pRbu;
191050
+ if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
191051
+ rbuMainlistAdd(p);
191052
+ }
189913191053
if( p->pWalFd ) p->pWalFd->pRbu = pRbu;
189914191054
rc = SQLITE_OK;
189915191055
}
189916191056
}
189917191057
return rc;
@@ -190069,24 +191209,10 @@
190069191209
rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
190070191210
}
190071191211
return rc;
190072191212
}
190073191213
190074
-/*
190075
-** Given that zWal points to a buffer containing a wal file name passed to
190076
-** either the xOpen() or xAccess() VFS method, return a pointer to the
190077
-** file-handle opened by the same database connection on the corresponding
190078
-** database file.
190079
-*/
190080
-static rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal){
190081
- rbu_file *pDb;
190082
- sqlite3_mutex_enter(pRbuVfs->mutex);
190083
- for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}
190084
- sqlite3_mutex_leave(pRbuVfs->mutex);
190085
- return pDb;
190086
-}
190087
-
190088191214
/*
190089191215
** A main database named zName has just been opened. The following
190090191216
** function returns a pointer to a buffer owned by SQLite that contains
190091191217
** the name of the *-wal file this db connection will use. SQLite
190092191218
** happens to pass a pointer to this buffer when using xAccess()
@@ -190161,11 +191287,11 @@
190161191287
** happens to pass a pointer to this buffer when using xAccess()
190162191288
** or xOpen() to operate on the *-wal file. */
190163191289
pFd->zWal = rbuMainToWal(zName, flags);
190164191290
}
190165191291
else if( flags & SQLITE_OPEN_WAL ){
190166
- rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName);
191292
+ rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);
190167191293
if( pDb ){
190168191294
if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
190169191295
/* This call is to open a *-wal file. Intead, open the *-oal. This
190170191296
** code ensures that the string passed to xOpen() is terminated by a
190171191297
** pair of '\0' bytes in case the VFS attempts to extract a URI
@@ -190213,14 +191339,11 @@
190213191339
/* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods
190214191340
** pointer and, if the file is a main database file, link it into the
190215191341
** mutex protected linked list of all such files. */
190216191342
pFile->pMethods = &rbuvfs_io_methods;
190217191343
if( flags & SQLITE_OPEN_MAIN_DB ){
190218
- sqlite3_mutex_enter(pRbuVfs->mutex);
190219
- pFd->pMainNext = pRbuVfs->pMain;
190220
- pRbuVfs->pMain = pFd;
190221
- sqlite3_mutex_leave(pRbuVfs->mutex);
191344
+ rbuMainlistAdd(pFd);
190222191345
}
190223191346
}else{
190224191347
sqlite3_free(pFd->zDel);
190225191348
}
190226191349
@@ -190264,11 +191387,11 @@
190264191387
** causing SQLite to call xOpen() to open it. This call will also
190265191388
** be intercepted (see the rbuVfsOpen() function) and the *-oal
190266191389
** file opened instead.
190267191390
*/
190268191391
if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){
190269
- rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath);
191392
+ rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath, 1);
190270191393
if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
190271191394
if( *pResOut ){
190272191395
rc = SQLITE_CANTOPEN;
190273191396
}else{
190274191397
sqlite3_int64 sz = 0;
@@ -190737,18 +191860,24 @@
190737191860
190738191861
*ppCursor = (sqlite3_vtab_cursor *)pCsr;
190739191862
return SQLITE_OK;
190740191863
}
190741191864
190742
-static void statClearPage(StatPage *p){
191865
+static void statClearCells(StatPage *p){
190743191866
int i;
190744191867
if( p->aCell ){
190745191868
for(i=0; i<p->nCell; i++){
190746191869
sqlite3_free(p->aCell[i].aOvfl);
190747191870
}
190748191871
sqlite3_free(p->aCell);
190749191872
}
191873
+ p->nCell = 0;
191874
+ p->aCell = 0;
191875
+}
191876
+
191877
+static void statClearPage(StatPage *p){
191878
+ statClearCells(p);
190750191879
sqlite3PagerUnref(p->pPg);
190751191880
sqlite3_free(p->zPath);
190752191881
memset(p, 0, sizeof(StatPage));
190753191882
}
190754191883
@@ -190807,26 +191936,37 @@
190807191936
190808191937
u8 *aData = sqlite3PagerGetData(p->pPg);
190809191938
u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];
190810191939
190811191940
p->flags = aHdr[0];
191941
+ if( p->flags==0x0A || p->flags==0x0D ){
191942
+ isLeaf = 1;
191943
+ nHdr = 8;
191944
+ }else if( p->flags==0x05 || p->flags==0x02 ){
191945
+ isLeaf = 0;
191946
+ nHdr = 12;
191947
+ }else{
191948
+ goto statPageIsCorrupt;
191949
+ }
191950
+ if( p->iPgno==1 ) nHdr += 100;
190812191951
p->nCell = get2byte(&aHdr[3]);
190813191952
p->nMxPayload = 0;
190814
-
190815
- isLeaf = (p->flags==0x0A || p->flags==0x0D);
190816
- nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;
191953
+ szPage = sqlite3BtreeGetPageSize(pBt);
190817191954
190818191955
nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;
190819191956
nUnused += (int)aHdr[7];
190820191957
iOff = get2byte(&aHdr[1]);
190821191958
while( iOff ){
191959
+ int iNext;
191960
+ if( iOff>=szPage ) goto statPageIsCorrupt;
190822191961
nUnused += get2byte(&aData[iOff+2]);
190823
- iOff = get2byte(&aData[iOff]);
191962
+ iNext = get2byte(&aData[iOff]);
191963
+ if( iNext<iOff+4 && iNext>0 ) goto statPageIsCorrupt;
191964
+ iOff = iNext;
190824191965
}
190825191966
p->nUnused = nUnused;
190826191967
p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
190827
- szPage = sqlite3BtreeGetPageSize(pBt);
190828191968
190829191969
if( p->nCell ){
190830191970
int i; /* Used to iterate through cells */
190831191971
int nUsable; /* Usable bytes per page */
190832191972
@@ -190839,10 +191979,11 @@
190839191979
190840191980
for(i=0; i<p->nCell; i++){
190841191981
StatCell *pCell = &p->aCell[i];
190842191982
190843191983
iOff = get2byte(&aData[nHdr+i*2]);
191984
+ if( iOff<nHdr || iOff>=szPage ) goto statPageIsCorrupt;
190844191985
if( !isLeaf ){
190845191986
pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);
190846191987
iOff += 4;
190847191988
}
190848191989
if( p->flags==0x05 ){
@@ -190855,12 +191996,12 @@
190855191996
u64 dummy;
190856191997
iOff += sqlite3GetVarint(&aData[iOff], &dummy);
190857191998
}
190858191999
if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
190859192000
getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
192001
+ if( nLocal<0 ) goto statPageIsCorrupt;
190860192002
pCell->nLocal = nLocal;
190861
- assert( nLocal>=0 );
190862192003
assert( nPayload>=(u32)nLocal );
190863192004
assert( nLocal<=(nUsable-35) );
190864192005
if( nPayload>(u32)nLocal ){
190865192006
int j;
190866192007
int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);
@@ -190885,10 +192026,15 @@
190885192026
}
190886192027
}
190887192028
}
190888192029
190889192030
return SQLITE_OK;
192031
+
192032
+statPageIsCorrupt:
192033
+ p->flags = 0;
192034
+ statClearCells(p);
192035
+ return SQLITE_OK;
190890192036
}
190891192037
190892192038
/*
190893192039
** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
190894192040
** the current value of pCsr->iPageno.
@@ -191180,10 +192326,11 @@
191180192326
0, /* xFindMethod */
191181192327
0, /* xRename */
191182192328
0, /* xSavepoint */
191183192329
0, /* xRelease */
191184192330
0, /* xRollbackTo */
192331
+ 0 /* xShadowName */
191185192332
};
191186192333
return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
191187192334
}
191188192335
#elif defined(SQLITE_ENABLE_DBSTAT_VTAB)
191189192336
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191504,10 +192651,14 @@
191504192651
int iDb;
191505192652
Btree *pBt;
191506192653
Pager *pPager;
191507192654
int szPage;
191508192655
192656
+ if( pTab->db->flags & SQLITE_Defensive ){
192657
+ zErr = "read-only";
192658
+ goto update_fail;
192659
+ }
191509192660
if( argc==1 ){
191510192661
zErr = "cannot delete";
191511192662
goto update_fail;
191512192663
}
191513192664
pgno = sqlite3_value_int(argv[0]);
@@ -191594,10 +192745,11 @@
191594192745
0, /* xFindMethod */
191595192746
0, /* xRename */
191596192747
0, /* xSavepoint */
191597192748
0, /* xRelease */
191598192749
0, /* xRollbackTo */
192750
+ 0 /* xShadowName */
191599192751
};
191600192752
return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
191601192753
}
191602192754
#elif defined(SQLITE_ENABLE_DBPAGE_VTAB)
191603192755
SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191629,10 +192781,12 @@
191629192781
# define SESSIONS_STRM_CHUNK_SIZE 64
191630192782
# else
191631192783
# define SESSIONS_STRM_CHUNK_SIZE 1024
191632192784
# endif
191633192785
#endif
192786
+
192787
+static int sessions_strm_chunk_size = SESSIONS_STRM_CHUNK_SIZE;
191634192788
191635192789
typedef struct SessionHook SessionHook;
191636192790
struct SessionHook {
191637192791
void *pCtx;
191638192792
int (*xOld)(void*,int,sqlite3_value**);
@@ -191692,10 +192846,11 @@
191692192846
*/
191693192847
struct sqlite3_changeset_iter {
191694192848
SessionInput in; /* Input buffer or stream */
191695192849
SessionBuffer tblhdr; /* Buffer to hold apValue/zTab/abPK/ */
191696192850
int bPatchset; /* True if this is a patchset */
192851
+ int bInvert; /* True to invert changeset */
191697192852
int rc; /* Iterator error code */
191698192853
sqlite3_stmt *pConflict; /* Points to conflicting row, if any */
191699192854
char *zTab; /* Current table */
191700192855
int nCol; /* Number of columns in zTab */
191701192856
int op; /* Current operation */
@@ -191848,10 +193003,46 @@
191848193003
** and fields associated with modified columns contain the new column values.
191849193004
**
191850193005
** The records associated with INSERT changes are in the same format as for
191851193006
** changesets. It is not possible for a record associated with an INSERT
191852193007
** change to contain a field set to "undefined".
193008
+**
193009
+** REBASE BLOB FORMAT:
193010
+**
193011
+** A rebase blob may be output by sqlite3changeset_apply_v2() and its
193012
+** streaming equivalent for use with the sqlite3_rebaser APIs to rebase
193013
+** existing changesets. A rebase blob contains one entry for each conflict
193014
+** resolved using either the OMIT or REPLACE strategies within the apply_v2()
193015
+** call.
193016
+**
193017
+** The format used for a rebase blob is very similar to that used for
193018
+** changesets. All entries related to a single table are grouped together.
193019
+**
193020
+** Each group of entries begins with a table header in changeset format:
193021
+**
193022
+** 1 byte: Constant 0x54 (capital 'T')
193023
+** Varint: Number of columns in the table.
193024
+** nCol bytes: 0x01 for PK columns, 0x00 otherwise.
193025
+** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
193026
+**
193027
+** Followed by one or more entries associated with the table.
193028
+**
193029
+** 1 byte: Either SQLITE_INSERT (0x12), DELETE (0x09).
193030
+** 1 byte: Flag. 0x01 for REPLACE, 0x00 for OMIT.
193031
+** record: (in the record format defined above).
193032
+**
193033
+** In a rebase blob, the first field is set to SQLITE_INSERT if the change
193034
+** that caused the conflict was an INSERT or UPDATE, or to SQLITE_DELETE if
193035
+** it was a DELETE. The second field is set to 0x01 if the conflict
193036
+** resolution strategy was REPLACE, or 0x00 if it was OMIT.
193037
+**
193038
+** If the change that caused the conflict was a DELETE, then the single
193039
+** record is a copy of the old.* record from the original changeset. If it
193040
+** was an INSERT, then the single record is a copy of the new.* record. If
193041
+** the conflicting change was an UPDATE, then the single record is a copy
193042
+** of the new.* record with the PK fields filled in based on the original
193043
+** old.* record.
191853193044
*/
191854193045
191855193046
/*
191856193047
** For each row modified during a session, there exists a single instance of
191857193048
** this structure stored in a SessionTable.aChange[] hash table.
@@ -193398,16 +194589,16 @@
193398194589
** set *pRc to SQLITE_NOMEM and return non-zero.
193399194590
*/
193400194591
static int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){
193401194592
if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){
193402194593
u8 *aNew;
193403
- int nNew = p->nAlloc ? p->nAlloc : 128;
194594
+ i64 nNew = p->nAlloc ? p->nAlloc : 128;
193404194595
do {
193405194596
nNew = nNew*2;
193406
- }while( nNew<(p->nBuf+nByte) );
194597
+ }while( (nNew-p->nBuf)<nByte );
193407194598
193408
- aNew = (u8 *)sqlite3_realloc(p->aBuf, nNew);
194599
+ aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
193409194600
if( 0==aNew ){
193410194601
*pRc = SQLITE_NOMEM;
193411194602
}else{
193412194603
p->aBuf = aNew;
193413194604
p->nAlloc = nNew;
@@ -194001,16 +195192,16 @@
194001195192
}
194002195193
if( rc==SQLITE_OK ){
194003195194
rc = sqlite3_reset(pSel);
194004195195
}
194005195196
194006
- /* If the buffer is now larger than SESSIONS_STRM_CHUNK_SIZE, pass
195197
+ /* If the buffer is now larger than sessions_strm_chunk_size, pass
194007195198
** its contents to the xOutput() callback. */
194008195199
if( xOutput
194009195200
&& rc==SQLITE_OK
194010195201
&& buf.nBuf>nNoop
194011
- && buf.nBuf>SESSIONS_STRM_CHUNK_SIZE
195202
+ && buf.nBuf>sessions_strm_chunk_size
194012195203
){
194013195204
rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);
194014195205
nNoop = -1;
194015195206
buf.nBuf = 0;
194016195207
}
@@ -194145,11 +195336,12 @@
194145195336
static int sessionChangesetStart(
194146195337
sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194147195338
int (*xInput)(void *pIn, void *pData, int *pnData),
194148195339
void *pIn,
194149195340
int nChangeset, /* Size of buffer pChangeset in bytes */
194150
- void *pChangeset /* Pointer to buffer containing changeset */
195341
+ void *pChangeset, /* Pointer to buffer containing changeset */
195342
+ int bInvert /* True to invert changeset */
194151195343
){
194152195344
sqlite3_changeset_iter *pRet; /* Iterator to return */
194153195345
int nByte; /* Number of bytes to allocate for iterator */
194154195346
194155195347
assert( xInput==0 || (pChangeset==0 && nChangeset==0) );
@@ -194165,10 +195357,11 @@
194165195357
pRet->in.aData = (u8 *)pChangeset;
194166195358
pRet->in.nData = nChangeset;
194167195359
pRet->in.xInput = xInput;
194168195360
pRet->in.pIn = pIn;
194169195361
pRet->in.bEof = (xInput ? 0 : 1);
195362
+ pRet->bInvert = bInvert;
194170195363
194171195364
/* Populate the output variable and return success. */
194172195365
*pp = pRet;
194173195366
return SQLITE_OK;
194174195367
}
@@ -194179,11 +195372,20 @@
194179195372
SQLITE_API int sqlite3changeset_start(
194180195373
sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194181195374
int nChangeset, /* Size of buffer pChangeset in bytes */
194182195375
void *pChangeset /* Pointer to buffer containing changeset */
194183195376
){
194184
- return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset);
195377
+ return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, 0);
195378
+}
195379
+SQLITE_API int sqlite3changeset_start_v2(
195380
+ sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195381
+ int nChangeset, /* Size of buffer pChangeset in bytes */
195382
+ void *pChangeset, /* Pointer to buffer containing changeset */
195383
+ int flags
195384
+){
195385
+ int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);
195386
+ return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, bInvert);
194185195387
}
194186195388
194187195389
/*
194188195390
** Streaming version of sqlite3changeset_start().
194189195391
*/
@@ -194190,19 +195392,28 @@
194190195392
SQLITE_API int sqlite3changeset_start_strm(
194191195393
sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194192195394
int (*xInput)(void *pIn, void *pData, int *pnData),
194193195395
void *pIn
194194195396
){
194195
- return sessionChangesetStart(pp, xInput, pIn, 0, 0);
195397
+ return sessionChangesetStart(pp, xInput, pIn, 0, 0, 0);
195398
+}
195399
+SQLITE_API int sqlite3changeset_start_v2_strm(
195400
+ sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195401
+ int (*xInput)(void *pIn, void *pData, int *pnData),
195402
+ void *pIn,
195403
+ int flags
195404
+){
195405
+ int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);
195406
+ return sessionChangesetStart(pp, xInput, pIn, 0, 0, bInvert);
194196195407
}
194197195408
194198195409
/*
194199195410
** If the SessionInput object passed as the only argument is a streaming
194200195411
** object and the buffer is full, discard some data to free up space.
194201195412
*/
194202195413
static void sessionDiscardData(SessionInput *pIn){
194203
- if( pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){
195414
+ if( pIn->xInput && pIn->iNext>=sessions_strm_chunk_size ){
194204195415
int nMove = pIn->buf.nBuf - pIn->iNext;
194205195416
assert( nMove>=0 );
194206195417
if( nMove>0 ){
194207195418
memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);
194208195419
}
@@ -194221,11 +195432,11 @@
194221195432
*/
194222195433
static int sessionInputBuffer(SessionInput *pIn, int nByte){
194223195434
int rc = SQLITE_OK;
194224195435
if( pIn->xInput ){
194225195436
while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){
194226
- int nNew = SESSIONS_STRM_CHUNK_SIZE;
195437
+ int nNew = sessions_strm_chunk_size;
194227195438
194228195439
if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);
194229195440
if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){
194230195441
rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);
194231195442
if( nNew==0 ){
@@ -194569,14 +195780,14 @@
194569195780
p->in.iCurrent = p->in.iNext;
194570195781
if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
194571195782
op = p->in.aData[p->in.iNext++];
194572195783
}
194573195784
194574
- if( p->zTab==0 ){
195785
+ if( p->zTab==0 || (p->bPatchset && p->bInvert) ){
194575195786
/* The first record in the changeset is not a table header. Must be a
194576195787
** corrupt changeset. */
194577
- assert( p->in.iNext==1 );
195788
+ assert( p->in.iNext==1 || p->zTab );
194578195789
return (p->rc = SQLITE_CORRUPT_BKPT);
194579195790
}
194580195791
194581195792
p->op = op;
194582195793
p->bIndirect = p->in.aData[p->in.iNext++];
@@ -194597,37 +195808,43 @@
194597195808
p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);
194598195809
if( p->rc!=SQLITE_OK ) return p->rc;
194599195810
*paRec = &p->in.aData[p->in.iNext];
194600195811
p->in.iNext += *pnRec;
194601195812
}else{
195813
+ sqlite3_value **apOld = (p->bInvert ? &p->apValue[p->nCol] : p->apValue);
195814
+ sqlite3_value **apNew = (p->bInvert ? p->apValue : &p->apValue[p->nCol]);
194602195815
194603195816
/* If this is an UPDATE or DELETE, read the old.* record. */
194604195817
if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){
194605195818
u8 *abPK = p->bPatchset ? p->abPK : 0;
194606
- p->rc = sessionReadRecord(&p->in, p->nCol, abPK, p->apValue);
195819
+ p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld);
194607195820
if( p->rc!=SQLITE_OK ) return p->rc;
194608195821
}
194609195822
194610195823
/* If this is an INSERT or UPDATE, read the new.* record. */
194611195824
if( p->op!=SQLITE_DELETE ){
194612
- p->rc = sessionReadRecord(&p->in, p->nCol, 0, &p->apValue[p->nCol]);
195825
+ p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew);
194613195826
if( p->rc!=SQLITE_OK ) return p->rc;
194614195827
}
194615195828
194616
- if( p->bPatchset && p->op==SQLITE_UPDATE ){
195829
+ if( (p->bPatchset || p->bInvert) && p->op==SQLITE_UPDATE ){
194617195830
/* If this is an UPDATE that is part of a patchset, then all PK and
194618195831
** modified fields are present in the new.* record. The old.* record
194619195832
** is currently completely empty. This block shifts the PK fields from
194620195833
** new.* to old.*, to accommodate the code that reads these arrays. */
194621195834
for(i=0; i<p->nCol; i++){
194622
- assert( p->apValue[i]==0 );
195835
+ assert( p->bPatchset==0 || p->apValue[i]==0 );
194623195836
if( p->abPK[i] ){
195837
+ assert( p->apValue[i]==0 );
194624195838
p->apValue[i] = p->apValue[i+p->nCol];
194625195839
if( p->apValue[i]==0 ) return (p->rc = SQLITE_CORRUPT_BKPT);
194626195840
p->apValue[i+p->nCol] = 0;
194627195841
}
194628195842
}
195843
+ }else if( p->bInvert ){
195844
+ if( p->op==SQLITE_INSERT ) p->op = SQLITE_DELETE;
195845
+ else if( p->op==SQLITE_DELETE ) p->op = SQLITE_INSERT;
194629195846
}
194630195847
}
194631195848
194632195849
return SQLITE_ROW;
194633195850
}
@@ -194940,11 +196157,11 @@
194940196157
rc = SQLITE_CORRUPT_BKPT;
194941196158
goto finished_invert;
194942196159
}
194943196160
194944196161
assert( rc==SQLITE_OK );
194945
- if( xOutput && sOut.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){
196162
+ if( xOutput && sOut.nBuf>=sessions_strm_chunk_size ){
194946196163
rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
194947196164
sOut.nBuf = 0;
194948196165
if( rc!=SQLITE_OK ) goto finished_invert;
194949196166
}
194950196167
}
@@ -195019,11 +196236,12 @@
195019196236
u8 *abPK; /* Boolean array - true if column is in PK */
195020196237
int bStat1; /* True if table is sqlite_stat1 */
195021196238
int bDeferConstraints; /* True to defer constraints */
195022196239
SessionBuffer constraints; /* Deferred constraints are stored here */
195023196240
SessionBuffer rebase; /* Rebase information (if any) here */
195024
- int bRebaseStarted; /* If table header is already in rebase */
196241
+ u8 bRebaseStarted; /* If table header is already in rebase */
196242
+ u8 bRebase; /* True to collect rebase information */
195025196243
};
195026196244
195027196245
/*
195028196246
** Formulate a statement to DELETE a row from database db. Assuming a table
195029196247
** structure like this:
@@ -195416,39 +196634,40 @@
195416196634
SessionApplyCtx *p, /* Apply context */
195417196635
int eType, /* Conflict resolution (OMIT or REPLACE) */
195418196636
sqlite3_changeset_iter *pIter /* Iterator pointing at current change */
195419196637
){
195420196638
int rc = SQLITE_OK;
195421
- int i;
195422
- int eOp = pIter->op;
195423
- if( p->bRebaseStarted==0 ){
195424
- /* Append a table-header to the rebase buffer */
195425
- const char *zTab = pIter->zTab;
195426
- sessionAppendByte(&p->rebase, 'T', &rc);
195427
- sessionAppendVarint(&p->rebase, p->nCol, &rc);
195428
- sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
195429
- sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
195430
- p->bRebaseStarted = 1;
195431
- }
195432
-
195433
- assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );
195434
- assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );
195435
-
195436
- sessionAppendByte(&p->rebase,
195437
- (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
195438
- );
195439
- sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
195440
- for(i=0; i<p->nCol; i++){
195441
- sqlite3_value *pVal = 0;
195442
- if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){
195443
- sqlite3changeset_old(pIter, i, &pVal);
195444
- }else{
195445
- sqlite3changeset_new(pIter, i, &pVal);
195446
- }
195447
- sessionAppendValue(&p->rebase, pVal, &rc);
195448
- }
195449
-
196639
+ if( p->bRebase ){
196640
+ int i;
196641
+ int eOp = pIter->op;
196642
+ if( p->bRebaseStarted==0 ){
196643
+ /* Append a table-header to the rebase buffer */
196644
+ const char *zTab = pIter->zTab;
196645
+ sessionAppendByte(&p->rebase, 'T', &rc);
196646
+ sessionAppendVarint(&p->rebase, p->nCol, &rc);
196647
+ sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
196648
+ sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
196649
+ p->bRebaseStarted = 1;
196650
+ }
196651
+
196652
+ assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );
196653
+ assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );
196654
+
196655
+ sessionAppendByte(&p->rebase,
196656
+ (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
196657
+ );
196658
+ sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
196659
+ for(i=0; i<p->nCol; i++){
196660
+ sqlite3_value *pVal = 0;
196661
+ if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){
196662
+ sqlite3changeset_old(pIter, i, &pVal);
196663
+ }else{
196664
+ sqlite3changeset_new(pIter, i, &pVal);
196665
+ }
196666
+ sessionAppendValue(&p->rebase, pVal, &rc);
196667
+ }
196668
+ }
195450196669
return rc;
195451196670
}
195452196671
195453196672
/*
195454196673
** Invoke the conflict handler for the change that the changeset iterator
@@ -195787,11 +197006,11 @@
195787197006
while( pApply->constraints.nBuf ){
195788197007
sqlite3_changeset_iter *pIter2 = 0;
195789197008
SessionBuffer cons = pApply->constraints;
195790197009
memset(&pApply->constraints, 0, sizeof(SessionBuffer));
195791197010
195792
- rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf);
197011
+ rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf, 0);
195793197012
if( rc==SQLITE_OK ){
195794197013
int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
195795197014
int rc2;
195796197015
pIter2->bPatchset = bPatchset;
195797197016
pIter2->zTab = (char*)zTab;
@@ -195853,10 +197072,11 @@
195853197072
195854197073
assert( xConflict!=0 );
195855197074
195856197075
pIter->in.bNoDiscard = 1;
195857197076
memset(&sApply, 0, sizeof(sApply));
197077
+ sApply.bRebase = (ppRebase && pnRebase);
195858197078
sqlite3_mutex_enter(sqlite3_db_mutex(db));
195859197079
if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
195860197080
rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
195861197081
}
195862197082
if( rc==SQLITE_OK ){
@@ -196003,11 +197223,12 @@
196003197223
sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
196004197224
sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
196005197225
}
196006197226
}
196007197227
196008
- if( rc==SQLITE_OK && bPatchset==0 && ppRebase && pnRebase ){
197228
+ assert( sApply.bRebase || sApply.rebase.nBuf==0 );
197229
+ if( rc==SQLITE_OK && bPatchset==0 && sApply.bRebase ){
196009197230
*ppRebase = (void*)sApply.rebase.aBuf;
196010197231
*pnRebase = sApply.rebase.nBuf;
196011197232
sApply.rebase.aBuf = 0;
196012197233
}
196013197234
sqlite3_finalize(sApply.pInsert);
@@ -196041,11 +197262,12 @@
196041197262
void *pCtx, /* First argument passed to xConflict */
196042197263
void **ppRebase, int *pnRebase,
196043197264
int flags
196044197265
){
196045197266
sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
196046
- int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
197267
+ int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
197268
+ int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset,bInverse);
196047197269
if( rc==SQLITE_OK ){
196048197270
rc = sessionChangesetApply(
196049197271
db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
196050197272
);
196051197273
}
@@ -196098,11 +197320,12 @@
196098197320
void *pCtx, /* First argument passed to xConflict */
196099197321
void **ppRebase, int *pnRebase,
196100197322
int flags
196101197323
){
196102197324
sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
196103
- int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
197325
+ int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
197326
+ int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse);
196104197327
if( rc==SQLITE_OK ){
196105197328
rc = sessionChangesetApply(
196106197329
db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
196107197330
);
196108197331
}
@@ -196471,17 +197694,16 @@
196471197694
SessionChange *p;
196472197695
for(p=pTab->apChange[i]; p; p=p->pNext){
196473197696
sessionAppendByte(&buf, p->op, &rc);
196474197697
sessionAppendByte(&buf, p->bIndirect, &rc);
196475197698
sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);
197699
+ if( rc==SQLITE_OK && xOutput && buf.nBuf>=sessions_strm_chunk_size ){
197700
+ rc = xOutput(pOut, buf.aBuf, buf.nBuf);
197701
+ buf.nBuf = 0;
197702
+ }
196476197703
}
196477197704
}
196478
-
196479
- if( rc==SQLITE_OK && xOutput && buf.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){
196480
- rc = xOutput(pOut, buf.aBuf, buf.nBuf);
196481
- buf.nBuf = 0;
196482
- }
196483197705
}
196484197706
196485197707
if( rc==SQLITE_OK ){
196486197708
if( xOutput ){
196487197709
if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
@@ -196868,11 +198090,11 @@
196868198090
if( bDone==0 ){
196869198091
sessionAppendByte(&sOut, pIter->op, &rc);
196870198092
sessionAppendByte(&sOut, pIter->bIndirect, &rc);
196871198093
sessionAppendBlob(&sOut, aRec, nRec, &rc);
196872198094
}
196873
- if( rc==SQLITE_OK && xOutput && sOut.nBuf>SESSIONS_STRM_CHUNK_SIZE ){
198095
+ if( rc==SQLITE_OK && xOutput && sOut.nBuf>sessions_strm_chunk_size ){
196874198096
rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
196875198097
sOut.nBuf = 0;
196876198098
}
196877198099
if( rc ) break;
196878198100
}
@@ -196978,10 +198200,31 @@
196978198200
if( p ){
196979198201
sessionDeleteTable(p->grp.pList);
196980198202
sqlite3_free(p);
196981198203
}
196982198204
}
198205
+
198206
+/*
198207
+** Global configuration
198208
+*/
198209
+SQLITE_API int sqlite3session_config(int op, void *pArg){
198210
+ int rc = SQLITE_OK;
198211
+ switch( op ){
198212
+ case SQLITE_SESSION_CONFIG_STRMSIZE: {
198213
+ int *pInt = (int*)pArg;
198214
+ if( *pInt>0 ){
198215
+ sessions_strm_chunk_size = *pInt;
198216
+ }
198217
+ *pInt = sessions_strm_chunk_size;
198218
+ break;
198219
+ }
198220
+ default:
198221
+ rc = SQLITE_MISUSE;
198222
+ break;
198223
+ }
198224
+ return rc;
198225
+}
196983198226
196984198227
#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
196985198228
196986198229
/************** End of sqlite3session.c **************************************/
196987198230
/************** Begin file fts5.c ********************************************/
@@ -210693,11 +211936,11 @@
210693211936
sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
210694211937
pRet = 0;
210695211938
fts5CloseReader(p);
210696211939
}
210697211940
210698
- *ppIter = &pRet->base;
211941
+ *ppIter = (Fts5IndexIter*)pRet;
210699211942
sqlite3Fts5BufferFree(&buf);
210700211943
}
210701211944
return fts5IndexReturn(p);
210702211945
}
210703211946
@@ -214442,16 +215685,31 @@
214442215685
int nArg, /* Number of args */
214443215686
sqlite3_value **apUnused /* Function arguments */
214444215687
){
214445215688
assert( nArg==0 );
214446215689
UNUSED_PARAM2(nArg, apUnused);
214447
- sqlite3_result_text(pCtx, "fts5: 2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7", -1, SQLITE_TRANSIENT);
215690
+ sqlite3_result_text(pCtx, "fts5: 2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513", -1, SQLITE_TRANSIENT);
215691
+}
215692
+
215693
+/*
215694
+** Return true if zName is the extension on one of the shadow tables used
215695
+** by this module.
215696
+*/
215697
+static int fts5ShadowName(const char *zName){
215698
+ static const char *azName[] = {
215699
+ "config", "content", "data", "docsize", "idx"
215700
+ };
215701
+ unsigned int i;
215702
+ for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
215703
+ if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
215704
+ }
215705
+ return 0;
214448215706
}
214449215707
214450215708
static int fts5Init(sqlite3 *db){
214451215709
static const sqlite3_module fts5Mod = {
214452
- /* iVersion */ 2,
215710
+ /* iVersion */ 3,
214453215711
/* xCreate */ fts5CreateMethod,
214454215712
/* xConnect */ fts5ConnectMethod,
214455215713
/* xBestIndex */ fts5BestIndexMethod,
214456215714
/* xDisconnect */ fts5DisconnectMethod,
214457215715
/* xDestroy */ fts5DestroyMethod,
@@ -214470,10 +215728,11 @@
214470215728
/* xFindFunction */ fts5FindFunctionMethod,
214471215729
/* xRename */ fts5RenameMethod,
214472215730
/* xSavepoint */ fts5SavepointMethod,
214473215731
/* xRelease */ fts5ReleaseMethod,
214474215732
/* xRollbackTo */ fts5RollbackToMethod,
215733
+ /* xShadowName */ fts5ShadowName
214475215734
};
214476215735
214477215736
int rc;
214478215737
Fts5Global *pGlobal = 0;
214479215738
@@ -218514,20 +219773,22 @@
218514219773
int rc = SQLITE_OK;
218515219774
Fts5IndexIter *pIter = pCsr->pIter;
218516219775
i64 *pp = &pCsr->iInstPos;
218517219776
int *po = &pCsr->iInstOff;
218518219777
219778
+ assert( sqlite3Fts5IterEof(pIter)==0 );
219779
+ assert( pCsr->bEof==0 );
218519219780
while( eDetail==FTS5_DETAIL_NONE
218520219781
|| sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp)
218521219782
){
218522219783
pCsr->iInstPos = 0;
218523219784
pCsr->iInstOff = 0;
218524219785
218525219786
rc = sqlite3Fts5IterNextScan(pCsr->pIter);
218526219787
if( rc==SQLITE_OK ){
218527219788
rc = fts5VocabInstanceNewTerm(pCsr);
218528
- if( eDetail==FTS5_DETAIL_NONE ) break;
219789
+ if( pCsr->bEof || eDetail==FTS5_DETAIL_NONE ) break;
218529219790
}
218530219791
if( rc ){
218531219792
pCsr->bEof = 1;
218532219793
break;
218533219794
}
@@ -218838,17 +220099,16 @@
218838220099
/* xFindFunction */ 0,
218839220100
/* xRename */ 0,
218840220101
/* xSavepoint */ 0,
218841220102
/* xRelease */ 0,
218842220103
/* xRollbackTo */ 0,
220104
+ /* xShadowName */ 0
218843220105
};
218844220106
void *p = (void*)pGlobal;
218845220107
218846220108
return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0);
218847220109
}
218848
-
218849
-
218850220110
218851220111
218852220112
218853220113
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
218854220114
@@ -219120,10 +220380,11 @@
219120220380
0, /* xFindMethod */
219121220381
0, /* xRename */
219122220382
0, /* xSavepoint */
219123220383
0, /* xRelease */
219124220384
0, /* xRollbackTo */
220385
+ 0, /* xShadowName */
219125220386
};
219126220387
219127220388
#endif /* SQLITE_OMIT_VIRTUALTABLE */
219128220389
219129220390
SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
@@ -219152,12 +220413,12 @@
219152220413
}
219153220414
#endif /* SQLITE_CORE */
219154220415
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219155220416
219156220417
/************** End of stmt.c ************************************************/
219157
-#if __LINE__!=219157
220418
+#if __LINE__!=220418
219158220419
#undef SQLITE_SOURCE_ID
219159
-#define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792alt2"
220420
+#define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a04035alt2"
219160220421
#endif
219161220422
/* Return the source-id for this library */
219162220423
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219163220424
/************************** End of sqlite3.c ******************************/
219164220425
--- 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.25.2. 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.
@@ -257,10 +257,13 @@
257 #if SQLITE_ENABLE_FTS4
258 "ENABLE_FTS4",
259 #endif
260 #if SQLITE_ENABLE_FTS5
261 "ENABLE_FTS5",
 
 
 
262 #endif
263 #if SQLITE_ENABLE_HIDDEN_COLUMNS
264 "ENABLE_HIDDEN_COLUMNS",
265 #endif
266 #if SQLITE_ENABLE_ICU
@@ -287,10 +290,13 @@
287 #if SQLITE_ENABLE_MEMSYS5
288 "ENABLE_MEMSYS5",
289 #endif
290 #if SQLITE_ENABLE_MULTIPLEX
291 "ENABLE_MULTIPLEX",
 
 
 
292 #endif
293 #if SQLITE_ENABLE_NULL_TRIM
294 "ENABLE_NULL_TRIM",
295 #endif
296 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
@@ -1154,13 +1160,13 @@
1154 **
1155 ** See also: [sqlite3_libversion()],
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.2"
1160 #define SQLITE_VERSION_NUMBER 3025002
1161 #define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -3048,10 +3054,11 @@
3048 ** the call worked. ^The [sqlite3_db_config()] interface will return a
3049 ** non-zero [error code] if a discontinued or unsupported configuration option
3050 ** is invoked.
3051 **
3052 ** <dl>
 
3053 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
3054 ** <dd> ^This option takes three additional arguments that determine the
3055 ** [lookaside memory allocator] configuration for the [database connection].
3056 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
3057 ** pointer to a memory buffer to use for lookaside memory.
@@ -3070,10 +3077,11 @@
3070 ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
3071 ** Any attempt to change the lookaside memory configuration when lookaside
3072 ** memory is in use leaves the configuration unchanged and returns
3073 ** [SQLITE_BUSY].)^</dd>
3074 **
 
3075 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
3076 ** <dd> ^This option is used to enable or disable the enforcement of
3077 ** [foreign key constraints]. There should be two additional arguments.
3078 ** The first argument is an integer which is 0 to disable FK enforcement,
3079 ** positive to enable FK enforcement or negative to leave FK enforcement
@@ -3080,10 +3088,11 @@
3080 ** unchanged. The second parameter is a pointer to an integer into which
3081 ** is written 0 or 1 to indicate whether FK enforcement is off or on
3082 ** following this call. The second parameter may be a NULL pointer, in
3083 ** which case the FK enforcement setting is not reported back. </dd>
3084 **
 
3085 ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
3086 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
3087 ** There should be two additional arguments.
3088 ** The first argument is an integer which is 0 to disable triggers,
3089 ** positive to enable triggers or negative to leave the setting unchanged.
@@ -3090,10 +3099,11 @@
3090 ** The second parameter is a pointer to an integer into which
3091 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
3092 ** following this call. The second parameter may be a NULL pointer, in
3093 ** which case the trigger setting is not reported back. </dd>
3094 **
 
3095 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
3096 ** <dd> ^This option is used to enable or disable the two-argument
3097 ** version of the [fts3_tokenizer()] function which is part of the
3098 ** [FTS3] full-text search engine extension.
3099 ** There should be two additional arguments.
@@ -3103,10 +3113,11 @@
3103 ** The second parameter is a pointer to an integer into which
3104 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
3105 ** following this call. The second parameter may be a NULL pointer, in
3106 ** which case the new setting is not reported back. </dd>
3107 **
 
3108 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
3109 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
3110 ** interface independently of the [load_extension()] SQL function.
3111 ** The [sqlite3_enable_load_extension()] API enables or disables both the
3112 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -3120,19 +3131,20 @@
3120 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
3121 ** is disabled or enabled following this call. The second parameter may
3122 ** be a NULL pointer, in which case the new setting is not reported back.
3123 ** </dd>
3124 **
3125 ** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
3126 ** <dd> ^This option is used to change the name of the "main" database
3127 ** schema. ^The sole argument is a pointer to a constant UTF8 string
3128 ** which will become the new schema name in place of "main". ^SQLite
3129 ** does not make a copy of the new main schema name string, so the application
3130 ** must ensure that the argument passed into this DBCONFIG option is unchanged
3131 ** until after the database connection closes.
3132 ** </dd>
3133 **
 
3134 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
3135 ** <dd> Usually, when a database in wal mode is closed or detached from a
3136 ** database handle, SQLite checks if this will mean that there are now no
3137 ** connections at all to the database. If so, it performs a checkpoint
3138 ** operation before closing the connection. This option may be used to
@@ -3142,11 +3154,11 @@
3142 ** The second parameter is a pointer to an integer
3143 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3144 ** have been disabled - 0 if they are not disabled, 1 if they are.
3145 ** </dd>
3146 **
3147 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3148 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3149 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3150 ** a single SQL query statement will always use the same algorithm regardless
3151 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
3152 ** that look at the values of bound parameters, which can make some queries
@@ -3158,11 +3170,11 @@
3158 ** unchanged. The second parameter is a pointer to an integer into which
3159 ** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
3160 ** following this call.
3161 ** </dd>
3162 **
3163 ** <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
3164 ** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
3165 ** include output for any operations performed by trigger programs. This
3166 ** option is used to set or clear (the default) a flag that governs this
3167 ** behavior. The first parameter passed to this operation is an integer -
3168 ** positive to enable output for trigger programs, or zero to disable it,
@@ -3170,11 +3182,11 @@
3170 ** The second parameter is a pointer to an integer into which is written
3171 ** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
3172 ** it is not disabled, 1 if it is.
3173 ** </dd>
3174 **
3175 ** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
3176 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
3177 ** [VACUUM] in order to reset a database back to an empty database
3178 ** with no schema and no content. The following process works even for
3179 ** a badly corrupted database file:
3180 ** <ol>
@@ -3189,10 +3201,22 @@
3189 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
3190 ** </ol>
3191 ** Because resetting a database is destructive and irreversible, the
3192 ** process requires the use of this obscure API and multiple steps to help
3193 ** ensure that it does not happen by accident.
 
 
 
 
 
 
 
 
 
 
 
 
3194 ** </dd>
3195 ** </dl>
3196 */
3197 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3198 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -3202,11 +3226,12 @@
3202 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
3203 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3204 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3205 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
3206 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
3207 #define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
 
3208
3209 /*
3210 ** CAPI3REF: Enable Or Disable Extended Result Codes
3211 ** METHOD: sqlite3
3212 **
@@ -4640,13 +4665,23 @@
4640 ** be used just once or at most a few times and then destroyed using
4641 ** [sqlite3_finalize()] relatively soon. The current implementation acts
4642 ** on this hint by avoiding the use of [lookaside memory] so as not to
4643 ** deplete the limited store of lookaside memory. Future versions of
4644 ** SQLite may act on this hint differently.
 
 
 
 
 
 
 
 
 
4645 ** </dl>
4646 */
4647 #define SQLITE_PREPARE_PERSISTENT 0x01
 
4648
4649 /*
4650 ** CAPI3REF: Compiling An SQL Statement
4651 ** KEYWORDS: {SQL statement compiler}
4652 ** METHOD: sqlite3
@@ -4800,10 +4835,15 @@
4800 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4801 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4802 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
4803 ** string containing the SQL text of prepared statement P with
4804 ** [bound parameters] expanded.
 
 
 
 
 
4805 **
4806 ** ^(For example, if a prepared statement is created using the SQL
4807 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
4808 ** and parameter :xyz is unbound, then sqlite3_sql() will return
4809 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -4815,18 +4855,20 @@
4815 **
4816 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
4817 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
4818 ** option causes sqlite3_expanded_sql() to always return NULL.
4819 **
4820 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
4821 ** automatically freed when the prepared statement is finalized.
 
4822 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4823 ** is obtained from [sqlite3_malloc()] and must be free by the application
4824 ** by passing it to [sqlite3_free()].
4825 */
4826 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4827 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
 
4828
4829 /*
4830 ** CAPI3REF: Determine If An SQL Statement Writes The Database
4831 ** METHOD: sqlite3_stmt
4832 **
@@ -7312,10 +7354,13 @@
7312 /* The methods above are in version 1 of the sqlite_module object. Those
7313 ** below are for version 2 and greater. */
7314 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
7315 int (*xRelease)(sqlite3_vtab *pVTab, int);
7316 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
 
 
 
7317 };
7318
7319 /*
7320 ** CAPI3REF: Virtual Table Indexing Information
7321 ** KEYWORDS: sqlite3_index_info
@@ -9646,10 +9691,11 @@
9646 ** These macros define the various options to the
9647 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
9648 ** can use to customize and optimize their behavior.
9649 **
9650 ** <dl>
 
9651 ** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
9652 ** <dd>Calls of the form
9653 ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
9654 ** where X is an integer. If X is zero, then the [virtual table] whose
9655 ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -10911,16 +10957,42 @@
10911 ** an application iterates through a changeset using an iterator created by
10912 ** this function, all changes that relate to a single table are visited
10913 ** consecutively. There is no chance that the iterator will visit a change
10914 ** the applies to table X, then one for table Y, and then later on visit
10915 ** another change for table X.
 
 
 
 
 
 
 
10916 */
10917 SQLITE_API int sqlite3changeset_start(
10918 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
10919 int nChangeset, /* Size of changeset blob in bytes */
10920 void *pChangeset /* Pointer to blob containing changeset */
10921 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10922
10923
10924 /*
10925 ** CAPI3REF: Advance A Changeset Iterator
10926 ** METHOD: sqlite3_changeset_iter
@@ -11571,11 +11643,11 @@
11571 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
11572 sqlite3_changeset_iter *p /* Handle describing change and conflict */
11573 ),
11574 void *pCtx, /* First argument passed to xConflict */
11575 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
11576 int flags /* Combination of SESSION_APPLY_* flags */
11577 );
11578
11579 /*
11580 ** CAPI3REF: Flags for sqlite3changeset_apply_v2
11581 **
@@ -11589,12 +11661,18 @@
11589 ** SAVEPOINT is committed if the changeset or patchset is successfully
11590 ** applied, or rolled back if an error occurs. Specifying this flag
11591 ** causes the sessions module to omit this savepoint. In this case, if the
11592 ** caller has an open transaction or savepoint when apply_v2() is called,
11593 ** it may revert the partially applied changeset by rolling it back.
 
 
 
 
 
11594 */
11595 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
 
11596
11597 /*
11598 ** CAPI3REF: Constants Passed To The Conflict Handler
11599 **
11600 ** Values that may be passed as the second argument to a conflict-handler.
@@ -11983,10 +12061,16 @@
11983 );
11984 SQLITE_API int sqlite3changeset_start_strm(
11985 sqlite3_changeset_iter **pp,
11986 int (*xInput)(void *pIn, void *pData, int *pnData),
11987 void *pIn
 
 
 
 
 
 
11988 );
11989 SQLITE_API int sqlite3session_changeset_strm(
11990 sqlite3_session *pSession,
11991 int (*xOutput)(void *pOut, const void *pData, int nData),
11992 void *pOut
@@ -12010,10 +12094,49 @@
12010 void *pIn,
12011 int (*xOutput)(void *pOut, const void *pData, int nData),
12012 void *pOut
12013 );
12014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12015
12016 /*
12017 ** Make sure we can call this stuff from C++.
12018 */
12019 #if 0
@@ -16036,16 +16159,18 @@
16036 /*
16037 ** A hash table for built-in function definitions. (Application-defined
16038 ** functions use a regular table table from hash.h.)
16039 **
16040 ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
16041 ** Collisions are on the FuncDef.u.pHash chain.
 
16042 */
16043 #define SQLITE_FUNC_HASH_SZ 23
16044 struct FuncDefHash {
16045 FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
16046 };
 
16047
16048 #ifdef SQLITE_USER_AUTHENTICATION
16049 /*
16050 ** Information held in the "sqlite3" database connection object and used
16051 ** to manage user authentication.
@@ -16102,11 +16227,11 @@
16102 CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
16103 sqlite3_mutex *mutex; /* Connection mutex */
16104 Db *aDb; /* All backends */
16105 int nDb; /* Number of backends currently in use */
16106 u32 mDbFlags; /* flags recording internal state */
16107 u32 flags; /* flags settable by pragmas. See below */
16108 i64 lastRowid; /* ROWID of most recent insert (see above) */
16109 i64 szMmap; /* Default mmap_size setting */
16110 u32 nSchemaLock; /* Do not reset the schema when non-zero */
16111 unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
16112 int errCode; /* Most recent error code (SQLITE_*) */
@@ -16268,18 +16393,21 @@
16268 #define SQLITE_Fts3Tokenizer 0x00400000 /* Enable fts3_tokenizer(2) */
16269 #define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
16270 #define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
16271 #define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
16272 #define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
 
 
16273
16274 /* Flags used only if debugging */
 
16275 #ifdef SQLITE_DEBUG
16276 #define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
16277 #define SQLITE_VdbeListing 0x10000000 /* Debug listings of VDBE programs */
16278 #define SQLITE_VdbeTrace 0x20000000 /* True to trace VDBE execution */
16279 #define SQLITE_VdbeAddopTrace 0x40000000 /* Trace sqlite3VdbeAddOp() calls */
16280 #define SQLITE_VdbeEQP 0x80000000 /* Debug EXPLAIN QUERY PLAN */
16281 #endif
16282
16283 /*
16284 ** Allowed values for sqlite3.mDbFlags
16285 */
@@ -16674,10 +16802,13 @@
16674 ** by an instance of the following structure.
16675 */
16676 struct Table {
16677 char *zName; /* Name of the table or view */
16678 Column *aCol; /* Information about each column */
 
 
 
16679 Index *pIndex; /* List of SQL indexes on this table. */
16680 Select *pSelect; /* NULL for tables. Points to definition if a view. */
16681 FKey *pFKey; /* Linked list of all foreign keys in this table */
16682 char *zColAff; /* String defining the affinity of each column */
16683 ExprList *pCheck; /* All CHECK constraints */
@@ -16724,10 +16855,11 @@
16724 #define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
16725 #define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
16726 #define TF_StatsUsed 0x0100 /* Query planner decisions affected by
16727 ** Index.aiRowLogEst[] values */
16728 #define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
 
16729
16730 /*
16731 ** Test to see whether or not a table is a virtual table. This is
16732 ** done as a macro so that it will be optimized out when virtual
16733 ** table support is omitted from the build.
@@ -17010,10 +17142,16 @@
17010 tRowcnt *anEq; /* Est. number of rows where the key equals this sample */
17011 tRowcnt *anLt; /* Est. number of rows where key is less than this sample */
17012 tRowcnt *anDLt; /* Est. number of distinct keys less than this sample */
17013 };
17014
 
 
 
 
 
 
17015 /*
17016 ** Each token coming out of the lexer is an instance of
17017 ** this structure. Tokens are also used as part of an expression.
17018 **
17019 ** The memory that "z" points to is owned by other objects. Take care
@@ -17191,15 +17329,15 @@
17191 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
17192 u8 op2; /* TK_REGISTER: original value of Expr.op
17193 ** TK_COLUMN: the value of p5 for OP_Column
17194 ** TK_AGG_FUNCTION: nesting depth */
17195 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17196 Table *pTab; /* Table for TK_COLUMN expressions. Can be NULL
17197 ** for a column of an index on an expression */
17198 #ifndef SQLITE_OMIT_WINDOWFUNC
17199 Window *pWin; /* Window definition for window functions */
17200 #endif
17201 };
17202
17203 /*
17204 ** The following are the meanings of bits in the Expr.flags field.
17205 */
@@ -17225,10 +17363,11 @@
17225 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17226 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17227 #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17228 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17229 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
 
17230
17231 /*
17232 ** The EP_Propagate mask is a set of properties that automatically propagate
17233 ** upwards into parent nodes.
17234 */
@@ -17910,10 +18049,11 @@
17910 ** OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
17911 ** OPFLAG_AUXDELETE == BTREE_AUXDELETE
17912 */
17913 #define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
17914 /* Also used in P2 (not P5) of OP_Delete */
 
17915 #define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */
17916 #define OPFLAG_LASTROWID 0x20 /* Set to update db->lastRowid */
17917 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
17918 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
17919 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
@@ -18381,10 +18521,11 @@
18381 /*
18382 ** Internal function prototypes
18383 */
18384 SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
18385 SQLITE_PRIVATE int sqlite3Strlen30(const char*);
 
18386 SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*);
18387 #define sqlite3StrNICmp sqlite3_strnicmp
18388
18389 SQLITE_PRIVATE int sqlite3MallocInit(void);
18390 SQLITE_PRIVATE void sqlite3MallocEnd(void);
@@ -18497,10 +18638,11 @@
18497
18498 #if defined(SQLITE_DEBUG)
18499 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
18500 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
18501 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
 
18502 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
18503 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
18504 #ifndef SQLITE_OMIT_WINDOWFUNC
18505 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
18506 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
@@ -18729,15 +18871,19 @@
18729 #endif
18730 SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
18731 SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
18732 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
18733 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
 
 
 
18734 SQLITE_PRIVATE void sqlite3GenerateRowDelete(
18735 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
18736 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
18737 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
18738 SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
 
18739 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
18740 u8,u8,int,int*,int*,Upsert*);
18741 #ifdef SQLITE_ENABLE_NULL_TRIM
18742 SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
18743 #else
@@ -18754,10 +18900,13 @@
18754 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
18755 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
18756 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
18757 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
18758 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
 
 
 
18759 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
18760 SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
18761 SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
18762 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
18763 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18911,10 +19060,11 @@
18911 SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
18912 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
18913 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
18914 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
18915 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
 
18916 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
18917 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
18918 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
18919 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
18920 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
@@ -18957,10 +19107,13 @@
18957 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
18958 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
18959 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
18960 SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
18961 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
 
 
 
18962 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18963 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
18964 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
18965 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
18966 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
@@ -19114,10 +19267,13 @@
19114 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
19115 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
19116 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
19117 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
19118 SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
 
 
 
19119 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
19120 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
19121 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
19122 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
19123 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
@@ -20066,10 +20222,13 @@
20066 bft bIsReader:1; /* True for statements that read */
20067 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
20068 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
20069 u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
20070 char *zSql; /* Text of the SQL statement that generated this */
 
 
 
20071 void *pFree; /* Free this when deleting the vdbe */
20072 VdbeFrame *pFrame; /* Parent frame */
20073 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
20074 int nFrame; /* Number of frames in pFrame list */
20075 u32 expmask; /* Binding to these vars invalidates VM */
@@ -28294,10 +28453,46 @@
28294 }
28295 sqlite3TreeViewPop(pView);
28296 }
28297 }
28298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28299
28300 /*
28301 ** Generate a human-readable description of a Select object.
28302 */
28303 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
@@ -28348,43 +28543,13 @@
28348 }
28349 sqlite3TreeViewPop(pView);
28350 }
28351 #endif
28352 if( p->pSrc && p->pSrc->nSrc ){
28353 int i;
28354 pView = sqlite3TreeViewPush(pView, (n--)>0);
28355 sqlite3TreeViewLine(pView, "FROM");
28356 for(i=0; i<p->pSrc->nSrc; i++){
28357 struct SrcList_item *pItem = &p->pSrc->a[i];
28358 StrAccum x;
28359 char zLine[100];
28360 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28361 sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28362 if( pItem->zDatabase ){
28363 sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28364 }else if( pItem->zName ){
28365 sqlite3_str_appendf(&x, " %s", pItem->zName);
28366 }
28367 if( pItem->pTab ){
28368 sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
28369 }
28370 if( pItem->zAlias ){
28371 sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
28372 }
28373 if( pItem->fg.jointype & JT_LEFT ){
28374 sqlite3_str_appendf(&x, " LEFT-JOIN");
28375 }
28376 sqlite3StrAccumFinish(&x);
28377 sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1);
28378 if( pItem->pSelect ){
28379 sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
28380 }
28381 if( pItem->fg.isTabFunc ){
28382 sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
28383 }
28384 sqlite3TreeViewPop(pView);
28385 }
28386 sqlite3TreeViewPop(pView);
28387 }
28388 if( p->pWhere ){
28389 sqlite3TreeViewItem(pView, "WHERE", (n--)>0);
28390 sqlite3TreeViewExpr(pView, p->pWhere, 0);
@@ -28670,11 +28835,11 @@
28670 pFarg = 0;
28671 pWin = 0;
28672 }else{
28673 pFarg = pExpr->x.pList;
28674 #ifndef SQLITE_OMIT_WINDOWFUNC
28675 pWin = pExpr->pWin;
28676 #else
28677 pWin = 0;
28678 #endif
28679 }
28680 if( pExpr->op==TK_AGG_FUNCTION ){
@@ -31498,10 +31663,24 @@
31498 h += sqlite3UpperToLower[c];
31499 h *= 0x9e3779b1;
31500 }
31501 return h;
31502 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31503
31504
31505 /* Link pNew element into the hash table pH. If pEntry!=0 then also
31506 ** insert pNew into the pEntry hash bucket.
31507 */
@@ -31609,10 +31788,44 @@
31609 }
31610 elem = elem->next;
31611 }
31612 return &nullElement;
31613 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31614
31615 /* Remove a single entry from the hash table given a pointer to that
31616 ** element and a hash on the element's key.
31617 */
31618 static void removeElementGivenHash(
@@ -31653,10 +31866,18 @@
31653 SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
31654 assert( pH!=0 );
31655 assert( pKey!=0 );
31656 return findElementWithHash(pH, pKey, 0)->data;
31657 }
 
 
 
 
 
 
 
 
31658
31659 /* Insert an element into the hash table pH. The key is pKey
31660 ** and the data is "data".
31661 **
31662 ** If no element exists with a matching key, then a new
@@ -32035,16 +32256,14 @@
32035 ** Allowed values of unixFile.fsFlags
32036 */
32037 #define SQLITE_FSFLAGS_IS_MSDOS 0x1
32038
32039 /*
32040 ** If we are to be thread-safe, include the pthreads header and define
32041 ** the SQLITE_UNIX_THREADS macro.
32042 */
32043 #if SQLITE_THREADSAFE
32044 /* # include <pthread.h> */
32045 # define SQLITE_UNIX_THREADS 1
32046 #endif
32047
32048 /*
32049 ** Default permissions when creating a new file
32050 */
@@ -33216,12 +33435,11 @@
33216 #endif
33217 };
33218
33219 /*
33220 ** An instance of the following structure is allocated for each open
33221 ** inode. Or, on LinuxThreads, there is one of these structures for
33222 ** each inode opened by each thread.
33223 **
33224 ** A single inode can have multiple file descriptors, so each unixFile
33225 ** structure contains a pointer to an instance of this object and this
33226 ** object keeps a count of the number of unixFile pointing to it.
33227 **
@@ -33263,17 +33481,20 @@
33263 #endif
33264 };
33265
33266 /*
33267 ** A lists of all unixInodeInfo objects.
 
 
33268 */
33269 static unixInodeInfo *inodeList = 0; /* All unixInodeInfo objects */
33270
33271 #ifdef SQLITE_DEBUG
33272 /*
33273 ** True if the inode mutex is held, or not. Used only within assert()
33274 ** to help verify correct mutex usage.
 
33275 */
33276 int unixFileMutexHeld(unixFile *pFile){
33277 assert( pFile->pInode );
33278 return sqlite3_mutex_held(pFile->pInode->pLockMutex);
33279 }
@@ -33397,12 +33618,12 @@
33397 }
33398
33399 /*
33400 ** Release a unixInodeInfo structure previously allocated by findInodeInfo().
33401 **
33402 ** The mutex entered using the unixEnterMutex() function must be held
33403 ** when this function is called.
33404 */
33405 static void releaseInodeInfo(unixFile *pFile){
33406 unixInodeInfo *pInode = pFile->pInode;
33407 assert( unixMutexHeld() );
33408 assert( unixFileMutexNotheld(pFile) );
@@ -33433,12 +33654,11 @@
33433 /*
33434 ** Given a file descriptor, locate the unixInodeInfo object that
33435 ** describes that file descriptor. Create a new one if necessary. The
33436 ** return value might be uninitialized if an error occurs.
33437 **
33438 ** The mutex entered using the unixEnterMutex() function must be held
33439 ** when this function is called.
33440 **
33441 ** Return an appropriate error code.
33442 */
33443 static int findInodeInfo(
33444 unixFile *pFile, /* Unix file with file desc used in the key */
@@ -33495,10 +33715,11 @@
33495 #if OS_VXWORKS
33496 fileId.pId = pFile->pId;
33497 #else
33498 fileId.ino = (u64)statbuf.st_ino;
33499 #endif
 
33500 pInode = inodeList;
33501 while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
33502 pInode = pInode->pNext;
33503 }
33504 if( pInode==0 ){
@@ -33514,10 +33735,11 @@
33514 sqlite3_free(pInode);
33515 return SQLITE_NOMEM_BKPT;
33516 }
33517 }
33518 pInode->nRef = 1;
 
33519 pInode->pNext = inodeList;
33520 pInode->pPrev = 0;
33521 if( inodeList ) inodeList->pPrev = pInode;
33522 inodeList = pInode;
33523 }else{
@@ -36311,22 +36533,22 @@
36311 **
36312 ** nRef
36313 **
36314 ** The following fields are read-only after the object is created:
36315 **
36316 ** fid
36317 ** zFilename
36318 **
36319 ** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and
36320 ** unixMutexHeld() is true when reading or writing any other field
36321 ** in this structure.
36322 */
36323 struct unixShmNode {
36324 unixInodeInfo *pInode; /* unixInodeInfo that owns this SHM node */
36325 sqlite3_mutex *mutex; /* Mutex to access this object */
36326 char *zFilename; /* Name of the mmapped file */
36327 int h; /* Open file descriptor */
36328 int szRegion; /* Size of shared-memory regions */
36329 u16 nRegion; /* Size of array apRegion */
36330 u8 isReadonly; /* True if read-only */
36331 u8 isUnlocked; /* True if no DMS lock held */
36332 char **apRegion; /* Array of mapped shared-memory regions */
@@ -36344,20 +36566,20 @@
36344 ** open shared memory connection.
36345 **
36346 ** The following fields are initialized when this object is created and
36347 ** are read-only thereafter:
36348 **
36349 ** unixShm.pFile
36350 ** unixShm.id
36351 **
36352 ** All other fields are read/write. The unixShm.pFile->mutex must be held
36353 ** while accessing any read/write fields.
36354 */
36355 struct unixShm {
36356 unixShmNode *pShmNode; /* The underlying unixShmNode object */
36357 unixShm *pNext; /* Next unixShm with the same unixShmNode */
36358 u8 hasMutex; /* True if holding the unixShmNode mutex */
36359 u8 id; /* Id of this connection within its unixShmNode */
36360 u16 sharedMask; /* Mask of shared locks held */
36361 u16 exclMask; /* Mask of exclusive locks held */
36362 };
36363
@@ -36383,25 +36605,26 @@
36383 struct flock f; /* The posix advisory locking structure */
36384 int rc = SQLITE_OK; /* Result code form fcntl() */
36385
36386 /* Access to the unixShmNode object is serialized by the caller */
36387 pShmNode = pFile->pInode->pShmNode;
36388 assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->mutex) );
 
36389
36390 /* Shared locks never span more than one byte */
36391 assert( n==1 || lockType!=F_RDLCK );
36392
36393 /* Locks are within range */
36394 assert( n>=1 && n<=SQLITE_SHM_NLOCK );
36395
36396 if( pShmNode->h>=0 ){
36397 /* Initialize the locking parameters */
36398 f.l_type = lockType;
36399 f.l_whence = SEEK_SET;
36400 f.l_start = ofst;
36401 f.l_len = n;
36402 rc = osSetPosixAdvisoryLock(pShmNode->h, &f, pFile);
36403 rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
36404 }
36405
36406 /* Update the global lock state and do debug tracing */
36407 #ifdef SQLITE_DEBUG
@@ -36469,22 +36692,22 @@
36469 assert( unixMutexHeld() );
36470 if( p && ALWAYS(p->nRef==0) ){
36471 int nShmPerMap = unixShmRegionPerMap();
36472 int i;
36473 assert( p->pInode==pFd->pInode );
36474 sqlite3_mutex_free(p->mutex);
36475 for(i=0; i<p->nRegion; i+=nShmPerMap){
36476 if( p->h>=0 ){
36477 osMunmap(p->apRegion[i], p->szRegion);
36478 }else{
36479 sqlite3_free(p->apRegion[i]);
36480 }
36481 }
36482 sqlite3_free(p->apRegion);
36483 if( p->h>=0 ){
36484 robust_close(pFd, p->h, __LINE__);
36485 p->h = -1;
36486 }
36487 p->pInode->pShmNode = 0;
36488 sqlite3_free(p);
36489 }
36490 }
@@ -36522,19 +36745,24 @@
36522 ** system crash, the database itself may also become corrupt. */
36523 lock.l_whence = SEEK_SET;
36524 lock.l_start = UNIX_SHM_DMS;
36525 lock.l_len = 1;
36526 lock.l_type = F_WRLCK;
36527 if( osFcntl(pShmNode->h, F_GETLK, &lock)!=0 ) {
36528 rc = SQLITE_IOERR_LOCK;
36529 }else if( lock.l_type==F_UNLCK ){
36530 if( pShmNode->isReadonly ){
36531 pShmNode->isUnlocked = 1;
36532 rc = SQLITE_READONLY_CANTINIT;
36533 }else{
36534 rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);
36535 if( rc==SQLITE_OK && robust_ftruncate(pShmNode->h, 0) ){
 
 
 
 
 
36536 rc = unixLogError(SQLITE_IOERR_SHMOPEN,"ftruncate",pShmNode->zFilename);
36537 }
36538 }
36539 }else if( lock.l_type==F_WRLCK ){
36540 rc = SQLITE_BUSY;
@@ -36636,28 +36864,28 @@
36636 (u32)sStat.st_ino, (u32)sStat.st_dev);
36637 #else
36638 sqlite3_snprintf(nShmFilename, zShm, "%s-shm", zBasePath);
36639 sqlite3FileSuffix3(pDbFd->zPath, zShm);
36640 #endif
36641 pShmNode->h = -1;
36642 pDbFd->pInode->pShmNode = pShmNode;
36643 pShmNode->pInode = pDbFd->pInode;
36644 if( sqlite3GlobalConfig.bCoreMutex ){
36645 pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
36646 if( pShmNode->mutex==0 ){
36647 rc = SQLITE_NOMEM_BKPT;
36648 goto shm_open_err;
36649 }
36650 }
36651
36652 if( pInode->bProcessLock==0 ){
36653 if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
36654 pShmNode->h = robust_open(zShm, O_RDWR|O_CREAT, (sStat.st_mode&0777));
36655 }
36656 if( pShmNode->h<0 ){
36657 pShmNode->h = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
36658 if( pShmNode->h<0 ){
36659 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
36660 goto shm_open_err;
36661 }
36662 pShmNode->isReadonly = 1;
36663 }
@@ -36664,11 +36892,11 @@
36664
36665 /* If this process is running as root, make sure that the SHM file
36666 ** is owned by the same user that owns the original database. Otherwise,
36667 ** the original owner will not be able to connect.
36668 */
36669 robustFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);
36670
36671 rc = unixLockSharedMemory(pDbFd, pShmNode);
36672 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
36673 }
36674 }
@@ -36684,17 +36912,17 @@
36684
36685 /* The reference count on pShmNode has already been incremented under
36686 ** the cover of the unixEnterMutex() mutex and the pointer from the
36687 ** new (struct unixShm) object to the pShmNode has been set. All that is
36688 ** left to do is to link the new object into the linked list starting
36689 ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex
36690 ** mutex.
36691 */
36692 sqlite3_mutex_enter(pShmNode->mutex);
36693 p->pNext = pShmNode->pFirst;
36694 pShmNode->pFirst = p;
36695 sqlite3_mutex_leave(pShmNode->mutex);
36696 return rc;
36697
36698 /* Jump here on any error */
36699 shm_open_err:
36700 unixShmPurge(pDbFd); /* This call frees pShmNode if required */
@@ -36742,20 +36970,20 @@
36742 if( rc!=SQLITE_OK ) return rc;
36743 }
36744
36745 p = pDbFd->pShm;
36746 pShmNode = p->pShmNode;
36747 sqlite3_mutex_enter(pShmNode->mutex);
36748 if( pShmNode->isUnlocked ){
36749 rc = unixLockSharedMemory(pDbFd, pShmNode);
36750 if( rc!=SQLITE_OK ) goto shmpage_out;
36751 pShmNode->isUnlocked = 0;
36752 }
36753 assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
36754 assert( pShmNode->pInode==pDbFd->pInode );
36755 assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
36756 assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
36757
36758 /* Minimum number of regions required to be mapped. */
36759 nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;
36760
36761 if( pShmNode->nRegion<nReqRegion ){
@@ -36763,16 +36991,16 @@
36763 int nByte = nReqRegion*szRegion; /* Minimum required file size */
36764 struct stat sStat; /* Used by fstat() */
36765
36766 pShmNode->szRegion = szRegion;
36767
36768 if( pShmNode->h>=0 ){
36769 /* The requested region is not mapped into this processes address space.
36770 ** Check to see if it has been allocated (i.e. if the wal-index file is
36771 ** large enough to contain the requested region).
36772 */
36773 if( osFstat(pShmNode->h, &sStat) ){
36774 rc = SQLITE_IOERR_SHMSIZE;
36775 goto shmpage_out;
36776 }
36777
36778 if( sStat.st_size<nByte ){
@@ -36796,11 +37024,11 @@
36796
36797 /* Write to the last byte of each newly allocated or extended page */
36798 assert( (nByte % pgsz)==0 );
36799 for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){
36800 int x = 0;
36801 if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, "", 1, &x)!=1 ){
36802 const char *zFile = pShmNode->zFilename;
36803 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "write", zFile);
36804 goto shmpage_out;
36805 }
36806 }
@@ -36819,26 +37047,26 @@
36819 pShmNode->apRegion = apNew;
36820 while( pShmNode->nRegion<nReqRegion ){
36821 int nMap = szRegion*nShmPerMap;
36822 int i;
36823 void *pMem;
36824 if( pShmNode->h>=0 ){
36825 pMem = osMmap(0, nMap,
36826 pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
36827 MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion
36828 );
36829 if( pMem==MAP_FAILED ){
36830 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
36831 goto shmpage_out;
36832 }
36833 }else{
36834 pMem = sqlite3_malloc64(szRegion);
36835 if( pMem==0 ){
36836 rc = SQLITE_NOMEM_BKPT;
36837 goto shmpage_out;
36838 }
36839 memset(pMem, 0, szRegion);
36840 }
36841
36842 for(i=0; i<nShmPerMap; i++){
36843 pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
36844 }
@@ -36851,11 +37079,11 @@
36851 *pp = pShmNode->apRegion[iRegion];
36852 }else{
36853 *pp = 0;
36854 }
36855 if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;
36856 sqlite3_mutex_leave(pShmNode->mutex);
36857 return rc;
36858 }
36859
36860 /*
36861 ** Change the lock state for a shared-memory segment.
@@ -36885,16 +37113,16 @@
36885 assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
36886 || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
36887 || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
36888 || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
36889 assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
36890 assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );
36891 assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );
36892
36893 mask = (1<<(ofst+n)) - (1<<ofst);
36894 assert( n>1 || mask==(1<<ofst) );
36895 sqlite3_mutex_enter(pShmNode->mutex);
36896 if( flags & SQLITE_SHM_UNLOCK ){
36897 u16 allMask = 0; /* Mask of locks held by siblings */
36898
36899 /* See if any siblings hold this same lock */
36900 for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
@@ -36963,11 +37191,11 @@
36963 assert( (p->sharedMask & mask)==0 );
36964 p->exclMask |= mask;
36965 }
36966 }
36967 }
36968 sqlite3_mutex_leave(pShmNode->mutex);
36969 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
36970 p->id, osGetpid(0), p->sharedMask, p->exclMask));
36971 return rc;
36972 }
36973
@@ -37013,27 +37241,27 @@
37013 assert( pShmNode==pDbFd->pInode->pShmNode );
37014 assert( pShmNode->pInode==pDbFd->pInode );
37015
37016 /* Remove connection p from the set of connections associated
37017 ** with pShmNode */
37018 sqlite3_mutex_enter(pShmNode->mutex);
37019 for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
37020 *pp = p->pNext;
37021
37022 /* Free the connection p */
37023 sqlite3_free(p);
37024 pDbFd->pShm = 0;
37025 sqlite3_mutex_leave(pShmNode->mutex);
37026
37027 /* If pShmNode->nRef has reached 0, then close the underlying
37028 ** shared-memory file, too */
37029 assert( unixFileMutexNotheld(pDbFd) );
37030 unixEnterMutex();
37031 assert( pShmNode->nRef>0 );
37032 pShmNode->nRef--;
37033 if( pShmNode->nRef==0 ){
37034 if( deleteFlag && pShmNode->h>=0 ){
37035 osUnlink(pShmNode->zFilename);
37036 }
37037 unixShmPurge(pDbFd);
37038 }
37039 unixLeaveMutex();
@@ -47321,11 +47549,11 @@
47321 ** pDirtyTail to the last (oldest).
47322 **
47323 ** The PCache.pSynced variable is used to optimize searching for a dirty
47324 ** page to eject from the cache mid-transaction. It is better to eject
47325 ** a page that does not require a journal sync than one that does.
47326 ** Therefore, pSynced is maintained to that it *almost* always points
47327 ** to either the oldest page in the pDirty/pDirtyTail list that has a
47328 ** clear PGHDR_NEED_SYNC flag or to a page that is older than this one
47329 ** (so that the right page to eject can be found by following pDirtyPrev
47330 ** pointers).
47331 */
@@ -57104,10 +57332,11 @@
57104 void *(*xCodec)(void*,void*,Pgno,int),
57105 void (*xCodecSizeChng)(void*,int,int),
57106 void (*xCodecFree)(void*),
57107 void *pCodec
57108 ){
 
57109 if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
57110 pPager->xCodec = pPager->memDb ? 0 : xCodec;
57111 pPager->xCodecSizeChng = xCodecSizeChng;
57112 pPager->xCodecFree = xCodecFree;
57113 pPager->pCodec = pCodec;
@@ -65764,11 +65993,11 @@
65764 freeTempSpace(pBt);
65765 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
65766 pageSize-usableSize);
65767 return rc;
65768 }
65769 if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){
65770 rc = SQLITE_CORRUPT_BKPT;
65771 goto page1_init_failed;
65772 }
65773 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
65774 ** be less than 480. In other words, if the page size is 512, then the
@@ -66238,10 +66467,11 @@
66238
66239 assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 ||
66240 eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );
66241 assert( sqlite3_mutex_held(pBt->mutex) );
66242 assert( pDbPage->pBt==pBt );
 
66243
66244 /* Move page iDbPage from its current location to page number iFreePage */
66245 TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
66246 iDbPage, iFreePage, iPtrPage, eType));
66247 rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
@@ -74033,11 +74263,12 @@
74033 sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
74034 }else{
74035 assert( fg & MEM_Real );
74036 sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
74037 }
74038 pMem->n = sqlite3Strlen30(pMem->z);
 
74039 pMem->enc = SQLITE_UTF8;
74040 pMem->flags |= MEM_Str|MEM_Term;
74041 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
74042 sqlite3VdbeChangeEncoding(pMem, enc);
74043 return SQLITE_OK;
@@ -75608,10 +75839,17 @@
75608 if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
75609 p->expmask = 0;
75610 }
75611 assert( p->zSql==0 );
75612 p->zSql = sqlite3DbStrNDup(p->db, z, n);
 
 
 
 
 
 
 
75613 }
75614
75615 /*
75616 ** Swap all content between two VDBE structures.
75617 */
@@ -75629,10 +75867,15 @@
75629 pA->pPrev = pB->pPrev;
75630 pB->pPrev = pTmp;
75631 zTmp = pA->zSql;
75632 pA->zSql = pB->zSql;
75633 pB->zSql = zTmp;
 
 
 
 
 
75634 pB->expmask = pA->expmask;
75635 pB->prepFlags = pA->prepFlags;
75636 memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
75637 pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
75638 }
@@ -78700,10 +78943,13 @@
78700 sqlite3DbFree(db, p->pFree);
78701 }
78702 vdbeFreeOpArray(db, p->aOp, p->nOp);
78703 sqlite3DbFree(db, p->aColName);
78704 sqlite3DbFree(db, p->zSql);
 
 
 
78705 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
78706 {
78707 int i;
78708 for(i=0; i<p->nScan; i++){
78709 sqlite3DbFree(db, p->aScan[i].zName);
@@ -80101,11 +80347,13 @@
80101
80102 /* The index entry must begin with a header size */
80103 (void)getVarint32((u8*)m.z, szHdr);
80104 testcase( szHdr==3 );
80105 testcase( szHdr==m.n );
80106 if( unlikely(szHdr<3 || (int)szHdr>m.n) ){
 
 
80107 goto idx_rowid_corruption;
80108 }
80109
80110 /* The last field of the index should be an integer - the ROWID.
80111 ** Verify that the last entry really is an integer. */
@@ -82112,10 +82360,20 @@
82112 }
82113 return z;
82114 #endif
82115 }
82116
 
 
 
 
 
 
 
 
 
 
82117 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
82118 /*
82119 ** Allocate and populate an UnpackedRecord structure based on the serialized
82120 ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
82121 ** if successful, or a NULL pointer if an OOM error is encountered.
@@ -85551,21 +85809,29 @@
85551 nVarint = sqlite3VarintLen(nHdr);
85552 nHdr += nVarint;
85553 if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
85554 }
85555 nByte = nHdr+nData;
85556 if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
85557 goto too_big;
85558 }
85559
85560 /* Make sure the output register has a buffer large enough to store
85561 ** the new record. The output register (pOp->p3) is not allowed to
85562 ** be one of the input registers (because the following call to
85563 ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).
85564 */
85565 if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){
85566 goto no_mem;
 
 
 
 
 
 
 
 
 
 
 
85567 }
85568 zNewRecord = (u8 *)pOut->z;
85569
85570 /* Write the record */
85571 i = putVarint32(zNewRecord, nHdr);
@@ -88417,11 +88683,11 @@
88417 }else
88418 #endif
88419 {
88420 zMaster = MASTER_NAME;
88421 initData.db = db;
88422 initData.iDb = pOp->p1;
88423 initData.pzErrMsg = &p->zErrMsg;
88424 initData.mInitFlags = 0;
88425 zSql = sqlite3MPrintf(db,
88426 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
88427 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
@@ -89614,14 +89880,15 @@
89614 ** Store in register P3 the value of the P2-th column of
89615 ** the current row of the virtual-table of cursor P1.
89616 **
89617 ** If the VColumn opcode is being used to fetch the value of
89618 ** an unchanging column during an UPDATE operation, then the P5
89619 ** value is 1. Otherwise, P5 is 0. The P5 value is returned
89620 ** by sqlite3_vtab_nochange() routine and can be used
89621 ** by virtual table implementations to return special "no-change"
89622 ** marks which can be more efficient, depending on the virtual table.
 
89623 */
89624 case OP_VColumn: {
89625 sqlite3_vtab *pVtab;
89626 const sqlite3_module *pModule;
89627 Mem *pDest;
@@ -89639,11 +89906,12 @@
89639 pVtab = pCur->uc.pVCur->pVtab;
89640 pModule = pVtab->pModule;
89641 assert( pModule->xColumn );
89642 memset(&sContext, 0, sizeof(sContext));
89643 sContext.pOut = pDest;
89644 if( pOp->p5 ){
 
89645 sqlite3VdbeMemSetNull(pDest);
89646 pDest->flags = MEM_Null|MEM_Zero;
89647 pDest->u.nZero = 0;
89648 }else{
89649 MemSetTypeFlag(pDest, MEM_Null);
@@ -93998,12 +94266,12 @@
93998 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
93999 }else if( pExpr->x.pList ){
94000 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
94001 }
94002 #ifndef SQLITE_OMIT_WINDOWFUNC
94003 if( !ExprHasProperty(pExpr, EP_Reduced) && pExpr->pWin ){
94004 Window *pWin = pExpr->pWin;
94005 if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
94006 if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
94007 if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
94008 }
94009 #endif
@@ -94272,11 +94540,11 @@
94272 **
94273 ** pExpr->iDb Set the index in db->aDb[] of the database X
94274 ** (even if X is implied).
94275 ** pExpr->iTable Set to the cursor number for the table obtained
94276 ** from pSrcList.
94277 ** pExpr->pTab Points to the Table structure of X.Y (even if
94278 ** X and/or Y are implied.)
94279 ** pExpr->iColumn Set to the column number within the table.
94280 ** pExpr->op Set to TK_COLUMN.
94281 ** pExpr->pLeft Any expression this points to is deleted
94282 ** pExpr->pRight Any expression this points to is deleted.
@@ -94316,11 +94584,10 @@
94316 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
94317 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
94318
94319 /* Initialize the node to no-match */
94320 pExpr->iTable = -1;
94321 pExpr->pTab = 0;
94322 ExprSetVVAProperty(pExpr, EP_NoReduce);
94323
94324 /* Translate the schema name in zDb into a pointer to the corresponding
94325 ** schema. If not found, pSchema will remain NULL and nothing will match
94326 ** resulting in an appropriate error message toward the end of this routine
@@ -94378,11 +94645,11 @@
94378 assert( zTabName!=0 );
94379 if( sqlite3StrICmp(zTabName, zTab)!=0 ){
94380 continue;
94381 }
94382 if( IN_RENAME_OBJECT && pItem->zAlias ){
94383 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->pTab);
94384 }
94385 }
94386 if( 0==(cntTab++) ){
94387 pMatch = pItem;
94388 }
@@ -94404,17 +94671,17 @@
94404 }
94405 }
94406 }
94407 if( pMatch ){
94408 pExpr->iTable = pMatch->iCursor;
94409 pExpr->pTab = pMatch->pTab;
94410 /* RIGHT JOIN not (yet) supported */
94411 assert( (pMatch->fg.jointype & JT_RIGHT)==0 );
94412 if( (pMatch->fg.jointype & JT_LEFT)!=0 ){
94413 ExprSetProperty(pExpr, EP_CanBeNull);
94414 }
94415 pSchema = pExpr->pTab->pSchema;
94416 }
94417 } /* if( pSrcList ) */
94418
94419 #if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
94420 /* If we have not already resolved the name, then maybe
@@ -94467,11 +94734,11 @@
94467 #ifndef SQLITE_OMIT_UPSERT
94468 if( pExpr->iTable==2 ){
94469 testcase( iCol==(-1) );
94470 if( IN_RENAME_OBJECT ){
94471 pExpr->iColumn = iCol;
94472 pExpr->pTab = pTab;
94473 eNewExprOp = TK_COLUMN;
94474 }else{
94475 pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94476 eNewExprOp = TK_REGISTER;
94477 ExprSetProperty(pExpr, EP_Alias);
@@ -94489,11 +94756,11 @@
94489 }else{
94490 testcase( iCol==31 );
94491 testcase( iCol==32 );
94492 pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
94493 }
94494 pExpr->pTab = pTab;
94495 pExpr->iColumn = (i16)iCol;
94496 eNewExprOp = TK_TRIGGER;
94497 #endif /* SQLITE_OMIT_TRIGGER */
94498 }
94499 }
@@ -94589,11 +94856,11 @@
94589 */
94590 if( cnt==0 && zTab==0 ){
94591 assert( pExpr->op==TK_ID );
94592 if( ExprHasProperty(pExpr,EP_DblQuoted) ){
94593 pExpr->op = TK_STRING;
94594 pExpr->pTab = 0;
94595 return WRC_Prune;
94596 }
94597 if( sqlite3ExprIdToTrueFalse(pExpr) ){
94598 return WRC_Prune;
94599 }
@@ -94667,13 +94934,13 @@
94667 */
94668 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
94669 Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
94670 if( p ){
94671 struct SrcList_item *pItem = &pSrc->a[iSrc];
94672 p->pTab = pItem->pTab;
94673 p->iTable = pItem->iCursor;
94674 if( p->pTab->iPKey==iCol ){
94675 p->iColumn = -1;
94676 }else{
94677 p->iColumn = (ynVar)iCol;
94678 testcase( iCol==BMS );
94679 testcase( iCol==BMS-1 );
@@ -94759,11 +95026,11 @@
94759 struct SrcList_item *pItem;
94760 assert( pSrcList && pSrcList->nSrc==1 );
94761 pItem = pSrcList->a;
94762 assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
94763 pExpr->op = TK_COLUMN;
94764 pExpr->pTab = pItem->pTab;
94765 pExpr->iTable = pItem->iCursor;
94766 pExpr->iColumn = -1;
94767 pExpr->affinity = SQLITE_AFF_INTEGER;
94768 break;
94769 }
@@ -94803,13 +95070,11 @@
94803 }
94804 zTable = pLeft->u.zToken;
94805 zColumn = pRight->u.zToken;
94806 if( IN_RENAME_OBJECT ){
94807 sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
94808 }
94809 if( IN_RENAME_OBJECT ){
94810 sqlite3RenameTokenRemap(pParse, (void*)&pExpr->pTab, (void*)pLeft);
94811 }
94812 }
94813 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
94814 }
94815
@@ -94895,22 +95160,22 @@
94895 #ifndef SQLITE_OMIT_WINDOWFUNC
94896 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94897 || (pDef->xValue==0 && pDef->xInverse==0)
94898 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94899 );
94900 if( pDef && pDef->xValue==0 && pExpr->pWin ){
94901 sqlite3ErrorMsg(pParse,
94902 "%.*s() may not be used as a window function", nId, zId
94903 );
94904 pNC->nErr++;
94905 }else if(
94906 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94907 || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94908 || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94909 ){
94910 const char *zType;
94911 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94912 zType = "window";
94913 }else{
94914 zType = "aggregate";
94915 }
94916 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -94936,30 +95201,30 @@
94936 nId, zId);
94937 pNC->nErr++;
94938 }
94939 if( is_agg ){
94940 #ifndef SQLITE_OMIT_WINDOWFUNC
94941 pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94942 #else
94943 pNC->ncFlags &= ~NC_AllowAgg;
94944 #endif
94945 }
94946 }
94947 sqlite3WalkExprList(pWalker, pList);
94948 if( is_agg ){
94949 #ifndef SQLITE_OMIT_WINDOWFUNC
94950 if( pExpr->pWin ){
94951 Select *pSel = pNC->pWinSelect;
94952 sqlite3WalkExprList(pWalker, pExpr->pWin->pPartition);
94953 sqlite3WalkExprList(pWalker, pExpr->pWin->pOrderBy);
94954 sqlite3WalkExpr(pWalker, pExpr->pWin->pFilter);
94955 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->pWin, pDef);
94956 if( 0==pSel->pWin
94957 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->pWin)
94958 ){
94959 pExpr->pWin->pNextWin = pSel->pWin;
94960 pSel->pWin = pExpr->pWin;
94961 }
94962 pNC->ncFlags |= NC_AllowWin;
94963 }else
94964 #endif /* SQLITE_OMIT_WINDOWFUNC */
94965 {
@@ -95378,17 +95643,17 @@
95378 return 1;
95379 }
95380 for(j=0; j<pSelect->pEList->nExpr; j++){
95381 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
95382 #ifndef SQLITE_OMIT_WINDOWFUNC
95383 if( pE->pWin ){
95384 /* Since this window function is being changed into a reference
95385 ** to the same window function the result set, remove the instance
95386 ** of this window function from the Select.pWin list. */
95387 Window **pp;
95388 for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
95389 if( *pp==pE->pWin ){
95390 *pp = (*pp)->pNextWin;
95391 }
95392 }
95393 }
95394 #endif
@@ -95847,12 +96112,12 @@
95847 if( op==TK_CAST ){
95848 assert( !ExprHasProperty(pExpr, EP_IntValue) );
95849 return sqlite3AffinityType(pExpr->u.zToken, 0);
95850 }
95851 #endif
95852 if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){
95853 return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
95854 }
95855 if( op==TK_SELECT_COLUMN ){
95856 assert( pExpr->pLeft->flags&EP_xIsSelect );
95857 return sqlite3ExprAffinity(
95858 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
@@ -95932,17 +96197,17 @@
95932 while( p ){
95933 int op = p->op;
95934 if( p->flags & EP_Generic ) break;
95935 if( (op==TK_AGG_COLUMN || op==TK_COLUMN
95936 || op==TK_REGISTER || op==TK_TRIGGER)
95937 && p->pTab!=0
95938 ){
95939 /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
95940 ** a TK_COLUMN but was previously evaluated and cached in a register */
95941 int j = p->iColumn;
95942 if( j>=0 ){
95943 const char *zColl = p->pTab->aCol[j].zColl;
95944 pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
95945 }
95946 break;
95947 }
95948 if( op==TK_CAST || op==TK_UPLUS ){
@@ -96841,10 +97106,14 @@
96841 */
96842 static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
96843 assert( p!=0 );
96844 /* Sanity check: Assert that the IntValue is non-negative if it exists */
96845 assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
 
 
 
 
96846 #ifdef SQLITE_DEBUG
96847 if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){
96848 assert( p->pLeft==0 );
96849 assert( p->pRight==0 );
96850 assert( p->x.pSelect==0 );
@@ -96859,12 +97128,13 @@
96859 }else if( ExprHasProperty(p, EP_xIsSelect) ){
96860 sqlite3SelectDelete(db, p->x.pSelect);
96861 }else{
96862 sqlite3ExprListDelete(db, p->x.pList);
96863 }
96864 if( !ExprHasProperty(p, EP_Reduced) ){
96865 sqlite3WindowDelete(db, p->pWin);
 
96866 }
96867 }
96868 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
96869 if( !ExprHasProperty(p, EP_Static) ){
96870 sqlite3DbFreeNN(db, p);
@@ -96924,11 +97194,11 @@
96924 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
96925 assert( EXPR_FULLSIZE<=0xfff );
96926 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
96927 if( 0==flags || p->op==TK_SELECT_COLUMN
96928 #ifndef SQLITE_OMIT_WINDOWFUNC
96929 || p->pWin
96930 #endif
96931 ){
96932 nSize = EXPR_FULLSIZE;
96933 }else{
96934 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
@@ -96951,11 +97221,11 @@
96951 ** string is defined.)
96952 */
96953 static int dupedExprNodeSize(Expr *p, int flags){
96954 int nByte = dupedExprStructSize(p, flags) & 0xfff;
96955 if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
96956 nByte += sqlite3Strlen30(p->u.zToken)+1;
96957 }
96958 return ROUND8(nByte);
96959 }
96960
96961 /*
@@ -97054,26 +97324,28 @@
97054 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);
97055 }
97056 }
97057
97058 /* Fill in pNew->pLeft and pNew->pRight. */
97059 zAlloc += dupedExprNodeSize(p, dupFlags);
97060 if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
97061 if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
97062 pNew->pLeft = p->pLeft ?
97063 exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
97064 pNew->pRight = p->pRight ?
97065 exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
97066 }
97067 }else{
97068 #ifndef SQLITE_OMIT_WINDOWFUNC
97069 if( ExprHasProperty(p, EP_Reduced|EP_TokenOnly) ){
97070 pNew->pWin = 0;
97071 }else{
97072 pNew->pWin = sqlite3WindowDup(db, pNew, p->pWin);
97073 }
97074 #endif /* SQLITE_OMIT_WINDOWFUNC */
 
 
 
 
97075 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
97076 if( pNew->op==TK_SELECT_COLUMN ){
97077 pNew->pLeft = p->pLeft;
97078 assert( p->iColumn==0 || p->pRight==0 );
97079 assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -97081,13 +97353,10 @@
97081 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
97082 }
97083 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
97084 }
97085 }
97086 if( pzBuffer ){
97087 *pzBuffer = zAlloc;
97088 }
97089 }
97090 return pNew;
97091 }
97092
97093 /*
@@ -97878,12 +98147,12 @@
97878 case TK_FLOAT:
97879 case TK_BLOB:
97880 return 0;
97881 case TK_COLUMN:
97882 return ExprHasProperty(p, EP_CanBeNull) ||
97883 p->pTab==0 || /* Reference to column of index on expression */
97884 (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);
97885 default:
97886 return 1;
97887 }
97888 }
97889
@@ -97934,10 +98203,18 @@
97934 if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1;
97935 if( sqlite3StrICmp(z, "ROWID")==0 ) return 1;
97936 if( sqlite3StrICmp(z, "OID")==0 ) return 1;
97937 return 0;
97938 }
 
 
 
 
 
 
 
 
97939
97940 /*
97941 ** pX is the RHS of an IN operator. If pX is a SELECT statement
97942 ** that can be simplified to a direct table access, then return
97943 ** a pointer to the SELECT statement. If pX is not a SELECT statement,
@@ -99167,11 +99444,11 @@
99167 ** expresssion. However, make sure the constant has the correct
99168 ** datatype by applying the Affinity of the table column to the
99169 ** constant.
99170 */
99171 int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
99172 int aff = sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
99173 if( aff!=SQLITE_AFF_BLOB ){
99174 static const char zAff[] = "B\000C\000D\000E";
99175 assert( SQLITE_AFF_BLOB=='A' );
99176 assert( SQLITE_AFF_TEXT=='B' );
99177 if( iReg!=target ){
@@ -99191,11 +99468,11 @@
99191 /* Coding an expression that is part of an index where column names
99192 ** in the index refer to the table to which the index belongs */
99193 iTab = pParse->iSelfTab - 1;
99194 }
99195 }
99196 return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
99197 pExpr->iColumn, iTab, target,
99198 pExpr->op2);
99199 }
99200 case TK_INTEGER: {
99201 codeInteger(pParse, pExpr, 0, target);
@@ -99405,12 +99682,12 @@
99405 sqlite3 *db = pParse->db; /* The database connection */
99406 u8 enc = ENC(db); /* The text encoding used by this database */
99407 CollSeq *pColl = 0; /* A collating sequence */
99408
99409 #ifndef SQLITE_OMIT_WINDOWFUNC
99410 if( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) && pExpr->pWin ){
99411 return pExpr->pWin->regResult;
99412 }
99413 #endif
99414
99415 if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
99416 /* SQL functions can be expensive. So try to move constant functions
@@ -99649,11 +99926,11 @@
99649 **
99650 ** p1==0 -> old.rowid p1==3 -> new.rowid
99651 ** p1==1 -> old.a p1==4 -> new.a
99652 ** p1==2 -> old.b p1==5 -> new.b
99653 */
99654 Table *pTab = pExpr->pTab;
99655 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
99656
99657 assert( pExpr->iTable==0 || pExpr->iTable==1 );
99658 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
99659 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
@@ -99660,11 +99937,11 @@
99660 assert( p1>=0 && p1<(pTab->nCol*2+2) );
99661
99662 sqlite3VdbeAddOp2(v, OP_Param, p1, target);
99663 VdbeComment((v, "r[%d]=%s.%s", target,
99664 (pExpr->iTable ? "new" : "old"),
99665 (pExpr->iColumn<0 ? "rowid" : pExpr->pTab->aCol[pExpr->iColumn].zName)
99666 ));
99667
99668 #ifndef SQLITE_OMIT_FLOATING_POINT
99669 /* If the column has REAL affinity, it may currently be stored as an
99670 ** integer. Use OP_RealAffinity to make sure it is really real.
@@ -100511,10 +100788,24 @@
100511 return 2;
100512 }
100513 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
100514 if( pA->op==TK_FUNCTION ){
100515 if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100516 }else if( pA->op==TK_COLLATE ){
100517 if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
100518 }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
100519 return 2;
100520 }
@@ -100530,25 +100821,10 @@
100530 if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
100531 if( pA->iColumn!=pB->iColumn ) return 2;
100532 if( pA->iTable!=pB->iTable
100533 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
100534 }
100535 #ifndef SQLITE_OMIT_WINDOWFUNC
100536 /* Justification for the assert():
100537 ** window functions have p->op==TK_FUNCTION but aggregate functions
100538 ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100539 ** function and a window function should have failed before reaching
100540 ** this point. And, it is not possible to have a window function and
100541 ** a scalar function with the same name and number of arguments. So
100542 ** if we reach this point, either A and B both window functions or
100543 ** neither are a window functions. */
100544 assert( (pA->pWin==0)==(pB->pWin==0) );
100545
100546 if( pA->pWin!=0 ){
100547 if( sqlite3WindowCompare(pParse,pA->pWin,pB->pWin)!=0 ) return 2;
100548 }
100549 #endif
100550 }
100551 return 0;
100552 }
100553
100554 /*
@@ -100685,12 +100961,12 @@
100685 testcase( pExpr->op==TK_NE );
100686 testcase( pExpr->op==TK_LT );
100687 testcase( pExpr->op==TK_LE );
100688 testcase( pExpr->op==TK_GT );
100689 testcase( pExpr->op==TK_GE );
100690 if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
100691 || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
100692 ){
100693 return WRC_Prune;
100694 }
100695 default:
100696 return WRC_Continue;
@@ -100917,11 +101193,11 @@
100917 }
100918 if( (k>=pAggInfo->nColumn)
100919 && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0
100920 ){
100921 pCol = &pAggInfo->aCol[k];
100922 pCol->pTab = pExpr->pTab;
100923 pCol->iTable = pExpr->iTable;
100924 pCol->iColumn = pExpr->iColumn;
100925 pCol->iMem = ++pParse->nMem;
100926 pCol->iSorterColumn = -1;
100927 pCol->pExpr = pExpr;
@@ -101936,11 +102212,11 @@
101936 && pWalker->pParse->pTriggerTab==p->pTab
101937 ){
101938 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101939 }else if( pExpr->op==TK_COLUMN
101940 && pExpr->iColumn==p->iCol
101941 && p->pTab==pExpr->pTab
101942 ){
101943 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101944 }
101945 return WRC_Continue;
101946 }
@@ -102194,13 +102470,18 @@
102194 assert( pNew->pTabSchema );
102195 pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
102196 db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName
102197 );
102198 pParse->eTriggerOp = pNew->op;
 
 
 
 
 
102199
102200 /* Resolve symbols in WHEN clause */
102201 if( pNew->pWhen ){
102202 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
102203 }
102204
102205 for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
102206 if( pStep->pSelect ){
@@ -102474,12 +102755,12 @@
102474 /*
102475 ** Walker expression callback used by "RENAME TABLE".
102476 */
102477 static int renameTableExprCb(Walker *pWalker, Expr *pExpr){
102478 RenameCtx *p = pWalker->u.pRename;
102479 if( pExpr->op==TK_COLUMN && p->pTab==pExpr->pTab ){
102480 renameTokenFind(pWalker->pParse, p, (void*)&pExpr->pTab);
102481 }
102482 return WRC_Continue;
102483 }
102484
102485 /*
@@ -102572,11 +102853,11 @@
102572 sqlite3WalkSelect(&sWalker, pTab->pSelect);
102573 }
102574 }else{
102575 /* Modify any FK definitions to point to the new table. */
102576 #ifndef SQLITE_OMIT_FOREIGN_KEY
102577 if( db->flags & SQLITE_ForeignKeys ){
102578 FKey *pFKey;
102579 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102580 if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102581 renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102582 }
@@ -105457,10 +105738,11 @@
105457 int iSrc; /* Index in pTabList->a[] of table being read */
105458 int iDb; /* The index of the database the expression refers to */
105459 int iCol; /* Index of column in table */
105460
105461 assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
 
105462 if( db->xAuth==0 ) return;
105463 iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
105464 if( iDb<0 ){
105465 /* An attempt to read a column out of a subquery or other
105466 ** temporary table. */
@@ -105513,10 +105795,11 @@
105513 int rc;
105514
105515 /* Don't do any authorization checks if the database is initialising
105516 ** or if the parser is being invoked from within sqlite3_declare_vtab.
105517 */
 
105518 if( db->init.busy || IN_SPECIAL_PARSE ){
105519 return SQLITE_OK;
105520 }
105521
105522 if( db->xAuth==0 ){
@@ -105936,21 +106219,19 @@
105936
105937 p = sqlite3FindTable(db, zName, zDbase);
105938 if( p==0 ){
105939 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
105940 #ifndef SQLITE_OMIT_VIRTUALTABLE
105941 if( sqlite3FindDbName(db, zDbase)<1 ){
105942 /* If zName is the not the name of a table in the schema created using
105943 ** CREATE, then check to see if it is the name of an virtual table that
105944 ** can be an eponymous virtual table. */
105945 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
105946 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
105947 pMod = sqlite3PragmaVtabRegister(db, zName);
105948 }
105949 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
105950 return pMod->pEpoTab;
105951 }
105952 }
105953 #endif
105954 if( (flags & LOCATE_NOERR)==0 ){
105955 if( zDbase ){
105956 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
@@ -106213,10 +106494,16 @@
106213 /* Delete any foreign keys attached to this table. */
106214 sqlite3FkDelete(db, pTable);
106215
106216 /* Delete the Table structure itself.
106217 */
 
 
 
 
 
 
106218 sqlite3DeleteColumnNames(db, pTable);
106219 sqlite3DbFree(db, pTable->zName);
106220 sqlite3DbFree(db, pTable->zColAff);
106221 sqlite3SelectDelete(db, pTable->pSelect);
106222 sqlite3ExprListDelete(db, pTable->pCheck);
@@ -106370,10 +106657,24 @@
106370 iDb = db->init.iDb;
106371 *pUnqual = pName1;
106372 }
106373 return iDb;
106374 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106375
106376 /*
106377 ** This routine is used to check if the UTF-8 string zName is a legal
106378 ** unqualified name for a new schema object (table, index, view or
106379 ** trigger). All names are legal except those that begin with the string
@@ -106380,11 +106681,11 @@
106380 ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
106381 ** is reserved for internal use.
106382 */
106383 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){
106384 if( !pParse->db->init.busy && pParse->nested==0
106385 && (pParse->db->flags & SQLITE_WriteSchema)==0
106386 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
106387 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
106388 return SQLITE_ERROR;
106389 }
106390 return SQLITE_OK;
@@ -107455,10 +107756,36 @@
107455 }else{
107456 pPk->nColumn = pTab->nCol;
107457 }
107458 recomputeColumnsNotIndexed(pPk);
107459 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107460
107461 /*
107462 ** This routine is called to report the final ")" that terminates
107463 ** a CREATE TABLE statement.
107464 **
@@ -107494,10 +107821,14 @@
107494 return;
107495 }
107496 assert( !db->mallocFailed );
107497 p = pParse->pNewTable;
107498 if( p==0 ) return;
 
 
 
 
107499
107500 /* If the db->init.busy is 1 it means we are reading the SQL off the
107501 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
107502 ** So do not write to the disk again. Extract the root page number
107503 ** for the table from the db->init.newTnum field. (The page number
@@ -108002,11 +108333,11 @@
108002 ** erasing iTable (this can happen with an auto-vacuum database).
108003 */
108004 static void destroyRootPage(Parse *pParse, int iTable, int iDb){
108005 Vdbe *v = sqlite3GetVdbe(pParse);
108006 int r1 = sqlite3GetTempReg(pParse);
108007 assert( iTable>1 );
108008 sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
108009 sqlite3MayAbort(pParse);
108010 #ifndef SQLITE_OMIT_AUTOVACUUM
108011 /* OP_Destroy stores an in integer r1. If this integer
108012 ** is non-zero, then it is the root page number of a table moved to
@@ -110457,10 +110788,25 @@
110457 return p;
110458 }
110459 }
110460 return 0;
110461 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110462
110463 /*
110464 ** Insert a new FuncDef into a FuncDefHash hash table.
110465 */
110466 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
@@ -110470,11 +110816,11 @@
110470 int i;
110471 for(i=0; i<nDef; i++){
110472 FuncDef *pOther;
110473 const char *zName = aDef[i].zName;
110474 int nName = sqlite3Strlen30(zName);
110475 int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;
110476 assert( zName[0]>='a' && zName[0]<='z' );
110477 pOther = functionSearch(h, zName);
110478 if( pOther ){
110479 assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
110480 aDef[i].pNext = pOther->pNext;
@@ -110549,11 +110895,11 @@
110549 ** new function. But the FuncDefs for built-in functions are read-only.
110550 ** So we must not search for built-ins when creating a new function.
110551 */
110552 if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
110553 bestScore = 0;
110554 h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;
110555 p = functionSearch(h, zName);
110556 while( p ){
110557 int score = matchQuality(p, nArg, enc);
110558 if( score>bestScore ){
110559 pBest = p;
@@ -110696,37 +111042,52 @@
110696 if( sqlite3IndexedByLookup(pParse, pItem) ){
110697 pTab = 0;
110698 }
110699 return pTab;
110700 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110701
110702 /*
110703 ** Check to make sure the given table is writable. If it is not
110704 ** writable, generate an error message and return 1. If it is
110705 ** writable return 0;
110706 */
110707 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
110708 /* A table is not writable under the following circumstances:
110709 **
110710 ** 1) It is a virtual table and no implementation of the xUpdate method
110711 ** has been provided, or
110712 ** 2) It is a system table (i.e. sqlite_master), this call is not
110713 ** part of a nested parse and writable_schema pragma has not
110714 ** been specified.
110715 **
110716 ** In either case leave an error message in pParse and return non-zero.
110717 */
110718 if( ( IsVirtual(pTab)
110719 && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 )
110720 || ( (pTab->tabFlags & TF_Readonly)!=0
110721 && (pParse->db->flags & SQLITE_WriteSchema)==0
110722 && pParse->nested==0 )
110723 ){
110724 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
110725 return 1;
110726 }
110727
110728 #ifndef SQLITE_OMIT_VIEW
110729 if( !viewOk && pTab->pSelect ){
110730 sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
110731 return 1;
110732 }
@@ -114126,11 +114487,11 @@
114126 int iCursor, /* The open cursor on the table */
114127 i16 iCol /* The column that is wanted */
114128 ){
114129 Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);
114130 if( pExpr ){
114131 pExpr->pTab = pTab;
114132 pExpr->iTable = iCursor;
114133 pExpr->iColumn = iCol;
114134 }
114135 return pExpr;
114136 }
@@ -115202,11 +115563,12 @@
115202 do{
115203 zColAff[i--] = 0;
115204 }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );
115205 pTab->zColAff = zColAff;
115206 }
115207 i = sqlite3Strlen30(zColAff);
 
115208 if( i ){
115209 if( iReg ){
115210 sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);
115211 }else{
115212 sqlite3VdbeChangeP4(v, -1, zColAff, i);
@@ -116182,18 +116544,19 @@
116182 #ifdef tmask
116183 #undef tmask
116184 #endif
116185
116186 /*
116187 ** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()
 
116188 */
116189 #define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
116190 #define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */
116191
116192 /* This is the Walker callback from checkConstraintUnchanged(). Set
116193 ** bit 0x01 of pWalker->eCode if
116194 ** pWalker->eCode to 0 if this expression node references any of the
116195 ** columns that are being modifed by an UPDATE statement.
116196 */
116197 static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
116198 if( pExpr->op==TK_COLUMN ){
116199 assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
@@ -116211,16 +116574,25 @@
116211 /*
116212 ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
116213 ** only columns that are modified by the UPDATE are those for which
116214 ** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
116215 **
116216 ** Return true if CHECK constraint pExpr does not use any of the
116217 ** changing columns (or the rowid if it is changing). In other words,
116218 ** return true if this CHECK constraint can be skipped when validating
116219 ** the new row in the UPDATE statement.
 
 
 
 
 
116220 */
116221 static int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){
 
 
 
 
116222 Walker w;
116223 memset(&w, 0, sizeof(w));
116224 w.eCode = 0;
116225 w.xExprCallback = checkConstraintExprNode;
116226 w.u.aiCol = aiChng;
@@ -116231,11 +116603,11 @@
116231 }
116232 testcase( w.eCode==0 );
116233 testcase( w.eCode==CKCNSTRNT_COLUMN );
116234 testcase( w.eCode==CKCNSTRNT_ROWID );
116235 testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
116236 return !w.eCode;
116237 }
116238
116239 /*
116240 ** Generate code to do constraint checks prior to an INSERT or an UPDATE
116241 ** on table pTab.
@@ -116437,11 +116809,17 @@
116437 pParse->iSelfTab = -(regNewData+1);
116438 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
116439 for(i=0; i<pCheck->nExpr; i++){
116440 int allOk;
116441 Expr *pExpr = pCheck->a[i].pExpr;
116442 if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;
 
 
 
 
 
 
116443 allOk = sqlite3VdbeMakeLabel(v);
116444 sqlite3VdbeVerifyAbortable(v, onError);
116445 sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
116446 if( onError==OE_Ignore ){
116447 sqlite3VdbeGoto(v, ignoreDest);
@@ -117938,16 +118316,19 @@
117938 void (*str_appendchar)(sqlite3_str*, int N, char C);
117939 void (*str_reset)(sqlite3_str*);
117940 int (*str_errcode)(sqlite3_str*);
117941 int (*str_length)(sqlite3_str*);
117942 char *(*str_value)(sqlite3_str*);
 
117943 int (*create_window_function)(sqlite3*,const char*,int,int,void*,
117944 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
117945 void (*xFinal)(sqlite3_context*),
117946 void (*xValue)(sqlite3_context*),
117947 void (*xInv)(sqlite3_context*,int,sqlite3_value**),
117948 void(*xDestroy)(void*));
 
 
117949 };
117950
117951 /*
117952 ** This is the function signature used for all extension entry points. It
117953 ** is also defined in the file "loadext.c".
@@ -118231,10 +118612,12 @@
118231 #define sqlite3_str_errcode sqlite3_api->str_errcode
118232 #define sqlite3_str_length sqlite3_api->str_length
118233 #define sqlite3_str_value sqlite3_api->str_value
118234 /* Version 3.25.0 and later */
118235 #define sqlite3_create_window_function sqlite3_api->create_window_function
 
 
118236 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118237
118238 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118239 /* This case when the file really is being compiled as a loadable
118240 ** extension */
@@ -118686,11 +119069,17 @@
118686 sqlite3_str_reset,
118687 sqlite3_str_errcode,
118688 sqlite3_str_length,
118689 sqlite3_str_value,
118690 /* Version 3.25.0 and later */
118691 sqlite3_create_window_function
 
 
 
 
 
 
118692 };
118693
118694 /*
118695 ** Attempt to load an SQLite extension library contained in the file
118696 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -119136,14 +119525,13 @@
119136 #define PragTyp_WAL_AUTOCHECKPOINT 38
119137 #define PragTyp_WAL_CHECKPOINT 39
119138 #define PragTyp_ACTIVATE_EXTENSIONS 40
119139 #define PragTyp_HEXKEY 41
119140 #define PragTyp_KEY 42
119141 #define PragTyp_REKEY 43
119142 #define PragTyp_LOCK_STATUS 44
119143 #define PragTyp_PARSER_TRACE 45
119144 #define PragTyp_STATS 46
119145
119146 /* Property flags associated with various pragma. */
119147 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
119148 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
119149 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -119156,72 +119544,71 @@
119156 /* Names of columns for pragmas that return multi-column result
119157 ** or that return single-column results where the name of the
119158 ** result column is different from the name of the pragma
119159 */
119160 static const char *const pragCName[] = {
119161 /* 0 */ "cache_size", /* Used by: default_cache_size */
119162 /* 1 */ "cid", /* Used by: table_info */
119163 /* 2 */ "name",
119164 /* 3 */ "type",
119165 /* 4 */ "notnull",
119166 /* 5 */ "dflt_value",
119167 /* 6 */ "pk",
119168 /* 7 */ "tbl", /* Used by: stats */
119169 /* 8 */ "idx",
119170 /* 9 */ "wdth",
119171 /* 10 */ "hght",
119172 /* 11 */ "flgs",
119173 /* 12 */ "seqno", /* Used by: index_info */
119174 /* 13 */ "cid",
119175 /* 14 */ "name",
 
119176 /* 15 */ "seqno", /* Used by: index_xinfo */
119177 /* 16 */ "cid",
119178 /* 17 */ "name",
119179 /* 18 */ "desc",
119180 /* 19 */ "coll",
119181 /* 20 */ "key",
119182 /* 21 */ "seq", /* Used by: index_list */
119183 /* 22 */ "name",
119184 /* 23 */ "unique",
119185 /* 24 */ "origin",
119186 /* 25 */ "partial",
119187 /* 26 */ "seq", /* Used by: database_list */
119188 /* 27 */ "name",
119189 /* 28 */ "file",
119190 /* 29 */ "name", /* Used by: function_list */
119191 /* 30 */ "builtin",
119192 /* 31 */ "name", /* Used by: module_list pragma_list */
119193 /* 32 */ "seq", /* Used by: collation_list */
119194 /* 33 */ "name",
119195 /* 34 */ "id", /* Used by: foreign_key_list */
119196 /* 35 */ "seq",
119197 /* 36 */ "table",
119198 /* 37 */ "from",
119199 /* 38 */ "to",
119200 /* 39 */ "on_update",
119201 /* 40 */ "on_delete",
119202 /* 41 */ "match",
119203 /* 42 */ "table", /* Used by: foreign_key_check */
119204 /* 43 */ "rowid",
119205 /* 44 */ "parent",
119206 /* 45 */ "fkid",
119207 /* 46 */ "busy", /* Used by: wal_checkpoint */
119208 /* 47 */ "log",
119209 /* 48 */ "checkpointed",
119210 /* 49 */ "timeout", /* Used by: busy_timeout */
119211 /* 50 */ "database", /* Used by: lock_status */
119212 /* 51 */ "status",
119213 };
119214
119215 /* Definitions of all built-in pragmas */
119216 typedef struct PragmaName {
119217 const char *const zName; /* Name of pragma */
119218 u8 ePragTyp; /* PragTyp_XXX value */
119219 u8 mPragFlg; /* Zero or more PragFlg_XXX values */
119220 u8 iPragCName; /* Start of column names in pragCName[] */
119221 u8 nPragCName; /* Num of col names. 0 means use pragma name */
119222 u32 iArg; /* Extra argument */
119223 } PragmaName;
119224 static const PragmaName aPragmaName[] = {
119225 #if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
119226 {/* zName: */ "activate_extensions",
119227 /* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
@@ -119253,11 +119640,11 @@
119253 #endif
119254 #endif
119255 {/* zName: */ "busy_timeout",
119256 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
119257 /* ePragFlg: */ PragFlg_Result0,
119258 /* ColNames: */ 49, 1,
119259 /* iArg: */ 0 },
119260 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119261 {/* zName: */ "cache_size",
119262 /* ePragTyp: */ PragTyp_CACHE_SIZE,
119263 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -119290,11 +119677,11 @@
119290 #endif
119291 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119292 {/* zName: */ "collation_list",
119293 /* ePragTyp: */ PragTyp_COLLATION_LIST,
119294 /* ePragFlg: */ PragFlg_Result0,
119295 /* ColNames: */ 32, 2,
119296 /* iArg: */ 0 },
119297 #endif
119298 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
119299 {/* zName: */ "compile_options",
119300 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -119325,18 +119712,18 @@
119325 #endif
119326 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119327 {/* zName: */ "database_list",
119328 /* ePragTyp: */ PragTyp_DATABASE_LIST,
119329 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119330 /* ColNames: */ 26, 3,
119331 /* iArg: */ 0 },
119332 #endif
119333 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
119334 {/* zName: */ "default_cache_size",
119335 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
119336 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
119337 /* ColNames: */ 0, 1,
119338 /* iArg: */ 0 },
119339 #endif
119340 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119341 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119342 {/* zName: */ "defer_foreign_keys",
@@ -119362,18 +119749,18 @@
119362 #endif
119363 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119364 {/* zName: */ "foreign_key_check",
119365 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
119366 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119367 /* ColNames: */ 42, 4,
119368 /* iArg: */ 0 },
119369 #endif
119370 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
119371 {/* zName: */ "foreign_key_list",
119372 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
119373 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119374 /* ColNames: */ 34, 8,
119375 /* iArg: */ 0 },
119376 #endif
119377 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119378 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119379 {/* zName: */ "foreign_keys",
@@ -119405,25 +119792,25 @@
119405 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119406 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119407 {/* zName: */ "function_list",
119408 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
119409 /* ePragFlg: */ PragFlg_Result0,
119410 /* ColNames: */ 29, 2,
119411 /* iArg: */ 0 },
119412 #endif
119413 #endif
119414 #if defined(SQLITE_HAS_CODEC)
119415 {/* zName: */ "hexkey",
119416 /* ePragTyp: */ PragTyp_HEXKEY,
119417 /* ePragFlg: */ 0,
119418 /* ColNames: */ 0, 0,
119419 /* iArg: */ 0 },
119420 {/* zName: */ "hexrekey",
119421 /* ePragTyp: */ PragTyp_HEXKEY,
119422 /* ePragFlg: */ 0,
119423 /* ColNames: */ 0, 0,
119424 /* iArg: */ 0 },
119425 #endif
119426 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119427 #if !defined(SQLITE_OMIT_CHECK)
119428 {/* zName: */ "ignore_check_constraints",
119429 /* ePragTyp: */ PragTyp_FLAG,
@@ -119441,16 +119828,16 @@
119441 #endif
119442 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119443 {/* zName: */ "index_info",
119444 /* ePragTyp: */ PragTyp_INDEX_INFO,
119445 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119446 /* ColNames: */ 12, 3,
119447 /* iArg: */ 0 },
119448 {/* zName: */ "index_list",
119449 /* ePragTyp: */ PragTyp_INDEX_LIST,
119450 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119451 /* ColNames: */ 21, 5,
119452 /* iArg: */ 0 },
119453 {/* zName: */ "index_xinfo",
119454 /* ePragTyp: */ PragTyp_INDEX_INFO,
119455 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119456 /* ColNames: */ 15, 6,
@@ -119503,11 +119890,11 @@
119503 #endif
119504 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
119505 {/* zName: */ "lock_status",
119506 /* ePragTyp: */ PragTyp_LOCK_STATUS,
119507 /* ePragFlg: */ PragFlg_Result0,
119508 /* ColNames: */ 50, 2,
119509 /* iArg: */ 0 },
119510 #endif
119511 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119512 {/* zName: */ "locking_mode",
119513 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -119529,11 +119916,11 @@
119529 #if !defined(SQLITE_OMIT_VIRTUALTABLE)
119530 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119531 {/* zName: */ "module_list",
119532 /* ePragTyp: */ PragTyp_MODULE_LIST,
119533 /* ePragFlg: */ PragFlg_Result0,
119534 /* ColNames: */ 31, 1,
119535 /* iArg: */ 0 },
119536 #endif
119537 #endif
119538 #endif
119539 {/* zName: */ "optimize",
@@ -119562,11 +119949,11 @@
119562 #endif
119563 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119564 {/* zName: */ "pragma_list",
119565 /* ePragTyp: */ PragTyp_PRAGMA_LIST,
119566 /* ePragFlg: */ PragFlg_Result0,
119567 /* ColNames: */ 31, 1,
119568 /* iArg: */ 0 },
119569 #endif
119570 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119571 {/* zName: */ "query_only",
119572 /* ePragTyp: */ PragTyp_FLAG,
@@ -119593,14 +119980,14 @@
119593 /* ColNames: */ 0, 0,
119594 /* iArg: */ SQLITE_RecTriggers },
119595 #endif
119596 #if defined(SQLITE_HAS_CODEC)
119597 {/* zName: */ "rekey",
119598 /* ePragTyp: */ PragTyp_REKEY,
119599 /* ePragFlg: */ 0,
119600 /* ColNames: */ 0, 0,
119601 /* iArg: */ 0 },
119602 #endif
119603 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119604 {/* zName: */ "reverse_unordered_selects",
119605 /* ePragTyp: */ PragTyp_FLAG,
119606 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119649,11 +120036,11 @@
119649 #endif
119650 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
119651 {/* zName: */ "stats",
119652 /* ePragTyp: */ PragTyp_STATS,
119653 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
119654 /* ColNames: */ 7, 5,
119655 /* iArg: */ 0 },
119656 #endif
119657 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119658 {/* zName: */ "synchronous",
119659 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -119663,12 +120050,17 @@
119663 #endif
119664 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119665 {/* zName: */ "table_info",
119666 /* ePragTyp: */ PragTyp_TABLE_INFO,
119667 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119668 /* ColNames: */ 1, 6,
119669 /* iArg: */ 0 },
 
 
 
 
 
119670 #endif
119671 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119672 {/* zName: */ "temp_store",
119673 /* ePragTyp: */ PragTyp_TEMP_STORE,
119674 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119677,10 +120069,22 @@
119677 {/* zName: */ "temp_store_directory",
119678 /* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
119679 /* ePragFlg: */ PragFlg_NoColumns1,
119680 /* ColNames: */ 0, 0,
119681 /* iArg: */ 0 },
 
 
 
 
 
 
 
 
 
 
 
 
119682 #endif
119683 {/* zName: */ "threads",
119684 /* ePragTyp: */ PragTyp_THREADS,
119685 /* ePragFlg: */ PragFlg_Result0,
119686 /* ColNames: */ 0, 0,
@@ -119728,22 +120132,22 @@
119728 /* ColNames: */ 0, 0,
119729 /* iArg: */ 0 },
119730 {/* zName: */ "wal_checkpoint",
119731 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
119732 /* ePragFlg: */ PragFlg_NeedSchema,
119733 /* ColNames: */ 46, 3,
119734 /* iArg: */ 0 },
119735 #endif
119736 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119737 {/* zName: */ "writable_schema",
119738 /* ePragTyp: */ PragTyp_FLAG,
119739 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
119740 /* ColNames: */ 0, 0,
119741 /* iArg: */ SQLITE_WriteSchema },
119742 #endif
119743 };
119744 /* Number of pragmas: 61 on by default, 78 total. */
119745
119746 /************** End of pragma.h **********************************************/
119747 /************** Continuing where we left off in pragma.c *********************/
119748
119749 /*
@@ -120751,11 +121155,11 @@
120751 case PragTyp_FLAG: {
120752 if( zRight==0 ){
120753 setPragmaResultColumnNames(v, pPragma);
120754 returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );
120755 }else{
120756 int mask = pPragma->iArg; /* Mask of bits to set or clear. */
120757 if( db->autoCommit==0 ){
120758 /* Foreign key support may not be enabled or disabled while not
120759 ** in auto-commit mode. */
120760 mask &= ~(SQLITE_ForeignKeys);
120761 }
@@ -120804,15 +121208,16 @@
120804 if( pTab ){
120805 int i, k;
120806 int nHidden = 0;
120807 Column *pCol;
120808 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
120809 pParse->nMem = 6;
120810 sqlite3CodeVerifySchema(pParse, iDb);
120811 sqlite3ViewGetColumnNames(pParse, pTab);
120812 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
120813 if( IsHiddenColumn(pCol) ){
 
120814 nHidden++;
120815 continue;
120816 }
120817 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
120818 k = 0;
@@ -120820,17 +121225,18 @@
120820 k = 1;
120821 }else{
120822 for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
120823 }
120824 assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
120825 sqlite3VdbeMultiLoad(v, 1, "issisi",
120826 i-nHidden,
120827 pCol->zName,
120828 sqlite3ColumnType(pCol,""),
120829 pCol->notNull ? 1 : 0,
120830 pCol->pDflt ? pCol->pDflt->u.zToken : 0,
120831 k);
 
120832 }
120833 }
120834 }
120835 break;
120836
@@ -121830,16 +122236,28 @@
121830 break;
121831 }
121832 #endif
121833
121834 #ifdef SQLITE_HAS_CODEC
 
 
 
 
 
 
 
 
 
121835 case PragTyp_KEY: {
121836 if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
121837 break;
121838 }
121839 case PragTyp_REKEY: {
121840 if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
 
 
 
121841 break;
121842 }
121843 case PragTyp_HEXKEY: {
121844 if( zRight ){
121845 u8 iByte;
@@ -121847,11 +122265,11 @@
121847 char zKey[40];
121848 for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
121849 iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
121850 if( (i&1)!=0 ) zKey[i/2] = iByte;
121851 }
121852 if( (zLeft[3] & 0xf)==0xb ){
121853 sqlite3_key_v2(db, zDb, zKey, i/2);
121854 }else{
121855 sqlite3_rekey_v2(db, zDb, zKey, i/2);
121856 }
121857 }
@@ -122177,11 +122595,12 @@
122177 0, /* xRollback - rollback transaction */
122178 0, /* xFindFunction - function overloading */
122179 0, /* xRename - rename the table */
122180 0, /* xSavepoint */
122181 0, /* xRelease */
122182 0 /* xRollbackTo */
 
122183 };
122184
122185 /*
122186 ** Check to see if zTabName is really the name of a pragma. If it is,
122187 ** then register an eponymous virtual table for that pragma and return
@@ -122530,12 +122949,12 @@
122530 }
122531 if( db->mallocFailed ){
122532 rc = SQLITE_NOMEM_BKPT;
122533 sqlite3ResetAllSchemasOfConnection(db);
122534 }
122535 if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){
122536 /* Black magic: If the SQLITE_WriteSchema flag is set, then consider
122537 ** the schema loaded, even if errors occurred. In this situation the
122538 ** current sqlite3_prepare() operation will fail, but the following one
122539 ** will attempt to compile the supplied statement against whatever subset
122540 ** of the schema was loaded before the error occurred. The primary
122541 ** purpose of this is to allow access to the sqlite_master table
@@ -122912,10 +123331,298 @@
122912 assert( (rc&db->errMask)==rc );
122913 sqlite3_mutex_leave(db->mutex);
122914 return rc;
122915 }
122916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122917 /*
122918 ** Rerun the compilation of a statement after a schema change.
122919 **
122920 ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,
122921 ** if the statement cannot be recompiled because another connection has
@@ -123924,11 +124631,11 @@
123924 ExprList *pExtra = 0;
123925 for(i=0; i<pEList->nExpr; i++){
123926 struct ExprList_item *pItem = &pEList->a[i];
123927 if( pItem->u.x.iOrderByCol==0 ){
123928 Expr *pExpr = pItem->pExpr;
123929 Table *pTab = pExpr->pTab;
123930 if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab)
123931 && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
123932 ){
123933 int j;
123934 for(j=0; j<nDefer; j++){
@@ -123947,16 +124654,16 @@
123947 }
123948 for(k=0; k<nKey; k++){
123949 Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
123950 if( pNew ){
123951 pNew->iTable = pExpr->iTable;
123952 pNew->pTab = pExpr->pTab;
123953 pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
123954 pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
123955 }
123956 }
123957 pSort->aDefer[nDefer].pTab = pExpr->pTab;
123958 pSort->aDefer[nDefer].iCsr = pExpr->iTable;
123959 pSort->aDefer[nDefer].nKey = nKey;
123960 nDefer++;
123961 }
123962 }
@@ -124801,11 +125508,11 @@
124801 ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
124802 ** branch below. */
124803 break;
124804 }
124805
124806 assert( pTab && pExpr->pTab==pTab );
124807 if( pS ){
124808 /* The "table" is actually a sub-select or a view in the FROM clause
124809 ** of the SELECT statement. Return the declaration type and origin
124810 ** data for the result-set column of the sub-select.
124811 */
@@ -124986,19 +125693,19 @@
124986 for(i=0; i<pEList->nExpr; i++){
124987 Expr *p = pEList->a[i].pExpr;
124988
124989 assert( p!=0 );
124990 assert( p->op!=TK_AGG_COLUMN ); /* Agg processing has not run yet */
124991 assert( p->op!=TK_COLUMN || p->pTab!=0 ); /* Covering idx not yet coded */
124992 if( pEList->a[i].zName ){
124993 /* An AS clause always takes first priority */
124994 char *zName = pEList->a[i].zName;
124995 sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);
124996 }else if( srcName && p->op==TK_COLUMN ){
124997 char *zCol;
124998 int iCol = p->iColumn;
124999 pTab = p->pTab;
125000 assert( pTab!=0 );
125001 if( iCol<0 ) iCol = pTab->iPKey;
125002 assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
125003 if( iCol<0 ){
125004 zCol = "rowid";
@@ -125085,11 +125792,11 @@
125085 }
125086 assert( pColExpr->op!=TK_AGG_COLUMN );
125087 if( pColExpr->op==TK_COLUMN ){
125088 /* For columns use the column name name */
125089 int iCol = pColExpr->iColumn;
125090 Table *pTab = pColExpr->pTab;
125091 assert( pTab!=0 );
125092 if( iCol<0 ) iCol = pTab->iPKey;
125093 zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
125094 }else if( pColExpr->op==TK_ID ){
125095 assert( !ExprHasProperty(pColExpr, EP_IntValue) );
@@ -125438,10 +126145,17 @@
125438 int i; /* Loop counter */
125439 int rc; /* Result code */
125440 ExprList *pOrderBy; /* The ORDER BY clause */
125441 Expr *pLimit; /* Saved LIMIT and OFFSET */
125442 int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */
 
 
 
 
 
 
 
125443
125444 /* Obtain authorization to do a recursive query */
125445 if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
125446
125447 /* Process the LIMIT and OFFSET clauses, if they exist */
@@ -127188,11 +127902,11 @@
127188 return 1;
127189 }
127190 #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
127191
127192 /*
127193 ** A structure to keep track of all of the column values that fixed to
127194 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
127195 */
127196 typedef struct WhereConst WhereConst;
127197 struct WhereConst {
127198 Parse *pParse; /* Parsing context */
@@ -127200,17 +127914,32 @@
127200 int nChng; /* Number of times a constant is propagated */
127201 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
127202 };
127203
127204 /*
127205 ** Add a new entry to the pConst object
 
127206 */
127207 static void constInsert(
127208 WhereConst *pConst,
127209 Expr *pColumn,
127210 Expr *pValue
127211 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127212
127213 pConst->nConst++;
127214 pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
127215 pConst->nConst*2*sizeof(Expr*));
127216 if( pConst->apExpr==0 ){
@@ -131187,10 +131916,61 @@
131187 if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
131188 sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
131189 }
131190 #endif
131191 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131192
131193 /*
131194 ** Process an UPDATE statement.
131195 **
131196 ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
@@ -131411,23 +132191,22 @@
131411 hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);
131412
131413 /* There is one entry in the aRegIdx[] array for each index on the table
131414 ** being updated. Fill in aRegIdx[] with a register number that will hold
131415 ** the key for accessing each index.
131416 **
131417 ** FIXME: Be smarter about omitting indexes that use expressions.
131418 */
131419 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
131420 int reg;
131421 if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){
 
 
131422 reg = ++pParse->nMem;
131423 pParse->nMem += pIdx->nColumn;
131424 }else{
131425 reg = 0;
131426 for(i=0; i<pIdx->nKeyCol; i++){
131427 i16 iIdxCol = pIdx->aiColumn[i];
131428 if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){
131429 reg = ++pParse->nMem;
131430 pParse->nMem += pIdx->nColumn;
131431 if( (onError==OE_Replace)
131432 || (onError==OE_Default && pIdx->onError==OE_Replace)
131433 ){
@@ -131972,11 +132751,11 @@
131972 for(i=0; i<pTab->nCol; i++){
131973 if( aXRef[i]>=0 ){
131974 sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
131975 }else{
131976 sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
131977 sqlite3VdbeChangeP5(v, 1); /* Enable sqlite3_vtab_nochange() */
131978 }
131979 }
131980 if( HasRowid(pTab) ){
131981 sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);
131982 if( pRowid ){
@@ -132473,11 +133252,12 @@
132473 saved_nChange = db->nChange;
132474 saved_nTotalChange = db->nTotalChange;
132475 saved_mTrace = db->mTrace;
132476 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
132477 db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;
132478 db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_CountRows);
 
132479 db->mTrace = 0;
132480
132481 zDbMain = db->aDb[iDb].zDbSName;
132482 pMain = db->aDb[iDb].pBt;
132483 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
@@ -133015,22 +133795,19 @@
133015 Token *pName1, /* Name of new table, or database name */
133016 Token *pName2, /* Name of new table or NULL */
133017 Token *pModuleName, /* Name of the module for the virtual table */
133018 int ifNotExists /* No error if the table already exists */
133019 ){
133020 int iDb; /* The database the table is being created in */
133021 Table *pTable; /* The new virtual table */
133022 sqlite3 *db; /* Database connection */
133023
133024 sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);
133025 pTable = pParse->pNewTable;
133026 if( pTable==0 ) return;
133027 assert( 0==pTable->pIndex );
133028
133029 db = pParse->db;
133030 iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
133031 assert( iDb>=0 );
133032
133033 assert( pTable->nModuleArg==0 );
133034 addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
133035 addModuleArgument(db, pTable, 0);
133036 addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
@@ -133046,10 +133823,12 @@
133046 ** The first invocation, to obtain permission to INSERT a row into the
133047 ** sqlite_master table, has already been made by sqlite3StartTable().
133048 ** The second call, to obtain permission to create the table, is made now.
133049 */
133050 if( pTable->azModuleArg ){
 
 
133051 sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
133052 pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);
133053 }
133054 #endif
133055 }
@@ -133740,11 +134519,11 @@
133740 int rc = 0;
133741
133742 /* Check to see the left operand is a column in a virtual table */
133743 if( NEVER(pExpr==0) ) return pDef;
133744 if( pExpr->op!=TK_COLUMN ) return pDef;
133745 pTab = pExpr->pTab;
133746 if( pTab==0 ) return pDef;
133747 if( !IsVirtual(pTab) ) return pDef;
133748 pVtab = sqlite3GetVTable(db, pTab)->pVtab;
133749 assert( pVtab!=0 );
133750 assert( pVtab->pModule!=0 );
@@ -134360,15 +135139,36 @@
134360 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
134361 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
134362 int nRecValid; /* Number of valid fields currently in pRec */
134363 #endif
134364 unsigned int bldFlags; /* SQLITE_BLDF_* flags */
 
134365 };
134366
134367 /* Allowed values for WhereLoopBuider.bldFlags */
134368 #define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
134369 #define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134370
134371 /*
134372 ** The WHERE clause processing routine has two halves. The
134373 ** first part does the start of the WHERE loop and the second
134374 ** half does the tail of the WHERE loop. An instance of
@@ -134927,11 +135727,11 @@
134927 Select *pSelect; /* Pointer to the SELECT on the RHS */
134928
134929 for(i=iEq; i<pLoop->nLTerm; i++){
134930 if( pLoop->aLTerm[i]->pExpr==pX ){
134931 int iField = pLoop->aLTerm[i]->iField - 1;
134932 assert( pOrigRhs->a[iField].pExpr!=0 );
134933 pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
134934 pOrigRhs->a[iField].pExpr = 0;
134935 assert( pOrigLhs->a[iField].pExpr!=0 );
134936 pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
134937 pOrigLhs->a[iField].pExpr = 0;
@@ -135619,11 +136419,11 @@
135619 IdxExprTrans *pX = p->u.pIdxTrans;
135620 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
135621 pExpr->op = TK_COLUMN;
135622 pExpr->iTable = pX->iIdxCur;
135623 pExpr->iColumn = pX->iIdxCol;
135624 pExpr->pTab = 0;
135625 return WRC_Prune;
135626 }else{
135627 return WRC_Continue;
135628 }
135629 }
@@ -137019,11 +137819,11 @@
137019 || zNew[0]=='-'
137020 || (zNew[0]+1=='0' && iTo==1)
137021 ){
137022 if( pLeft->op!=TK_COLUMN
137023 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
137024 || IsVirtual(pLeft->pTab) /* Value might be numeric */
137025 ){
137026 sqlite3ExprDelete(db, pPrefix);
137027 sqlite3ValueFree(pVal);
137028 return 0;
137029 }
@@ -137120,11 +137920,11 @@
137120 **
137121 ** vtab_column MATCH expression
137122 ** MATCH(expression,vtab_column)
137123 */
137124 pCol = pList->a[1].pExpr;
137125 if( pCol->op==TK_COLUMN && IsVirtual(pCol->pTab) ){
137126 for(i=0; i<ArraySize(aOp); i++){
137127 if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
137128 *peOp2 = aOp[i].eOp2;
137129 *ppRight = pList->a[0].pExpr;
137130 *ppLeft = pCol;
@@ -137142,16 +137942,16 @@
137142 ** Historically, xFindFunction expected to see lower-case function
137143 ** names. But for this use case, xFindFunction is expected to deal
137144 ** with function names in an arbitrary case.
137145 */
137146 pCol = pList->a[0].pExpr;
137147 if( pCol->op==TK_COLUMN && IsVirtual(pCol->pTab) ){
137148 sqlite3_vtab *pVtab;
137149 sqlite3_module *pMod;
137150 void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);
137151 void *pNotUsed;
137152 pVtab = sqlite3GetVTable(db, pCol->pTab)->pVtab;
137153 assert( pVtab!=0 );
137154 assert( pVtab->pModule!=0 );
137155 pMod = (sqlite3_module *)pVtab->pModule;
137156 if( pMod->xFindFunction!=0 ){
137157 i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
@@ -137165,14 +137965,14 @@
137165 }
137166 }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){
137167 int res = 0;
137168 Expr *pLeft = pExpr->pLeft;
137169 Expr *pRight = pExpr->pRight;
137170 if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->pTab) ){
137171 res++;
137172 }
137173 if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->pTab) ){
137174 res++;
137175 SWAP(Expr*, pLeft, pRight);
137176 }
137177 *ppLeft = pLeft;
137178 *ppRight = pRight;
@@ -138120,10 +138920,11 @@
138120 ** Note that the virtual term must be tagged with TERM_VNULL.
138121 */
138122 if( pExpr->op==TK_NOTNULL
138123 && pExpr->pLeft->op==TK_COLUMN
138124 && pExpr->pLeft->iColumn>=0
 
138125 && OptimizationEnabled(db, SQLITE_Stat34)
138126 ){
138127 Expr *pNewExpr;
138128 Expr *pLeft = pExpr->pLeft;
138129 int idxNew;
@@ -138311,10 +139112,11 @@
138311 pTab = pItem->pTab;
138312 assert( pTab!=0 );
138313 pArgs = pItem->u1.pFuncArg;
138314 if( pArgs==0 ) return;
138315 for(j=k=0; j<pArgs->nExpr; j++){
 
138316 while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}
138317 if( k>=pTab->nCol ){
138318 sqlite3ErrorMsg(pParse, "too many arguments on %s() - max %d",
138319 pTab->zName, j);
138320 return;
@@ -138321,13 +139123,14 @@
138321 }
138322 pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);
138323 if( pColRef==0 ) return;
138324 pColRef->iTable = pItem->iCursor;
138325 pColRef->iColumn = k++;
138326 pColRef->pTab = pTab;
138327 pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef,
138328 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0));
 
138329 whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
138330 }
138331 }
138332
138333 /************** End of whereexpr.c *******************************************/
@@ -139186,11 +139989,10 @@
139186 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
139187 testcase( pParse->db->mallocFailed );
139188 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
139189 pTabItem->regResult, 1);
139190 sqlite3VdbeGoto(v, addrTop);
139191 pTabItem->fg.viaCoroutine = 0;
139192 }else{
139193 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
139194 }
139195 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
139196 sqlite3VdbeJumpHere(v, addrTop);
@@ -140457,10 +141259,18 @@
140457 static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
140458 WhereLoop **ppPrev, *p;
140459 WhereInfo *pWInfo = pBuilder->pWInfo;
140460 sqlite3 *db = pWInfo->pParse->db;
140461 int rc;
 
 
 
 
 
 
 
 
140462
140463 /* If pBuilder->pOrSet is defined, then only keep track of the costs
140464 ** and prereqs.
140465 */
140466 if( pBuilder->pOrSet!=0 ){
@@ -141864,13 +142674,15 @@
141864 u8 priorJointype = 0;
141865
141866 /* Loop over the tables in the join, from left to right */
141867 pNew = pBuilder->pNew;
141868 whereLoopInit(pNew);
 
141869 for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
141870 Bitmask mUnusable = 0;
141871 pNew->iTab = iTab;
 
141872 pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
141873 if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){
141874 /* This condition is true when pItem is the FROM clause term on the
141875 ** right-hand-side of a LEFT or CROSS JOIN. */
141876 mPrereq = mPrior;
@@ -141892,11 +142704,19 @@
141892 }
141893 if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
141894 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
141895 }
141896 mPrior |= pNew->maskSelf;
141897 if( rc || db->mallocFailed ) break;
 
 
 
 
 
 
 
 
141898 }
141899
141900 whereLoopClear(db, pNew);
141901 return rc;
141902 }
@@ -144274,16 +145094,16 @@
144274 }
144275
144276 switch( pExpr->op ){
144277
144278 case TK_FUNCTION:
144279 if( pExpr->pWin==0 ){
144280 break;
144281 }else{
144282 Window *pWin;
144283 for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
144284 if( pExpr->pWin==pWin ){
144285 assert( pWin->pOwner==pExpr );
144286 return WRC_Prune;
144287 }
144288 }
144289 }
@@ -144396,11 +145216,11 @@
144396 ** are invoked in the correct order as described under "SELECT REWRITING"
144397 ** at the top of this file.
144398 */
144399 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
144400 int rc = SQLITE_OK;
144401 if( p->pWin ){
144402 Vdbe *v = sqlite3GetVdbe(pParse);
144403 sqlite3 *db = pParse->db;
144404 Select *pSub = 0; /* The subquery */
144405 SrcList *pSrc = p->pSrc;
144406 Expr *pWhere = p->pWhere;
@@ -144609,15 +145429,17 @@
144609 /*
144610 ** Attach window object pWin to expression p.
144611 */
144612 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
144613 if( p ){
 
144614 /* This routine is only called for the parser. If pWin was not
144615 ** allocated due to an OOM, then the parser would fail before ever
144616 ** invoking this routine */
144617 if( ALWAYS(pWin) ){
144618 p->pWin = pWin;
 
144619 pWin->pOwner = p;
144620 if( p->flags & EP_Distinct ){
144621 sqlite3ErrorMsg(pParse,
144622 "DISTINCT is not supported for window functions");
144623 }
@@ -145776,11 +146598,11 @@
145776 ** third argument. Set the Window.pOwner field of the new object to
145777 ** pOwner.
145778 */
145779 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
145780 Window *pNew = 0;
145781 if( p ){
145782 pNew = sqlite3DbMallocZero(db, sizeof(Window));
145783 if( pNew ){
145784 pNew->zName = sqlite3DbStrDup(db, p->zName);
145785 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
145786 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
@@ -146029,17 +146851,14 @@
146029 p->flags = EP_Leaf;
146030 p->iAgg = -1;
146031 p->pLeft = p->pRight = 0;
146032 p->x.pList = 0;
146033 p->pAggInfo = 0;
146034 p->pTab = 0;
146035 p->op2 = 0;
146036 p->iTable = 0;
146037 p->iColumn = 0;
146038 #ifndef SQLITE_OMIT_WINDOWFUNC
146039 p->pWin = 0;
146040 #endif
146041 p->u.zToken = (char*)&p[1];
146042 memcpy(p->u.zToken, t.z, t.n);
146043 p->u.zToken[t.n] = 0;
146044 if( sqlite3Isquote(p->u.zToken[0]) ){
146045 if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -146186,21 +147005,21 @@
146186 #define sqlite3ParserCTX_PDECL ,Parse *pParse
146187 #define sqlite3ParserCTX_PARAM ,pParse
146188 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
146189 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
146190 #define YYFALLBACK 1
146191 #define YYNSTATE 521
146192 #define YYNRULE 367
146193 #define YYNTOKEN 155
146194 #define YY_MAX_SHIFT 520
146195 #define YY_MIN_SHIFTREDUCE 756
146196 #define YY_MAX_SHIFTREDUCE 1122
146197 #define YY_ERROR_ACTION 1123
146198 #define YY_ACCEPT_ACTION 1124
146199 #define YY_NO_ACTION 1125
146200 #define YY_MIN_REDUCE 1126
146201 #define YY_MAX_REDUCE 1492
146202 /************* End control #defines *******************************************/
146203 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
146204
146205 /* Define the yytestcase() macro to be a no-op if is not already defined
146206 ** otherwise.
@@ -146265,211 +147084,211 @@
146265 ** yy_default[] Default action for each state.
146266 **
146267 *********** Begin parsing tables **********************************************/
146268 #define YY_ACTTAB_COUNT (2009)
146269 static const YYACTIONTYPE yy_action[] = {
146270 /* 0 */ 368, 105, 102, 197, 105, 102, 197, 515, 1124, 1,
146271 /* 10 */ 1, 520, 2, 1128, 515, 1192, 1171, 1456, 275, 370,
146272 /* 20 */ 127, 1389, 1197, 1197, 1192, 1166, 178, 1205, 64, 64,
146273 /* 30 */ 477, 887, 322, 428, 348, 37, 37, 808, 362, 888,
146274 /* 40 */ 509, 509, 509, 112, 113, 103, 1100, 1100, 953, 956,
146275 /* 50 */ 946, 946, 110, 110, 111, 111, 111, 111, 365, 252,
146276 /* 60 */ 252, 515, 252, 252, 497, 515, 309, 515, 459, 515,
146277 /* 70 */ 1079, 491, 512, 478, 6, 512, 809, 134, 498, 228,
146278 /* 80 */ 194, 428, 37, 37, 515, 208, 64, 64, 64, 64,
146279 /* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
146280 /* 100 */ 107, 106, 401, 258, 381, 13, 13, 398, 397, 428,
146281 /* 110 */ 252, 252, 370, 476, 405, 1104, 1079, 1080, 1081, 386,
146282 /* 120 */ 1106, 390, 497, 512, 497, 1423, 1419, 304, 1105, 307,
146283 /* 130 */ 1256, 496, 370, 499, 16, 16, 112, 113, 103, 1100,
146284 /* 140 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146285 /* 150 */ 111, 262, 1107, 495, 1107, 401, 112, 113, 103, 1100,
146286 /* 160 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146287 /* 170 */ 111, 129, 1425, 343, 1420, 339, 1059, 492, 1057, 263,
146288 /* 180 */ 73, 105, 102, 197, 994, 109, 109, 109, 109, 108,
146289 /* 190 */ 108, 107, 107, 107, 106, 401, 370, 111, 111, 111,
146290 /* 200 */ 111, 104, 492, 89, 1432, 109, 109, 109, 109, 108,
146291 /* 210 */ 108, 107, 107, 107, 106, 401, 111, 111, 111, 111,
146292 /* 220 */ 112, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146293 /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
146294 /* 240 */ 108, 107, 107, 107, 106, 401, 114, 108, 108, 107,
146295 /* 250 */ 107, 107, 106, 401, 109, 109, 109, 109, 108, 108,
146296 /* 260 */ 107, 107, 107, 106, 401, 152, 399, 399, 399, 109,
146297 /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146298 /* 280 */ 178, 493, 1412, 434, 1037, 1486, 1079, 515, 1486, 370,
146299 /* 290 */ 421, 297, 357, 412, 74, 1079, 109, 109, 109, 109,
146300 /* 300 */ 108, 108, 107, 107, 107, 106, 401, 1413, 37, 37,
146301 /* 310 */ 1431, 274, 506, 112, 113, 103, 1100, 1100, 953, 956,
146302 /* 320 */ 946, 946, 110, 110, 111, 111, 111, 111, 1436, 520,
146303 /* 330 */ 2, 1128, 1079, 1080, 1081, 430, 275, 1079, 127, 366,
146304 /* 340 */ 933, 1079, 1080, 1081, 220, 1205, 913, 458, 455, 454,
146305 /* 350 */ 392, 167, 515, 1035, 152, 445, 924, 453, 152, 874,
146306 /* 360 */ 923, 289, 109, 109, 109, 109, 108, 108, 107, 107,
146307 /* 370 */ 107, 106, 401, 13, 13, 261, 853, 252, 252, 227,
146308 /* 380 */ 106, 401, 370, 1079, 1080, 1081, 311, 388, 1079, 296,
146309 /* 390 */ 512, 923, 923, 925, 231, 323, 1255, 1388, 1423, 490,
146310 /* 400 */ 274, 506, 12, 208, 274, 506, 112, 113, 103, 1100,
146311 /* 410 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146312 /* 420 */ 111, 1440, 286, 1128, 288, 1079, 1097, 247, 275, 1098,
146313 /* 430 */ 127, 387, 405, 389, 1079, 1080, 1081, 1205, 159, 238,
146314 /* 440 */ 255, 321, 461, 316, 460, 225, 790, 105, 102, 197,
146315 /* 450 */ 513, 314, 842, 842, 445, 109, 109, 109, 109, 108,
146316 /* 460 */ 108, 107, 107, 107, 106, 401, 515, 514, 515, 252,
146317 /* 470 */ 252, 1079, 1080, 1081, 435, 370, 1098, 933, 1460, 794,
146318 /* 480 */ 274, 506, 512, 105, 102, 197, 336, 63, 63, 64,
146319 /* 490 */ 64, 27, 790, 924, 287, 208, 1354, 923, 515, 112,
146320 /* 500 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146321 /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 401, 49,
146322 /* 520 */ 49, 515, 28, 1079, 405, 497, 421, 297, 923, 923,
146323 /* 530 */ 925, 186, 468, 1079, 467, 999, 999, 442, 515, 1079,
146324 /* 540 */ 334, 515, 45, 45, 1083, 342, 173, 168, 109, 109,
146325 /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 13,
146326 /* 560 */ 13, 205, 13, 13, 252, 252, 1195, 1195, 370, 1079,
146327 /* 570 */ 1080, 1081, 787, 265, 5, 359, 494, 512, 469, 1079,
146328 /* 580 */ 1080, 1081, 398, 397, 1079, 1079, 1080, 1081, 3, 282,
146329 /* 590 */ 1079, 1083, 112, 113, 103, 1100, 1100, 953, 956, 946,
146330 /* 600 */ 946, 110, 110, 111, 111, 111, 111, 252, 252, 1015,
146331 /* 610 */ 220, 1079, 873, 458, 455, 454, 943, 943, 954, 957,
146332 /* 620 */ 512, 252, 252, 453, 1016, 1079, 445, 1107, 1209, 1107,
146333 /* 630 */ 1079, 1080, 1081, 515, 512, 426, 1079, 1080, 1081, 1017,
146334 /* 640 */ 512, 109, 109, 109, 109, 108, 108, 107, 107, 107,
146335 /* 650 */ 106, 401, 1052, 515, 50, 50, 515, 1079, 1080, 1081,
146336 /* 660 */ 828, 370, 1051, 379, 411, 1064, 1358, 207, 408, 773,
146337 /* 670 */ 829, 1079, 1080, 1081, 64, 64, 322, 64, 64, 1302,
146338 /* 680 */ 947, 411, 410, 1358, 1360, 112, 113, 103, 1100, 1100,
146339 /* 690 */ 953, 956, 946, 946, 110, 110, 111, 111, 111, 111,
146340 /* 700 */ 294, 482, 515, 1037, 1487, 515, 434, 1487, 354, 1120,
146341 /* 710 */ 483, 996, 913, 485, 466, 996, 132, 178, 33, 450,
146342 /* 720 */ 1203, 136, 406, 64, 64, 479, 64, 64, 419, 369,
146343 /* 730 */ 283, 1146, 252, 252, 109, 109, 109, 109, 108, 108,
146344 /* 740 */ 107, 107, 107, 106, 401, 512, 224, 440, 411, 266,
146345 /* 750 */ 1358, 266, 252, 252, 370, 296, 416, 284, 934, 396,
146346 /* 760 */ 976, 470, 400, 252, 252, 512, 9, 473, 231, 500,
146347 /* 770 */ 354, 1036, 1035, 1488, 355, 374, 512, 1121, 112, 113,
146348 /* 780 */ 103, 1100, 1100, 953, 956, 946, 946, 110, 110, 111,
146349 /* 790 */ 111, 111, 111, 252, 252, 1015, 515, 1347, 295, 252,
146350 /* 800 */ 252, 252, 252, 1098, 375, 249, 512, 445, 872, 322,
146351 /* 810 */ 1016, 480, 512, 195, 512, 434, 273, 15, 15, 515,
146352 /* 820 */ 314, 515, 95, 515, 93, 1017, 367, 109, 109, 109,
146353 /* 830 */ 109, 108, 108, 107, 107, 107, 106, 401, 515, 1121,
146354 /* 840 */ 39, 39, 51, 51, 52, 52, 503, 370, 515, 1204,
146355 /* 850 */ 1098, 918, 439, 341, 133, 436, 223, 222, 221, 53,
146356 /* 860 */ 53, 322, 1400, 761, 762, 763, 515, 370, 88, 54,
146357 /* 870 */ 54, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146358 /* 880 */ 110, 110, 111, 111, 111, 111, 407, 55, 55, 196,
146359 /* 890 */ 515, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146360 /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1149, 376,
146361 /* 910 */ 515, 40, 40, 515, 872, 515, 993, 515, 993, 116,
146362 /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146363 /* 930 */ 401, 41, 41, 515, 43, 43, 44, 44, 56, 56,
146364 /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146365 /* 950 */ 401, 515, 379, 515, 57, 57, 515, 799, 515, 379,
146366 /* 960 */ 515, 445, 200, 515, 323, 515, 1397, 515, 1459, 515,
146367 /* 970 */ 1287, 817, 58, 58, 14, 14, 515, 59, 59, 118,
146368 /* 980 */ 118, 60, 60, 515, 46, 46, 61, 61, 62, 62,
146369 /* 990 */ 47, 47, 515, 190, 189, 91, 515, 140, 140, 515,
146370 /* 1000 */ 394, 515, 277, 1200, 141, 141, 515, 1115, 515, 992,
146371 /* 1010 */ 515, 992, 515, 69, 69, 370, 278, 48, 48, 259,
146372 /* 1020 */ 65, 65, 119, 119, 246, 246, 260, 66, 66, 120,
146373 /* 1030 */ 120, 121, 121, 117, 117, 370, 515, 512, 383, 112,
146374 /* 1040 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146375 /* 1050 */ 111, 111, 111, 111, 515, 872, 515, 139, 139, 112,
146376 /* 1060 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146377 /* 1070 */ 111, 111, 111, 111, 1287, 138, 138, 125, 125, 515,
146378 /* 1080 */ 12, 515, 281, 1287, 515, 445, 131, 1287, 109, 109,
146379 /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146380 /* 1100 */ 124, 124, 122, 122, 515, 123, 123, 515, 109, 109,
146381 /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146382 /* 1120 */ 68, 68, 463, 783, 515, 70, 70, 302, 67, 67,
146383 /* 1130 */ 1032, 253, 253, 356, 1287, 191, 196, 1433, 465, 1301,
146384 /* 1140 */ 38, 38, 384, 94, 512, 42, 42, 177, 848, 274,
146385 /* 1150 */ 506, 385, 420, 847, 1356, 441, 508, 376, 377, 153,
146386 /* 1160 */ 423, 872, 432, 370, 224, 251, 194, 887, 182, 293,
146387 /* 1170 */ 783, 848, 88, 254, 466, 888, 847, 915, 807, 806,
146388 /* 1180 */ 230, 1241, 910, 370, 17, 413, 797, 112, 113, 103,
146389 /* 1190 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146390 /* 1200 */ 111, 111, 395, 814, 815, 1175, 983, 112, 101, 103,
146391 /* 1210 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146392 /* 1220 */ 111, 111, 375, 422, 427, 429, 298, 230, 230, 88,
146393 /* 1230 */ 1240, 451, 312, 797, 226, 88, 109, 109, 109, 109,
146394 /* 1240 */ 108, 108, 107, 107, 107, 106, 401, 86, 433, 979,
146395 /* 1250 */ 927, 881, 226, 983, 230, 415, 109, 109, 109, 109,
146396 /* 1260 */ 108, 108, 107, 107, 107, 106, 401, 320, 845, 781,
146397 /* 1270 */ 846, 100, 130, 100, 1403, 290, 370, 319, 1377, 1376,
146398 /* 1280 */ 437, 1449, 299, 1237, 303, 306, 308, 310, 1188, 1174,
146399 /* 1290 */ 1173, 1172, 315, 324, 325, 1228, 370, 927, 1249, 271,
146400 /* 1300 */ 1286, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146401 /* 1310 */ 110, 111, 111, 111, 111, 1224, 1235, 502, 501, 1292,
146402 /* 1320 */ 1221, 1155, 103, 1100, 1100, 953, 956, 946, 946, 110,
146403 /* 1330 */ 110, 111, 111, 111, 111, 1148, 1137, 1136, 1138, 1443,
146404 /* 1340 */ 446, 244, 184, 98, 507, 188, 4, 353, 327, 109,
146405 /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146406 /* 1360 */ 510, 329, 331, 199, 414, 456, 292, 285, 318, 109,
146407 /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146408 /* 1380 */ 11, 1271, 1279, 402, 361, 192, 1171, 1351, 431, 505,
146409 /* 1390 */ 346, 1350, 333, 98, 507, 504, 4, 187, 1446, 1115,
146410 /* 1400 */ 233, 1396, 155, 1394, 1112, 152, 72, 75, 378, 425,
146411 /* 1410 */ 510, 165, 149, 157, 933, 1276, 86, 30, 1268, 417,
146412 /* 1420 */ 96, 96, 8, 160, 161, 162, 163, 97, 418, 402,
146413 /* 1430 */ 517, 516, 449, 402, 923, 210, 358, 424, 1282, 438,
146414 /* 1440 */ 169, 214, 360, 1345, 80, 504, 31, 444, 1365, 301,
146415 /* 1450 */ 245, 274, 506, 216, 174, 305, 488, 447, 217, 462,
146416 /* 1460 */ 1139, 487, 218, 363, 933, 923, 923, 925, 926, 24,
146417 /* 1470 */ 96, 96, 1191, 1190, 1189, 391, 1182, 97, 1163, 402,
146418 /* 1480 */ 517, 516, 799, 364, 923, 1162, 317, 1161, 98, 507,
146419 /* 1490 */ 1181, 4, 1458, 472, 393, 269, 270, 475, 481, 1232,
146420 /* 1500 */ 85, 1233, 326, 328, 232, 510, 495, 1231, 330, 98,
146421 /* 1510 */ 507, 1230, 4, 486, 335, 923, 923, 925, 926, 24,
146422 /* 1520 */ 1435, 1068, 404, 181, 336, 256, 510, 115, 402, 332,
146423 /* 1530 */ 352, 352, 351, 241, 349, 1214, 1414, 770, 338, 10,
146424 /* 1540 */ 504, 340, 272, 92, 1331, 1213, 87, 183, 484, 402,
146425 /* 1550 */ 201, 488, 280, 239, 344, 345, 489, 1145, 29, 933,
146426 /* 1560 */ 279, 504, 1074, 518, 240, 96, 96, 242, 243, 519,
146427 /* 1570 */ 1134, 1129, 97, 154, 402, 517, 516, 372, 373, 923,
146428 /* 1580 */ 933, 142, 143, 128, 1381, 267, 96, 96, 852, 757,
146429 /* 1590 */ 203, 144, 403, 97, 1382, 402, 517, 516, 204, 1380,
146430 /* 1600 */ 923, 146, 1379, 1159, 1158, 71, 1156, 276, 202, 185,
146431 /* 1610 */ 923, 923, 925, 926, 24, 198, 257, 126, 991, 989,
146432 /* 1620 */ 907, 98, 507, 156, 4, 145, 158, 206, 831, 209,
146433 /* 1630 */ 291, 923, 923, 925, 926, 24, 1005, 911, 510, 164,
146434 /* 1640 */ 147, 380, 371, 382, 166, 76, 77, 274, 506, 148,
146435 /* 1650 */ 78, 79, 1008, 211, 212, 1004, 137, 213, 18, 300,
146436 /* 1660 */ 230, 402, 997, 1109, 443, 215, 32, 170, 171, 772,
146437 /* 1670 */ 409, 448, 319, 504, 219, 172, 452, 81, 19, 457,
146438 /* 1680 */ 313, 20, 82, 268, 488, 150, 810, 179, 83, 487,
146439 /* 1690 */ 464, 151, 933, 180, 959, 84, 1040, 34, 96, 96,
146440 /* 1700 */ 471, 1041, 35, 474, 193, 97, 248, 402, 517, 516,
146441 /* 1710 */ 1068, 404, 923, 250, 256, 880, 229, 175, 875, 352,
146442 /* 1720 */ 352, 351, 241, 349, 100, 21, 770, 22, 1054, 1056,
146443 /* 1730 */ 7, 98, 507, 1045, 4, 337, 1058, 23, 974, 201,
146444 /* 1740 */ 176, 280, 88, 923, 923, 925, 926, 24, 510, 279,
146445 /* 1750 */ 960, 958, 962, 1014, 963, 1013, 235, 234, 25, 36,
146446 /* 1760 */ 99, 90, 507, 928, 4, 511, 350, 782, 26, 841,
146447 /* 1770 */ 236, 402, 347, 1069, 237, 1125, 1125, 1451, 510, 203,
146448 /* 1780 */ 1450, 1125, 1125, 504, 1125, 1125, 1125, 204, 1125, 1125,
146449 /* 1790 */ 146, 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125,
146450 /* 1800 */ 1125, 402, 933, 1125, 1125, 1125, 1125, 1125, 96, 96,
146451 /* 1810 */ 1125, 1125, 1125, 504, 1125, 97, 1125, 402, 517, 516,
146452 /* 1820 */ 1125, 1125, 923, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146453 /* 1830 */ 1125, 371, 933, 1125, 1125, 1125, 274, 506, 96, 96,
146454 /* 1840 */ 1125, 1125, 1125, 1125, 1125, 97, 1125, 402, 517, 516,
146455 /* 1850 */ 1125, 1125, 923, 923, 923, 925, 926, 24, 1125, 409,
146456 /* 1860 */ 1125, 1125, 1125, 256, 1125, 1125, 1125, 1125, 352, 352,
146457 /* 1870 */ 351, 241, 349, 1125, 1125, 770, 1125, 1125, 1125, 1125,
146458 /* 1880 */ 1125, 1125, 1125, 923, 923, 925, 926, 24, 201, 1125,
146459 /* 1890 */ 280, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 279, 1125,
146460 /* 1900 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146461 /* 1910 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146462 /* 1920 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 203, 1125,
146463 /* 1930 */ 1125, 1125, 1125, 1125, 1125, 1125, 204, 1125, 1125, 146,
146464 /* 1940 */ 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125, 1125,
146465 /* 1950 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146466 /* 1960 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146467 /* 1970 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146468 /* 1980 */ 371, 1125, 1125, 1125, 1125, 274, 506, 1125, 1125, 1125,
146469 /* 1990 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146470 /* 2000 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 409,
146471 };
146472 static const YYCODETYPE yy_lookahead[] = {
146473 /* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
146474 /* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
146475 /* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -146609,48 +147428,48 @@
146609 /* 1360 */ 36, 222, 222, 260, 226, 188, 256, 226, 187, 92,
146610 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
146611 /* 1380 */ 210, 213, 213, 59, 213, 196, 192, 187, 256, 244,
146612 /* 1390 */ 212, 187, 226, 19, 20, 71, 22, 210, 166, 60,
146613 /* 1400 */ 130, 170, 260, 170, 38, 81, 257, 257, 170, 104,
146614 /* 1410 */ 36, 22, 43, 201, 90, 236, 138, 235, 213, 18,
146615 /* 1420 */ 96, 97, 48, 204, 204, 204, 204, 103, 170, 105,
146616 /* 1430 */ 106, 107, 18, 59, 110, 169, 213, 213, 201, 170,
146617 /* 1440 */ 201, 169, 236, 213, 146, 71, 235, 62, 253, 252,
146618 /* 1450 */ 170, 127, 128, 169, 22, 170, 82, 189, 169, 104,
146619 /* 1460 */ 170, 87, 169, 189, 90, 141, 142, 143, 144, 145,
146620 /* 1470 */ 96, 97, 186, 186, 186, 64, 194, 103, 186, 105,
146621 /* 1480 */ 106, 107, 115, 189, 110, 188, 186, 186, 19, 20,
146622 /* 1490 */ 194, 22, 186, 189, 102, 246, 246, 189, 133, 228,
146623 /* 1500 */ 104, 228, 227, 227, 170, 36, 134, 228, 227, 19,
146624 /* 1510 */ 20, 228, 22, 84, 271, 141, 142, 143, 144, 145,
146625 /* 1520 */ 0, 1, 2, 216, 22, 5, 36, 137, 59, 227,
146626 /* 1530 */ 10, 11, 12, 13, 14, 217, 269, 17, 216, 22,
146627 /* 1540 */ 71, 170, 243, 146, 241, 217, 136, 215, 135, 59,
146628 /* 1550 */ 30, 82, 32, 25, 214, 213, 87, 173, 26, 90,
146629 /* 1560 */ 40, 71, 13, 172, 164, 96, 97, 164, 6, 162,
146630 /* 1570 */ 162, 162, 103, 263, 105, 106, 107, 266, 266, 110,
146631 /* 1580 */ 90, 176, 176, 190, 182, 190, 96, 97, 98, 4,
146632 /* 1590 */ 70, 176, 3, 103, 182, 105, 106, 107, 78, 182,
146633 /* 1600 */ 110, 81, 182, 182, 182, 182, 182, 151, 88, 22,
146634 /* 1610 */ 141, 142, 143, 144, 145, 15, 89, 16, 23, 23,
146635 /* 1620 */ 128, 19, 20, 139, 22, 119, 131, 24, 20, 133,
146636 /* 1630 */ 16, 141, 142, 143, 144, 145, 1, 140, 36, 131,
146637 /* 1640 */ 119, 61, 122, 37, 139, 53, 53, 127, 128, 119,
146638 /* 1650 */ 53, 53, 105, 34, 130, 1, 5, 104, 22, 149,
146639 /* 1660 */ 26, 59, 68, 75, 41, 130, 24, 68, 104, 20,
146640 /* 1670 */ 150, 19, 120, 71, 114, 22, 67, 22, 22, 67,
146641 /* 1680 */ 23, 22, 22, 67, 82, 37, 28, 23, 138, 87,
146642 /* 1690 */ 22, 153, 90, 23, 23, 26, 23, 22, 96, 97,
146643 /* 1700 */ 24, 23, 22, 24, 130, 103, 23, 105, 106, 107,
146644 /* 1710 */ 1, 2, 110, 23, 5, 105, 34, 22, 132, 10,
146645 /* 1720 */ 11, 12, 13, 14, 26, 34, 17, 34, 85, 83,
146646 /* 1730 */ 44, 19, 20, 23, 22, 24, 75, 34, 23, 30,
146647 /* 1740 */ 26, 32, 26, 141, 142, 143, 144, 145, 36, 40,
146648 /* 1750 */ 23, 23, 23, 23, 11, 23, 22, 26, 22, 22,
146649 /* 1760 */ 22, 19, 20, 23, 22, 26, 15, 23, 22, 124,
146650 /* 1770 */ 130, 59, 23, 1, 130, 277, 277, 130, 36, 70,
146651 /* 1780 */ 130, 277, 277, 71, 277, 277, 277, 78, 277, 277,
146652 /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
146653 /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
146654 /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
146655 /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
146656 /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -146671,11 +147490,11 @@
146671 /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
146672 /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
146673 /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
146674 /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
146675 };
146676 #define YY_SHIFT_COUNT (520)
146677 #define YY_SHIFT_MIN (0)
146678 #define YY_SHIFT_MAX (1858)
146679 static const unsigned short int yy_shift_ofst[] = {
146680 /* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
146681 /* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -146703,39 +147522,39 @@
146703 /* 230 */ 531, 531, 744, 531, 531, 783, 531, 531, 531, 531,
146704 /* 240 */ 531, 531, 531, 531, 419, 682, 327, 370, 370, 370,
146705 /* 250 */ 370, 1029, 327, 327, 1024, 897, 856, 947, 1109, 706,
146706 /* 260 */ 706, 1143, 1109, 1109, 1143, 842, 945, 1118, 1136, 1136,
146707 /* 270 */ 1136, 706, 676, 400, 1047, 694, 1339, 1270, 1270, 1366,
146708 /* 280 */ 1366, 1270, 1305, 1389, 1369, 1278, 1401, 1401, 1401, 1401,
146709 /* 290 */ 1270, 1414, 1278, 1278, 1305, 1389, 1369, 1369, 1278, 1270,
146710 /* 300 */ 1414, 1298, 1385, 1270, 1414, 1432, 1270, 1414, 1270, 1414,
146711 /* 310 */ 1432, 1355, 1355, 1355, 1411, 1432, 1355, 1367, 1355, 1411,
146712 /* 320 */ 1355, 1355, 1432, 1392, 1392, 1432, 1365, 1396, 1365, 1396,
146713 /* 330 */ 1365, 1396, 1365, 1396, 1270, 1372, 1429, 1502, 1390, 1372,
146714 /* 340 */ 1517, 1270, 1397, 1390, 1410, 1413, 1278, 1528, 1532, 1549,
146715 /* 350 */ 1549, 1562, 1562, 1562, 2009, 2009, 2009, 2009, 2009, 2009,
146716 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
146717 /* 370 */ 570, 345, 686, 748, 50, 740, 1064, 1107, 469, 537,
146718 /* 380 */ 1042, 1146, 1162, 1154, 1201, 1202, 1203, 1208, 1209, 1127,
146719 /* 390 */ 1069, 1196, 1157, 1147, 1226, 1228, 1245, 775, 868, 1246,
146720 /* 400 */ 1247, 1191, 1151, 1585, 1589, 1587, 1456, 1600, 1527, 1601,
146721 /* 410 */ 1595, 1596, 1492, 1484, 1506, 1603, 1495, 1608, 1496, 1614,
146722 /* 420 */ 1635, 1508, 1497, 1521, 1580, 1606, 1505, 1592, 1593, 1597,
146723 /* 430 */ 1598, 1530, 1547, 1619, 1524, 1654, 1651, 1636, 1553, 1510,
146724 /* 440 */ 1594, 1634, 1599, 1588, 1623, 1535, 1564, 1642, 1649, 1652,
146725 /* 450 */ 1552, 1560, 1653, 1609, 1655, 1656, 1657, 1659, 1612, 1658,
146726 /* 460 */ 1660, 1616, 1648, 1664, 1550, 1668, 1538, 1670, 1671, 1669,
146727 /* 470 */ 1673, 1675, 1676, 1678, 1680, 1679, 1574, 1683, 1690, 1610,
146728 /* 480 */ 1682, 1695, 1586, 1698, 1691, 1698, 1693, 1643, 1661, 1646,
146729 /* 490 */ 1686, 1710, 1711, 1714, 1716, 1703, 1715, 1698, 1727, 1728,
146730 /* 500 */ 1729, 1730, 1731, 1732, 1734, 1743, 1736, 1737, 1740, 1744,
146731 /* 510 */ 1738, 1746, 1739, 1645, 1640, 1644, 1647, 1650, 1749, 1751,
146732 /* 520 */ 1772,
146733 };
146734 #define YY_REDUCE_COUNT (369)
146735 #define YY_REDUCE_MIN (-237)
146736 #define YY_REDUCE_MAX (1424)
146737 static const short yy_reduce_ofst[] = {
146738 /* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
146739 /* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
146740 /* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
146741 /* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -146761,74 +147580,75 @@
146761 /* 230 */ 1137, 1152, 1077, 1153, 1155, 1114, 1156, 304, 1158, 1172,
146762 /* 240 */ 1173, 1174, 1175, 1176, 1089, 1091, 1133, 1098, 1126, 1139,
146763 /* 250 */ 1140, 1070, 1133, 1133, 1170, 1163, 1186, 1103, 1168, 1138,
146764 /* 260 */ 1141, 1110, 1169, 1171, 1132, 1177, 1189, 1194, 1181, 1200,
146765 /* 270 */ 1204, 1166, 1145, 1178, 1187, 1232, 1142, 1231, 1233, 1149,
146766 /* 280 */ 1150, 1238, 1179, 1182, 1212, 1205, 1219, 1220, 1221, 1222,
146767 /* 290 */ 1258, 1266, 1223, 1224, 1206, 1211, 1237, 1239, 1230, 1269,
146768 /* 300 */ 1272, 1195, 1197, 1280, 1284, 1268, 1285, 1289, 1290, 1293,
146769 /* 310 */ 1274, 1286, 1287, 1288, 1282, 1294, 1292, 1297, 1300, 1296,
146770 /* 320 */ 1301, 1306, 1304, 1249, 1250, 1308, 1271, 1275, 1273, 1276,
146771 /* 330 */ 1279, 1281, 1283, 1302, 1334, 1307, 1243, 1267, 1318, 1322,
146772 /* 340 */ 1303, 1371, 1299, 1328, 1332, 1340, 1342, 1384, 1391, 1400,
146773 /* 350 */ 1403, 1407, 1408, 1409, 1311, 1312, 1310, 1405, 1402, 1412,
146774 /* 360 */ 1417, 1420, 1406, 1393, 1395, 1421, 1422, 1423, 1424, 1415,
 
146775 };
146776 static const YYACTIONTYPE yy_default[] = {
146777 /* 0 */ 1492, 1492, 1492, 1340, 1123, 1229, 1123, 1123, 1123, 1340,
146778 /* 10 */ 1340, 1340, 1123, 1259, 1259, 1391, 1154, 1123, 1123, 1123,
146779 /* 20 */ 1123, 1123, 1123, 1123, 1339, 1123, 1123, 1123, 1123, 1123,
146780 /* 30 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1265, 1123,
146781 /* 40 */ 1123, 1123, 1123, 1123, 1341, 1342, 1123, 1123, 1123, 1390,
146782 /* 50 */ 1392, 1275, 1274, 1273, 1272, 1373, 1246, 1270, 1263, 1267,
146783 /* 60 */ 1335, 1336, 1334, 1338, 1342, 1341, 1123, 1266, 1306, 1320,
146784 /* 70 */ 1305, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146785 /* 80 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146786 /* 90 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146787 /* 100 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146788 /* 110 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1314, 1319, 1325,
146789 /* 120 */ 1318, 1315, 1308, 1307, 1309, 1310, 1123, 1144, 1193, 1123,
146790 /* 130 */ 1123, 1123, 1123, 1409, 1408, 1123, 1123, 1154, 1311, 1312,
146791 /* 140 */ 1322, 1321, 1398, 1448, 1447, 1123, 1123, 1123, 1123, 1123,
146792 /* 150 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146793 /* 160 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146794 /* 170 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1154, 1150, 1300,
146795 /* 180 */ 1299, 1418, 1150, 1253, 1123, 1404, 1229, 1220, 1123, 1123,
146796 /* 190 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146797 /* 200 */ 1123, 1395, 1393, 1123, 1355, 1123, 1123, 1123, 1123, 1123,
146798 /* 210 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146799 /* 220 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146800 /* 230 */ 1123, 1123, 1225, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146801 /* 240 */ 1123, 1123, 1123, 1442, 1123, 1368, 1207, 1225, 1225, 1225,
146802 /* 250 */ 1225, 1227, 1208, 1206, 1219, 1154, 1130, 1484, 1269, 1248,
146803 /* 260 */ 1248, 1481, 1269, 1269, 1481, 1168, 1462, 1165, 1259, 1259,
146804 /* 270 */ 1259, 1248, 1337, 1226, 1219, 1123, 1484, 1234, 1234, 1483,
146805 /* 280 */ 1483, 1234, 1278, 1284, 1196, 1269, 1202, 1202, 1202, 1202,
146806 /* 290 */ 1234, 1141, 1269, 1269, 1278, 1284, 1196, 1196, 1269, 1234,
146807 /* 300 */ 1141, 1372, 1478, 1234, 1141, 1348, 1234, 1141, 1234, 1141,
146808 /* 310 */ 1348, 1194, 1194, 1194, 1183, 1348, 1194, 1168, 1194, 1183,
146809 /* 320 */ 1194, 1194, 1348, 1352, 1352, 1348, 1252, 1247, 1252, 1247,
146810 /* 330 */ 1252, 1247, 1252, 1247, 1234, 1253, 1417, 1123, 1264, 1253,
146811 /* 340 */ 1343, 1234, 1123, 1264, 1262, 1260, 1269, 1147, 1186, 1445,
146812 /* 350 */ 1445, 1441, 1441, 1441, 1489, 1489, 1404, 1457, 1154, 1154,
146813 /* 360 */ 1154, 1154, 1457, 1170, 1170, 1154, 1154, 1154, 1154, 1457,
146814 /* 370 */ 1123, 1123, 1123, 1123, 1123, 1123, 1452, 1123, 1357, 1238,
146815 /* 380 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146816 /* 390 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146817 /* 400 */ 1123, 1123, 1289, 1123, 1126, 1401, 1123, 1123, 1399, 1123,
146818 /* 410 */ 1123, 1123, 1123, 1123, 1123, 1239, 1123, 1123, 1123, 1123,
146819 /* 420 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146820 /* 430 */ 1123, 1123, 1123, 1123, 1480, 1123, 1123, 1123, 1123, 1123,
146821 /* 440 */ 1123, 1371, 1370, 1123, 1123, 1236, 1123, 1123, 1123, 1123,
146822 /* 450 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146823 /* 460 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146824 /* 470 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146825 /* 480 */ 1123, 1123, 1123, 1261, 1123, 1416, 1123, 1123, 1123, 1123,
146826 /* 490 */ 1123, 1123, 1123, 1430, 1254, 1123, 1123, 1471, 1123, 1123,
146827 /* 500 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146828 /* 510 */ 1123, 1123, 1466, 1210, 1291, 1123, 1290, 1294, 1123, 1135,
146829 /* 520 */ 1123,
146830 };
146831 /********** End of lemon-generated parsing tables *****************************/
146832
146833 /* The next table maps tokens (terminal symbols) into fallback tokens.
146834 ** If a construct like the following:
@@ -147448,14 +148268,14 @@
147448 /* 137 */ "having_opt ::= HAVING expr",
147449 /* 138 */ "limit_opt ::=",
147450 /* 139 */ "limit_opt ::= LIMIT expr",
147451 /* 140 */ "limit_opt ::= LIMIT expr OFFSET expr",
147452 /* 141 */ "limit_opt ::= LIMIT expr COMMA expr",
147453 /* 142 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
147454 /* 143 */ "where_opt ::=",
147455 /* 144 */ "where_opt ::= WHERE expr",
147456 /* 145 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
147457 /* 146 */ "setlist ::= setlist COMMA nm EQ expr",
147458 /* 147 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
147459 /* 148 */ "setlist ::= nm EQ expr",
147460 /* 149 */ "setlist ::= LP idlist RP EQ expr",
147461 /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
@@ -148328,14 +149148,14 @@
148328 { 215, -2 }, /* (137) having_opt ::= HAVING expr */
148329 { 217, 0 }, /* (138) limit_opt ::= */
148330 { 217, -2 }, /* (139) limit_opt ::= LIMIT expr */
148331 { 217, -4 }, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
148332 { 217, -4 }, /* (141) limit_opt ::= LIMIT expr COMMA expr */
148333 { 160, -6 }, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
148334 { 213, 0 }, /* (143) where_opt ::= */
148335 { 213, -2 }, /* (144) where_opt ::= WHERE expr */
148336 { 160, -8 }, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
148337 { 233, -5 }, /* (146) setlist ::= setlist COMMA nm EQ expr */
148338 { 233, -7 }, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
148339 { 233, -3 }, /* (148) setlist ::= nm EQ expr */
148340 { 233, -5 }, /* (149) setlist ::= LP idlist RP EQ expr */
148341 { 160, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
@@ -149215,21 +150035,21 @@
149215 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
149216 break;
149217 case 141: /* limit_opt ::= LIMIT expr COMMA expr */
149218 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
149219 break;
149220 case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
149221 {
149222 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy135, &yymsp[-1].minor.yy0);
149223 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy135,yymsp[0].minor.yy18,0,0);
149224 }
149225 break;
149226 case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
149227 {
149228 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
149229 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy420,"set list");
149230 sqlite3Update(pParse,yymsp[-4].minor.yy135,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,yymsp[-5].minor.yy70,0,0,0);
 
 
 
 
 
 
149231 }
149232 break;
149233 case 146: /* setlist ::= setlist COMMA nm EQ expr */
149234 {
149235 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
@@ -151197,10 +152017,77 @@
151197 while( IdChar(z[i]) ){ i++; }
151198 *tokenType = TK_ID;
151199 return i;
151200 }
151201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151202 /*
151203 ** Run the parser on the given SQL string. The parser structure is
151204 ** passed in. An SQLITE_ status code is returned. If an error occurs
151205 ** then an and attempt is made to write an error message into
151206 ** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
@@ -152594,10 +153481,11 @@
152594 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
152595 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
152596 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
152597 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
152598 { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
 
152599 };
152600 unsigned int i;
152601 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
152602 for(i=0; i<ArraySize(aFlagOp); i++){
152603 if( aFlagOp[i].op==op ){
@@ -154820,10 +155708,13 @@
154820 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
154821 | SQLITE_Fts3Tokenizer
154822 #endif
154823 #if defined(SQLITE_ENABLE_QPSG)
154824 | SQLITE_EnableQPSG
 
 
 
154825 #endif
154826 ;
154827 sqlite3HashInit(&db->aCollSeq);
154828 #ifndef SQLITE_OMIT_VIRTUALTABLE
154829 sqlite3HashInit(&db->aModule);
@@ -159159,11 +160050,11 @@
159159 ){
159160 int rc = SQLITE_OK; /* Return code */
159161 const char *zCsr = zNode; /* Cursor to iterate through node */
159162 const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
159163 char *zBuffer = 0; /* Buffer to load terms into */
159164 int nAlloc = 0; /* Size of allocated buffer */
159165 int isFirstTerm = 1; /* True when processing first term on page */
159166 sqlite3_int64 iChild; /* Block id of child node to descend to */
159167
159168 /* Skip over the 'height' varint that occurs at the start of every
159169 ** interior node. Then load the blockid of the left-child of the b-tree
@@ -159197,18 +160088,18 @@
159197 }
159198 isFirstTerm = 0;
159199 zCsr += fts3GetVarint32(zCsr, &nSuffix);
159200
159201 assert( nPrefix>=0 && nSuffix>=0 );
159202 if( &zCsr[nSuffix]>zEnd ){
159203 rc = FTS_CORRUPT_VTAB;
159204 goto finish_scan;
159205 }
159206 if( nPrefix+nSuffix>nAlloc ){
159207 char *zNew;
159208 nAlloc = (nPrefix+nSuffix) * 2;
159209 zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);
159210 if( !zNew ){
159211 rc = SQLITE_NOMEM;
159212 goto finish_scan;
159213 }
159214 zBuffer = zNew;
@@ -161183,13 +162074,28 @@
161183 assert( p->mxSavepoint >= iSavepoint );
161184 TESTONLY( p->mxSavepoint = iSavepoint );
161185 sqlite3Fts3PendingTermsClear(p);
161186 return SQLITE_OK;
161187 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161188
161189 static const sqlite3_module fts3Module = {
161190 /* iVersion */ 2,
161191 /* xCreate */ fts3CreateMethod,
161192 /* xConnect */ fts3ConnectMethod,
161193 /* xBestIndex */ fts3BestIndexMethod,
161194 /* xDisconnect */ fts3DisconnectMethod,
161195 /* xDestroy */ fts3DestroyMethod,
@@ -161208,10 +162114,11 @@
161208 /* xFindFunction */ fts3FindFunctionMethod,
161209 /* xRename */ fts3RenameMethod,
161210 /* xSavepoint */ fts3SavepointMethod,
161211 /* xRelease */ fts3ReleaseMethod,
161212 /* xRollbackTo */ fts3RollbackToMethod,
 
161213 };
161214
161215 /*
161216 ** This function is registered as the module destructor (called when an
161217 ** FTS3 enabled database connection is closed). It frees the memory
@@ -163839,11 +164746,12 @@
163839 0, /* xRollback */
163840 0, /* xFindFunction */
163841 0, /* xRename */
163842 0, /* xSavepoint */
163843 0, /* xRelease */
163844 0 /* xRollbackTo */
 
163845 };
163846 int rc; /* Return code */
163847
163848 rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0);
163849 return rc;
@@ -167398,11 +168306,12 @@
167398 0, /* xRollback */
167399 0, /* xFindFunction */
167400 0, /* xRename */
167401 0, /* xSavepoint */
167402 0, /* xRelease */
167403 0 /* xRollbackTo */
 
167404 };
167405 int rc; /* Return code */
167406
167407 rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
167408 return rc;
@@ -168786,19 +169695,23 @@
168786
168787 /* Because of the FTS3_NODE_PADDING bytes of padding, the following is
168788 ** safe (no risk of overread) even if the node data is corrupted. */
168789 pNext += fts3GetVarint32(pNext, &nPrefix);
168790 pNext += fts3GetVarint32(pNext, &nSuffix);
168791 if( nPrefix<0 || nSuffix<=0
168792 || &pNext[nSuffix]>&pReader->aNode[pReader->nNode]
 
168793 ){
168794 return FTS_CORRUPT_VTAB;
168795 }
168796
168797 if( nPrefix+nSuffix>pReader->nTermAlloc ){
168798 int nNew = (nPrefix+nSuffix)*2;
168799 char *zNew = sqlite3_realloc(pReader->zTerm, nNew);
 
 
 
168800 if( !zNew ){
168801 return SQLITE_NOMEM;
168802 }
168803 pReader->zTerm = zNew;
168804 pReader->nTermAlloc = nNew;
@@ -168816,11 +169729,11 @@
168816
168817 /* Check that the doclist does not appear to extend past the end of the
168818 ** b-tree node. And that the final byte of the doclist is 0x00. If either
168819 ** of these statements is untrue, then the data structure is corrupt.
168820 */
168821 if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode]
168822 || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
168823 ){
168824 return FTS_CORRUPT_VTAB;
168825 }
168826 return SQLITE_OK;
@@ -171142,25 +172055,30 @@
171142 if( bFirst==0 ){
171143 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
171144 }
171145 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
171146
 
 
 
171147 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
171148 if( rc==SQLITE_OK ){
171149 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
171150 p->term.n = nPrefix+nSuffix;
171151 p->iOff += nSuffix;
171152 if( p->iChild==0 ){
171153 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
 
 
 
171154 p->aDoclist = &p->aNode[p->iOff];
171155 p->iOff += p->nDoclist;
171156 }
171157 }
171158 }
171159
171160 assert( p->iOff<=p->nNode );
171161
171162 return rc;
171163 }
171164
171165 /*
171166 ** Release all dynamic resources held by node-reader object *p.
@@ -177960,11 +178878,12 @@
177960 0, /* xRollback */
177961 0, /* xFindMethod */
177962 0, /* xRename */
177963 0, /* xSavepoint */
177964 0, /* xRelease */
177965 0 /* xRollbackTo */
 
177966 };
177967
177968 /* The methods of the json_tree virtual table. */
177969 static sqlite3_module jsonTreeModule = {
177970 0, /* iVersion */
@@ -177987,11 +178906,12 @@
177987 0, /* xRollback */
177988 0, /* xFindMethod */
177989 0, /* xRename */
177990 0, /* xSavepoint */
177991 0, /* xRelease */
177992 0 /* xRollbackTo */
 
177993 };
177994 #endif /* SQLITE_OMIT_VIRTUALTABLE */
177995
177996 /****************************************************************************
177997 ** The following routines are the only publically visible identifiers in this
@@ -181417,12 +182337,28 @@
181417 }
181418
181419 return rc;
181420 }
181421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181422 static sqlite3_module rtreeModule = {
181423 2, /* iVersion */
181424 rtreeCreate, /* xCreate - create a table */
181425 rtreeConnect, /* xConnect - connect to an existing table */
181426 rtreeBestIndex, /* xBestIndex - Determine search strategy */
181427 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
181428 rtreeDestroy, /* xDestroy - Drop a table */
@@ -181441,10 +182377,11 @@
181441 0, /* xFindFunction - function overloading */
181442 rtreeRename, /* xRename - rename the table */
181443 rtreeSavepoint, /* xSavepoint */
181444 0, /* xRelease */
181445 0, /* xRollbackTo */
 
181446 };
181447
181448 static int rtreeSqlInit(
181449 Rtree *pRtree,
181450 sqlite3 *db,
@@ -182431,17 +183368,27 @@
182431 ** The on-disk representation consists of a 4-byte header followed by
182432 ** the values. The 4-byte header is:
182433 **
182434 ** encoding (1 byte) 0=big-endian, 1=little-endian
182435 ** nvertex (3 bytes) Number of vertexes as a big-endian integer
 
 
 
 
 
182436 */
182437 typedef struct GeoPoly GeoPoly;
182438 struct GeoPoly {
182439 int nVertex; /* Number of vertexes */
182440 unsigned char hdr[4]; /* Header for on-disk representation */
182441 GeoCoord a[2]; /* 2*nVertex values. X (longitude) first, then Y */
182442 };
 
 
 
 
 
182443
182444 /*
182445 ** State of a parse of a GeoJSON input.
182446 */
182447 typedef struct GeoParse GeoParse;
@@ -182463,11 +183410,11 @@
182463 a[2] = t;
182464 }
182465
182466 /* Skip whitespace. Return the next non-whitespace character. */
182467 static char geopolySkipSpace(GeoParse *p){
182468 while( p->z[0] && safe_isspace(p->z[0]) ) p->z++;
182469 return p->z[0];
182470 }
182471
182472 /* Parse out a number. Write the value into *pVal if pVal!=0.
182473 ** return non-zero on success and zero if the next token is not a number.
@@ -182483,11 +183430,11 @@
182483 c = z[j];
182484 }
182485 if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
182486 for(;; j++){
182487 c = z[j];
182488 if( c>='0' && c<='9' ) continue;
182489 if( c=='.' ){
182490 if( z[j-1]=='-' ) return 0;
182491 if( seenDP ) return 0;
182492 seenDP = 1;
182493 continue;
@@ -182505,11 +183452,21 @@
182505 continue;
182506 }
182507 break;
182508 }
182509 if( z[j-1]<'0' ) return 0;
182510 if( pVal ) *pVal = (GeoCoord)atof((const char*)p->z);
 
 
 
 
 
 
 
 
 
 
182511 p->z += j;
182512 return 1;
182513 }
182514
182515 /*
@@ -182563,16 +183520,14 @@
182563 && s.nVertex>=4
182564 && s.a[0]==s.a[s.nVertex*2-2]
182565 && s.a[1]==s.a[s.nVertex*2-1]
182566 && (s.z++, geopolySkipSpace(&s)==0)
182567 ){
182568 int nByte;
182569 GeoPoly *pOut;
182570 int x = 1;
182571 s.nVertex--; /* Remove the redundant vertex at the end */
182572 nByte = sizeof(GeoPoly) * s.nVertex*2*sizeof(GeoCoord);
182573 pOut = sqlite3_malloc64( nByte );
182574 x = 1;
182575 if( pOut==0 ) goto parse_json_err;
182576 pOut->nVertex = s.nVertex;
182577 memcpy(pOut->a, s.a, s.nVertex*2*sizeof(GeoCoord));
182578 pOut->hdr[0] = *(unsigned char*)&x;
@@ -182770,10 +183725,31 @@
182770 sqlite3_result_blob(context, p->hdr,
182771 4+8*p->nVertex, SQLITE_TRANSIENT);
182772 sqlite3_free(p);
182773 }
182774 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182775
182776 /*
182777 ** Implementation of the geopoly_area(X) function.
182778 **
182779 ** If the input is a well-formed Geopoly BLOB then return the area
@@ -182786,24 +183762,109 @@
182786 int argc,
182787 sqlite3_value **argv
182788 ){
182789 GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
182790 if( p ){
182791 double rArea = 0.0;
182792 int ii;
182793 for(ii=0; ii<p->nVertex-1; ii++){
182794 rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
182795 * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
182796 * 0.5;
182797 }
182798 rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
182799 * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
182800 * 0.5;
182801 sqlite3_result_double(context, rArea);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182802 sqlite3_free(p);
182803 }
182804 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182805
182806 /*
182807 ** If pPoly is a polygon, compute its bounding box. Then:
182808 **
182809 ** (1) if aCoord!=0 store the bounding box in aCoord, returning NULL
@@ -182845,11 +183906,11 @@
182845 else if( r>mxY ) mxY = (float)r;
182846 }
182847 if( pRc ) *pRc = SQLITE_OK;
182848 if( aCoord==0 ){
182849 geopolyBboxFill:
182850 pOut = sqlite3_realloc(p, sizeof(GeoPoly)+sizeof(GeoCoord)*6);
182851 if( pOut==0 ){
182852 sqlite3_free(p);
182853 if( context ) sqlite3_result_error_nomem(context);
182854 if( pRc ) *pRc = SQLITE_NOMEM;
182855 return 0;
@@ -183873,11 +184934,20 @@
183873 sqlite3_bind_int64(pUp, 1, cell.iRowid);
183874 assert( pRtree->nAux>=1 );
183875 if( sqlite3_value_nochange(aData[2]) ){
183876 sqlite3_bind_null(pUp, 2);
183877 }else{
183878 sqlite3_bind_value(pUp, 2, aData[2]);
 
 
 
 
 
 
 
 
 
183879 nChange = 1;
183880 }
183881 for(jj=1; jj<pRtree->nAux; jj++){
183882 nChange++;
183883 sqlite3_bind_value(pUp, jj+2, aData[jj+2]);
@@ -183917,11 +184987,11 @@
183917 return 0;
183918 }
183919
183920
183921 static sqlite3_module geopolyModule = {
183922 2, /* iVersion */
183923 geopolyCreate, /* xCreate - create a table */
183924 geopolyConnect, /* xConnect - connect to an existing table */
183925 geopolyBestIndex, /* xBestIndex - Determine search strategy */
183926 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
183927 rtreeDestroy, /* xDestroy - Drop a table */
@@ -183940,29 +185010,33 @@
183940 geopolyFindFunction, /* xFindFunction - function overloading */
183941 rtreeRename, /* xRename - rename the table */
183942 rtreeSavepoint, /* xSavepoint */
183943 0, /* xRelease */
183944 0, /* xRollbackTo */
 
183945 };
183946
183947 static int sqlite3_geopoly_init(sqlite3 *db){
183948 int rc = SQLITE_OK;
183949 static const struct {
183950 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
183951 int nArg;
 
183952 const char *zName;
183953 } aFunc[] = {
183954 { geopolyAreaFunc, 1, "geopoly_area" },
183955 { geopolyBlobFunc, 1, "geopoly_blob" },
183956 { geopolyJsonFunc, 1, "geopoly_json" },
183957 { geopolySvgFunc, -1, "geopoly_svg" },
183958 { geopolyWithinFunc, 2, "geopoly_within" },
183959 { geopolyContainsPointFunc, 3, "geopoly_contains_point" },
183960 { geopolyOverlapFunc, 2, "geopoly_overlap" },
183961 { geopolyDebugFunc, 1, "geopoly_debug" },
183962 { geopolyBBoxFunc, 1, "geopoly_bbox" },
183963 { geopolyXformFunc, 7, "geopoly_xform" },
 
 
183964 };
183965 static const struct {
183966 void (*xStep)(sqlite3_context*,int,sqlite3_value**);
183967 void (*xFinal)(sqlite3_context*);
183968 const char *zName;
@@ -183969,12 +185043,13 @@
183969 } aAgg[] = {
183970 { geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox" },
183971 };
183972 int i;
183973 for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
 
183974 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
183975 SQLITE_UTF8, 0,
183976 aFunc[i].xFunc, 0, 0);
183977 }
183978 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
183979 rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,
183980 0, aAgg[i].xStep, aAgg[i].xFinal);
@@ -185997,11 +187072,12 @@
185997 struct rbu_vfs {
185998 sqlite3_vfs base; /* rbu VFS shim methods */
185999 sqlite3_vfs *pRealVfs; /* Underlying VFS */
186000 sqlite3_mutex *mutex; /* Mutex to protect pMain */
186001 sqlite3rbu *pRbu; /* Owner RBU object */
186002 rbu_file *pMain; /* Linked list of main db files */
 
186003 };
186004
186005 /*
186006 ** Each file opened by an rbu VFS is represented by an instance of
186007 ** the following structure.
@@ -186026,10 +187102,11 @@
186026 char *zDel; /* Delete this when closing file */
186027
186028 const char *zWal; /* Wal filename for this main db file */
186029 rbu_file *pWalFd; /* Wal file descriptor for this main db */
186030 rbu_file *pMainNext; /* Next MAIN_DB file */
 
186031 };
186032
186033 /*
186034 ** True for an RBU vacuum handle, or false otherwise.
186035 */
@@ -189621,10 +190698,73 @@
189621 pFd->sz = nNew;
189622 assert( pRbu->szTemp>=0 );
189623 if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;
189624 return SQLITE_OK;
189625 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189626
189627 /*
189628 ** Close an rbu file.
189629 */
189630 static int rbuVfsClose(sqlite3_file *pFile){
@@ -189639,21 +190779,18 @@
189639 sqlite3_free(p->apShm);
189640 p->apShm = 0;
189641 sqlite3_free(p->zDel);
189642
189643 if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
189644 rbu_file **pp;
189645 sqlite3_mutex_enter(p->pRbuVfs->mutex);
189646 for(pp=&p->pRbuVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext));
189647 *pp = p->pMainNext;
189648 sqlite3_mutex_leave(p->pRbuVfs->mutex);
189649 rbuUnlockShm(p);
189650 p->pReal->pMethods->xShmUnmap(p->pReal, 0);
189651 }
189652 else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){
189653 rbuUpdateTempSize(p, 0);
189654 }
 
189655
189656 /* Close the underlying file handle */
189657 rc = p->pReal->pMethods->xClose(p->pReal);
189658 return rc;
189659 }
@@ -189908,10 +191045,13 @@
189908 rc = SQLITE_ERROR;
189909 pRbu->zErrmsg = sqlite3_mprintf("rbu/zipvfs setup error");
189910 }else if( rc==SQLITE_NOTFOUND ){
189911 pRbu->pTargetFd = p;
189912 p->pRbu = pRbu;
 
 
 
189913 if( p->pWalFd ) p->pWalFd->pRbu = pRbu;
189914 rc = SQLITE_OK;
189915 }
189916 }
189917 return rc;
@@ -190069,24 +191209,10 @@
190069 rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
190070 }
190071 return rc;
190072 }
190073
190074 /*
190075 ** Given that zWal points to a buffer containing a wal file name passed to
190076 ** either the xOpen() or xAccess() VFS method, return a pointer to the
190077 ** file-handle opened by the same database connection on the corresponding
190078 ** database file.
190079 */
190080 static rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal){
190081 rbu_file *pDb;
190082 sqlite3_mutex_enter(pRbuVfs->mutex);
190083 for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}
190084 sqlite3_mutex_leave(pRbuVfs->mutex);
190085 return pDb;
190086 }
190087
190088 /*
190089 ** A main database named zName has just been opened. The following
190090 ** function returns a pointer to a buffer owned by SQLite that contains
190091 ** the name of the *-wal file this db connection will use. SQLite
190092 ** happens to pass a pointer to this buffer when using xAccess()
@@ -190161,11 +191287,11 @@
190161 ** happens to pass a pointer to this buffer when using xAccess()
190162 ** or xOpen() to operate on the *-wal file. */
190163 pFd->zWal = rbuMainToWal(zName, flags);
190164 }
190165 else if( flags & SQLITE_OPEN_WAL ){
190166 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName);
190167 if( pDb ){
190168 if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
190169 /* This call is to open a *-wal file. Intead, open the *-oal. This
190170 ** code ensures that the string passed to xOpen() is terminated by a
190171 ** pair of '\0' bytes in case the VFS attempts to extract a URI
@@ -190213,14 +191339,11 @@
190213 /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods
190214 ** pointer and, if the file is a main database file, link it into the
190215 ** mutex protected linked list of all such files. */
190216 pFile->pMethods = &rbuvfs_io_methods;
190217 if( flags & SQLITE_OPEN_MAIN_DB ){
190218 sqlite3_mutex_enter(pRbuVfs->mutex);
190219 pFd->pMainNext = pRbuVfs->pMain;
190220 pRbuVfs->pMain = pFd;
190221 sqlite3_mutex_leave(pRbuVfs->mutex);
190222 }
190223 }else{
190224 sqlite3_free(pFd->zDel);
190225 }
190226
@@ -190264,11 +191387,11 @@
190264 ** causing SQLite to call xOpen() to open it. This call will also
190265 ** be intercepted (see the rbuVfsOpen() function) and the *-oal
190266 ** file opened instead.
190267 */
190268 if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){
190269 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath);
190270 if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
190271 if( *pResOut ){
190272 rc = SQLITE_CANTOPEN;
190273 }else{
190274 sqlite3_int64 sz = 0;
@@ -190737,18 +191860,24 @@
190737
190738 *ppCursor = (sqlite3_vtab_cursor *)pCsr;
190739 return SQLITE_OK;
190740 }
190741
190742 static void statClearPage(StatPage *p){
190743 int i;
190744 if( p->aCell ){
190745 for(i=0; i<p->nCell; i++){
190746 sqlite3_free(p->aCell[i].aOvfl);
190747 }
190748 sqlite3_free(p->aCell);
190749 }
 
 
 
 
 
 
190750 sqlite3PagerUnref(p->pPg);
190751 sqlite3_free(p->zPath);
190752 memset(p, 0, sizeof(StatPage));
190753 }
190754
@@ -190807,26 +191936,37 @@
190807
190808 u8 *aData = sqlite3PagerGetData(p->pPg);
190809 u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];
190810
190811 p->flags = aHdr[0];
 
 
 
 
 
 
 
 
 
 
190812 p->nCell = get2byte(&aHdr[3]);
190813 p->nMxPayload = 0;
190814
190815 isLeaf = (p->flags==0x0A || p->flags==0x0D);
190816 nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;
190817
190818 nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;
190819 nUnused += (int)aHdr[7];
190820 iOff = get2byte(&aHdr[1]);
190821 while( iOff ){
 
 
190822 nUnused += get2byte(&aData[iOff+2]);
190823 iOff = get2byte(&aData[iOff]);
 
 
190824 }
190825 p->nUnused = nUnused;
190826 p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
190827 szPage = sqlite3BtreeGetPageSize(pBt);
190828
190829 if( p->nCell ){
190830 int i; /* Used to iterate through cells */
190831 int nUsable; /* Usable bytes per page */
190832
@@ -190839,10 +191979,11 @@
190839
190840 for(i=0; i<p->nCell; i++){
190841 StatCell *pCell = &p->aCell[i];
190842
190843 iOff = get2byte(&aData[nHdr+i*2]);
 
190844 if( !isLeaf ){
190845 pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);
190846 iOff += 4;
190847 }
190848 if( p->flags==0x05 ){
@@ -190855,12 +191996,12 @@
190855 u64 dummy;
190856 iOff += sqlite3GetVarint(&aData[iOff], &dummy);
190857 }
190858 if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
190859 getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
 
190860 pCell->nLocal = nLocal;
190861 assert( nLocal>=0 );
190862 assert( nPayload>=(u32)nLocal );
190863 assert( nLocal<=(nUsable-35) );
190864 if( nPayload>(u32)nLocal ){
190865 int j;
190866 int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);
@@ -190885,10 +192026,15 @@
190885 }
190886 }
190887 }
190888
190889 return SQLITE_OK;
 
 
 
 
 
190890 }
190891
190892 /*
190893 ** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
190894 ** the current value of pCsr->iPageno.
@@ -191180,10 +192326,11 @@
191180 0, /* xFindMethod */
191181 0, /* xRename */
191182 0, /* xSavepoint */
191183 0, /* xRelease */
191184 0, /* xRollbackTo */
 
191185 };
191186 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
191187 }
191188 #elif defined(SQLITE_ENABLE_DBSTAT_VTAB)
191189 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191504,10 +192651,14 @@
191504 int iDb;
191505 Btree *pBt;
191506 Pager *pPager;
191507 int szPage;
191508
 
 
 
 
191509 if( argc==1 ){
191510 zErr = "cannot delete";
191511 goto update_fail;
191512 }
191513 pgno = sqlite3_value_int(argv[0]);
@@ -191594,10 +192745,11 @@
191594 0, /* xFindMethod */
191595 0, /* xRename */
191596 0, /* xSavepoint */
191597 0, /* xRelease */
191598 0, /* xRollbackTo */
 
191599 };
191600 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
191601 }
191602 #elif defined(SQLITE_ENABLE_DBPAGE_VTAB)
191603 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191629,10 +192781,12 @@
191629 # define SESSIONS_STRM_CHUNK_SIZE 64
191630 # else
191631 # define SESSIONS_STRM_CHUNK_SIZE 1024
191632 # endif
191633 #endif
 
 
191634
191635 typedef struct SessionHook SessionHook;
191636 struct SessionHook {
191637 void *pCtx;
191638 int (*xOld)(void*,int,sqlite3_value**);
@@ -191692,10 +192846,11 @@
191692 */
191693 struct sqlite3_changeset_iter {
191694 SessionInput in; /* Input buffer or stream */
191695 SessionBuffer tblhdr; /* Buffer to hold apValue/zTab/abPK/ */
191696 int bPatchset; /* True if this is a patchset */
 
191697 int rc; /* Iterator error code */
191698 sqlite3_stmt *pConflict; /* Points to conflicting row, if any */
191699 char *zTab; /* Current table */
191700 int nCol; /* Number of columns in zTab */
191701 int op; /* Current operation */
@@ -191848,10 +193003,46 @@
191848 ** and fields associated with modified columns contain the new column values.
191849 **
191850 ** The records associated with INSERT changes are in the same format as for
191851 ** changesets. It is not possible for a record associated with an INSERT
191852 ** change to contain a field set to "undefined".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191853 */
191854
191855 /*
191856 ** For each row modified during a session, there exists a single instance of
191857 ** this structure stored in a SessionTable.aChange[] hash table.
@@ -193398,16 +194589,16 @@
193398 ** set *pRc to SQLITE_NOMEM and return non-zero.
193399 */
193400 static int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){
193401 if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){
193402 u8 *aNew;
193403 int nNew = p->nAlloc ? p->nAlloc : 128;
193404 do {
193405 nNew = nNew*2;
193406 }while( nNew<(p->nBuf+nByte) );
193407
193408 aNew = (u8 *)sqlite3_realloc(p->aBuf, nNew);
193409 if( 0==aNew ){
193410 *pRc = SQLITE_NOMEM;
193411 }else{
193412 p->aBuf = aNew;
193413 p->nAlloc = nNew;
@@ -194001,16 +195192,16 @@
194001 }
194002 if( rc==SQLITE_OK ){
194003 rc = sqlite3_reset(pSel);
194004 }
194005
194006 /* If the buffer is now larger than SESSIONS_STRM_CHUNK_SIZE, pass
194007 ** its contents to the xOutput() callback. */
194008 if( xOutput
194009 && rc==SQLITE_OK
194010 && buf.nBuf>nNoop
194011 && buf.nBuf>SESSIONS_STRM_CHUNK_SIZE
194012 ){
194013 rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);
194014 nNoop = -1;
194015 buf.nBuf = 0;
194016 }
@@ -194145,11 +195336,12 @@
194145 static int sessionChangesetStart(
194146 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194147 int (*xInput)(void *pIn, void *pData, int *pnData),
194148 void *pIn,
194149 int nChangeset, /* Size of buffer pChangeset in bytes */
194150 void *pChangeset /* Pointer to buffer containing changeset */
 
194151 ){
194152 sqlite3_changeset_iter *pRet; /* Iterator to return */
194153 int nByte; /* Number of bytes to allocate for iterator */
194154
194155 assert( xInput==0 || (pChangeset==0 && nChangeset==0) );
@@ -194165,10 +195357,11 @@
194165 pRet->in.aData = (u8 *)pChangeset;
194166 pRet->in.nData = nChangeset;
194167 pRet->in.xInput = xInput;
194168 pRet->in.pIn = pIn;
194169 pRet->in.bEof = (xInput ? 0 : 1);
 
194170
194171 /* Populate the output variable and return success. */
194172 *pp = pRet;
194173 return SQLITE_OK;
194174 }
@@ -194179,11 +195372,20 @@
194179 SQLITE_API int sqlite3changeset_start(
194180 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194181 int nChangeset, /* Size of buffer pChangeset in bytes */
194182 void *pChangeset /* Pointer to buffer containing changeset */
194183 ){
194184 return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset);
 
 
 
 
 
 
 
 
 
194185 }
194186
194187 /*
194188 ** Streaming version of sqlite3changeset_start().
194189 */
@@ -194190,19 +195392,28 @@
194190 SQLITE_API int sqlite3changeset_start_strm(
194191 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
194192 int (*xInput)(void *pIn, void *pData, int *pnData),
194193 void *pIn
194194 ){
194195 return sessionChangesetStart(pp, xInput, pIn, 0, 0);
 
 
 
 
 
 
 
 
 
194196 }
194197
194198 /*
194199 ** If the SessionInput object passed as the only argument is a streaming
194200 ** object and the buffer is full, discard some data to free up space.
194201 */
194202 static void sessionDiscardData(SessionInput *pIn){
194203 if( pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){
194204 int nMove = pIn->buf.nBuf - pIn->iNext;
194205 assert( nMove>=0 );
194206 if( nMove>0 ){
194207 memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);
194208 }
@@ -194221,11 +195432,11 @@
194221 */
194222 static int sessionInputBuffer(SessionInput *pIn, int nByte){
194223 int rc = SQLITE_OK;
194224 if( pIn->xInput ){
194225 while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){
194226 int nNew = SESSIONS_STRM_CHUNK_SIZE;
194227
194228 if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);
194229 if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){
194230 rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);
194231 if( nNew==0 ){
@@ -194569,14 +195780,14 @@
194569 p->in.iCurrent = p->in.iNext;
194570 if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
194571 op = p->in.aData[p->in.iNext++];
194572 }
194573
194574 if( p->zTab==0 ){
194575 /* The first record in the changeset is not a table header. Must be a
194576 ** corrupt changeset. */
194577 assert( p->in.iNext==1 );
194578 return (p->rc = SQLITE_CORRUPT_BKPT);
194579 }
194580
194581 p->op = op;
194582 p->bIndirect = p->in.aData[p->in.iNext++];
@@ -194597,37 +195808,43 @@
194597 p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);
194598 if( p->rc!=SQLITE_OK ) return p->rc;
194599 *paRec = &p->in.aData[p->in.iNext];
194600 p->in.iNext += *pnRec;
194601 }else{
 
 
194602
194603 /* If this is an UPDATE or DELETE, read the old.* record. */
194604 if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){
194605 u8 *abPK = p->bPatchset ? p->abPK : 0;
194606 p->rc = sessionReadRecord(&p->in, p->nCol, abPK, p->apValue);
194607 if( p->rc!=SQLITE_OK ) return p->rc;
194608 }
194609
194610 /* If this is an INSERT or UPDATE, read the new.* record. */
194611 if( p->op!=SQLITE_DELETE ){
194612 p->rc = sessionReadRecord(&p->in, p->nCol, 0, &p->apValue[p->nCol]);
194613 if( p->rc!=SQLITE_OK ) return p->rc;
194614 }
194615
194616 if( p->bPatchset && p->op==SQLITE_UPDATE ){
194617 /* If this is an UPDATE that is part of a patchset, then all PK and
194618 ** modified fields are present in the new.* record. The old.* record
194619 ** is currently completely empty. This block shifts the PK fields from
194620 ** new.* to old.*, to accommodate the code that reads these arrays. */
194621 for(i=0; i<p->nCol; i++){
194622 assert( p->apValue[i]==0 );
194623 if( p->abPK[i] ){
 
194624 p->apValue[i] = p->apValue[i+p->nCol];
194625 if( p->apValue[i]==0 ) return (p->rc = SQLITE_CORRUPT_BKPT);
194626 p->apValue[i+p->nCol] = 0;
194627 }
194628 }
 
 
 
194629 }
194630 }
194631
194632 return SQLITE_ROW;
194633 }
@@ -194940,11 +196157,11 @@
194940 rc = SQLITE_CORRUPT_BKPT;
194941 goto finished_invert;
194942 }
194943
194944 assert( rc==SQLITE_OK );
194945 if( xOutput && sOut.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){
194946 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
194947 sOut.nBuf = 0;
194948 if( rc!=SQLITE_OK ) goto finished_invert;
194949 }
194950 }
@@ -195019,11 +196236,12 @@
195019 u8 *abPK; /* Boolean array - true if column is in PK */
195020 int bStat1; /* True if table is sqlite_stat1 */
195021 int bDeferConstraints; /* True to defer constraints */
195022 SessionBuffer constraints; /* Deferred constraints are stored here */
195023 SessionBuffer rebase; /* Rebase information (if any) here */
195024 int bRebaseStarted; /* If table header is already in rebase */
 
195025 };
195026
195027 /*
195028 ** Formulate a statement to DELETE a row from database db. Assuming a table
195029 ** structure like this:
@@ -195416,39 +196634,40 @@
195416 SessionApplyCtx *p, /* Apply context */
195417 int eType, /* Conflict resolution (OMIT or REPLACE) */
195418 sqlite3_changeset_iter *pIter /* Iterator pointing at current change */
195419 ){
195420 int rc = SQLITE_OK;
195421 int i;
195422 int eOp = pIter->op;
195423 if( p->bRebaseStarted==0 ){
195424 /* Append a table-header to the rebase buffer */
195425 const char *zTab = pIter->zTab;
195426 sessionAppendByte(&p->rebase, 'T', &rc);
195427 sessionAppendVarint(&p->rebase, p->nCol, &rc);
195428 sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
195429 sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
195430 p->bRebaseStarted = 1;
195431 }
195432
195433 assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );
195434 assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );
195435
195436 sessionAppendByte(&p->rebase,
195437 (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
195438 );
195439 sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
195440 for(i=0; i<p->nCol; i++){
195441 sqlite3_value *pVal = 0;
195442 if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){
195443 sqlite3changeset_old(pIter, i, &pVal);
195444 }else{
195445 sqlite3changeset_new(pIter, i, &pVal);
195446 }
195447 sessionAppendValue(&p->rebase, pVal, &rc);
195448 }
195449
 
195450 return rc;
195451 }
195452
195453 /*
195454 ** Invoke the conflict handler for the change that the changeset iterator
@@ -195787,11 +197006,11 @@
195787 while( pApply->constraints.nBuf ){
195788 sqlite3_changeset_iter *pIter2 = 0;
195789 SessionBuffer cons = pApply->constraints;
195790 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
195791
195792 rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf);
195793 if( rc==SQLITE_OK ){
195794 int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
195795 int rc2;
195796 pIter2->bPatchset = bPatchset;
195797 pIter2->zTab = (char*)zTab;
@@ -195853,10 +197072,11 @@
195853
195854 assert( xConflict!=0 );
195855
195856 pIter->in.bNoDiscard = 1;
195857 memset(&sApply, 0, sizeof(sApply));
 
195858 sqlite3_mutex_enter(sqlite3_db_mutex(db));
195859 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
195860 rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
195861 }
195862 if( rc==SQLITE_OK ){
@@ -196003,11 +197223,12 @@
196003 sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
196004 sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
196005 }
196006 }
196007
196008 if( rc==SQLITE_OK && bPatchset==0 && ppRebase && pnRebase ){
 
196009 *ppRebase = (void*)sApply.rebase.aBuf;
196010 *pnRebase = sApply.rebase.nBuf;
196011 sApply.rebase.aBuf = 0;
196012 }
196013 sqlite3_finalize(sApply.pInsert);
@@ -196041,11 +197262,12 @@
196041 void *pCtx, /* First argument passed to xConflict */
196042 void **ppRebase, int *pnRebase,
196043 int flags
196044 ){
196045 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
196046 int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
 
196047 if( rc==SQLITE_OK ){
196048 rc = sessionChangesetApply(
196049 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
196050 );
196051 }
@@ -196098,11 +197320,12 @@
196098 void *pCtx, /* First argument passed to xConflict */
196099 void **ppRebase, int *pnRebase,
196100 int flags
196101 ){
196102 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
196103 int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
 
196104 if( rc==SQLITE_OK ){
196105 rc = sessionChangesetApply(
196106 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
196107 );
196108 }
@@ -196471,17 +197694,16 @@
196471 SessionChange *p;
196472 for(p=pTab->apChange[i]; p; p=p->pNext){
196473 sessionAppendByte(&buf, p->op, &rc);
196474 sessionAppendByte(&buf, p->bIndirect, &rc);
196475 sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);
 
 
 
 
196476 }
196477 }
196478
196479 if( rc==SQLITE_OK && xOutput && buf.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){
196480 rc = xOutput(pOut, buf.aBuf, buf.nBuf);
196481 buf.nBuf = 0;
196482 }
196483 }
196484
196485 if( rc==SQLITE_OK ){
196486 if( xOutput ){
196487 if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
@@ -196868,11 +198090,11 @@
196868 if( bDone==0 ){
196869 sessionAppendByte(&sOut, pIter->op, &rc);
196870 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
196871 sessionAppendBlob(&sOut, aRec, nRec, &rc);
196872 }
196873 if( rc==SQLITE_OK && xOutput && sOut.nBuf>SESSIONS_STRM_CHUNK_SIZE ){
196874 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
196875 sOut.nBuf = 0;
196876 }
196877 if( rc ) break;
196878 }
@@ -196978,10 +198200,31 @@
196978 if( p ){
196979 sessionDeleteTable(p->grp.pList);
196980 sqlite3_free(p);
196981 }
196982 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196983
196984 #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
196985
196986 /************** End of sqlite3session.c **************************************/
196987 /************** Begin file fts5.c ********************************************/
@@ -210693,11 +211936,11 @@
210693 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
210694 pRet = 0;
210695 fts5CloseReader(p);
210696 }
210697
210698 *ppIter = &pRet->base;
210699 sqlite3Fts5BufferFree(&buf);
210700 }
210701 return fts5IndexReturn(p);
210702 }
210703
@@ -214442,16 +215685,31 @@
214442 int nArg, /* Number of args */
214443 sqlite3_value **apUnused /* Function arguments */
214444 ){
214445 assert( nArg==0 );
214446 UNUSED_PARAM2(nArg, apUnused);
214447 sqlite3_result_text(pCtx, "fts5: 2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7", -1, SQLITE_TRANSIENT);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214448 }
214449
214450 static int fts5Init(sqlite3 *db){
214451 static const sqlite3_module fts5Mod = {
214452 /* iVersion */ 2,
214453 /* xCreate */ fts5CreateMethod,
214454 /* xConnect */ fts5ConnectMethod,
214455 /* xBestIndex */ fts5BestIndexMethod,
214456 /* xDisconnect */ fts5DisconnectMethod,
214457 /* xDestroy */ fts5DestroyMethod,
@@ -214470,10 +215728,11 @@
214470 /* xFindFunction */ fts5FindFunctionMethod,
214471 /* xRename */ fts5RenameMethod,
214472 /* xSavepoint */ fts5SavepointMethod,
214473 /* xRelease */ fts5ReleaseMethod,
214474 /* xRollbackTo */ fts5RollbackToMethod,
 
214475 };
214476
214477 int rc;
214478 Fts5Global *pGlobal = 0;
214479
@@ -218514,20 +219773,22 @@
218514 int rc = SQLITE_OK;
218515 Fts5IndexIter *pIter = pCsr->pIter;
218516 i64 *pp = &pCsr->iInstPos;
218517 int *po = &pCsr->iInstOff;
218518
 
 
218519 while( eDetail==FTS5_DETAIL_NONE
218520 || sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp)
218521 ){
218522 pCsr->iInstPos = 0;
218523 pCsr->iInstOff = 0;
218524
218525 rc = sqlite3Fts5IterNextScan(pCsr->pIter);
218526 if( rc==SQLITE_OK ){
218527 rc = fts5VocabInstanceNewTerm(pCsr);
218528 if( eDetail==FTS5_DETAIL_NONE ) break;
218529 }
218530 if( rc ){
218531 pCsr->bEof = 1;
218532 break;
218533 }
@@ -218838,17 +220099,16 @@
218838 /* xFindFunction */ 0,
218839 /* xRename */ 0,
218840 /* xSavepoint */ 0,
218841 /* xRelease */ 0,
218842 /* xRollbackTo */ 0,
 
218843 };
218844 void *p = (void*)pGlobal;
218845
218846 return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0);
218847 }
218848
218849
218850
218851
218852
218853 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
218854
@@ -219120,10 +220380,11 @@
219120 0, /* xFindMethod */
219121 0, /* xRename */
219122 0, /* xSavepoint */
219123 0, /* xRelease */
219124 0, /* xRollbackTo */
 
219125 };
219126
219127 #endif /* SQLITE_OMIT_VIRTUALTABLE */
219128
219129 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
@@ -219152,12 +220413,12 @@
219152 }
219153 #endif /* SQLITE_CORE */
219154 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219155
219156 /************** End of stmt.c ************************************************/
219157 #if __LINE__!=219157
219158 #undef SQLITE_SOURCE_ID
219159 #define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792alt2"
219160 #endif
219161 /* Return the source-id for this library */
219162 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219163 /************************** End of sqlite3.c ******************************/
219164
--- 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.26.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.
@@ -257,10 +257,13 @@
257 #if SQLITE_ENABLE_FTS4
258 "ENABLE_FTS4",
259 #endif
260 #if SQLITE_ENABLE_FTS5
261 "ENABLE_FTS5",
262 #endif
263 #if SQLITE_ENABLE_GEOPOLY
264 "ENABLE_GEOPOLY",
265 #endif
266 #if SQLITE_ENABLE_HIDDEN_COLUMNS
267 "ENABLE_HIDDEN_COLUMNS",
268 #endif
269 #if SQLITE_ENABLE_ICU
@@ -287,10 +290,13 @@
290 #if SQLITE_ENABLE_MEMSYS5
291 "ENABLE_MEMSYS5",
292 #endif
293 #if SQLITE_ENABLE_MULTIPLEX
294 "ENABLE_MULTIPLEX",
295 #endif
296 #if SQLITE_ENABLE_NORMALIZE
297 "ENABLE_NORMALIZE",
298 #endif
299 #if SQLITE_ENABLE_NULL_TRIM
300 "ENABLE_NULL_TRIM",
301 #endif
302 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
@@ -1154,13 +1160,13 @@
1160 **
1161 ** See also: [sqlite3_libversion()],
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.26.0"
1166 #define SQLITE_VERSION_NUMBER 3026000
1167 #define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -3048,10 +3054,11 @@
3054 ** the call worked. ^The [sqlite3_db_config()] interface will return a
3055 ** non-zero [error code] if a discontinued or unsupported configuration option
3056 ** is invoked.
3057 **
3058 ** <dl>
3059 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
3060 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
3061 ** <dd> ^This option takes three additional arguments that determine the
3062 ** [lookaside memory allocator] configuration for the [database connection].
3063 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
3064 ** pointer to a memory buffer to use for lookaside memory.
@@ -3070,10 +3077,11 @@
3077 ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
3078 ** Any attempt to change the lookaside memory configuration when lookaside
3079 ** memory is in use leaves the configuration unchanged and returns
3080 ** [SQLITE_BUSY].)^</dd>
3081 **
3082 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
3083 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
3084 ** <dd> ^This option is used to enable or disable the enforcement of
3085 ** [foreign key constraints]. There should be two additional arguments.
3086 ** The first argument is an integer which is 0 to disable FK enforcement,
3087 ** positive to enable FK enforcement or negative to leave FK enforcement
@@ -3080,10 +3088,11 @@
3088 ** unchanged. The second parameter is a pointer to an integer into which
3089 ** is written 0 or 1 to indicate whether FK enforcement is off or on
3090 ** following this call. The second parameter may be a NULL pointer, in
3091 ** which case the FK enforcement setting is not reported back. </dd>
3092 **
3093 ** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]
3094 ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
3095 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
3096 ** There should be two additional arguments.
3097 ** The first argument is an integer which is 0 to disable triggers,
3098 ** positive to enable triggers or negative to leave the setting unchanged.
@@ -3090,10 +3099,11 @@
3099 ** The second parameter is a pointer to an integer into which
3100 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
3101 ** following this call. The second parameter may be a NULL pointer, in
3102 ** which case the trigger setting is not reported back. </dd>
3103 **
3104 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
3105 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
3106 ** <dd> ^This option is used to enable or disable the two-argument
3107 ** version of the [fts3_tokenizer()] function which is part of the
3108 ** [FTS3] full-text search engine extension.
3109 ** There should be two additional arguments.
@@ -3103,10 +3113,11 @@
3113 ** The second parameter is a pointer to an integer into which
3114 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
3115 ** following this call. The second parameter may be a NULL pointer, in
3116 ** which case the new setting is not reported back. </dd>
3117 **
3118 ** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]
3119 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
3120 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
3121 ** interface independently of the [load_extension()] SQL function.
3122 ** The [sqlite3_enable_load_extension()] API enables or disables both the
3123 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -3120,19 +3131,20 @@
3131 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
3132 ** is disabled or enabled following this call. The second parameter may
3133 ** be a NULL pointer, in which case the new setting is not reported back.
3134 ** </dd>
3135 **
3136 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
3137 ** <dd> ^This option is used to change the name of the "main" database
3138 ** schema. ^The sole argument is a pointer to a constant UTF8 string
3139 ** which will become the new schema name in place of "main". ^SQLite
3140 ** does not make a copy of the new main schema name string, so the application
3141 ** must ensure that the argument passed into this DBCONFIG option is unchanged
3142 ** until after the database connection closes.
3143 ** </dd>
3144 **
3145 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
3146 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
3147 ** <dd> Usually, when a database in wal mode is closed or detached from a
3148 ** database handle, SQLite checks if this will mean that there are now no
3149 ** connections at all to the database. If so, it performs a checkpoint
3150 ** operation before closing the connection. This option may be used to
@@ -3142,11 +3154,11 @@
3154 ** The second parameter is a pointer to an integer
3155 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
3156 ** have been disabled - 0 if they are not disabled, 1 if they are.
3157 ** </dd>
3158 **
3159 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
3160 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
3161 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
3162 ** a single SQL query statement will always use the same algorithm regardless
3163 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
3164 ** that look at the values of bound parameters, which can make some queries
@@ -3158,11 +3170,11 @@
3170 ** unchanged. The second parameter is a pointer to an integer into which
3171 ** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
3172 ** following this call.
3173 ** </dd>
3174 **
3175 ** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
3176 ** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
3177 ** include output for any operations performed by trigger programs. This
3178 ** option is used to set or clear (the default) a flag that governs this
3179 ** behavior. The first parameter passed to this operation is an integer -
3180 ** positive to enable output for trigger programs, or zero to disable it,
@@ -3170,11 +3182,11 @@
3182 ** The second parameter is a pointer to an integer into which is written
3183 ** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
3184 ** it is not disabled, 1 if it is.
3185 ** </dd>
3186 **
3187 ** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
3188 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
3189 ** [VACUUM] in order to reset a database back to an empty database
3190 ** with no schema and no content. The following process works even for
3191 ** a badly corrupted database file:
3192 ** <ol>
@@ -3189,10 +3201,22 @@
3201 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
3202 ** </ol>
3203 ** Because resetting a database is destructive and irreversible, the
3204 ** process requires the use of this obscure API and multiple steps to help
3205 ** ensure that it does not happen by accident.
3206 **
3207 ** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
3208 ** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
3209 ** "defensive" flag for a database connection. When the defensive
3210 ** flag is enabled, language features that allow ordinary SQL to
3211 ** deliberately corrupt the database file are disabled. The disabled
3212 ** features include but are not limited to the following:
3213 ** <ul>
3214 ** <li> The [PRAGMA writable_schema=ON] statement.
3215 ** <li> Writes to the [sqlite_dbpage] virtual table.
3216 ** <li> Direct writes to [shadow tables].
3217 ** </ul>
3218 ** </dd>
3219 ** </dl>
3220 */
3221 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3222 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -3202,11 +3226,12 @@
3226 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
3227 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3228 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3229 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
3230 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
3231 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3232 #define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
3233
3234 /*
3235 ** CAPI3REF: Enable Or Disable Extended Result Codes
3236 ** METHOD: sqlite3
3237 **
@@ -4640,13 +4665,23 @@
4665 ** be used just once or at most a few times and then destroyed using
4666 ** [sqlite3_finalize()] relatively soon. The current implementation acts
4667 ** on this hint by avoiding the use of [lookaside memory] so as not to
4668 ** deplete the limited store of lookaside memory. Future versions of
4669 ** SQLite may act on this hint differently.
4670 **
4671 ** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
4672 ** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
4673 ** representation of the SQL statement should be calculated and then
4674 ** associated with the prepared statement, which can be obtained via
4675 ** the [sqlite3_normalized_sql()] interface. The semantics used to
4676 ** normalize a SQL statement are unspecified and subject to change.
4677 ** At a minimum, literal values will be replaced with suitable
4678 ** placeholders.
4679 ** </dl>
4680 */
4681 #define SQLITE_PREPARE_PERSISTENT 0x01
4682 #define SQLITE_PREPARE_NORMALIZE 0x02
4683
4684 /*
4685 ** CAPI3REF: Compiling An SQL Statement
4686 ** KEYWORDS: {SQL statement compiler}
4687 ** METHOD: sqlite3
@@ -4800,10 +4835,15 @@
4835 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
4836 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
4837 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
4838 ** string containing the SQL text of prepared statement P with
4839 ** [bound parameters] expanded.
4840 ** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8
4841 ** string containing the normalized SQL text of prepared statement P. The
4842 ** semantics used to normalize a SQL statement are unspecified and subject
4843 ** to change. At a minimum, literal values will be replaced with suitable
4844 ** placeholders.
4845 **
4846 ** ^(For example, if a prepared statement is created using the SQL
4847 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
4848 ** and parameter :xyz is unbound, then sqlite3_sql() will return
4849 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -4815,18 +4855,20 @@
4855 **
4856 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
4857 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
4858 ** option causes sqlite3_expanded_sql() to always return NULL.
4859 **
4860 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
4861 ** are managed by SQLite and are automatically freed when the prepared
4862 ** statement is finalized.
4863 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4864 ** is obtained from [sqlite3_malloc()] and must be free by the application
4865 ** by passing it to [sqlite3_free()].
4866 */
4867 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4868 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4869 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4870
4871 /*
4872 ** CAPI3REF: Determine If An SQL Statement Writes The Database
4873 ** METHOD: sqlite3_stmt
4874 **
@@ -7312,10 +7354,13 @@
7354 /* The methods above are in version 1 of the sqlite_module object. Those
7355 ** below are for version 2 and greater. */
7356 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
7357 int (*xRelease)(sqlite3_vtab *pVTab, int);
7358 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
7359 /* The methods above are in versions 1 and 2 of the sqlite_module object.
7360 ** Those below are for version 3 and greater. */
7361 int (*xShadowName)(const char*);
7362 };
7363
7364 /*
7365 ** CAPI3REF: Virtual Table Indexing Information
7366 ** KEYWORDS: sqlite3_index_info
@@ -9646,10 +9691,11 @@
9691 ** These macros define the various options to the
9692 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
9693 ** can use to customize and optimize their behavior.
9694 **
9695 ** <dl>
9696 ** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]
9697 ** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
9698 ** <dd>Calls of the form
9699 ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
9700 ** where X is an integer. If X is zero, then the [virtual table] whose
9701 ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -10911,16 +10957,42 @@
10957 ** an application iterates through a changeset using an iterator created by
10958 ** this function, all changes that relate to a single table are visited
10959 ** consecutively. There is no chance that the iterator will visit a change
10960 ** the applies to table X, then one for table Y, and then later on visit
10961 ** another change for table X.
10962 **
10963 ** The behavior of sqlite3changeset_start_v2() and its streaming equivalent
10964 ** may be modified by passing a combination of
10965 ** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.
10966 **
10967 ** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>
10968 ** and therefore subject to change.
10969 */
10970 SQLITE_API int sqlite3changeset_start(
10971 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
10972 int nChangeset, /* Size of changeset blob in bytes */
10973 void *pChangeset /* Pointer to blob containing changeset */
10974 );
10975 SQLITE_API int sqlite3changeset_start_v2(
10976 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
10977 int nChangeset, /* Size of changeset blob in bytes */
10978 void *pChangeset, /* Pointer to blob containing changeset */
10979 int flags /* SESSION_CHANGESETSTART_* flags */
10980 );
10981
10982 /*
10983 ** CAPI3REF: Flags for sqlite3changeset_start_v2
10984 **
10985 ** The following flags may passed via the 4th parameter to
10986 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
10987 **
10988 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
10989 ** Invert the changeset while iterating through it. This is equivalent to
10990 ** inverting a changeset using sqlite3changeset_invert() before applying it.
10991 ** It is an error to specify this flag with a patchset.
10992 */
10993 #define SQLITE_CHANGESETSTART_INVERT 0x0002
10994
10995
10996 /*
10997 ** CAPI3REF: Advance A Changeset Iterator
10998 ** METHOD: sqlite3_changeset_iter
@@ -11571,11 +11643,11 @@
11643 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
11644 sqlite3_changeset_iter *p /* Handle describing change and conflict */
11645 ),
11646 void *pCtx, /* First argument passed to xConflict */
11647 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
11648 int flags /* SESSION_CHANGESETAPPLY_* flags */
11649 );
11650
11651 /*
11652 ** CAPI3REF: Flags for sqlite3changeset_apply_v2
11653 **
@@ -11589,12 +11661,18 @@
11661 ** SAVEPOINT is committed if the changeset or patchset is successfully
11662 ** applied, or rolled back if an error occurs. Specifying this flag
11663 ** causes the sessions module to omit this savepoint. In this case, if the
11664 ** caller has an open transaction or savepoint when apply_v2() is called,
11665 ** it may revert the partially applied changeset by rolling it back.
11666 **
11667 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
11668 ** Invert the changeset before applying it. This is equivalent to inverting
11669 ** a changeset using sqlite3changeset_invert() before applying it. It is
11670 ** an error to specify this flag with a patchset.
11671 */
11672 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
11673 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
11674
11675 /*
11676 ** CAPI3REF: Constants Passed To The Conflict Handler
11677 **
11678 ** Values that may be passed as the second argument to a conflict-handler.
@@ -11983,10 +12061,16 @@
12061 );
12062 SQLITE_API int sqlite3changeset_start_strm(
12063 sqlite3_changeset_iter **pp,
12064 int (*xInput)(void *pIn, void *pData, int *pnData),
12065 void *pIn
12066 );
12067 SQLITE_API int sqlite3changeset_start_v2_strm(
12068 sqlite3_changeset_iter **pp,
12069 int (*xInput)(void *pIn, void *pData, int *pnData),
12070 void *pIn,
12071 int flags
12072 );
12073 SQLITE_API int sqlite3session_changeset_strm(
12074 sqlite3_session *pSession,
12075 int (*xOutput)(void *pOut, const void *pData, int nData),
12076 void *pOut
@@ -12010,10 +12094,49 @@
12094 void *pIn,
12095 int (*xOutput)(void *pOut, const void *pData, int nData),
12096 void *pOut
12097 );
12098
12099 /*
12100 ** CAPI3REF: Configure global parameters
12101 **
12102 ** The sqlite3session_config() interface is used to make global configuration
12103 ** changes to the sessions module in order to tune it to the specific needs
12104 ** of the application.
12105 **
12106 ** The sqlite3session_config() interface is not threadsafe. If it is invoked
12107 ** while any other thread is inside any other sessions method then the
12108 ** results are undefined. Furthermore, if it is invoked after any sessions
12109 ** related objects have been created, the results are also undefined.
12110 **
12111 ** The first argument to the sqlite3session_config() function must be one
12112 ** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The
12113 ** interpretation of the (void*) value passed as the second parameter and
12114 ** the effect of calling this function depends on the value of the first
12115 ** parameter.
12116 **
12117 ** <dl>
12118 ** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>
12119 ** By default, the sessions module streaming interfaces attempt to input
12120 ** and output data in approximately 1 KiB chunks. This operand may be used
12121 ** to set and query the value of this configuration setting. The pointer
12122 ** passed as the second argument must point to a value of type (int).
12123 ** If this value is greater than 0, it is used as the new streaming data
12124 ** chunk size for both input and output. Before returning, the (int) value
12125 ** pointed to by pArg is set to the final value of the streaming interface
12126 ** chunk size.
12127 ** </dl>
12128 **
12129 ** This function returns SQLITE_OK if successful, or an SQLite error code
12130 ** otherwise.
12131 */
12132 SQLITE_API int sqlite3session_config(int op, void *pArg);
12133
12134 /*
12135 ** CAPI3REF: Values for sqlite3session_config().
12136 */
12137 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
12138
12139 /*
12140 ** Make sure we can call this stuff from C++.
12141 */
12142 #if 0
@@ -16036,16 +16159,18 @@
16159 /*
16160 ** A hash table for built-in function definitions. (Application-defined
16161 ** functions use a regular table table from hash.h.)
16162 **
16163 ** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.
16164 ** Collisions are on the FuncDef.u.pHash chain. Use the SQLITE_FUNC_HASH()
16165 ** macro to compute a hash on the function name.
16166 */
16167 #define SQLITE_FUNC_HASH_SZ 23
16168 struct FuncDefHash {
16169 FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */
16170 };
16171 #define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)
16172
16173 #ifdef SQLITE_USER_AUTHENTICATION
16174 /*
16175 ** Information held in the "sqlite3" database connection object and used
16176 ** to manage user authentication.
@@ -16102,11 +16227,11 @@
16227 CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
16228 sqlite3_mutex *mutex; /* Connection mutex */
16229 Db *aDb; /* All backends */
16230 int nDb; /* Number of backends currently in use */
16231 u32 mDbFlags; /* flags recording internal state */
16232 u64 flags; /* flags settable by pragmas. See below */
16233 i64 lastRowid; /* ROWID of most recent insert (see above) */
16234 i64 szMmap; /* Default mmap_size setting */
16235 u32 nSchemaLock; /* Do not reset the schema when non-zero */
16236 unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
16237 int errCode; /* Most recent error code (SQLITE_*) */
@@ -16268,18 +16393,21 @@
16393 #define SQLITE_Fts3Tokenizer 0x00400000 /* Enable fts3_tokenizer(2) */
16394 #define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
16395 #define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
16396 #define SQLITE_ResetDatabase 0x02000000 /* Reset the database */
16397 #define SQLITE_LegacyAlter 0x04000000 /* Legacy ALTER TABLE behaviour */
16398 #define SQLITE_NoSchemaError 0x08000000 /* Do not report schema parse errors*/
16399 #define SQLITE_Defensive 0x10000000 /* Input SQL is likely hostile */
16400
16401 /* Flags used only if debugging */
16402 #define HI(X) ((u64)(X)<<32)
16403 #ifdef SQLITE_DEBUG
16404 #define SQLITE_SqlTrace HI(0x0001) /* Debug print SQL as it executes */
16405 #define SQLITE_VdbeListing HI(0x0002) /* Debug listings of VDBE progs */
16406 #define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
16407 #define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
16408 #define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
16409 #endif
16410
16411 /*
16412 ** Allowed values for sqlite3.mDbFlags
16413 */
@@ -16674,10 +16802,13 @@
16802 ** by an instance of the following structure.
16803 */
16804 struct Table {
16805 char *zName; /* Name of the table or view */
16806 Column *aCol; /* Information about each column */
16807 #ifdef SQLITE_ENABLE_NORMALIZE
16808 Hash *pColHash; /* All columns indexed by name */
16809 #endif
16810 Index *pIndex; /* List of SQL indexes on this table. */
16811 Select *pSelect; /* NULL for tables. Points to definition if a view. */
16812 FKey *pFKey; /* Linked list of all foreign keys in this table */
16813 char *zColAff; /* String defining the affinity of each column */
16814 ExprList *pCheck; /* All CHECK constraints */
@@ -16724,10 +16855,11 @@
16855 #define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
16856 #define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
16857 #define TF_StatsUsed 0x0100 /* Query planner decisions affected by
16858 ** Index.aiRowLogEst[] values */
16859 #define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
16860 #define TF_Shadow 0x0400 /* True for a shadow table */
16861
16862 /*
16863 ** Test to see whether or not a table is a virtual table. This is
16864 ** done as a macro so that it will be optimized out when virtual
16865 ** table support is omitted from the build.
@@ -17010,10 +17142,16 @@
17142 tRowcnt *anEq; /* Est. number of rows where the key equals this sample */
17143 tRowcnt *anLt; /* Est. number of rows where key is less than this sample */
17144 tRowcnt *anDLt; /* Est. number of distinct keys less than this sample */
17145 };
17146
17147 /*
17148 ** Possible values to use within the flags argument to sqlite3GetToken().
17149 */
17150 #define SQLITE_TOKEN_QUOTED 0x1 /* Token is a quoted identifier. */
17151 #define SQLITE_TOKEN_KEYWORD 0x2 /* Token is a keyword. */
17152
17153 /*
17154 ** Each token coming out of the lexer is an instance of
17155 ** this structure. Tokens are also used as part of an expression.
17156 **
17157 ** The memory that "z" points to is owned by other objects. Take care
@@ -17191,15 +17329,15 @@
17329 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
17330 u8 op2; /* TK_REGISTER: original value of Expr.op
17331 ** TK_COLUMN: the value of p5 for OP_Column
17332 ** TK_AGG_FUNCTION: nesting depth */
17333 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
17334 union {
17335 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
17336 ** for a column of an index on an expression */
17337 Window *pWin; /* TK_FUNCTION: Window definition for the func */
17338 } y;
17339 };
17340
17341 /*
17342 ** The following are the meanings of bits in the Expr.flags field.
17343 */
@@ -17225,10 +17363,11 @@
17363 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17364 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
17365 #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
17366 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17367 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17368 #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17369
17370 /*
17371 ** The EP_Propagate mask is a set of properties that automatically propagate
17372 ** upwards into parent nodes.
17373 */
@@ -17910,10 +18049,11 @@
18049 ** OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
18050 ** OPFLAG_AUXDELETE == BTREE_AUXDELETE
18051 */
18052 #define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
18053 /* Also used in P2 (not P5) of OP_Delete */
18054 #define OPFLAG_NOCHNG 0x01 /* OP_VColumn nochange for UPDATE */
18055 #define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */
18056 #define OPFLAG_LASTROWID 0x20 /* Set to update db->lastRowid */
18057 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
18058 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
18059 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
@@ -18381,10 +18521,11 @@
18521 /*
18522 ** Internal function prototypes
18523 */
18524 SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
18525 SQLITE_PRIVATE int sqlite3Strlen30(const char*);
18526 #define sqlite3Strlen30NN(C) (strlen(C)&0x3fffffff)
18527 SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*);
18528 #define sqlite3StrNICmp sqlite3_strnicmp
18529
18530 SQLITE_PRIVATE int sqlite3MallocInit(void);
18531 SQLITE_PRIVATE void sqlite3MallocEnd(void);
@@ -18497,10 +18638,11 @@
18638
18639 #if defined(SQLITE_DEBUG)
18640 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
18641 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
18642 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
18643 SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView*, const SrcList*);
18644 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
18645 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
18646 #ifndef SQLITE_OMIT_WINDOWFUNC
18647 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
18648 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
@@ -18729,15 +18871,19 @@
18871 #endif
18872 SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
18873 SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
18874 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
18875 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
18876 #ifdef SQLITE_ENABLE_NORMALIZE
18877 SQLITE_PRIVATE int sqlite3IsRowidN(const char*, int);
18878 #endif
18879 SQLITE_PRIVATE void sqlite3GenerateRowDelete(
18880 Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
18881 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
18882 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
18883 SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
18884 SQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(Expr*,int*,int);
18885 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
18886 u8,u8,int,int*,int*,Upsert*);
18887 #ifdef SQLITE_ENABLE_NULL_TRIM
18888 SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
18889 #else
@@ -18754,10 +18900,13 @@
18900 SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
18901 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
18902 SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
18903 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
18904 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
18905 #ifdef SQLITE_ENABLE_NORMALIZE
18906 SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(int,const char*,int);
18907 #endif
18908 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
18909 SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
18910 SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
18911 SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
18912 SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
@@ -18911,10 +19060,11 @@
19060 SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);
19061 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
19062 SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
19063 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
19064 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
19065 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
19066 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
19067 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
19068 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
19069 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
19070 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
@@ -18957,10 +19107,13 @@
19107 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
19108 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
19109 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
19110 SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
19111 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
19112 #ifdef SQLITE_ENABLE_NORMALIZE
19113 SQLITE_PRIVATE int sqlite3GetTokenNormalized(const unsigned char *, int *, int *);
19114 #endif
19115 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
19116 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
19117 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
19118 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
19119 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
@@ -19114,10 +19267,13 @@
19267 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
19268 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
19269 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
19270 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
19271 SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
19272 #ifdef SQLITE_ENABLE_NORMALIZE
19273 SQLITE_PRIVATE void sqlite3Normalize(Vdbe*, const char*, int, u8);
19274 #endif
19275 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
19276 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
19277 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
19278 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
19279 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
@@ -20066,10 +20222,13 @@
20222 bft bIsReader:1; /* True for statements that read */
20223 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
20224 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
20225 u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
20226 char *zSql; /* Text of the SQL statement that generated this */
20227 #ifdef SQLITE_ENABLE_NORMALIZE
20228 char *zNormSql; /* Normalization of the associated SQL statement */
20229 #endif
20230 void *pFree; /* Free this when deleting the vdbe */
20231 VdbeFrame *pFrame; /* Parent frame */
20232 VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */
20233 int nFrame; /* Number of frames in pFrame list */
20234 u32 expmask; /* Binding to these vars invalidates VM */
@@ -28294,10 +28453,46 @@
28453 }
28454 sqlite3TreeViewPop(pView);
28455 }
28456 }
28457
28458 /*
28459 ** Generate a human-readable description of a SrcList object.
28460 */
28461 SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){
28462 int i;
28463 for(i=0; i<pSrc->nSrc; i++){
28464 const struct SrcList_item *pItem = &pSrc->a[i];
28465 StrAccum x;
28466 char zLine[100];
28467 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
28468 sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor);
28469 if( pItem->zDatabase ){
28470 sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName);
28471 }else if( pItem->zName ){
28472 sqlite3_str_appendf(&x, " %s", pItem->zName);
28473 }
28474 if( pItem->pTab ){
28475 sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
28476 }
28477 if( pItem->zAlias ){
28478 sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
28479 }
28480 if( pItem->fg.jointype & JT_LEFT ){
28481 sqlite3_str_appendf(&x, " LEFT-JOIN");
28482 }
28483 sqlite3StrAccumFinish(&x);
28484 sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1);
28485 if( pItem->pSelect ){
28486 sqlite3TreeViewSelect(pView, pItem->pSelect, 0);
28487 }
28488 if( pItem->fg.isTabFunc ){
28489 sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
28490 }
28491 sqlite3TreeViewPop(pView);
28492 }
28493 }
28494
28495 /*
28496 ** Generate a human-readable description of a Select object.
28497 */
28498 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
@@ -28348,43 +28543,13 @@
28543 }
28544 sqlite3TreeViewPop(pView);
28545 }
28546 #endif
28547 if( p->pSrc && p->pSrc->nSrc ){
 
28548 pView = sqlite3TreeViewPush(pView, (n--)>0);
28549 sqlite3TreeViewLine(pView, "FROM");
28550 sqlite3TreeViewSrcList(pView, p->pSrc);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28551 sqlite3TreeViewPop(pView);
28552 }
28553 if( p->pWhere ){
28554 sqlite3TreeViewItem(pView, "WHERE", (n--)>0);
28555 sqlite3TreeViewExpr(pView, p->pWhere, 0);
@@ -28670,11 +28835,11 @@
28835 pFarg = 0;
28836 pWin = 0;
28837 }else{
28838 pFarg = pExpr->x.pList;
28839 #ifndef SQLITE_OMIT_WINDOWFUNC
28840 pWin = pExpr->y.pWin;
28841 #else
28842 pWin = 0;
28843 #endif
28844 }
28845 if( pExpr->op==TK_AGG_FUNCTION ){
@@ -31498,10 +31663,24 @@
31663 h += sqlite3UpperToLower[c];
31664 h *= 0x9e3779b1;
31665 }
31666 return h;
31667 }
31668 #ifdef SQLITE_ENABLE_NORMALIZE
31669 static unsigned int strHashN(const char *z, int n){
31670 unsigned int h = 0;
31671 int i;
31672 for(i=0; i<n; i++){
31673 /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
31674 ** 0x9e3779b1 is 2654435761 which is the closest prime number to
31675 ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
31676 h += sqlite3UpperToLower[z[i]];
31677 h *= 0x9e3779b1;
31678 }
31679 return h;
31680 }
31681 #endif /* SQLITE_ENABLE_NORMALIZE */
31682
31683
31684 /* Link pNew element into the hash table pH. If pEntry!=0 then also
31685 ** insert pNew into the pEntry hash bucket.
31686 */
@@ -31609,10 +31788,44 @@
31788 }
31789 elem = elem->next;
31790 }
31791 return &nullElement;
31792 }
31793 #ifdef SQLITE_ENABLE_NORMALIZE
31794 static HashElem *findElementWithHashN(
31795 const Hash *pH, /* The pH to be searched */
31796 const char *pKey, /* The key we are searching for */
31797 int nKey, /* Number of key bytes to use */
31798 unsigned int *pHash /* Write the hash value here */
31799 ){
31800 HashElem *elem; /* Used to loop thru the element list */
31801 int count; /* Number of elements left to test */
31802 unsigned int h; /* The computed hash */
31803 static HashElem nullElement = { 0, 0, 0, 0 };
31804
31805 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
31806 struct _ht *pEntry;
31807 h = strHashN(pKey, nKey) % pH->htsize;
31808 pEntry = &pH->ht[h];
31809 elem = pEntry->chain;
31810 count = pEntry->count;
31811 }else{
31812 h = 0;
31813 elem = pH->first;
31814 count = pH->count;
31815 }
31816 if( pHash ) *pHash = h;
31817 while( count-- ){
31818 assert( elem!=0 );
31819 if( sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){
31820 return elem;
31821 }
31822 elem = elem->next;
31823 }
31824 return &nullElement;
31825 }
31826 #endif /* SQLITE_ENABLE_NORMALIZE */
31827
31828 /* Remove a single entry from the hash table given a pointer to that
31829 ** element and a hash on the element's key.
31830 */
31831 static void removeElementGivenHash(
@@ -31653,10 +31866,18 @@
31866 SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
31867 assert( pH!=0 );
31868 assert( pKey!=0 );
31869 return findElementWithHash(pH, pKey, 0)->data;
31870 }
31871 #ifdef SQLITE_ENABLE_NORMALIZE
31872 SQLITE_PRIVATE void *sqlite3HashFindN(const Hash *pH, const char *pKey, int nKey){
31873 assert( pH!=0 );
31874 assert( pKey!=0 );
31875 assert( nKey>=0 );
31876 return findElementWithHashN(pH, pKey, nKey, 0)->data;
31877 }
31878 #endif /* SQLITE_ENABLE_NORMALIZE */
31879
31880 /* Insert an element into the hash table pH. The key is pKey
31881 ** and the data is "data".
31882 **
31883 ** If no element exists with a matching key, then a new
@@ -32035,16 +32256,14 @@
32256 ** Allowed values of unixFile.fsFlags
32257 */
32258 #define SQLITE_FSFLAGS_IS_MSDOS 0x1
32259
32260 /*
32261 ** If we are to be thread-safe, include the pthreads header.
 
32262 */
32263 #if SQLITE_THREADSAFE
32264 /* # include <pthread.h> */
 
32265 #endif
32266
32267 /*
32268 ** Default permissions when creating a new file
32269 */
@@ -33216,12 +33435,11 @@
33435 #endif
33436 };
33437
33438 /*
33439 ** An instance of the following structure is allocated for each open
33440 ** inode.
 
33441 **
33442 ** A single inode can have multiple file descriptors, so each unixFile
33443 ** structure contains a pointer to an instance of this object and this
33444 ** object keeps a count of the number of unixFile pointing to it.
33445 **
@@ -33263,17 +33481,20 @@
33481 #endif
33482 };
33483
33484 /*
33485 ** A lists of all unixInodeInfo objects.
33486 **
33487 ** Must hold unixBigLock in order to read or write this variable.
33488 */
33489 static unixInodeInfo *inodeList = 0; /* All unixInodeInfo objects */
33490
33491 #ifdef SQLITE_DEBUG
33492 /*
33493 ** True if the inode mutex (on the unixFile.pFileMutex field) is held, or not.
33494 ** This routine is used only within assert() to help verify correct mutex
33495 ** usage.
33496 */
33497 int unixFileMutexHeld(unixFile *pFile){
33498 assert( pFile->pInode );
33499 return sqlite3_mutex_held(pFile->pInode->pLockMutex);
33500 }
@@ -33397,12 +33618,12 @@
33618 }
33619
33620 /*
33621 ** Release a unixInodeInfo structure previously allocated by findInodeInfo().
33622 **
33623 ** The global mutex must be held when this routine is called, but the mutex
33624 ** on the inode being deleted must NOT be held.
33625 */
33626 static void releaseInodeInfo(unixFile *pFile){
33627 unixInodeInfo *pInode = pFile->pInode;
33628 assert( unixMutexHeld() );
33629 assert( unixFileMutexNotheld(pFile) );
@@ -33433,12 +33654,11 @@
33654 /*
33655 ** Given a file descriptor, locate the unixInodeInfo object that
33656 ** describes that file descriptor. Create a new one if necessary. The
33657 ** return value might be uninitialized if an error occurs.
33658 **
33659 ** The global mutex must held when calling this routine.
 
33660 **
33661 ** Return an appropriate error code.
33662 */
33663 static int findInodeInfo(
33664 unixFile *pFile, /* Unix file with file desc used in the key */
@@ -33495,10 +33715,11 @@
33715 #if OS_VXWORKS
33716 fileId.pId = pFile->pId;
33717 #else
33718 fileId.ino = (u64)statbuf.st_ino;
33719 #endif
33720 assert( unixMutexHeld() );
33721 pInode = inodeList;
33722 while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
33723 pInode = pInode->pNext;
33724 }
33725 if( pInode==0 ){
@@ -33514,10 +33735,11 @@
33735 sqlite3_free(pInode);
33736 return SQLITE_NOMEM_BKPT;
33737 }
33738 }
33739 pInode->nRef = 1;
33740 assert( unixMutexHeld() );
33741 pInode->pNext = inodeList;
33742 pInode->pPrev = 0;
33743 if( inodeList ) inodeList->pPrev = pInode;
33744 inodeList = pInode;
33745 }else{
@@ -36311,22 +36533,22 @@
36533 **
36534 ** nRef
36535 **
36536 ** The following fields are read-only after the object is created:
36537 **
36538 ** hShm
36539 ** zFilename
36540 **
36541 ** Either unixShmNode.pShmMutex must be held or unixShmNode.nRef==0 and
36542 ** unixMutexHeld() is true when reading or writing any other field
36543 ** in this structure.
36544 */
36545 struct unixShmNode {
36546 unixInodeInfo *pInode; /* unixInodeInfo that owns this SHM node */
36547 sqlite3_mutex *pShmMutex; /* Mutex to access this object */
36548 char *zFilename; /* Name of the mmapped file */
36549 int hShm; /* Open file descriptor */
36550 int szRegion; /* Size of shared-memory regions */
36551 u16 nRegion; /* Size of array apRegion */
36552 u8 isReadonly; /* True if read-only */
36553 u8 isUnlocked; /* True if no DMS lock held */
36554 char **apRegion; /* Array of mapped shared-memory regions */
@@ -36344,20 +36566,20 @@
36566 ** open shared memory connection.
36567 **
36568 ** The following fields are initialized when this object is created and
36569 ** are read-only thereafter:
36570 **
36571 ** unixShm.pShmNode
36572 ** unixShm.id
36573 **
36574 ** All other fields are read/write. The unixShm.pShmNode->pShmMutex must
36575 ** be held while accessing any read/write fields.
36576 */
36577 struct unixShm {
36578 unixShmNode *pShmNode; /* The underlying unixShmNode object */
36579 unixShm *pNext; /* Next unixShm with the same unixShmNode */
36580 u8 hasMutex; /* True if holding the unixShmNode->pShmMutex */
36581 u8 id; /* Id of this connection within its unixShmNode */
36582 u16 sharedMask; /* Mask of shared locks held */
36583 u16 exclMask; /* Mask of exclusive locks held */
36584 };
36585
@@ -36383,25 +36605,26 @@
36605 struct flock f; /* The posix advisory locking structure */
36606 int rc = SQLITE_OK; /* Result code form fcntl() */
36607
36608 /* Access to the unixShmNode object is serialized by the caller */
36609 pShmNode = pFile->pInode->pShmNode;
36610 assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) );
36611 assert( pShmNode->nRef>0 || unixMutexHeld() );
36612
36613 /* Shared locks never span more than one byte */
36614 assert( n==1 || lockType!=F_RDLCK );
36615
36616 /* Locks are within range */
36617 assert( n>=1 && n<=SQLITE_SHM_NLOCK );
36618
36619 if( pShmNode->hShm>=0 ){
36620 /* Initialize the locking parameters */
36621 f.l_type = lockType;
36622 f.l_whence = SEEK_SET;
36623 f.l_start = ofst;
36624 f.l_len = n;
36625 rc = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile);
36626 rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
36627 }
36628
36629 /* Update the global lock state and do debug tracing */
36630 #ifdef SQLITE_DEBUG
@@ -36469,22 +36692,22 @@
36692 assert( unixMutexHeld() );
36693 if( p && ALWAYS(p->nRef==0) ){
36694 int nShmPerMap = unixShmRegionPerMap();
36695 int i;
36696 assert( p->pInode==pFd->pInode );
36697 sqlite3_mutex_free(p->pShmMutex);
36698 for(i=0; i<p->nRegion; i+=nShmPerMap){
36699 if( p->hShm>=0 ){
36700 osMunmap(p->apRegion[i], p->szRegion);
36701 }else{
36702 sqlite3_free(p->apRegion[i]);
36703 }
36704 }
36705 sqlite3_free(p->apRegion);
36706 if( p->hShm>=0 ){
36707 robust_close(pFd, p->hShm, __LINE__);
36708 p->hShm = -1;
36709 }
36710 p->pInode->pShmNode = 0;
36711 sqlite3_free(p);
36712 }
36713 }
@@ -36522,19 +36745,24 @@
36745 ** system crash, the database itself may also become corrupt. */
36746 lock.l_whence = SEEK_SET;
36747 lock.l_start = UNIX_SHM_DMS;
36748 lock.l_len = 1;
36749 lock.l_type = F_WRLCK;
36750 if( osFcntl(pShmNode->hShm, F_GETLK, &lock)!=0 ) {
36751 rc = SQLITE_IOERR_LOCK;
36752 }else if( lock.l_type==F_UNLCK ){
36753 if( pShmNode->isReadonly ){
36754 pShmNode->isUnlocked = 1;
36755 rc = SQLITE_READONLY_CANTINIT;
36756 }else{
36757 rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);
36758 /* The first connection to attach must truncate the -shm file. We
36759 ** truncate to 3 bytes (an arbitrary small number, less than the
36760 ** -shm header size) rather than 0 as a system debugging aid, to
36761 ** help detect if a -shm file truncation is legitimate or is the work
36762 ** or a rogue process. */
36763 if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 3) ){
36764 rc = unixLogError(SQLITE_IOERR_SHMOPEN,"ftruncate",pShmNode->zFilename);
36765 }
36766 }
36767 }else if( lock.l_type==F_WRLCK ){
36768 rc = SQLITE_BUSY;
@@ -36636,28 +36864,28 @@
36864 (u32)sStat.st_ino, (u32)sStat.st_dev);
36865 #else
36866 sqlite3_snprintf(nShmFilename, zShm, "%s-shm", zBasePath);
36867 sqlite3FileSuffix3(pDbFd->zPath, zShm);
36868 #endif
36869 pShmNode->hShm = -1;
36870 pDbFd->pInode->pShmNode = pShmNode;
36871 pShmNode->pInode = pDbFd->pInode;
36872 if( sqlite3GlobalConfig.bCoreMutex ){
36873 pShmNode->pShmMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
36874 if( pShmNode->pShmMutex==0 ){
36875 rc = SQLITE_NOMEM_BKPT;
36876 goto shm_open_err;
36877 }
36878 }
36879
36880 if( pInode->bProcessLock==0 ){
36881 if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
36882 pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777));
36883 }
36884 if( pShmNode->hShm<0 ){
36885 pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
36886 if( pShmNode->hShm<0 ){
36887 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
36888 goto shm_open_err;
36889 }
36890 pShmNode->isReadonly = 1;
36891 }
@@ -36664,11 +36892,11 @@
36892
36893 /* If this process is running as root, make sure that the SHM file
36894 ** is owned by the same user that owns the original database. Otherwise,
36895 ** the original owner will not be able to connect.
36896 */
36897 robustFchown(pShmNode->hShm, sStat.st_uid, sStat.st_gid);
36898
36899 rc = unixLockSharedMemory(pDbFd, pShmNode);
36900 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
36901 }
36902 }
@@ -36684,17 +36912,17 @@
36912
36913 /* The reference count on pShmNode has already been incremented under
36914 ** the cover of the unixEnterMutex() mutex and the pointer from the
36915 ** new (struct unixShm) object to the pShmNode has been set. All that is
36916 ** left to do is to link the new object into the linked list starting
36917 ** at pShmNode->pFirst. This must be done while holding the
36918 ** pShmNode->pShmMutex.
36919 */
36920 sqlite3_mutex_enter(pShmNode->pShmMutex);
36921 p->pNext = pShmNode->pFirst;
36922 pShmNode->pFirst = p;
36923 sqlite3_mutex_leave(pShmNode->pShmMutex);
36924 return rc;
36925
36926 /* Jump here on any error */
36927 shm_open_err:
36928 unixShmPurge(pDbFd); /* This call frees pShmNode if required */
@@ -36742,20 +36970,20 @@
36970 if( rc!=SQLITE_OK ) return rc;
36971 }
36972
36973 p = pDbFd->pShm;
36974 pShmNode = p->pShmNode;
36975 sqlite3_mutex_enter(pShmNode->pShmMutex);
36976 if( pShmNode->isUnlocked ){
36977 rc = unixLockSharedMemory(pDbFd, pShmNode);
36978 if( rc!=SQLITE_OK ) goto shmpage_out;
36979 pShmNode->isUnlocked = 0;
36980 }
36981 assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
36982 assert( pShmNode->pInode==pDbFd->pInode );
36983 assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );
36984 assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );
36985
36986 /* Minimum number of regions required to be mapped. */
36987 nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;
36988
36989 if( pShmNode->nRegion<nReqRegion ){
@@ -36763,16 +36991,16 @@
36991 int nByte = nReqRegion*szRegion; /* Minimum required file size */
36992 struct stat sStat; /* Used by fstat() */
36993
36994 pShmNode->szRegion = szRegion;
36995
36996 if( pShmNode->hShm>=0 ){
36997 /* The requested region is not mapped into this processes address space.
36998 ** Check to see if it has been allocated (i.e. if the wal-index file is
36999 ** large enough to contain the requested region).
37000 */
37001 if( osFstat(pShmNode->hShm, &sStat) ){
37002 rc = SQLITE_IOERR_SHMSIZE;
37003 goto shmpage_out;
37004 }
37005
37006 if( sStat.st_size<nByte ){
@@ -36796,11 +37024,11 @@
37024
37025 /* Write to the last byte of each newly allocated or extended page */
37026 assert( (nByte % pgsz)==0 );
37027 for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){
37028 int x = 0;
37029 if( seekAndWriteFd(pShmNode->hShm, iPg*pgsz + pgsz-1,"",1,&x)!=1 ){
37030 const char *zFile = pShmNode->zFilename;
37031 rc = unixLogError(SQLITE_IOERR_SHMSIZE, "write", zFile);
37032 goto shmpage_out;
37033 }
37034 }
@@ -36819,26 +37047,26 @@
37047 pShmNode->apRegion = apNew;
37048 while( pShmNode->nRegion<nReqRegion ){
37049 int nMap = szRegion*nShmPerMap;
37050 int i;
37051 void *pMem;
37052 if( pShmNode->hShm>=0 ){
37053 pMem = osMmap(0, nMap,
37054 pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
37055 MAP_SHARED, pShmNode->hShm, szRegion*(i64)pShmNode->nRegion
37056 );
37057 if( pMem==MAP_FAILED ){
37058 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
37059 goto shmpage_out;
37060 }
37061 }else{
37062 pMem = sqlite3_malloc64(nMap);
37063 if( pMem==0 ){
37064 rc = SQLITE_NOMEM_BKPT;
37065 goto shmpage_out;
37066 }
37067 memset(pMem, 0, nMap);
37068 }
37069
37070 for(i=0; i<nShmPerMap; i++){
37071 pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];
37072 }
@@ -36851,11 +37079,11 @@
37079 *pp = pShmNode->apRegion[iRegion];
37080 }else{
37081 *pp = 0;
37082 }
37083 if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;
37084 sqlite3_mutex_leave(pShmNode->pShmMutex);
37085 return rc;
37086 }
37087
37088 /*
37089 ** Change the lock state for a shared-memory segment.
@@ -36885,16 +37113,16 @@
37113 assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
37114 || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
37115 || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
37116 || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
37117 assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
37118 assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );
37119 assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );
37120
37121 mask = (1<<(ofst+n)) - (1<<ofst);
37122 assert( n>1 || mask==(1<<ofst) );
37123 sqlite3_mutex_enter(pShmNode->pShmMutex);
37124 if( flags & SQLITE_SHM_UNLOCK ){
37125 u16 allMask = 0; /* Mask of locks held by siblings */
37126
37127 /* See if any siblings hold this same lock */
37128 for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
@@ -36963,11 +37191,11 @@
37191 assert( (p->sharedMask & mask)==0 );
37192 p->exclMask |= mask;
37193 }
37194 }
37195 }
37196 sqlite3_mutex_leave(pShmNode->pShmMutex);
37197 OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
37198 p->id, osGetpid(0), p->sharedMask, p->exclMask));
37199 return rc;
37200 }
37201
@@ -37013,27 +37241,27 @@
37241 assert( pShmNode==pDbFd->pInode->pShmNode );
37242 assert( pShmNode->pInode==pDbFd->pInode );
37243
37244 /* Remove connection p from the set of connections associated
37245 ** with pShmNode */
37246 sqlite3_mutex_enter(pShmNode->pShmMutex);
37247 for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
37248 *pp = p->pNext;
37249
37250 /* Free the connection p */
37251 sqlite3_free(p);
37252 pDbFd->pShm = 0;
37253 sqlite3_mutex_leave(pShmNode->pShmMutex);
37254
37255 /* If pShmNode->nRef has reached 0, then close the underlying
37256 ** shared-memory file, too */
37257 assert( unixFileMutexNotheld(pDbFd) );
37258 unixEnterMutex();
37259 assert( pShmNode->nRef>0 );
37260 pShmNode->nRef--;
37261 if( pShmNode->nRef==0 ){
37262 if( deleteFlag && pShmNode->hShm>=0 ){
37263 osUnlink(pShmNode->zFilename);
37264 }
37265 unixShmPurge(pDbFd);
37266 }
37267 unixLeaveMutex();
@@ -47321,11 +47549,11 @@
47549 ** pDirtyTail to the last (oldest).
47550 **
47551 ** The PCache.pSynced variable is used to optimize searching for a dirty
47552 ** page to eject from the cache mid-transaction. It is better to eject
47553 ** a page that does not require a journal sync than one that does.
47554 ** Therefore, pSynced is maintained so that it *almost* always points
47555 ** to either the oldest page in the pDirty/pDirtyTail list that has a
47556 ** clear PGHDR_NEED_SYNC flag or to a page that is older than this one
47557 ** (so that the right page to eject can be found by following pDirtyPrev
47558 ** pointers).
47559 */
@@ -57104,10 +57332,11 @@
57332 void *(*xCodec)(void*,void*,Pgno,int),
57333 void (*xCodecSizeChng)(void*,int,int),
57334 void (*xCodecFree)(void*),
57335 void *pCodec
57336 ){
57337 pager_reset(pPager);
57338 if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
57339 pPager->xCodec = pPager->memDb ? 0 : xCodec;
57340 pPager->xCodecSizeChng = xCodecSizeChng;
57341 pPager->xCodecFree = xCodecFree;
57342 pPager->pCodec = pCodec;
@@ -65764,11 +65993,11 @@
65993 freeTempSpace(pBt);
65994 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
65995 pageSize-usableSize);
65996 return rc;
65997 }
65998 if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
65999 rc = SQLITE_CORRUPT_BKPT;
66000 goto page1_init_failed;
66001 }
66002 /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
66003 ** be less than 480. In other words, if the page size is 512, then the
@@ -66238,10 +66467,11 @@
66467
66468 assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 ||
66469 eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );
66470 assert( sqlite3_mutex_held(pBt->mutex) );
66471 assert( pDbPage->pBt==pBt );
66472 if( iDbPage<3 ) return SQLITE_CORRUPT_BKPT;
66473
66474 /* Move page iDbPage from its current location to page number iFreePage */
66475 TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
66476 iDbPage, iFreePage, iPtrPage, eType));
66477 rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);
@@ -74033,11 +74263,12 @@
74263 sqlite3_snprintf(nByte, pMem->z, "%lld", pMem->u.i);
74264 }else{
74265 assert( fg & MEM_Real );
74266 sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->u.r);
74267 }
74268 assert( pMem->z!=0 );
74269 pMem->n = sqlite3Strlen30NN(pMem->z);
74270 pMem->enc = SQLITE_UTF8;
74271 pMem->flags |= MEM_Str|MEM_Term;
74272 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);
74273 sqlite3VdbeChangeEncoding(pMem, enc);
74274 return SQLITE_OK;
@@ -75608,10 +75839,17 @@
75839 if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){
75840 p->expmask = 0;
75841 }
75842 assert( p->zSql==0 );
75843 p->zSql = sqlite3DbStrNDup(p->db, z, n);
75844 #ifdef SQLITE_ENABLE_NORMALIZE
75845 assert( p->zNormSql==0 );
75846 if( p->zSql && (prepFlags & SQLITE_PREPARE_NORMALIZE)!=0 ){
75847 sqlite3Normalize(p, p->zSql, n, prepFlags);
75848 assert( p->zNormSql!=0 || p->db->mallocFailed );
75849 }
75850 #endif
75851 }
75852
75853 /*
75854 ** Swap all content between two VDBE structures.
75855 */
@@ -75629,10 +75867,15 @@
75867 pA->pPrev = pB->pPrev;
75868 pB->pPrev = pTmp;
75869 zTmp = pA->zSql;
75870 pA->zSql = pB->zSql;
75871 pB->zSql = zTmp;
75872 #ifdef SQLITE_ENABLE_NORMALIZE
75873 zTmp = pA->zNormSql;
75874 pA->zNormSql = pB->zNormSql;
75875 pB->zNormSql = zTmp;
75876 #endif
75877 pB->expmask = pA->expmask;
75878 pB->prepFlags = pA->prepFlags;
75879 memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));
75880 pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;
75881 }
@@ -78700,10 +78943,13 @@
78943 sqlite3DbFree(db, p->pFree);
78944 }
78945 vdbeFreeOpArray(db, p->aOp, p->nOp);
78946 sqlite3DbFree(db, p->aColName);
78947 sqlite3DbFree(db, p->zSql);
78948 #ifdef SQLITE_ENABLE_NORMALIZE
78949 sqlite3DbFree(db, p->zNormSql);
78950 #endif
78951 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
78952 {
78953 int i;
78954 for(i=0; i<p->nScan; i++){
78955 sqlite3DbFree(db, p->aScan[i].zName);
@@ -80101,11 +80347,13 @@
80347
80348 /* The index entry must begin with a header size */
80349 (void)getVarint32((u8*)m.z, szHdr);
80350 testcase( szHdr==3 );
80351 testcase( szHdr==m.n );
80352 testcase( szHdr>0x7fffffff );
80353 assert( m.n>=0 );
80354 if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
80355 goto idx_rowid_corruption;
80356 }
80357
80358 /* The last field of the index should be an integer - the ROWID.
80359 ** Verify that the last entry really is an integer. */
@@ -82112,10 +82360,20 @@
82360 }
82361 return z;
82362 #endif
82363 }
82364
82365 #ifdef SQLITE_ENABLE_NORMALIZE
82366 /*
82367 ** Return the normalized SQL associated with a prepared statement.
82368 */
82369 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){
82370 Vdbe *p = (Vdbe *)pStmt;
82371 return p ? p->zNormSql : 0;
82372 }
82373 #endif /* SQLITE_ENABLE_NORMALIZE */
82374
82375 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
82376 /*
82377 ** Allocate and populate an UnpackedRecord structure based on the serialized
82378 ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure
82379 ** if successful, or a NULL pointer if an OOM error is encountered.
@@ -85551,21 +85809,29 @@
85809 nVarint = sqlite3VarintLen(nHdr);
85810 nHdr += nVarint;
85811 if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
85812 }
85813 nByte = nHdr+nData;
 
 
 
85814
85815 /* Make sure the output register has a buffer large enough to store
85816 ** the new record. The output register (pOp->p3) is not allowed to
85817 ** be one of the input registers (because the following call to
85818 ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).
85819 */
85820 if( nByte+nZero<=pOut->szMalloc ){
85821 /* The output register is already large enough to hold the record.
85822 ** No error checks or buffer enlargement is required */
85823 pOut->z = pOut->zMalloc;
85824 }else{
85825 /* Need to make sure that the output is not too big and then enlarge
85826 ** the output register to hold the full result */
85827 if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
85828 goto too_big;
85829 }
85830 if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){
85831 goto no_mem;
85832 }
85833 }
85834 zNewRecord = (u8 *)pOut->z;
85835
85836 /* Write the record */
85837 i = putVarint32(zNewRecord, nHdr);
@@ -88417,11 +88683,11 @@
88683 }else
88684 #endif
88685 {
88686 zMaster = MASTER_NAME;
88687 initData.db = db;
88688 initData.iDb = iDb;
88689 initData.pzErrMsg = &p->zErrMsg;
88690 initData.mInitFlags = 0;
88691 zSql = sqlite3MPrintf(db,
88692 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
88693 db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
@@ -89614,14 +89880,15 @@
89880 ** Store in register P3 the value of the P2-th column of
89881 ** the current row of the virtual-table of cursor P1.
89882 **
89883 ** If the VColumn opcode is being used to fetch the value of
89884 ** an unchanging column during an UPDATE operation, then the P5
89885 ** value is OPFLAG_NOCHNG. This will cause the sqlite3_vtab_nochange()
89886 ** function to return true inside the xColumn method of the virtual
89887 ** table implementation. The P5 column might also contain other
89888 ** bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are
89889 ** unused by OP_VColumn.
89890 */
89891 case OP_VColumn: {
89892 sqlite3_vtab *pVtab;
89893 const sqlite3_module *pModule;
89894 Mem *pDest;
@@ -89639,11 +89906,12 @@
89906 pVtab = pCur->uc.pVCur->pVtab;
89907 pModule = pVtab->pModule;
89908 assert( pModule->xColumn );
89909 memset(&sContext, 0, sizeof(sContext));
89910 sContext.pOut = pDest;
89911 testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );
89912 if( pOp->p5 & OPFLAG_NOCHNG ){
89913 sqlite3VdbeMemSetNull(pDest);
89914 pDest->flags = MEM_Null|MEM_Zero;
89915 pDest->u.nZero = 0;
89916 }else{
89917 MemSetTypeFlag(pDest, MEM_Null);
@@ -93998,12 +94266,12 @@
94266 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
94267 }else if( pExpr->x.pList ){
94268 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
94269 }
94270 #ifndef SQLITE_OMIT_WINDOWFUNC
94271 if( ExprHasProperty(pExpr, EP_WinFunc) ){
94272 Window *pWin = pExpr->y.pWin;
94273 if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
94274 if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
94275 if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
94276 }
94277 #endif
@@ -94272,11 +94540,11 @@
94540 **
94541 ** pExpr->iDb Set the index in db->aDb[] of the database X
94542 ** (even if X is implied).
94543 ** pExpr->iTable Set to the cursor number for the table obtained
94544 ** from pSrcList.
94545 ** pExpr->y.pTab Points to the Table structure of X.Y (even if
94546 ** X and/or Y are implied.)
94547 ** pExpr->iColumn Set to the column number within the table.
94548 ** pExpr->op Set to TK_COLUMN.
94549 ** pExpr->pLeft Any expression this points to is deleted
94550 ** pExpr->pRight Any expression this points to is deleted.
@@ -94316,11 +94584,10 @@
94584 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
94585 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
94586
94587 /* Initialize the node to no-match */
94588 pExpr->iTable = -1;
 
94589 ExprSetVVAProperty(pExpr, EP_NoReduce);
94590
94591 /* Translate the schema name in zDb into a pointer to the corresponding
94592 ** schema. If not found, pSchema will remain NULL and nothing will match
94593 ** resulting in an appropriate error message toward the end of this routine
@@ -94378,11 +94645,11 @@
94645 assert( zTabName!=0 );
94646 if( sqlite3StrICmp(zTabName, zTab)!=0 ){
94647 continue;
94648 }
94649 if( IN_RENAME_OBJECT && pItem->zAlias ){
94650 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
94651 }
94652 }
94653 if( 0==(cntTab++) ){
94654 pMatch = pItem;
94655 }
@@ -94404,17 +94671,17 @@
94671 }
94672 }
94673 }
94674 if( pMatch ){
94675 pExpr->iTable = pMatch->iCursor;
94676 pExpr->y.pTab = pMatch->pTab;
94677 /* RIGHT JOIN not (yet) supported */
94678 assert( (pMatch->fg.jointype & JT_RIGHT)==0 );
94679 if( (pMatch->fg.jointype & JT_LEFT)!=0 ){
94680 ExprSetProperty(pExpr, EP_CanBeNull);
94681 }
94682 pSchema = pExpr->y.pTab->pSchema;
94683 }
94684 } /* if( pSrcList ) */
94685
94686 #if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
94687 /* If we have not already resolved the name, then maybe
@@ -94467,11 +94734,11 @@
94734 #ifndef SQLITE_OMIT_UPSERT
94735 if( pExpr->iTable==2 ){
94736 testcase( iCol==(-1) );
94737 if( IN_RENAME_OBJECT ){
94738 pExpr->iColumn = iCol;
94739 pExpr->y.pTab = pTab;
94740 eNewExprOp = TK_COLUMN;
94741 }else{
94742 pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94743 eNewExprOp = TK_REGISTER;
94744 ExprSetProperty(pExpr, EP_Alias);
@@ -94489,11 +94756,11 @@
94756 }else{
94757 testcase( iCol==31 );
94758 testcase( iCol==32 );
94759 pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
94760 }
94761 pExpr->y.pTab = pTab;
94762 pExpr->iColumn = (i16)iCol;
94763 eNewExprOp = TK_TRIGGER;
94764 #endif /* SQLITE_OMIT_TRIGGER */
94765 }
94766 }
@@ -94589,11 +94856,11 @@
94856 */
94857 if( cnt==0 && zTab==0 ){
94858 assert( pExpr->op==TK_ID );
94859 if( ExprHasProperty(pExpr,EP_DblQuoted) ){
94860 pExpr->op = TK_STRING;
94861 pExpr->y.pTab = 0;
94862 return WRC_Prune;
94863 }
94864 if( sqlite3ExprIdToTrueFalse(pExpr) ){
94865 return WRC_Prune;
94866 }
@@ -94667,13 +94934,13 @@
94934 */
94935 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
94936 Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
94937 if( p ){
94938 struct SrcList_item *pItem = &pSrc->a[iSrc];
94939 p->y.pTab = pItem->pTab;
94940 p->iTable = pItem->iCursor;
94941 if( p->y.pTab->iPKey==iCol ){
94942 p->iColumn = -1;
94943 }else{
94944 p->iColumn = (ynVar)iCol;
94945 testcase( iCol==BMS );
94946 testcase( iCol==BMS-1 );
@@ -94759,11 +95026,11 @@
95026 struct SrcList_item *pItem;
95027 assert( pSrcList && pSrcList->nSrc==1 );
95028 pItem = pSrcList->a;
95029 assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );
95030 pExpr->op = TK_COLUMN;
95031 pExpr->y.pTab = pItem->pTab;
95032 pExpr->iTable = pItem->iCursor;
95033 pExpr->iColumn = -1;
95034 pExpr->affinity = SQLITE_AFF_INTEGER;
95035 break;
95036 }
@@ -94803,13 +95070,11 @@
95070 }
95071 zTable = pLeft->u.zToken;
95072 zColumn = pRight->u.zToken;
95073 if( IN_RENAME_OBJECT ){
95074 sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
95075 sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft);
 
 
95076 }
95077 }
95078 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
95079 }
95080
@@ -94895,22 +95160,22 @@
95160 #ifndef SQLITE_OMIT_WINDOWFUNC
95161 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
95162 || (pDef->xValue==0 && pDef->xInverse==0)
95163 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
95164 );
95165 if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
95166 sqlite3ErrorMsg(pParse,
95167 "%.*s() may not be used as a window function", nId, zId
95168 );
95169 pNC->nErr++;
95170 }else if(
95171 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
95172 || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)
95173 || (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)
95174 ){
95175 const char *zType;
95176 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){
95177 zType = "window";
95178 }else{
95179 zType = "aggregate";
95180 }
95181 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
@@ -94936,30 +95201,30 @@
95201 nId, zId);
95202 pNC->nErr++;
95203 }
95204 if( is_agg ){
95205 #ifndef SQLITE_OMIT_WINDOWFUNC
95206 pNC->ncFlags &= ~(pExpr->y.pWin ? NC_AllowWin : NC_AllowAgg);
95207 #else
95208 pNC->ncFlags &= ~NC_AllowAgg;
95209 #endif
95210 }
95211 }
95212 sqlite3WalkExprList(pWalker, pList);
95213 if( is_agg ){
95214 #ifndef SQLITE_OMIT_WINDOWFUNC
95215 if( pExpr->y.pWin ){
95216 Select *pSel = pNC->pWinSelect;
95217 sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
95218 sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
95219 sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
95220 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
95221 if( 0==pSel->pWin
95222 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
95223 ){
95224 pExpr->y.pWin->pNextWin = pSel->pWin;
95225 pSel->pWin = pExpr->y.pWin;
95226 }
95227 pNC->ncFlags |= NC_AllowWin;
95228 }else
95229 #endif /* SQLITE_OMIT_WINDOWFUNC */
95230 {
@@ -95378,17 +95643,17 @@
95643 return 1;
95644 }
95645 for(j=0; j<pSelect->pEList->nExpr; j++){
95646 if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
95647 #ifndef SQLITE_OMIT_WINDOWFUNC
95648 if( ExprHasProperty(pE, EP_WinFunc) ){
95649 /* Since this window function is being changed into a reference
95650 ** to the same window function the result set, remove the instance
95651 ** of this window function from the Select.pWin list. */
95652 Window **pp;
95653 for(pp=&pSelect->pWin; *pp; pp=&(*pp)->pNextWin){
95654 if( *pp==pE->y.pWin ){
95655 *pp = (*pp)->pNextWin;
95656 }
95657 }
95658 }
95659 #endif
@@ -95847,12 +96112,12 @@
96112 if( op==TK_CAST ){
96113 assert( !ExprHasProperty(pExpr, EP_IntValue) );
96114 return sqlite3AffinityType(pExpr->u.zToken, 0);
96115 }
96116 #endif
96117 if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){
96118 return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
96119 }
96120 if( op==TK_SELECT_COLUMN ){
96121 assert( pExpr->pLeft->flags&EP_xIsSelect );
96122 return sqlite3ExprAffinity(
96123 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
@@ -95932,17 +96197,17 @@
96197 while( p ){
96198 int op = p->op;
96199 if( p->flags & EP_Generic ) break;
96200 if( (op==TK_AGG_COLUMN || op==TK_COLUMN
96201 || op==TK_REGISTER || op==TK_TRIGGER)
96202 && p->y.pTab!=0
96203 ){
96204 /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
96205 ** a TK_COLUMN but was previously evaluated and cached in a register */
96206 int j = p->iColumn;
96207 if( j>=0 ){
96208 const char *zColl = p->y.pTab->aCol[j].zColl;
96209 pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);
96210 }
96211 break;
96212 }
96213 if( op==TK_CAST || op==TK_UPLUS ){
@@ -96841,10 +97106,14 @@
97106 */
97107 static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
97108 assert( p!=0 );
97109 /* Sanity check: Assert that the IntValue is non-negative if it exists */
97110 assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
97111
97112 assert( !ExprHasProperty(p, EP_WinFunc) || p->y.pWin!=0 || db->mallocFailed );
97113 assert( p->op!=TK_FUNCTION || ExprHasProperty(p, EP_TokenOnly|EP_Reduced)
97114 || p->y.pWin==0 || ExprHasProperty(p, EP_WinFunc) );
97115 #ifdef SQLITE_DEBUG
97116 if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){
97117 assert( p->pLeft==0 );
97118 assert( p->pRight==0 );
97119 assert( p->x.pSelect==0 );
@@ -96859,12 +97128,13 @@
97128 }else if( ExprHasProperty(p, EP_xIsSelect) ){
97129 sqlite3SelectDelete(db, p->x.pSelect);
97130 }else{
97131 sqlite3ExprListDelete(db, p->x.pList);
97132 }
97133 if( ExprHasProperty(p, EP_WinFunc) ){
97134 assert( p->op==TK_FUNCTION );
97135 sqlite3WindowDelete(db, p->y.pWin);
97136 }
97137 }
97138 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
97139 if( !ExprHasProperty(p, EP_Static) ){
97140 sqlite3DbFreeNN(db, p);
@@ -96924,11 +97194,11 @@
97194 assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
97195 assert( EXPR_FULLSIZE<=0xfff );
97196 assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );
97197 if( 0==flags || p->op==TK_SELECT_COLUMN
97198 #ifndef SQLITE_OMIT_WINDOWFUNC
97199 || ExprHasProperty(p, EP_WinFunc)
97200 #endif
97201 ){
97202 nSize = EXPR_FULLSIZE;
97203 }else{
97204 assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
@@ -96951,11 +97221,11 @@
97221 ** string is defined.)
97222 */
97223 static int dupedExprNodeSize(Expr *p, int flags){
97224 int nByte = dupedExprStructSize(p, flags) & 0xfff;
97225 if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){
97226 nByte += sqlite3Strlen30NN(p->u.zToken)+1;
97227 }
97228 return ROUND8(nByte);
97229 }
97230
97231 /*
@@ -97054,26 +97324,28 @@
97324 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);
97325 }
97326 }
97327
97328 /* Fill in pNew->pLeft and pNew->pRight. */
97329 if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){
97330 zAlloc += dupedExprNodeSize(p, dupFlags);
97331 if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
97332 pNew->pLeft = p->pLeft ?
97333 exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
97334 pNew->pRight = p->pRight ?
97335 exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
97336 }
 
97337 #ifndef SQLITE_OMIT_WINDOWFUNC
97338 if( ExprHasProperty(p, EP_WinFunc) ){
97339 pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);
97340 assert( ExprHasProperty(pNew, EP_WinFunc) );
 
97341 }
97342 #endif /* SQLITE_OMIT_WINDOWFUNC */
97343 if( pzBuffer ){
97344 *pzBuffer = zAlloc;
97345 }
97346 }else{
97347 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
97348 if( pNew->op==TK_SELECT_COLUMN ){
97349 pNew->pLeft = p->pLeft;
97350 assert( p->iColumn==0 || p->pRight==0 );
97351 assert( p->pRight==0 || p->pRight==p->pLeft );
@@ -97081,13 +97353,10 @@
97353 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
97354 }
97355 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
97356 }
97357 }
 
 
 
97358 }
97359 return pNew;
97360 }
97361
97362 /*
@@ -97878,12 +98147,12 @@
98147 case TK_FLOAT:
98148 case TK_BLOB:
98149 return 0;
98150 case TK_COLUMN:
98151 return ExprHasProperty(p, EP_CanBeNull) ||
98152 p->y.pTab==0 || /* Reference to column of index on expression */
98153 (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0);
98154 default:
98155 return 1;
98156 }
98157 }
98158
@@ -97934,10 +98203,18 @@
98203 if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1;
98204 if( sqlite3StrICmp(z, "ROWID")==0 ) return 1;
98205 if( sqlite3StrICmp(z, "OID")==0 ) return 1;
98206 return 0;
98207 }
98208 #ifdef SQLITE_ENABLE_NORMALIZE
98209 SQLITE_PRIVATE int sqlite3IsRowidN(const char *z, int n){
98210 if( sqlite3StrNICmp(z, "_ROWID_", n)==0 ) return 1;
98211 if( sqlite3StrNICmp(z, "ROWID", n)==0 ) return 1;
98212 if( sqlite3StrNICmp(z, "OID", n)==0 ) return 1;
98213 return 0;
98214 }
98215 #endif
98216
98217 /*
98218 ** pX is the RHS of an IN operator. If pX is a SELECT statement
98219 ** that can be simplified to a direct table access, then return
98220 ** a pointer to the SELECT statement. If pX is not a SELECT statement,
@@ -99167,11 +99444,11 @@
99444 ** expresssion. However, make sure the constant has the correct
99445 ** datatype by applying the Affinity of the table column to the
99446 ** constant.
99447 */
99448 int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
99449 int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
99450 if( aff!=SQLITE_AFF_BLOB ){
99451 static const char zAff[] = "B\000C\000D\000E";
99452 assert( SQLITE_AFF_BLOB=='A' );
99453 assert( SQLITE_AFF_TEXT=='B' );
99454 if( iReg!=target ){
@@ -99191,11 +99468,11 @@
99468 /* Coding an expression that is part of an index where column names
99469 ** in the index refer to the table to which the index belongs */
99470 iTab = pParse->iSelfTab - 1;
99471 }
99472 }
99473 return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
99474 pExpr->iColumn, iTab, target,
99475 pExpr->op2);
99476 }
99477 case TK_INTEGER: {
99478 codeInteger(pParse, pExpr, 0, target);
@@ -99405,12 +99682,12 @@
99682 sqlite3 *db = pParse->db; /* The database connection */
99683 u8 enc = ENC(db); /* The text encoding used by this database */
99684 CollSeq *pColl = 0; /* A collating sequence */
99685
99686 #ifndef SQLITE_OMIT_WINDOWFUNC
99687 if( ExprHasProperty(pExpr, EP_WinFunc) ){
99688 return pExpr->y.pWin->regResult;
99689 }
99690 #endif
99691
99692 if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
99693 /* SQL functions can be expensive. So try to move constant functions
@@ -99649,11 +99926,11 @@
99926 **
99927 ** p1==0 -> old.rowid p1==3 -> new.rowid
99928 ** p1==1 -> old.a p1==4 -> new.a
99929 ** p1==2 -> old.b p1==5 -> new.b
99930 */
99931 Table *pTab = pExpr->y.pTab;
99932 int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;
99933
99934 assert( pExpr->iTable==0 || pExpr->iTable==1 );
99935 assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );
99936 assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );
@@ -99660,11 +99937,11 @@
99937 assert( p1>=0 && p1<(pTab->nCol*2+2) );
99938
99939 sqlite3VdbeAddOp2(v, OP_Param, p1, target);
99940 VdbeComment((v, "r[%d]=%s.%s", target,
99941 (pExpr->iTable ? "new" : "old"),
99942 (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[pExpr->iColumn].zName)
99943 ));
99944
99945 #ifndef SQLITE_OMIT_FLOATING_POINT
99946 /* If the column has REAL affinity, it may currently be stored as an
99947 ** integer. Use OP_RealAffinity to make sure it is really real.
@@ -100511,10 +100788,24 @@
100788 return 2;
100789 }
100790 if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
100791 if( pA->op==TK_FUNCTION ){
100792 if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
100793 #ifndef SQLITE_OMIT_WINDOWFUNC
100794 /* Justification for the assert():
100795 ** window functions have p->op==TK_FUNCTION but aggregate functions
100796 ** have p->op==TK_AGG_FUNCTION. So any comparison between an aggregate
100797 ** function and a window function should have failed before reaching
100798 ** this point. And, it is not possible to have a window function and
100799 ** a scalar function with the same name and number of arguments. So
100800 ** if we reach this point, either A and B both window functions or
100801 ** neither are a window functions. */
100802 assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) );
100803 if( ExprHasProperty(pA,EP_WinFunc) ){
100804 if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
100805 }
100806 #endif
100807 }else if( pA->op==TK_COLLATE ){
100808 if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
100809 }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
100810 return 2;
100811 }
@@ -100530,25 +100821,10 @@
100821 if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
100822 if( pA->iColumn!=pB->iColumn ) return 2;
100823 if( pA->iTable!=pB->iTable
100824 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
100825 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100826 }
100827 return 0;
100828 }
100829
100830 /*
@@ -100685,12 +100961,12 @@
100961 testcase( pExpr->op==TK_NE );
100962 testcase( pExpr->op==TK_LT );
100963 testcase( pExpr->op==TK_LE );
100964 testcase( pExpr->op==TK_GT );
100965 testcase( pExpr->op==TK_GE );
100966 if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
100967 || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
100968 ){
100969 return WRC_Prune;
100970 }
100971 default:
100972 return WRC_Continue;
@@ -100917,11 +101193,11 @@
101193 }
101194 if( (k>=pAggInfo->nColumn)
101195 && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0
101196 ){
101197 pCol = &pAggInfo->aCol[k];
101198 pCol->pTab = pExpr->y.pTab;
101199 pCol->iTable = pExpr->iTable;
101200 pCol->iColumn = pExpr->iColumn;
101201 pCol->iMem = ++pParse->nMem;
101202 pCol->iSorterColumn = -1;
101203 pCol->pExpr = pExpr;
@@ -101936,11 +102212,11 @@
102212 && pWalker->pParse->pTriggerTab==p->pTab
102213 ){
102214 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
102215 }else if( pExpr->op==TK_COLUMN
102216 && pExpr->iColumn==p->iCol
102217 && p->pTab==pExpr->y.pTab
102218 ){
102219 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
102220 }
102221 return WRC_Continue;
102222 }
@@ -102194,13 +102470,18 @@
102470 assert( pNew->pTabSchema );
102471 pParse->pTriggerTab = sqlite3FindTable(db, pNew->table,
102472 db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName
102473 );
102474 pParse->eTriggerOp = pNew->op;
102475 /* ALWAYS() because if the table of the trigger does not exist, the
102476 ** error would have been hit before this point */
102477 if( ALWAYS(pParse->pTriggerTab) ){
102478 rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
102479 }
102480
102481 /* Resolve symbols in WHEN clause */
102482 if( rc==SQLITE_OK && pNew->pWhen ){
102483 rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);
102484 }
102485
102486 for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){
102487 if( pStep->pSelect ){
@@ -102474,12 +102755,12 @@
102755 /*
102756 ** Walker expression callback used by "RENAME TABLE".
102757 */
102758 static int renameTableExprCb(Walker *pWalker, Expr *pExpr){
102759 RenameCtx *p = pWalker->u.pRename;
102760 if( pExpr->op==TK_COLUMN && p->pTab==pExpr->y.pTab ){
102761 renameTokenFind(pWalker->pParse, p, (void*)&pExpr->y.pTab);
102762 }
102763 return WRC_Continue;
102764 }
102765
102766 /*
@@ -102572,11 +102853,11 @@
102853 sqlite3WalkSelect(&sWalker, pTab->pSelect);
102854 }
102855 }else{
102856 /* Modify any FK definitions to point to the new table. */
102857 #ifndef SQLITE_OMIT_FOREIGN_KEY
102858 if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
102859 FKey *pFKey;
102860 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102861 if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102862 renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102863 }
@@ -105457,10 +105738,11 @@
105738 int iSrc; /* Index in pTabList->a[] of table being read */
105739 int iDb; /* The index of the database the expression refers to */
105740 int iCol; /* Index of column in table */
105741
105742 assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );
105743 assert( !IN_RENAME_OBJECT || db->xAuth==0 );
105744 if( db->xAuth==0 ) return;
105745 iDb = sqlite3SchemaToIndex(pParse->db, pSchema);
105746 if( iDb<0 ){
105747 /* An attempt to read a column out of a subquery or other
105748 ** temporary table. */
@@ -105513,10 +105795,11 @@
105795 int rc;
105796
105797 /* Don't do any authorization checks if the database is initialising
105798 ** or if the parser is being invoked from within sqlite3_declare_vtab.
105799 */
105800 assert( !IN_RENAME_OBJECT || db->xAuth==0 );
105801 if( db->init.busy || IN_SPECIAL_PARSE ){
105802 return SQLITE_OK;
105803 }
105804
105805 if( db->xAuth==0 ){
@@ -105936,21 +106219,19 @@
106219
106220 p = sqlite3FindTable(db, zName, zDbase);
106221 if( p==0 ){
106222 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
106223 #ifndef SQLITE_OMIT_VIRTUALTABLE
106224 /* If zName is the not the name of a table in the schema created using
106225 ** CREATE, then check to see if it is the name of an virtual table that
106226 ** can be an eponymous virtual table. */
106227 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
106228 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
106229 pMod = sqlite3PragmaVtabRegister(db, zName);
106230 }
106231 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
106232 return pMod->pEpoTab;
 
 
106233 }
106234 #endif
106235 if( (flags & LOCATE_NOERR)==0 ){
106236 if( zDbase ){
106237 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
@@ -106213,10 +106494,16 @@
106494 /* Delete any foreign keys attached to this table. */
106495 sqlite3FkDelete(db, pTable);
106496
106497 /* Delete the Table structure itself.
106498 */
106499 #ifdef SQLITE_ENABLE_NORMALIZE
106500 if( pTable->pColHash ){
106501 sqlite3HashClear(pTable->pColHash);
106502 sqlite3_free(pTable->pColHash);
106503 }
106504 #endif
106505 sqlite3DeleteColumnNames(db, pTable);
106506 sqlite3DbFree(db, pTable->zName);
106507 sqlite3DbFree(db, pTable->zColAff);
106508 sqlite3SelectDelete(db, pTable->pSelect);
106509 sqlite3ExprListDelete(db, pTable->pCheck);
@@ -106370,10 +106657,24 @@
106657 iDb = db->init.iDb;
106658 *pUnqual = pName1;
106659 }
106660 return iDb;
106661 }
106662
106663 /*
106664 ** True if PRAGMA writable_schema is ON
106665 */
106666 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){
106667 testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==0 );
106668 testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106669 SQLITE_WriteSchema );
106670 testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106671 SQLITE_Defensive );
106672 testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==
106673 (SQLITE_WriteSchema|SQLITE_Defensive) );
106674 return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema;
106675 }
106676
106677 /*
106678 ** This routine is used to check if the UTF-8 string zName is a legal
106679 ** unqualified name for a new schema object (table, index, view or
106680 ** trigger). All names are legal except those that begin with the string
@@ -106380,11 +106681,11 @@
106681 ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace
106682 ** is reserved for internal use.
106683 */
106684 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){
106685 if( !pParse->db->init.busy && pParse->nested==0
106686 && sqlite3WritableSchema(pParse->db)==0
106687 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
106688 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
106689 return SQLITE_ERROR;
106690 }
106691 return SQLITE_OK;
@@ -107455,10 +107756,36 @@
107756 }else{
107757 pPk->nColumn = pTab->nCol;
107758 }
107759 recomputeColumnsNotIndexed(pPk);
107760 }
107761
107762 /*
107763 ** Return true if zName is a shadow table name in the current database
107764 ** connection.
107765 **
107766 ** zName is temporarily modified while this routine is running, but is
107767 ** restored to its original value prior to this routine returning.
107768 */
107769 static int isShadowTableName(sqlite3 *db, char *zName){
107770 char *zTail; /* Pointer to the last "_" in zName */
107771 Table *pTab; /* Table that zName is a shadow of */
107772 Module *pMod; /* Module for the virtual table */
107773
107774 zTail = strrchr(zName, '_');
107775 if( zTail==0 ) return 0;
107776 *zTail = 0;
107777 pTab = sqlite3FindTable(db, zName, 0);
107778 *zTail = '_';
107779 if( pTab==0 ) return 0;
107780 if( !IsVirtual(pTab) ) return 0;
107781 pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
107782 if( pMod==0 ) return 0;
107783 if( pMod->pModule->iVersion<3 ) return 0;
107784 if( pMod->pModule->xShadowName==0 ) return 0;
107785 return pMod->pModule->xShadowName(zTail+1);
107786 }
107787
107788 /*
107789 ** This routine is called to report the final ")" that terminates
107790 ** a CREATE TABLE statement.
107791 **
@@ -107494,10 +107821,14 @@
107821 return;
107822 }
107823 assert( !db->mallocFailed );
107824 p = pParse->pNewTable;
107825 if( p==0 ) return;
107826
107827 if( pSelect==0 && isShadowTableName(db, p->zName) ){
107828 p->tabFlags |= TF_Shadow;
107829 }
107830
107831 /* If the db->init.busy is 1 it means we are reading the SQL off the
107832 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
107833 ** So do not write to the disk again. Extract the root page number
107834 ** for the table from the db->init.newTnum field. (The page number
@@ -108002,11 +108333,11 @@
108333 ** erasing iTable (this can happen with an auto-vacuum database).
108334 */
108335 static void destroyRootPage(Parse *pParse, int iTable, int iDb){
108336 Vdbe *v = sqlite3GetVdbe(pParse);
108337 int r1 = sqlite3GetTempReg(pParse);
108338 if( iTable<2 ) sqlite3ErrorMsg(pParse, "corrupt schema");
108339 sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
108340 sqlite3MayAbort(pParse);
108341 #ifndef SQLITE_OMIT_AUTOVACUUM
108342 /* OP_Destroy stores an in integer r1. If this integer
108343 ** is non-zero, then it is the root page number of a table moved to
@@ -110457,10 +110788,25 @@
110788 return p;
110789 }
110790 }
110791 return 0;
110792 }
110793 #ifdef SQLITE_ENABLE_NORMALIZE
110794 SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(
110795 int h, /* Hash of the name */
110796 const char *zFunc, /* Name of function */
110797 int nFunc /* Length of the name */
110798 ){
110799 FuncDef *p;
110800 for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){
110801 if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 ){
110802 return p;
110803 }
110804 }
110805 return 0;
110806 }
110807 #endif /* SQLITE_ENABLE_NORMALIZE */
110808
110809 /*
110810 ** Insert a new FuncDef into a FuncDefHash hash table.
110811 */
110812 SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
@@ -110470,11 +110816,11 @@
110816 int i;
110817 for(i=0; i<nDef; i++){
110818 FuncDef *pOther;
110819 const char *zName = aDef[i].zName;
110820 int nName = sqlite3Strlen30(zName);
110821 int h = SQLITE_FUNC_HASH(zName[0], nName);
110822 assert( zName[0]>='a' && zName[0]<='z' );
110823 pOther = functionSearch(h, zName);
110824 if( pOther ){
110825 assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
110826 aDef[i].pNext = pOther->pNext;
@@ -110549,11 +110895,11 @@
110895 ** new function. But the FuncDefs for built-in functions are read-only.
110896 ** So we must not search for built-ins when creating a new function.
110897 */
110898 if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
110899 bestScore = 0;
110900 h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);
110901 p = functionSearch(h, zName);
110902 while( p ){
110903 int score = matchQuality(p, nArg, enc);
110904 if( score>bestScore ){
110905 pBest = p;
@@ -110696,37 +111042,52 @@
111042 if( sqlite3IndexedByLookup(pParse, pItem) ){
111043 pTab = 0;
111044 }
111045 return pTab;
111046 }
111047
111048 /* Return true if table pTab is read-only.
111049 **
111050 ** A table is read-only if any of the following are true:
111051 **
111052 ** 1) It is a virtual table and no implementation of the xUpdate method
111053 ** has been provided
111054 **
111055 ** 2) It is a system table (i.e. sqlite_master), this call is not
111056 ** part of a nested parse and writable_schema pragma has not
111057 ** been specified
111058 **
111059 ** 3) The table is a shadow table, the database connection is in
111060 ** defensive mode, and the current sqlite3_prepare()
111061 ** is for a top-level SQL statement.
111062 */
111063 static int tabIsReadOnly(Parse *pParse, Table *pTab){
111064 sqlite3 *db;
111065 if( IsVirtual(pTab) ){
111066 return sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0;
111067 }
111068 if( (pTab->tabFlags & (TF_Readonly|TF_Shadow))==0 ) return 0;
111069 db = pParse->db;
111070 if( (pTab->tabFlags & TF_Readonly)!=0 ){
111071 return sqlite3WritableSchema(db)==0 && pParse->nested==0;
111072 }
111073 assert( pTab->tabFlags & TF_Shadow );
111074 return (db->flags & SQLITE_Defensive)!=0
111075 && db->nVdbeExec==0
111076 && db->pVtabCtx==0;
111077 }
111078
111079 /*
111080 ** Check to make sure the given table is writable. If it is not
111081 ** writable, generate an error message and return 1. If it is
111082 ** writable return 0;
111083 */
111084 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
111085 if( tabIsReadOnly(pParse, pTab) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111086 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
111087 return 1;
111088 }
 
111089 #ifndef SQLITE_OMIT_VIEW
111090 if( !viewOk && pTab->pSelect ){
111091 sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
111092 return 1;
111093 }
@@ -114126,11 +114487,11 @@
114487 int iCursor, /* The open cursor on the table */
114488 i16 iCol /* The column that is wanted */
114489 ){
114490 Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);
114491 if( pExpr ){
114492 pExpr->y.pTab = pTab;
114493 pExpr->iTable = iCursor;
114494 pExpr->iColumn = iCol;
114495 }
114496 return pExpr;
114497 }
@@ -115202,11 +115563,12 @@
115563 do{
115564 zColAff[i--] = 0;
115565 }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );
115566 pTab->zColAff = zColAff;
115567 }
115568 assert( zColAff!=0 );
115569 i = sqlite3Strlen30NN(zColAff);
115570 if( i ){
115571 if( iReg ){
115572 sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);
115573 }else{
115574 sqlite3VdbeChangeP4(v, -1, zColAff, i);
@@ -116182,18 +116544,19 @@
116544 #ifdef tmask
116545 #undef tmask
116546 #endif
116547
116548 /*
116549 ** Meanings of bits in of pWalker->eCode for
116550 ** sqlite3ExprReferencesUpdatedColumn()
116551 */
116552 #define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
116553 #define CKCNSTRNT_ROWID 0x02 /* CHECK constraint references the ROWID */
116554
116555 /* This is the Walker callback from sqlite3ExprReferencesUpdatedColumn().
116556 * Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this
116557 ** expression node references any of the
116558 ** columns that are being modifed by an UPDATE statement.
116559 */
116560 static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){
116561 if( pExpr->op==TK_COLUMN ){
116562 assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );
@@ -116211,16 +116574,25 @@
116574 /*
116575 ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The
116576 ** only columns that are modified by the UPDATE are those for which
116577 ** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
116578 **
116579 ** Return true if CHECK constraint pExpr uses any of the
116580 ** changing columns (or the rowid if it is changing). In other words,
116581 ** return true if this CHECK constraint must be validated for
116582 ** the new row in the UPDATE statement.
116583 **
116584 ** 2018-09-15: pExpr might also be an expression for an index-on-expressions.
116585 ** The operation of this routine is the same - return true if an only if
116586 ** the expression uses one or more of columns identified by the second and
116587 ** third arguments.
116588 */
116589 SQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(
116590 Expr *pExpr, /* The expression to be checked */
116591 int *aiChng, /* aiChng[x]>=0 if column x changed by the UPDATE */
116592 int chngRowid /* True if UPDATE changes the rowid */
116593 ){
116594 Walker w;
116595 memset(&w, 0, sizeof(w));
116596 w.eCode = 0;
116597 w.xExprCallback = checkConstraintExprNode;
116598 w.u.aiCol = aiChng;
@@ -116231,11 +116603,11 @@
116603 }
116604 testcase( w.eCode==0 );
116605 testcase( w.eCode==CKCNSTRNT_COLUMN );
116606 testcase( w.eCode==CKCNSTRNT_ROWID );
116607 testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
116608 return w.eCode!=0;
116609 }
116610
116611 /*
116612 ** Generate code to do constraint checks prior to an INSERT or an UPDATE
116613 ** on table pTab.
@@ -116437,11 +116809,17 @@
116809 pParse->iSelfTab = -(regNewData+1);
116810 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
116811 for(i=0; i<pCheck->nExpr; i++){
116812 int allOk;
116813 Expr *pExpr = pCheck->a[i].pExpr;
116814 if( aiChng
116815 && !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng)
116816 ){
116817 /* The check constraints do not reference any of the columns being
116818 ** updated so there is no point it verifying the check constraint */
116819 continue;
116820 }
116821 allOk = sqlite3VdbeMakeLabel(v);
116822 sqlite3VdbeVerifyAbortable(v, onError);
116823 sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
116824 if( onError==OE_Ignore ){
116825 sqlite3VdbeGoto(v, ignoreDest);
@@ -117938,16 +118316,19 @@
118316 void (*str_appendchar)(sqlite3_str*, int N, char C);
118317 void (*str_reset)(sqlite3_str*);
118318 int (*str_errcode)(sqlite3_str*);
118319 int (*str_length)(sqlite3_str*);
118320 char *(*str_value)(sqlite3_str*);
118321 /* Version 3.25.0 and later */
118322 int (*create_window_function)(sqlite3*,const char*,int,int,void*,
118323 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
118324 void (*xFinal)(sqlite3_context*),
118325 void (*xValue)(sqlite3_context*),
118326 void (*xInv)(sqlite3_context*,int,sqlite3_value**),
118327 void(*xDestroy)(void*));
118328 /* Version 3.26.0 and later */
118329 const char *(*normalized_sql)(sqlite3_stmt*);
118330 };
118331
118332 /*
118333 ** This is the function signature used for all extension entry points. It
118334 ** is also defined in the file "loadext.c".
@@ -118231,10 +118612,12 @@
118612 #define sqlite3_str_errcode sqlite3_api->str_errcode
118613 #define sqlite3_str_length sqlite3_api->str_length
118614 #define sqlite3_str_value sqlite3_api->str_value
118615 /* Version 3.25.0 and later */
118616 #define sqlite3_create_window_function sqlite3_api->create_window_function
118617 /* Version 3.26.0 and later */
118618 #define sqlite3_normalized_sql sqlite3_api->normalized_sql
118619 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
118620
118621 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
118622 /* This case when the file really is being compiled as a loadable
118623 ** extension */
@@ -118686,11 +119069,17 @@
119069 sqlite3_str_reset,
119070 sqlite3_str_errcode,
119071 sqlite3_str_length,
119072 sqlite3_str_value,
119073 /* Version 3.25.0 and later */
119074 sqlite3_create_window_function,
119075 /* Version 3.26.0 and later */
119076 #ifdef SQLITE_ENABLE_NORMALIZE
119077 sqlite3_normalized_sql
119078 #else
119079 0
119080 #endif
119081 };
119082
119083 /*
119084 ** Attempt to load an SQLite extension library contained in the file
119085 ** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -119136,14 +119525,13 @@
119525 #define PragTyp_WAL_AUTOCHECKPOINT 38
119526 #define PragTyp_WAL_CHECKPOINT 39
119527 #define PragTyp_ACTIVATE_EXTENSIONS 40
119528 #define PragTyp_HEXKEY 41
119529 #define PragTyp_KEY 42
119530 #define PragTyp_LOCK_STATUS 43
119531 #define PragTyp_PARSER_TRACE 44
119532 #define PragTyp_STATS 45
 
119533
119534 /* Property flags associated with various pragma. */
119535 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
119536 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
119537 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -119156,72 +119544,71 @@
119544 /* Names of columns for pragmas that return multi-column result
119545 ** or that return single-column results where the name of the
119546 ** result column is different from the name of the pragma
119547 */
119548 static const char *const pragCName[] = {
119549 /* 0 */ "id", /* Used by: foreign_key_list */
119550 /* 1 */ "seq",
119551 /* 2 */ "table",
119552 /* 3 */ "from",
119553 /* 4 */ "to",
119554 /* 5 */ "on_update",
119555 /* 6 */ "on_delete",
119556 /* 7 */ "match",
119557 /* 8 */ "cid", /* Used by: table_xinfo */
119558 /* 9 */ "name",
119559 /* 10 */ "type",
119560 /* 11 */ "notnull",
119561 /* 12 */ "dflt_value",
119562 /* 13 */ "pk",
119563 /* 14 */ "hidden",
119564 /* table_info reuses 8 */
119565 /* 15 */ "seqno", /* Used by: index_xinfo */
119566 /* 16 */ "cid",
119567 /* 17 */ "name",
119568 /* 18 */ "desc",
119569 /* 19 */ "coll",
119570 /* 20 */ "key",
119571 /* 21 */ "tbl", /* Used by: stats */
119572 /* 22 */ "idx",
119573 /* 23 */ "wdth",
119574 /* 24 */ "hght",
119575 /* 25 */ "flgs",
119576 /* 26 */ "seq", /* Used by: index_list */
119577 /* 27 */ "name",
119578 /* 28 */ "unique",
119579 /* 29 */ "origin",
119580 /* 30 */ "partial",
119581 /* 31 */ "table", /* Used by: foreign_key_check */
119582 /* 32 */ "rowid",
119583 /* 33 */ "parent",
119584 /* 34 */ "fkid",
119585 /* index_info reuses 15 */
119586 /* 35 */ "seq", /* Used by: database_list */
119587 /* 36 */ "name",
119588 /* 37 */ "file",
119589 /* 38 */ "busy", /* Used by: wal_checkpoint */
119590 /* 39 */ "log",
119591 /* 40 */ "checkpointed",
119592 /* 41 */ "name", /* Used by: function_list */
119593 /* 42 */ "builtin",
119594 /* collation_list reuses 26 */
119595 /* 43 */ "database", /* Used by: lock_status */
119596 /* 44 */ "status",
119597 /* 45 */ "cache_size", /* Used by: default_cache_size */
119598 /* module_list pragma_list reuses 9 */
119599 /* 46 */ "timeout", /* Used by: busy_timeout */
 
 
119600 };
119601
119602 /* Definitions of all built-in pragmas */
119603 typedef struct PragmaName {
119604 const char *const zName; /* Name of pragma */
119605 u8 ePragTyp; /* PragTyp_XXX value */
119606 u8 mPragFlg; /* Zero or more PragFlg_XXX values */
119607 u8 iPragCName; /* Start of column names in pragCName[] */
119608 u8 nPragCName; /* Num of col names. 0 means use pragma name */
119609 u64 iArg; /* Extra argument */
119610 } PragmaName;
119611 static const PragmaName aPragmaName[] = {
119612 #if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
119613 {/* zName: */ "activate_extensions",
119614 /* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
@@ -119253,11 +119640,11 @@
119640 #endif
119641 #endif
119642 {/* zName: */ "busy_timeout",
119643 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
119644 /* ePragFlg: */ PragFlg_Result0,
119645 /* ColNames: */ 46, 1,
119646 /* iArg: */ 0 },
119647 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119648 {/* zName: */ "cache_size",
119649 /* ePragTyp: */ PragTyp_CACHE_SIZE,
119650 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -119290,11 +119677,11 @@
119677 #endif
119678 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119679 {/* zName: */ "collation_list",
119680 /* ePragTyp: */ PragTyp_COLLATION_LIST,
119681 /* ePragFlg: */ PragFlg_Result0,
119682 /* ColNames: */ 26, 2,
119683 /* iArg: */ 0 },
119684 #endif
119685 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
119686 {/* zName: */ "compile_options",
119687 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -119325,18 +119712,18 @@
119712 #endif
119713 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119714 {/* zName: */ "database_list",
119715 /* ePragTyp: */ PragTyp_DATABASE_LIST,
119716 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119717 /* ColNames: */ 35, 3,
119718 /* iArg: */ 0 },
119719 #endif
119720 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
119721 {/* zName: */ "default_cache_size",
119722 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
119723 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
119724 /* ColNames: */ 45, 1,
119725 /* iArg: */ 0 },
119726 #endif
119727 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119728 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119729 {/* zName: */ "defer_foreign_keys",
@@ -119362,18 +119749,18 @@
119749 #endif
119750 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119751 {/* zName: */ "foreign_key_check",
119752 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
119753 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
119754 /* ColNames: */ 31, 4,
119755 /* iArg: */ 0 },
119756 #endif
119757 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
119758 {/* zName: */ "foreign_key_list",
119759 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
119760 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119761 /* ColNames: */ 0, 8,
119762 /* iArg: */ 0 },
119763 #endif
119764 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119765 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
119766 {/* zName: */ "foreign_keys",
@@ -119405,25 +119792,25 @@
119792 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119793 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119794 {/* zName: */ "function_list",
119795 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
119796 /* ePragFlg: */ PragFlg_Result0,
119797 /* ColNames: */ 41, 2,
119798 /* iArg: */ 0 },
119799 #endif
119800 #endif
119801 #if defined(SQLITE_HAS_CODEC)
119802 {/* zName: */ "hexkey",
119803 /* ePragTyp: */ PragTyp_HEXKEY,
119804 /* ePragFlg: */ 0,
119805 /* ColNames: */ 0, 0,
119806 /* iArg: */ 2 },
119807 {/* zName: */ "hexrekey",
119808 /* ePragTyp: */ PragTyp_HEXKEY,
119809 /* ePragFlg: */ 0,
119810 /* ColNames: */ 0, 0,
119811 /* iArg: */ 3 },
119812 #endif
119813 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119814 #if !defined(SQLITE_OMIT_CHECK)
119815 {/* zName: */ "ignore_check_constraints",
119816 /* ePragTyp: */ PragTyp_FLAG,
@@ -119441,16 +119828,16 @@
119828 #endif
119829 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
119830 {/* zName: */ "index_info",
119831 /* ePragTyp: */ PragTyp_INDEX_INFO,
119832 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119833 /* ColNames: */ 15, 3,
119834 /* iArg: */ 0 },
119835 {/* zName: */ "index_list",
119836 /* ePragTyp: */ PragTyp_INDEX_LIST,
119837 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119838 /* ColNames: */ 26, 5,
119839 /* iArg: */ 0 },
119840 {/* zName: */ "index_xinfo",
119841 /* ePragTyp: */ PragTyp_INDEX_INFO,
119842 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
119843 /* ColNames: */ 15, 6,
@@ -119503,11 +119890,11 @@
119890 #endif
119891 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
119892 {/* zName: */ "lock_status",
119893 /* ePragTyp: */ PragTyp_LOCK_STATUS,
119894 /* ePragFlg: */ PragFlg_Result0,
119895 /* ColNames: */ 43, 2,
119896 /* iArg: */ 0 },
119897 #endif
119898 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
119899 {/* zName: */ "locking_mode",
119900 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -119529,11 +119916,11 @@
119916 #if !defined(SQLITE_OMIT_VIRTUALTABLE)
119917 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119918 {/* zName: */ "module_list",
119919 /* ePragTyp: */ PragTyp_MODULE_LIST,
119920 /* ePragFlg: */ PragFlg_Result0,
119921 /* ColNames: */ 9, 1,
119922 /* iArg: */ 0 },
119923 #endif
119924 #endif
119925 #endif
119926 {/* zName: */ "optimize",
@@ -119562,11 +119949,11 @@
119949 #endif
119950 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
119951 {/* zName: */ "pragma_list",
119952 /* ePragTyp: */ PragTyp_PRAGMA_LIST,
119953 /* ePragFlg: */ PragFlg_Result0,
119954 /* ColNames: */ 9, 1,
119955 /* iArg: */ 0 },
119956 #endif
119957 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119958 {/* zName: */ "query_only",
119959 /* ePragTyp: */ PragTyp_FLAG,
@@ -119593,14 +119980,14 @@
119980 /* ColNames: */ 0, 0,
119981 /* iArg: */ SQLITE_RecTriggers },
119982 #endif
119983 #if defined(SQLITE_HAS_CODEC)
119984 {/* zName: */ "rekey",
119985 /* ePragTyp: */ PragTyp_KEY,
119986 /* ePragFlg: */ 0,
119987 /* ColNames: */ 0, 0,
119988 /* iArg: */ 1 },
119989 #endif
119990 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
119991 {/* zName: */ "reverse_unordered_selects",
119992 /* ePragTyp: */ PragTyp_FLAG,
119993 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119649,11 +120036,11 @@
120036 #endif
120037 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
120038 {/* zName: */ "stats",
120039 /* ePragTyp: */ PragTyp_STATS,
120040 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
120041 /* ColNames: */ 21, 5,
120042 /* iArg: */ 0 },
120043 #endif
120044 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
120045 {/* zName: */ "synchronous",
120046 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -119663,12 +120050,17 @@
120050 #endif
120051 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
120052 {/* zName: */ "table_info",
120053 /* ePragTyp: */ PragTyp_TABLE_INFO,
120054 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
120055 /* ColNames: */ 8, 6,
120056 /* iArg: */ 0 },
120057 {/* zName: */ "table_xinfo",
120058 /* ePragTyp: */ PragTyp_TABLE_INFO,
120059 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
120060 /* ColNames: */ 8, 7,
120061 /* iArg: */ 1 },
120062 #endif
120063 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
120064 {/* zName: */ "temp_store",
120065 /* ePragTyp: */ PragTyp_TEMP_STORE,
120066 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -119677,10 +120069,22 @@
120069 {/* zName: */ "temp_store_directory",
120070 /* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
120071 /* ePragFlg: */ PragFlg_NoColumns1,
120072 /* ColNames: */ 0, 0,
120073 /* iArg: */ 0 },
120074 #endif
120075 #if defined(SQLITE_HAS_CODEC)
120076 {/* zName: */ "textkey",
120077 /* ePragTyp: */ PragTyp_KEY,
120078 /* ePragFlg: */ 0,
120079 /* ColNames: */ 0, 0,
120080 /* iArg: */ 4 },
120081 {/* zName: */ "textrekey",
120082 /* ePragTyp: */ PragTyp_KEY,
120083 /* ePragFlg: */ 0,
120084 /* ColNames: */ 0, 0,
120085 /* iArg: */ 5 },
120086 #endif
120087 {/* zName: */ "threads",
120088 /* ePragTyp: */ PragTyp_THREADS,
120089 /* ePragFlg: */ PragFlg_Result0,
120090 /* ColNames: */ 0, 0,
@@ -119728,22 +120132,22 @@
120132 /* ColNames: */ 0, 0,
120133 /* iArg: */ 0 },
120134 {/* zName: */ "wal_checkpoint",
120135 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
120136 /* ePragFlg: */ PragFlg_NeedSchema,
120137 /* ColNames: */ 38, 3,
120138 /* iArg: */ 0 },
120139 #endif
120140 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
120141 {/* zName: */ "writable_schema",
120142 /* ePragTyp: */ PragTyp_FLAG,
120143 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
120144 /* ColNames: */ 0, 0,
120145 /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
120146 #endif
120147 };
120148 /* Number of pragmas: 62 on by default, 81 total. */
120149
120150 /************** End of pragma.h **********************************************/
120151 /************** Continuing where we left off in pragma.c *********************/
120152
120153 /*
@@ -120751,11 +121155,11 @@
121155 case PragTyp_FLAG: {
121156 if( zRight==0 ){
121157 setPragmaResultColumnNames(v, pPragma);
121158 returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );
121159 }else{
121160 u64 mask = pPragma->iArg; /* Mask of bits to set or clear. */
121161 if( db->autoCommit==0 ){
121162 /* Foreign key support may not be enabled or disabled while not
121163 ** in auto-commit mode. */
121164 mask &= ~(SQLITE_ForeignKeys);
121165 }
@@ -120804,15 +121208,16 @@
121208 if( pTab ){
121209 int i, k;
121210 int nHidden = 0;
121211 Column *pCol;
121212 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
121213 pParse->nMem = 7;
121214 sqlite3CodeVerifySchema(pParse, iDb);
121215 sqlite3ViewGetColumnNames(pParse, pTab);
121216 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
121217 int isHidden = IsHiddenColumn(pCol);
121218 if( isHidden && pPragma->iArg==0 ){
121219 nHidden++;
121220 continue;
121221 }
121222 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
121223 k = 0;
@@ -120820,17 +121225,18 @@
121225 k = 1;
121226 }else{
121227 for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
121228 }
121229 assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
121230 sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
121231 i-nHidden,
121232 pCol->zName,
121233 sqlite3ColumnType(pCol,""),
121234 pCol->notNull ? 1 : 0,
121235 pCol->pDflt ? pCol->pDflt->u.zToken : 0,
121236 k,
121237 isHidden);
121238 }
121239 }
121240 }
121241 break;
121242
@@ -121830,16 +122236,28 @@
122236 break;
122237 }
122238 #endif
122239
122240 #ifdef SQLITE_HAS_CODEC
122241 /* Pragma iArg
122242 ** ---------- ------
122243 ** key 0
122244 ** rekey 1
122245 ** hexkey 2
122246 ** hexrekey 3
122247 ** textkey 4
122248 ** textrekey 5
122249 */
122250 case PragTyp_KEY: {
122251 if( zRight ){
122252 int n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1;
122253 if( (pPragma->iArg & 1)==0 ){
122254 sqlite3_key_v2(db, zDb, zRight, n);
122255 }else{
122256 sqlite3_rekey_v2(db, zDb, zRight, n);
122257 }
122258 }
122259 break;
122260 }
122261 case PragTyp_HEXKEY: {
122262 if( zRight ){
122263 u8 iByte;
@@ -121847,11 +122265,11 @@
122265 char zKey[40];
122266 for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
122267 iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
122268 if( (i&1)!=0 ) zKey[i/2] = iByte;
122269 }
122270 if( (pPragma->iArg & 1)==0 ){
122271 sqlite3_key_v2(db, zDb, zKey, i/2);
122272 }else{
122273 sqlite3_rekey_v2(db, zDb, zKey, i/2);
122274 }
122275 }
@@ -122177,11 +122595,12 @@
122595 0, /* xRollback - rollback transaction */
122596 0, /* xFindFunction - function overloading */
122597 0, /* xRename - rename the table */
122598 0, /* xSavepoint */
122599 0, /* xRelease */
122600 0, /* xRollbackTo */
122601 0 /* xShadowName */
122602 };
122603
122604 /*
122605 ** Check to see if zTabName is really the name of a pragma. If it is,
122606 ** then register an eponymous virtual table for that pragma and return
@@ -122530,12 +122949,12 @@
122949 }
122950 if( db->mallocFailed ){
122951 rc = SQLITE_NOMEM_BKPT;
122952 sqlite3ResetAllSchemasOfConnection(db);
122953 }
122954 if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
122955 /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider
122956 ** the schema loaded, even if errors occurred. In this situation the
122957 ** current sqlite3_prepare() operation will fail, but the following one
122958 ** will attempt to compile the supplied statement against whatever subset
122959 ** of the schema was loaded before the error occurred. The primary
122960 ** purpose of this is to allow access to the sqlite_master table
@@ -122912,10 +123331,298 @@
123331 assert( (rc&db->errMask)==rc );
123332 sqlite3_mutex_leave(db->mutex);
123333 return rc;
123334 }
123335
123336 #ifdef SQLITE_ENABLE_NORMALIZE
123337 /*
123338 ** Checks if the specified token is a table, column, or function name,
123339 ** based on the databases associated with the statement being prepared.
123340 ** If the function fails, zero is returned and pRc is filled with the
123341 ** error code.
123342 */
123343 static int shouldTreatAsIdentifier(
123344 sqlite3 *db, /* Database handle. */
123345 const char *zToken, /* Pointer to start of token to be checked */
123346 int nToken, /* Length of token to be checked */
123347 int *pRc /* Pointer to error code upon failure */
123348 ){
123349 int bFound = 0; /* Non-zero if token is an identifier name. */
123350 int i, j; /* Database and column loop indexes. */
123351 Schema *pSchema; /* Schema for current database. */
123352 Hash *pHash; /* Hash table of tables for current database. */
123353 HashElem *e; /* Hash element for hash table iteration. */
123354 Table *pTab; /* Database table for columns being checked. */
123355
123356 if( sqlite3IsRowidN(zToken, nToken) ){
123357 return 1;
123358 }
123359 if( nToken>0 ){
123360 int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
123361 if( sqlite3FunctionSearchN(hash, zToken, nToken) ) return 1;
123362 }
123363 assert( db!=0 );
123364 sqlite3_mutex_enter(db->mutex);
123365 sqlite3BtreeEnterAll(db);
123366 for(i=0; i<db->nDb; i++){
123367 pHash = &db->aFunc;
123368 if( sqlite3HashFindN(pHash, zToken, nToken) ){
123369 bFound = 1;
123370 break;
123371 }
123372 pSchema = db->aDb[i].pSchema;
123373 if( pSchema==0 ) continue;
123374 pHash = &pSchema->tblHash;
123375 if( sqlite3HashFindN(pHash, zToken, nToken) ){
123376 bFound = 1;
123377 break;
123378 }
123379 for(e=sqliteHashFirst(pHash); e; e=sqliteHashNext(e)){
123380 pTab = sqliteHashData(e);
123381 if( pTab==0 ) continue;
123382 pHash = pTab->pColHash;
123383 if( pHash==0 ){
123384 pTab->pColHash = pHash = sqlite3_malloc(sizeof(Hash));
123385 if( pHash ){
123386 sqlite3HashInit(pHash);
123387 for(j=0; j<pTab->nCol; j++){
123388 Column *pCol = &pTab->aCol[j];
123389 sqlite3HashInsert(pHash, pCol->zName, pCol);
123390 }
123391 }else{
123392 *pRc = SQLITE_NOMEM_BKPT;
123393 bFound = 0;
123394 goto done;
123395 }
123396 }
123397 if( pHash && sqlite3HashFindN(pHash, zToken, nToken) ){
123398 bFound = 1;
123399 goto done;
123400 }
123401 }
123402 }
123403 done:
123404 sqlite3BtreeLeaveAll(db);
123405 sqlite3_mutex_leave(db->mutex);
123406 return bFound;
123407 }
123408
123409 /*
123410 ** Attempt to estimate the final output buffer size needed for the fully
123411 ** normalized version of the specified SQL string. This should take into
123412 ** account any potential expansion that could occur (e.g. via IN clauses
123413 ** being expanded, etc). This size returned is the total number of bytes
123414 ** including the NUL terminator.
123415 */
123416 static int estimateNormalizedSize(
123417 const char *zSql, /* The original SQL string */
123418 int nSql, /* Length of original SQL string */
123419 u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
123420 ){
123421 int nOut = nSql + 4;
123422 const char *z = zSql;
123423 while( nOut<nSql*5 ){
123424 while( z[0]!=0 && z[0]!='I' && z[0]!='i' ){ z++; }
123425 if( z[0]==0 ) break;
123426 z++;
123427 if( z[0]!='N' && z[0]!='n' ) break;
123428 z++;
123429 while( sqlite3Isspace(z[0]) ){ z++; }
123430 if( z[0]!='(' ) break;
123431 z++;
123432 nOut += 5; /* ?,?,? */
123433 }
123434 return nOut;
123435 }
123436
123437 /*
123438 ** Copy the current token into the output buffer while dealing with quoted
123439 ** identifiers. By default, all letters will be converted into lowercase.
123440 ** If the bUpper flag is set, uppercase will be used. The piOut argument
123441 ** will be used to update the target index into the output string.
123442 */
123443 static void copyNormalizedToken(
123444 const char *zSql, /* The original SQL string */
123445 int iIn, /* Current index into the original SQL string */
123446 int nToken, /* Number of bytes in the current token */
123447 int tokenFlags, /* Flags returned by the tokenizer */
123448 char *zOut, /* The output string */
123449 int *piOut /* Pointer to target index into the output string */
123450 ){
123451 int bQuoted = tokenFlags & SQLITE_TOKEN_QUOTED;
123452 int bKeyword = tokenFlags & SQLITE_TOKEN_KEYWORD;
123453 int j = *piOut, k = 0;
123454 for(; k<nToken; k++){
123455 if( bQuoted ){
123456 if( k==0 && iIn>0 ){
123457 zOut[j++] = '"';
123458 continue;
123459 }else if( k==nToken-1 ){
123460 zOut[j++] = '"';
123461 continue;
123462 }
123463 }
123464 if( bKeyword ){
123465 zOut[j++] = sqlite3Toupper(zSql[iIn+k]);
123466 }else{
123467 zOut[j++] = sqlite3Tolower(zSql[iIn+k]);
123468 }
123469 }
123470 *piOut = j;
123471 }
123472
123473 /*
123474 ** Perform normalization of the SQL contained in the prepared statement and
123475 ** store the result in the zNormSql field. The schema for the associated
123476 ** databases are consulted while performing the normalization in order to
123477 ** determine if a token appears to be an identifier. All identifiers are
123478 ** left intact in the normalized SQL and all literals are replaced with a
123479 ** single '?'.
123480 */
123481 SQLITE_PRIVATE void sqlite3Normalize(
123482 Vdbe *pVdbe, /* VM being reprepared */
123483 const char *zSql, /* The original SQL string */
123484 int nSql, /* Size of the input string in bytes */
123485 u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
123486 ){
123487 sqlite3 *db; /* Database handle. */
123488 char *z; /* The output string */
123489 int nZ; /* Size of the output string in bytes */
123490 int i; /* Next character to read from zSql[] */
123491 int j; /* Next character to fill in on z[] */
123492 int tokenType = 0; /* Type of the next token */
123493 int prevTokenType = 0; /* Type of the previous token, except spaces */
123494 int n; /* Size of the next token */
123495 int nParen = 0; /* Nesting level of parenthesis */
123496 Hash inHash; /* Table of parenthesis levels to output index. */
123497
123498 db = sqlite3VdbeDb(pVdbe);
123499 assert( db!=0 );
123500 assert( pVdbe->zNormSql==0 );
123501 if( zSql==0 ) return;
123502 nZ = estimateNormalizedSize(zSql, nSql, prepFlags);
123503 z = sqlite3DbMallocRawNN(db, nZ);
123504 if( z==0 ) return;
123505 sqlite3HashInit(&inHash);
123506 for(i=j=0; i<nSql && zSql[i]; i+=n){
123507 int flags = 0;
123508 if( tokenType!=TK_SPACE ) prevTokenType = tokenType;
123509 n = sqlite3GetTokenNormalized((unsigned char*)zSql+i, &tokenType, &flags);
123510 switch( tokenType ){
123511 case TK_SPACE: {
123512 break;
123513 }
123514 case TK_ILLEGAL: {
123515 sqlite3DbFree(db, z);
123516 sqlite3HashClear(&inHash);
123517 return;
123518 }
123519 case TK_STRING:
123520 case TK_INTEGER:
123521 case TK_FLOAT:
123522 case TK_VARIABLE:
123523 case TK_BLOB: {
123524 z[j++] = '?';
123525 break;
123526 }
123527 case TK_LP:
123528 case TK_RP: {
123529 if( tokenType==TK_LP ){
123530 nParen++;
123531 if( prevTokenType==TK_IN ){
123532 assert( nParen<nSql );
123533 sqlite3HashInsert(&inHash, zSql+nParen, SQLITE_INT_TO_PTR(j));
123534 }
123535 }else{
123536 int jj;
123537 assert( nParen<nSql );
123538 jj = SQLITE_PTR_TO_INT(sqlite3HashFind(&inHash, zSql+nParen));
123539 if( jj>0 ){
123540 sqlite3HashInsert(&inHash, zSql+nParen, 0);
123541 assert( jj+6<nZ );
123542 memcpy(z+jj+1, "?,?,?", 5);
123543 j = jj+6;
123544 assert( nZ-1-j>=0 );
123545 assert( nZ-1-j<nZ );
123546 memset(z+j, 0, nZ-1-j);
123547 }
123548 nParen--;
123549 }
123550 assert( nParen>=0 );
123551 /* Fall through */
123552 }
123553 case TK_MINUS:
123554 case TK_SEMI:
123555 case TK_PLUS:
123556 case TK_STAR:
123557 case TK_SLASH:
123558 case TK_REM:
123559 case TK_EQ:
123560 case TK_LE:
123561 case TK_NE:
123562 case TK_LSHIFT:
123563 case TK_LT:
123564 case TK_RSHIFT:
123565 case TK_GT:
123566 case TK_GE:
123567 case TK_BITOR:
123568 case TK_CONCAT:
123569 case TK_COMMA:
123570 case TK_BITAND:
123571 case TK_BITNOT:
123572 case TK_DOT:
123573 case TK_IN:
123574 case TK_IS:
123575 case TK_NOT:
123576 case TK_NULL:
123577 case TK_ID: {
123578 if( tokenType==TK_NULL ){
123579 if( prevTokenType==TK_IS || prevTokenType==TK_NOT ){
123580 /* NULL is a keyword in this case, not a literal value */
123581 }else{
123582 /* Here the NULL is a literal value */
123583 z[j++] = '?';
123584 break;
123585 }
123586 }
123587 if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){
123588 z[j++] = ' ';
123589 }
123590 if( tokenType==TK_ID ){
123591 int i2 = i, n2 = n, rc = SQLITE_OK;
123592 if( nParen>0 ){
123593 assert( nParen<nSql );
123594 sqlite3HashInsert(&inHash, zSql+nParen, 0);
123595 }
123596 if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; }
123597 if( shouldTreatAsIdentifier(db, zSql+i2, n2, &rc)==0 ){
123598 if( rc!=SQLITE_OK ){
123599 sqlite3DbFree(db, z);
123600 sqlite3HashClear(&inHash);
123601 return;
123602 }
123603 if( sqlite3_keyword_check(zSql+i2, n2)==0 ){
123604 z[j++] = '?';
123605 break;
123606 }
123607 }
123608 }
123609 copyNormalizedToken(zSql, i, n, flags, z, &j);
123610 break;
123611 }
123612 }
123613 }
123614 assert( j<nZ && "one" );
123615 while( j>0 && z[j-1]==' ' ){ j--; }
123616 if( j>0 && z[j-1]!=';' ){ z[j++] = ';'; }
123617 z[j] = 0;
123618 assert( j<nZ && "two" );
123619 pVdbe->zNormSql = z;
123620 sqlite3HashClear(&inHash);
123621 }
123622 #endif /* SQLITE_ENABLE_NORMALIZE */
123623
123624 /*
123625 ** Rerun the compilation of a statement after a schema change.
123626 **
123627 ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,
123628 ** if the statement cannot be recompiled because another connection has
@@ -123924,11 +124631,11 @@
124631 ExprList *pExtra = 0;
124632 for(i=0; i<pEList->nExpr; i++){
124633 struct ExprList_item *pItem = &pEList->a[i];
124634 if( pItem->u.x.iOrderByCol==0 ){
124635 Expr *pExpr = pItem->pExpr;
124636 Table *pTab = pExpr->y.pTab;
124637 if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab)
124638 && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
124639 ){
124640 int j;
124641 for(j=0; j<nDefer; j++){
@@ -123947,16 +124654,16 @@
124654 }
124655 for(k=0; k<nKey; k++){
124656 Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
124657 if( pNew ){
124658 pNew->iTable = pExpr->iTable;
124659 pNew->y.pTab = pExpr->y.pTab;
124660 pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
124661 pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
124662 }
124663 }
124664 pSort->aDefer[nDefer].pTab = pExpr->y.pTab;
124665 pSort->aDefer[nDefer].iCsr = pExpr->iTable;
124666 pSort->aDefer[nDefer].nKey = nKey;
124667 nDefer++;
124668 }
124669 }
@@ -124801,11 +125508,11 @@
125508 ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
125509 ** branch below. */
125510 break;
125511 }
125512
125513 assert( pTab && pExpr->y.pTab==pTab );
125514 if( pS ){
125515 /* The "table" is actually a sub-select or a view in the FROM clause
125516 ** of the SELECT statement. Return the declaration type and origin
125517 ** data for the result-set column of the sub-select.
125518 */
@@ -124986,19 +125693,19 @@
125693 for(i=0; i<pEList->nExpr; i++){
125694 Expr *p = pEList->a[i].pExpr;
125695
125696 assert( p!=0 );
125697 assert( p->op!=TK_AGG_COLUMN ); /* Agg processing has not run yet */
125698 assert( p->op!=TK_COLUMN || p->y.pTab!=0 ); /* Covering idx not yet coded */
125699 if( pEList->a[i].zName ){
125700 /* An AS clause always takes first priority */
125701 char *zName = pEList->a[i].zName;
125702 sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);
125703 }else if( srcName && p->op==TK_COLUMN ){
125704 char *zCol;
125705 int iCol = p->iColumn;
125706 pTab = p->y.pTab;
125707 assert( pTab!=0 );
125708 if( iCol<0 ) iCol = pTab->iPKey;
125709 assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
125710 if( iCol<0 ){
125711 zCol = "rowid";
@@ -125085,11 +125792,11 @@
125792 }
125793 assert( pColExpr->op!=TK_AGG_COLUMN );
125794 if( pColExpr->op==TK_COLUMN ){
125795 /* For columns use the column name name */
125796 int iCol = pColExpr->iColumn;
125797 Table *pTab = pColExpr->y.pTab;
125798 assert( pTab!=0 );
125799 if( iCol<0 ) iCol = pTab->iPKey;
125800 zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
125801 }else if( pColExpr->op==TK_ID ){
125802 assert( !ExprHasProperty(pColExpr, EP_IntValue) );
@@ -125438,10 +126145,17 @@
126145 int i; /* Loop counter */
126146 int rc; /* Result code */
126147 ExprList *pOrderBy; /* The ORDER BY clause */
126148 Expr *pLimit; /* Saved LIMIT and OFFSET */
126149 int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */
126150
126151 #ifndef SQLITE_OMIT_WINDOWFUNC
126152 if( p->pWin ){
126153 sqlite3ErrorMsg(pParse, "cannot use window functions in recursive queries");
126154 return;
126155 }
126156 #endif
126157
126158 /* Obtain authorization to do a recursive query */
126159 if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
126160
126161 /* Process the LIMIT and OFFSET clauses, if they exist */
@@ -127188,11 +127902,11 @@
127902 return 1;
127903 }
127904 #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
127905
127906 /*
127907 ** A structure to keep track of all of the column values that are fixed to
127908 ** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
127909 */
127910 typedef struct WhereConst WhereConst;
127911 struct WhereConst {
127912 Parse *pParse; /* Parsing context */
@@ -127200,17 +127914,32 @@
127914 int nChng; /* Number of times a constant is propagated */
127915 Expr **apExpr; /* [i*2] is COLUMN and [i*2+1] is VALUE */
127916 };
127917
127918 /*
127919 ** Add a new entry to the pConst object. Except, do not add duplicate
127920 ** pColumn entires.
127921 */
127922 static void constInsert(
127923 WhereConst *pConst, /* The WhereConst into which we are inserting */
127924 Expr *pColumn, /* The COLUMN part of the constraint */
127925 Expr *pValue /* The VALUE part of the constraint */
127926 ){
127927 int i;
127928 assert( pColumn->op==TK_COLUMN );
127929
127930 /* 2018-10-25 ticket [cf5ed20f]
127931 ** Make sure the same pColumn is not inserted more than once */
127932 for(i=0; i<pConst->nConst; i++){
127933 const Expr *pExpr = pConst->apExpr[i*2];
127934 assert( pExpr->op==TK_COLUMN );
127935 if( pExpr->iTable==pColumn->iTable
127936 && pExpr->iColumn==pColumn->iColumn
127937 ){
127938 return; /* Already present. Return without doing anything. */
127939 }
127940 }
127941
127942 pConst->nConst++;
127943 pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,
127944 pConst->nConst*2*sizeof(Expr*));
127945 if( pConst->apExpr==0 ){
@@ -131187,10 +131916,61 @@
131916 if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
131917 sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
131918 }
131919 #endif
131920 }
131921
131922 /*
131923 ** Check to see if column iCol of index pIdx references any of the
131924 ** columns defined by aXRef and chngRowid. Return true if it does
131925 ** and false if not. This is an optimization. False-positives are a
131926 ** performance degradation, but false-negatives can result in a corrupt
131927 ** index and incorrect answers.
131928 **
131929 ** aXRef[j] will be non-negative if column j of the original table is
131930 ** being updated. chngRowid will be true if the rowid of the table is
131931 ** being updated.
131932 */
131933 static int indexColumnIsBeingUpdated(
131934 Index *pIdx, /* The index to check */
131935 int iCol, /* Which column of the index to check */
131936 int *aXRef, /* aXRef[j]>=0 if column j is being updated */
131937 int chngRowid /* true if the rowid is being updated */
131938 ){
131939 i16 iIdxCol = pIdx->aiColumn[iCol];
131940 assert( iIdxCol!=XN_ROWID ); /* Cannot index rowid */
131941 if( iIdxCol>=0 ){
131942 return aXRef[iIdxCol]>=0;
131943 }
131944 assert( iIdxCol==XN_EXPR );
131945 assert( pIdx->aColExpr!=0 );
131946 assert( pIdx->aColExpr->a[iCol].pExpr!=0 );
131947 return sqlite3ExprReferencesUpdatedColumn(pIdx->aColExpr->a[iCol].pExpr,
131948 aXRef,chngRowid);
131949 }
131950
131951 /*
131952 ** Check to see if index pIdx is a partial index whose conditional
131953 ** expression might change values due to an UPDATE. Return true if
131954 ** the index is subject to change and false if the index is guaranteed
131955 ** to be unchanged. This is an optimization. False-positives are a
131956 ** performance degradation, but false-negatives can result in a corrupt
131957 ** index and incorrect answers.
131958 **
131959 ** aXRef[j] will be non-negative if column j of the original table is
131960 ** being updated. chngRowid will be true if the rowid of the table is
131961 ** being updated.
131962 */
131963 static int indexWhereClauseMightChange(
131964 Index *pIdx, /* The index to check */
131965 int *aXRef, /* aXRef[j]>=0 if column j is being updated */
131966 int chngRowid /* true if the rowid is being updated */
131967 ){
131968 if( pIdx->pPartIdxWhere==0 ) return 0;
131969 return sqlite3ExprReferencesUpdatedColumn(pIdx->pPartIdxWhere,
131970 aXRef, chngRowid);
131971 }
131972
131973 /*
131974 ** Process an UPDATE statement.
131975 **
131976 ** UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
@@ -131411,23 +132191,22 @@
132191 hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);
132192
132193 /* There is one entry in the aRegIdx[] array for each index on the table
132194 ** being updated. Fill in aRegIdx[] with a register number that will hold
132195 ** the key for accessing each index.
 
 
132196 */
132197 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
132198 int reg;
132199 if( chngKey || hasFK>1 || pIdx==pPk
132200 || indexWhereClauseMightChange(pIdx,aXRef,chngRowid)
132201 ){
132202 reg = ++pParse->nMem;
132203 pParse->nMem += pIdx->nColumn;
132204 }else{
132205 reg = 0;
132206 for(i=0; i<pIdx->nKeyCol; i++){
132207 if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
 
132208 reg = ++pParse->nMem;
132209 pParse->nMem += pIdx->nColumn;
132210 if( (onError==OE_Replace)
132211 || (onError==OE_Default && pIdx->onError==OE_Replace)
132212 ){
@@ -131972,11 +132751,11 @@
132751 for(i=0; i<pTab->nCol; i++){
132752 if( aXRef[i]>=0 ){
132753 sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
132754 }else{
132755 sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
132756 sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
132757 }
132758 }
132759 if( HasRowid(pTab) ){
132760 sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);
132761 if( pRowid ){
@@ -132473,11 +133252,12 @@
133252 saved_nChange = db->nChange;
133253 saved_nTotalChange = db->nTotalChange;
133254 saved_mTrace = db->mTrace;
133255 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
133256 db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;
133257 db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder
133258 | SQLITE_Defensive | SQLITE_CountRows);
133259 db->mTrace = 0;
133260
133261 zDbMain = db->aDb[iDb].zDbSName;
133262 pMain = db->aDb[iDb].pBt;
133263 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
@@ -133015,22 +133795,19 @@
133795 Token *pName1, /* Name of new table, or database name */
133796 Token *pName2, /* Name of new table or NULL */
133797 Token *pModuleName, /* Name of the module for the virtual table */
133798 int ifNotExists /* No error if the table already exists */
133799 ){
 
133800 Table *pTable; /* The new virtual table */
133801 sqlite3 *db; /* Database connection */
133802
133803 sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);
133804 pTable = pParse->pNewTable;
133805 if( pTable==0 ) return;
133806 assert( 0==pTable->pIndex );
133807
133808 db = pParse->db;
 
 
133809
133810 assert( pTable->nModuleArg==0 );
133811 addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
133812 addModuleArgument(db, pTable, 0);
133813 addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
@@ -133046,10 +133823,12 @@
133823 ** The first invocation, to obtain permission to INSERT a row into the
133824 ** sqlite_master table, has already been made by sqlite3StartTable().
133825 ** The second call, to obtain permission to create the table, is made now.
133826 */
133827 if( pTable->azModuleArg ){
133828 int iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
133829 assert( iDb>=0 ); /* The database the table is being created in */
133830 sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
133831 pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);
133832 }
133833 #endif
133834 }
@@ -133740,11 +134519,11 @@
134519 int rc = 0;
134520
134521 /* Check to see the left operand is a column in a virtual table */
134522 if( NEVER(pExpr==0) ) return pDef;
134523 if( pExpr->op!=TK_COLUMN ) return pDef;
134524 pTab = pExpr->y.pTab;
134525 if( pTab==0 ) return pDef;
134526 if( !IsVirtual(pTab) ) return pDef;
134527 pVtab = sqlite3GetVTable(db, pTab)->pVtab;
134528 assert( pVtab!=0 );
134529 assert( pVtab->pModule!=0 );
@@ -134360,15 +135139,36 @@
135139 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
135140 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
135141 int nRecValid; /* Number of valid fields currently in pRec */
135142 #endif
135143 unsigned int bldFlags; /* SQLITE_BLDF_* flags */
135144 unsigned int iPlanLimit; /* Search limiter */
135145 };
135146
135147 /* Allowed values for WhereLoopBuider.bldFlags */
135148 #define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
135149 #define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
135150
135151 /* The WhereLoopBuilder.iPlanLimit is used to limit the number of
135152 ** index+constraint combinations the query planner will consider for a
135153 ** particular query. If this parameter is unlimited, then certain
135154 ** pathological queries can spend excess time in the sqlite3WhereBegin()
135155 ** routine. The limit is high enough that is should not impact real-world
135156 ** queries.
135157 **
135158 ** SQLITE_QUERY_PLANNER_LIMIT is the baseline limit. The limit is
135159 ** increased by SQLITE_QUERY_PLANNER_LIMIT_INCR before each term of the FROM
135160 ** clause is processed, so that every table in a join is guaranteed to be
135161 ** able to propose a some index+constraint combinations even if the initial
135162 ** baseline limit was exhausted by prior tables of the join.
135163 */
135164 #ifndef SQLITE_QUERY_PLANNER_LIMIT
135165 # define SQLITE_QUERY_PLANNER_LIMIT 20000
135166 #endif
135167 #ifndef SQLITE_QUERY_PLANNER_LIMIT_INCR
135168 # define SQLITE_QUERY_PLANNER_LIMIT_INCR 1000
135169 #endif
135170
135171 /*
135172 ** The WHERE clause processing routine has two halves. The
135173 ** first part does the start of the WHERE loop and the second
135174 ** half does the tail of the WHERE loop. An instance of
@@ -134927,11 +135727,11 @@
135727 Select *pSelect; /* Pointer to the SELECT on the RHS */
135728
135729 for(i=iEq; i<pLoop->nLTerm; i++){
135730 if( pLoop->aLTerm[i]->pExpr==pX ){
135731 int iField = pLoop->aLTerm[i]->iField - 1;
135732 if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
135733 pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
135734 pOrigRhs->a[iField].pExpr = 0;
135735 assert( pOrigLhs->a[iField].pExpr!=0 );
135736 pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
135737 pOrigLhs->a[iField].pExpr = 0;
@@ -135619,11 +136419,11 @@
136419 IdxExprTrans *pX = p->u.pIdxTrans;
136420 if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
136421 pExpr->op = TK_COLUMN;
136422 pExpr->iTable = pX->iIdxCur;
136423 pExpr->iColumn = pX->iIdxCol;
136424 pExpr->y.pTab = 0;
136425 return WRC_Prune;
136426 }else{
136427 return WRC_Continue;
136428 }
136429 }
@@ -137019,11 +137819,11 @@
137819 || zNew[0]=='-'
137820 || (zNew[0]+1=='0' && iTo==1)
137821 ){
137822 if( pLeft->op!=TK_COLUMN
137823 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
137824 || IsVirtual(pLeft->y.pTab) /* Value might be numeric */
137825 ){
137826 sqlite3ExprDelete(db, pPrefix);
137827 sqlite3ValueFree(pVal);
137828 return 0;
137829 }
@@ -137120,11 +137920,11 @@
137920 **
137921 ** vtab_column MATCH expression
137922 ** MATCH(expression,vtab_column)
137923 */
137924 pCol = pList->a[1].pExpr;
137925 if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
137926 for(i=0; i<ArraySize(aOp); i++){
137927 if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
137928 *peOp2 = aOp[i].eOp2;
137929 *ppRight = pList->a[0].pExpr;
137930 *ppLeft = pCol;
@@ -137142,16 +137942,16 @@
137942 ** Historically, xFindFunction expected to see lower-case function
137943 ** names. But for this use case, xFindFunction is expected to deal
137944 ** with function names in an arbitrary case.
137945 */
137946 pCol = pList->a[0].pExpr;
137947 if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
137948 sqlite3_vtab *pVtab;
137949 sqlite3_module *pMod;
137950 void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);
137951 void *pNotUsed;
137952 pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab;
137953 assert( pVtab!=0 );
137954 assert( pVtab->pModule!=0 );
137955 pMod = (sqlite3_module *)pVtab->pModule;
137956 if( pMod->xFindFunction!=0 ){
137957 i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
@@ -137165,14 +137965,14 @@
137965 }
137966 }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){
137967 int res = 0;
137968 Expr *pLeft = pExpr->pLeft;
137969 Expr *pRight = pExpr->pRight;
137970 if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->y.pTab) ){
137971 res++;
137972 }
137973 if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->y.pTab) ){
137974 res++;
137975 SWAP(Expr*, pLeft, pRight);
137976 }
137977 *ppLeft = pLeft;
137978 *ppRight = pRight;
@@ -138120,10 +138920,11 @@
138920 ** Note that the virtual term must be tagged with TERM_VNULL.
138921 */
138922 if( pExpr->op==TK_NOTNULL
138923 && pExpr->pLeft->op==TK_COLUMN
138924 && pExpr->pLeft->iColumn>=0
138925 && !ExprHasProperty(pExpr, EP_FromJoin)
138926 && OptimizationEnabled(db, SQLITE_Stat34)
138927 ){
138928 Expr *pNewExpr;
138929 Expr *pLeft = pExpr->pLeft;
138930 int idxNew;
@@ -138311,10 +139112,11 @@
139112 pTab = pItem->pTab;
139113 assert( pTab!=0 );
139114 pArgs = pItem->u1.pFuncArg;
139115 if( pArgs==0 ) return;
139116 for(j=k=0; j<pArgs->nExpr; j++){
139117 Expr *pRhs;
139118 while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}
139119 if( k>=pTab->nCol ){
139120 sqlite3ErrorMsg(pParse, "too many arguments on %s() - max %d",
139121 pTab->zName, j);
139122 return;
@@ -138321,13 +139123,14 @@
139123 }
139124 pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);
139125 if( pColRef==0 ) return;
139126 pColRef->iTable = pItem->iCursor;
139127 pColRef->iColumn = k++;
139128 pColRef->y.pTab = pTab;
139129 pRhs = sqlite3PExpr(pParse, TK_UPLUS,
139130 sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
139131 pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
139132 whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);
139133 }
139134 }
139135
139136 /************** End of whereexpr.c *******************************************/
@@ -139186,11 +139989,10 @@
139989 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
139990 testcase( pParse->db->mallocFailed );
139991 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
139992 pTabItem->regResult, 1);
139993 sqlite3VdbeGoto(v, addrTop);
 
139994 }else{
139995 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
139996 }
139997 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
139998 sqlite3VdbeJumpHere(v, addrTop);
@@ -140457,10 +141259,18 @@
141259 static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
141260 WhereLoop **ppPrev, *p;
141261 WhereInfo *pWInfo = pBuilder->pWInfo;
141262 sqlite3 *db = pWInfo->pParse->db;
141263 int rc;
141264
141265 /* Stop the search once we hit the query planner search limit */
141266 if( pBuilder->iPlanLimit==0 ){
141267 WHERETRACE(0xffffffff,("=== query planner search limit reached ===\n"));
141268 if( pBuilder->pOrSet ) pBuilder->pOrSet->n = 0;
141269 return SQLITE_DONE;
141270 }
141271 pBuilder->iPlanLimit--;
141272
141273 /* If pBuilder->pOrSet is defined, then only keep track of the costs
141274 ** and prereqs.
141275 */
141276 if( pBuilder->pOrSet!=0 ){
@@ -141864,13 +142674,15 @@
142674 u8 priorJointype = 0;
142675
142676 /* Loop over the tables in the join, from left to right */
142677 pNew = pBuilder->pNew;
142678 whereLoopInit(pNew);
142679 pBuilder->iPlanLimit = SQLITE_QUERY_PLANNER_LIMIT;
142680 for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
142681 Bitmask mUnusable = 0;
142682 pNew->iTab = iTab;
142683 pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
142684 pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
142685 if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){
142686 /* This condition is true when pItem is the FROM clause term on the
142687 ** right-hand-side of a LEFT or CROSS JOIN. */
142688 mPrereq = mPrior;
@@ -141892,11 +142704,19 @@
142704 }
142705 if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){
142706 rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);
142707 }
142708 mPrior |= pNew->maskSelf;
142709 if( rc || db->mallocFailed ){
142710 if( rc==SQLITE_DONE ){
142711 /* We hit the query planner search limit set by iPlanLimit */
142712 sqlite3_log(SQLITE_WARNING, "abbreviated query algorithm search");
142713 rc = SQLITE_OK;
142714 }else{
142715 break;
142716 }
142717 }
142718 }
142719
142720 whereLoopClear(db, pNew);
142721 return rc;
142722 }
@@ -144274,16 +145094,16 @@
145094 }
145095
145096 switch( pExpr->op ){
145097
145098 case TK_FUNCTION:
145099 if( !ExprHasProperty(pExpr, EP_WinFunc) ){
145100 break;
145101 }else{
145102 Window *pWin;
145103 for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
145104 if( pExpr->y.pWin==pWin ){
145105 assert( pWin->pOwner==pExpr );
145106 return WRC_Prune;
145107 }
145108 }
145109 }
@@ -144396,11 +145216,11 @@
145216 ** are invoked in the correct order as described under "SELECT REWRITING"
145217 ** at the top of this file.
145218 */
145219 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
145220 int rc = SQLITE_OK;
145221 if( p->pWin && p->pPrior==0 ){
145222 Vdbe *v = sqlite3GetVdbe(pParse);
145223 sqlite3 *db = pParse->db;
145224 Select *pSub = 0; /* The subquery */
145225 SrcList *pSrc = p->pSrc;
145226 Expr *pWhere = p->pWhere;
@@ -144609,15 +145429,17 @@
145429 /*
145430 ** Attach window object pWin to expression p.
145431 */
145432 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
145433 if( p ){
145434 assert( p->op==TK_FUNCTION );
145435 /* This routine is only called for the parser. If pWin was not
145436 ** allocated due to an OOM, then the parser would fail before ever
145437 ** invoking this routine */
145438 if( ALWAYS(pWin) ){
145439 p->y.pWin = pWin;
145440 ExprSetProperty(p, EP_WinFunc);
145441 pWin->pOwner = p;
145442 if( p->flags & EP_Distinct ){
145443 sqlite3ErrorMsg(pParse,
145444 "DISTINCT is not supported for window functions");
145445 }
@@ -145776,11 +146598,11 @@
146598 ** third argument. Set the Window.pOwner field of the new object to
146599 ** pOwner.
146600 */
146601 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
146602 Window *pNew = 0;
146603 if( ALWAYS(p) ){
146604 pNew = sqlite3DbMallocZero(db, sizeof(Window));
146605 if( pNew ){
146606 pNew->zName = sqlite3DbStrDup(db, p->zName);
146607 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
146608 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
@@ -146029,17 +146851,14 @@
146851 p->flags = EP_Leaf;
146852 p->iAgg = -1;
146853 p->pLeft = p->pRight = 0;
146854 p->x.pList = 0;
146855 p->pAggInfo = 0;
146856 p->y.pTab = 0;
146857 p->op2 = 0;
146858 p->iTable = 0;
146859 p->iColumn = 0;
 
 
 
146860 p->u.zToken = (char*)&p[1];
146861 memcpy(p->u.zToken, t.z, t.n);
146862 p->u.zToken[t.n] = 0;
146863 if( sqlite3Isquote(p->u.zToken[0]) ){
146864 if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -146186,21 +147005,21 @@
147005 #define sqlite3ParserCTX_PDECL ,Parse *pParse
147006 #define sqlite3ParserCTX_PARAM ,pParse
147007 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
147008 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
147009 #define YYFALLBACK 1
147010 #define YYNSTATE 525
147011 #define YYNRULE 367
147012 #define YYNTOKEN 155
147013 #define YY_MAX_SHIFT 524
147014 #define YY_MIN_SHIFTREDUCE 760
147015 #define YY_MAX_SHIFTREDUCE 1126
147016 #define YY_ERROR_ACTION 1127
147017 #define YY_ACCEPT_ACTION 1128
147018 #define YY_NO_ACTION 1129
147019 #define YY_MIN_REDUCE 1130
147020 #define YY_MAX_REDUCE 1496
147021 /************* End control #defines *******************************************/
147022 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
147023
147024 /* Define the yytestcase() macro to be a no-op if is not already defined
147025 ** otherwise.
@@ -146265,211 +147084,211 @@
147084 ** yy_default[] Default action for each state.
147085 **
147086 *********** Begin parsing tables **********************************************/
147087 #define YY_ACTTAB_COUNT (2009)
147088 static const YYACTIONTYPE yy_action[] = {
147089 /* 0 */ 372, 105, 102, 197, 105, 102, 197, 519, 1128, 1,
147090 /* 10 */ 1, 524, 2, 1132, 519, 1196, 1175, 1460, 275, 374,
147091 /* 20 */ 127, 1393, 1201, 1201, 1196, 1170, 178, 1209, 64, 64,
147092 /* 30 */ 481, 891, 326, 432, 352, 37, 37, 812, 366, 892,
147093 /* 40 */ 513, 513, 513, 112, 113, 103, 1104, 1104, 957, 960,
147094 /* 50 */ 950, 950, 110, 110, 111, 111, 111, 111, 369, 252,
147095 /* 60 */ 252, 519, 252, 252, 501, 519, 313, 519, 463, 519,
147096 /* 70 */ 1083, 495, 516, 482, 6, 516, 813, 134, 502, 228,
147097 /* 80 */ 194, 432, 37, 37, 519, 208, 64, 64, 64, 64,
147098 /* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
147099 /* 100 */ 107, 106, 405, 258, 385, 13, 13, 402, 401, 432,
147100 /* 110 */ 252, 252, 374, 480, 409, 1108, 1083, 1084, 1085, 390,
147101 /* 120 */ 1110, 394, 501, 516, 501, 1427, 1423, 308, 1109, 311,
147102 /* 130 */ 1260, 500, 374, 503, 16, 16, 112, 113, 103, 1104,
147103 /* 140 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147104 /* 150 */ 111, 262, 1111, 499, 1111, 405, 112, 113, 103, 1104,
147105 /* 160 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147106 /* 170 */ 111, 129, 1429, 347, 1424, 343, 1063, 496, 1061, 263,
147107 /* 180 */ 73, 105, 102, 197, 998, 109, 109, 109, 109, 108,
147108 /* 190 */ 108, 107, 107, 107, 106, 405, 374, 111, 111, 111,
147109 /* 200 */ 111, 104, 496, 89, 1436, 109, 109, 109, 109, 108,
147110 /* 210 */ 108, 107, 107, 107, 106, 405, 111, 111, 111, 111,
147111 /* 220 */ 112, 113, 103, 1104, 1104, 957, 960, 950, 950, 110,
147112 /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
147113 /* 240 */ 108, 107, 107, 107, 106, 405, 114, 108, 108, 107,
147114 /* 250 */ 107, 107, 106, 405, 109, 109, 109, 109, 108, 108,
147115 /* 260 */ 107, 107, 107, 106, 405, 152, 403, 403, 403, 109,
147116 /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147117 /* 280 */ 178, 497, 1416, 438, 1041, 1490, 1083, 519, 1490, 374,
147118 /* 290 */ 425, 301, 361, 416, 74, 1083, 109, 109, 109, 109,
147119 /* 300 */ 108, 108, 107, 107, 107, 106, 405, 1417, 37, 37,
147120 /* 310 */ 1435, 274, 510, 112, 113, 103, 1104, 1104, 957, 960,
147121 /* 320 */ 950, 950, 110, 110, 111, 111, 111, 111, 1440, 524,
147122 /* 330 */ 2, 1132, 1083, 1084, 1085, 434, 275, 1083, 127, 370,
147123 /* 340 */ 937, 1083, 1084, 1085, 220, 1209, 917, 462, 459, 458,
147124 /* 350 */ 396, 167, 519, 1039, 152, 449, 928, 457, 152, 878,
147125 /* 360 */ 927, 293, 109, 109, 109, 109, 108, 108, 107, 107,
147126 /* 370 */ 107, 106, 405, 13, 13, 261, 857, 252, 252, 227,
147127 /* 380 */ 106, 405, 374, 1083, 1084, 1085, 315, 392, 1083, 300,
147128 /* 390 */ 516, 927, 927, 929, 231, 327, 1259, 1392, 1427, 494,
147129 /* 400 */ 274, 510, 12, 208, 274, 510, 112, 113, 103, 1104,
147130 /* 410 */ 1104, 957, 960, 950, 950, 110, 110, 111, 111, 111,
147131 /* 420 */ 111, 1444, 290, 1132, 292, 1083, 1101, 247, 275, 1102,
147132 /* 430 */ 127, 391, 409, 393, 1083, 1084, 1085, 1209, 159, 238,
147133 /* 440 */ 255, 325, 465, 320, 464, 225, 794, 105, 102, 197,
147134 /* 450 */ 517, 318, 846, 846, 449, 109, 109, 109, 109, 108,
147135 /* 460 */ 108, 107, 107, 107, 106, 405, 519, 518, 519, 252,
147136 /* 470 */ 252, 1083, 1084, 1085, 439, 374, 1102, 937, 1464, 798,
147137 /* 480 */ 274, 510, 516, 105, 102, 197, 340, 63, 63, 64,
147138 /* 490 */ 64, 27, 794, 928, 291, 208, 1358, 927, 519, 112,
147139 /* 500 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147140 /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 405, 49,
147141 /* 520 */ 49, 519, 28, 1083, 409, 501, 425, 301, 927, 927,
147142 /* 530 */ 929, 186, 472, 1083, 471, 1003, 1003, 446, 519, 1083,
147143 /* 540 */ 338, 519, 45, 45, 1087, 346, 173, 168, 109, 109,
147144 /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 13,
147145 /* 560 */ 13, 205, 13, 13, 252, 252, 1199, 1199, 374, 1083,
147146 /* 570 */ 1084, 1085, 791, 265, 5, 363, 498, 516, 473, 1083,
147147 /* 580 */ 1084, 1085, 402, 401, 1083, 1083, 1084, 1085, 3, 282,
147148 /* 590 */ 1083, 1087, 112, 113, 103, 1104, 1104, 957, 960, 950,
147149 /* 600 */ 950, 110, 110, 111, 111, 111, 111, 252, 252, 1019,
147150 /* 610 */ 220, 1083, 877, 462, 459, 458, 947, 947, 958, 961,
147151 /* 620 */ 516, 252, 252, 457, 1020, 1083, 449, 1111, 1213, 1111,
147152 /* 630 */ 1083, 1084, 1085, 519, 516, 430, 1083, 1084, 1085, 1021,
147153 /* 640 */ 516, 109, 109, 109, 109, 108, 108, 107, 107, 107,
147154 /* 650 */ 106, 405, 1056, 519, 50, 50, 519, 1083, 1084, 1085,
147155 /* 660 */ 832, 374, 1055, 383, 415, 1068, 1362, 207, 412, 777,
147156 /* 670 */ 833, 1083, 1084, 1085, 64, 64, 326, 64, 64, 1306,
147157 /* 680 */ 951, 415, 414, 1362, 1364, 112, 113, 103, 1104, 1104,
147158 /* 690 */ 957, 960, 950, 950, 110, 110, 111, 111, 111, 111,
147159 /* 700 */ 298, 486, 519, 1041, 1491, 519, 438, 1491, 358, 1124,
147160 /* 710 */ 487, 1000, 917, 489, 470, 1000, 132, 178, 33, 454,
147161 /* 720 */ 1207, 136, 410, 64, 64, 483, 64, 64, 423, 373,
147162 /* 730 */ 283, 1150, 252, 252, 109, 109, 109, 109, 108, 108,
147163 /* 740 */ 107, 107, 107, 106, 405, 516, 224, 444, 415, 266,
147164 /* 750 */ 1362, 266, 252, 252, 374, 300, 420, 286, 938, 400,
147165 /* 760 */ 980, 474, 404, 252, 252, 516, 9, 477, 231, 504,
147166 /* 770 */ 358, 1040, 1039, 1492, 359, 378, 516, 1125, 112, 113,
147167 /* 780 */ 103, 1104, 1104, 957, 960, 950, 950, 110, 110, 111,
147168 /* 790 */ 111, 111, 111, 252, 252, 1019, 519, 1351, 299, 252,
147169 /* 800 */ 252, 252, 252, 1102, 379, 249, 516, 449, 876, 326,
147170 /* 810 */ 1020, 484, 516, 195, 516, 438, 273, 15, 15, 519,
147171 /* 820 */ 318, 519, 95, 519, 93, 1021, 371, 109, 109, 109,
147172 /* 830 */ 109, 108, 108, 107, 107, 107, 106, 405, 519, 1125,
147173 /* 840 */ 39, 39, 51, 51, 52, 52, 507, 374, 519, 1208,
147174 /* 850 */ 1102, 922, 443, 345, 133, 440, 223, 222, 221, 53,
147175 /* 860 */ 53, 326, 1404, 765, 766, 767, 519, 374, 88, 54,
147176 /* 870 */ 54, 112, 113, 103, 1104, 1104, 957, 960, 950, 950,
147177 /* 880 */ 110, 110, 111, 111, 111, 111, 411, 55, 55, 196,
147178 /* 890 */ 519, 112, 113, 103, 1104, 1104, 957, 960, 950, 950,
147179 /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1153, 380,
147180 /* 910 */ 519, 40, 40, 519, 876, 519, 997, 519, 997, 116,
147181 /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
147182 /* 930 */ 405, 41, 41, 519, 43, 43, 44, 44, 56, 56,
147183 /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
147184 /* 950 */ 405, 519, 383, 519, 57, 57, 519, 803, 519, 383,
147185 /* 960 */ 519, 449, 200, 519, 327, 519, 1401, 519, 1463, 519,
147186 /* 970 */ 1291, 821, 58, 58, 14, 14, 519, 59, 59, 118,
147187 /* 980 */ 118, 60, 60, 519, 46, 46, 61, 61, 62, 62,
147188 /* 990 */ 47, 47, 519, 190, 189, 91, 519, 140, 140, 519,
147189 /* 1000 */ 398, 519, 277, 1204, 141, 141, 519, 1119, 519, 996,
147190 /* 1010 */ 519, 996, 519, 69, 69, 374, 278, 48, 48, 259,
147191 /* 1020 */ 65, 65, 119, 119, 246, 246, 260, 66, 66, 120,
147192 /* 1030 */ 120, 121, 121, 117, 117, 374, 519, 516, 387, 112,
147193 /* 1040 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147194 /* 1050 */ 111, 111, 111, 111, 519, 876, 519, 139, 139, 112,
147195 /* 1060 */ 113, 103, 1104, 1104, 957, 960, 950, 950, 110, 110,
147196 /* 1070 */ 111, 111, 111, 111, 1291, 138, 138, 125, 125, 519,
147197 /* 1080 */ 12, 519, 281, 1291, 519, 449, 131, 1291, 109, 109,
147198 /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 519,
147199 /* 1100 */ 124, 124, 122, 122, 519, 123, 123, 519, 109, 109,
147200 /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 405, 519,
147201 /* 1120 */ 68, 68, 467, 787, 519, 70, 70, 306, 67, 67,
147202 /* 1130 */ 1036, 253, 253, 360, 1291, 191, 196, 1437, 469, 1305,
147203 /* 1140 */ 38, 38, 388, 94, 516, 42, 42, 177, 852, 274,
147204 /* 1150 */ 510, 389, 424, 851, 1360, 445, 512, 380, 381, 153,
147205 /* 1160 */ 427, 876, 436, 374, 224, 251, 194, 891, 182, 297,
147206 /* 1170 */ 787, 852, 88, 254, 470, 892, 851, 919, 811, 810,
147207 /* 1180 */ 230, 1245, 914, 374, 17, 417, 801, 112, 113, 103,
147208 /* 1190 */ 1104, 1104, 957, 960, 950, 950, 110, 110, 111, 111,
147209 /* 1200 */ 111, 111, 399, 818, 819, 1179, 987, 112, 101, 103,
147210 /* 1210 */ 1104, 1104, 957, 960, 950, 950, 110, 110, 111, 111,
147211 /* 1220 */ 111, 111, 379, 426, 431, 433, 302, 230, 230, 88,
147212 /* 1230 */ 1244, 455, 316, 801, 226, 88, 109, 109, 109, 109,
147213 /* 1240 */ 108, 108, 107, 107, 107, 106, 405, 86, 437, 983,
147214 /* 1250 */ 931, 885, 226, 987, 230, 419, 109, 109, 109, 109,
147215 /* 1260 */ 108, 108, 107, 107, 107, 106, 405, 324, 849, 785,
147216 /* 1270 */ 850, 100, 130, 100, 1407, 294, 374, 323, 1381, 1380,
147217 /* 1280 */ 441, 1453, 303, 1241, 307, 310, 312, 314, 1192, 1178,
147218 /* 1290 */ 1177, 1176, 319, 328, 329, 1232, 374, 931, 1253, 271,
147219 /* 1300 */ 1290, 113, 103, 1104, 1104, 957, 960, 950, 950, 110,
147220 /* 1310 */ 110, 111, 111, 111, 111, 1228, 1239, 506, 505, 1296,
147221 /* 1320 */ 1225, 1159, 103, 1104, 1104, 957, 960, 950, 950, 110,
147222 /* 1330 */ 110, 111, 111, 111, 111, 1152, 1141, 1140, 1142, 1447,
147223 /* 1340 */ 450, 244, 184, 98, 511, 188, 4, 357, 331, 109,
147224 /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147225 /* 1360 */ 514, 333, 335, 199, 418, 460, 296, 289, 322, 109,
147226 /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 405,
147227 /* 1380 */ 11, 285, 1283, 406, 365, 192, 1175, 1355, 435, 509,
147228 /* 1390 */ 350, 1354, 337, 98, 511, 508, 4, 187, 1450, 1119,
147229 /* 1400 */ 233, 1400, 155, 1398, 1116, 152, 72, 75, 382, 429,
147230 /* 1410 */ 514, 165, 115, 499, 937, 1280, 1275, 30, 149, 157,
147231 /* 1420 */ 96, 96, 8, 284, 86, 288, 287, 97, 1272, 406,
147232 /* 1430 */ 521, 520, 421, 406, 927, 422, 453, 210, 160, 161,
147233 /* 1440 */ 162, 163, 362, 428, 1286, 508, 442, 214, 80, 364,
147234 /* 1450 */ 31, 274, 510, 169, 1349, 448, 492, 245, 1369, 216,
147235 /* 1460 */ 174, 491, 451, 309, 937, 927, 927, 929, 930, 24,
147236 /* 1470 */ 96, 96, 305, 217, 367, 466, 1143, 97, 218, 406,
147237 /* 1480 */ 521, 520, 1195, 1194, 927, 1193, 395, 803, 98, 511,
147238 /* 1490 */ 368, 4, 1186, 1167, 1185, 269, 1166, 321, 1165, 1462,
147239 /* 1500 */ 397, 270, 485, 476, 479, 514, 85, 232, 1236, 98,
147240 /* 1510 */ 511, 330, 4, 490, 340, 927, 927, 929, 930, 24,
147241 /* 1520 */ 1439, 1072, 408, 1237, 339, 256, 514, 1418, 406, 10,
147242 /* 1530 */ 356, 356, 355, 241, 353, 181, 92, 774, 1235, 1218,
147243 /* 1540 */ 508, 342, 87, 332, 334, 1217, 1234, 336, 344, 406,
147244 /* 1550 */ 201, 492, 280, 183, 488, 348, 493, 349, 239, 937,
147245 /* 1560 */ 279, 508, 1335, 29, 1149, 96, 96, 522, 1078, 272,
147246 /* 1570 */ 243, 240, 97, 242, 406, 521, 520, 523, 1138, 927,
147247 /* 1580 */ 937, 142, 1133, 1385, 143, 1386, 96, 96, 856, 376,
147248 /* 1590 */ 203, 761, 154, 97, 1384, 406, 521, 520, 204, 377,
147249 /* 1600 */ 927, 146, 144, 1383, 407, 1163, 1162, 128, 202, 71,
147250 /* 1610 */ 927, 927, 929, 930, 24, 267, 1160, 185, 276, 198,
147251 /* 1620 */ 257, 98, 511, 126, 4, 911, 995, 156, 993, 145,
147252 /* 1630 */ 206, 927, 927, 929, 930, 24, 158, 835, 514, 209,
147253 /* 1640 */ 295, 1009, 375, 164, 915, 147, 384, 274, 510, 386,
147254 /* 1650 */ 166, 76, 77, 78, 148, 1012, 211, 212, 1008, 137,
147255 /* 1660 */ 18, 406, 79, 213, 304, 1001, 1113, 230, 447, 215,
147256 /* 1670 */ 413, 171, 32, 508, 323, 776, 170, 452, 172, 219,
147257 /* 1680 */ 456, 81, 19, 20, 492, 317, 461, 82, 268, 491,
147258 /* 1690 */ 150, 814, 937, 179, 83, 468, 151, 180, 96, 96,
147259 /* 1700 */ 963, 84, 1044, 34, 475, 97, 1045, 406, 521, 520,
147260 /* 1710 */ 1072, 408, 927, 35, 256, 884, 478, 248, 193, 356,
147261 /* 1720 */ 356, 355, 241, 353, 250, 175, 774, 229, 879, 21,
147262 /* 1730 */ 100, 98, 511, 22, 4, 1058, 1049, 176, 341, 201,
147263 /* 1740 */ 7, 280, 1062, 927, 927, 929, 930, 24, 514, 279,
147264 /* 1750 */ 88, 1060, 23, 978, 964, 962, 966, 1018, 1017, 967,
147265 /* 1760 */ 235, 90, 511, 234, 4, 25, 36, 515, 932, 786,
147266 /* 1770 */ 845, 406, 99, 26, 236, 237, 351, 1455, 514, 203,
147267 /* 1780 */ 354, 1454, 1073, 508, 1129, 1129, 1129, 204, 1129, 1129,
147268 /* 1790 */ 146, 1129, 1129, 1129, 1129, 1129, 1129, 202, 1129, 1129,
147269 /* 1800 */ 1129, 406, 937, 1129, 1129, 1129, 1129, 1129, 96, 96,
147270 /* 1810 */ 1129, 1129, 1129, 508, 1129, 97, 1129, 406, 521, 520,
147271 /* 1820 */ 1129, 1129, 927, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147272 /* 1830 */ 1129, 375, 937, 1129, 1129, 1129, 274, 510, 96, 96,
147273 /* 1840 */ 1129, 1129, 1129, 1129, 1129, 97, 1129, 406, 521, 520,
147274 /* 1850 */ 1129, 1129, 927, 927, 927, 929, 930, 24, 1129, 413,
147275 /* 1860 */ 1129, 1129, 1129, 256, 1129, 1129, 1129, 1129, 356, 356,
147276 /* 1870 */ 355, 241, 353, 1129, 1129, 774, 1129, 1129, 1129, 1129,
147277 /* 1880 */ 1129, 1129, 1129, 927, 927, 929, 930, 24, 201, 1129,
147278 /* 1890 */ 280, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 279, 1129,
147279 /* 1900 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147280 /* 1910 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147281 /* 1920 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 203, 1129,
147282 /* 1930 */ 1129, 1129, 1129, 1129, 1129, 1129, 204, 1129, 1129, 146,
147283 /* 1940 */ 1129, 1129, 1129, 1129, 1129, 1129, 202, 1129, 1129, 1129,
147284 /* 1950 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147285 /* 1960 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147286 /* 1970 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147287 /* 1980 */ 375, 1129, 1129, 1129, 1129, 274, 510, 1129, 1129, 1129,
147288 /* 1990 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
147289 /* 2000 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 413,
147290 };
147291 static const YYCODETYPE yy_lookahead[] = {
147292 /* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
147293 /* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
147294 /* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -146609,48 +147428,48 @@
147428 /* 1360 */ 36, 222, 222, 260, 226, 188, 256, 226, 187, 92,
147429 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
147430 /* 1380 */ 210, 213, 213, 59, 213, 196, 192, 187, 256, 244,
147431 /* 1390 */ 212, 187, 226, 19, 20, 71, 22, 210, 166, 60,
147432 /* 1400 */ 130, 170, 260, 170, 38, 81, 257, 257, 170, 104,
147433 /* 1410 */ 36, 22, 137, 134, 90, 236, 217, 235, 43, 201,
147434 /* 1420 */ 96, 97, 48, 216, 138, 213, 216, 103, 217, 105,
147435 /* 1430 */ 106, 107, 18, 59, 110, 170, 18, 169, 204, 204,
147436 /* 1440 */ 204, 204, 213, 213, 201, 71, 170, 169, 146, 236,
147437 /* 1450 */ 235, 127, 128, 201, 213, 62, 82, 170, 253, 169,
147438 /* 1460 */ 22, 87, 189, 170, 90, 141, 142, 143, 144, 145,
147439 /* 1470 */ 96, 97, 252, 169, 189, 104, 170, 103, 169, 105,
147440 /* 1480 */ 106, 107, 186, 186, 110, 186, 64, 115, 19, 20,
147441 /* 1490 */ 189, 22, 194, 186, 194, 246, 188, 186, 186, 186,
147442 /* 1500 */ 102, 246, 133, 189, 189, 36, 104, 170, 228, 19,
147443 /* 1510 */ 20, 227, 22, 84, 22, 141, 142, 143, 144, 145,
147444 /* 1520 */ 0, 1, 2, 228, 271, 5, 36, 269, 59, 22,
147445 /* 1530 */ 10, 11, 12, 13, 14, 216, 146, 17, 228, 217,
147446 /* 1540 */ 71, 216, 136, 227, 227, 217, 228, 227, 170, 59,
147447 /* 1550 */ 30, 82, 32, 215, 135, 214, 87, 213, 25, 90,
147448 /* 1560 */ 40, 71, 241, 26, 173, 96, 97, 172, 13, 243,
147449 /* 1570 */ 6, 164, 103, 164, 105, 106, 107, 162, 162, 110,
147450 /* 1580 */ 90, 176, 162, 182, 176, 182, 96, 97, 98, 266,
147451 /* 1590 */ 70, 4, 263, 103, 182, 105, 106, 107, 78, 266,
147452 /* 1600 */ 110, 81, 176, 182, 3, 182, 182, 190, 88, 182,
147453 /* 1610 */ 141, 142, 143, 144, 145, 190, 182, 22, 151, 15,
147454 /* 1620 */ 89, 19, 20, 16, 22, 128, 23, 139, 23, 119,
147455 /* 1630 */ 24, 141, 142, 143, 144, 145, 131, 20, 36, 133,
147456 /* 1640 */ 16, 1, 122, 131, 140, 119, 61, 127, 128, 37,
147457 /* 1650 */ 139, 53, 53, 53, 119, 105, 34, 130, 1, 5,
147458 /* 1660 */ 22, 59, 53, 104, 149, 68, 75, 26, 41, 130,
147459 /* 1670 */ 150, 104, 24, 71, 120, 20, 68, 19, 22, 114,
147460 /* 1680 */ 67, 22, 22, 22, 82, 23, 67, 22, 67, 87,
147461 /* 1690 */ 37, 28, 90, 23, 138, 22, 153, 23, 96, 97,
147462 /* 1700 */ 23, 26, 23, 22, 24, 103, 23, 105, 106, 107,
147463 /* 1710 */ 1, 2, 110, 22, 5, 105, 24, 23, 130, 10,
147464 /* 1720 */ 11, 12, 13, 14, 23, 22, 17, 34, 132, 34,
147465 /* 1730 */ 26, 19, 20, 34, 22, 85, 23, 26, 24, 30,
147466 /* 1740 */ 44, 32, 75, 141, 142, 143, 144, 145, 36, 40,
147467 /* 1750 */ 26, 83, 34, 23, 23, 23, 23, 23, 23, 11,
147468 /* 1760 */ 22, 19, 20, 26, 22, 22, 22, 26, 23, 23,
147469 /* 1770 */ 124, 59, 22, 22, 130, 130, 23, 130, 36, 70,
147470 /* 1780 */ 15, 130, 1, 71, 277, 277, 277, 78, 277, 277,
147471 /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
147472 /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
147473 /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
147474 /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
147475 /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -146671,11 +147490,11 @@
147490 /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
147491 /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
147492 /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
147493 /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
147494 };
147495 #define YY_SHIFT_COUNT (524)
147496 #define YY_SHIFT_MIN (0)
147497 #define YY_SHIFT_MAX (1858)
147498 static const unsigned short int yy_shift_ofst[] = {
147499 /* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
147500 /* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -146703,39 +147522,39 @@
147522 /* 230 */ 531, 531, 744, 531, 531, 783, 531, 531, 531, 531,
147523 /* 240 */ 531, 531, 531, 531, 419, 682, 327, 370, 370, 370,
147524 /* 250 */ 370, 1029, 327, 327, 1024, 897, 856, 947, 1109, 706,
147525 /* 260 */ 706, 1143, 1109, 1109, 1143, 842, 945, 1118, 1136, 1136,
147526 /* 270 */ 1136, 706, 676, 400, 1047, 694, 1339, 1270, 1270, 1366,
147527 /* 280 */ 1366, 1270, 1305, 1389, 1275, 1279, 1375, 1275, 1279, 1286,
147528 /* 290 */ 1414, 1414, 1414, 1414, 1270, 1418, 1286, 1286, 1305, 1389,
147529 /* 300 */ 1375, 1375, 1286, 1270, 1418, 1302, 1393, 1270, 1418, 1438,
147530 /* 310 */ 1270, 1418, 1270, 1418, 1438, 1371, 1371, 1371, 1422, 1438,
147531 /* 320 */ 1371, 1372, 1371, 1422, 1371, 1371, 1438, 1398, 1398, 1438,
147532 /* 330 */ 1369, 1402, 1369, 1402, 1369, 1402, 1369, 1402, 1270, 1279,
147533 /* 340 */ 1429, 1492, 1275, 1279, 1507, 1270, 1390, 1275, 1406, 1419,
147534 /* 350 */ 1286, 1533, 1537, 1555, 1555, 1564, 1564, 1564, 2009, 2009,
147535 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
147536 /* 370 */ 2009, 2009, 2009, 2009, 570, 345, 686, 748, 50, 740,
147537 /* 380 */ 1064, 1107, 469, 537, 1042, 1146, 1162, 1154, 1201, 1202,
147538 /* 390 */ 1203, 1208, 1209, 1127, 1069, 1196, 1157, 1147, 1226, 1228,
147539 /* 400 */ 1245, 775, 868, 1246, 1247, 1191, 1151, 1587, 1601, 1595,
147540 /* 410 */ 1467, 1604, 1531, 1607, 1603, 1605, 1497, 1488, 1510, 1606,
147541 /* 420 */ 1505, 1617, 1506, 1624, 1640, 1512, 1504, 1526, 1585, 1612,
147542 /* 430 */ 1511, 1598, 1599, 1600, 1609, 1535, 1550, 1622, 1527, 1657,
147543 /* 440 */ 1654, 1638, 1559, 1515, 1597, 1641, 1608, 1591, 1627, 1539,
147544 /* 450 */ 1567, 1648, 1655, 1658, 1554, 1565, 1656, 1613, 1659, 1660,
147545 /* 460 */ 1662, 1661, 1619, 1663, 1665, 1621, 1653, 1670, 1556, 1673,
147546 /* 470 */ 1543, 1674, 1677, 1675, 1679, 1681, 1680, 1683, 1691, 1692,
147547 /* 480 */ 1588, 1694, 1701, 1610, 1693, 1703, 1596, 1704, 1695, 1704,
147548 /* 490 */ 1699, 1650, 1667, 1668, 1696, 1713, 1714, 1711, 1724, 1718,
147549 /* 500 */ 1730, 1704, 1731, 1732, 1733, 1734, 1737, 1735, 1738, 1748,
147550 /* 510 */ 1743, 1744, 1745, 1746, 1750, 1751, 1741, 1646, 1644, 1645,
147551 /* 520 */ 1647, 1651, 1753, 1765, 1781,
147552 };
147553 #define YY_REDUCE_COUNT (373)
147554 #define YY_REDUCE_MIN (-237)
147555 #define YY_REDUCE_MAX (1434)
147556 static const short yy_reduce_ofst[] = {
147557 /* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
147558 /* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
147559 /* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
147560 /* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -146761,74 +147580,75 @@
147580 /* 230 */ 1137, 1152, 1077, 1153, 1155, 1114, 1156, 304, 1158, 1172,
147581 /* 240 */ 1173, 1174, 1175, 1176, 1089, 1091, 1133, 1098, 1126, 1139,
147582 /* 250 */ 1140, 1070, 1133, 1133, 1170, 1163, 1186, 1103, 1168, 1138,
147583 /* 260 */ 1141, 1110, 1169, 1171, 1132, 1177, 1189, 1194, 1181, 1200,
147584 /* 270 */ 1204, 1166, 1145, 1178, 1187, 1232, 1142, 1231, 1233, 1149,
147585 /* 280 */ 1150, 1238, 1179, 1182, 1199, 1207, 1218, 1211, 1210, 1212,
147586 /* 290 */ 1234, 1235, 1236, 1237, 1265, 1268, 1229, 1230, 1213, 1215,
147587 /* 300 */ 1243, 1252, 1241, 1276, 1278, 1205, 1220, 1287, 1290, 1273,
147588 /* 310 */ 1293, 1304, 1306, 1309, 1285, 1296, 1297, 1299, 1298, 1301,
147589 /* 320 */ 1307, 1308, 1311, 1300, 1312, 1313, 1314, 1249, 1255, 1315,
147590 /* 330 */ 1280, 1284, 1295, 1316, 1310, 1317, 1318, 1320, 1337, 1319,
147591 /* 340 */ 1253, 1258, 1322, 1325, 1321, 1378, 1326, 1328, 1338, 1341,
147592 /* 350 */ 1344, 1391, 1395, 1407, 1409, 1415, 1416, 1420, 1323, 1333,
147593 /* 360 */ 1329, 1405, 1401, 1403, 1412, 1421, 1408, 1417, 1425, 1423,
147594 /* 370 */ 1424, 1427, 1434, 1426,
147595 };
147596 static const YYACTIONTYPE yy_default[] = {
147597 /* 0 */ 1496, 1496, 1496, 1344, 1127, 1233, 1127, 1127, 1127, 1344,
147598 /* 10 */ 1344, 1344, 1127, 1263, 1263, 1395, 1158, 1127, 1127, 1127,
147599 /* 20 */ 1127, 1127, 1127, 1127, 1343, 1127, 1127, 1127, 1127, 1127,
147600 /* 30 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1269, 1127,
147601 /* 40 */ 1127, 1127, 1127, 1127, 1345, 1346, 1127, 1127, 1127, 1394,
147602 /* 50 */ 1396, 1279, 1278, 1277, 1276, 1377, 1250, 1274, 1267, 1271,
147603 /* 60 */ 1339, 1340, 1338, 1342, 1346, 1345, 1127, 1270, 1310, 1324,
147604 /* 70 */ 1309, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147605 /* 80 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147606 /* 90 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147607 /* 100 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147608 /* 110 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1318, 1323, 1329,
147609 /* 120 */ 1322, 1319, 1312, 1311, 1313, 1314, 1127, 1148, 1197, 1127,
147610 /* 130 */ 1127, 1127, 1127, 1413, 1412, 1127, 1127, 1158, 1315, 1316,
147611 /* 140 */ 1326, 1325, 1402, 1452, 1451, 1127, 1127, 1127, 1127, 1127,
147612 /* 150 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147613 /* 160 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147614 /* 170 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1158, 1154, 1304,
147615 /* 180 */ 1303, 1422, 1154, 1257, 1127, 1408, 1233, 1224, 1127, 1127,
147616 /* 190 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147617 /* 200 */ 1127, 1399, 1397, 1127, 1359, 1127, 1127, 1127, 1127, 1127,
147618 /* 210 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147619 /* 220 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147620 /* 230 */ 1127, 1127, 1229, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147621 /* 240 */ 1127, 1127, 1127, 1446, 1127, 1372, 1211, 1229, 1229, 1229,
147622 /* 250 */ 1229, 1231, 1212, 1210, 1223, 1158, 1134, 1488, 1273, 1252,
147623 /* 260 */ 1252, 1485, 1273, 1273, 1485, 1172, 1466, 1169, 1263, 1263,
147624 /* 270 */ 1263, 1252, 1341, 1230, 1223, 1127, 1488, 1238, 1238, 1487,
147625 /* 280 */ 1487, 1238, 1282, 1288, 1268, 1257, 1200, 1268, 1257, 1273,
147626 /* 290 */ 1206, 1206, 1206, 1206, 1238, 1145, 1273, 1273, 1282, 1288,
147627 /* 300 */ 1200, 1200, 1273, 1238, 1145, 1376, 1482, 1238, 1145, 1352,
147628 /* 310 */ 1238, 1145, 1238, 1145, 1352, 1198, 1198, 1198, 1187, 1352,
147629 /* 320 */ 1198, 1172, 1198, 1187, 1198, 1198, 1352, 1356, 1356, 1352,
147630 /* 330 */ 1256, 1251, 1256, 1251, 1256, 1251, 1256, 1251, 1238, 1257,
147631 /* 340 */ 1421, 1127, 1268, 1257, 1347, 1238, 1127, 1268, 1266, 1264,
147632 /* 350 */ 1273, 1151, 1190, 1449, 1449, 1445, 1445, 1445, 1493, 1493,
147633 /* 360 */ 1408, 1461, 1158, 1158, 1158, 1158, 1461, 1174, 1174, 1158,
147634 /* 370 */ 1158, 1158, 1158, 1461, 1127, 1127, 1127, 1127, 1127, 1127,
147635 /* 380 */ 1456, 1127, 1361, 1242, 1127, 1127, 1127, 1127, 1127, 1127,
147636 /* 390 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147637 /* 400 */ 1127, 1127, 1127, 1127, 1127, 1127, 1293, 1127, 1130, 1405,
147638 /* 410 */ 1127, 1127, 1403, 1127, 1127, 1127, 1127, 1127, 1127, 1243,
147639 /* 420 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147640 /* 430 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1484, 1127,
147641 /* 440 */ 1127, 1127, 1127, 1127, 1127, 1375, 1374, 1127, 1127, 1240,
147642 /* 450 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147643 /* 460 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147644 /* 470 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147645 /* 480 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1265, 1127, 1420,
147646 /* 490 */ 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1434, 1258, 1127,
147647 /* 500 */ 1127, 1475, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,
147648 /* 510 */ 1127, 1127, 1127, 1127, 1127, 1127, 1470, 1214, 1295, 1127,
147649 /* 520 */ 1294, 1298, 1127, 1139, 1127,
147650 };
147651 /********** End of lemon-generated parsing tables *****************************/
147652
147653 /* The next table maps tokens (terminal symbols) into fallback tokens.
147654 ** If a construct like the following:
@@ -147448,14 +148268,14 @@
148268 /* 137 */ "having_opt ::= HAVING expr",
148269 /* 138 */ "limit_opt ::=",
148270 /* 139 */ "limit_opt ::= LIMIT expr",
148271 /* 140 */ "limit_opt ::= LIMIT expr OFFSET expr",
148272 /* 141 */ "limit_opt ::= LIMIT expr COMMA expr",
148273 /* 142 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt",
148274 /* 143 */ "where_opt ::=",
148275 /* 144 */ "where_opt ::= WHERE expr",
148276 /* 145 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt",
148277 /* 146 */ "setlist ::= setlist COMMA nm EQ expr",
148278 /* 147 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
148279 /* 148 */ "setlist ::= nm EQ expr",
148280 /* 149 */ "setlist ::= LP idlist RP EQ expr",
148281 /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
@@ -148328,14 +149148,14 @@
149148 { 215, -2 }, /* (137) having_opt ::= HAVING expr */
149149 { 217, 0 }, /* (138) limit_opt ::= */
149150 { 217, -2 }, /* (139) limit_opt ::= LIMIT expr */
149151 { 217, -4 }, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
149152 { 217, -4 }, /* (141) limit_opt ::= LIMIT expr COMMA expr */
149153 { 160, -8 }, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt */
149154 { 213, 0 }, /* (143) where_opt ::= */
149155 { 213, -2 }, /* (144) where_opt ::= WHERE expr */
149156 { 160, -10 }, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt */
149157 { 233, -5 }, /* (146) setlist ::= setlist COMMA nm EQ expr */
149158 { 233, -7 }, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
149159 { 233, -3 }, /* (148) setlist ::= nm EQ expr */
149160 { 233, -5 }, /* (149) setlist ::= LP idlist RP EQ expr */
149161 { 160, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
@@ -149215,21 +150035,21 @@
150035 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy18,yymsp[0].minor.yy18);}
150036 break;
150037 case 141: /* limit_opt ::= LIMIT expr COMMA expr */
150038 {yymsp[-3].minor.yy18 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy18,yymsp[-2].minor.yy18);}
150039 break;
150040 case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt orderby_opt limit_opt */
 
 
 
 
 
 
150041 {
150042 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy135, &yymsp[-3].minor.yy0);
150043 sqlite3DeleteFrom(pParse,yymsp[-4].minor.yy135,yymsp[-2].minor.yy18,yymsp[-1].minor.yy420,yymsp[0].minor.yy18);
150044 }
150045 break;
150046 case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt orderby_opt limit_opt */
150047 {
150048 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy135, &yymsp[-5].minor.yy0);
150049 sqlite3ExprListCheckLength(pParse,yymsp[-3].minor.yy420,"set list");
150050 sqlite3Update(pParse,yymsp[-6].minor.yy135,yymsp[-3].minor.yy420,yymsp[-2].minor.yy18,yymsp[-7].minor.yy70,yymsp[-1].minor.yy420,yymsp[0].minor.yy18,0);
150051 }
150052 break;
150053 case 146: /* setlist ::= setlist COMMA nm EQ expr */
150054 {
150055 yymsp[-4].minor.yy420 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy420, yymsp[0].minor.yy18);
@@ -151197,10 +152017,77 @@
152017 while( IdChar(z[i]) ){ i++; }
152018 *tokenType = TK_ID;
152019 return i;
152020 }
152021
152022 #ifdef SQLITE_ENABLE_NORMALIZE
152023 /*
152024 ** Return the length (in bytes) of the token that begins at z[0].
152025 ** Store the token type in *tokenType before returning. If flags has
152026 ** SQLITE_TOKEN_NORMALIZE flag enabled, use the identifier token type
152027 ** for keywords. Add SQLITE_TOKEN_QUOTED to flags if the token was
152028 ** actually a quoted identifier. Add SQLITE_TOKEN_KEYWORD to flags
152029 ** if the token was recognized as a keyword; this is useful when the
152030 ** SQLITE_TOKEN_NORMALIZE flag is used, because it enables the caller
152031 ** to differentiate between a keyword being treated as an identifier
152032 ** (for normalization purposes) and an actual identifier.
152033 */
152034 SQLITE_PRIVATE int sqlite3GetTokenNormalized(
152035 const unsigned char *z,
152036 int *tokenType,
152037 int *flags
152038 ){
152039 int n;
152040 unsigned char iClass = aiClass[*z];
152041 if( iClass==CC_KYWD ){
152042 int i;
152043 for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}
152044 if( IdChar(z[i]) ){
152045 /* This token started out using characters that can appear in keywords,
152046 ** but z[i] is a character not allowed within keywords, so this must
152047 ** be an identifier instead */
152048 i++;
152049 while( IdChar(z[i]) ){ i++; }
152050 *tokenType = TK_ID;
152051 return i;
152052 }
152053 *tokenType = TK_ID;
152054 n = keywordCode((char*)z, i, tokenType);
152055 /* If the token is no longer considered to be an identifier, then it is a
152056 ** keyword of some kind. Make the token back into an identifier and then
152057 ** set the SQLITE_TOKEN_KEYWORD flag. Several non-identifier tokens are
152058 ** used verbatim, including IN, IS, NOT, and NULL. */
152059 switch( *tokenType ){
152060 case TK_ID: {
152061 /* do nothing, handled by caller */
152062 break;
152063 }
152064 case TK_IN:
152065 case TK_IS:
152066 case TK_NOT:
152067 case TK_NULL: {
152068 *flags |= SQLITE_TOKEN_KEYWORD;
152069 break;
152070 }
152071 default: {
152072 *tokenType = TK_ID;
152073 *flags |= SQLITE_TOKEN_KEYWORD;
152074 break;
152075 }
152076 }
152077 }else{
152078 n = sqlite3GetToken(z, tokenType);
152079 /* If the token is considered to be an identifier and the character class
152080 ** of the first character is a quote, set the SQLITE_TOKEN_QUOTED flag. */
152081 if( *tokenType==TK_ID && (iClass==CC_QUOTE || iClass==CC_QUOTE2) ){
152082 *flags |= SQLITE_TOKEN_QUOTED;
152083 }
152084 }
152085 return n;
152086 }
152087 #endif /* SQLITE_ENABLE_NORMALIZE */
152088
152089 /*
152090 ** Run the parser on the given SQL string. The parser structure is
152091 ** passed in. An SQLITE_ status code is returned. If an error occurs
152092 ** then an and attempt is made to write an error message into
152093 ** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
@@ -152594,10 +153481,11 @@
153481 { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
153482 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
153483 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
153484 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
153485 { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
153486 { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive },
153487 };
153488 unsigned int i;
153489 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
153490 for(i=0; i<ArraySize(aFlagOp); i++){
153491 if( aFlagOp[i].op==op ){
@@ -154820,10 +155708,13 @@
155708 #if defined(SQLITE_ENABLE_FTS3_TOKENIZER)
155709 | SQLITE_Fts3Tokenizer
155710 #endif
155711 #if defined(SQLITE_ENABLE_QPSG)
155712 | SQLITE_EnableQPSG
155713 #endif
155714 #if defined(SQLITE_DEFAULT_DEFENSIVE)
155715 | SQLITE_Defensive
155716 #endif
155717 ;
155718 sqlite3HashInit(&db->aCollSeq);
155719 #ifndef SQLITE_OMIT_VIRTUALTABLE
155720 sqlite3HashInit(&db->aModule);
@@ -159159,11 +160050,11 @@
160050 ){
160051 int rc = SQLITE_OK; /* Return code */
160052 const char *zCsr = zNode; /* Cursor to iterate through node */
160053 const char *zEnd = &zCsr[nNode];/* End of interior node buffer */
160054 char *zBuffer = 0; /* Buffer to load terms into */
160055 i64 nAlloc = 0; /* Size of allocated buffer */
160056 int isFirstTerm = 1; /* True when processing first term on page */
160057 sqlite3_int64 iChild; /* Block id of child node to descend to */
160058
160059 /* Skip over the 'height' varint that occurs at the start of every
160060 ** interior node. Then load the blockid of the left-child of the b-tree
@@ -159197,18 +160088,18 @@
160088 }
160089 isFirstTerm = 0;
160090 zCsr += fts3GetVarint32(zCsr, &nSuffix);
160091
160092 assert( nPrefix>=0 && nSuffix>=0 );
160093 if( nPrefix>zCsr-zNode || nSuffix>zEnd-zCsr ){
160094 rc = FTS_CORRUPT_VTAB;
160095 goto finish_scan;
160096 }
160097 if( (i64)nPrefix+nSuffix>nAlloc ){
160098 char *zNew;
160099 nAlloc = ((i64)nPrefix+nSuffix) * 2;
160100 zNew = (char *)sqlite3_realloc64(zBuffer, nAlloc);
160101 if( !zNew ){
160102 rc = SQLITE_NOMEM;
160103 goto finish_scan;
160104 }
160105 zBuffer = zNew;
@@ -161183,13 +162074,28 @@
162074 assert( p->mxSavepoint >= iSavepoint );
162075 TESTONLY( p->mxSavepoint = iSavepoint );
162076 sqlite3Fts3PendingTermsClear(p);
162077 return SQLITE_OK;
162078 }
162079
162080 /*
162081 ** Return true if zName is the extension on one of the shadow tables used
162082 ** by this module.
162083 */
162084 static int fts3ShadowName(const char *zName){
162085 static const char *azName[] = {
162086 "content", "docsize", "segdir", "segments", "stat",
162087 };
162088 unsigned int i;
162089 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
162090 if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
162091 }
162092 return 0;
162093 }
162094
162095 static const sqlite3_module fts3Module = {
162096 /* iVersion */ 3,
162097 /* xCreate */ fts3CreateMethod,
162098 /* xConnect */ fts3ConnectMethod,
162099 /* xBestIndex */ fts3BestIndexMethod,
162100 /* xDisconnect */ fts3DisconnectMethod,
162101 /* xDestroy */ fts3DestroyMethod,
@@ -161208,10 +162114,11 @@
162114 /* xFindFunction */ fts3FindFunctionMethod,
162115 /* xRename */ fts3RenameMethod,
162116 /* xSavepoint */ fts3SavepointMethod,
162117 /* xRelease */ fts3ReleaseMethod,
162118 /* xRollbackTo */ fts3RollbackToMethod,
162119 /* xShadowName */ fts3ShadowName,
162120 };
162121
162122 /*
162123 ** This function is registered as the module destructor (called when an
162124 ** FTS3 enabled database connection is closed). It frees the memory
@@ -163839,11 +164746,12 @@
164746 0, /* xRollback */
164747 0, /* xFindFunction */
164748 0, /* xRename */
164749 0, /* xSavepoint */
164750 0, /* xRelease */
164751 0, /* xRollbackTo */
164752 0 /* xShadowName */
164753 };
164754 int rc; /* Return code */
164755
164756 rc = sqlite3_create_module(db, "fts4aux", &fts3aux_module, 0);
164757 return rc;
@@ -167398,11 +168306,12 @@
168306 0, /* xRollback */
168307 0, /* xFindFunction */
168308 0, /* xRename */
168309 0, /* xSavepoint */
168310 0, /* xRelease */
168311 0, /* xRollbackTo */
168312 0 /* xShadowName */
168313 };
168314 int rc; /* Return code */
168315
168316 rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
168317 return rc;
@@ -168786,19 +169695,23 @@
169695
169696 /* Because of the FTS3_NODE_PADDING bytes of padding, the following is
169697 ** safe (no risk of overread) even if the node data is corrupted. */
169698 pNext += fts3GetVarint32(pNext, &nPrefix);
169699 pNext += fts3GetVarint32(pNext, &nSuffix);
169700 if( nSuffix<=0
169701 || (&pReader->aNode[pReader->nNode] - pNext)<nSuffix
169702 || nPrefix>pReader->nTermAlloc
169703 ){
169704 return FTS_CORRUPT_VTAB;
169705 }
169706
169707 /* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are
169708 ** between 0 and 0x7FFFFFFF. But the sum of the two may cause integer
169709 ** overflow - hence the (i64) casts. */
169710 if( (i64)nPrefix+nSuffix>(i64)pReader->nTermAlloc ){
169711 i64 nNew = ((i64)nPrefix+nSuffix)*2;
169712 char *zNew = sqlite3_realloc64(pReader->zTerm, nNew);
169713 if( !zNew ){
169714 return SQLITE_NOMEM;
169715 }
169716 pReader->zTerm = zNew;
169717 pReader->nTermAlloc = nNew;
@@ -168816,11 +169729,11 @@
169729
169730 /* Check that the doclist does not appear to extend past the end of the
169731 ** b-tree node. And that the final byte of the doclist is 0x00. If either
169732 ** of these statements is untrue, then the data structure is corrupt.
169733 */
169734 if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
169735 || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
169736 ){
169737 return FTS_CORRUPT_VTAB;
169738 }
169739 return SQLITE_OK;
@@ -171142,25 +172055,30 @@
172055 if( bFirst==0 ){
172056 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
172057 }
172058 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
172059
172060 if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
172061 return SQLITE_CORRUPT_VTAB;
172062 }
172063 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
172064 if( rc==SQLITE_OK ){
172065 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
172066 p->term.n = nPrefix+nSuffix;
172067 p->iOff += nSuffix;
172068 if( p->iChild==0 ){
172069 p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
172070 if( (p->nNode-p->iOff)<p->nDoclist ){
172071 return SQLITE_CORRUPT_VTAB;
172072 }
172073 p->aDoclist = &p->aNode[p->iOff];
172074 p->iOff += p->nDoclist;
172075 }
172076 }
172077 }
172078
172079 assert( p->iOff<=p->nNode );
 
172080 return rc;
172081 }
172082
172083 /*
172084 ** Release all dynamic resources held by node-reader object *p.
@@ -177960,11 +178878,12 @@
178878 0, /* xRollback */
178879 0, /* xFindMethod */
178880 0, /* xRename */
178881 0, /* xSavepoint */
178882 0, /* xRelease */
178883 0, /* xRollbackTo */
178884 0 /* xShadowName */
178885 };
178886
178887 /* The methods of the json_tree virtual table. */
178888 static sqlite3_module jsonTreeModule = {
178889 0, /* iVersion */
@@ -177987,11 +178906,12 @@
178906 0, /* xRollback */
178907 0, /* xFindMethod */
178908 0, /* xRename */
178909 0, /* xSavepoint */
178910 0, /* xRelease */
178911 0, /* xRollbackTo */
178912 0 /* xShadowName */
178913 };
178914 #endif /* SQLITE_OMIT_VIRTUALTABLE */
178915
178916 /****************************************************************************
178917 ** The following routines are the only publically visible identifiers in this
@@ -181417,12 +182337,28 @@
182337 }
182338
182339 return rc;
182340 }
182341
182342
182343 /*
182344 ** Return true if zName is the extension on one of the shadow tables used
182345 ** by this module.
182346 */
182347 static int rtreeShadowName(const char *zName){
182348 static const char *azName[] = {
182349 "node", "parent", "rowid"
182350 };
182351 unsigned int i;
182352 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
182353 if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
182354 }
182355 return 0;
182356 }
182357
182358 static sqlite3_module rtreeModule = {
182359 3, /* iVersion */
182360 rtreeCreate, /* xCreate - create a table */
182361 rtreeConnect, /* xConnect - connect to an existing table */
182362 rtreeBestIndex, /* xBestIndex - Determine search strategy */
182363 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
182364 rtreeDestroy, /* xDestroy - Drop a table */
@@ -181441,10 +182377,11 @@
182377 0, /* xFindFunction - function overloading */
182378 rtreeRename, /* xRename - rename the table */
182379 rtreeSavepoint, /* xSavepoint */
182380 0, /* xRelease */
182381 0, /* xRollbackTo */
182382 rtreeShadowName /* xShadowName */
182383 };
182384
182385 static int rtreeSqlInit(
182386 Rtree *pRtree,
182387 sqlite3 *db,
@@ -182431,17 +183368,27 @@
183368 ** The on-disk representation consists of a 4-byte header followed by
183369 ** the values. The 4-byte header is:
183370 **
183371 ** encoding (1 byte) 0=big-endian, 1=little-endian
183372 ** nvertex (3 bytes) Number of vertexes as a big-endian integer
183373 **
183374 ** Enough space is allocated for 4 coordinates, to work around over-zealous
183375 ** warnings coming from some compiler (notably, clang). In reality, the size
183376 ** of each GeoPoly memory allocate is adjusted as necessary so that the
183377 ** GeoPoly.a[] array at the end is the appropriate size.
183378 */
183379 typedef struct GeoPoly GeoPoly;
183380 struct GeoPoly {
183381 int nVertex; /* Number of vertexes */
183382 unsigned char hdr[4]; /* Header for on-disk representation */
183383 GeoCoord a[8]; /* 2*nVertex values. X (longitude) first, then Y */
183384 };
183385
183386 /* The size of a memory allocation needed for a GeoPoly object sufficient
183387 ** to hold N coordinate pairs.
183388 */
183389 #define GEOPOLY_SZ(N) (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4))
183390
183391 /*
183392 ** State of a parse of a GeoJSON input.
183393 */
183394 typedef struct GeoParse GeoParse;
@@ -182463,11 +183410,11 @@
183410 a[2] = t;
183411 }
183412
183413 /* Skip whitespace. Return the next non-whitespace character. */
183414 static char geopolySkipSpace(GeoParse *p){
183415 while( safe_isspace(p->z[0]) ) p->z++;
183416 return p->z[0];
183417 }
183418
183419 /* Parse out a number. Write the value into *pVal if pVal!=0.
183420 ** return non-zero on success and zero if the next token is not a number.
@@ -182483,11 +183430,11 @@
183430 c = z[j];
183431 }
183432 if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
183433 for(;; j++){
183434 c = z[j];
183435 if( safe_isdigit(c) ) continue;
183436 if( c=='.' ){
183437 if( z[j-1]=='-' ) return 0;
183438 if( seenDP ) return 0;
183439 seenDP = 1;
183440 continue;
@@ -182505,11 +183452,21 @@
183452 continue;
183453 }
183454 break;
183455 }
183456 if( z[j-1]<'0' ) return 0;
183457 if( pVal ){
183458 #ifdef SQLITE_AMALGAMATION
183459 /* The sqlite3AtoF() routine is much much faster than atof(), if it
183460 ** is available */
183461 double r;
183462 (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);
183463 *pVal = r;
183464 #else
183465 *pVal = (GeoCoord)atof((const char*)p->z);
183466 #endif
183467 }
183468 p->z += j;
183469 return 1;
183470 }
183471
183472 /*
@@ -182563,16 +183520,14 @@
183520 && s.nVertex>=4
183521 && s.a[0]==s.a[s.nVertex*2-2]
183522 && s.a[1]==s.a[s.nVertex*2-1]
183523 && (s.z++, geopolySkipSpace(&s)==0)
183524 ){
 
183525 GeoPoly *pOut;
183526 int x = 1;
183527 s.nVertex--; /* Remove the redundant vertex at the end */
183528 pOut = sqlite3_malloc64( GEOPOLY_SZ(s.nVertex) );
 
183529 x = 1;
183530 if( pOut==0 ) goto parse_json_err;
183531 pOut->nVertex = s.nVertex;
183532 memcpy(pOut->a, s.a, s.nVertex*2*sizeof(GeoCoord));
183533 pOut->hdr[0] = *(unsigned char*)&x;
@@ -182770,10 +183725,31 @@
183725 sqlite3_result_blob(context, p->hdr,
183726 4+8*p->nVertex, SQLITE_TRANSIENT);
183727 sqlite3_free(p);
183728 }
183729 }
183730
183731 /*
183732 ** Compute the area enclosed by the polygon.
183733 **
183734 ** This routine can also be used to detect polygons that rotate in
183735 ** the wrong direction. Polygons are suppose to be counter-clockwise (CCW).
183736 ** This routine returns a negative value for clockwise (CW) polygons.
183737 */
183738 static double geopolyArea(GeoPoly *p){
183739 double rArea = 0.0;
183740 int ii;
183741 for(ii=0; ii<p->nVertex-1; ii++){
183742 rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
183743 * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
183744 * 0.5;
183745 }
183746 rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
183747 * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
183748 * 0.5;
183749 return rArea;
183750 }
183751
183752 /*
183753 ** Implementation of the geopoly_area(X) function.
183754 **
183755 ** If the input is a well-formed Geopoly BLOB then return the area
@@ -182786,24 +183762,109 @@
183762 int argc,
183763 sqlite3_value **argv
183764 ){
183765 GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
183766 if( p ){
183767 sqlite3_result_double(context, geopolyArea(p));
183768 sqlite3_free(p);
183769 }
183770 }
183771
183772 /*
183773 ** Implementation of the geopoly_ccw(X) function.
183774 **
183775 ** If the rotation of polygon X is clockwise (incorrect) instead of
183776 ** counter-clockwise (the correct winding order according to RFC7946)
183777 ** then reverse the order of the vertexes in polygon X.
183778 **
183779 ** In other words, this routine returns a CCW polygon regardless of the
183780 ** winding order of its input.
183781 **
183782 ** Use this routine to sanitize historical inputs that that sometimes
183783 ** contain polygons that wind in the wrong direction.
183784 */
183785 static void geopolyCcwFunc(
183786 sqlite3_context *context,
183787 int argc,
183788 sqlite3_value **argv
183789 ){
183790 GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
183791 if( p ){
183792 if( geopolyArea(p)<0.0 ){
183793 int ii, jj;
183794 for(ii=2, jj=p->nVertex*2 - 4; ii<jj; ii+=2, jj-=2){
183795 GeoCoord t = p->a[ii];
183796 p->a[ii] = p->a[jj];
183797 p->a[jj] = t;
183798 t = p->a[ii+1];
183799 p->a[ii+1] = p->a[jj+1];
183800 p->a[jj+1] = t;
183801 }
183802 }
183803 sqlite3_result_blob(context, p->hdr,
183804 4+8*p->nVertex, SQLITE_TRANSIENT);
183805 sqlite3_free(p);
183806 }
183807 }
183808
183809 #define GEOPOLY_PI 3.1415926535897932385
183810
183811 /* Fast approximation for cosine(X) for X between -0.5*pi and 2*pi
183812 */
183813 static double geopolyCosine(double r){
183814 assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI );
183815 if( r>=1.5*GEOPOLY_PI ){
183816 r -= 2.0*GEOPOLY_PI;
183817 }
183818 if( r>=0.5*GEOPOLY_PI ){
183819 return -geopolyCosine(r-GEOPOLY_PI);
183820 }else{
183821 double r2 = r*r;
183822 double r3 = r2*r;
183823 double r5 = r3*r2;
183824 return 0.9996949*r - 0.1656700*r3 + 0.0075134*r5;
183825 }
183826 }
183827
183828 /*
183829 ** Function: geopoly_regular(X,Y,R,N)
183830 **
183831 ** Construct a simple, convex, regular polygon centered at X, Y
183832 ** with circumradius R and with N sides.
183833 */
183834 static void geopolyRegularFunc(
183835 sqlite3_context *context,
183836 int argc,
183837 sqlite3_value **argv
183838 ){
183839 double x = sqlite3_value_double(argv[0]);
183840 double y = sqlite3_value_double(argv[1]);
183841 double r = sqlite3_value_double(argv[2]);
183842 int n = sqlite3_value_int(argv[3]);
183843 int i;
183844 GeoPoly *p;
183845
183846 if( n<3 || r<=0.0 ) return;
183847 if( n>1000 ) n = 1000;
183848 p = sqlite3_malloc64( sizeof(*p) + (n-1)*2*sizeof(GeoCoord) );
183849 if( p==0 ){
183850 sqlite3_result_error_nomem(context);
183851 return;
183852 }
183853 i = 1;
183854 p->hdr[0] = *(unsigned char*)&i;
183855 p->hdr[1] = 0;
183856 p->hdr[2] = (n>>8)&0xff;
183857 p->hdr[3] = n&0xff;
183858 for(i=0; i<n; i++){
183859 double rAngle = 2.0*GEOPOLY_PI*i/n;
183860 p->a[i*2] = x - r*geopolyCosine(rAngle-0.5*GEOPOLY_PI);
183861 p->a[i*2+1] = y + r*geopolyCosine(rAngle);
183862 }
183863 sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);
183864 sqlite3_free(p);
183865 }
183866
183867 /*
183868 ** If pPoly is a polygon, compute its bounding box. Then:
183869 **
183870 ** (1) if aCoord!=0 store the bounding box in aCoord, returning NULL
@@ -182845,11 +183906,11 @@
183906 else if( r>mxY ) mxY = (float)r;
183907 }
183908 if( pRc ) *pRc = SQLITE_OK;
183909 if( aCoord==0 ){
183910 geopolyBboxFill:
183911 pOut = sqlite3_realloc(p, GEOPOLY_SZ(4));
183912 if( pOut==0 ){
183913 sqlite3_free(p);
183914 if( context ) sqlite3_result_error_nomem(context);
183915 if( pRc ) *pRc = SQLITE_NOMEM;
183916 return 0;
@@ -183873,11 +184934,20 @@
184934 sqlite3_bind_int64(pUp, 1, cell.iRowid);
184935 assert( pRtree->nAux>=1 );
184936 if( sqlite3_value_nochange(aData[2]) ){
184937 sqlite3_bind_null(pUp, 2);
184938 }else{
184939 GeoPoly *p = 0;
184940 if( sqlite3_value_type(aData[2])==SQLITE_TEXT
184941 && (p = geopolyFuncParam(0, aData[2], &rc))!=0
184942 && rc==SQLITE_OK
184943 ){
184944 sqlite3_bind_blob(pUp, 2, p->hdr, 4+8*p->nVertex, SQLITE_TRANSIENT);
184945 }else{
184946 sqlite3_bind_value(pUp, 2, aData[2]);
184947 }
184948 sqlite3_free(p);
184949 nChange = 1;
184950 }
184951 for(jj=1; jj<pRtree->nAux; jj++){
184952 nChange++;
184953 sqlite3_bind_value(pUp, jj+2, aData[jj+2]);
@@ -183917,11 +184987,11 @@
184987 return 0;
184988 }
184989
184990
184991 static sqlite3_module geopolyModule = {
184992 3, /* iVersion */
184993 geopolyCreate, /* xCreate - create a table */
184994 geopolyConnect, /* xConnect - connect to an existing table */
184995 geopolyBestIndex, /* xBestIndex - Determine search strategy */
184996 rtreeDisconnect, /* xDisconnect - Disconnect from a table */
184997 rtreeDestroy, /* xDestroy - Drop a table */
@@ -183940,29 +185010,33 @@
185010 geopolyFindFunction, /* xFindFunction - function overloading */
185011 rtreeRename, /* xRename - rename the table */
185012 rtreeSavepoint, /* xSavepoint */
185013 0, /* xRelease */
185014 0, /* xRollbackTo */
185015 rtreeShadowName /* xShadowName */
185016 };
185017
185018 static int sqlite3_geopoly_init(sqlite3 *db){
185019 int rc = SQLITE_OK;
185020 static const struct {
185021 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
185022 signed char nArg;
185023 unsigned char bPure;
185024 const char *zName;
185025 } aFunc[] = {
185026 { geopolyAreaFunc, 1, 1, "geopoly_area" },
185027 { geopolyBlobFunc, 1, 1, "geopoly_blob" },
185028 { geopolyJsonFunc, 1, 1, "geopoly_json" },
185029 { geopolySvgFunc, -1, 1, "geopoly_svg" },
185030 { geopolyWithinFunc, 2, 1, "geopoly_within" },
185031 { geopolyContainsPointFunc, 3, 1, "geopoly_contains_point" },
185032 { geopolyOverlapFunc, 2, 1, "geopoly_overlap" },
185033 { geopolyDebugFunc, 1, 0, "geopoly_debug" },
185034 { geopolyBBoxFunc, 1, 1, "geopoly_bbox" },
185035 { geopolyXformFunc, 7, 1, "geopoly_xform" },
185036 { geopolyRegularFunc, 4, 1, "geopoly_regular" },
185037 { geopolyCcwFunc, 1, 1, "geopoly_ccw" },
185038 };
185039 static const struct {
185040 void (*xStep)(sqlite3_context*,int,sqlite3_value**);
185041 void (*xFinal)(sqlite3_context*);
185042 const char *zName;
@@ -183969,12 +185043,13 @@
185043 } aAgg[] = {
185044 { geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox" },
185045 };
185046 int i;
185047 for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
185048 int enc = aFunc[i].bPure ? SQLITE_UTF8|SQLITE_DETERMINISTIC : SQLITE_UTF8;
185049 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
185050 enc, 0,
185051 aFunc[i].xFunc, 0, 0);
185052 }
185053 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
185054 rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,
185055 0, aAgg[i].xStep, aAgg[i].xFinal);
@@ -185997,11 +187072,12 @@
187072 struct rbu_vfs {
187073 sqlite3_vfs base; /* rbu VFS shim methods */
187074 sqlite3_vfs *pRealVfs; /* Underlying VFS */
187075 sqlite3_mutex *mutex; /* Mutex to protect pMain */
187076 sqlite3rbu *pRbu; /* Owner RBU object */
187077 rbu_file *pMain; /* List of main db files */
187078 rbu_file *pMainRbu; /* List of main db files with pRbu!=0 */
187079 };
187080
187081 /*
187082 ** Each file opened by an rbu VFS is represented by an instance of
187083 ** the following structure.
@@ -186026,10 +187102,11 @@
187102 char *zDel; /* Delete this when closing file */
187103
187104 const char *zWal; /* Wal filename for this main db file */
187105 rbu_file *pWalFd; /* Wal file descriptor for this main db */
187106 rbu_file *pMainNext; /* Next MAIN_DB file */
187107 rbu_file *pMainRbuNext; /* Next MAIN_DB file with pRbu!=0 */
187108 };
187109
187110 /*
187111 ** True for an RBU vacuum handle, or false otherwise.
187112 */
@@ -189621,10 +190698,73 @@
190698 pFd->sz = nNew;
190699 assert( pRbu->szTemp>=0 );
190700 if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;
190701 return SQLITE_OK;
190702 }
190703
190704 /*
190705 ** Add an item to the main-db lists, if it is not already present.
190706 **
190707 ** There are two main-db lists. One for all file descriptors, and one
190708 ** for all file descriptors with rbu_file.pDb!=0. If the argument has
190709 ** rbu_file.pDb!=0, then it is assumed to already be present on the
190710 ** main list and is only added to the pDb!=0 list.
190711 */
190712 static void rbuMainlistAdd(rbu_file *p){
190713 rbu_vfs *pRbuVfs = p->pRbuVfs;
190714 rbu_file *pIter;
190715 assert( (p->openFlags & SQLITE_OPEN_MAIN_DB) );
190716 sqlite3_mutex_enter(pRbuVfs->mutex);
190717 if( p->pRbu==0 ){
190718 for(pIter=pRbuVfs->pMain; pIter; pIter=pIter->pMainNext);
190719 p->pMainNext = pRbuVfs->pMain;
190720 pRbuVfs->pMain = p;
190721 }else{
190722 for(pIter=pRbuVfs->pMainRbu; pIter && pIter!=p; pIter=pIter->pMainRbuNext){}
190723 if( pIter==0 ){
190724 p->pMainRbuNext = pRbuVfs->pMainRbu;
190725 pRbuVfs->pMainRbu = p;
190726 }
190727 }
190728 sqlite3_mutex_leave(pRbuVfs->mutex);
190729 }
190730
190731 /*
190732 ** Remove an item from the main-db lists.
190733 */
190734 static void rbuMainlistRemove(rbu_file *p){
190735 rbu_file **pp;
190736 sqlite3_mutex_enter(p->pRbuVfs->mutex);
190737 for(pp=&p->pRbuVfs->pMain; *pp && *pp!=p; pp=&((*pp)->pMainNext)){}
190738 if( *pp ) *pp = p->pMainNext;
190739 p->pMainNext = 0;
190740 for(pp=&p->pRbuVfs->pMainRbu; *pp && *pp!=p; pp=&((*pp)->pMainRbuNext)){}
190741 if( *pp ) *pp = p->pMainRbuNext;
190742 p->pMainRbuNext = 0;
190743 sqlite3_mutex_leave(p->pRbuVfs->mutex);
190744 }
190745
190746 /*
190747 ** Given that zWal points to a buffer containing a wal file name passed to
190748 ** either the xOpen() or xAccess() VFS method, search the main-db list for
190749 ** a file-handle opened by the same database connection on the corresponding
190750 ** database file.
190751 **
190752 ** If parameter bRbu is true, only search for file-descriptors with
190753 ** rbu_file.pDb!=0.
190754 */
190755 static rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal, int bRbu){
190756 rbu_file *pDb;
190757 sqlite3_mutex_enter(pRbuVfs->mutex);
190758 if( bRbu ){
190759 for(pDb=pRbuVfs->pMainRbu; pDb && pDb->zWal!=zWal; pDb=pDb->pMainRbuNext){}
190760 }else{
190761 for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}
190762 }
190763 sqlite3_mutex_leave(pRbuVfs->mutex);
190764 return pDb;
190765 }
190766
190767 /*
190768 ** Close an rbu file.
190769 */
190770 static int rbuVfsClose(sqlite3_file *pFile){
@@ -189639,21 +190779,18 @@
190779 sqlite3_free(p->apShm);
190780 p->apShm = 0;
190781 sqlite3_free(p->zDel);
190782
190783 if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
190784 rbuMainlistRemove(p);
 
 
 
 
190785 rbuUnlockShm(p);
190786 p->pReal->pMethods->xShmUnmap(p->pReal, 0);
190787 }
190788 else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){
190789 rbuUpdateTempSize(p, 0);
190790 }
190791 assert( p->pMainNext==0 && p->pRbuVfs->pMain!=p );
190792
190793 /* Close the underlying file handle */
190794 rc = p->pReal->pMethods->xClose(p->pReal);
190795 return rc;
190796 }
@@ -189908,10 +191045,13 @@
191045 rc = SQLITE_ERROR;
191046 pRbu->zErrmsg = sqlite3_mprintf("rbu/zipvfs setup error");
191047 }else if( rc==SQLITE_NOTFOUND ){
191048 pRbu->pTargetFd = p;
191049 p->pRbu = pRbu;
191050 if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
191051 rbuMainlistAdd(p);
191052 }
191053 if( p->pWalFd ) p->pWalFd->pRbu = pRbu;
191054 rc = SQLITE_OK;
191055 }
191056 }
191057 return rc;
@@ -190069,24 +191209,10 @@
191209 rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
191210 }
191211 return rc;
191212 }
191213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191214 /*
191215 ** A main database named zName has just been opened. The following
191216 ** function returns a pointer to a buffer owned by SQLite that contains
191217 ** the name of the *-wal file this db connection will use. SQLite
191218 ** happens to pass a pointer to this buffer when using xAccess()
@@ -190161,11 +191287,11 @@
191287 ** happens to pass a pointer to this buffer when using xAccess()
191288 ** or xOpen() to operate on the *-wal file. */
191289 pFd->zWal = rbuMainToWal(zName, flags);
191290 }
191291 else if( flags & SQLITE_OPEN_WAL ){
191292 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);
191293 if( pDb ){
191294 if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
191295 /* This call is to open a *-wal file. Intead, open the *-oal. This
191296 ** code ensures that the string passed to xOpen() is terminated by a
191297 ** pair of '\0' bytes in case the VFS attempts to extract a URI
@@ -190213,14 +191339,11 @@
191339 /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods
191340 ** pointer and, if the file is a main database file, link it into the
191341 ** mutex protected linked list of all such files. */
191342 pFile->pMethods = &rbuvfs_io_methods;
191343 if( flags & SQLITE_OPEN_MAIN_DB ){
191344 rbuMainlistAdd(pFd);
 
 
 
191345 }
191346 }else{
191347 sqlite3_free(pFd->zDel);
191348 }
191349
@@ -190264,11 +191387,11 @@
191387 ** causing SQLite to call xOpen() to open it. This call will also
191388 ** be intercepted (see the rbuVfsOpen() function) and the *-oal
191389 ** file opened instead.
191390 */
191391 if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){
191392 rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath, 1);
191393 if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){
191394 if( *pResOut ){
191395 rc = SQLITE_CANTOPEN;
191396 }else{
191397 sqlite3_int64 sz = 0;
@@ -190737,18 +191860,24 @@
191860
191861 *ppCursor = (sqlite3_vtab_cursor *)pCsr;
191862 return SQLITE_OK;
191863 }
191864
191865 static void statClearCells(StatPage *p){
191866 int i;
191867 if( p->aCell ){
191868 for(i=0; i<p->nCell; i++){
191869 sqlite3_free(p->aCell[i].aOvfl);
191870 }
191871 sqlite3_free(p->aCell);
191872 }
191873 p->nCell = 0;
191874 p->aCell = 0;
191875 }
191876
191877 static void statClearPage(StatPage *p){
191878 statClearCells(p);
191879 sqlite3PagerUnref(p->pPg);
191880 sqlite3_free(p->zPath);
191881 memset(p, 0, sizeof(StatPage));
191882 }
191883
@@ -190807,26 +191936,37 @@
191936
191937 u8 *aData = sqlite3PagerGetData(p->pPg);
191938 u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];
191939
191940 p->flags = aHdr[0];
191941 if( p->flags==0x0A || p->flags==0x0D ){
191942 isLeaf = 1;
191943 nHdr = 8;
191944 }else if( p->flags==0x05 || p->flags==0x02 ){
191945 isLeaf = 0;
191946 nHdr = 12;
191947 }else{
191948 goto statPageIsCorrupt;
191949 }
191950 if( p->iPgno==1 ) nHdr += 100;
191951 p->nCell = get2byte(&aHdr[3]);
191952 p->nMxPayload = 0;
191953 szPage = sqlite3BtreeGetPageSize(pBt);
 
 
191954
191955 nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;
191956 nUnused += (int)aHdr[7];
191957 iOff = get2byte(&aHdr[1]);
191958 while( iOff ){
191959 int iNext;
191960 if( iOff>=szPage ) goto statPageIsCorrupt;
191961 nUnused += get2byte(&aData[iOff+2]);
191962 iNext = get2byte(&aData[iOff]);
191963 if( iNext<iOff+4 && iNext>0 ) goto statPageIsCorrupt;
191964 iOff = iNext;
191965 }
191966 p->nUnused = nUnused;
191967 p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
 
191968
191969 if( p->nCell ){
191970 int i; /* Used to iterate through cells */
191971 int nUsable; /* Usable bytes per page */
191972
@@ -190839,10 +191979,11 @@
191979
191980 for(i=0; i<p->nCell; i++){
191981 StatCell *pCell = &p->aCell[i];
191982
191983 iOff = get2byte(&aData[nHdr+i*2]);
191984 if( iOff<nHdr || iOff>=szPage ) goto statPageIsCorrupt;
191985 if( !isLeaf ){
191986 pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);
191987 iOff += 4;
191988 }
191989 if( p->flags==0x05 ){
@@ -190855,12 +191996,12 @@
191996 u64 dummy;
191997 iOff += sqlite3GetVarint(&aData[iOff], &dummy);
191998 }
191999 if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
192000 getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
192001 if( nLocal<0 ) goto statPageIsCorrupt;
192002 pCell->nLocal = nLocal;
 
192003 assert( nPayload>=(u32)nLocal );
192004 assert( nLocal<=(nUsable-35) );
192005 if( nPayload>(u32)nLocal ){
192006 int j;
192007 int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);
@@ -190885,10 +192026,15 @@
192026 }
192027 }
192028 }
192029
192030 return SQLITE_OK;
192031
192032 statPageIsCorrupt:
192033 p->flags = 0;
192034 statClearCells(p);
192035 return SQLITE_OK;
192036 }
192037
192038 /*
192039 ** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
192040 ** the current value of pCsr->iPageno.
@@ -191180,10 +192326,11 @@
192326 0, /* xFindMethod */
192327 0, /* xRename */
192328 0, /* xSavepoint */
192329 0, /* xRelease */
192330 0, /* xRollbackTo */
192331 0 /* xShadowName */
192332 };
192333 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
192334 }
192335 #elif defined(SQLITE_ENABLE_DBSTAT_VTAB)
192336 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191504,10 +192651,14 @@
192651 int iDb;
192652 Btree *pBt;
192653 Pager *pPager;
192654 int szPage;
192655
192656 if( pTab->db->flags & SQLITE_Defensive ){
192657 zErr = "read-only";
192658 goto update_fail;
192659 }
192660 if( argc==1 ){
192661 zErr = "cannot delete";
192662 goto update_fail;
192663 }
192664 pgno = sqlite3_value_int(argv[0]);
@@ -191594,10 +192745,11 @@
192745 0, /* xFindMethod */
192746 0, /* xRename */
192747 0, /* xSavepoint */
192748 0, /* xRelease */
192749 0, /* xRollbackTo */
192750 0 /* xShadowName */
192751 };
192752 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
192753 }
192754 #elif defined(SQLITE_ENABLE_DBPAGE_VTAB)
192755 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -191629,10 +192781,12 @@
192781 # define SESSIONS_STRM_CHUNK_SIZE 64
192782 # else
192783 # define SESSIONS_STRM_CHUNK_SIZE 1024
192784 # endif
192785 #endif
192786
192787 static int sessions_strm_chunk_size = SESSIONS_STRM_CHUNK_SIZE;
192788
192789 typedef struct SessionHook SessionHook;
192790 struct SessionHook {
192791 void *pCtx;
192792 int (*xOld)(void*,int,sqlite3_value**);
@@ -191692,10 +192846,11 @@
192846 */
192847 struct sqlite3_changeset_iter {
192848 SessionInput in; /* Input buffer or stream */
192849 SessionBuffer tblhdr; /* Buffer to hold apValue/zTab/abPK/ */
192850 int bPatchset; /* True if this is a patchset */
192851 int bInvert; /* True to invert changeset */
192852 int rc; /* Iterator error code */
192853 sqlite3_stmt *pConflict; /* Points to conflicting row, if any */
192854 char *zTab; /* Current table */
192855 int nCol; /* Number of columns in zTab */
192856 int op; /* Current operation */
@@ -191848,10 +193003,46 @@
193003 ** and fields associated with modified columns contain the new column values.
193004 **
193005 ** The records associated with INSERT changes are in the same format as for
193006 ** changesets. It is not possible for a record associated with an INSERT
193007 ** change to contain a field set to "undefined".
193008 **
193009 ** REBASE BLOB FORMAT:
193010 **
193011 ** A rebase blob may be output by sqlite3changeset_apply_v2() and its
193012 ** streaming equivalent for use with the sqlite3_rebaser APIs to rebase
193013 ** existing changesets. A rebase blob contains one entry for each conflict
193014 ** resolved using either the OMIT or REPLACE strategies within the apply_v2()
193015 ** call.
193016 **
193017 ** The format used for a rebase blob is very similar to that used for
193018 ** changesets. All entries related to a single table are grouped together.
193019 **
193020 ** Each group of entries begins with a table header in changeset format:
193021 **
193022 ** 1 byte: Constant 0x54 (capital 'T')
193023 ** Varint: Number of columns in the table.
193024 ** nCol bytes: 0x01 for PK columns, 0x00 otherwise.
193025 ** N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.
193026 **
193027 ** Followed by one or more entries associated with the table.
193028 **
193029 ** 1 byte: Either SQLITE_INSERT (0x12), DELETE (0x09).
193030 ** 1 byte: Flag. 0x01 for REPLACE, 0x00 for OMIT.
193031 ** record: (in the record format defined above).
193032 **
193033 ** In a rebase blob, the first field is set to SQLITE_INSERT if the change
193034 ** that caused the conflict was an INSERT or UPDATE, or to SQLITE_DELETE if
193035 ** it was a DELETE. The second field is set to 0x01 if the conflict
193036 ** resolution strategy was REPLACE, or 0x00 if it was OMIT.
193037 **
193038 ** If the change that caused the conflict was a DELETE, then the single
193039 ** record is a copy of the old.* record from the original changeset. If it
193040 ** was an INSERT, then the single record is a copy of the new.* record. If
193041 ** the conflicting change was an UPDATE, then the single record is a copy
193042 ** of the new.* record with the PK fields filled in based on the original
193043 ** old.* record.
193044 */
193045
193046 /*
193047 ** For each row modified during a session, there exists a single instance of
193048 ** this structure stored in a SessionTable.aChange[] hash table.
@@ -193398,16 +194589,16 @@
194589 ** set *pRc to SQLITE_NOMEM and return non-zero.
194590 */
194591 static int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){
194592 if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){
194593 u8 *aNew;
194594 i64 nNew = p->nAlloc ? p->nAlloc : 128;
194595 do {
194596 nNew = nNew*2;
194597 }while( (nNew-p->nBuf)<nByte );
194598
194599 aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);
194600 if( 0==aNew ){
194601 *pRc = SQLITE_NOMEM;
194602 }else{
194603 p->aBuf = aNew;
194604 p->nAlloc = nNew;
@@ -194001,16 +195192,16 @@
195192 }
195193 if( rc==SQLITE_OK ){
195194 rc = sqlite3_reset(pSel);
195195 }
195196
195197 /* If the buffer is now larger than sessions_strm_chunk_size, pass
195198 ** its contents to the xOutput() callback. */
195199 if( xOutput
195200 && rc==SQLITE_OK
195201 && buf.nBuf>nNoop
195202 && buf.nBuf>sessions_strm_chunk_size
195203 ){
195204 rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);
195205 nNoop = -1;
195206 buf.nBuf = 0;
195207 }
@@ -194145,11 +195336,12 @@
195336 static int sessionChangesetStart(
195337 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195338 int (*xInput)(void *pIn, void *pData, int *pnData),
195339 void *pIn,
195340 int nChangeset, /* Size of buffer pChangeset in bytes */
195341 void *pChangeset, /* Pointer to buffer containing changeset */
195342 int bInvert /* True to invert changeset */
195343 ){
195344 sqlite3_changeset_iter *pRet; /* Iterator to return */
195345 int nByte; /* Number of bytes to allocate for iterator */
195346
195347 assert( xInput==0 || (pChangeset==0 && nChangeset==0) );
@@ -194165,10 +195357,11 @@
195357 pRet->in.aData = (u8 *)pChangeset;
195358 pRet->in.nData = nChangeset;
195359 pRet->in.xInput = xInput;
195360 pRet->in.pIn = pIn;
195361 pRet->in.bEof = (xInput ? 0 : 1);
195362 pRet->bInvert = bInvert;
195363
195364 /* Populate the output variable and return success. */
195365 *pp = pRet;
195366 return SQLITE_OK;
195367 }
@@ -194179,11 +195372,20 @@
195372 SQLITE_API int sqlite3changeset_start(
195373 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195374 int nChangeset, /* Size of buffer pChangeset in bytes */
195375 void *pChangeset /* Pointer to buffer containing changeset */
195376 ){
195377 return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, 0);
195378 }
195379 SQLITE_API int sqlite3changeset_start_v2(
195380 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195381 int nChangeset, /* Size of buffer pChangeset in bytes */
195382 void *pChangeset, /* Pointer to buffer containing changeset */
195383 int flags
195384 ){
195385 int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);
195386 return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, bInvert);
195387 }
195388
195389 /*
195390 ** Streaming version of sqlite3changeset_start().
195391 */
@@ -194190,19 +195392,28 @@
195392 SQLITE_API int sqlite3changeset_start_strm(
195393 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195394 int (*xInput)(void *pIn, void *pData, int *pnData),
195395 void *pIn
195396 ){
195397 return sessionChangesetStart(pp, xInput, pIn, 0, 0, 0);
195398 }
195399 SQLITE_API int sqlite3changeset_start_v2_strm(
195400 sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */
195401 int (*xInput)(void *pIn, void *pData, int *pnData),
195402 void *pIn,
195403 int flags
195404 ){
195405 int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);
195406 return sessionChangesetStart(pp, xInput, pIn, 0, 0, bInvert);
195407 }
195408
195409 /*
195410 ** If the SessionInput object passed as the only argument is a streaming
195411 ** object and the buffer is full, discard some data to free up space.
195412 */
195413 static void sessionDiscardData(SessionInput *pIn){
195414 if( pIn->xInput && pIn->iNext>=sessions_strm_chunk_size ){
195415 int nMove = pIn->buf.nBuf - pIn->iNext;
195416 assert( nMove>=0 );
195417 if( nMove>0 ){
195418 memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);
195419 }
@@ -194221,11 +195432,11 @@
195432 */
195433 static int sessionInputBuffer(SessionInput *pIn, int nByte){
195434 int rc = SQLITE_OK;
195435 if( pIn->xInput ){
195436 while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){
195437 int nNew = sessions_strm_chunk_size;
195438
195439 if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);
195440 if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){
195441 rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);
195442 if( nNew==0 ){
@@ -194569,14 +195780,14 @@
195780 p->in.iCurrent = p->in.iNext;
195781 if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
195782 op = p->in.aData[p->in.iNext++];
195783 }
195784
195785 if( p->zTab==0 || (p->bPatchset && p->bInvert) ){
195786 /* The first record in the changeset is not a table header. Must be a
195787 ** corrupt changeset. */
195788 assert( p->in.iNext==1 || p->zTab );
195789 return (p->rc = SQLITE_CORRUPT_BKPT);
195790 }
195791
195792 p->op = op;
195793 p->bIndirect = p->in.aData[p->in.iNext++];
@@ -194597,37 +195808,43 @@
195808 p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);
195809 if( p->rc!=SQLITE_OK ) return p->rc;
195810 *paRec = &p->in.aData[p->in.iNext];
195811 p->in.iNext += *pnRec;
195812 }else{
195813 sqlite3_value **apOld = (p->bInvert ? &p->apValue[p->nCol] : p->apValue);
195814 sqlite3_value **apNew = (p->bInvert ? p->apValue : &p->apValue[p->nCol]);
195815
195816 /* If this is an UPDATE or DELETE, read the old.* record. */
195817 if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){
195818 u8 *abPK = p->bPatchset ? p->abPK : 0;
195819 p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld);
195820 if( p->rc!=SQLITE_OK ) return p->rc;
195821 }
195822
195823 /* If this is an INSERT or UPDATE, read the new.* record. */
195824 if( p->op!=SQLITE_DELETE ){
195825 p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew);
195826 if( p->rc!=SQLITE_OK ) return p->rc;
195827 }
195828
195829 if( (p->bPatchset || p->bInvert) && p->op==SQLITE_UPDATE ){
195830 /* If this is an UPDATE that is part of a patchset, then all PK and
195831 ** modified fields are present in the new.* record. The old.* record
195832 ** is currently completely empty. This block shifts the PK fields from
195833 ** new.* to old.*, to accommodate the code that reads these arrays. */
195834 for(i=0; i<p->nCol; i++){
195835 assert( p->bPatchset==0 || p->apValue[i]==0 );
195836 if( p->abPK[i] ){
195837 assert( p->apValue[i]==0 );
195838 p->apValue[i] = p->apValue[i+p->nCol];
195839 if( p->apValue[i]==0 ) return (p->rc = SQLITE_CORRUPT_BKPT);
195840 p->apValue[i+p->nCol] = 0;
195841 }
195842 }
195843 }else if( p->bInvert ){
195844 if( p->op==SQLITE_INSERT ) p->op = SQLITE_DELETE;
195845 else if( p->op==SQLITE_DELETE ) p->op = SQLITE_INSERT;
195846 }
195847 }
195848
195849 return SQLITE_ROW;
195850 }
@@ -194940,11 +196157,11 @@
196157 rc = SQLITE_CORRUPT_BKPT;
196158 goto finished_invert;
196159 }
196160
196161 assert( rc==SQLITE_OK );
196162 if( xOutput && sOut.nBuf>=sessions_strm_chunk_size ){
196163 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
196164 sOut.nBuf = 0;
196165 if( rc!=SQLITE_OK ) goto finished_invert;
196166 }
196167 }
@@ -195019,11 +196236,12 @@
196236 u8 *abPK; /* Boolean array - true if column is in PK */
196237 int bStat1; /* True if table is sqlite_stat1 */
196238 int bDeferConstraints; /* True to defer constraints */
196239 SessionBuffer constraints; /* Deferred constraints are stored here */
196240 SessionBuffer rebase; /* Rebase information (if any) here */
196241 u8 bRebaseStarted; /* If table header is already in rebase */
196242 u8 bRebase; /* True to collect rebase information */
196243 };
196244
196245 /*
196246 ** Formulate a statement to DELETE a row from database db. Assuming a table
196247 ** structure like this:
@@ -195416,39 +196634,40 @@
196634 SessionApplyCtx *p, /* Apply context */
196635 int eType, /* Conflict resolution (OMIT or REPLACE) */
196636 sqlite3_changeset_iter *pIter /* Iterator pointing at current change */
196637 ){
196638 int rc = SQLITE_OK;
196639 if( p->bRebase ){
196640 int i;
196641 int eOp = pIter->op;
196642 if( p->bRebaseStarted==0 ){
196643 /* Append a table-header to the rebase buffer */
196644 const char *zTab = pIter->zTab;
196645 sessionAppendByte(&p->rebase, 'T', &rc);
196646 sessionAppendVarint(&p->rebase, p->nCol, &rc);
196647 sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
196648 sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
196649 p->bRebaseStarted = 1;
196650 }
196651
196652 assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );
196653 assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );
196654
196655 sessionAppendByte(&p->rebase,
196656 (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
196657 );
196658 sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
196659 for(i=0; i<p->nCol; i++){
196660 sqlite3_value *pVal = 0;
196661 if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){
196662 sqlite3changeset_old(pIter, i, &pVal);
196663 }else{
196664 sqlite3changeset_new(pIter, i, &pVal);
196665 }
196666 sessionAppendValue(&p->rebase, pVal, &rc);
196667 }
196668 }
196669 return rc;
196670 }
196671
196672 /*
196673 ** Invoke the conflict handler for the change that the changeset iterator
@@ -195787,11 +197006,11 @@
197006 while( pApply->constraints.nBuf ){
197007 sqlite3_changeset_iter *pIter2 = 0;
197008 SessionBuffer cons = pApply->constraints;
197009 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
197010
197011 rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf, 0);
197012 if( rc==SQLITE_OK ){
197013 int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
197014 int rc2;
197015 pIter2->bPatchset = bPatchset;
197016 pIter2->zTab = (char*)zTab;
@@ -195853,10 +197072,11 @@
197072
197073 assert( xConflict!=0 );
197074
197075 pIter->in.bNoDiscard = 1;
197076 memset(&sApply, 0, sizeof(sApply));
197077 sApply.bRebase = (ppRebase && pnRebase);
197078 sqlite3_mutex_enter(sqlite3_db_mutex(db));
197079 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
197080 rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
197081 }
197082 if( rc==SQLITE_OK ){
@@ -196003,11 +197223,12 @@
197223 sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
197224 sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
197225 }
197226 }
197227
197228 assert( sApply.bRebase || sApply.rebase.nBuf==0 );
197229 if( rc==SQLITE_OK && bPatchset==0 && sApply.bRebase ){
197230 *ppRebase = (void*)sApply.rebase.aBuf;
197231 *pnRebase = sApply.rebase.nBuf;
197232 sApply.rebase.aBuf = 0;
197233 }
197234 sqlite3_finalize(sApply.pInsert);
@@ -196041,11 +197262,12 @@
197262 void *pCtx, /* First argument passed to xConflict */
197263 void **ppRebase, int *pnRebase,
197264 int flags
197265 ){
197266 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
197267 int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
197268 int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset,bInverse);
197269 if( rc==SQLITE_OK ){
197270 rc = sessionChangesetApply(
197271 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
197272 );
197273 }
@@ -196098,11 +197320,12 @@
197320 void *pCtx, /* First argument passed to xConflict */
197321 void **ppRebase, int *pnRebase,
197322 int flags
197323 ){
197324 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
197325 int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
197326 int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse);
197327 if( rc==SQLITE_OK ){
197328 rc = sessionChangesetApply(
197329 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
197330 );
197331 }
@@ -196471,17 +197694,16 @@
197694 SessionChange *p;
197695 for(p=pTab->apChange[i]; p; p=p->pNext){
197696 sessionAppendByte(&buf, p->op, &rc);
197697 sessionAppendByte(&buf, p->bIndirect, &rc);
197698 sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);
197699 if( rc==SQLITE_OK && xOutput && buf.nBuf>=sessions_strm_chunk_size ){
197700 rc = xOutput(pOut, buf.aBuf, buf.nBuf);
197701 buf.nBuf = 0;
197702 }
197703 }
197704 }
 
 
 
 
 
197705 }
197706
197707 if( rc==SQLITE_OK ){
197708 if( xOutput ){
197709 if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
@@ -196868,11 +198090,11 @@
198090 if( bDone==0 ){
198091 sessionAppendByte(&sOut, pIter->op, &rc);
198092 sessionAppendByte(&sOut, pIter->bIndirect, &rc);
198093 sessionAppendBlob(&sOut, aRec, nRec, &rc);
198094 }
198095 if( rc==SQLITE_OK && xOutput && sOut.nBuf>sessions_strm_chunk_size ){
198096 rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
198097 sOut.nBuf = 0;
198098 }
198099 if( rc ) break;
198100 }
@@ -196978,10 +198200,31 @@
198200 if( p ){
198201 sessionDeleteTable(p->grp.pList);
198202 sqlite3_free(p);
198203 }
198204 }
198205
198206 /*
198207 ** Global configuration
198208 */
198209 SQLITE_API int sqlite3session_config(int op, void *pArg){
198210 int rc = SQLITE_OK;
198211 switch( op ){
198212 case SQLITE_SESSION_CONFIG_STRMSIZE: {
198213 int *pInt = (int*)pArg;
198214 if( *pInt>0 ){
198215 sessions_strm_chunk_size = *pInt;
198216 }
198217 *pInt = sessions_strm_chunk_size;
198218 break;
198219 }
198220 default:
198221 rc = SQLITE_MISUSE;
198222 break;
198223 }
198224 return rc;
198225 }
198226
198227 #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
198228
198229 /************** End of sqlite3session.c **************************************/
198230 /************** Begin file fts5.c ********************************************/
@@ -210693,11 +211936,11 @@
211936 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
211937 pRet = 0;
211938 fts5CloseReader(p);
211939 }
211940
211941 *ppIter = (Fts5IndexIter*)pRet;
211942 sqlite3Fts5BufferFree(&buf);
211943 }
211944 return fts5IndexReturn(p);
211945 }
211946
@@ -214442,16 +215685,31 @@
215685 int nArg, /* Number of args */
215686 sqlite3_value **apUnused /* Function arguments */
215687 ){
215688 assert( nArg==0 );
215689 UNUSED_PARAM2(nArg, apUnused);
215690 sqlite3_result_text(pCtx, "fts5: 2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513", -1, SQLITE_TRANSIENT);
215691 }
215692
215693 /*
215694 ** Return true if zName is the extension on one of the shadow tables used
215695 ** by this module.
215696 */
215697 static int fts5ShadowName(const char *zName){
215698 static const char *azName[] = {
215699 "config", "content", "data", "docsize", "idx"
215700 };
215701 unsigned int i;
215702 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
215703 if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;
215704 }
215705 return 0;
215706 }
215707
215708 static int fts5Init(sqlite3 *db){
215709 static const sqlite3_module fts5Mod = {
215710 /* iVersion */ 3,
215711 /* xCreate */ fts5CreateMethod,
215712 /* xConnect */ fts5ConnectMethod,
215713 /* xBestIndex */ fts5BestIndexMethod,
215714 /* xDisconnect */ fts5DisconnectMethod,
215715 /* xDestroy */ fts5DestroyMethod,
@@ -214470,10 +215728,11 @@
215728 /* xFindFunction */ fts5FindFunctionMethod,
215729 /* xRename */ fts5RenameMethod,
215730 /* xSavepoint */ fts5SavepointMethod,
215731 /* xRelease */ fts5ReleaseMethod,
215732 /* xRollbackTo */ fts5RollbackToMethod,
215733 /* xShadowName */ fts5ShadowName
215734 };
215735
215736 int rc;
215737 Fts5Global *pGlobal = 0;
215738
@@ -218514,20 +219773,22 @@
219773 int rc = SQLITE_OK;
219774 Fts5IndexIter *pIter = pCsr->pIter;
219775 i64 *pp = &pCsr->iInstPos;
219776 int *po = &pCsr->iInstOff;
219777
219778 assert( sqlite3Fts5IterEof(pIter)==0 );
219779 assert( pCsr->bEof==0 );
219780 while( eDetail==FTS5_DETAIL_NONE
219781 || sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp)
219782 ){
219783 pCsr->iInstPos = 0;
219784 pCsr->iInstOff = 0;
219785
219786 rc = sqlite3Fts5IterNextScan(pCsr->pIter);
219787 if( rc==SQLITE_OK ){
219788 rc = fts5VocabInstanceNewTerm(pCsr);
219789 if( pCsr->bEof || eDetail==FTS5_DETAIL_NONE ) break;
219790 }
219791 if( rc ){
219792 pCsr->bEof = 1;
219793 break;
219794 }
@@ -218838,17 +220099,16 @@
220099 /* xFindFunction */ 0,
220100 /* xRename */ 0,
220101 /* xSavepoint */ 0,
220102 /* xRelease */ 0,
220103 /* xRollbackTo */ 0,
220104 /* xShadowName */ 0
220105 };
220106 void *p = (void*)pGlobal;
220107
220108 return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0);
220109 }
 
 
220110
220111
220112
220113 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */
220114
@@ -219120,10 +220380,11 @@
220380 0, /* xFindMethod */
220381 0, /* xRename */
220382 0, /* xSavepoint */
220383 0, /* xRelease */
220384 0, /* xRollbackTo */
220385 0, /* xShadowName */
220386 };
220387
220388 #endif /* SQLITE_OMIT_VIRTUALTABLE */
220389
220390 SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
@@ -219152,12 +220413,12 @@
220413 }
220414 #endif /* SQLITE_CORE */
220415 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
220416
220417 /************** End of stmt.c ************************************************/
220418 #if __LINE__!=220418
220419 #undef SQLITE_SOURCE_ID
220420 #define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a04035alt2"
220421 #endif
220422 /* Return the source-id for this library */
220423 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
220424 /************************** End of sqlite3.c ******************************/
220425
+128 -11
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121121
**
122122
** See also: [sqlite3_libversion()],
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126
-#define SQLITE_VERSION "3.25.2"
127
-#define SQLITE_VERSION_NUMBER 3025002
128
-#define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7"
126
+#define SQLITE_VERSION "3.26.0"
127
+#define SQLITE_VERSION_NUMBER 3026000
128
+#define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -2015,10 +2015,11 @@
20152015
** the call worked. ^The [sqlite3_db_config()] interface will return a
20162016
** non-zero [error code] if a discontinued or unsupported configuration option
20172017
** is invoked.
20182018
**
20192019
** <dl>
2020
+** [[SQLITE_DBCONFIG_LOOKASIDE]]
20202021
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
20212022
** <dd> ^This option takes three additional arguments that determine the
20222023
** [lookaside memory allocator] configuration for the [database connection].
20232024
** ^The first argument (the third parameter to [sqlite3_db_config()] is a
20242025
** pointer to a memory buffer to use for lookaside memory.
@@ -2037,10 +2038,11 @@
20372038
** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
20382039
** Any attempt to change the lookaside memory configuration when lookaside
20392040
** memory is in use leaves the configuration unchanged and returns
20402041
** [SQLITE_BUSY].)^</dd>
20412042
**
2043
+** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
20422044
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
20432045
** <dd> ^This option is used to enable or disable the enforcement of
20442046
** [foreign key constraints]. There should be two additional arguments.
20452047
** The first argument is an integer which is 0 to disable FK enforcement,
20462048
** positive to enable FK enforcement or negative to leave FK enforcement
@@ -2047,10 +2049,11 @@
20472049
** unchanged. The second parameter is a pointer to an integer into which
20482050
** is written 0 or 1 to indicate whether FK enforcement is off or on
20492051
** following this call. The second parameter may be a NULL pointer, in
20502052
** which case the FK enforcement setting is not reported back. </dd>
20512053
**
2054
+** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]
20522055
** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
20532056
** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
20542057
** There should be two additional arguments.
20552058
** The first argument is an integer which is 0 to disable triggers,
20562059
** positive to enable triggers or negative to leave the setting unchanged.
@@ -2057,10 +2060,11 @@
20572060
** The second parameter is a pointer to an integer into which
20582061
** is written 0 or 1 to indicate whether triggers are disabled or enabled
20592062
** following this call. The second parameter may be a NULL pointer, in
20602063
** which case the trigger setting is not reported back. </dd>
20612064
**
2065
+** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
20622066
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
20632067
** <dd> ^This option is used to enable or disable the two-argument
20642068
** version of the [fts3_tokenizer()] function which is part of the
20652069
** [FTS3] full-text search engine extension.
20662070
** There should be two additional arguments.
@@ -2070,10 +2074,11 @@
20702074
** The second parameter is a pointer to an integer into which
20712075
** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
20722076
** following this call. The second parameter may be a NULL pointer, in
20732077
** which case the new setting is not reported back. </dd>
20742078
**
2079
+** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]
20752080
** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
20762081
** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
20772082
** interface independently of the [load_extension()] SQL function.
20782083
** The [sqlite3_enable_load_extension()] API enables or disables both the
20792084
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -2087,19 +2092,20 @@
20872092
** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
20882093
** is disabled or enabled following this call. The second parameter may
20892094
** be a NULL pointer, in which case the new setting is not reported back.
20902095
** </dd>
20912096
**
2092
-** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2097
+** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
20932098
** <dd> ^This option is used to change the name of the "main" database
20942099
** schema. ^The sole argument is a pointer to a constant UTF8 string
20952100
** which will become the new schema name in place of "main". ^SQLite
20962101
** does not make a copy of the new main schema name string, so the application
20972102
** must ensure that the argument passed into this DBCONFIG option is unchanged
20982103
** until after the database connection closes.
20992104
** </dd>
21002105
**
2106
+** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
21012107
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
21022108
** <dd> Usually, when a database in wal mode is closed or detached from a
21032109
** database handle, SQLite checks if this will mean that there are now no
21042110
** connections at all to the database. If so, it performs a checkpoint
21052111
** operation before closing the connection. This option may be used to
@@ -2109,11 +2115,11 @@
21092115
** The second parameter is a pointer to an integer
21102116
** into which is written 0 or 1 to indicate whether checkpoints-on-close
21112117
** have been disabled - 0 if they are not disabled, 1 if they are.
21122118
** </dd>
21132119
**
2114
-** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2120
+** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
21152121
** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
21162122
** the [query planner stability guarantee] (QPSG). When the QPSG is active,
21172123
** a single SQL query statement will always use the same algorithm regardless
21182124
** of values of [bound parameters].)^ The QPSG disables some query optimizations
21192125
** that look at the values of bound parameters, which can make some queries
@@ -2125,11 +2131,11 @@
21252131
** unchanged. The second parameter is a pointer to an integer into which
21262132
** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
21272133
** following this call.
21282134
** </dd>
21292135
**
2130
-** <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
2136
+** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
21312137
** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
21322138
** include output for any operations performed by trigger programs. This
21332139
** option is used to set or clear (the default) a flag that governs this
21342140
** behavior. The first parameter passed to this operation is an integer -
21352141
** positive to enable output for trigger programs, or zero to disable it,
@@ -2137,11 +2143,11 @@
21372143
** The second parameter is a pointer to an integer into which is written
21382144
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
21392145
** it is not disabled, 1 if it is.
21402146
** </dd>
21412147
**
2142
-** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
2148
+** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
21432149
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
21442150
** [VACUUM] in order to reset a database back to an empty database
21452151
** with no schema and no content. The following process works even for
21462152
** a badly corrupted database file:
21472153
** <ol>
@@ -2156,10 +2162,22 @@
21562162
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
21572163
** </ol>
21582164
** Because resetting a database is destructive and irreversible, the
21592165
** process requires the use of this obscure API and multiple steps to help
21602166
** ensure that it does not happen by accident.
2167
+**
2168
+** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
2169
+** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
2170
+** "defensive" flag for a database connection. When the defensive
2171
+** flag is enabled, language features that allow ordinary SQL to
2172
+** deliberately corrupt the database file are disabled. The disabled
2173
+** features include but are not limited to the following:
2174
+** <ul>
2175
+** <li> The [PRAGMA writable_schema=ON] statement.
2176
+** <li> Writes to the [sqlite_dbpage] virtual table.
2177
+** <li> Direct writes to [shadow tables].
2178
+** </ul>
21612179
** </dd>
21622180
** </dl>
21632181
*/
21642182
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
21652183
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2169,11 +2187,12 @@
21692187
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
21702188
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
21712189
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
21722190
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
21732191
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
2174
-#define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
2192
+#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2193
+#define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
21752194
21762195
/*
21772196
** CAPI3REF: Enable Or Disable Extended Result Codes
21782197
** METHOD: sqlite3
21792198
**
@@ -3607,13 +3626,23 @@
36073626
** be used just once or at most a few times and then destroyed using
36083627
** [sqlite3_finalize()] relatively soon. The current implementation acts
36093628
** on this hint by avoiding the use of [lookaside memory] so as not to
36103629
** deplete the limited store of lookaside memory. Future versions of
36113630
** SQLite may act on this hint differently.
3631
+**
3632
+** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
3633
+** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
3634
+** representation of the SQL statement should be calculated and then
3635
+** associated with the prepared statement, which can be obtained via
3636
+** the [sqlite3_normalized_sql()] interface. The semantics used to
3637
+** normalize a SQL statement are unspecified and subject to change.
3638
+** At a minimum, literal values will be replaced with suitable
3639
+** placeholders.
36123640
** </dl>
36133641
*/
36143642
#define SQLITE_PREPARE_PERSISTENT 0x01
3643
+#define SQLITE_PREPARE_NORMALIZE 0x02
36153644
36163645
/*
36173646
** CAPI3REF: Compiling An SQL Statement
36183647
** KEYWORDS: {SQL statement compiler}
36193648
** METHOD: sqlite3
@@ -3767,10 +3796,15 @@
37673796
** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
37683797
** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
37693798
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
37703799
** string containing the SQL text of prepared statement P with
37713800
** [bound parameters] expanded.
3801
+** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8
3802
+** string containing the normalized SQL text of prepared statement P. The
3803
+** semantics used to normalize a SQL statement are unspecified and subject
3804
+** to change. At a minimum, literal values will be replaced with suitable
3805
+** placeholders.
37723806
**
37733807
** ^(For example, if a prepared statement is created using the SQL
37743808
** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
37753809
** and parameter :xyz is unbound, then sqlite3_sql() will return
37763810
** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -3782,18 +3816,20 @@
37823816
**
37833817
** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
37843818
** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
37853819
** option causes sqlite3_expanded_sql() to always return NULL.
37863820
**
3787
-** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3788
-** automatically freed when the prepared statement is finalized.
3821
+** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
3822
+** are managed by SQLite and are automatically freed when the prepared
3823
+** statement is finalized.
37893824
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
37903825
** is obtained from [sqlite3_malloc()] and must be free by the application
37913826
** by passing it to [sqlite3_free()].
37923827
*/
37933828
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
37943829
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3830
+SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
37953831
37963832
/*
37973833
** CAPI3REF: Determine If An SQL Statement Writes The Database
37983834
** METHOD: sqlite3_stmt
37993835
**
@@ -6279,10 +6315,13 @@
62796315
/* The methods above are in version 1 of the sqlite_module object. Those
62806316
** below are for version 2 and greater. */
62816317
int (*xSavepoint)(sqlite3_vtab *pVTab, int);
62826318
int (*xRelease)(sqlite3_vtab *pVTab, int);
62836319
int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
6320
+ /* The methods above are in versions 1 and 2 of the sqlite_module object.
6321
+ ** Those below are for version 3 and greater. */
6322
+ int (*xShadowName)(const char*);
62846323
};
62856324
62866325
/*
62876326
** CAPI3REF: Virtual Table Indexing Information
62886327
** KEYWORDS: sqlite3_index_info
@@ -8613,10 +8652,11 @@
86138652
** These macros define the various options to the
86148653
** [sqlite3_vtab_config()] interface that [virtual table] implementations
86158654
** can use to customize and optimize their behavior.
86168655
**
86178656
** <dl>
8657
+** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]
86188658
** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
86198659
** <dd>Calls of the form
86208660
** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
86218661
** where X is an integer. If X is zero, then the [virtual table] whose
86228662
** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -9878,16 +9918,42 @@
98789918
** an application iterates through a changeset using an iterator created by
98799919
** this function, all changes that relate to a single table are visited
98809920
** consecutively. There is no chance that the iterator will visit a change
98819921
** the applies to table X, then one for table Y, and then later on visit
98829922
** another change for table X.
9923
+**
9924
+** The behavior of sqlite3changeset_start_v2() and its streaming equivalent
9925
+** may be modified by passing a combination of
9926
+** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.
9927
+**
9928
+** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>
9929
+** and therefore subject to change.
98839930
*/
98849931
SQLITE_API int sqlite3changeset_start(
98859932
sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
98869933
int nChangeset, /* Size of changeset blob in bytes */
98879934
void *pChangeset /* Pointer to blob containing changeset */
98889935
);
9936
+SQLITE_API int sqlite3changeset_start_v2(
9937
+ sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
9938
+ int nChangeset, /* Size of changeset blob in bytes */
9939
+ void *pChangeset, /* Pointer to blob containing changeset */
9940
+ int flags /* SESSION_CHANGESETSTART_* flags */
9941
+);
9942
+
9943
+/*
9944
+** CAPI3REF: Flags for sqlite3changeset_start_v2
9945
+**
9946
+** The following flags may passed via the 4th parameter to
9947
+** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
9948
+**
9949
+** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
9950
+** Invert the changeset while iterating through it. This is equivalent to
9951
+** inverting a changeset using sqlite3changeset_invert() before applying it.
9952
+** It is an error to specify this flag with a patchset.
9953
+*/
9954
+#define SQLITE_CHANGESETSTART_INVERT 0x0002
98899955
98909956
98919957
/*
98929958
** CAPI3REF: Advance A Changeset Iterator
98939959
** METHOD: sqlite3_changeset_iter
@@ -10538,11 +10604,11 @@
1053810604
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1053910605
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1054010606
),
1054110607
void *pCtx, /* First argument passed to xConflict */
1054210608
void **ppRebase, int *pnRebase, /* OUT: Rebase data */
10543
- int flags /* Combination of SESSION_APPLY_* flags */
10609
+ int flags /* SESSION_CHANGESETAPPLY_* flags */
1054410610
);
1054510611
1054610612
/*
1054710613
** CAPI3REF: Flags for sqlite3changeset_apply_v2
1054810614
**
@@ -10556,12 +10622,18 @@
1055610622
** SAVEPOINT is committed if the changeset or patchset is successfully
1055710623
** applied, or rolled back if an error occurs. Specifying this flag
1055810624
** causes the sessions module to omit this savepoint. In this case, if the
1055910625
** caller has an open transaction or savepoint when apply_v2() is called,
1056010626
** it may revert the partially applied changeset by rolling it back.
10627
+**
10628
+** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
10629
+** Invert the changeset before applying it. This is equivalent to inverting
10630
+** a changeset using sqlite3changeset_invert() before applying it. It is
10631
+** an error to specify this flag with a patchset.
1056110632
*/
1056210633
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
10634
+#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
1056310635
1056410636
/*
1056510637
** CAPI3REF: Constants Passed To The Conflict Handler
1056610638
**
1056710639
** Values that may be passed as the second argument to a conflict-handler.
@@ -10950,10 +11022,16 @@
1095011022
);
1095111023
SQLITE_API int sqlite3changeset_start_strm(
1095211024
sqlite3_changeset_iter **pp,
1095311025
int (*xInput)(void *pIn, void *pData, int *pnData),
1095411026
void *pIn
11027
+);
11028
+SQLITE_API int sqlite3changeset_start_v2_strm(
11029
+ sqlite3_changeset_iter **pp,
11030
+ int (*xInput)(void *pIn, void *pData, int *pnData),
11031
+ void *pIn,
11032
+ int flags
1095511033
);
1095611034
SQLITE_API int sqlite3session_changeset_strm(
1095711035
sqlite3_session *pSession,
1095811036
int (*xOutput)(void *pOut, const void *pData, int nData),
1095911037
void *pOut
@@ -10977,10 +11055,49 @@
1097711055
void *pIn,
1097811056
int (*xOutput)(void *pOut, const void *pData, int nData),
1097911057
void *pOut
1098011058
);
1098111059
11060
+/*
11061
+** CAPI3REF: Configure global parameters
11062
+**
11063
+** The sqlite3session_config() interface is used to make global configuration
11064
+** changes to the sessions module in order to tune it to the specific needs
11065
+** of the application.
11066
+**
11067
+** The sqlite3session_config() interface is not threadsafe. If it is invoked
11068
+** while any other thread is inside any other sessions method then the
11069
+** results are undefined. Furthermore, if it is invoked after any sessions
11070
+** related objects have been created, the results are also undefined.
11071
+**
11072
+** The first argument to the sqlite3session_config() function must be one
11073
+** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The
11074
+** interpretation of the (void*) value passed as the second parameter and
11075
+** the effect of calling this function depends on the value of the first
11076
+** parameter.
11077
+**
11078
+** <dl>
11079
+** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>
11080
+** By default, the sessions module streaming interfaces attempt to input
11081
+** and output data in approximately 1 KiB chunks. This operand may be used
11082
+** to set and query the value of this configuration setting. The pointer
11083
+** passed as the second argument must point to a value of type (int).
11084
+** If this value is greater than 0, it is used as the new streaming data
11085
+** chunk size for both input and output. Before returning, the (int) value
11086
+** pointed to by pArg is set to the final value of the streaming interface
11087
+** chunk size.
11088
+** </dl>
11089
+**
11090
+** This function returns SQLITE_OK if successful, or an SQLite error code
11091
+** otherwise.
11092
+*/
11093
+SQLITE_API int sqlite3session_config(int op, void *pArg);
11094
+
11095
+/*
11096
+** CAPI3REF: Values for sqlite3session_config().
11097
+*/
11098
+#define SQLITE_SESSION_CONFIG_STRMSIZE 1
1098211099
1098311100
/*
1098411101
** Make sure we can call this stuff from C++.
1098511102
*/
1098611103
#ifdef __cplusplus
1098711104
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.25.2"
127 #define SQLITE_VERSION_NUMBER 3025002
128 #define SQLITE_SOURCE_ID "2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -2015,10 +2015,11 @@
2015 ** the call worked. ^The [sqlite3_db_config()] interface will return a
2016 ** non-zero [error code] if a discontinued or unsupported configuration option
2017 ** is invoked.
2018 **
2019 ** <dl>
 
2020 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2021 ** <dd> ^This option takes three additional arguments that determine the
2022 ** [lookaside memory allocator] configuration for the [database connection].
2023 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2024 ** pointer to a memory buffer to use for lookaside memory.
@@ -2037,10 +2038,11 @@
2037 ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
2038 ** Any attempt to change the lookaside memory configuration when lookaside
2039 ** memory is in use leaves the configuration unchanged and returns
2040 ** [SQLITE_BUSY].)^</dd>
2041 **
 
2042 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2043 ** <dd> ^This option is used to enable or disable the enforcement of
2044 ** [foreign key constraints]. There should be two additional arguments.
2045 ** The first argument is an integer which is 0 to disable FK enforcement,
2046 ** positive to enable FK enforcement or negative to leave FK enforcement
@@ -2047,10 +2049,11 @@
2047 ** unchanged. The second parameter is a pointer to an integer into which
2048 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2049 ** following this call. The second parameter may be a NULL pointer, in
2050 ** which case the FK enforcement setting is not reported back. </dd>
2051 **
 
2052 ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
2053 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
2054 ** There should be two additional arguments.
2055 ** The first argument is an integer which is 0 to disable triggers,
2056 ** positive to enable triggers or negative to leave the setting unchanged.
@@ -2057,10 +2060,11 @@
2057 ** The second parameter is a pointer to an integer into which
2058 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
2059 ** following this call. The second parameter may be a NULL pointer, in
2060 ** which case the trigger setting is not reported back. </dd>
2061 **
 
2062 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2063 ** <dd> ^This option is used to enable or disable the two-argument
2064 ** version of the [fts3_tokenizer()] function which is part of the
2065 ** [FTS3] full-text search engine extension.
2066 ** There should be two additional arguments.
@@ -2070,10 +2074,11 @@
2070 ** The second parameter is a pointer to an integer into which
2071 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
2072 ** following this call. The second parameter may be a NULL pointer, in
2073 ** which case the new setting is not reported back. </dd>
2074 **
 
2075 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2076 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2077 ** interface independently of the [load_extension()] SQL function.
2078 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2079 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -2087,19 +2092,20 @@
2087 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
2088 ** is disabled or enabled following this call. The second parameter may
2089 ** be a NULL pointer, in which case the new setting is not reported back.
2090 ** </dd>
2091 **
2092 ** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2093 ** <dd> ^This option is used to change the name of the "main" database
2094 ** schema. ^The sole argument is a pointer to a constant UTF8 string
2095 ** which will become the new schema name in place of "main". ^SQLite
2096 ** does not make a copy of the new main schema name string, so the application
2097 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2098 ** until after the database connection closes.
2099 ** </dd>
2100 **
 
2101 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2102 ** <dd> Usually, when a database in wal mode is closed or detached from a
2103 ** database handle, SQLite checks if this will mean that there are now no
2104 ** connections at all to the database. If so, it performs a checkpoint
2105 ** operation before closing the connection. This option may be used to
@@ -2109,11 +2115,11 @@
2109 ** The second parameter is a pointer to an integer
2110 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2111 ** have been disabled - 0 if they are not disabled, 1 if they are.
2112 ** </dd>
2113 **
2114 ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2115 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2116 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2117 ** a single SQL query statement will always use the same algorithm regardless
2118 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
2119 ** that look at the values of bound parameters, which can make some queries
@@ -2125,11 +2131,11 @@
2125 ** unchanged. The second parameter is a pointer to an integer into which
2126 ** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
2127 ** following this call.
2128 ** </dd>
2129 **
2130 ** <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
2131 ** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
2132 ** include output for any operations performed by trigger programs. This
2133 ** option is used to set or clear (the default) a flag that governs this
2134 ** behavior. The first parameter passed to this operation is an integer -
2135 ** positive to enable output for trigger programs, or zero to disable it,
@@ -2137,11 +2143,11 @@
2137 ** The second parameter is a pointer to an integer into which is written
2138 ** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
2139 ** it is not disabled, 1 if it is.
2140 ** </dd>
2141 **
2142 ** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
2143 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
2144 ** [VACUUM] in order to reset a database back to an empty database
2145 ** with no schema and no content. The following process works even for
2146 ** a badly corrupted database file:
2147 ** <ol>
@@ -2156,10 +2162,22 @@
2156 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
2157 ** </ol>
2158 ** Because resetting a database is destructive and irreversible, the
2159 ** process requires the use of this obscure API and multiple steps to help
2160 ** ensure that it does not happen by accident.
 
 
 
 
 
 
 
 
 
 
 
 
2161 ** </dd>
2162 ** </dl>
2163 */
2164 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2165 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2169,11 +2187,12 @@
2169 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2170 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2171 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2172 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
2173 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
2174 #define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
 
2175
2176 /*
2177 ** CAPI3REF: Enable Or Disable Extended Result Codes
2178 ** METHOD: sqlite3
2179 **
@@ -3607,13 +3626,23 @@
3607 ** be used just once or at most a few times and then destroyed using
3608 ** [sqlite3_finalize()] relatively soon. The current implementation acts
3609 ** on this hint by avoiding the use of [lookaside memory] so as not to
3610 ** deplete the limited store of lookaside memory. Future versions of
3611 ** SQLite may act on this hint differently.
 
 
 
 
 
 
 
 
 
3612 ** </dl>
3613 */
3614 #define SQLITE_PREPARE_PERSISTENT 0x01
 
3615
3616 /*
3617 ** CAPI3REF: Compiling An SQL Statement
3618 ** KEYWORDS: {SQL statement compiler}
3619 ** METHOD: sqlite3
@@ -3767,10 +3796,15 @@
3767 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3768 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3769 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3770 ** string containing the SQL text of prepared statement P with
3771 ** [bound parameters] expanded.
 
 
 
 
 
3772 **
3773 ** ^(For example, if a prepared statement is created using the SQL
3774 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3775 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3776 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -3782,18 +3816,20 @@
3782 **
3783 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3784 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3785 ** option causes sqlite3_expanded_sql() to always return NULL.
3786 **
3787 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
3788 ** automatically freed when the prepared statement is finalized.
 
3789 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3790 ** is obtained from [sqlite3_malloc()] and must be free by the application
3791 ** by passing it to [sqlite3_free()].
3792 */
3793 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3794 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
 
3795
3796 /*
3797 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3798 ** METHOD: sqlite3_stmt
3799 **
@@ -6279,10 +6315,13 @@
6279 /* The methods above are in version 1 of the sqlite_module object. Those
6280 ** below are for version 2 and greater. */
6281 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
6282 int (*xRelease)(sqlite3_vtab *pVTab, int);
6283 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
 
 
 
6284 };
6285
6286 /*
6287 ** CAPI3REF: Virtual Table Indexing Information
6288 ** KEYWORDS: sqlite3_index_info
@@ -8613,10 +8652,11 @@
8613 ** These macros define the various options to the
8614 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
8615 ** can use to customize and optimize their behavior.
8616 **
8617 ** <dl>
 
8618 ** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
8619 ** <dd>Calls of the form
8620 ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
8621 ** where X is an integer. If X is zero, then the [virtual table] whose
8622 ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -9878,16 +9918,42 @@
9878 ** an application iterates through a changeset using an iterator created by
9879 ** this function, all changes that relate to a single table are visited
9880 ** consecutively. There is no chance that the iterator will visit a change
9881 ** the applies to table X, then one for table Y, and then later on visit
9882 ** another change for table X.
 
 
 
 
 
 
 
9883 */
9884 SQLITE_API int sqlite3changeset_start(
9885 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
9886 int nChangeset, /* Size of changeset blob in bytes */
9887 void *pChangeset /* Pointer to blob containing changeset */
9888 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9889
9890
9891 /*
9892 ** CAPI3REF: Advance A Changeset Iterator
9893 ** METHOD: sqlite3_changeset_iter
@@ -10538,11 +10604,11 @@
10538 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
10539 sqlite3_changeset_iter *p /* Handle describing change and conflict */
10540 ),
10541 void *pCtx, /* First argument passed to xConflict */
10542 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
10543 int flags /* Combination of SESSION_APPLY_* flags */
10544 );
10545
10546 /*
10547 ** CAPI3REF: Flags for sqlite3changeset_apply_v2
10548 **
@@ -10556,12 +10622,18 @@
10556 ** SAVEPOINT is committed if the changeset or patchset is successfully
10557 ** applied, or rolled back if an error occurs. Specifying this flag
10558 ** causes the sessions module to omit this savepoint. In this case, if the
10559 ** caller has an open transaction or savepoint when apply_v2() is called,
10560 ** it may revert the partially applied changeset by rolling it back.
 
 
 
 
 
10561 */
10562 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
 
10563
10564 /*
10565 ** CAPI3REF: Constants Passed To The Conflict Handler
10566 **
10567 ** Values that may be passed as the second argument to a conflict-handler.
@@ -10950,10 +11022,16 @@
10950 );
10951 SQLITE_API int sqlite3changeset_start_strm(
10952 sqlite3_changeset_iter **pp,
10953 int (*xInput)(void *pIn, void *pData, int *pnData),
10954 void *pIn
 
 
 
 
 
 
10955 );
10956 SQLITE_API int sqlite3session_changeset_strm(
10957 sqlite3_session *pSession,
10958 int (*xOutput)(void *pOut, const void *pData, int nData),
10959 void *pOut
@@ -10977,10 +11055,49 @@
10977 void *pIn,
10978 int (*xOutput)(void *pOut, const void *pData, int nData),
10979 void *pOut
10980 );
10981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10982
10983 /*
10984 ** Make sure we can call this stuff from C++.
10985 */
10986 #ifdef __cplusplus
10987
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.26.0"
127 #define SQLITE_VERSION_NUMBER 3026000
128 #define SQLITE_SOURCE_ID "2018-11-12 15:20:44 f9755f81b1c0fd29f242dce78a2fba570fa2714d76e93b8563f426a040352513"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -2015,10 +2015,11 @@
2015 ** the call worked. ^The [sqlite3_db_config()] interface will return a
2016 ** non-zero [error code] if a discontinued or unsupported configuration option
2017 ** is invoked.
2018 **
2019 ** <dl>
2020 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2021 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2022 ** <dd> ^This option takes three additional arguments that determine the
2023 ** [lookaside memory allocator] configuration for the [database connection].
2024 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2025 ** pointer to a memory buffer to use for lookaside memory.
@@ -2037,10 +2038,11 @@
2038 ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
2039 ** Any attempt to change the lookaside memory configuration when lookaside
2040 ** memory is in use leaves the configuration unchanged and returns
2041 ** [SQLITE_BUSY].)^</dd>
2042 **
2043 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2044 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2045 ** <dd> ^This option is used to enable or disable the enforcement of
2046 ** [foreign key constraints]. There should be two additional arguments.
2047 ** The first argument is an integer which is 0 to disable FK enforcement,
2048 ** positive to enable FK enforcement or negative to leave FK enforcement
@@ -2047,10 +2049,11 @@
2049 ** unchanged. The second parameter is a pointer to an integer into which
2050 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2051 ** following this call. The second parameter may be a NULL pointer, in
2052 ** which case the FK enforcement setting is not reported back. </dd>
2053 **
2054 ** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]
2055 ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
2056 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
2057 ** There should be two additional arguments.
2058 ** The first argument is an integer which is 0 to disable triggers,
2059 ** positive to enable triggers or negative to leave the setting unchanged.
@@ -2057,10 +2060,11 @@
2060 ** The second parameter is a pointer to an integer into which
2061 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
2062 ** following this call. The second parameter may be a NULL pointer, in
2063 ** which case the trigger setting is not reported back. </dd>
2064 **
2065 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2066 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2067 ** <dd> ^This option is used to enable or disable the two-argument
2068 ** version of the [fts3_tokenizer()] function which is part of the
2069 ** [FTS3] full-text search engine extension.
2070 ** There should be two additional arguments.
@@ -2070,10 +2074,11 @@
2074 ** The second parameter is a pointer to an integer into which
2075 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
2076 ** following this call. The second parameter may be a NULL pointer, in
2077 ** which case the new setting is not reported back. </dd>
2078 **
2079 ** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]
2080 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2081 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2082 ** interface independently of the [load_extension()] SQL function.
2083 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2084 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
@@ -2087,19 +2092,20 @@
2092 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
2093 ** is disabled or enabled following this call. The second parameter may
2094 ** be a NULL pointer, in which case the new setting is not reported back.
2095 ** </dd>
2096 **
2097 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2098 ** <dd> ^This option is used to change the name of the "main" database
2099 ** schema. ^The sole argument is a pointer to a constant UTF8 string
2100 ** which will become the new schema name in place of "main". ^SQLite
2101 ** does not make a copy of the new main schema name string, so the application
2102 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2103 ** until after the database connection closes.
2104 ** </dd>
2105 **
2106 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2107 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2108 ** <dd> Usually, when a database in wal mode is closed or detached from a
2109 ** database handle, SQLite checks if this will mean that there are now no
2110 ** connections at all to the database. If so, it performs a checkpoint
2111 ** operation before closing the connection. This option may be used to
@@ -2109,11 +2115,11 @@
2115 ** The second parameter is a pointer to an integer
2116 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2117 ** have been disabled - 0 if they are not disabled, 1 if they are.
2118 ** </dd>
2119 **
2120 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
2121 ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
2122 ** the [query planner stability guarantee] (QPSG). When the QPSG is active,
2123 ** a single SQL query statement will always use the same algorithm regardless
2124 ** of values of [bound parameters].)^ The QPSG disables some query optimizations
2125 ** that look at the values of bound parameters, which can make some queries
@@ -2125,11 +2131,11 @@
2131 ** unchanged. The second parameter is a pointer to an integer into which
2132 ** is written 0 or 1 to indicate whether the QPSG is disabled or enabled
2133 ** following this call.
2134 ** </dd>
2135 **
2136 ** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
2137 ** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
2138 ** include output for any operations performed by trigger programs. This
2139 ** option is used to set or clear (the default) a flag that governs this
2140 ** behavior. The first parameter passed to this operation is an integer -
2141 ** positive to enable output for trigger programs, or zero to disable it,
@@ -2137,11 +2143,11 @@
2143 ** The second parameter is a pointer to an integer into which is written
2144 ** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
2145 ** it is not disabled, 1 if it is.
2146 ** </dd>
2147 **
2148 ** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
2149 ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
2150 ** [VACUUM] in order to reset a database back to an empty database
2151 ** with no schema and no content. The following process works even for
2152 ** a badly corrupted database file:
2153 ** <ol>
@@ -2156,10 +2162,22 @@
2162 ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
2163 ** </ol>
2164 ** Because resetting a database is destructive and irreversible, the
2165 ** process requires the use of this obscure API and multiple steps to help
2166 ** ensure that it does not happen by accident.
2167 **
2168 ** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
2169 ** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
2170 ** "defensive" flag for a database connection. When the defensive
2171 ** flag is enabled, language features that allow ordinary SQL to
2172 ** deliberately corrupt the database file are disabled. The disabled
2173 ** features include but are not limited to the following:
2174 ** <ul>
2175 ** <li> The [PRAGMA writable_schema=ON] statement.
2176 ** <li> Writes to the [sqlite_dbpage] virtual table.
2177 ** <li> Direct writes to [shadow tables].
2178 ** </ul>
2179 ** </dd>
2180 ** </dl>
2181 */
2182 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2183 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2169,11 +2187,12 @@
2187 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
2188 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2189 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2190 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
2191 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
2192 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2193 #define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
2194
2195 /*
2196 ** CAPI3REF: Enable Or Disable Extended Result Codes
2197 ** METHOD: sqlite3
2198 **
@@ -3607,13 +3626,23 @@
3626 ** be used just once or at most a few times and then destroyed using
3627 ** [sqlite3_finalize()] relatively soon. The current implementation acts
3628 ** on this hint by avoiding the use of [lookaside memory] so as not to
3629 ** deplete the limited store of lookaside memory. Future versions of
3630 ** SQLite may act on this hint differently.
3631 **
3632 ** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
3633 ** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
3634 ** representation of the SQL statement should be calculated and then
3635 ** associated with the prepared statement, which can be obtained via
3636 ** the [sqlite3_normalized_sql()] interface. The semantics used to
3637 ** normalize a SQL statement are unspecified and subject to change.
3638 ** At a minimum, literal values will be replaced with suitable
3639 ** placeholders.
3640 ** </dl>
3641 */
3642 #define SQLITE_PREPARE_PERSISTENT 0x01
3643 #define SQLITE_PREPARE_NORMALIZE 0x02
3644
3645 /*
3646 ** CAPI3REF: Compiling An SQL Statement
3647 ** KEYWORDS: {SQL statement compiler}
3648 ** METHOD: sqlite3
@@ -3767,10 +3796,15 @@
3796 ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],
3797 ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].
3798 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
3799 ** string containing the SQL text of prepared statement P with
3800 ** [bound parameters] expanded.
3801 ** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8
3802 ** string containing the normalized SQL text of prepared statement P. The
3803 ** semantics used to normalize a SQL statement are unspecified and subject
3804 ** to change. At a minimum, literal values will be replaced with suitable
3805 ** placeholders.
3806 **
3807 ** ^(For example, if a prepared statement is created using the SQL
3808 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
3809 ** and parameter :xyz is unbound, then sqlite3_sql() will return
3810 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
@@ -3782,18 +3816,20 @@
3816 **
3817 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
3818 ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
3819 ** option causes sqlite3_expanded_sql() to always return NULL.
3820 **
3821 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
3822 ** are managed by SQLite and are automatically freed when the prepared
3823 ** statement is finalized.
3824 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
3825 ** is obtained from [sqlite3_malloc()] and must be free by the application
3826 ** by passing it to [sqlite3_free()].
3827 */
3828 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3829 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
3830 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
3831
3832 /*
3833 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3834 ** METHOD: sqlite3_stmt
3835 **
@@ -6279,10 +6315,13 @@
6315 /* The methods above are in version 1 of the sqlite_module object. Those
6316 ** below are for version 2 and greater. */
6317 int (*xSavepoint)(sqlite3_vtab *pVTab, int);
6318 int (*xRelease)(sqlite3_vtab *pVTab, int);
6319 int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
6320 /* The methods above are in versions 1 and 2 of the sqlite_module object.
6321 ** Those below are for version 3 and greater. */
6322 int (*xShadowName)(const char*);
6323 };
6324
6325 /*
6326 ** CAPI3REF: Virtual Table Indexing Information
6327 ** KEYWORDS: sqlite3_index_info
@@ -8613,10 +8652,11 @@
8652 ** These macros define the various options to the
8653 ** [sqlite3_vtab_config()] interface that [virtual table] implementations
8654 ** can use to customize and optimize their behavior.
8655 **
8656 ** <dl>
8657 ** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]
8658 ** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
8659 ** <dd>Calls of the form
8660 ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
8661 ** where X is an integer. If X is zero, then the [virtual table] whose
8662 ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
@@ -9878,16 +9918,42 @@
9918 ** an application iterates through a changeset using an iterator created by
9919 ** this function, all changes that relate to a single table are visited
9920 ** consecutively. There is no chance that the iterator will visit a change
9921 ** the applies to table X, then one for table Y, and then later on visit
9922 ** another change for table X.
9923 **
9924 ** The behavior of sqlite3changeset_start_v2() and its streaming equivalent
9925 ** may be modified by passing a combination of
9926 ** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.
9927 **
9928 ** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>
9929 ** and therefore subject to change.
9930 */
9931 SQLITE_API int sqlite3changeset_start(
9932 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
9933 int nChangeset, /* Size of changeset blob in bytes */
9934 void *pChangeset /* Pointer to blob containing changeset */
9935 );
9936 SQLITE_API int sqlite3changeset_start_v2(
9937 sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
9938 int nChangeset, /* Size of changeset blob in bytes */
9939 void *pChangeset, /* Pointer to blob containing changeset */
9940 int flags /* SESSION_CHANGESETSTART_* flags */
9941 );
9942
9943 /*
9944 ** CAPI3REF: Flags for sqlite3changeset_start_v2
9945 **
9946 ** The following flags may passed via the 4th parameter to
9947 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
9948 **
9949 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
9950 ** Invert the changeset while iterating through it. This is equivalent to
9951 ** inverting a changeset using sqlite3changeset_invert() before applying it.
9952 ** It is an error to specify this flag with a patchset.
9953 */
9954 #define SQLITE_CHANGESETSTART_INVERT 0x0002
9955
9956
9957 /*
9958 ** CAPI3REF: Advance A Changeset Iterator
9959 ** METHOD: sqlite3_changeset_iter
@@ -10538,11 +10604,11 @@
10604 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
10605 sqlite3_changeset_iter *p /* Handle describing change and conflict */
10606 ),
10607 void *pCtx, /* First argument passed to xConflict */
10608 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
10609 int flags /* SESSION_CHANGESETAPPLY_* flags */
10610 );
10611
10612 /*
10613 ** CAPI3REF: Flags for sqlite3changeset_apply_v2
10614 **
@@ -10556,12 +10622,18 @@
10622 ** SAVEPOINT is committed if the changeset or patchset is successfully
10623 ** applied, or rolled back if an error occurs. Specifying this flag
10624 ** causes the sessions module to omit this savepoint. In this case, if the
10625 ** caller has an open transaction or savepoint when apply_v2() is called,
10626 ** it may revert the partially applied changeset by rolling it back.
10627 **
10628 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
10629 ** Invert the changeset before applying it. This is equivalent to inverting
10630 ** a changeset using sqlite3changeset_invert() before applying it. It is
10631 ** an error to specify this flag with a patchset.
10632 */
10633 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
10634 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
10635
10636 /*
10637 ** CAPI3REF: Constants Passed To The Conflict Handler
10638 **
10639 ** Values that may be passed as the second argument to a conflict-handler.
@@ -10950,10 +11022,16 @@
11022 );
11023 SQLITE_API int sqlite3changeset_start_strm(
11024 sqlite3_changeset_iter **pp,
11025 int (*xInput)(void *pIn, void *pData, int *pnData),
11026 void *pIn
11027 );
11028 SQLITE_API int sqlite3changeset_start_v2_strm(
11029 sqlite3_changeset_iter **pp,
11030 int (*xInput)(void *pIn, void *pData, int *pnData),
11031 void *pIn,
11032 int flags
11033 );
11034 SQLITE_API int sqlite3session_changeset_strm(
11035 sqlite3_session *pSession,
11036 int (*xOutput)(void *pOut, const void *pData, int nData),
11037 void *pOut
@@ -10977,10 +11055,49 @@
11055 void *pIn,
11056 int (*xOutput)(void *pOut, const void *pData, int nData),
11057 void *pOut
11058 );
11059
11060 /*
11061 ** CAPI3REF: Configure global parameters
11062 **
11063 ** The sqlite3session_config() interface is used to make global configuration
11064 ** changes to the sessions module in order to tune it to the specific needs
11065 ** of the application.
11066 **
11067 ** The sqlite3session_config() interface is not threadsafe. If it is invoked
11068 ** while any other thread is inside any other sessions method then the
11069 ** results are undefined. Furthermore, if it is invoked after any sessions
11070 ** related objects have been created, the results are also undefined.
11071 **
11072 ** The first argument to the sqlite3session_config() function must be one
11073 ** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The
11074 ** interpretation of the (void*) value passed as the second parameter and
11075 ** the effect of calling this function depends on the value of the first
11076 ** parameter.
11077 **
11078 ** <dl>
11079 ** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>
11080 ** By default, the sessions module streaming interfaces attempt to input
11081 ** and output data in approximately 1 KiB chunks. This operand may be used
11082 ** to set and query the value of this configuration setting. The pointer
11083 ** passed as the second argument must point to a value of type (int).
11084 ** If this value is greater than 0, it is used as the new streaming data
11085 ** chunk size for both input and output. Before returning, the (int) value
11086 ** pointed to by pArg is set to the final value of the streaming interface
11087 ** chunk size.
11088 ** </dl>
11089 **
11090 ** This function returns SQLITE_OK if successful, or an SQLite error code
11091 ** otherwise.
11092 */
11093 SQLITE_API int sqlite3session_config(int op, void *pArg);
11094
11095 /*
11096 ** CAPI3REF: Values for sqlite3session_config().
11097 */
11098 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
11099
11100 /*
11101 ** Make sure we can call this stuff from C++.
11102 */
11103 #ifdef __cplusplus
11104
+10 -4
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,13 +28,13 @@
2828
2929
SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB
3030
3131
SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
3232
33
-SRC = add_.c alerts_.c allrepo_.c attach_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c webmail_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
33
+SRC = add_.c alerts_.c allrepo_.c attach_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c webmail_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
3434
35
-OBJ = $(OBJDIR)\add$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\webmail$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
35
+OBJ = $(OBJDIR)\add$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\webmail$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
3636
3737
3838
RC=$(DMDIR)\bin\rcc
3939
RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
4040
@@ -49,11 +49,11 @@
4949
5050
$(OBJDIR)\fossil.res: $B\win\fossil.rc
5151
$(RC) $(RCFLAGS) -o$@ $**
5252
5353
$(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54
- +echo add alerts allrepo attach backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi checkin checkout clearsign clone comformat configure content cookies db delta deltacmd descendants diff diffcmd dispatch doc encode etag event export file finfo foci forum fshell fusefs glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile webmail wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
54
+ +echo add alerts allrepo attach backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi checkin checkout clearsign clone comformat configure content cookies db delta deltacmd descendants diff diffcmd dispatch doc encode etag event export file finfo foci forum fshell fusefs glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile webmail wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
5555
+echo fossil >> $@
5656
+echo fossil >> $@
5757
+echo $(LIBS) >> $@
5858
+echo. >> $@
5959
+echo fossil >> $@
@@ -668,10 +668,16 @@
668668
$(OBJDIR)\regexp$O : regexp_.c regexp.h
669669
$(TCC) -o$@ -c regexp_.c
670670
671671
regexp_.c : $(SRCDIR)\regexp.c
672672
+translate$E $** > $@
673
+
674
+$(OBJDIR)\repolist$O : repolist_.c repolist.h
675
+ $(TCC) -o$@ -c repolist_.c
676
+
677
+repolist_.c : $(SRCDIR)\repolist.c
678
+ +translate$E $** > $@
673679
674680
$(OBJDIR)\report$O : report_.c report.h
675681
$(TCC) -o$@ -c report_.c
676682
677683
report_.c : $(SRCDIR)\report.c
@@ -940,7 +946,7 @@
940946
941947
zip_.c : $(SRCDIR)\zip.c
942948
+translate$E $** > $@
943949
944950
headers: makeheaders$E page_index.h builtin_data.h default_css.h VERSION.h
945
- +makeheaders$E add_.c:add.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h webmail_.c:webmail.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
951
+ +makeheaders$E add_.c:add.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h webmail_.c:webmail.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
946952
@copy /Y nul: headers
947953
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,13 +28,13 @@
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB
30
31 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c alerts_.c allrepo_.c attach_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c webmail_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35 OBJ = $(OBJDIR)\add$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\webmail$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
36
37
38 RC=$(DMDIR)\bin\rcc
39 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
40
@@ -49,11 +49,11 @@
49
50 $(OBJDIR)\fossil.res: $B\win\fossil.rc
51 $(RC) $(RCFLAGS) -o$@ $**
52
53 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54 +echo add alerts allrepo attach backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi checkin checkout clearsign clone comformat configure content cookies db delta deltacmd descendants diff diffcmd dispatch doc encode etag event export file finfo foci forum fshell fusefs glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile webmail wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
55 +echo fossil >> $@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
@@ -668,10 +668,16 @@
668 $(OBJDIR)\regexp$O : regexp_.c regexp.h
669 $(TCC) -o$@ -c regexp_.c
670
671 regexp_.c : $(SRCDIR)\regexp.c
672 +translate$E $** > $@
 
 
 
 
 
 
673
674 $(OBJDIR)\report$O : report_.c report.h
675 $(TCC) -o$@ -c report_.c
676
677 report_.c : $(SRCDIR)\report.c
@@ -940,7 +946,7 @@
940
941 zip_.c : $(SRCDIR)\zip.c
942 +translate$E $** > $@
943
944 headers: makeheaders$E page_index.h builtin_data.h default_css.h VERSION.h
945 +makeheaders$E add_.c:add.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h webmail_.c:webmail.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
946 @copy /Y nul: headers
947
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,13 +28,13 @@
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB
30
31 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c alerts_.c allrepo_.c attach_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c webmail_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35 OBJ = $(OBJDIR)\add$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\webmail$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
36
37
38 RC=$(DMDIR)\bin\rcc
39 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
40
@@ -49,11 +49,11 @@
49
50 $(OBJDIR)\fossil.res: $B\win\fossil.rc
51 $(RC) $(RCFLAGS) -o$@ $**
52
53 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54 +echo add alerts allrepo attach backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi checkin checkout clearsign clone comformat configure content cookies db delta deltacmd descendants diff diffcmd dispatch doc encode etag event export file finfo foci forum fshell fusefs glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile webmail wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
55 +echo fossil >> $@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
@@ -668,10 +668,16 @@
668 $(OBJDIR)\regexp$O : regexp_.c regexp.h
669 $(TCC) -o$@ -c regexp_.c
670
671 regexp_.c : $(SRCDIR)\regexp.c
672 +translate$E $** > $@
673
674 $(OBJDIR)\repolist$O : repolist_.c repolist.h
675 $(TCC) -o$@ -c repolist_.c
676
677 repolist_.c : $(SRCDIR)\repolist.c
678 +translate$E $** > $@
679
680 $(OBJDIR)\report$O : report_.c report.h
681 $(TCC) -o$@ -c report_.c
682
683 report_.c : $(SRCDIR)\report.c
@@ -940,7 +946,7 @@
946
947 zip_.c : $(SRCDIR)\zip.c
948 +translate$E $** > $@
949
950 headers: makeheaders$E page_index.h builtin_data.h default_css.h VERSION.h
951 +makeheaders$E add_.c:add.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h webmail_.c:webmail.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
952 @copy /Y nul: headers
953
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -526,10 +526,11 @@
526526
$(SRCDIR)/printf.c \
527527
$(SRCDIR)/publish.c \
528528
$(SRCDIR)/purge.c \
529529
$(SRCDIR)/rebuild.c \
530530
$(SRCDIR)/regexp.c \
531
+ $(SRCDIR)/repolist.c \
531532
$(SRCDIR)/report.c \
532533
$(SRCDIR)/rss.c \
533534
$(SRCDIR)/schema.c \
534535
$(SRCDIR)/search.c \
535536
$(SRCDIR)/security_audit.c \
@@ -736,10 +737,11 @@
736737
$(OBJDIR)/printf_.c \
737738
$(OBJDIR)/publish_.c \
738739
$(OBJDIR)/purge_.c \
739740
$(OBJDIR)/rebuild_.c \
740741
$(OBJDIR)/regexp_.c \
742
+ $(OBJDIR)/repolist_.c \
741743
$(OBJDIR)/report_.c \
742744
$(OBJDIR)/rss_.c \
743745
$(OBJDIR)/schema_.c \
744746
$(OBJDIR)/search_.c \
745747
$(OBJDIR)/security_audit_.c \
@@ -873,10 +875,11 @@
873875
$(OBJDIR)/printf.o \
874876
$(OBJDIR)/publish.o \
875877
$(OBJDIR)/purge.o \
876878
$(OBJDIR)/rebuild.o \
877879
$(OBJDIR)/regexp.o \
880
+ $(OBJDIR)/repolist.o \
878881
$(OBJDIR)/report.o \
879882
$(OBJDIR)/rss.o \
880883
$(OBJDIR)/schema.o \
881884
$(OBJDIR)/search.o \
882885
$(OBJDIR)/security_audit.o \
@@ -1229,10 +1232,11 @@
12291232
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
12301233
$(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
12311234
$(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
12321235
$(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
12331236
$(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
1237
+ $(OBJDIR)/repolist_.c:$(OBJDIR)/repolist.h \
12341238
$(OBJDIR)/report_.c:$(OBJDIR)/report.h \
12351239
$(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
12361240
$(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
12371241
$(OBJDIR)/search_.c:$(OBJDIR)/search.h \
12381242
$(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -2002,10 +2006,18 @@
20022006
20032007
$(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
20042008
$(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
20052009
20062010
$(OBJDIR)/regexp.h: $(OBJDIR)/headers
2011
+
2012
+$(OBJDIR)/repolist_.c: $(SRCDIR)/repolist.c $(TRANSLATE)
2013
+ $(TRANSLATE) $(SRCDIR)/repolist.c >$@
2014
+
2015
+$(OBJDIR)/repolist.o: $(OBJDIR)/repolist_.c $(OBJDIR)/repolist.h $(SRCDIR)/config.h
2016
+ $(XTCC) -o $(OBJDIR)/repolist.o -c $(OBJDIR)/repolist_.c
2017
+
2018
+$(OBJDIR)/repolist.h: $(OBJDIR)/headers
20072019
20082020
$(OBJDIR)/report_.c: $(SRCDIR)/report.c $(TRANSLATE)
20092021
$(TRANSLATE) $(SRCDIR)/report.c >$@
20102022
20112023
$(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
20122024
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -526,10 +526,11 @@
526 $(SRCDIR)/printf.c \
527 $(SRCDIR)/publish.c \
528 $(SRCDIR)/purge.c \
529 $(SRCDIR)/rebuild.c \
530 $(SRCDIR)/regexp.c \
 
531 $(SRCDIR)/report.c \
532 $(SRCDIR)/rss.c \
533 $(SRCDIR)/schema.c \
534 $(SRCDIR)/search.c \
535 $(SRCDIR)/security_audit.c \
@@ -736,10 +737,11 @@
736 $(OBJDIR)/printf_.c \
737 $(OBJDIR)/publish_.c \
738 $(OBJDIR)/purge_.c \
739 $(OBJDIR)/rebuild_.c \
740 $(OBJDIR)/regexp_.c \
 
741 $(OBJDIR)/report_.c \
742 $(OBJDIR)/rss_.c \
743 $(OBJDIR)/schema_.c \
744 $(OBJDIR)/search_.c \
745 $(OBJDIR)/security_audit_.c \
@@ -873,10 +875,11 @@
873 $(OBJDIR)/printf.o \
874 $(OBJDIR)/publish.o \
875 $(OBJDIR)/purge.o \
876 $(OBJDIR)/rebuild.o \
877 $(OBJDIR)/regexp.o \
 
878 $(OBJDIR)/report.o \
879 $(OBJDIR)/rss.o \
880 $(OBJDIR)/schema.o \
881 $(OBJDIR)/search.o \
882 $(OBJDIR)/security_audit.o \
@@ -1229,10 +1232,11 @@
1229 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1230 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
1231 $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
1232 $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
1233 $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
 
1234 $(OBJDIR)/report_.c:$(OBJDIR)/report.h \
1235 $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
1236 $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
1237 $(OBJDIR)/search_.c:$(OBJDIR)/search.h \
1238 $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -2002,10 +2006,18 @@
2002
2003 $(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
2004 $(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
2005
2006 $(OBJDIR)/regexp.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
2007
2008 $(OBJDIR)/report_.c: $(SRCDIR)/report.c $(TRANSLATE)
2009 $(TRANSLATE) $(SRCDIR)/report.c >$@
2010
2011 $(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
2012
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -526,10 +526,11 @@
526 $(SRCDIR)/printf.c \
527 $(SRCDIR)/publish.c \
528 $(SRCDIR)/purge.c \
529 $(SRCDIR)/rebuild.c \
530 $(SRCDIR)/regexp.c \
531 $(SRCDIR)/repolist.c \
532 $(SRCDIR)/report.c \
533 $(SRCDIR)/rss.c \
534 $(SRCDIR)/schema.c \
535 $(SRCDIR)/search.c \
536 $(SRCDIR)/security_audit.c \
@@ -736,10 +737,11 @@
737 $(OBJDIR)/printf_.c \
738 $(OBJDIR)/publish_.c \
739 $(OBJDIR)/purge_.c \
740 $(OBJDIR)/rebuild_.c \
741 $(OBJDIR)/regexp_.c \
742 $(OBJDIR)/repolist_.c \
743 $(OBJDIR)/report_.c \
744 $(OBJDIR)/rss_.c \
745 $(OBJDIR)/schema_.c \
746 $(OBJDIR)/search_.c \
747 $(OBJDIR)/security_audit_.c \
@@ -873,10 +875,11 @@
875 $(OBJDIR)/printf.o \
876 $(OBJDIR)/publish.o \
877 $(OBJDIR)/purge.o \
878 $(OBJDIR)/rebuild.o \
879 $(OBJDIR)/regexp.o \
880 $(OBJDIR)/repolist.o \
881 $(OBJDIR)/report.o \
882 $(OBJDIR)/rss.o \
883 $(OBJDIR)/schema.o \
884 $(OBJDIR)/search.o \
885 $(OBJDIR)/security_audit.o \
@@ -1229,10 +1232,11 @@
1232 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1233 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
1234 $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \
1235 $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
1236 $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
1237 $(OBJDIR)/repolist_.c:$(OBJDIR)/repolist.h \
1238 $(OBJDIR)/report_.c:$(OBJDIR)/report.h \
1239 $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
1240 $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
1241 $(OBJDIR)/search_.c:$(OBJDIR)/search.h \
1242 $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \
@@ -2002,10 +2006,18 @@
2006
2007 $(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
2008 $(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
2009
2010 $(OBJDIR)/regexp.h: $(OBJDIR)/headers
2011
2012 $(OBJDIR)/repolist_.c: $(SRCDIR)/repolist.c $(TRANSLATE)
2013 $(TRANSLATE) $(SRCDIR)/repolist.c >$@
2014
2015 $(OBJDIR)/repolist.o: $(OBJDIR)/repolist_.c $(OBJDIR)/repolist.h $(SRCDIR)/config.h
2016 $(XTCC) -o $(OBJDIR)/repolist.o -c $(OBJDIR)/repolist_.c
2017
2018 $(OBJDIR)/repolist.h: $(OBJDIR)/headers
2019
2020 $(OBJDIR)/report_.c: $(SRCDIR)/report.c $(TRANSLATE)
2021 $(TRANSLATE) $(SRCDIR)/report.c >$@
2022
2023 $(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
2024
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -466,10 +466,11 @@
466466
printf_.c \
467467
publish_.c \
468468
purge_.c \
469469
rebuild_.c \
470470
regexp_.c \
471
+ repolist_.c \
471472
report_.c \
472473
rss_.c \
473474
schema_.c \
474475
search_.c \
475476
security_audit_.c \
@@ -675,10 +676,11 @@
675676
$(OX)\printf$O \
676677
$(OX)\publish$O \
677678
$(OX)\purge$O \
678679
$(OX)\rebuild$O \
679680
$(OX)\regexp$O \
681
+ $(OX)\repolist$O \
680682
$(OX)\report$O \
681683
$(OX)\rss$O \
682684
$(OX)\schema$O \
683685
$(OX)\search$O \
684686
$(OX)\security_audit$O \
@@ -871,10 +873,11 @@
871873
echo $(OX)\printf.obj >> $@
872874
echo $(OX)\publish.obj >> $@
873875
echo $(OX)\purge.obj >> $@
874876
echo $(OX)\rebuild.obj >> $@
875877
echo $(OX)\regexp.obj >> $@
878
+ echo $(OX)\repolist.obj >> $@
876879
echo $(OX)\report.obj >> $@
877880
echo $(OX)\rss.obj >> $@
878881
echo $(OX)\schema.obj >> $@
879882
echo $(OX)\search.obj >> $@
880883
echo $(OX)\security_audit.obj >> $@
@@ -1578,10 +1581,16 @@
15781581
$(OX)\regexp$O : regexp_.c regexp.h
15791582
$(TCC) /Fo$@ -c regexp_.c
15801583
15811584
regexp_.c : $(SRCDIR)\regexp.c
15821585
translate$E $** > $@
1586
+
1587
+$(OX)\repolist$O : repolist_.c repolist.h
1588
+ $(TCC) /Fo$@ -c repolist_.c
1589
+
1590
+repolist_.c : $(SRCDIR)\repolist.c
1591
+ translate$E $** > $@
15831592
15841593
$(OX)\report$O : report_.c report.h
15851594
$(TCC) /Fo$@ -c report_.c
15861595
15871596
report_.c : $(SRCDIR)\report.c
@@ -1943,10 +1952,11 @@
19431952
printf_.c:printf.h \
19441953
publish_.c:publish.h \
19451954
purge_.c:purge.h \
19461955
rebuild_.c:rebuild.h \
19471956
regexp_.c:regexp.h \
1957
+ repolist_.c:repolist.h \
19481958
report_.c:report.h \
19491959
rss_.c:rss.h \
19501960
schema_.c:schema.h \
19511961
search_.c:search.h \
19521962
security_audit_.c:security_audit.h \
19531963
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -466,10 +466,11 @@
466 printf_.c \
467 publish_.c \
468 purge_.c \
469 rebuild_.c \
470 regexp_.c \
 
471 report_.c \
472 rss_.c \
473 schema_.c \
474 search_.c \
475 security_audit_.c \
@@ -675,10 +676,11 @@
675 $(OX)\printf$O \
676 $(OX)\publish$O \
677 $(OX)\purge$O \
678 $(OX)\rebuild$O \
679 $(OX)\regexp$O \
 
680 $(OX)\report$O \
681 $(OX)\rss$O \
682 $(OX)\schema$O \
683 $(OX)\search$O \
684 $(OX)\security_audit$O \
@@ -871,10 +873,11 @@
871 echo $(OX)\printf.obj >> $@
872 echo $(OX)\publish.obj >> $@
873 echo $(OX)\purge.obj >> $@
874 echo $(OX)\rebuild.obj >> $@
875 echo $(OX)\regexp.obj >> $@
 
876 echo $(OX)\report.obj >> $@
877 echo $(OX)\rss.obj >> $@
878 echo $(OX)\schema.obj >> $@
879 echo $(OX)\search.obj >> $@
880 echo $(OX)\security_audit.obj >> $@
@@ -1578,10 +1581,16 @@
1578 $(OX)\regexp$O : regexp_.c regexp.h
1579 $(TCC) /Fo$@ -c regexp_.c
1580
1581 regexp_.c : $(SRCDIR)\regexp.c
1582 translate$E $** > $@
 
 
 
 
 
 
1583
1584 $(OX)\report$O : report_.c report.h
1585 $(TCC) /Fo$@ -c report_.c
1586
1587 report_.c : $(SRCDIR)\report.c
@@ -1943,10 +1952,11 @@
1943 printf_.c:printf.h \
1944 publish_.c:publish.h \
1945 purge_.c:purge.h \
1946 rebuild_.c:rebuild.h \
1947 regexp_.c:regexp.h \
 
1948 report_.c:report.h \
1949 rss_.c:rss.h \
1950 schema_.c:schema.h \
1951 search_.c:search.h \
1952 security_audit_.c:security_audit.h \
1953
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -466,10 +466,11 @@
466 printf_.c \
467 publish_.c \
468 purge_.c \
469 rebuild_.c \
470 regexp_.c \
471 repolist_.c \
472 report_.c \
473 rss_.c \
474 schema_.c \
475 search_.c \
476 security_audit_.c \
@@ -675,10 +676,11 @@
676 $(OX)\printf$O \
677 $(OX)\publish$O \
678 $(OX)\purge$O \
679 $(OX)\rebuild$O \
680 $(OX)\regexp$O \
681 $(OX)\repolist$O \
682 $(OX)\report$O \
683 $(OX)\rss$O \
684 $(OX)\schema$O \
685 $(OX)\search$O \
686 $(OX)\security_audit$O \
@@ -871,10 +873,11 @@
873 echo $(OX)\printf.obj >> $@
874 echo $(OX)\publish.obj >> $@
875 echo $(OX)\purge.obj >> $@
876 echo $(OX)\rebuild.obj >> $@
877 echo $(OX)\regexp.obj >> $@
878 echo $(OX)\repolist.obj >> $@
879 echo $(OX)\report.obj >> $@
880 echo $(OX)\rss.obj >> $@
881 echo $(OX)\schema.obj >> $@
882 echo $(OX)\search.obj >> $@
883 echo $(OX)\security_audit.obj >> $@
@@ -1578,10 +1581,16 @@
1581 $(OX)\regexp$O : regexp_.c regexp.h
1582 $(TCC) /Fo$@ -c regexp_.c
1583
1584 regexp_.c : $(SRCDIR)\regexp.c
1585 translate$E $** > $@
1586
1587 $(OX)\repolist$O : repolist_.c repolist.h
1588 $(TCC) /Fo$@ -c repolist_.c
1589
1590 repolist_.c : $(SRCDIR)\repolist.c
1591 translate$E $** > $@
1592
1593 $(OX)\report$O : report_.c report.h
1594 $(TCC) /Fo$@ -c report_.c
1595
1596 report_.c : $(SRCDIR)\report.c
@@ -1943,10 +1952,11 @@
1952 printf_.c:printf.h \
1953 publish_.c:publish.h \
1954 purge_.c:purge.h \
1955 rebuild_.c:rebuild.h \
1956 regexp_.c:regexp.h \
1957 repolist_.c:repolist.h \
1958 report_.c:report.h \
1959 rss_.c:rss.h \
1960 schema_.c:schema.h \
1961 search_.c:search.h \
1962 security_audit_.c:security_audit.h \
1963
+6 -6
--- www/grep.md
+++ www/grep.md
@@ -70,25 +70,25 @@
7070
| `(X)` | match X
7171
| <tt>X\|Y</tt>| X or Y
7272
| `^X` | X occurring at the beginning of a line
7373
| `X$` | X occurring at the end of a line
7474
| `.` | Match any single character
75
-| `\c` | Character `c` where `c` is one of <tt>{}()[]\|\*+?.</tt>
75
+| `\c` | Character `c` where `c` is one of <tt>{}()[]\|\*+?.\\</tt>
7676
| `\c` | C-language escapes for `c` in `afnrtv`. ex: `\t` or `\n`
7777
| `\uXXXX`| Where XXXX is exactly 4 hex digits, Unicode value XXXX
7878
| `\xXX` | Where XX is exactly 2 hex digits, Unicode value XX
7979
| `[abc]` | Any single character from the set `abc`
8080
| `[^abc]`| Any single character not in the set `abc`
8181
| `[a-z]` | Any single character in the range `a-z`
8282
| `[^a-z]`| Any single character not in the range `a-z`
8383
| `\b` | Word boundary
8484
| `\w` | Word character: `[A-Za-z0-9_]`
85
-| `\W` | Non-word character
86
-| `\d` | Digit
87
-| `\D` | Non-digit
88
-| `\s` | Whitespace character
89
-| `\S` | Non-whitespace character
85
+| `\W` | Non-word character: `[^A-Za-z0-9_]`
86
+| `\d` | Digit: `[0-9]`
87
+| `\D` | Non-digit: `[^0-9]`
88
+| `\s` | Whitespace character: `[ \t\r\n\v\f]`
89
+| `\S` | Non-whitespace character: `[^ \t\r\n\v\f]`
9090
9191
There are several restrictions in Fossil `grep` relative to a fully
9292
POSIX compatible regular expression engine. Among them are:
9393
9494
* There is currently no support for POSIX character classes such as
9595
--- www/grep.md
+++ www/grep.md
@@ -70,25 +70,25 @@
70 | `(X)` | match X
71 | <tt>X\|Y</tt>| X or Y
72 | `^X` | X occurring at the beginning of a line
73 | `X$` | X occurring at the end of a line
74 | `.` | Match any single character
75 | `\c` | Character `c` where `c` is one of <tt>{}()[]\|\*+?.</tt>
76 | `\c` | C-language escapes for `c` in `afnrtv`. ex: `\t` or `\n`
77 | `\uXXXX`| Where XXXX is exactly 4 hex digits, Unicode value XXXX
78 | `\xXX` | Where XX is exactly 2 hex digits, Unicode value XX
79 | `[abc]` | Any single character from the set `abc`
80 | `[^abc]`| Any single character not in the set `abc`
81 | `[a-z]` | Any single character in the range `a-z`
82 | `[^a-z]`| Any single character not in the range `a-z`
83 | `\b` | Word boundary
84 | `\w` | Word character: `[A-Za-z0-9_]`
85 | `\W` | Non-word character
86 | `\d` | Digit
87 | `\D` | Non-digit
88 | `\s` | Whitespace character
89 | `\S` | Non-whitespace character
90
91 There are several restrictions in Fossil `grep` relative to a fully
92 POSIX compatible regular expression engine. Among them are:
93
94 * There is currently no support for POSIX character classes such as
95
--- www/grep.md
+++ www/grep.md
@@ -70,25 +70,25 @@
70 | `(X)` | match X
71 | <tt>X\|Y</tt>| X or Y
72 | `^X` | X occurring at the beginning of a line
73 | `X$` | X occurring at the end of a line
74 | `.` | Match any single character
75 | `\c` | Character `c` where `c` is one of <tt>{}()[]\|\*+?.\\</tt>
76 | `\c` | C-language escapes for `c` in `afnrtv`. ex: `\t` or `\n`
77 | `\uXXXX`| Where XXXX is exactly 4 hex digits, Unicode value XXXX
78 | `\xXX` | Where XX is exactly 2 hex digits, Unicode value XX
79 | `[abc]` | Any single character from the set `abc`
80 | `[^abc]`| Any single character not in the set `abc`
81 | `[a-z]` | Any single character in the range `a-z`
82 | `[^a-z]`| Any single character not in the range `a-z`
83 | `\b` | Word boundary
84 | `\w` | Word character: `[A-Za-z0-9_]`
85 | `\W` | Non-word character: `[^A-Za-z0-9_]`
86 | `\d` | Digit: `[0-9]`
87 | `\D` | Non-digit: `[^0-9]`
88 | `\s` | Whitespace character: `[ \t\r\n\v\f]`
89 | `\S` | Non-whitespace character: `[^ \t\r\n\v\f]`
90
91 There are several restrictions in Fossil `grep` relative to a fully
92 POSIX compatible regular expression engine. Among them are:
93
94 * There is currently no support for POSIX character classes such as
95
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -42,10 +42,11 @@
4242
forum.wiki {Fossil Forums}
4343
foss-cklist.wiki {Checklist For Successful Open-Source Projects}
4444
fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
4545
fossil-v-git.wiki {Fossil Versus Git}
4646
globs.md {File Name Glob Patterns}
47
+ grep.md {Fossil grep vs POSIX grep}
4748
hacker-howto.wiki {Hacker How-To}
4849
hashpolicy.wiki {Hash Policy: Choosing Between SHA1 and SHA3-256}
4950
/help {Lists of Commands and Webpages}
5051
hints.wiki {Fossil Tips And Usage Hints}
5152
index.wiki {Home Page}
5253
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -42,10 +42,11 @@
42 forum.wiki {Fossil Forums}
43 foss-cklist.wiki {Checklist For Successful Open-Source Projects}
44 fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
45 fossil-v-git.wiki {Fossil Versus Git}
46 globs.md {File Name Glob Patterns}
 
47 hacker-howto.wiki {Hacker How-To}
48 hashpolicy.wiki {Hash Policy: Choosing Between SHA1 and SHA3-256}
49 /help {Lists of Commands and Webpages}
50 hints.wiki {Fossil Tips And Usage Hints}
51 index.wiki {Home Page}
52
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -42,10 +42,11 @@
42 forum.wiki {Fossil Forums}
43 foss-cklist.wiki {Checklist For Successful Open-Source Projects}
44 fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
45 fossil-v-git.wiki {Fossil Versus Git}
46 globs.md {File Name Glob Patterns}
47 grep.md {Fossil grep vs POSIX grep}
48 hacker-howto.wiki {Hacker How-To}
49 hashpolicy.wiki {Hash Policy: Choosing Between SHA1 and SHA3-256}
50 /help {Lists of Commands and Webpages}
51 hints.wiki {Fossil Tips And Usage Hints}
52 index.wiki {Home Page}
53
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -106,10 +106,11 @@
106106
<li><a href="concepts.wiki"><b>Fossil Core Concepts</b></a></li>
107107
<li><a href="delta_encoder_algorithm.wiki"><b>Fossil Delta Encoding Algorithm</b></a></li>
108108
<li><a href="delta_format.wiki"><b>Fossil Delta Format</b></a></li>
109109
<li><a href="fileformat.wiki"><b>Fossil File Format</b></a></li>
110110
<li><a href="forum.wiki"><b>Fossil Forums</b></a></li>
111
+<li><a href="grep.md"><b>Fossil grep vs POSIX grep</b></a></li>
111112
<li><a href="quickstart.wiki"><b>Fossil Quick Start Guide</b></a></li>
112113
<li><a href="selfcheck.wiki"><b>Fossil Repository Integrity Self Checks</b></a></li>
113114
<li><a href="selfhost.wiki"><b>Fossil Self Hosting Repositories</b></a></li>
114115
<li><a href="settings.wiki"><b>Fossil Settings</b></a></li>
115116
<li><a href="hints.wiki"><b>Fossil Tips And Usage Hints</b></a></li>
@@ -121,10 +122,12 @@
121122
<li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
122123
<li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
123124
<li><a href="globs.md">Glob Patterns &mdash; File Name</a></li>
124125
<li><a href="env-opts.md">Global Options &mdash; Environment Variables and</a></li>
125126
<li><a href="customgraph.md">Graph &mdash; Theming: Customizing the Timeline</a></li>
127
+<li><a href="grep.md">grep &mdash; Fossil grep vs POSIX</a></li>
128
+<li><a href="grep.md">grep vs POSIX grep &mdash; Fossil</a></li>
126129
<li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
127130
<li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
128131
<li><a href="hacker-howto.wiki"><b>Hacker How-To</b></a></li>
129132
<li><a href="adding_code.wiki"><b>Hacking Fossil</b></a></li>
130133
<li><a href="hashpolicy.wiki"><b>Hash Policy: Choosing Between SHA1 and SHA3-256</b></a></li>
@@ -169,10 +172,11 @@
169172
<li><a href="password.wiki"><b>Password Management And Authentication</b></a></li>
170173
<li><a href="globs.md">Patterns &mdash; File Name Glob</a></li>
171174
<li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes: What</a></li>
172175
<li><a href="stats.wiki"><b>Performance Statistics</b></a></li>
173176
<li><a href="hashpolicy.wiki">Policy: Choosing Between SHA1 and SHA3-256 &mdash; Hash</a></li>
177
+<li><a href="grep.md">POSIX grep &mdash; Fossil grep vs</a></li>
174178
<li><a href="../test/release-checklist.wiki"><b>Pre-Release Testing Checklist</b></a></li>
175179
<li><a href="pop.wiki"><b>Principles Of Operation</b></a></li>
176180
<li><a href="private.wiki">Private Branches &mdash; Creating, Syncing, and Deleting</a></li>
177181
<li><a href="makefile.wiki">Process &mdash; The Fossil Build</a></li>
178182
<li><a href="contribute.wiki">Project &mdash; Contributing Code or Documentation To The Fossil</a></li>
@@ -242,10 +246,11 @@
242246
<li><a href="ssl.wiki"><b>Using SSL with Fossil</b></a></li>
243247
<li><a href="env-opts.md">Variables and Global Options &mdash; Environment</a></li>
244248
<li><a href="whyusefossil.wiki">Version Control &mdash; Benefits Of</a></li>
245249
<li><a href="checkin_names.wiki">Version Names &mdash; Check-in And</a></li>
246250
<li><a href="fossil-v-git.wiki">Versus Git &mdash; Fossil</a></li>
251
+<li><a href="grep.md">vs POSIX grep &mdash; Fossil grep</a></li>
247252
<li><a href="webui.wiki">Web Interface &mdash; The Fossil</a></li>
248253
<li><a href="customskin.md">Web Pages &mdash; Theming: Customizing The Appearance of</a></li>
249254
<li><a href="webpage-ex.md"><b>Webpage Examples</b></a></li>
250255
<li><a href="../../../help">Webpages &mdash; Lists of Commands and</a></li>
251256
<li><a href="quotes.wiki">What People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes:</a></li>
252257
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -106,10 +106,11 @@
106 <li><a href="concepts.wiki"><b>Fossil Core Concepts</b></a></li>
107 <li><a href="delta_encoder_algorithm.wiki"><b>Fossil Delta Encoding Algorithm</b></a></li>
108 <li><a href="delta_format.wiki"><b>Fossil Delta Format</b></a></li>
109 <li><a href="fileformat.wiki"><b>Fossil File Format</b></a></li>
110 <li><a href="forum.wiki"><b>Fossil Forums</b></a></li>
 
111 <li><a href="quickstart.wiki"><b>Fossil Quick Start Guide</b></a></li>
112 <li><a href="selfcheck.wiki"><b>Fossil Repository Integrity Self Checks</b></a></li>
113 <li><a href="selfhost.wiki"><b>Fossil Self Hosting Repositories</b></a></li>
114 <li><a href="settings.wiki"><b>Fossil Settings</b></a></li>
115 <li><a href="hints.wiki"><b>Fossil Tips And Usage Hints</b></a></li>
@@ -121,10 +122,12 @@
121 <li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
122 <li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
123 <li><a href="globs.md">Glob Patterns &mdash; File Name</a></li>
124 <li><a href="env-opts.md">Global Options &mdash; Environment Variables and</a></li>
125 <li><a href="customgraph.md">Graph &mdash; Theming: Customizing the Timeline</a></li>
 
 
126 <li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
127 <li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
128 <li><a href="hacker-howto.wiki"><b>Hacker How-To</b></a></li>
129 <li><a href="adding_code.wiki"><b>Hacking Fossil</b></a></li>
130 <li><a href="hashpolicy.wiki"><b>Hash Policy: Choosing Between SHA1 and SHA3-256</b></a></li>
@@ -169,10 +172,11 @@
169 <li><a href="password.wiki"><b>Password Management And Authentication</b></a></li>
170 <li><a href="globs.md">Patterns &mdash; File Name Glob</a></li>
171 <li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes: What</a></li>
172 <li><a href="stats.wiki"><b>Performance Statistics</b></a></li>
173 <li><a href="hashpolicy.wiki">Policy: Choosing Between SHA1 and SHA3-256 &mdash; Hash</a></li>
 
174 <li><a href="../test/release-checklist.wiki"><b>Pre-Release Testing Checklist</b></a></li>
175 <li><a href="pop.wiki"><b>Principles Of Operation</b></a></li>
176 <li><a href="private.wiki">Private Branches &mdash; Creating, Syncing, and Deleting</a></li>
177 <li><a href="makefile.wiki">Process &mdash; The Fossil Build</a></li>
178 <li><a href="contribute.wiki">Project &mdash; Contributing Code or Documentation To The Fossil</a></li>
@@ -242,10 +246,11 @@
242 <li><a href="ssl.wiki"><b>Using SSL with Fossil</b></a></li>
243 <li><a href="env-opts.md">Variables and Global Options &mdash; Environment</a></li>
244 <li><a href="whyusefossil.wiki">Version Control &mdash; Benefits Of</a></li>
245 <li><a href="checkin_names.wiki">Version Names &mdash; Check-in And</a></li>
246 <li><a href="fossil-v-git.wiki">Versus Git &mdash; Fossil</a></li>
 
247 <li><a href="webui.wiki">Web Interface &mdash; The Fossil</a></li>
248 <li><a href="customskin.md">Web Pages &mdash; Theming: Customizing The Appearance of</a></li>
249 <li><a href="webpage-ex.md"><b>Webpage Examples</b></a></li>
250 <li><a href="../../../help">Webpages &mdash; Lists of Commands and</a></li>
251 <li><a href="quotes.wiki">What People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes:</a></li>
252
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -106,10 +106,11 @@
106 <li><a href="concepts.wiki"><b>Fossil Core Concepts</b></a></li>
107 <li><a href="delta_encoder_algorithm.wiki"><b>Fossil Delta Encoding Algorithm</b></a></li>
108 <li><a href="delta_format.wiki"><b>Fossil Delta Format</b></a></li>
109 <li><a href="fileformat.wiki"><b>Fossil File Format</b></a></li>
110 <li><a href="forum.wiki"><b>Fossil Forums</b></a></li>
111 <li><a href="grep.md"><b>Fossil grep vs POSIX grep</b></a></li>
112 <li><a href="quickstart.wiki"><b>Fossil Quick Start Guide</b></a></li>
113 <li><a href="selfcheck.wiki"><b>Fossil Repository Integrity Self Checks</b></a></li>
114 <li><a href="selfhost.wiki"><b>Fossil Self Hosting Repositories</b></a></li>
115 <li><a href="settings.wiki"><b>Fossil Settings</b></a></li>
116 <li><a href="hints.wiki"><b>Fossil Tips And Usage Hints</b></a></li>
@@ -121,10 +122,12 @@
122 <li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
123 <li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
124 <li><a href="globs.md">Glob Patterns &mdash; File Name</a></li>
125 <li><a href="env-opts.md">Global Options &mdash; Environment Variables and</a></li>
126 <li><a href="customgraph.md">Graph &mdash; Theming: Customizing the Timeline</a></li>
127 <li><a href="grep.md">grep &mdash; Fossil grep vs POSIX</a></li>
128 <li><a href="grep.md">grep vs POSIX grep &mdash; Fossil</a></li>
129 <li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
130 <li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
131 <li><a href="hacker-howto.wiki"><b>Hacker How-To</b></a></li>
132 <li><a href="adding_code.wiki"><b>Hacking Fossil</b></a></li>
133 <li><a href="hashpolicy.wiki"><b>Hash Policy: Choosing Between SHA1 and SHA3-256</b></a></li>
@@ -169,10 +172,11 @@
172 <li><a href="password.wiki"><b>Password Management And Authentication</b></a></li>
173 <li><a href="globs.md">Patterns &mdash; File Name Glob</a></li>
174 <li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes: What</a></li>
175 <li><a href="stats.wiki"><b>Performance Statistics</b></a></li>
176 <li><a href="hashpolicy.wiki">Policy: Choosing Between SHA1 and SHA3-256 &mdash; Hash</a></li>
177 <li><a href="grep.md">POSIX grep &mdash; Fossil grep vs</a></li>
178 <li><a href="../test/release-checklist.wiki"><b>Pre-Release Testing Checklist</b></a></li>
179 <li><a href="pop.wiki"><b>Principles Of Operation</b></a></li>
180 <li><a href="private.wiki">Private Branches &mdash; Creating, Syncing, and Deleting</a></li>
181 <li><a href="makefile.wiki">Process &mdash; The Fossil Build</a></li>
182 <li><a href="contribute.wiki">Project &mdash; Contributing Code or Documentation To The Fossil</a></li>
@@ -242,10 +246,11 @@
246 <li><a href="ssl.wiki"><b>Using SSL with Fossil</b></a></li>
247 <li><a href="env-opts.md">Variables and Global Options &mdash; Environment</a></li>
248 <li><a href="whyusefossil.wiki">Version Control &mdash; Benefits Of</a></li>
249 <li><a href="checkin_names.wiki">Version Names &mdash; Check-in And</a></li>
250 <li><a href="fossil-v-git.wiki">Versus Git &mdash; Fossil</a></li>
251 <li><a href="grep.md">vs POSIX grep &mdash; Fossil grep</a></li>
252 <li><a href="webui.wiki">Web Interface &mdash; The Fossil</a></li>
253 <li><a href="customskin.md">Web Pages &mdash; Theming: Customizing The Appearance of</a></li>
254 <li><a href="webpage-ex.md"><b>Webpage Examples</b></a></li>
255 <li><a href="../../../help">Webpages &mdash; Lists of Commands and</a></li>
256 <li><a href="quotes.wiki">What People Are Saying About Fossil, Git, and DVCSes in General &mdash; Quotes:</a></li>
257

Keyboard Shortcuts

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