Fossil SCM

Backed out merge - it included an unintented change :/.

stephan 2020-01-03 14:30 mistake
Commit 070d6ea103280c5a4eb7bb69224e0d89b86ce4886c159085335cf30f3e9e8282
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -803,16 +803,10 @@
803803
}
804804
td.browser,
805805
td.tktDescLabel {
806806
vertical-align: top
807807
}
808
-td.tktTlOpen {
809
- color: #ffa0a0;
810
-}
811
-td.tktTlClosed {
812
- color: #555;
813
-}
814808
div.filetreeline {
815809
display: table;
816810
width: 100%;
817811
white-space: nowrap
818812
}
819813
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -803,16 +803,10 @@
803 }
804 td.browser,
805 td.tktDescLabel {
806 vertical-align: top
807 }
808 td.tktTlOpen {
809 color: #ffa0a0;
810 }
811 td.tktTlClosed {
812 color: #555;
813 }
814 div.filetreeline {
815 display: table;
816 width: 100%;
817 white-space: nowrap
818 }
819
--- skins/ardoise/css.txt
+++ skins/ardoise/css.txt
@@ -803,16 +803,10 @@
803 }
804 td.browser,
805 td.tktDescLabel {
806 vertical-align: top
807 }
 
 
 
 
 
 
808 div.filetreeline {
809 display: table;
810 width: 100%;
811 white-space: nowrap
812 }
813
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -289,18 +289,10 @@
289289
text-align: left;
290290
vertical-align: top;
291291
background-color: #485D7B;
292292
}
293293
294
-/* Ticket display on timelines */
295
-td.tktTlOpen {
296
- color: #ffc0c0;
297
-}
298
-td.tktTlClose {
299
- color: #c0c0c0;
300
-}
301
-
302294
/* format for example table cells on the report edit page */
303295
td.rpteditex {
304296
border-width: thin;
305297
border-color: white;
306298
border-style: solid;
307299
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -289,18 +289,10 @@
289 text-align: left;
290 vertical-align: top;
291 background-color: #485D7B;
292 }
293
294 /* Ticket display on timelines */
295 td.tktTlOpen {
296 color: #ffc0c0;
297 }
298 td.tktTlClose {
299 color: #c0c0c0;
300 }
301
302 /* format for example table cells on the report edit page */
303 td.rpteditex {
304 border-width: thin;
305 border-color: white;
306 border-style: solid;
307
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -289,18 +289,10 @@
289 text-align: left;
290 vertical-align: top;
291 background-color: #485D7B;
292 }
293
 
 
 
 
 
 
 
 
294 /* format for example table cells on the report edit page */
295 td.rpteditex {
296 border-width: thin;
297 border-color: white;
298 border-style: solid;
299
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -696,15 +696,10 @@
696696
background-color: #111;
697697
text-align: left;
698698
vertical-align: top;
699699
}
700700
701
-/* Tickets on timelines */
702
-td.tktTlOpen {
703
- color: #ffa0a0;
704
-}
705
-
706701
/* format for ticket error messages */
707702
span.tktError {
708703
color: #f00;
709704
font-weight: bold;
710705
}
711706
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -696,15 +696,10 @@
696 background-color: #111;
697 text-align: left;
698 vertical-align: top;
699 }
700
701 /* Tickets on timelines */
702 td.tktTlOpen {
703 color: #ffa0a0;
704 }
705
706 /* format for ticket error messages */
707 span.tktError {
708 color: #f00;
709 font-weight: bold;
710 }
711
--- skins/xekri/css.txt
+++ skins/xekri/css.txt
@@ -696,15 +696,10 @@
696 background-color: #111;
697 text-align: left;
698 vertical-align: top;
699 }
700
 
 
 
 
 
701 /* format for ticket error messages */
702 span.tktError {
703 color: #f00;
704 font-weight: bold;
705 }
706
+1 -4
--- src/alerts.c
+++ src/alerts.c
@@ -2003,14 +2003,11 @@
20032003
20042004
20052005
/* First do non-forum post events */
20062006
db_prepare(&q,
20072007
"SELECT"
2008
- " CASE WHEN event.type='t'"
2009
- " THEN (SELECT substr(tagname,5) FROM tag"
2010
- " WHERE tagid=event.tagid AND tagname LIKE 'tkt-%%')"
2011
- " ELSE blob.uuid END," /* 0 */
2008
+ " blob.uuid," /* 0 */
20122009
" datetime(event.mtime)," /* 1 */
20132010
" coalesce(ecomment,comment)"
20142011
" || ' (user: ' || coalesce(euser,user,'?')"
20152012
" || (SELECT case when length(x)>0 then ' tags: ' || x else '' end"
20162013
" FROM (SELECT group_concat(substr(tagname,5), ', ') AS x"
20172014
--- src/alerts.c
+++ src/alerts.c
@@ -2003,14 +2003,11 @@
2003
2004
2005 /* First do non-forum post events */
2006 db_prepare(&q,
2007 "SELECT"
2008 " CASE WHEN event.type='t'"
2009 " THEN (SELECT substr(tagname,5) FROM tag"
2010 " WHERE tagid=event.tagid AND tagname LIKE 'tkt-%%')"
2011 " ELSE blob.uuid END," /* 0 */
2012 " datetime(event.mtime)," /* 1 */
2013 " coalesce(ecomment,comment)"
2014 " || ' (user: ' || coalesce(euser,user,'?')"
2015 " || (SELECT case when length(x)>0 then ' tags: ' || x else '' end"
2016 " FROM (SELECT group_concat(substr(tagname,5), ', ') AS x"
2017
--- src/alerts.c
+++ src/alerts.c
@@ -2003,14 +2003,11 @@
2003
2004
2005 /* First do non-forum post events */
2006 db_prepare(&q,
2007 "SELECT"
2008 " blob.uuid," /* 0 */
 
 
 
2009 " datetime(event.mtime)," /* 1 */
2010 " coalesce(ecomment,comment)"
2011 " || ' (user: ' || coalesce(euser,user,'?')"
2012 " || (SELECT case when length(x)>0 then ' tags: ' || x else '' end"
2013 " FROM (SELECT group_concat(substr(tagname,5), ', ') AS x"
2014
-6
--- src/bag.c
+++ src/bag.c
@@ -48,16 +48,10 @@
4848
int cnt; /* Number of integers in the bag */
4949
int sz; /* Number of slots in a[] */
5050
int used; /* Number of used slots in a[] */
5151
int *a; /* Hash table of integers that are in the bag */
5252
};
53
-/*
54
-** An expression for statically initializing a Bag instance, to be
55
-** assigned to Bag instances at their declaration point. It has
56
-** the same effect as passing the Bag to bag_init().
57
-*/
58
-#define Bag_INIT {0,0,0,0}
5953
#endif
6054
6155
/*
6256
** Initialize a Bag structure
6357
*/
6458
--- src/bag.c
+++ src/bag.c
@@ -48,16 +48,10 @@
48 int cnt; /* Number of integers in the bag */
49 int sz; /* Number of slots in a[] */
50 int used; /* Number of used slots in a[] */
51 int *a; /* Hash table of integers that are in the bag */
52 };
53 /*
54 ** An expression for statically initializing a Bag instance, to be
55 ** assigned to Bag instances at their declaration point. It has
56 ** the same effect as passing the Bag to bag_init().
57 */
58 #define Bag_INIT {0,0,0,0}
59 #endif
60
61 /*
62 ** Initialize a Bag structure
63 */
64
--- src/bag.c
+++ src/bag.c
@@ -48,16 +48,10 @@
48 int cnt; /* Number of integers in the bag */
49 int sz; /* Number of slots in a[] */
50 int used; /* Number of used slots in a[] */
51 int *a; /* Hash table of integers that are in the bag */
52 };
 
 
 
 
 
 
53 #endif
54
55 /*
56 ** Initialize a Bag structure
57 */
58
+9 -78
--- src/cgi.c
+++ src/cgi.c
@@ -350,11 +350,11 @@
350350
fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
351351
}
352352
}
353353
}
354354
fflush(g.httpOut);
355
- CGIDEBUG(("-------- END cgi ---------\n"));
355
+ CGIDEBUG(("DONE\n"));
356356
357357
/* After the webpage has been sent, do any useful background
358358
** processing.
359359
*/
360360
g.cgiOutput = 2;
@@ -1168,14 +1168,10 @@
11681168
j++;
11691169
}
11701170
nUsedQP = j;
11711171
}
11721172
1173
- /* Invoking with a NULL zName is just a way to cause the parameters
1174
- ** to be sorted. So go ahead and bail out in that case */
1175
- if( zName==0 || zName[0]==0 ) return 0;
1176
-
11771173
/* Do a binary search for a matching query parameter */
11781174
lo = 0;
11791175
hi = nUsedQP-1;
11801176
while( lo<=hi ){
11811177
mid = (lo+hi)/2;
@@ -1193,11 +1189,11 @@
11931189
/* If no match is found and the name begins with an upper-case
11941190
** letter, then check to see if there is an environment variable
11951191
** with the given name. Handle environment variables with empty values
11961192
** the same as non-existent environment variables.
11971193
*/
1198
- if( fossil_isupper(zName[0]) ){
1194
+ if( zName && fossil_isupper(zName[0]) ){
11991195
const char *zValue = fossil_getenv(zName);
12001196
if( zValue && zValue[0] ){
12011197
cgi_set_parameter_nocopy(zName, zValue, 0);
12021198
CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
12031199
return zValue;
@@ -1318,73 +1314,28 @@
13181314
va_end(ap);
13191315
return 1;
13201316
}
13211317
13221318
/*
1323
-** Load all relevant environment variables into the parameter buffer.
1324
-** Invoke this routine prior to calling cgi_print_all() in order to see
1325
-** the full CGI environment. This routine intended for debugging purposes
1326
-** only.
1327
-*/
1328
-void cgi_load_environment(void){
1329
- /* The following is a list of environment variables that Fossil considers
1330
- ** to be "relevant". */
1331
- static const char *const azCgiVars[] = {
1332
- "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1333
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1334
- "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1335
- "HTTP_CONNECTION", "HTTP_HOST",
1336
- "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1337
- "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1338
- "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1339
- "REMOTE_USER", "REQUEST_METHOD",
1340
- "REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_PROTOCOL",
1341
- "HOME", "FOSSIL_HOME", "USERNAME", "USER", "FOSSIL_USER",
1342
- "SQLITE_TMPDIR", "TMPDIR",
1343
- "TEMP", "TMP", "FOSSIL_VFS",
1344
- "FOSSIL_FORCE_TICKET_MODERATION", "FOSSIL_FORCE_WIKI_MODERATION",
1345
- "FOSSIL_TCL_PATH", "TH1_DELETE_INTERP", "TH1_ENABLE_DOCS",
1346
- "TH1_ENABLE_HOOKS", "TH1_ENABLE_TCL", "REMOTE_HOST",
1347
- };
1348
- int i;
1349
- for(i=0; i<count(azCgiVars); i++) (void)P(azCgiVars[i]);
1350
-}
1351
-
1352
-/*
1353
-** Print all query parameters on standard output.
1354
-** This is used for testing and debugging.
1319
+** Print all query parameters on standard output. Format the
1320
+** parameters as HTML. This is used for testing and debugging.
13551321
**
13561322
** Omit the values of the cookies unless showAll is true.
1357
-**
1358
-** The eDest parameter determines where the output is shown:
1359
-**
1360
-** eDest==0: Rendering as HTML into the CGI reply
1361
-** eDest==1: Written to stderr
1362
-** eDest==2: Written to cgi_debug
13631323
*/
1364
-void cgi_print_all(int showAll, unsigned int eDest){
1324
+void cgi_print_all(int showAll, int onConsole){
13651325
int i;
13661326
cgi_parameter("",""); /* Force the parameters into sorted order */
13671327
for(i=0; i<nUsedQP; i++){
13681328
const char *zName = aParamQP[i].zName;
13691329
if( !showAll ){
13701330
if( fossil_stricmp("HTTP_COOKIE",zName)==0 ) continue;
13711331
if( fossil_strnicmp("fossil-",zName,7)==0 ) continue;
13721332
}
1373
- switch( eDest ){
1374
- case 0: {
1375
- cgi_printf("%h = %h <br />\n", zName, aParamQP[i].zValue);
1376
- break;
1377
- }
1378
- case 1: {
1379
- fossil_trace("%s = %s\n", zName, aParamQP[i].zValue);
1380
- break;
1381
- }
1382
- case 2: {
1383
- cgi_debug("%s = %s\n", zName, aParamQP[i].zValue);
1384
- break;
1385
- }
1333
+ if( onConsole ){
1334
+ fossil_trace("%s = %s\n", zName, aParamQP[i].zValue);
1335
+ }else{
1336
+ cgi_printf("%h = %h <br />\n", zName, aParamQP[i].zValue);
13861337
}
13871338
}
13881339
}
13891340
13901341
/*
@@ -2126,30 +2077,10 @@
21262077
azDays[pTm->tm_wday], pTm->tm_mday, azMonths[pTm->tm_mon],
21272078
pTm->tm_year+1900, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
21282079
}
21292080
}
21302081
2131
-/*
2132
-** Returns an ISO8601-formatted time string suitable for debugging
2133
-** purposes.
2134
-**
2135
-** The value returned is always a string obtained from mprintf() and must
2136
-** be freed using fossil_free() to avoid a memory leak.
2137
-*/
2138
-char *cgi_iso8601_datestamp(void){
2139
- struct tm *pTm;
2140
- time_t now = time(0);
2141
- pTm = gmtime(&now);
2142
- if( pTm==0 ){
2143
- return mprintf("");
2144
- }else{
2145
- return mprintf("%04d-%02d-%02d %02d:%02d:%02d",
2146
- pTm->tm_year+1900, pTm->tm_mon, pTm->tm_mday,
2147
- pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
2148
- }
2149
-}
2150
-
21512082
/*
21522083
** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return
21532084
** a Unix epoch time. <= zero is returned on failure.
21542085
**
21552086
** Note that this won't handle all the _allowed_ HTTP formats, just the
21562087
--- src/cgi.c
+++ src/cgi.c
@@ -350,11 +350,11 @@
350 fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
351 }
352 }
353 }
354 fflush(g.httpOut);
355 CGIDEBUG(("-------- END cgi ---------\n"));
356
357 /* After the webpage has been sent, do any useful background
358 ** processing.
359 */
360 g.cgiOutput = 2;
@@ -1168,14 +1168,10 @@
1168 j++;
1169 }
1170 nUsedQP = j;
1171 }
1172
1173 /* Invoking with a NULL zName is just a way to cause the parameters
1174 ** to be sorted. So go ahead and bail out in that case */
1175 if( zName==0 || zName[0]==0 ) return 0;
1176
1177 /* Do a binary search for a matching query parameter */
1178 lo = 0;
1179 hi = nUsedQP-1;
1180 while( lo<=hi ){
1181 mid = (lo+hi)/2;
@@ -1193,11 +1189,11 @@
1193 /* If no match is found and the name begins with an upper-case
1194 ** letter, then check to see if there is an environment variable
1195 ** with the given name. Handle environment variables with empty values
1196 ** the same as non-existent environment variables.
1197 */
1198 if( fossil_isupper(zName[0]) ){
1199 const char *zValue = fossil_getenv(zName);
1200 if( zValue && zValue[0] ){
1201 cgi_set_parameter_nocopy(zName, zValue, 0);
1202 CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
1203 return zValue;
@@ -1318,73 +1314,28 @@
1318 va_end(ap);
1319 return 1;
1320 }
1321
1322 /*
1323 ** Load all relevant environment variables into the parameter buffer.
1324 ** Invoke this routine prior to calling cgi_print_all() in order to see
1325 ** the full CGI environment. This routine intended for debugging purposes
1326 ** only.
1327 */
1328 void cgi_load_environment(void){
1329 /* The following is a list of environment variables that Fossil considers
1330 ** to be "relevant". */
1331 static const char *const azCgiVars[] = {
1332 "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1333 "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1334 "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1335 "HTTP_CONNECTION", "HTTP_HOST",
1336 "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1337 "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1338 "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1339 "REMOTE_USER", "REQUEST_METHOD",
1340 "REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_PROTOCOL",
1341 "HOME", "FOSSIL_HOME", "USERNAME", "USER", "FOSSIL_USER",
1342 "SQLITE_TMPDIR", "TMPDIR",
1343 "TEMP", "TMP", "FOSSIL_VFS",
1344 "FOSSIL_FORCE_TICKET_MODERATION", "FOSSIL_FORCE_WIKI_MODERATION",
1345 "FOSSIL_TCL_PATH", "TH1_DELETE_INTERP", "TH1_ENABLE_DOCS",
1346 "TH1_ENABLE_HOOKS", "TH1_ENABLE_TCL", "REMOTE_HOST",
1347 };
1348 int i;
1349 for(i=0; i<count(azCgiVars); i++) (void)P(azCgiVars[i]);
1350 }
1351
1352 /*
1353 ** Print all query parameters on standard output.
1354 ** This is used for testing and debugging.
1355 **
1356 ** Omit the values of the cookies unless showAll is true.
1357 **
1358 ** The eDest parameter determines where the output is shown:
1359 **
1360 ** eDest==0: Rendering as HTML into the CGI reply
1361 ** eDest==1: Written to stderr
1362 ** eDest==2: Written to cgi_debug
1363 */
1364 void cgi_print_all(int showAll, unsigned int eDest){
1365 int i;
1366 cgi_parameter("",""); /* Force the parameters into sorted order */
1367 for(i=0; i<nUsedQP; i++){
1368 const char *zName = aParamQP[i].zName;
1369 if( !showAll ){
1370 if( fossil_stricmp("HTTP_COOKIE",zName)==0 ) continue;
1371 if( fossil_strnicmp("fossil-",zName,7)==0 ) continue;
1372 }
1373 switch( eDest ){
1374 case 0: {
1375 cgi_printf("%h = %h <br />\n", zName, aParamQP[i].zValue);
1376 break;
1377 }
1378 case 1: {
1379 fossil_trace("%s = %s\n", zName, aParamQP[i].zValue);
1380 break;
1381 }
1382 case 2: {
1383 cgi_debug("%s = %s\n", zName, aParamQP[i].zValue);
1384 break;
1385 }
1386 }
1387 }
1388 }
1389
1390 /*
@@ -2126,30 +2077,10 @@
2126 azDays[pTm->tm_wday], pTm->tm_mday, azMonths[pTm->tm_mon],
2127 pTm->tm_year+1900, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
2128 }
2129 }
2130
2131 /*
2132 ** Returns an ISO8601-formatted time string suitable for debugging
2133 ** purposes.
2134 **
2135 ** The value returned is always a string obtained from mprintf() and must
2136 ** be freed using fossil_free() to avoid a memory leak.
2137 */
2138 char *cgi_iso8601_datestamp(void){
2139 struct tm *pTm;
2140 time_t now = time(0);
2141 pTm = gmtime(&now);
2142 if( pTm==0 ){
2143 return mprintf("");
2144 }else{
2145 return mprintf("%04d-%02d-%02d %02d:%02d:%02d",
2146 pTm->tm_year+1900, pTm->tm_mon, pTm->tm_mday,
2147 pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
2148 }
2149 }
2150
2151 /*
2152 ** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return
2153 ** a Unix epoch time. <= zero is returned on failure.
2154 **
2155 ** Note that this won't handle all the _allowed_ HTTP formats, just the
2156
--- src/cgi.c
+++ src/cgi.c
@@ -350,11 +350,11 @@
350 fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
351 }
352 }
353 }
354 fflush(g.httpOut);
355 CGIDEBUG(("DONE\n"));
356
357 /* After the webpage has been sent, do any useful background
358 ** processing.
359 */
360 g.cgiOutput = 2;
@@ -1168,14 +1168,10 @@
1168 j++;
1169 }
1170 nUsedQP = j;
1171 }
1172
 
 
 
 
1173 /* Do a binary search for a matching query parameter */
1174 lo = 0;
1175 hi = nUsedQP-1;
1176 while( lo<=hi ){
1177 mid = (lo+hi)/2;
@@ -1193,11 +1189,11 @@
1189 /* If no match is found and the name begins with an upper-case
1190 ** letter, then check to see if there is an environment variable
1191 ** with the given name. Handle environment variables with empty values
1192 ** the same as non-existent environment variables.
1193 */
1194 if( zName && fossil_isupper(zName[0]) ){
1195 const char *zValue = fossil_getenv(zName);
1196 if( zValue && zValue[0] ){
1197 cgi_set_parameter_nocopy(zName, zValue, 0);
1198 CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
1199 return zValue;
@@ -1318,73 +1314,28 @@
1314 va_end(ap);
1315 return 1;
1316 }
1317
1318 /*
1319 ** Print all query parameters on standard output. Format the
1320 ** parameters as HTML. This is used for testing and debugging.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1321 **
1322 ** Omit the values of the cookies unless showAll is true.
 
 
 
 
 
 
1323 */
1324 void cgi_print_all(int showAll, int onConsole){
1325 int i;
1326 cgi_parameter("",""); /* Force the parameters into sorted order */
1327 for(i=0; i<nUsedQP; i++){
1328 const char *zName = aParamQP[i].zName;
1329 if( !showAll ){
1330 if( fossil_stricmp("HTTP_COOKIE",zName)==0 ) continue;
1331 if( fossil_strnicmp("fossil-",zName,7)==0 ) continue;
1332 }
1333 if( onConsole ){
1334 fossil_trace("%s = %s\n", zName, aParamQP[i].zValue);
1335 }else{
1336 cgi_printf("%h = %h <br />\n", zName, aParamQP[i].zValue);
 
 
 
 
 
 
 
 
 
1337 }
1338 }
1339 }
1340
1341 /*
@@ -2126,30 +2077,10 @@
2077 azDays[pTm->tm_wday], pTm->tm_mday, azMonths[pTm->tm_mon],
2078 pTm->tm_year+1900, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
2079 }
2080 }
2081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2082 /*
2083 ** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return
2084 ** a Unix epoch time. <= zero is returned on failure.
2085 **
2086 ** Note that this won't handle all the _allowed_ HTTP formats, just the
2087
+2 -9
--- src/content.c
+++ src/content.c
@@ -99,29 +99,22 @@
9999
blob_zero(pBlob);
100100
bag_insert(&contentCache.inCache, rid);
101101
}
102102
103103
/*
104
-** Clear the content cache. If it is passed true, it
105
-** also frees all associated memory, otherwise it may
106
-** retain parts for future uses of the cache.
104
+** Clear the content cache.
107105
*/
108
-void content_clear_cache(int bFreeIt){
106
+void content_clear_cache(void){
109107
int i;
110108
for(i=0; i<contentCache.n; i++){
111109
blob_reset(&contentCache.a[i].content);
112110
}
113111
bag_clear(&contentCache.missing);
114112
bag_clear(&contentCache.available);
115113
bag_clear(&contentCache.inCache);
116114
contentCache.n = 0;
117115
contentCache.szTotal = 0;
118
- if(bFreeIt){
119
- fossil_free(contentCache.a);
120
- contentCache.a = 0;
121
- contentCache.nAlloc = 0;
122
- }
123116
}
124117
125118
/*
126119
** Return the srcid associated with rid. Or return 0 if rid is
127120
** original content and not a delta.
128121
--- src/content.c
+++ src/content.c
@@ -99,29 +99,22 @@
99 blob_zero(pBlob);
100 bag_insert(&contentCache.inCache, rid);
101 }
102
103 /*
104 ** Clear the content cache. If it is passed true, it
105 ** also frees all associated memory, otherwise it may
106 ** retain parts for future uses of the cache.
107 */
108 void content_clear_cache(int bFreeIt){
109 int i;
110 for(i=0; i<contentCache.n; i++){
111 blob_reset(&contentCache.a[i].content);
112 }
113 bag_clear(&contentCache.missing);
114 bag_clear(&contentCache.available);
115 bag_clear(&contentCache.inCache);
116 contentCache.n = 0;
117 contentCache.szTotal = 0;
118 if(bFreeIt){
119 fossil_free(contentCache.a);
120 contentCache.a = 0;
121 contentCache.nAlloc = 0;
122 }
123 }
124
125 /*
126 ** Return the srcid associated with rid. Or return 0 if rid is
127 ** original content and not a delta.
128
--- src/content.c
+++ src/content.c
@@ -99,29 +99,22 @@
99 blob_zero(pBlob);
100 bag_insert(&contentCache.inCache, rid);
101 }
102
103 /*
104 ** Clear the content cache.
 
 
105 */
106 void content_clear_cache(void){
107 int i;
108 for(i=0; i<contentCache.n; i++){
109 blob_reset(&contentCache.a[i].content);
110 }
111 bag_clear(&contentCache.missing);
112 bag_clear(&contentCache.available);
113 bag_clear(&contentCache.inCache);
114 contentCache.n = 0;
115 contentCache.szTotal = 0;
 
 
 
 
 
116 }
117
118 /*
119 ** Return the srcid associated with rid. Or return 0 if rid is
120 ** original content and not a delta.
121
+1 -9
--- src/db.c
+++ src/db.c
@@ -1628,13 +1628,11 @@
16281628
assert( g.localOpen );
16291629
assert( g.zLocalRoot );
16301630
if( zRepo==0 ){
16311631
zRepo = db_lget("repository", 0);
16321632
if( zRepo && !file_is_absolute_path(zRepo) ){
1633
- char * zFree = zRepo;
16341633
zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
1635
- fossil_free(zFree);
16361634
}
16371635
}
16381636
return zRepo;
16391637
}
16401638
@@ -2635,15 +2633,11 @@
26352633
db_swap_connections();
26362634
}
26372635
if( pSetting!=0 && pSetting->versionable ){
26382636
/* This is a versionable setting, try and get the info from a
26392637
** checked out file */
2640
- char * zZ = z;
26412638
z = db_get_versioned(zName, z);
2642
- if(zZ != z){
2643
- fossil_free(zZ);
2644
- }
26452639
}
26462640
if( z==0 ){
26472641
if( zDefault==0 && pSetting && pSetting->def[0] ){
26482642
z = fossil_strdup(pSetting->def);
26492643
}else{
@@ -4008,18 +4002,16 @@
40084002
if( g.argc==3 ){
40094003
rcvid = atoi(g.argv[2]);
40104004
}else if( g.argc!=2 ){
40114005
fossil_fatal("wrong number of arguments");
40124006
}
4013
- fossil_print("legacy: %z\n", db_fingerprint(rcvid, 0));
4007
+ fossil_print("legecy: %z\n", db_fingerprint(rcvid, 0));
40144008
fossil_print("version-1: %z\n", db_fingerprint(rcvid, 1));
40154009
if( g.localOpen ){
40164010
fossil_print("localdb: %z\n", db_lget("fingerprint","(none)"));
40174011
fossil_print("db_fingerprint_ok(): %d\n", db_fingerprint_ok());
40184012
}
4019
- fossil_print("Fossil version: %s - %.10s %.19s\n",
4020
- RELEASE_VERSION, MANIFEST_DATE, MANIFEST_UUID);
40214013
}
40224014
40234015
/*
40244016
** Set the value of the "checkout" entry in the VVAR table.
40254017
**
40264018
--- src/db.c
+++ src/db.c
@@ -1628,13 +1628,11 @@
1628 assert( g.localOpen );
1629 assert( g.zLocalRoot );
1630 if( zRepo==0 ){
1631 zRepo = db_lget("repository", 0);
1632 if( zRepo && !file_is_absolute_path(zRepo) ){
1633 char * zFree = zRepo;
1634 zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
1635 fossil_free(zFree);
1636 }
1637 }
1638 return zRepo;
1639 }
1640
@@ -2635,15 +2633,11 @@
2635 db_swap_connections();
2636 }
2637 if( pSetting!=0 && pSetting->versionable ){
2638 /* This is a versionable setting, try and get the info from a
2639 ** checked out file */
2640 char * zZ = z;
2641 z = db_get_versioned(zName, z);
2642 if(zZ != z){
2643 fossil_free(zZ);
2644 }
2645 }
2646 if( z==0 ){
2647 if( zDefault==0 && pSetting && pSetting->def[0] ){
2648 z = fossil_strdup(pSetting->def);
2649 }else{
@@ -4008,18 +4002,16 @@
4008 if( g.argc==3 ){
4009 rcvid = atoi(g.argv[2]);
4010 }else if( g.argc!=2 ){
4011 fossil_fatal("wrong number of arguments");
4012 }
4013 fossil_print("legacy: %z\n", db_fingerprint(rcvid, 0));
4014 fossil_print("version-1: %z\n", db_fingerprint(rcvid, 1));
4015 if( g.localOpen ){
4016 fossil_print("localdb: %z\n", db_lget("fingerprint","(none)"));
4017 fossil_print("db_fingerprint_ok(): %d\n", db_fingerprint_ok());
4018 }
4019 fossil_print("Fossil version: %s - %.10s %.19s\n",
4020 RELEASE_VERSION, MANIFEST_DATE, MANIFEST_UUID);
4021 }
4022
4023 /*
4024 ** Set the value of the "checkout" entry in the VVAR table.
4025 **
4026
--- src/db.c
+++ src/db.c
@@ -1628,13 +1628,11 @@
1628 assert( g.localOpen );
1629 assert( g.zLocalRoot );
1630 if( zRepo==0 ){
1631 zRepo = db_lget("repository", 0);
1632 if( zRepo && !file_is_absolute_path(zRepo) ){
 
1633 zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
 
1634 }
1635 }
1636 return zRepo;
1637 }
1638
@@ -2635,15 +2633,11 @@
2633 db_swap_connections();
2634 }
2635 if( pSetting!=0 && pSetting->versionable ){
2636 /* This is a versionable setting, try and get the info from a
2637 ** checked out file */
 
2638 z = db_get_versioned(zName, z);
 
 
 
2639 }
2640 if( z==0 ){
2641 if( zDefault==0 && pSetting && pSetting->def[0] ){
2642 z = fossil_strdup(pSetting->def);
2643 }else{
@@ -4008,18 +4002,16 @@
4002 if( g.argc==3 ){
4003 rcvid = atoi(g.argv[2]);
4004 }else if( g.argc!=2 ){
4005 fossil_fatal("wrong number of arguments");
4006 }
4007 fossil_print("legecy: %z\n", db_fingerprint(rcvid, 0));
4008 fossil_print("version-1: %z\n", db_fingerprint(rcvid, 1));
4009 if( g.localOpen ){
4010 fossil_print("localdb: %z\n", db_lget("fingerprint","(none)"));
4011 fossil_print("db_fingerprint_ok(): %d\n", db_fingerprint_ok());
4012 }
 
 
4013 }
4014
4015 /*
4016 ** Set the value of the "checkout" entry in the VVAR table.
4017 **
4018
--- src/default_css.txt
+++ src/default_css.txt
@@ -456,16 +456,10 @@
456456
td.tktDspValue {
457457
text-align: left;
458458
vertical-align: top;
459459
background-color: #d0d0d0;
460460
}
461
-td.tktTlOpen {
462
- color: #800;
463
-}
464
-td.tktTlClosed {
465
- color: #888;
466
-}
467461
span.tktError {
468462
color: red;
469463
font-weight: bold;
470464
}
471465
table.rpteditex {
472466
--- src/default_css.txt
+++ src/default_css.txt
@@ -456,16 +456,10 @@
456 td.tktDspValue {
457 text-align: left;
458 vertical-align: top;
459 background-color: #d0d0d0;
460 }
461 td.tktTlOpen {
462 color: #800;
463 }
464 td.tktTlClosed {
465 color: #888;
466 }
467 span.tktError {
468 color: red;
469 font-weight: bold;
470 }
471 table.rpteditex {
472
--- src/default_css.txt
+++ src/default_css.txt
@@ -456,16 +456,10 @@
456 td.tktDspValue {
457 text-align: left;
458 vertical-align: top;
459 background-color: #d0d0d0;
460 }
 
 
 
 
 
 
461 span.tktError {
462 color: red;
463 font-weight: bold;
464 }
465 table.rpteditex {
466
+6 -54
--- src/doc.c
+++ src/doc.c
@@ -39,11 +39,11 @@
3939
4040
/* A table of mimetypes based on file content prefixes
4141
*/
4242
static const struct {
4343
const char *zPrefix; /* The file prefix */
44
- const int size; /* Length of the prefix */
44
+ int size; /* Length of the prefix */
4545
const char *zMimetype; /* The corresponding mimetype */
4646
} aMime[] = {
4747
{ "GIF87a", 6, "image/gif" },
4848
{ "GIF89a", 6, "image/gif" },
4949
{ "\211PNG\r\n\032\n", 8, "image/png" },
@@ -269,11 +269,10 @@
269269
{ "viv", 3, "video/vnd.vivo" },
270270
{ "vivo", 4, "video/vnd.vivo" },
271271
{ "vrml", 4, "model/vrml" },
272272
{ "wav", 3, "audio/x-wav" },
273273
{ "wax", 3, "audio/x-ms-wax" },
274
- { "webp", 4, "image/webp" },
275274
{ "wiki", 4, "text/x-fossil-wiki" },
276275
{ "wma", 3, "audio/x-ms-wma" },
277276
{ "wmv", 3, "video/x-ms-wmv" },
278277
{ "wmx", 3, "video/x-ms-wmx" },
279278
{ "wrl", 3, "model/vrml" },
@@ -508,53 +507,19 @@
508507
rid = 0;
509508
}
510509
return rid;
511510
}
512511
513
-/*
514
-** Check to verify that z[i] is contained within HTML markup.
515
-**
516
-** This works by looking backwards in the string for the most recent
517
-** '<' or '>' character. If a '<' is found first, then we assume that
518
-** z[i] is within markup. If a '>' is seen or neither character is seen,
519
-** then z[i] is not within markup.
520
-*/
521
-static int isWithinHtmlMarkup(const char *z, int i){
522
- while( i>=0 && z[i]!='>' && z[i]!='<' ){ i--; }
523
- return z[i]=='<';
524
-}
525
-
526
-/*
527
-** Check to see if z[i] is contained within an href='...' of markup.
528
-*/
529
-static int isWithinHref(const char *z, int i){
530
- while( i>5
531
- && !fossil_isspace(z[i])
532
- && z[i]!='\'' && z[i]!='"'
533
- && z[i]!='>'
534
- ){ i--; }
535
- if( i<=6 ) return 0;
536
- if( z[i]!='\'' && z[i]!='\"' ) return 0;
537
- if( strncmp(&z[i-5],"href=",5)!=0 ) return 0;
538
- if( !fossil_isspace(z[i-6]) ) return 0;
539
- return 1;
540
-}
541
-
542512
/*
543513
** Transfer content to the output. During the transfer, when text of
544514
** the following form is seen:
545515
**
546
-** href="$ROOT/..."
547
-** action="$ROOT/..."
548
-** href=".../doc/$SELF/..."
549
-**
550
-** Convert $ROOT to the root URI of the repository, and $SELF to the
551
-** version number of the /doc/ document currently being displayed (if any).
552
-** Allow ' in place of " and any case for href or action.
553
-**
554
-** Efforts are made to limit this translation to cases where the text is
555
-** fully contained with an HTML markup element.
516
+** href="$ROOT/
517
+** action="$ROOT/
518
+**
519
+** Convert $ROOT to the root URI of the repository. Allow ' in place of "
520
+** and any case for href or action.
556521
*/
557522
void convert_href_and_output(Blob *pIn){
558523
int i, base;
559524
int n = blob_size(pIn);
560525
char *z = blob_buffer(pIn);
@@ -563,27 +528,14 @@
563528
&& strncmp(&z[i],"$ROOT/", 6)==0
564529
&& (z[i-1]=='\'' || z[i-1]=='"')
565530
&& i-base>=9
566531
&& ((fossil_strnicmp(&z[i-6],"href=",5)==0 && fossil_isspace(z[i-7])) ||
567532
(fossil_strnicmp(&z[i-8],"action=",7)==0 && fossil_isspace(z[i-9])) )
568
- && isWithinHtmlMarkup(z, i-6)
569533
){
570534
blob_append(cgi_output_blob(), &z[base], i-base);
571535
blob_appendf(cgi_output_blob(), "%R");
572536
base = i+5;
573
- }else
574
- if( z[i]=='$'
575
- && strncmp(&z[i-5],"/doc/$SELF/", 11)==0
576
- && isWithinHref(z,i-5)
577
- && isWithinHtmlMarkup(z, i-5)
578
- && strncmp(g.zPath, "doc/",4)==0
579
- ){
580
- int j;
581
- for(j=4; g.zPath[j] && g.zPath[j]!='/'; j++){}
582
- blob_append(cgi_output_blob(), &z[base], i-base);
583
- blob_appendf(cgi_output_blob(), "%.*s", j-4, g.zPath+4);
584
- base = i+5;
585537
}
586538
}
587539
blob_append(cgi_output_blob(), &z[base], i-base);
588540
}
589541
590542
--- src/doc.c
+++ src/doc.c
@@ -39,11 +39,11 @@
39
40 /* A table of mimetypes based on file content prefixes
41 */
42 static const struct {
43 const char *zPrefix; /* The file prefix */
44 const int size; /* Length of the prefix */
45 const char *zMimetype; /* The corresponding mimetype */
46 } aMime[] = {
47 { "GIF87a", 6, "image/gif" },
48 { "GIF89a", 6, "image/gif" },
49 { "\211PNG\r\n\032\n", 8, "image/png" },
@@ -269,11 +269,10 @@
269 { "viv", 3, "video/vnd.vivo" },
270 { "vivo", 4, "video/vnd.vivo" },
271 { "vrml", 4, "model/vrml" },
272 { "wav", 3, "audio/x-wav" },
273 { "wax", 3, "audio/x-ms-wax" },
274 { "webp", 4, "image/webp" },
275 { "wiki", 4, "text/x-fossil-wiki" },
276 { "wma", 3, "audio/x-ms-wma" },
277 { "wmv", 3, "video/x-ms-wmv" },
278 { "wmx", 3, "video/x-ms-wmx" },
279 { "wrl", 3, "model/vrml" },
@@ -508,53 +507,19 @@
508 rid = 0;
509 }
510 return rid;
511 }
512
513 /*
514 ** Check to verify that z[i] is contained within HTML markup.
515 **
516 ** This works by looking backwards in the string for the most recent
517 ** '<' or '>' character. If a '<' is found first, then we assume that
518 ** z[i] is within markup. If a '>' is seen or neither character is seen,
519 ** then z[i] is not within markup.
520 */
521 static int isWithinHtmlMarkup(const char *z, int i){
522 while( i>=0 && z[i]!='>' && z[i]!='<' ){ i--; }
523 return z[i]=='<';
524 }
525
526 /*
527 ** Check to see if z[i] is contained within an href='...' of markup.
528 */
529 static int isWithinHref(const char *z, int i){
530 while( i>5
531 && !fossil_isspace(z[i])
532 && z[i]!='\'' && z[i]!='"'
533 && z[i]!='>'
534 ){ i--; }
535 if( i<=6 ) return 0;
536 if( z[i]!='\'' && z[i]!='\"' ) return 0;
537 if( strncmp(&z[i-5],"href=",5)!=0 ) return 0;
538 if( !fossil_isspace(z[i-6]) ) return 0;
539 return 1;
540 }
541
542 /*
543 ** Transfer content to the output. During the transfer, when text of
544 ** the following form is seen:
545 **
546 ** href="$ROOT/..."
547 ** action="$ROOT/..."
548 ** href=".../doc/$SELF/..."
549 **
550 ** Convert $ROOT to the root URI of the repository, and $SELF to the
551 ** version number of the /doc/ document currently being displayed (if any).
552 ** Allow ' in place of " and any case for href or action.
553 **
554 ** Efforts are made to limit this translation to cases where the text is
555 ** fully contained with an HTML markup element.
556 */
557 void convert_href_and_output(Blob *pIn){
558 int i, base;
559 int n = blob_size(pIn);
560 char *z = blob_buffer(pIn);
@@ -563,27 +528,14 @@
563 && strncmp(&z[i],"$ROOT/", 6)==0
564 && (z[i-1]=='\'' || z[i-1]=='"')
565 && i-base>=9
566 && ((fossil_strnicmp(&z[i-6],"href=",5)==0 && fossil_isspace(z[i-7])) ||
567 (fossil_strnicmp(&z[i-8],"action=",7)==0 && fossil_isspace(z[i-9])) )
568 && isWithinHtmlMarkup(z, i-6)
569 ){
570 blob_append(cgi_output_blob(), &z[base], i-base);
571 blob_appendf(cgi_output_blob(), "%R");
572 base = i+5;
573 }else
574 if( z[i]=='$'
575 && strncmp(&z[i-5],"/doc/$SELF/", 11)==0
576 && isWithinHref(z,i-5)
577 && isWithinHtmlMarkup(z, i-5)
578 && strncmp(g.zPath, "doc/",4)==0
579 ){
580 int j;
581 for(j=4; g.zPath[j] && g.zPath[j]!='/'; j++){}
582 blob_append(cgi_output_blob(), &z[base], i-base);
583 blob_appendf(cgi_output_blob(), "%.*s", j-4, g.zPath+4);
584 base = i+5;
585 }
586 }
587 blob_append(cgi_output_blob(), &z[base], i-base);
588 }
589
590
--- src/doc.c
+++ src/doc.c
@@ -39,11 +39,11 @@
39
40 /* A table of mimetypes based on file content prefixes
41 */
42 static const struct {
43 const char *zPrefix; /* The file prefix */
44 int size; /* Length of the prefix */
45 const char *zMimetype; /* The corresponding mimetype */
46 } aMime[] = {
47 { "GIF87a", 6, "image/gif" },
48 { "GIF89a", 6, "image/gif" },
49 { "\211PNG\r\n\032\n", 8, "image/png" },
@@ -269,11 +269,10 @@
269 { "viv", 3, "video/vnd.vivo" },
270 { "vivo", 4, "video/vnd.vivo" },
271 { "vrml", 4, "model/vrml" },
272 { "wav", 3, "audio/x-wav" },
273 { "wax", 3, "audio/x-ms-wax" },
 
274 { "wiki", 4, "text/x-fossil-wiki" },
275 { "wma", 3, "audio/x-ms-wma" },
276 { "wmv", 3, "video/x-ms-wmv" },
277 { "wmx", 3, "video/x-ms-wmx" },
278 { "wrl", 3, "model/vrml" },
@@ -508,53 +507,19 @@
507 rid = 0;
508 }
509 return rid;
510 }
511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512 /*
513 ** Transfer content to the output. During the transfer, when text of
514 ** the following form is seen:
515 **
516 ** href="$ROOT/
517 ** action="$ROOT/
518 **
519 ** Convert $ROOT to the root URI of the repository. Allow ' in place of "
520 ** and any case for href or action.
 
 
 
 
 
521 */
522 void convert_href_and_output(Blob *pIn){
523 int i, base;
524 int n = blob_size(pIn);
525 char *z = blob_buffer(pIn);
@@ -563,27 +528,14 @@
528 && strncmp(&z[i],"$ROOT/", 6)==0
529 && (z[i-1]=='\'' || z[i-1]=='"')
530 && i-base>=9
531 && ((fossil_strnicmp(&z[i-6],"href=",5)==0 && fossil_isspace(z[i-7])) ||
532 (fossil_strnicmp(&z[i-8],"action=",7)==0 && fossil_isspace(z[i-9])) )
 
533 ){
534 blob_append(cgi_output_blob(), &z[base], i-base);
535 blob_appendf(cgi_output_blob(), "%R");
536 base = i+5;
 
 
 
 
 
 
 
 
 
 
 
 
537 }
538 }
539 blob_append(cgi_output_blob(), &z[base], i-base);
540 }
541
542
+1 -39
--- src/extcgi.c
+++ src/extcgi.c
@@ -99,43 +99,10 @@
9999
}
100100
}
101101
return zFailReason;
102102
}
103103
104
-/*
105
-** The *pzPath input is a pathname obtained from mprintf().
106
-**
107
-** If
108
-**
109
-** (1) zPathname is the name of a directory, and
110
-** (2) the name ends with "/", and
111
-** (3) the directory contains a file named index.html, index.wiki,
112
-** or index.md (in that order)
113
-**
114
-** then replace the input with a revised name that includes the index.*
115
-** file and return non-zero (true). If any condition is not met, return
116
-** zero and leave the input pathname unchanged.
117
-*/
118
-static int isDirWithIndexFile(char **pzPath){
119
- static const char *azIndexNames[] = {
120
- "index.html", "index.wiki", "index.md"
121
- };
122
- int i;
123
- if( file_isdir(*pzPath, ExtFILE)!=1 ) return 0;
124
- if( sqlite3_strglob("*/", *pzPath)!=0 ) return 0;
125
- for(i=0; i<sizeof(azIndexNames)/sizeof(azIndexNames[0]); i++){
126
- char *zNew = mprintf("%s%s", *pzPath, azIndexNames[i]);
127
- if( file_isfile(zNew, ExtFILE) ){
128
- fossil_free(*pzPath);
129
- *pzPath = zNew;
130
- return 1;
131
- }
132
- fossil_free(zNew);
133
- }
134
- return 0;
135
-}
136
-
137104
/*
138105
** WEBPAGE: ext raw-content
139106
**
140107
** Relay an HTTP request to secondary CGI after first checking the
141108
** login credentials and setting auxiliary environment variables
@@ -153,15 +120,10 @@
153120
** The path after the /ext is the path to the CGI script or static file
154121
** relative to DIR. For security, this path may not contain characters
155122
** other than ASCII letters or digits, ".", "-", "/", and "_". If the
156123
** "." or "-" characters are present in the path then they may not follow
157124
** a "/".
158
-**
159
-** If the path after /ext ends with "/" and is the name of a directory then
160
-** that directory is searched for files named "index.html", "index.wiki",
161
-** and "index.md" (in that order) and if found, those filenames are
162
-** appended to the path.
163125
*/
164126
void ext_page(void){
165127
const char *zName = P("name"); /* Path information after /ext */
166128
char *zPath = 0; /* Complete path from extroot */
167129
int nRoot; /* Number of bytes in the extroot name */
@@ -202,11 +164,11 @@
202164
zFailReason = "extroot is not a directory";
203165
goto ext_not_found;
204166
}
205167
zPath = mprintf("%s/%s", g.zExtRoot, zName);
206168
nRoot = (int)strlen(g.zExtRoot);
207
- if( file_isfile(zPath, ExtFILE) || isDirWithIndexFile(&zPath) ){
169
+ if( file_isfile(zPath, ExtFILE) ){
208170
nScript = (int)strlen(zPath);
209171
zScript = zPath;
210172
}else{
211173
for(i=nRoot+1; zPath[i]; i++){
212174
char c = zPath[i];
213175
--- src/extcgi.c
+++ src/extcgi.c
@@ -99,43 +99,10 @@
99 }
100 }
101 return zFailReason;
102 }
103
104 /*
105 ** The *pzPath input is a pathname obtained from mprintf().
106 **
107 ** If
108 **
109 ** (1) zPathname is the name of a directory, and
110 ** (2) the name ends with "/", and
111 ** (3) the directory contains a file named index.html, index.wiki,
112 ** or index.md (in that order)
113 **
114 ** then replace the input with a revised name that includes the index.*
115 ** file and return non-zero (true). If any condition is not met, return
116 ** zero and leave the input pathname unchanged.
117 */
118 static int isDirWithIndexFile(char **pzPath){
119 static const char *azIndexNames[] = {
120 "index.html", "index.wiki", "index.md"
121 };
122 int i;
123 if( file_isdir(*pzPath, ExtFILE)!=1 ) return 0;
124 if( sqlite3_strglob("*/", *pzPath)!=0 ) return 0;
125 for(i=0; i<sizeof(azIndexNames)/sizeof(azIndexNames[0]); i++){
126 char *zNew = mprintf("%s%s", *pzPath, azIndexNames[i]);
127 if( file_isfile(zNew, ExtFILE) ){
128 fossil_free(*pzPath);
129 *pzPath = zNew;
130 return 1;
131 }
132 fossil_free(zNew);
133 }
134 return 0;
135 }
136
137 /*
138 ** WEBPAGE: ext raw-content
139 **
140 ** Relay an HTTP request to secondary CGI after first checking the
141 ** login credentials and setting auxiliary environment variables
@@ -153,15 +120,10 @@
153 ** The path after the /ext is the path to the CGI script or static file
154 ** relative to DIR. For security, this path may not contain characters
155 ** other than ASCII letters or digits, ".", "-", "/", and "_". If the
156 ** "." or "-" characters are present in the path then they may not follow
157 ** a "/".
158 **
159 ** If the path after /ext ends with "/" and is the name of a directory then
160 ** that directory is searched for files named "index.html", "index.wiki",
161 ** and "index.md" (in that order) and if found, those filenames are
162 ** appended to the path.
163 */
164 void ext_page(void){
165 const char *zName = P("name"); /* Path information after /ext */
166 char *zPath = 0; /* Complete path from extroot */
167 int nRoot; /* Number of bytes in the extroot name */
@@ -202,11 +164,11 @@
202 zFailReason = "extroot is not a directory";
203 goto ext_not_found;
204 }
205 zPath = mprintf("%s/%s", g.zExtRoot, zName);
206 nRoot = (int)strlen(g.zExtRoot);
207 if( file_isfile(zPath, ExtFILE) || isDirWithIndexFile(&zPath) ){
208 nScript = (int)strlen(zPath);
209 zScript = zPath;
210 }else{
211 for(i=nRoot+1; zPath[i]; i++){
212 char c = zPath[i];
213
--- src/extcgi.c
+++ src/extcgi.c
@@ -99,43 +99,10 @@
99 }
100 }
101 return zFailReason;
102 }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104 /*
105 ** WEBPAGE: ext raw-content
106 **
107 ** Relay an HTTP request to secondary CGI after first checking the
108 ** login credentials and setting auxiliary environment variables
@@ -153,15 +120,10 @@
120 ** The path after the /ext is the path to the CGI script or static file
121 ** relative to DIR. For security, this path may not contain characters
122 ** other than ASCII letters or digits, ".", "-", "/", and "_". If the
123 ** "." or "-" characters are present in the path then they may not follow
124 ** a "/".
 
 
 
 
 
125 */
126 void ext_page(void){
127 const char *zName = P("name"); /* Path information after /ext */
128 char *zPath = 0; /* Complete path from extroot */
129 int nRoot; /* Number of bytes in the extroot name */
@@ -202,11 +164,11 @@
164 zFailReason = "extroot is not a directory";
165 goto ext_not_found;
166 }
167 zPath = mprintf("%s/%s", g.zExtRoot, zName);
168 nRoot = (int)strlen(g.zExtRoot);
169 if( file_isfile(zPath, ExtFILE) ){
170 nScript = (int)strlen(zPath);
171 zScript = zPath;
172 }else{
173 for(i=nRoot+1; zPath[i]; i++){
174 char c = zPath[i];
175
+2 -5
--- src/import.c
+++ src/import.c
@@ -212,12 +212,12 @@
212212
/*
213213
** Use data accumulated in gg from a "tag" record to add a new
214214
** control artifact to the BLOB table.
215215
*/
216216
static void finish_tag(void){
217
+ Blob record, cksum;
217218
if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
218
- Blob record, cksum;
219219
blob_zero(&record);
220220
blob_appendf(&record, "D %s\n", gg.zDate);
221221
blob_appendf(&record, "T +sym-%F%F%F %s", gimport.zTagPre, gg.zTag,
222222
gimport.zTagSuf, gg.zFrom);
223223
if( gg.zComment ){
@@ -226,11 +226,10 @@
226226
blob_appendf(&record, "\nU %F\n", gg.zUser);
227227
md5sum_blob(&record, &cksum);
228228
blob_appendf(&record, "Z %b\n", &cksum);
229229
fast_insert_content(&record, 0, 0, 1);
230230
blob_reset(&cksum);
231
- blob_reset(&record);
232231
}
233232
import_reset(0);
234233
}
235234
236235
/*
@@ -337,12 +336,10 @@
337336
**
338337
** This behavior seems like a bug in git-fast-export, but it is easier
339338
** to work around the problem than to fix git-fast-export.
340339
*/
341340
if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
342
- record.nUsed = 0
343
- /*in case fast_insert_comment() did not indirectly blob_reset() it */;
344341
blob_appendf(&record, "D %s\n", gg.zDate);
345342
blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
346343
gimport.zBranchSuf, gg.zPrevCheckin);
347344
blob_appendf(&record, "U %F\n", gg.zUser);
348345
md5sum_blob(&record, &cksum);
@@ -349,14 +346,14 @@
349346
blob_appendf(&record, "Z %b\n", &cksum);
350347
db_multi_exec(
351348
"INSERT OR REPLACE INTO xtag(tname, tcontent)"
352349
" VALUES(%Q,%Q)", gg.zBranch, blob_str(&record)
353350
);
351
+ blob_reset(&record);
354352
blob_reset(&cksum);
355353
}
356354
357
- blob_reset(&record);
358355
fossil_free(gg.zPrevBranch);
359356
gg.zPrevBranch = gg.zBranch;
360357
gg.zBranch = 0;
361358
import_reset(0);
362359
}
363360
--- src/import.c
+++ src/import.c
@@ -212,12 +212,12 @@
212 /*
213 ** Use data accumulated in gg from a "tag" record to add a new
214 ** control artifact to the BLOB table.
215 */
216 static void finish_tag(void){
 
217 if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
218 Blob record, cksum;
219 blob_zero(&record);
220 blob_appendf(&record, "D %s\n", gg.zDate);
221 blob_appendf(&record, "T +sym-%F%F%F %s", gimport.zTagPre, gg.zTag,
222 gimport.zTagSuf, gg.zFrom);
223 if( gg.zComment ){
@@ -226,11 +226,10 @@
226 blob_appendf(&record, "\nU %F\n", gg.zUser);
227 md5sum_blob(&record, &cksum);
228 blob_appendf(&record, "Z %b\n", &cksum);
229 fast_insert_content(&record, 0, 0, 1);
230 blob_reset(&cksum);
231 blob_reset(&record);
232 }
233 import_reset(0);
234 }
235
236 /*
@@ -337,12 +336,10 @@
337 **
338 ** This behavior seems like a bug in git-fast-export, but it is easier
339 ** to work around the problem than to fix git-fast-export.
340 */
341 if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
342 record.nUsed = 0
343 /*in case fast_insert_comment() did not indirectly blob_reset() it */;
344 blob_appendf(&record, "D %s\n", gg.zDate);
345 blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
346 gimport.zBranchSuf, gg.zPrevCheckin);
347 blob_appendf(&record, "U %F\n", gg.zUser);
348 md5sum_blob(&record, &cksum);
@@ -349,14 +346,14 @@
349 blob_appendf(&record, "Z %b\n", &cksum);
350 db_multi_exec(
351 "INSERT OR REPLACE INTO xtag(tname, tcontent)"
352 " VALUES(%Q,%Q)", gg.zBranch, blob_str(&record)
353 );
 
354 blob_reset(&cksum);
355 }
356
357 blob_reset(&record);
358 fossil_free(gg.zPrevBranch);
359 gg.zPrevBranch = gg.zBranch;
360 gg.zBranch = 0;
361 import_reset(0);
362 }
363
--- src/import.c
+++ src/import.c
@@ -212,12 +212,12 @@
212 /*
213 ** Use data accumulated in gg from a "tag" record to add a new
214 ** control artifact to the BLOB table.
215 */
216 static void finish_tag(void){
217 Blob record, cksum;
218 if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
 
219 blob_zero(&record);
220 blob_appendf(&record, "D %s\n", gg.zDate);
221 blob_appendf(&record, "T +sym-%F%F%F %s", gimport.zTagPre, gg.zTag,
222 gimport.zTagSuf, gg.zFrom);
223 if( gg.zComment ){
@@ -226,11 +226,10 @@
226 blob_appendf(&record, "\nU %F\n", gg.zUser);
227 md5sum_blob(&record, &cksum);
228 blob_appendf(&record, "Z %b\n", &cksum);
229 fast_insert_content(&record, 0, 0, 1);
230 blob_reset(&cksum);
 
231 }
232 import_reset(0);
233 }
234
235 /*
@@ -337,12 +336,10 @@
336 **
337 ** This behavior seems like a bug in git-fast-export, but it is easier
338 ** to work around the problem than to fix git-fast-export.
339 */
340 if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
 
 
341 blob_appendf(&record, "D %s\n", gg.zDate);
342 blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
343 gimport.zBranchSuf, gg.zPrevCheckin);
344 blob_appendf(&record, "U %F\n", gg.zUser);
345 md5sum_blob(&record, &cksum);
@@ -349,14 +346,14 @@
346 blob_appendf(&record, "Z %b\n", &cksum);
347 db_multi_exec(
348 "INSERT OR REPLACE INTO xtag(tname, tcontent)"
349 " VALUES(%Q,%Q)", gg.zBranch, blob_str(&record)
350 );
351 blob_reset(&record);
352 blob_reset(&cksum);
353 }
354
 
355 fossil_free(gg.zPrevBranch);
356 gg.zPrevBranch = gg.zBranch;
357 gg.zBranch = 0;
358 import_reset(0);
359 }
360
-1
--- src/info.c
+++ src/info.c
@@ -2511,11 +2511,10 @@
25112511
}
25122512
rc = name_to_uuid(&uuid, -1, "*");
25132513
if( rc==1 ){
25142514
if( validate16(zName, nLen) ){
25152515
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
2516
- cgi_set_parameter_nocopy("tl","1",0);
25172516
tktview_page();
25182517
return;
25192518
}
25202519
if( db_exists("SELECT 1 FROM tag"
25212520
" WHERE tagname GLOB 'event-%q*'", zName) ){
25222521
--- src/info.c
+++ src/info.c
@@ -2511,11 +2511,10 @@
2511 }
2512 rc = name_to_uuid(&uuid, -1, "*");
2513 if( rc==1 ){
2514 if( validate16(zName, nLen) ){
2515 if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
2516 cgi_set_parameter_nocopy("tl","1",0);
2517 tktview_page();
2518 return;
2519 }
2520 if( db_exists("SELECT 1 FROM tag"
2521 " WHERE tagname GLOB 'event-%q*'", zName) ){
2522
--- src/info.c
+++ src/info.c
@@ -2511,11 +2511,10 @@
2511 }
2512 rc = name_to_uuid(&uuid, -1, "*");
2513 if( rc==1 ){
2514 if( validate16(zName, nLen) ){
2515 if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
 
2516 tktview_page();
2517 return;
2518 }
2519 if( db_exists("SELECT 1 FROM tag"
2520 " WHERE tagname GLOB 'event-%q*'", zName) ){
2521
+11 -19
--- src/main.c
+++ src/main.c
@@ -364,13 +364,10 @@
364364
#endif
365365
free(g.zErrMsg);
366366
if(g.db){
367367
db_close(0);
368368
}
369
- manifest_clear_cache();
370
- content_clear_cache(1);
371
- rebuild_clear_cache();
372369
/*
373370
** FIXME: The next two lines cannot always be enabled; however, they
374371
** are very useful for tracking down TH1 memory leaks.
375372
*/
376373
if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
@@ -2045,11 +2042,11 @@
20452042
g.httpIn = stdin;
20462043
fossil_binary_mode(g.httpOut);
20472044
fossil_binary_mode(g.httpIn);
20482045
g.cgiOutput = 1;
20492046
fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
2050
- /* Find the name of the CGI control file */
2047
+ /* Read and parse the CGI control file. */
20512048
if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){
20522049
zFile = g.argv[2];
20532050
}else if( g.argc>=2 ){
20542051
zFile = g.argv[1];
20552052
}else{
@@ -2149,10 +2146,20 @@
21492146
blob_token(&line,&value2);
21502147
fossil_setenv(blob_str(&value), blob_str(&value2));
21512148
blob_reset(&value);
21522149
blob_reset(&value2);
21532150
continue;
2151
+ }
2152
+ if( blob_eq(&key, "debug:") && blob_token(&line, &value) ){
2153
+ /* debug: FILENAME
2154
+ **
2155
+ ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
2156
+ ** into FILENAME.
2157
+ */
2158
+ g.fDebug = fossil_fopen(blob_str(&value), "ab");
2159
+ blob_reset(&value);
2160
+ continue;
21542161
}
21552162
if( blob_eq(&key, "errorlog:") && blob_token(&line, &value) ){
21562163
/* errorlog: FILENAME
21572164
**
21582165
** Causes messages from warnings, errors, and panics to be appended
@@ -2200,25 +2207,10 @@
22002207
*/
22012208
skin_use_alternative(blob_str(&value));
22022209
blob_reset(&value);
22032210
continue;
22042211
}
2205
- if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2206
- /* cgi-debug: FILENAME
2207
- **
2208
- ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
2209
- ** into FILENAME. Useful for debugging CGI configuration problems.
2210
- */
2211
- char *zNow = cgi_iso8601_datestamp();
2212
- cgi_load_environment();
2213
- g.fDebug = fossil_fopen(blob_str(&value), "ab");
2214
- blob_reset(&value);
2215
- cgi_debug("-------- BEGIN cgi at %s --------\n", zNow);
2216
- fossil_free(zNow);
2217
- cgi_print_all(1,2);
2218
- continue;
2219
- }
22202212
}
22212213
blob_reset(&config);
22222214
if( g.db==0 && g.zRepositoryName==0 && nRedirect==0 ){
22232215
cgi_panic("Unable to find or open the project repository");
22242216
}
22252217
--- src/main.c
+++ src/main.c
@@ -364,13 +364,10 @@
364 #endif
365 free(g.zErrMsg);
366 if(g.db){
367 db_close(0);
368 }
369 manifest_clear_cache();
370 content_clear_cache(1);
371 rebuild_clear_cache();
372 /*
373 ** FIXME: The next two lines cannot always be enabled; however, they
374 ** are very useful for tracking down TH1 memory leaks.
375 */
376 if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
@@ -2045,11 +2042,11 @@
2045 g.httpIn = stdin;
2046 fossil_binary_mode(g.httpOut);
2047 fossil_binary_mode(g.httpIn);
2048 g.cgiOutput = 1;
2049 fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
2050 /* Find the name of the CGI control file */
2051 if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){
2052 zFile = g.argv[2];
2053 }else if( g.argc>=2 ){
2054 zFile = g.argv[1];
2055 }else{
@@ -2149,10 +2146,20 @@
2149 blob_token(&line,&value2);
2150 fossil_setenv(blob_str(&value), blob_str(&value2));
2151 blob_reset(&value);
2152 blob_reset(&value2);
2153 continue;
 
 
 
 
 
 
 
 
 
 
2154 }
2155 if( blob_eq(&key, "errorlog:") && blob_token(&line, &value) ){
2156 /* errorlog: FILENAME
2157 **
2158 ** Causes messages from warnings, errors, and panics to be appended
@@ -2200,25 +2207,10 @@
2200 */
2201 skin_use_alternative(blob_str(&value));
2202 blob_reset(&value);
2203 continue;
2204 }
2205 if( blob_eq(&key, "cgi-debug:") && blob_token(&line, &value) ){
2206 /* cgi-debug: FILENAME
2207 **
2208 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
2209 ** into FILENAME. Useful for debugging CGI configuration problems.
2210 */
2211 char *zNow = cgi_iso8601_datestamp();
2212 cgi_load_environment();
2213 g.fDebug = fossil_fopen(blob_str(&value), "ab");
2214 blob_reset(&value);
2215 cgi_debug("-------- BEGIN cgi at %s --------\n", zNow);
2216 fossil_free(zNow);
2217 cgi_print_all(1,2);
2218 continue;
2219 }
2220 }
2221 blob_reset(&config);
2222 if( g.db==0 && g.zRepositoryName==0 && nRedirect==0 ){
2223 cgi_panic("Unable to find or open the project repository");
2224 }
2225
--- src/main.c
+++ src/main.c
@@ -364,13 +364,10 @@
364 #endif
365 free(g.zErrMsg);
366 if(g.db){
367 db_close(0);
368 }
 
 
 
369 /*
370 ** FIXME: The next two lines cannot always be enabled; however, they
371 ** are very useful for tracking down TH1 memory leaks.
372 */
373 if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
@@ -2045,11 +2042,11 @@
2042 g.httpIn = stdin;
2043 fossil_binary_mode(g.httpOut);
2044 fossil_binary_mode(g.httpIn);
2045 g.cgiOutput = 1;
2046 fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
2047 /* Read and parse the CGI control file. */
2048 if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){
2049 zFile = g.argv[2];
2050 }else if( g.argc>=2 ){
2051 zFile = g.argv[1];
2052 }else{
@@ -2149,10 +2146,20 @@
2146 blob_token(&line,&value2);
2147 fossil_setenv(blob_str(&value), blob_str(&value2));
2148 blob_reset(&value);
2149 blob_reset(&value2);
2150 continue;
2151 }
2152 if( blob_eq(&key, "debug:") && blob_token(&line, &value) ){
2153 /* debug: FILENAME
2154 **
2155 ** Causes output from cgi_debug() and CGIDEBUG(()) calls to go
2156 ** into FILENAME.
2157 */
2158 g.fDebug = fossil_fopen(blob_str(&value), "ab");
2159 blob_reset(&value);
2160 continue;
2161 }
2162 if( blob_eq(&key, "errorlog:") && blob_token(&line, &value) ){
2163 /* errorlog: FILENAME
2164 **
2165 ** Causes messages from warnings, errors, and panics to be appended
@@ -2200,25 +2207,10 @@
2207 */
2208 skin_use_alternative(blob_str(&value));
2209 blob_reset(&value);
2210 continue;
2211 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2212 }
2213 blob_reset(&config);
2214 if( g.db==0 && g.zRepositoryName==0 && nRedirect==0 ){
2215 cgi_panic("Unable to find or open the project repository");
2216 }
2217
+7 -21
--- src/manifest.c
+++ src/manifest.c
@@ -68,11 +68,11 @@
6868
*/
6969
struct Manifest {
7070
Blob content; /* The original content blob */
7171
int type; /* Type of artifact. One of CFTYPE_xxxxx */
7272
int rid; /* The blob-id for this manifest */
73
- const char *zBaseline;/* Baseline manifest. The B card. */
73
+ char *zBaseline; /* Baseline manifest. The B card. */
7474
Manifest *pBaseline; /* The actual baseline manifest */
7575
char *zComment; /* Decoded comment. The C card. */
7676
double rDate; /* Date and time from D card. 0.0 if no D card. */
7777
char *zUser; /* Name of the user from the U card. */
7878
char *zRepoCksum; /* MD5 checksum of the baseline content. R card. */
@@ -385,23 +385,10 @@
385385
/*
386386
** Shorthand for a control-artifact parsing error
387387
*/
388388
#define SYNTAX(T) {zErr=(T); goto manifest_syntax_error;}
389389
390
-/*
391
-** A cache of manifest IDs which manifest_parse() has seen in this
392
-** session.
393
-*/
394
-static Bag seenManifests = Bag_INIT;
395
-/*
396
-** Frees all memory owned by the manifest "has-seen" cache. Intended
397
-** to be called only from the app's atexit() handler.
398
-*/
399
-void manifest_clear_cache(){
400
- bag_clear(&seenManifests);
401
-}
402
-
403390
/*
404391
** Parse a blob into a Manifest object. The Manifest object
405392
** takes over the input blob and will free it when the
406393
** Manifest object is freed. Zeros are inserted into the blob
407394
** as string terminators so that blob should not be used again.
@@ -441,22 +428,23 @@
441428
char *zUuid;
442429
int sz = 0;
443430
int isRepeat;
444431
int nSelfTag = 0; /* Number of T cards referring to this manifest */
445432
int nSimpleTag = 0; /* Number of T cards with "+" prefix */
433
+ static Bag seen;
446434
const char *zErr = 0;
447435
unsigned int m;
448436
unsigned int seenCard = 0; /* Which card types have been seen */
449437
char zErrBuf[100]; /* Write error messages here */
450438
451439
if( rid==0 ){
452440
isRepeat = 1;
453
- }else if( bag_find(&seenManifests, rid) ){
441
+ }else if( bag_find(&seen, rid) ){
454442
isRepeat = 1;
455443
}else{
456444
isRepeat = 0;
457
- bag_insert(&seenManifests, rid);
445
+ bag_insert(&seen, rid);
458446
}
459447
460448
/* Every structural artifact ends with a '\n' character. Exit early
461449
** if that is not the case for this artifact.
462450
*/
@@ -1716,11 +1704,11 @@
17161704
*/
17171705
static int manifest_add_checkin_linkages(
17181706
int rid, /* The RID of the check-in */
17191707
Manifest *p, /* Manifest for this check-in */
17201708
int nParent, /* Number of parents for this check-in */
1721
- char * const * azParent /* hashes for each parent */
1709
+ char **azParent /* hashes for each parent */
17221710
){
17231711
int i;
17241712
int parentid = 0;
17251713
char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */
17261714
Stmt q;
@@ -2099,13 +2087,12 @@
20992087
if( (p = manifest_cache_find(rid))!=0 ){
21002088
blob_reset(pContent);
21012089
}else if( (p = manifest_parse(pContent, rid, 0))==0 ){
21022090
assert( blob_is_reset(pContent) || pContent==0 );
21032091
if( (flags & MC_NO_ERRORS)==0 ){
2104
- char * zErrUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid);
2105
- fossil_error(1, "syntax error in manifest [%S]", zErrUuid);
2106
- fossil_free(zErrUuid);
2092
+ fossil_error(1, "syntax error in manifest [%S]",
2093
+ db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
21072094
}
21082095
return 0;
21092096
}
21102097
if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
21112098
manifest_destroy(p);
@@ -2210,11 +2197,10 @@
22102197
case '-': type = 0; break; /* Cancel prior occurrences */
22112198
case '+': type = 1; break; /* Apply to target only */
22122199
case '*': type = 2; break; /* Propagate to descendants */
22132200
default:
22142201
fossil_error(1, "unknown tag type in manifest: %s", p->aTag);
2215
- manifest_destroy(p);
22162202
return 0;
22172203
}
22182204
tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue,
22192205
rid, p->rDate, tid);
22202206
}
22212207
--- src/manifest.c
+++ src/manifest.c
@@ -68,11 +68,11 @@
68 */
69 struct Manifest {
70 Blob content; /* The original content blob */
71 int type; /* Type of artifact. One of CFTYPE_xxxxx */
72 int rid; /* The blob-id for this manifest */
73 const char *zBaseline;/* Baseline manifest. The B card. */
74 Manifest *pBaseline; /* The actual baseline manifest */
75 char *zComment; /* Decoded comment. The C card. */
76 double rDate; /* Date and time from D card. 0.0 if no D card. */
77 char *zUser; /* Name of the user from the U card. */
78 char *zRepoCksum; /* MD5 checksum of the baseline content. R card. */
@@ -385,23 +385,10 @@
385 /*
386 ** Shorthand for a control-artifact parsing error
387 */
388 #define SYNTAX(T) {zErr=(T); goto manifest_syntax_error;}
389
390 /*
391 ** A cache of manifest IDs which manifest_parse() has seen in this
392 ** session.
393 */
394 static Bag seenManifests = Bag_INIT;
395 /*
396 ** Frees all memory owned by the manifest "has-seen" cache. Intended
397 ** to be called only from the app's atexit() handler.
398 */
399 void manifest_clear_cache(){
400 bag_clear(&seenManifests);
401 }
402
403 /*
404 ** Parse a blob into a Manifest object. The Manifest object
405 ** takes over the input blob and will free it when the
406 ** Manifest object is freed. Zeros are inserted into the blob
407 ** as string terminators so that blob should not be used again.
@@ -441,22 +428,23 @@
441 char *zUuid;
442 int sz = 0;
443 int isRepeat;
444 int nSelfTag = 0; /* Number of T cards referring to this manifest */
445 int nSimpleTag = 0; /* Number of T cards with "+" prefix */
 
446 const char *zErr = 0;
447 unsigned int m;
448 unsigned int seenCard = 0; /* Which card types have been seen */
449 char zErrBuf[100]; /* Write error messages here */
450
451 if( rid==0 ){
452 isRepeat = 1;
453 }else if( bag_find(&seenManifests, rid) ){
454 isRepeat = 1;
455 }else{
456 isRepeat = 0;
457 bag_insert(&seenManifests, rid);
458 }
459
460 /* Every structural artifact ends with a '\n' character. Exit early
461 ** if that is not the case for this artifact.
462 */
@@ -1716,11 +1704,11 @@
1716 */
1717 static int manifest_add_checkin_linkages(
1718 int rid, /* The RID of the check-in */
1719 Manifest *p, /* Manifest for this check-in */
1720 int nParent, /* Number of parents for this check-in */
1721 char * const * azParent /* hashes for each parent */
1722 ){
1723 int i;
1724 int parentid = 0;
1725 char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */
1726 Stmt q;
@@ -2099,13 +2087,12 @@
2099 if( (p = manifest_cache_find(rid))!=0 ){
2100 blob_reset(pContent);
2101 }else if( (p = manifest_parse(pContent, rid, 0))==0 ){
2102 assert( blob_is_reset(pContent) || pContent==0 );
2103 if( (flags & MC_NO_ERRORS)==0 ){
2104 char * zErrUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid);
2105 fossil_error(1, "syntax error in manifest [%S]", zErrUuid);
2106 fossil_free(zErrUuid);
2107 }
2108 return 0;
2109 }
2110 if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
2111 manifest_destroy(p);
@@ -2210,11 +2197,10 @@
2210 case '-': type = 0; break; /* Cancel prior occurrences */
2211 case '+': type = 1; break; /* Apply to target only */
2212 case '*': type = 2; break; /* Propagate to descendants */
2213 default:
2214 fossil_error(1, "unknown tag type in manifest: %s", p->aTag);
2215 manifest_destroy(p);
2216 return 0;
2217 }
2218 tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue,
2219 rid, p->rDate, tid);
2220 }
2221
--- src/manifest.c
+++ src/manifest.c
@@ -68,11 +68,11 @@
68 */
69 struct Manifest {
70 Blob content; /* The original content blob */
71 int type; /* Type of artifact. One of CFTYPE_xxxxx */
72 int rid; /* The blob-id for this manifest */
73 char *zBaseline; /* Baseline manifest. The B card. */
74 Manifest *pBaseline; /* The actual baseline manifest */
75 char *zComment; /* Decoded comment. The C card. */
76 double rDate; /* Date and time from D card. 0.0 if no D card. */
77 char *zUser; /* Name of the user from the U card. */
78 char *zRepoCksum; /* MD5 checksum of the baseline content. R card. */
@@ -385,23 +385,10 @@
385 /*
386 ** Shorthand for a control-artifact parsing error
387 */
388 #define SYNTAX(T) {zErr=(T); goto manifest_syntax_error;}
389
 
 
 
 
 
 
 
 
 
 
 
 
 
390 /*
391 ** Parse a blob into a Manifest object. The Manifest object
392 ** takes over the input blob and will free it when the
393 ** Manifest object is freed. Zeros are inserted into the blob
394 ** as string terminators so that blob should not be used again.
@@ -441,22 +428,23 @@
428 char *zUuid;
429 int sz = 0;
430 int isRepeat;
431 int nSelfTag = 0; /* Number of T cards referring to this manifest */
432 int nSimpleTag = 0; /* Number of T cards with "+" prefix */
433 static Bag seen;
434 const char *zErr = 0;
435 unsigned int m;
436 unsigned int seenCard = 0; /* Which card types have been seen */
437 char zErrBuf[100]; /* Write error messages here */
438
439 if( rid==0 ){
440 isRepeat = 1;
441 }else if( bag_find(&seen, rid) ){
442 isRepeat = 1;
443 }else{
444 isRepeat = 0;
445 bag_insert(&seen, rid);
446 }
447
448 /* Every structural artifact ends with a '\n' character. Exit early
449 ** if that is not the case for this artifact.
450 */
@@ -1716,11 +1704,11 @@
1704 */
1705 static int manifest_add_checkin_linkages(
1706 int rid, /* The RID of the check-in */
1707 Manifest *p, /* Manifest for this check-in */
1708 int nParent, /* Number of parents for this check-in */
1709 char **azParent /* hashes for each parent */
1710 ){
1711 int i;
1712 int parentid = 0;
1713 char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */
1714 Stmt q;
@@ -2099,13 +2087,12 @@
2087 if( (p = manifest_cache_find(rid))!=0 ){
2088 blob_reset(pContent);
2089 }else if( (p = manifest_parse(pContent, rid, 0))==0 ){
2090 assert( blob_is_reset(pContent) || pContent==0 );
2091 if( (flags & MC_NO_ERRORS)==0 ){
2092 fossil_error(1, "syntax error in manifest [%S]",
2093 db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
 
2094 }
2095 return 0;
2096 }
2097 if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
2098 manifest_destroy(p);
@@ -2210,11 +2197,10 @@
2197 case '-': type = 0; break; /* Cancel prior occurrences */
2198 case '+': type = 1; break; /* Apply to target only */
2199 case '*': type = 2; break; /* Propagate to descendants */
2200 default:
2201 fossil_error(1, "unknown tag type in manifest: %s", p->aTag);
 
2202 return 0;
2203 }
2204 tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue,
2205 rid, p->rDate, tid);
2206 }
2207
+6 -13
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,18 +176,18 @@
176176
177177
/*
178178
** Variables used to store state information about an on-going "rebuild"
179179
** or "deconstruct".
180180
*/
181
-static int totalSize; /* Total number of artifacts to process */
182
-static int processCnt; /* Number processed so far */
183
-static int ttyOutput; /* Do progress output */
184
-static Bag bagDone = Bag_INIT; /* Bag of records rebuilt */
181
+static int totalSize; /* Total number of artifacts to process */
182
+static int processCnt; /* Number processed so far */
183
+static int ttyOutput; /* Do progress output */
184
+static Bag bagDone; /* Bag of records rebuilt */
185185
186186
static char *zFNameFormat; /* Format string for filenames on deconstruct */
187187
static int cchFNamePrefix; /* Length of directory prefix in zFNameFormat */
188
-static const char *zDestDir;/* Destination directory on deconstruct */
188
+static char *zDestDir; /* Destination directory on deconstruct */
189189
static int prefixLength; /* Length of directory prefix for deconstruct */
190190
static int fKeepRid1; /* Flag to preserve RID=1 on de- and reconstruct */
191191
192192
193193
/*
@@ -201,17 +201,10 @@
201201
fflush(stdout);
202202
lastOutput = permill;
203203
}
204204
}
205205
206
-/*
207
-** Frees rebuild-level cached state. Intended only to be called by the
208
-** app-level atexit() handler.
209
-*/
210
-void rebuild_clear_cache(){
211
- bag_clear(&bagDone);
212
-}
213206
214207
/*
215208
** Called after each artifact is processed
216209
*/
217210
static void rebuild_step_done(int rid){
@@ -373,11 +366,11 @@
373366
Stmt s, q;
374367
int errCnt = 0;
375368
int incrSize;
376369
Blob sql;
377370
378
- bag_clear(&bagDone);
371
+ bag_init(&bagDone);
379372
ttyOutput = doOut;
380373
processCnt = 0;
381374
if (ttyOutput && !g.fQuiet) {
382375
percent_complete(0);
383376
}
384377
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,18 +176,18 @@
176
177 /*
178 ** Variables used to store state information about an on-going "rebuild"
179 ** or "deconstruct".
180 */
181 static int totalSize; /* Total number of artifacts to process */
182 static int processCnt; /* Number processed so far */
183 static int ttyOutput; /* Do progress output */
184 static Bag bagDone = Bag_INIT; /* Bag of records rebuilt */
185
186 static char *zFNameFormat; /* Format string for filenames on deconstruct */
187 static int cchFNamePrefix; /* Length of directory prefix in zFNameFormat */
188 static const char *zDestDir;/* Destination directory on deconstruct */
189 static int prefixLength; /* Length of directory prefix for deconstruct */
190 static int fKeepRid1; /* Flag to preserve RID=1 on de- and reconstruct */
191
192
193 /*
@@ -201,17 +201,10 @@
201 fflush(stdout);
202 lastOutput = permill;
203 }
204 }
205
206 /*
207 ** Frees rebuild-level cached state. Intended only to be called by the
208 ** app-level atexit() handler.
209 */
210 void rebuild_clear_cache(){
211 bag_clear(&bagDone);
212 }
213
214 /*
215 ** Called after each artifact is processed
216 */
217 static void rebuild_step_done(int rid){
@@ -373,11 +366,11 @@
373 Stmt s, q;
374 int errCnt = 0;
375 int incrSize;
376 Blob sql;
377
378 bag_clear(&bagDone);
379 ttyOutput = doOut;
380 processCnt = 0;
381 if (ttyOutput && !g.fQuiet) {
382 percent_complete(0);
383 }
384
--- src/rebuild.c
+++ src/rebuild.c
@@ -176,18 +176,18 @@
176
177 /*
178 ** Variables used to store state information about an on-going "rebuild"
179 ** or "deconstruct".
180 */
181 static int totalSize; /* Total number of artifacts to process */
182 static int processCnt; /* Number processed so far */
183 static int ttyOutput; /* Do progress output */
184 static Bag bagDone; /* Bag of records rebuilt */
185
186 static char *zFNameFormat; /* Format string for filenames on deconstruct */
187 static int cchFNamePrefix; /* Length of directory prefix in zFNameFormat */
188 static char *zDestDir; /* Destination directory on deconstruct */
189 static int prefixLength; /* Length of directory prefix for deconstruct */
190 static int fKeepRid1; /* Flag to preserve RID=1 on de- and reconstruct */
191
192
193 /*
@@ -201,17 +201,10 @@
201 fflush(stdout);
202 lastOutput = permill;
203 }
204 }
205
 
 
 
 
 
 
 
206
207 /*
208 ** Called after each artifact is processed
209 */
210 static void rebuild_step_done(int rid){
@@ -373,11 +366,11 @@
366 Stmt s, q;
367 int errCnt = 0;
368 int incrSize;
369 Blob sql;
370
371 bag_init(&bagDone);
372 ttyOutput = doOut;
373 processCnt = 0;
374 if (ttyOutput && !g.fQuiet) {
375 percent_complete(0);
376 }
377
+1 -1
--- src/regexp.c
+++ src/regexp.c
@@ -107,11 +107,11 @@
107107
if( c<0x80 ) c = 0xfffd;
108108
}else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80
109109
&& (p->z[p->i+1]&0xc0)==0x80 ){
110110
c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);
111111
p->i += 2;
112
- if( c<=0x7ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
112
+ if( c<=0x3ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
113113
}else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80
114114
&& (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){
115115
c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)
116116
| (p->z[p->i+2]&0x3f);
117117
p->i += 3;
118118
--- src/regexp.c
+++ src/regexp.c
@@ -107,11 +107,11 @@
107 if( c<0x80 ) c = 0xfffd;
108 }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80
109 && (p->z[p->i+1]&0xc0)==0x80 ){
110 c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);
111 p->i += 2;
112 if( c<=0x7ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
113 }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80
114 && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){
115 c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)
116 | (p->z[p->i+2]&0x3f);
117 p->i += 3;
118
--- src/regexp.c
+++ src/regexp.c
@@ -107,11 +107,11 @@
107 if( c<0x80 ) c = 0xfffd;
108 }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80
109 && (p->z[p->i+1]&0xc0)==0x80 ){
110 c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);
111 p->i += 2;
112 if( c<=0x3ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;
113 }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80
114 && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){
115 c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)
116 | (p->z[p->i+2]&0x3f);
117 p->i += 3;
118
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -402,11 +402,11 @@
402402
@ -- facilitate the display of "back links".
403403
@ --
404404
@ CREATE TABLE backlink(
405405
@ target TEXT, -- Where the hyperlink points to
406406
@ srctype INT, -- 0: check-in 1: ticket 2: wiki
407
-@ srcid INT, -- EVENT.OBJID for the source document
407
+@ srcid INT, -- rid for check-in or wiki. tkt_id for ticket.
408408
@ mtime TIMESTAMP, -- time that the hyperlink was added. Julian day.
409409
@ UNIQUE(target, srctype, srcid)
410410
@ );
411411
@ CREATE INDEX backlink_src ON backlink(srcid, srctype);
412412
@
413413
--- src/schema.c
+++ src/schema.c
@@ -402,11 +402,11 @@
402 @ -- facilitate the display of "back links".
403 @ --
404 @ CREATE TABLE backlink(
405 @ target TEXT, -- Where the hyperlink points to
406 @ srctype INT, -- 0: check-in 1: ticket 2: wiki
407 @ srcid INT, -- EVENT.OBJID for the source document
408 @ mtime TIMESTAMP, -- time that the hyperlink was added. Julian day.
409 @ UNIQUE(target, srctype, srcid)
410 @ );
411 @ CREATE INDEX backlink_src ON backlink(srcid, srctype);
412 @
413
--- src/schema.c
+++ src/schema.c
@@ -402,11 +402,11 @@
402 @ -- facilitate the display of "back links".
403 @ --
404 @ CREATE TABLE backlink(
405 @ target TEXT, -- Where the hyperlink points to
406 @ srctype INT, -- 0: check-in 1: ticket 2: wiki
407 @ srcid INT, -- rid for check-in or wiki. tkt_id for ticket.
408 @ mtime TIMESTAMP, -- time that the hyperlink was added. Julian day.
409 @ UNIQUE(target, srctype, srcid)
410 @ );
411 @ CREATE INDEX backlink_src ON backlink(srcid, srctype);
412 @
413
+5 -5
--- src/shell.c
+++ src/shell.c
@@ -5206,10 +5206,11 @@
52065206
rc = SQLITE_NOMEM;
52075207
}else{
52085208
int res;
52095209
str.next_out = aOut;
52105210
str.avail_out = nAlloc;
5211
+ deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
52115212
res = deflate(&str, Z_FINISH);
52125213
if( res==Z_STREAM_END ){
52135214
*ppOut = aOut;
52145215
*pnOut = (int)str.total_out;
52155216
}else{
@@ -5825,11 +5826,10 @@
58255826
rc = zipfileGetMode(apVal[3], bIsDir, &mode, &pTab->base.zErrMsg);
58265827
}
58275828
58285829
if( rc==SQLITE_OK ){
58295830
zPath = (const char*)sqlite3_value_text(apVal[2]);
5830
- if( zPath==0 ) zPath = "";
58315831
nPath = (int)strlen(zPath);
58325832
mTime = zipfileGetTime(apVal[4]);
58335833
}
58345834
58355835
if( rc==SQLITE_OK && bIsDir ){
@@ -5839,11 +5839,11 @@
58395839
** otherwise. */
58405840
if( zPath[nPath-1]!='/' ){
58415841
zFree = sqlite3_mprintf("%s/", zPath);
58425842
if( zFree==0 ){ rc = SQLITE_NOMEM; }
58435843
zPath = (const char*)zFree;
5844
- nPath = (int)strlen(zPath);
5844
+ nPath++;
58455845
}
58465846
}
58475847
58485848
/* Check that we're not inserting a duplicate entry -OR- updating an
58495849
** entry with a path, thereby making it into a duplicate. */
@@ -6232,23 +6232,23 @@
62326232
62336233
/* If this is a directory entry, ensure that there is exactly one '/'
62346234
** at the end of the path. Or, if this is not a directory and the path
62356235
** ends in '/' it is an error. */
62366236
if( bIsDir==0 ){
6237
- if( nName>0 && zName[nName-1]=='/' ){
6237
+ if( zName[nName-1]=='/' ){
62386238
zErr = sqlite3_mprintf("non-directory name must not end with /");
62396239
rc = SQLITE_ERROR;
62406240
goto zipfile_step_out;
62416241
}
62426242
}else{
6243
- if( nName==0 || zName[nName-1]!='/' ){
6243
+ if( zName[nName-1]!='/' ){
62446244
zName = zFree = sqlite3_mprintf("%s/", zName);
6245
+ nName++;
62456246
if( zName==0 ){
62466247
rc = SQLITE_NOMEM;
62476248
goto zipfile_step_out;
62486249
}
6249
- nName = (int)strlen(zName);
62506250
}else{
62516251
while( nName>1 && zName[nName-2]=='/' ) nName--;
62526252
}
62536253
}
62546254
62556255
--- src/shell.c
+++ src/shell.c
@@ -5206,10 +5206,11 @@
5206 rc = SQLITE_NOMEM;
5207 }else{
5208 int res;
5209 str.next_out = aOut;
5210 str.avail_out = nAlloc;
 
5211 res = deflate(&str, Z_FINISH);
5212 if( res==Z_STREAM_END ){
5213 *ppOut = aOut;
5214 *pnOut = (int)str.total_out;
5215 }else{
@@ -5825,11 +5826,10 @@
5825 rc = zipfileGetMode(apVal[3], bIsDir, &mode, &pTab->base.zErrMsg);
5826 }
5827
5828 if( rc==SQLITE_OK ){
5829 zPath = (const char*)sqlite3_value_text(apVal[2]);
5830 if( zPath==0 ) zPath = "";
5831 nPath = (int)strlen(zPath);
5832 mTime = zipfileGetTime(apVal[4]);
5833 }
5834
5835 if( rc==SQLITE_OK && bIsDir ){
@@ -5839,11 +5839,11 @@
5839 ** otherwise. */
5840 if( zPath[nPath-1]!='/' ){
5841 zFree = sqlite3_mprintf("%s/", zPath);
5842 if( zFree==0 ){ rc = SQLITE_NOMEM; }
5843 zPath = (const char*)zFree;
5844 nPath = (int)strlen(zPath);
5845 }
5846 }
5847
5848 /* Check that we're not inserting a duplicate entry -OR- updating an
5849 ** entry with a path, thereby making it into a duplicate. */
@@ -6232,23 +6232,23 @@
6232
6233 /* If this is a directory entry, ensure that there is exactly one '/'
6234 ** at the end of the path. Or, if this is not a directory and the path
6235 ** ends in '/' it is an error. */
6236 if( bIsDir==0 ){
6237 if( nName>0 && zName[nName-1]=='/' ){
6238 zErr = sqlite3_mprintf("non-directory name must not end with /");
6239 rc = SQLITE_ERROR;
6240 goto zipfile_step_out;
6241 }
6242 }else{
6243 if( nName==0 || zName[nName-1]!='/' ){
6244 zName = zFree = sqlite3_mprintf("%s/", zName);
 
6245 if( zName==0 ){
6246 rc = SQLITE_NOMEM;
6247 goto zipfile_step_out;
6248 }
6249 nName = (int)strlen(zName);
6250 }else{
6251 while( nName>1 && zName[nName-2]=='/' ) nName--;
6252 }
6253 }
6254
6255
--- src/shell.c
+++ src/shell.c
@@ -5206,10 +5206,11 @@
5206 rc = SQLITE_NOMEM;
5207 }else{
5208 int res;
5209 str.next_out = aOut;
5210 str.avail_out = nAlloc;
5211 deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
5212 res = deflate(&str, Z_FINISH);
5213 if( res==Z_STREAM_END ){
5214 *ppOut = aOut;
5215 *pnOut = (int)str.total_out;
5216 }else{
@@ -5825,11 +5826,10 @@
5826 rc = zipfileGetMode(apVal[3], bIsDir, &mode, &pTab->base.zErrMsg);
5827 }
5828
5829 if( rc==SQLITE_OK ){
5830 zPath = (const char*)sqlite3_value_text(apVal[2]);
 
5831 nPath = (int)strlen(zPath);
5832 mTime = zipfileGetTime(apVal[4]);
5833 }
5834
5835 if( rc==SQLITE_OK && bIsDir ){
@@ -5839,11 +5839,11 @@
5839 ** otherwise. */
5840 if( zPath[nPath-1]!='/' ){
5841 zFree = sqlite3_mprintf("%s/", zPath);
5842 if( zFree==0 ){ rc = SQLITE_NOMEM; }
5843 zPath = (const char*)zFree;
5844 nPath++;
5845 }
5846 }
5847
5848 /* Check that we're not inserting a duplicate entry -OR- updating an
5849 ** entry with a path, thereby making it into a duplicate. */
@@ -6232,23 +6232,23 @@
6232
6233 /* If this is a directory entry, ensure that there is exactly one '/'
6234 ** at the end of the path. Or, if this is not a directory and the path
6235 ** ends in '/' it is an error. */
6236 if( bIsDir==0 ){
6237 if( zName[nName-1]=='/' ){
6238 zErr = sqlite3_mprintf("non-directory name must not end with /");
6239 rc = SQLITE_ERROR;
6240 goto zipfile_step_out;
6241 }
6242 }else{
6243 if( zName[nName-1]!='/' ){
6244 zName = zFree = sqlite3_mprintf("%s/", zName);
6245 nName++;
6246 if( zName==0 ){
6247 rc = SQLITE_NOMEM;
6248 goto zipfile_step_out;
6249 }
 
6250 }else{
6251 while( nName>1 && zName[nName-2]=='/' ) nName--;
6252 }
6253 }
6254
6255
+1 -9
--- src/smtp.c
+++ src/smtp.c
@@ -598,44 +598,36 @@
598598
** to the list of users TO. FROM is the sender of the email.
599599
**
600600
** Options:
601601
**
602602
** --direct Go directly to the TO domain. Bypass MX lookup
603
-** --relayhost R Use R as relay host directly for delivery.
604603
** --port N Use TCP port N instead of 25
605604
** --trace Show the SMTP conversation on the console
606605
*/
607606
void test_smtp_send(void){
608607
SmtpSession *p;
609608
const char *zFrom;
610609
int nTo;
611610
const char *zToDomain;
612611
const char *zFromDomain;
613
- const char *zRelay;
614612
const char **azTo;
615613
int smtpPort = 25;
616614
const char *zPort;
617615
Blob body;
618616
u32 smtpFlags = SMTP_PORT;
619617
if( find_option("trace",0,0)!=0 ) smtpFlags |= SMTP_TRACE_STDOUT;
620618
if( find_option("direct",0,0)!=0 ) smtpFlags |= SMTP_DIRECT;
621619
zPort = find_option("port",0,1);
622620
if( zPort ) smtpPort = atoi(zPort);
623
- zRelay = find_option("relayhost",0,1);
624621
verify_all_options();
625622
if( g.argc<5 ) usage("EMAIL FROM TO ...");
626623
blob_read_from_file(&body, g.argv[2], ExtFILE);
627624
zFrom = g.argv[3];
628625
nTo = g.argc-4;
629626
azTo = (const char**)g.argv+4;
630627
zFromDomain = domainOfAddr(zFrom);
631
- if( zRelay!=0 && zRelay[0]!= 0) {
632
- smtpFlags |= SMTP_DIRECT;
633
- zToDomain = zRelay;
634
- }else{
635
- zToDomain = domainOfAddr(azTo[0]);
636
- }
628
+ zToDomain = domainOfAddr(azTo[0]);
637629
p = smtp_session_new(zFromDomain, zToDomain, smtpFlags, smtpPort);
638630
if( p->zErr ){
639631
fossil_fatal("%s", p->zErr);
640632
}
641633
fossil_print("Connection to \"%s\"\n", p->zHostname);
642634
--- src/smtp.c
+++ src/smtp.c
@@ -598,44 +598,36 @@
598 ** to the list of users TO. FROM is the sender of the email.
599 **
600 ** Options:
601 **
602 ** --direct Go directly to the TO domain. Bypass MX lookup
603 ** --relayhost R Use R as relay host directly for delivery.
604 ** --port N Use TCP port N instead of 25
605 ** --trace Show the SMTP conversation on the console
606 */
607 void test_smtp_send(void){
608 SmtpSession *p;
609 const char *zFrom;
610 int nTo;
611 const char *zToDomain;
612 const char *zFromDomain;
613 const char *zRelay;
614 const char **azTo;
615 int smtpPort = 25;
616 const char *zPort;
617 Blob body;
618 u32 smtpFlags = SMTP_PORT;
619 if( find_option("trace",0,0)!=0 ) smtpFlags |= SMTP_TRACE_STDOUT;
620 if( find_option("direct",0,0)!=0 ) smtpFlags |= SMTP_DIRECT;
621 zPort = find_option("port",0,1);
622 if( zPort ) smtpPort = atoi(zPort);
623 zRelay = find_option("relayhost",0,1);
624 verify_all_options();
625 if( g.argc<5 ) usage("EMAIL FROM TO ...");
626 blob_read_from_file(&body, g.argv[2], ExtFILE);
627 zFrom = g.argv[3];
628 nTo = g.argc-4;
629 azTo = (const char**)g.argv+4;
630 zFromDomain = domainOfAddr(zFrom);
631 if( zRelay!=0 && zRelay[0]!= 0) {
632 smtpFlags |= SMTP_DIRECT;
633 zToDomain = zRelay;
634 }else{
635 zToDomain = domainOfAddr(azTo[0]);
636 }
637 p = smtp_session_new(zFromDomain, zToDomain, smtpFlags, smtpPort);
638 if( p->zErr ){
639 fossil_fatal("%s", p->zErr);
640 }
641 fossil_print("Connection to \"%s\"\n", p->zHostname);
642
--- src/smtp.c
+++ src/smtp.c
@@ -598,44 +598,36 @@
598 ** to the list of users TO. FROM is the sender of the email.
599 **
600 ** Options:
601 **
602 ** --direct Go directly to the TO domain. Bypass MX lookup
 
603 ** --port N Use TCP port N instead of 25
604 ** --trace Show the SMTP conversation on the console
605 */
606 void test_smtp_send(void){
607 SmtpSession *p;
608 const char *zFrom;
609 int nTo;
610 const char *zToDomain;
611 const char *zFromDomain;
 
612 const char **azTo;
613 int smtpPort = 25;
614 const char *zPort;
615 Blob body;
616 u32 smtpFlags = SMTP_PORT;
617 if( find_option("trace",0,0)!=0 ) smtpFlags |= SMTP_TRACE_STDOUT;
618 if( find_option("direct",0,0)!=0 ) smtpFlags |= SMTP_DIRECT;
619 zPort = find_option("port",0,1);
620 if( zPort ) smtpPort = atoi(zPort);
 
621 verify_all_options();
622 if( g.argc<5 ) usage("EMAIL FROM TO ...");
623 blob_read_from_file(&body, g.argv[2], ExtFILE);
624 zFrom = g.argv[3];
625 nTo = g.argc-4;
626 azTo = (const char**)g.argv+4;
627 zFromDomain = domainOfAddr(zFrom);
628 zToDomain = domainOfAddr(azTo[0]);
 
 
 
 
 
629 p = smtp_session_new(zFromDomain, zToDomain, smtpFlags, smtpPort);
630 if( p->zErr ){
631 fossil_fatal("%s", p->zErr);
632 }
633 fossil_print("Connection to \"%s\"\n", p->zHostname);
634
+719 -1331
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1165,11 +1165,11 @@
11651165
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11661166
** [sqlite_version()] and [sqlite_source_id()].
11671167
*/
11681168
#define SQLITE_VERSION "3.31.0"
11691169
#define SQLITE_VERSION_NUMBER 3031000
1170
-#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3"
1170
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
11711171
11721172
/*
11731173
** CAPI3REF: Run-Time Library Version Numbers
11741174
** KEYWORDS: sqlite3_version sqlite3_sourceid
11751175
**
@@ -1581,11 +1581,10 @@
15811581
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
15821582
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
15831583
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
15841584
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
15851585
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
1586
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
15871586
15881587
/*
15891588
** CAPI3REF: Flags For File Open Operations
15901589
**
15911590
** These bit values are intended for use in the
@@ -2022,20 +2021,20 @@
20222021
**
20232022
** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
20242023
** ^The [SQLITE_FCNTL_BUSYHANDLER]
20252024
** file-control may be invoked by SQLite on the database file handle
20262025
** shortly after it is opened in order to provide a custom VFS with access
2027
-** to the connection's busy-handler callback. The argument is of type (void**)
2026
+** to the connections busy-handler callback. The argument is of type (void **)
20282027
** - an array of two (void *) values. The first (void *) actually points
2029
-** to a function of type (int (*)(void *)). In order to invoke the connection's
2028
+** to a function of type (int (*)(void *)). In order to invoke the connections
20302029
** busy-handler, this function should be invoked with the second (void *) in
20312030
** the array as the only argument. If it returns non-zero, then the operation
20322031
** should be retried. If it returns zero, the custom VFS should abandon the
20332032
** current operation.
20342033
**
20352034
** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
2036
-** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
2035
+** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
20372036
** to have SQLite generate a
20382037
** temporary filename using the same algorithm that is followed to generate
20392038
** temporary filenames for TEMP tables and other internal uses. The
20402039
** argument should be a char** which will be filled with the filename
20412040
** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -2144,11 +2143,11 @@
21442143
** interface can be used to find if any database on the connection has changed,
21452144
** but that interface responds to changes on TEMP as well as MAIN and does
21462145
** not provide a mechanism to detect changes to MAIN only. Also, the
21472146
** [sqlite3_total_changes()] interface responds to internal changes only and
21482147
** omits changes made by other database connections. The
2149
-** [PRAGMA data_version] command provides a mechanism to detect changes to
2148
+** [PRAGMA data_version] command provide a mechanism to detect changes to
21502149
** a single attached database that occur due to other database connections,
21512150
** but omits changes implemented by the database connection on which it is
21522151
** called. This file control is the only mechanism to detect changes that
21532152
** happen either internally or externally and that are associated with
21542153
** a particular attached database.
@@ -2232,14 +2231,14 @@
22322231
** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
22332232
** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
22342233
** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
22352234
** may be appended to the sqlite3_vfs object and the iVersion value
22362235
** may increase again in future versions of SQLite.
2237
-** Note that due to an oversight, the structure
2238
-** of the sqlite3_vfs object changed in the transition from
2236
+** Note that the structure
2237
+** of the sqlite3_vfs object changes in the transition from
22392238
** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
2240
-** and yet the iVersion field was not increased.
2239
+** and yet the iVersion field was not modified.
22412240
**
22422241
** The szOsFile field is the size of the subclassed [sqlite3_file]
22432242
** structure used by this VFS. mxPathname is the maximum length of
22442243
** a pathname in this VFS.
22452244
**
@@ -2326,11 +2325,11 @@
23262325
** be created, and that it is an error if it already exists.
23272326
** It is <i>not</i> used to indicate the file should be opened
23282327
** for exclusive access.
23292328
**
23302329
** ^At least szOsFile bytes of memory are allocated by SQLite
2331
-** to hold the [sqlite3_file] structure passed as the third
2330
+** to hold the [sqlite3_file] structure passed as the third
23322331
** argument to xOpen. The xOpen method does not have to
23332332
** allocate the structure; it should just fill it in. Note that
23342333
** the xOpen method must set the sqlite3_file.pMethods to either
23352334
** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
23362335
** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -2449,10 +2448,11 @@
24492448
** SQLite.
24502449
*/
24512450
#define SQLITE_ACCESS_EXISTS 0
24522451
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
24532452
#define SQLITE_ACCESS_READ 2 /* Unused */
2453
+#define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
24542454
24552455
/*
24562456
** CAPI3REF: Flags for the xShmLock VFS method
24572457
**
24582458
** These integer constants define the various locking operations
@@ -2663,11 +2663,11 @@
26632663
** Every memory allocation request coming in through [sqlite3_malloc()]
26642664
** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
26652665
** that causes the corresponding memory allocation to fail.
26662666
**
26672667
** The xInit method initializes the memory allocator. For example,
2668
-** it might allocate any required mutexes or initialize internal data
2668
+** it might allocate any require mutexes or initialize internal data
26692669
** structures. The xShutdown method is invoked (indirectly) by
26702670
** [sqlite3_shutdown()] and should deallocate any resources acquired
26712671
** by xInit. The pAppData pointer is used as the only parameter to
26722672
** xInit and xShutdown.
26732673
**
@@ -2804,11 +2804,11 @@
28042804
**
28052805
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
28062806
** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
28072807
** that SQLite can use for the database page cache with the default page
28082808
** cache implementation.
2809
-** This configuration option is a no-op if an application-defined page
2809
+** This configuration option is a no-op if an application-define page
28102810
** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
28112811
** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
28122812
** 8-byte aligned memory (pMem), the size of each page cache line (sz),
28132813
** and the number of cache lines (N).
28142814
** The sz argument should be the size of the largest database page
@@ -3289,11 +3289,11 @@
32893289
** </dd>
32903290
**
32913291
** [[SQLITE_DBCONFIG_DQS_DML]]
32923292
** <dt>SQLITE_DBCONFIG_DQS_DML</td>
32933293
** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
3294
-** the legacy [double-quoted string literal] misfeature for DML statements
3294
+** the legacy [double-quoted string literal] misfeature for DML statement
32953295
** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
32963296
** default value of this setting is determined by the [-DSQLITE_DQS]
32973297
** compile-time option.
32983298
** </dd>
32993299
**
@@ -3550,11 +3550,11 @@
35503550
** will be rolled back automatically.
35513551
**
35523552
** ^The sqlite3_interrupt(D) call is in effect until all currently running
35533553
** SQL statements on [database connection] D complete. ^Any new SQL statements
35543554
** that are started after the sqlite3_interrupt() call and before the
3555
-** running statement count reaches zero are interrupted as if they had been
3555
+** running statements reaches zero are interrupted as if they had been
35563556
** running prior to the sqlite3_interrupt() call. ^New SQL statements
35573557
** that are started after the running statement count reaches zero are
35583558
** not effected by the sqlite3_interrupt().
35593559
** ^A call to sqlite3_interrupt(D) that occurs when there are no running
35603560
** SQL statements is a no-op and has no effect on SQL statements
@@ -3718,13 +3718,13 @@
37183718
** Alice | 43
37193719
** Bob | 28
37203720
** Cindy | 21
37213721
** </pre></blockquote>
37223722
**
3723
-** There are two columns (M==2) and three rows (N==3). Thus the
3723
+** There are two column (M==2) and three rows (N==3). Thus the
37243724
** result table has 8 entries. Suppose the result table is stored
3725
-** in an array named azResult. Then azResult holds this content:
3725
+** in an array names azResult. Then azResult holds this content:
37263726
**
37273727
** <blockquote><pre>
37283728
** azResult&#91;0] = "Name";
37293729
** azResult&#91;1] = "Age";
37303730
** azResult&#91;2] = "Alice";
@@ -3873,10 +3873,23 @@
38733873
** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
38743874
** sqlite3_malloc64(), and sqlite3_realloc64()
38753875
** is always aligned to at least an 8 byte boundary, or to a
38763876
** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
38773877
** option is used.
3878
+**
3879
+** In SQLite version 3.5.0 and 3.5.1, it was possible to define
3880
+** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
3881
+** implementation of these routines to be omitted. That capability
3882
+** is no longer provided. Only built-in memory allocators can be used.
3883
+**
3884
+** Prior to SQLite version 3.7.10, the Windows OS interface layer called
3885
+** the system malloc() and free() directly when converting
3886
+** filenames between the UTF-8 encoding used by SQLite
3887
+** and whatever filename encoding is used by the particular Windows
3888
+** installation. Memory allocation errors were detected, but
3889
+** they were reported back as [SQLITE_CANTOPEN] or
3890
+** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
38783891
**
38793892
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
38803893
** must be either NULL or else pointers obtained from a prior
38813894
** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
38823895
** not yet been released.
@@ -3922,11 +3935,11 @@
39223935
** CAPI3REF: Pseudo-Random Number Generator
39233936
**
39243937
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
39253938
** select random [ROWID | ROWIDs] when inserting new records into a table that
39263939
** already uses the largest possible [ROWID]. The PRNG is also used for
3927
-** the built-in random() and randomblob() SQL functions. This interface allows
3940
+** the build-in random() and randomblob() SQL functions. This interface allows
39283941
** applications to access the same PRNG for other purposes.
39293942
**
39303943
** ^A call to this routine stores N bytes of randomness into buffer P.
39313944
** ^The P parameter can be a NULL pointer.
39323945
**
@@ -4523,11 +4536,11 @@
45234536
** a VFS implementation when the flags parameter to xOpen() has one or
45244537
** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
45254538
** P is the name of the query parameter, then
45264539
** sqlite3_uri_parameter(F,P) returns the value of the P
45274540
** parameter if it exists or a NULL pointer if P does not appear as a
4528
-** query parameter on F. If P is a query parameter of F and it
4541
+** query parameter on F. If P is a query parameter of F
45294542
** has no explicit value, then sqlite3_uri_parameter(F,P) returns
45304543
** a pointer to an empty string.
45314544
**
45324545
** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
45334546
** parameter and returns true (1) or false (0) according to the value
@@ -4535,11 +4548,11 @@
45354548
** value of query parameter P is one of "yes", "true", or "on" in any
45364549
** case or if the value begins with a non-zero number. The
45374550
** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
45384551
** query parameter P is one of "no", "false", or "off" in any case or
45394552
** if the value begins with a numeric zero. If P is not a query
4540
-** parameter on F or if the value of P does not match any of the
4553
+** parameter on F or if the value of P is does not match any of the
45414554
** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
45424555
**
45434556
** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
45444557
** 64-bit signed integer and returns that integer, or D if P does not
45454558
** exist. If the value of P is something other than an integer, then
@@ -4872,16 +4885,16 @@
48724885
** in order to find the underlying cause of the problem. With the "v2" prepare
48734886
** interfaces, the underlying reason for the error is returned immediately.
48744887
** </li>
48754888
**
48764889
** <li>
4877
-** ^If the specific value bound to a [parameter | host parameter] in the
4890
+** ^If the specific value bound to [parameter | host parameter] in the
48784891
** WHERE clause might influence the choice of query plan for a statement,
48794892
** then the statement will be automatically recompiled, as if there had been
4880
-** a schema change, on the first [sqlite3_step()] call following any change
4893
+** a schema change, on the first [sqlite3_step()] call following any change
48814894
** to the [sqlite3_bind_text | bindings] of that [parameter].
4882
-** ^The specific value of a WHERE-clause [parameter] might influence the
4895
+** ^The specific value of WHERE-clause [parameter] might influence the
48834896
** choice of query plan if the parameter is the left-hand side of a [LIKE]
48844897
** or [GLOB] operator or if the parameter is compared to an indexed column
48854898
** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
48864899
** </li>
48874900
** </ol>
@@ -5386,19 +5399,23 @@
53865399
** the statement, where N is the second function argument.
53875400
** ^The left-most column is column 0 for these routines.
53885401
**
53895402
** ^If the Nth column returned by the statement is an expression or
53905403
** subquery and is not a column value, then all of these functions return
5391
-** NULL. ^These routines might also return NULL if a memory allocation error
5404
+** NULL. ^These routine might also return NULL if a memory allocation error
53925405
** occurs. ^Otherwise, they return the name of the attached database, table,
53935406
** or column that query result column was extracted from.
53945407
**
53955408
** ^As with all other SQLite APIs, those whose names end with "16" return
53965409
** UTF-16 encoded strings and the other functions return UTF-8.
53975410
**
53985411
** ^These APIs are only available if the library was compiled with the
53995412
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
5413
+**
5414
+** If two or more threads call one or more of these routines against the same
5415
+** prepared statement and column at the same time then the results are
5416
+** undefined.
54005417
**
54015418
** If two or more threads call one or more
54025419
** [sqlite3_column_database_name | column metadata interfaces]
54035420
** for the same [prepared statement] and result column
54045421
** at the same time then the results are undefined.
@@ -5532,11 +5549,11 @@
55325549
** METHOD: sqlite3_stmt
55335550
**
55345551
** ^The sqlite3_data_count(P) interface returns the number of columns in the
55355552
** current row of the result set of [prepared statement] P.
55365553
** ^If prepared statement P does not have results ready to return
5537
-** (via calls to the [sqlite3_column_int | sqlite3_column()] family of
5554
+** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
55385555
** interfaces) then sqlite3_data_count(P) returns 0.
55395556
** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
55405557
** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
55415558
** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
55425559
** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -6034,16 +6051,13 @@
60346051
** These constants may be ORed together with the
60356052
** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
60366053
** to [sqlite3_create_function()], [sqlite3_create_function16()], or
60376054
** [sqlite3_create_function_v2()].
60386055
**
6039
-** The SQLITE_DETERMINISTIC flag means that the new function always gives
6040
-** the same output when the input parameters are the same. The abs() function
6041
-** is deterministic, for example, but randomblob() is not. Functions must
6042
-** be deterministic in order to be used in certain contexts such as
6043
-** [CHECK constraints] or [generated columns]. SQLite might also optimize
6044
-** deterministic functions by factoring them out of inner loops.
6056
+** The SQLITE_DETERMINISTIC flag means that the new function will always
6057
+** maps the same inputs into the same output. The abs() function is
6058
+** deterministic, for example, but randomblob() is not.
60456059
**
60466060
** The SQLITE_DIRECTONLY flag means that the function may only be invoked
60476061
** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
60486062
** a security feature which is recommended for all
60496063
** [application-defined SQL functions] that have side-effects. This flag
@@ -6118,12 +6132,12 @@
61186132
**
61196133
** <b>Details:</b>
61206134
**
61216135
** These routines extract type, size, and content information from
61226136
** [protected sqlite3_value] objects. Protected sqlite3_value objects
6123
-** are used to pass parameter information into the functions that
6124
-** implement [application-defined SQL functions] and [virtual tables].
6137
+** are used to pass parameter information into implementation of
6138
+** [application-defined SQL functions] and [virtual tables].
61256139
**
61266140
** These routines work only with [protected sqlite3_value] objects.
61276141
** Any attempt to use these routines on an [unprotected sqlite3_value]
61286142
** is not threadsafe.
61296143
**
@@ -6176,11 +6190,11 @@
61766190
** the return value is arbitrary and meaningless.
61776191
**
61786192
** ^The sqlite3_value_frombind(X) interface returns non-zero if the
61796193
** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
61806194
** interfaces. ^If X comes from an SQL literal value, or a table column,
6181
-** or an expression, then sqlite3_value_frombind(X) returns zero.
6195
+** and expression, then sqlite3_value_frombind(X) returns zero.
61826196
**
61836197
** Please pay particular attention to the fact that the pointer returned
61846198
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
61856199
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
61866200
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6262,12 +6276,12 @@
62626276
**
62636277
** Implementations of aggregate SQL functions use this
62646278
** routine to allocate memory for storing their state.
62656279
**
62666280
** ^The first time the sqlite3_aggregate_context(C,N) routine is called
6267
-** for a particular aggregate function, SQLite allocates
6268
-** N bytes of memory, zeroes out that memory, and returns a pointer
6281
+** for a particular aggregate function, SQLite
6282
+** allocates N of memory, zeroes out that memory, and returns a pointer
62696283
** to the new memory. ^On second and subsequent calls to
62706284
** sqlite3_aggregate_context() for the same aggregate function instance,
62716285
** the same buffer is returned. Sqlite3_aggregate_context() is normally
62726286
** called once for each invocation of the xStep callback and then one
62736287
** last time when the xFinal callback is invoked. ^(When no rows match
@@ -6280,11 +6294,11 @@
62806294
** when first called if N is less than or equal to zero or if a memory
62816295
** allocate error occurs.
62826296
**
62836297
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
62846298
** determined by the N parameter on first successful call. Changing the
6285
-** value of N in any subsequents call to sqlite3_aggregate_context() within
6299
+** value of N in subsequent call to sqlite3_aggregate_context() within
62866300
** the same aggregate function instance will not resize the memory
62876301
** allocation.)^ Within the xFinal callback, it is customary to set
62886302
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
62896303
** pointless memory allocations occur.
62906304
**
@@ -6628,11 +6642,11 @@
66286642
** <li> If A&lt;B THEN B&gt;A.
66296643
** <li> If A&lt;B and B&lt;C then A&lt;C.
66306644
** </ol>
66316645
**
66326646
** If a collating function fails any of the above constraints and that
6633
-** collating function is registered and used, then the behavior of SQLite
6647
+** collating function is registered and used, then the behavior of SQLite
66346648
** is undefined.
66356649
**
66366650
** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
66376651
** with the addition that the xDestroy callback is invoked on pArg when
66386652
** the collating function is deleted.
@@ -6955,20 +6969,16 @@
69556969
69566970
/*
69576971
** CAPI3REF: Return The Filename For A Database Connection
69586972
** METHOD: sqlite3
69596973
**
6960
-** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename
6961
-** associated with database N of connection D.
6962
-** ^If there is no attached database N on the database
6974
+** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
6975
+** associated with database N of connection D. ^The main database file
6976
+** has the name "main". If there is no attached database N on the database
69636977
** connection D, or if database N is a temporary or in-memory database, then
69646978
** this function will return either a NULL pointer or an empty string.
69656979
**
6966
-** ^The string value returned by this routine is owned and managed by
6967
-** the database connection. ^The value will be valid until the database N
6968
-** is [DETACH]-ed or until the database connection closes.
6969
-**
69706980
** ^The filename returned by this function is the output of the
69716981
** xFullPathname method of the [VFS]. ^In other words, the filename
69726982
** will be an absolute pathname, even if the filename used
69736983
** to open the database originally was a URI or relative pathname.
69746984
*/
@@ -7118,23 +7128,19 @@
71187128
** In prior versions of SQLite,
71197129
** sharing was enabled or disabled for each thread separately.
71207130
**
71217131
** ^(The cache sharing mode set by this interface effects all subsequent
71227132
** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
7123
-** Existing database connections continue to use the sharing mode
7133
+** Existing database connections continue use the sharing mode
71247134
** that was in effect at the time they were opened.)^
71257135
**
71267136
** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
71277137
** successfully. An [error code] is returned otherwise.)^
71287138
**
7129
-** ^Shared cache is disabled by default. It is recommended that it stay
7130
-** that way. In other words, do not use this routine. This interface
7131
-** continues to be provided for historical compatibility, but its use is
7132
-** discouraged. Any use of shared cache is discouraged. If shared cache
7133
-** must be used, it is recommended that shared cache only be enabled for
7134
-** individual database connections using the [sqlite3_open_v2()] interface
7135
-** with the [SQLITE_OPEN_SHAREDCACHE] flag.
7139
+** ^Shared cache is disabled by default. But this might change in
7140
+** future releases of SQLite. Applications that care about shared
7141
+** cache setting should set it explicitly.
71367142
**
71377143
** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
71387144
** and will always return SQLITE_MISUSE. On those systems,
71397145
** shared cache mode should be enabled per-database connection via
71407146
** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -7263,11 +7269,11 @@
72637269
** information about column C of table T in database D
72647270
** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
72657271
** interface returns SQLITE_OK and fills in the non-NULL pointers in
72667272
** the final five arguments with appropriate values if the specified
72677273
** column exists. ^The sqlite3_table_column_metadata() interface returns
7268
-** SQLITE_ERROR if the specified column does not exist.
7274
+** SQLITE_ERROR and if the specified column does not exist.
72697275
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
72707276
** NULL pointer, then this routine simply checks for the existence of the
72717277
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
72727278
** does not. If the table name parameter T in a call to
72737279
** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -7405,11 +7411,11 @@
74057411
** [sqlite3_load_extension()] and the SQL function [load_extension()].
74067412
** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
74077413
** to enable or disable only the C-API.)^
74087414
**
74097415
** <b>Security warning:</b> It is recommended that extension loading
7410
-** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
7416
+** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
74117417
** rather than this interface, so the [load_extension()] SQL function
74127418
** remains disabled. This will prevent SQL injections from giving attackers
74137419
** access to extension loading capabilities.
74147420
*/
74157421
SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -7492,11 +7498,11 @@
74927498
/*
74937499
** CAPI3REF: Virtual Table Object
74947500
** KEYWORDS: sqlite3_module {virtual table module}
74957501
**
74967502
** This structure, sometimes called a "virtual table module",
7497
-** defines the implementation of a [virtual table].
7503
+** defines the implementation of a [virtual tables].
74987504
** This structure consists mostly of methods for the module.
74997505
**
75007506
** ^A virtual table module is created by filling in a persistent
75017507
** instance of this structure and passing a pointer to that instance
75027508
** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -7589,17 +7595,11 @@
75897595
** The [xBestIndex] method must fill aConstraintUsage[] with information
75907596
** about what parameters to pass to xFilter. ^If argvIndex>0 then
75917597
** the right-hand side of the corresponding aConstraint[] is evaluated
75927598
** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
75937599
** is true, then the constraint is assumed to be fully handled by the
7594
-** virtual table and might not be checked again by the byte code.)^ ^(The
7595
-** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
7596
-** is left in its default setting of false, the constraint will always be
7597
-** checked separately in byte code. If the omit flag is change to true, then
7598
-** the constraint may or may not be checked in byte code. In other words,
7599
-** when the omit flag is true there is no guarantee that the constraint will
7600
-** not be checked again using byte code.)^
7600
+** virtual table and is not checked again by SQLite.)^
76017601
**
76027602
** ^The idxNum and idxPtr values are recorded and passed into the
76037603
** [xFilter] method.
76047604
** ^[sqlite3_free()] is used to free idxPtr if and only if
76057605
** needToFreeIdxPtr is true.
@@ -7635,11 +7635,11 @@
76357635
** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
76367636
** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
76377637
** If a virtual table extension is
76387638
** used with an SQLite version earlier than 3.8.2, the results of attempting
76397639
** to read or write the estimatedRows field are undefined (but are likely
7640
-** to include crashing the application). The estimatedRows field should
7640
+** to included crashing the application). The estimatedRows field should
76417641
** therefore only be used if [sqlite3_libversion_number()] returns a
76427642
** value greater than or equal to 3008002. Similarly, the idxFlags field
76437643
** was added for [version 3.9.0] ([dateof:3.9.0]).
76447644
** It may therefore only be used if
76457645
** sqlite3_libversion_number() returns a value greater than or equal to
@@ -7687,11 +7687,11 @@
76877687
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
76887688
76897689
/*
76907690
** CAPI3REF: Virtual Table Constraint Operator Codes
76917691
**
7692
-** These macros define the allowed values for the
7692
+** These macros defined the allowed values for the
76937693
** [sqlite3_index_info].aConstraint[].op field. Each value represents
76947694
** an operator that is part of a constraint term in the wHERE clause of
76957695
** a query that uses a [virtual table].
76967696
*/
76977697
#define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -8297,11 +8297,11 @@
82978297
** </ul>)^
82988298
**
82998299
** The only difference is that the public sqlite3_XXX functions enumerated
83008300
** above silently ignore any invocations that pass a NULL pointer instead
83018301
** of a valid mutex handle. The implementations of the methods defined
8302
-** by this structure are not required to handle this case. The results
8302
+** by this structure are not required to handle this case, the results
83038303
** of passing a NULL pointer instead of a valid mutex handle are undefined
83048304
** (i.e. it is acceptable to provide an implementation that segfaults if
83058305
** it is passed a NULL pointer).
83068306
**
83078307
** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -8770,11 +8770,11 @@
87708770
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
87718771
** no space was left in the page cache.</dd>)^
87728772
**
87738773
** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
87748774
** <dd>This parameter records the largest memory allocation request
8775
-** handed to the [pagecache memory allocator]. Only the value returned in the
8775
+** handed to [pagecache memory allocator]. Only the value returned in the
87768776
** *pHighwater parameter to [sqlite3_status()] is of interest.
87778777
** The value written into the *pCurrent parameter is undefined.</dd>)^
87788778
**
87798779
** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
87808780
** <dd>No longer used.</dd>
@@ -8846,11 +8846,11 @@
88468846
** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
88478847
** <dd>This parameter returns the number of lookaside memory slots currently
88488848
** checked out.</dd>)^
88498849
**
88508850
** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
8851
-** <dd>This parameter returns the number of malloc attempts that were
8851
+** <dd>This parameter returns the number malloc attempts that were
88528852
** satisfied using lookaside memory. Only the high-water value is meaningful;
88538853
** the current value is always zero.)^
88548854
**
88558855
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
88568856
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -8928,11 +8928,11 @@
89288928
** <dd>This parameter returns the number of dirty cache entries that have
89298929
** been written to disk in the middle of a transaction due to the page
89308930
** cache overflowing. Transactions are more efficient if they are written
89318931
** to disk all at once. When pages spill mid-transaction, that introduces
89328932
** additional overhead. This parameter can be used help identify
8933
-** inefficiencies that can be resolved by increasing the cache size.
8933
+** inefficiencies that can be resolve by increasing the cache size.
89348934
** </dd>
89358935
**
89368936
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
89378937
** <dd>This parameter returns zero for the current value if and only if
89388938
** all foreign key constraints (deferred or immediate) have been
@@ -9017,11 +9017,11 @@
90179017
** If the number of virtual machine operations exceeds 2147483647
90189018
** then the value returned by this statement status code is undefined.
90199019
**
90209020
** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
90219021
** <dd>^This is the number of times that the prepare statement has been
9022
-** automatically regenerated due to schema changes or changes to
9022
+** automatically regenerated due to schema changes or change to
90239023
** [bound parameters] that might affect the query plan.
90249024
**
90259025
** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
90269026
** <dd>^This is the number of times that the prepared statement has
90279027
** been run. A single "run" for the purposes of this counter is one
@@ -9188,11 +9188,11 @@
91889188
** NULL if allocating a new page is effectively impossible.
91899189
** </table>
91909190
**
91919191
** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
91929192
** will only use a createFlag of 2 after a prior call with a createFlag of 1
9193
-** failed.)^ In between the xFetch() calls, SQLite may
9193
+** failed.)^ In between the to xFetch() calls, SQLite may
91949194
** attempt to unpin one or more cache pages by spilling the content of
91959195
** pinned pages to disk and synching the operating system disk cache.
91969196
**
91979197
** [[the xUnpin() page cache method]]
91989198
** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -9506,11 +9506,11 @@
95069506
** application receives an SQLITE_LOCKED error, it may call the
95079507
** sqlite3_unlock_notify() method with the blocked connection handle as
95089508
** the first argument to register for a callback that will be invoked
95099509
** when the blocking connections current transaction is concluded. ^The
95109510
** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
9511
-** call that concludes the blocking connection's transaction.
9511
+** call that concludes the blocking connections transaction.
95129512
**
95139513
** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
95149514
** there is a chance that the blocking connection will have already
95159515
** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
95169516
** If this happens, then the specified callback is invoked immediately,
@@ -9544,11 +9544,11 @@
95449544
** However, the signature of the callback function allows SQLite to pass
95459545
** it an array of void* context pointers. The first argument passed to
95469546
** an unlock-notify callback is a pointer to an array of void* pointers,
95479547
** and the second is the number of entries in the array.
95489548
**
9549
-** When a blocking connection's transaction is concluded, there may be
9549
+** When a blocking connections transaction is concluded, there may be
95509550
** more than one blocked connection that has registered for an unlock-notify
95519551
** callback. ^If two or more such blocked connections have specified the
95529552
** same callback function, then instead of invoking the callback function
95539553
** multiple times, it is invoked once with the set of void* context pointers
95549554
** specified by the blocked connections bundled together into an array.
@@ -10018,37 +10018,37 @@
1001810018
** managed by the prepared statement S and will be automatically freed when
1001910019
** S is finalized.
1002010020
**
1002110021
** <dl>
1002210022
** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
10023
-** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be
10023
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
1002410024
** set to the total number of times that the X-th loop has run.</dd>
1002510025
**
1002610026
** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
10027
-** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set
10027
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
1002810028
** to the total number of rows examined by all iterations of the X-th loop.</dd>
1002910029
**
1003010030
** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
10031
-** <dd>^The "double" variable pointed to by the V parameter will be set to the
10031
+** <dd>^The "double" variable pointed to by the T parameter will be set to the
1003210032
** query planner's estimate for the average number of rows output from each
1003310033
** iteration of the X-th loop. If the query planner's estimates was accurate,
1003410034
** then this value will approximate the quotient NVISIT/NLOOP and the
1003510035
** product of this value for all prior loops with the same SELECTID will
1003610036
** be the NLOOP value for the current loop.
1003710037
**
1003810038
** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
10039
-** <dd>^The "const char *" variable pointed to by the V parameter will be set
10039
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
1004010040
** to a zero-terminated UTF-8 string containing the name of the index or table
1004110041
** used for the X-th loop.
1004210042
**
1004310043
** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
10044
-** <dd>^The "const char *" variable pointed to by the V parameter will be set
10044
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
1004510045
** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
1004610046
** description for the X-th loop.
1004710047
**
1004810048
** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
10049
-** <dd>^The "int" variable pointed to by the V parameter will be set to the
10049
+** <dd>^The "int" variable pointed to by the T parameter will be set to the
1005010050
** "select-id" for the X-th loop. The select-id identifies which query or
1005110051
** subquery the loop is part of. The main query has a select-id of zero.
1005210052
** The select-id is the same value as is output in the first column
1005310053
** of an [EXPLAIN QUERY PLAN] query.
1005410054
** </dl>
@@ -10899,11 +10899,11 @@
1089910899
** METHOD: sqlite3_session
1090010900
**
1090110901
** The second argument (xFilter) is the "filter callback". For changes to rows
1090210902
** in tables that are not attached to the Session object, the filter is called
1090310903
** to determine whether changes to the table's rows should be tracked or not.
10904
-** If xFilter returns 0, changes are not tracked. Note that once a table is
10904
+** If xFilter returns 0, changes is not tracked. Note that once a table is
1090510905
** attached, xFilter will not be called again.
1090610906
*/
1090710907
SQLITE_API void sqlite3session_table_filter(
1090810908
sqlite3_session *pSession, /* Session object */
1090910909
int(*xFilter)(
@@ -11073,11 +11073,11 @@
1107311073
** identical.
1107411074
**
1107511075
** It an error if database zFrom does not exist or does not contain the
1107611076
** required compatible table.
1107711077
**
11078
-** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
11078
+** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
1107911079
** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
1108011080
** may be set to point to a buffer containing an English language error
1108111081
** message. It is the responsibility of the caller to free this buffer using
1108211082
** sqlite3_free().
1108311083
*/
@@ -11210,11 +11210,11 @@
1121011210
1121111211
/*
1121211212
** CAPI3REF: Advance A Changeset Iterator
1121311213
** METHOD: sqlite3_changeset_iter
1121411214
**
11215
-** This function may only be used with iterators created by the function
11215
+** This function may only be used with iterators created by function
1121611216
** [sqlite3changeset_start()]. If it is called on an iterator passed to
1121711217
** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
1121811218
** is returned and the call has no effect.
1121911219
**
1122011220
** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -11626,12 +11626,12 @@
1162611626
** in the changegroup, then the number of columns and the position of the
1162711627
** primary key columns for the table must be consistent. If this is not the
1162811628
** case, this function fails with SQLITE_SCHEMA. If the input changeset
1162911629
** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
1163011630
** returned. Or, if an out-of-memory condition occurs during processing, this
11631
-** function returns SQLITE_NOMEM. In all cases, if an error occurs the state
11632
-** of the final contents of the changegroup is undefined.
11631
+** function returns SQLITE_NOMEM. In all cases, if an error occurs the
11632
+** final contents of the changegroup is undefined.
1163311633
**
1163411634
** If no error occurs, SQLITE_OK is returned.
1163511635
*/
1163611636
SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
1163711637
@@ -11802,11 +11802,11 @@
1180211802
** [SQLITE_CHANGESET_REPLACE].
1180311803
** </dl>
1180411804
**
1180511805
** It is safe to execute SQL statements, including those that write to the
1180611806
** table that the callback related to, from within the xConflict callback.
11807
-** This can be used to further customize the application's conflict
11807
+** This can be used to further customize the applications conflict
1180811808
** resolution strategy.
1180911809
**
1181011810
** All changes made by these functions are enclosed in a savepoint transaction.
1181111811
** If any other error (aside from a constraint failure when attempting to
1181211812
** write to the target database) occurs, then the savepoint transaction is
@@ -12112,11 +12112,11 @@
1211212112
** CAPI3REF: Rebase a changeset
1211312113
** EXPERIMENTAL
1211412114
**
1211512115
** Argument pIn must point to a buffer containing a changeset nIn bytes
1211612116
** in size. This function allocates and populates a buffer with a copy
12117
-** of the changeset rebased according to the configuration of the
12117
+** of the changeset rebased rebased according to the configuration of the
1211812118
** rebaser object passed as the first argument. If successful, (*ppOut)
1211912119
** is set to point to the new buffer containing the rebased changeset and
1212012120
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
1212112121
** responsibility of the caller to eventually free the new buffer using
1212212122
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -12520,11 +12520,11 @@
1252012520
** the callback, an SQLite error code is returned.
1252112521
**
1252212522
**
1252312523
** xSetAuxdata(pFts5, pAux, xDelete)
1252412524
**
12525
-** Save the pointer passed as the second argument as the extension function's
12525
+** Save the pointer passed as the second argument as the extension functions
1252612526
** "auxiliary data". The pointer may then be retrieved by the current or any
1252712527
** future invocation of the same fts5 extension function made as part of
1252812528
** the same MATCH query using the xGetAuxdata() API.
1252912529
**
1253012530
** Each extension function is allocated a single auxiliary data slot for
@@ -12762,12 +12762,12 @@
1276212762
** all instances of "first place" or "1st place" regardless of which form
1276312763
** the user specified in the MATCH query text.
1276412764
**
1276512765
** There are several ways to approach this in FTS5:
1276612766
**
12767
-** <ol><li> By mapping all synonyms to a single token. In this case, using
12768
-** the above example, this means that the tokenizer returns the
12767
+** <ol><li> By mapping all synonyms to a single token. In this case, the
12768
+** In the above example, this means that the tokenizer returns the
1276912769
** same token for inputs "first" and "1st". Say that token is in
1277012770
** fact "first", so that when the user inserts the document "I won
1277112771
** 1st place" entries are added to the index for tokens "i", "won",
1277212772
** "first" and "place". If the user then queries for '1st + place',
1277312773
** the tokenizer substitutes "first" for "1st" and the query works
@@ -13435,30 +13435,10 @@
1343513435
#else
1343613436
# define ALWAYS(X) (X)
1343713437
# define NEVER(X) (X)
1343813438
#endif
1343913439
13440
-/*
13441
-** The harmless(X) macro indicates that expression X is usually false
13442
-** but can be true without causing any problems, but we don't know of
13443
-** any way to cause X to be true.
13444
-**
13445
-** In debugging and testing builds, this macro will abort if X is ever
13446
-** true. In this way, developers are alerted to a possible test case
13447
-** that causes X to be true. If a harmless macro ever fails, that is
13448
-** an opportunity to change the macro into a testcase() and add a new
13449
-** test case to the test suite.
13450
-**
13451
-** For normal production builds, harmless(X) is a no-op, since it does
13452
-** not matter whether expression X is true or false.
13453
-*/
13454
-#ifdef SQLITE_DEBUG
13455
-# define harmless(X) assert(!(X));
13456
-#else
13457
-# define harmless(X)
13458
-#endif
13459
-
1346013440
/*
1346113441
** Some conditionals are optimizations only. In other words, if the
1346213442
** conditionals are replaced with a constant 1 (true) or 0 (false) then
1346313443
** the correct answer is still obtained, though perhaps not as quickly.
1346413444
**
@@ -15169,14 +15149,13 @@
1516915149
#define OP_VRename 163
1517015150
#define OP_Pagecount 164
1517115151
#define OP_MaxPgcnt 165
1517215152
#define OP_Trace 166
1517315153
#define OP_CursorHint 167
15174
-#define OP_ReleaseReg 168 /* synopsis: release r[P1@P2] mask P3 */
15175
-#define OP_Noop 169
15176
-#define OP_Explain 170
15177
-#define OP_Abortable 171
15154
+#define OP_Noop 168
15155
+#define OP_Explain 169
15156
+#define OP_Abortable 170
1517815157
1517915158
/* Properties such as "out2" or "jump" that are specified in
1518015159
** comments following the "case" for each opcode in the vdbe.c
1518115160
** are encoded into bitvectors as follows:
1518215161
*/
@@ -15206,11 +15185,11 @@
1520615185
/* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\
1520715186
/* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1520815187
/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\
1520915188
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1521015189
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15211
-/* 168 */ 0x00, 0x00, 0x00, 0x00,}
15190
+/* 168 */ 0x00, 0x00, 0x00,}
1521215191
1521315192
/* The sqlite3P2Values() routine is able to run faster if it knows
1521415193
** the value of the largest JUMP opcode. The smaller the maximum
1521515194
** JUMP opcode the better, so the mkopcodeh.tcl script that
1521615195
** generated this include file strives to group all JUMP opcodes
@@ -15283,15 +15262,10 @@
1528315262
SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
1528415263
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
1528515264
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
1528615265
SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
1528715266
SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
15288
-#ifdef SQLITE_DEBUG
15289
-SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask);
15290
-#else
15291
-# define sqlite3VdbeReleaseRegisters(P,A,N,M)
15292
-#endif
1529315267
SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
1529415268
SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
1529515269
SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
1529615270
SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
1529715271
SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
@@ -16867,10 +16841,16 @@
1686716841
{nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
1686816842
pArg, 0, xFunc, 0, 0, 0, #zName, }
1686916843
#define LIKEFUNC(zName, nArg, arg, flags) \
1687016844
{nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
1687116845
(void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
16846
+#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
16847
+ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
16848
+ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
16849
+#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
16850
+ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
16851
+ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
1687216852
#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
1687316853
{nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
1687416854
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
1687516855
#define INTERNAL_FUNCTION(zName, nArg, xFunc) \
1687616856
{nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
@@ -17998,17 +17978,17 @@
1799817978
** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences
1799917979
** for the result set. The KeyInfo for addrOpenEphm[2] contains collating
1800017980
** sequences for the ORDER BY clause.
1800117981
*/
1800217982
struct Select {
17983
+ ExprList *pEList; /* The fields of the result */
1800317984
u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
1800417985
LogEst nSelectRow; /* Estimated number of result rows */
1800517986
u32 selFlags; /* Various SF_* values */
1800617987
int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
1800717988
u32 selId; /* Unique identifier number for this SELECT */
1800817989
int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
18009
- ExprList *pEList; /* The fields of the result */
1801017990
SrcList *pSrc; /* The FROM clause */
1801117991
Expr *pWhere; /* The WHERE clause */
1801217992
ExprList *pGroupBy; /* The GROUP BY clause */
1801317993
Expr *pHaving; /* The HAVING clause */
1801417994
ExprList *pOrderBy; /* The ORDER BY clause */
@@ -18050,11 +18030,10 @@
1805018030
#define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
1805118031
#define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
1805218032
#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
1805318033
#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
1805418034
#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18055
-#define SF_View 0x0200000 /* SELECT statement is a view */
1805618035
1805718036
/*
1805818037
** The results of a SELECT can be distributed in several ways, as defined
1805918038
** by one of the following macros. The "SRT" prefix means "SELECT Result
1806018039
** Type".
@@ -18330,12 +18309,12 @@
1833018309
#endif
1833118310
};
1833218311
1833318312
#define PARSE_MODE_NORMAL 0
1833418313
#define PARSE_MODE_DECLARE_VTAB 1
18335
-#define PARSE_MODE_RENAME 2
18336
-#define PARSE_MODE_UNMAP 3
18314
+#define PARSE_MODE_RENAME_COLUMN 2
18315
+#define PARSE_MODE_RENAME_TABLE 3
1833718316
1833818317
/*
1833918318
** Sizes and pointers of various parts of the Parse object.
1834018319
*/
1834118320
#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -18353,11 +18332,11 @@
1835318332
#endif
1835418333
1835518334
#if defined(SQLITE_OMIT_ALTERTABLE)
1835618335
#define IN_RENAME_OBJECT 0
1835718336
#else
18358
- #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME)
18337
+ #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN)
1835918338
#endif
1836018339
1836118340
#if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
1836218341
#define IN_SPECIAL_PARSE 0
1836318342
#else
@@ -19172,11 +19151,10 @@
1917219151
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1917319152
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1917419153
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1917519154
Expr*,ExprList*,u32,Expr*);
1917619155
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
19177
-SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*);
1917819156
SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
1917919157
SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
1918019158
SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
1918119159
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
1918219160
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -20756,11 +20734,11 @@
2075620734
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
2075720735
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
2075820736
SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
2075920737
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
2076020738
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
20761
-SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
20739
+SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);
2076220740
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
2076320741
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
2076420742
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
2076520743
#ifndef SQLITE_OMIT_WINDOWFUNC
2076620744
SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
@@ -22676,11 +22654,11 @@
2267622654
DO_OS_MALLOC_TEST(0);
2267722655
/* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
2267822656
** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
2267922657
** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
2268022658
** reaching the VFS. */
22681
- rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut);
22659
+ rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
2268222660
assert( rc==SQLITE_OK || pFile->pMethods==0 );
2268322661
return rc;
2268422662
}
2268522663
SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
2268622664
DO_OS_MALLOC_TEST(0);
@@ -29311,13 +29289,12 @@
2931129289
zOp2[0] = 0;
2931229290
}
2931329291
sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s",
2931429292
pExpr->iColumn, zFlgs, zOp2);
2931529293
}else{
29316
- sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s",
29317
- pExpr->iTable, pExpr->iColumn,
29318
- pExpr->y.pTab, zFlgs);
29294
+ sqlite3TreeViewLine(pView, "{%d:%d}%s",
29295
+ pExpr->iTable, pExpr->iColumn, zFlgs);
2931929296
}
2932029297
if( ExprHasProperty(pExpr, EP_FixedCol) ){
2932129298
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
2932229299
}
2932329300
break;
@@ -30984,11 +30961,11 @@
3098430961
#pragma warning(disable : 4756)
3098530962
#endif
3098630963
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
3098730964
#ifndef SQLITE_OMIT_FLOATING_POINT
3098830965
int incr;
30989
- const char *zEnd;
30966
+ const char *zEnd = z + length;
3099030967
/* sign * significand * (10 ^ (esign * exponent)) */
3099130968
int sign = 1; /* sign of significand */
3099230969
i64 s = 0; /* significand */
3099330970
int d = 0; /* adjust exponent for shifting decimal point */
3099430971
int esign = 1; /* sign of exponent */
@@ -30998,15 +30975,13 @@
3099830975
int nDigit = 0; /* Number of digits processed */
3099930976
int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
3100030977
3100130978
assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
3100230979
*pResult = 0.0; /* Default return value, in case of an error */
31003
- if( length==0 ) return 0;
3100430980
3100530981
if( enc==SQLITE_UTF8 ){
3100630982
incr = 1;
31007
- zEnd = z + length;
3100830983
}else{
3100930984
int i;
3101030985
incr = 2;
3101130986
assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
3101230987
testcase( enc==SQLITE_UTF16LE );
@@ -32685,14 +32660,13 @@
3268532660
/* 163 */ "VRename" OpHelp(""),
3268632661
/* 164 */ "Pagecount" OpHelp(""),
3268732662
/* 165 */ "MaxPgcnt" OpHelp(""),
3268832663
/* 166 */ "Trace" OpHelp(""),
3268932664
/* 167 */ "CursorHint" OpHelp(""),
32690
- /* 168 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
32691
- /* 169 */ "Noop" OpHelp(""),
32692
- /* 170 */ "Explain" OpHelp(""),
32693
- /* 171 */ "Abortable" OpHelp(""),
32665
+ /* 168 */ "Noop" OpHelp(""),
32666
+ /* 169 */ "Explain" OpHelp(""),
32667
+ /* 170 */ "Abortable" OpHelp(""),
3269432668
};
3269532669
return azName[i];
3269632670
}
3269732671
#endif
3269832672
@@ -36581,11 +36555,11 @@
3658136555
zDirname[ii] = '\0';
3658236556
}else{
3658336557
if( zDirname[0]!='/' ) zDirname[0] = '.';
3658436558
zDirname[1] = 0;
3658536559
}
36586
- fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0);
36560
+ fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
3658736561
if( fd>=0 ){
3658836562
OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
3658936563
}
3659036564
*pFd = fd;
3659136565
if( fd>=0 ) return SQLITE_OK;
@@ -37472,16 +37446,14 @@
3747237446
}
3747337447
}
3747437448
3747537449
if( pInode->bProcessLock==0 ){
3747637450
if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
37477
- pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW,
37478
- (sStat.st_mode&0777));
37451
+ pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777));
3747937452
}
3748037453
if( pShmNode->hShm<0 ){
37481
- pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW,
37482
- (sStat.st_mode&0777));
37454
+ pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
3748337455
if( pShmNode->hShm<0 ){
3748437456
rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
3748537457
goto shm_open_err;
3748637458
}
3748737459
pShmNode->isReadonly = 1;
@@ -38827,11 +38799,11 @@
3882738799
int *pOutFlags /* Output flags returned to SQLite core */
3882838800
){
3882938801
unixFile *p = (unixFile *)pFile;
3883038802
int fd = -1; /* File descriptor returned by open() */
3883138803
int openFlags = 0; /* Flags to pass to open() */
38832
- int eType = flags&0x0FFF00; /* Type of file to open */
38804
+ int eType = flags&0xFFFFFF00; /* Type of file to open */
3883338805
int noLock; /* True to omit locking primitives */
3883438806
int rc = SQLITE_OK; /* Function Return Code */
3883538807
int ctrlFlags = 0; /* UNIXFILE_* flags */
3883638808
3883738809
int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -38937,11 +38909,11 @@
3893738909
** 'conch file' locking functions later on. */
3893838910
if( isReadonly ) openFlags |= O_RDONLY;
3893938911
if( isReadWrite ) openFlags |= O_RDWR;
3894038912
if( isCreate ) openFlags |= O_CREAT;
3894138913
if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);
38942
- openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW);
38914
+ openFlags |= (O_LARGEFILE|O_BINARY);
3894338915
3894438916
if( fd<0 ){
3894538917
mode_t openMode; /* Permissions to create file with */
3894638918
uid_t uid; /* Userid for the file */
3894738919
gid_t gid; /* Groupid for the file */
@@ -39149,20 +39121,29 @@
3914939121
){
3915039122
UNUSED_PARAMETER(NotUsed);
3915139123
SimulateIOError( return SQLITE_IOERR_ACCESS; );
3915239124
assert( pResOut!=0 );
3915339125
39154
- /* The spec says there are three possible values for flags. But only
39155
- ** two of them are actually used */
39156
- assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );
39126
+ /* The spec says there are four possible values for flags. But the
39127
+ ** SQLITE_ACCESS_READ flag is never used */
39128
+ assert( flags==SQLITE_ACCESS_EXISTS
39129
+ || flags==SQLITE_ACCESS_READWRITE
39130
+ || flags==SQLITE_ACCESS_SYMLINK );
3915739131
3915839132
if( flags==SQLITE_ACCESS_EXISTS ){
3915939133
struct stat buf;
39160
- *pResOut = 0==osStat(zPath, &buf) &&
39161
- (S_ISDIR(buf.st_mode) || buf.st_size>0);
39162
- }else{
39134
+ *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
39135
+ }else if( flags==SQLITE_ACCESS_READWRITE ){
3916339136
*pResOut = osAccess(zPath, W_OK|R_OK)==0;
39137
+ }else{
39138
+#if !defined(HAVE_LSTAT)
39139
+ *pResOut = 0;
39140
+#else
39141
+ struct stat buf;
39142
+ *pResOut = (0==osLstat(zPath, &buf) && S_ISLNK(buf.st_mode));
39143
+#endif
39144
+ assert( flags==SQLITE_ACCESS_SYMLINK );
3916439145
}
3916539146
return SQLITE_OK;
3916639147
}
3916739148
3916839149
/*
@@ -39210,11 +39191,11 @@
3921039191
#if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)
3921139192
return mkFullPathname(zPath, zOut, nOut);
3921239193
#else
3921339194
int rc = SQLITE_OK;
3921439195
int nByte;
39215
- int nLink = 0; /* Number of symbolic links followed so far */
39196
+ int nLink = 1; /* Number of symbolic links followed so far */
3921639197
const char *zIn = zPath; /* Input path for each iteration of loop */
3921739198
char *zDel = 0;
3921839199
3921939200
assert( pVfs->mxPathname==MAX_PATHNAME );
3922039201
UNUSED_PARAMETER(pVfs);
@@ -39239,15 +39220,14 @@
3923939220
}else{
3924039221
bLink = S_ISLNK(buf.st_mode);
3924139222
}
3924239223
3924339224
if( bLink ){
39244
- nLink++;
3924539225
if( zDel==0 ){
3924639226
zDel = sqlite3_malloc(nOut);
3924739227
if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;
39248
- }else if( nLink>=SQLITE_MAX_SYMLINKS ){
39228
+ }else if( ++nLink>SQLITE_MAX_SYMLINKS ){
3924939229
rc = SQLITE_CANTOPEN_BKPT;
3925039230
}
3925139231
3925239232
if( rc==SQLITE_OK ){
3925339233
nByte = osReadlink(zIn, zDel, nOut-1);
@@ -39279,11 +39259,10 @@
3927939259
if( bLink==0 ) break;
3928039260
zIn = zOut;
3928139261
}while( rc==SQLITE_OK );
3928239262
3928339263
sqlite3_free(zDel);
39284
- if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK;
3928539264
return rc;
3928639265
#endif /* HAVE_READLINK && HAVE_LSTAT */
3928739266
}
3928839267
3928939268
@@ -39765,11 +39744,11 @@
3976539744
int islockfile /* if non zero missing dirs will be created */
3976639745
) {
3976739746
int fd = -1;
3976839747
unixFile *pNew;
3976939748
int rc = SQLITE_OK;
39770
- int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW;
39749
+ int openFlags = O_RDWR | O_CREAT;
3977139750
sqlite3_vfs dummyVfs;
3977239751
int terrno = 0;
3977339752
UnixUnusedFd *pUnused = NULL;
3977439753
3977539754
/* 1. first try to open/create the file
@@ -39795,11 +39774,11 @@
3979539774
fd = robust_open(path, openFlags, 0);
3979639775
}
3979739776
}
3979839777
}
3979939778
if( fd<0 ){
39800
- openFlags = O_RDONLY | O_NOFOLLOW;
39779
+ openFlags = O_RDONLY;
3980139780
fd = robust_open(path, openFlags, 0);
3980239781
terrno = errno;
3980339782
}
3980439783
if( fd<0 ){
3980539784
if( islockfile ){
@@ -39921,11 +39900,11 @@
3992139900
if( readLen<PROXY_PATHINDEX ){
3992239901
sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
3992339902
goto end_breaklock;
3992439903
}
3992539904
/* write it out to the temporary break file */
39926
- fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0);
39905
+ fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);
3992739906
if( fd<0 ){
3992839907
sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
3992939908
goto end_breaklock;
3993039909
}
3993139910
if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -41081,10 +41060,18 @@
4108141060
4108241061
#ifndef NTDDI_WINTHRESHOLD
4108341062
# define NTDDI_WINTHRESHOLD 0x06040000
4108441063
#endif
4108541064
41065
+/*
41066
+** This constant is needed by the winAccess function; therefore, define
41067
+** it when it is missing from the SDK header files.
41068
+*/
41069
+#ifndef FILE_ATTRIBUTE_REPARSE_POINT
41070
+# define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
41071
+#endif
41072
+
4108641073
/*
4108741074
** Check to see if the GetVersionEx[AW] functions are deprecated on the
4108841075
** target system. GetVersionEx was first deprecated in Win8.1.
4108941076
*/
4109041077
#ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46473,10 +46460,14 @@
4647346460
break;
4647446461
case SQLITE_ACCESS_READWRITE:
4647546462
rc = attr!=INVALID_FILE_ATTRIBUTES &&
4647646463
(attr & FILE_ATTRIBUTE_READONLY)==0;
4647746464
break;
46465
+ case SQLITE_ACCESS_SYMLINK:
46466
+ rc = attr!=INVALID_FILE_ATTRIBUTES &&
46467
+ (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0;
46468
+ break;
4647846469
default:
4647946470
assert(!"Invalid flags argument");
4648046471
}
4648146472
*pResOut = rc;
4648246473
OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -49512,19 +49503,17 @@
4951249503
sqlite3_free(p);
4951349504
pPg = 0;
4951449505
}
4951549506
#else
4951649507
pPg = pcache1Alloc(pCache->szAlloc);
49508
+ p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
4951749509
#endif
4951849510
if( benignMalloc ){ sqlite3EndBenignMalloc(); }
4951949511
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
4952049512
pcache1EnterMutex(pCache->pGroup);
4952149513
#endif
4952249514
if( pPg==0 ) return 0;
49523
-#ifndef SQLITE_PCACHE_SEPARATE_HEADER
49524
- p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
49525
-#endif
4952649515
p->page.pBuf = pPg;
4952749516
p->page.pExtra = &p[1];
4952849517
p->isBulkLocal = 0;
4952949518
p->isAnchor = 0;
4953049519
}
@@ -55793,34 +55782,31 @@
5579355782
** to by zPathname, length nPathname. Or, if this is a temporary file,
5579455783
** leave both nPathname and zPathname set to 0.
5579555784
*/
5579655785
if( zFilename && zFilename[0] ){
5579755786
const char *z;
55787
+ if( (vfsFlags & SQLITE_OPEN_NOFOLLOW)!=0 ){
55788
+ int isLink = 0;
55789
+ int rc = sqlite3OsAccess(pVfs, zFilename, SQLITE_ACCESS_SYMLINK, &isLink);
55790
+ if( rc==SQLITE_OK && isLink ) rc = SQLITE_CANTOPEN_SYMLINK;
55791
+ if( rc ) return rc;
55792
+ }
5579855793
nPathname = pVfs->mxPathname+1;
5579955794
zPathname = sqlite3DbMallocRaw(0, nPathname*2);
5580055795
if( zPathname==0 ){
5580155796
return SQLITE_NOMEM_BKPT;
5580255797
}
5580355798
zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
5580455799
rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
55805
- if( rc!=SQLITE_OK ){
55806
- if( rc==SQLITE_OK_SYMLINK ){
55807
- if( vfsFlags & SQLITE_OPEN_NOFOLLOW ){
55808
- rc = SQLITE_CANTOPEN_SYMLINK;
55809
- }else{
55810
- rc = SQLITE_OK;
55811
- }
55812
- }
55813
- }
5581455800
nPathname = sqlite3Strlen30(zPathname);
5581555801
z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
5581655802
while( *z ){
5581755803
z += strlen(z)+1;
5581855804
z += strlen(z)+1;
5581955805
nUri++;
5582055806
}
55821
- nUriByte = (int)(&z[1] - zUri);
55807
+ nUriByte = (int)(&z[2] - zUri);
5582255808
assert( nUriByte>=1 );
5582355809
if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
5582455810
/* This branch is taken when the journal path required by
5582555811
** the database being opened will be more than pVfs->mxPathname
5582655812
** bytes in length. This means the database cannot be opened,
@@ -57630,11 +57616,10 @@
5763057616
5763157617
/* This routine should not be called if a prior error has occurred.
5763257618
** But if (due to a coding error elsewhere in the system) it does get
5763357619
** called, just return the same error code without doing anything. */
5763457620
if( NEVER(pPager->errCode) ) return pPager->errCode;
57635
- pPager->iDataVersion++;
5763657621
5763757622
assert( pPager->eState==PAGER_WRITER_LOCKED
5763857623
|| pPager->eState==PAGER_WRITER_FINISHED
5763957624
|| (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)
5764057625
);
@@ -57659,10 +57644,11 @@
5765957644
pPager->eState = PAGER_READER;
5766057645
return SQLITE_OK;
5766157646
}
5766257647
5766357648
PAGERTRACE(("COMMIT %d\n", PAGERID(pPager)));
57649
+ pPager->iDataVersion++;
5766457650
rc = pager_end_transaction(pPager, pPager->setMaster, 1);
5766557651
return pager_error(pPager, rc);
5766657652
}
5766757653
5766857654
/*
@@ -60579,23 +60565,11 @@
6057960565
** of the aReadMark[] slot. The assumption here is that if that is
6058060566
** happening, the other client may only be increasing the value,
6058160567
** not decreasing it. So assuming either that either the "old" or
6058260568
** "new" version of the value is read, and not some arbitrary value
6058360569
** that would never be written by a real client, things are still
60584
- ** safe.
60585
- **
60586
- ** Astute readers have pointed out that the assumption stated in the
60587
- ** last sentence of the previous paragraph is not guaranteed to be
60588
- ** true for all conforming systems. However, the assumption is true
60589
- ** for all compilers and architectures in common use today (circa
60590
- ** 2019-11-27) and the alternatives are both slow and complex, and
60591
- ** so we will continue to go with the current design for now. If this
60592
- ** bothers you, or if you really are running on a system where aligned
60593
- ** 32-bit reads and writes are not atomic, then you can simply avoid
60594
- ** the use of WAL mode, or only use WAL mode together with
60595
- ** PRAGMA locking_mode=EXCLUSIVE and all will be well.
60596
- */
60570
+ ** safe. */
6059760571
u32 y = pInfo->aReadMark[i];
6059860572
if( mxSafeFrame>y ){
6059960573
assert( y<=pWal->hdr.mxFrame );
6060060574
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
6060160575
if( rc==SQLITE_OK ){
@@ -66047,17 +66021,13 @@
6604766021
memcpy(zFullPathname, zFilename, nFilename);
6604866022
}else{
6604966023
rc = sqlite3OsFullPathname(pVfs, zFilename,
6605066024
nFullPathname, zFullPathname);
6605166025
if( rc ){
66052
- if( rc==SQLITE_OK_SYMLINK ){
66053
- rc = SQLITE_OK;
66054
- }else{
66055
- sqlite3_free(zFullPathname);
66056
- sqlite3_free(p);
66057
- return rc;
66058
- }
66026
+ sqlite3_free(zFullPathname);
66027
+ sqlite3_free(p);
66028
+ return rc;
6605966029
}
6606066030
}
6606166031
#if SQLITE_THREADSAFE
6606266032
mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);
6606366033
sqlite3_mutex_enter(mutexOpen);
@@ -69362,15 +69332,12 @@
6936269332
6936369333
/* If the database file is corrupt, it is possible for the value of idx
6936469334
** to be invalid here. This can only occur if a second cursor modifies
6936569335
** the page while cursor pCur is holding a reference to it. Which can
6936669336
** only happen if the database is corrupt in such a way as to link the
69367
- ** page into more than one b-tree structure.
69368
- **
69369
- ** Update 2019-12-23: appears to long longer be possible after the
69370
- ** addition of anotherValidCursor() condition on balance_deeper(). */
69371
- harmless( idx>pPage->nCell );
69337
+ ** page into more than one b-tree structure. */
69338
+ testcase( idx>pPage->nCell );
6937269339
6937369340
if( idx>=pPage->nCell ){
6937469341
if( !pPage->leaf ){
6937569342
rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
6937669343
if( rc ) return rc;
@@ -71955,34 +71922,10 @@
7195571922
7195671923
*ppChild = pChild;
7195771924
return SQLITE_OK;
7195871925
}
7195971926
71960
-/*
71961
-** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid
71962
-** on the same B-tree as pCur.
71963
-**
71964
-** This can if a database is corrupt with two or more SQL tables
71965
-** pointing to the same b-tree. If an insert occurs on one SQL table
71966
-** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL
71967
-** table linked to the same b-tree. If the secondary insert causes a
71968
-** rebalance, that can change content out from under the cursor on the
71969
-** first SQL table, violating invariants on the first insert.
71970
-*/
71971
-static int anotherValidCursor(BtCursor *pCur){
71972
- BtCursor *pOther;
71973
- for(pOther=pCur->pBt->pCursor; pOther; pOther=pOther->pNext){
71974
- if( pOther!=pCur
71975
- && pOther->eState==CURSOR_VALID
71976
- && pOther->pPage==pCur->pPage
71977
- ){
71978
- return SQLITE_CORRUPT_BKPT;
71979
- }
71980
- }
71981
- return SQLITE_OK;
71982
-}
71983
-
7198471927
/*
7198571928
** The page that pCur currently points to has just been modified in
7198671929
** some way. This function figures out if this modification means the
7198771930
** tree needs to be balanced, and if so calls the appropriate balancing
7198871931
** routine. Balancing routines are:
@@ -72006,11 +71949,11 @@
7200671949
7200771950
if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
7200871951
if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
7200971952
break;
7201071953
}else if( (iPage = pCur->iPage)==0 ){
72011
- if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){
71954
+ if( pPage->nOverflow ){
7201271955
/* The root page of the b-tree is overfull. In this case call the
7201371956
** balance_deeper() function to create a new child for the root-page
7201471957
** and copy the current contents of the root-page to it. The
7201571958
** next iteration of the do-loop will balance the child page.
7201671959
*/
@@ -72377,13 +72320,11 @@
7237772320
return btreeOverwriteCell(pCur, &x2);
7237872321
}
7237972322
}
7238072323
7238172324
}
72382
- assert( pCur->eState==CURSOR_VALID
72383
- || (pCur->eState==CURSOR_INVALID && loc)
72384
- || CORRUPT_DB );
72325
+ assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
7238572326
7238672327
pPage = pCur->pPage;
7238772328
assert( pPage->intKey || pX->nKey>=0 );
7238872329
assert( pPage->leaf || !pPage->intKey );
7238972330
if( pPage->nFree<0 ){
@@ -75548,11 +75489,12 @@
7554875489
if( flags & (MEM_Int|MEM_IntReal) ){
7554975490
testcase( flags & MEM_IntReal );
7555075491
return pMem->u.i;
7555175492
}else if( flags & MEM_Real ){
7555275493
return doubleToInt64(pMem->u.r);
75553
- }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){
75494
+ }else if( flags & (MEM_Str|MEM_Blob) ){
75495
+ assert( pMem->z || pMem->n==0 );
7555475496
return memIntValue(pMem);
7555575497
}else{
7555675498
return 0;
7555775499
}
7555875500
}
@@ -75705,12 +75647,12 @@
7570575647
** "aff". Casting is different from applying affinity in that a cast
7570675648
** is forced. In other words, the value is converted into the desired
7570775649
** affinity even if that results in loss of data. This routine is
7570875650
** used (for example) to implement the SQL "cast()" operator.
7570975651
*/
75710
-SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
75711
- if( pMem->flags & MEM_Null ) return SQLITE_OK;
75652
+SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
75653
+ if( pMem->flags & MEM_Null ) return;
7571275654
switch( aff ){
7571375655
case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */
7571475656
if( (pMem->flags & MEM_Blob)==0 ){
7571575657
sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
7571675658
assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
@@ -75737,14 +75679,13 @@
7573775679
assert( MEM_Str==(MEM_Blob>>3) );
7573875680
pMem->flags |= (pMem->flags&MEM_Blob)>>3;
7573975681
sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
7574075682
assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
7574175683
pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero);
75742
- return sqlite3VdbeChangeEncoding(pMem, encoding);
75684
+ break;
7574375685
}
7574475686
}
75745
- return SQLITE_OK;
7574675687
}
7574775688
7574875689
/*
7574975690
** Initialize bulk memory to be a consistent Mem object.
7575075691
**
@@ -77513,11 +77454,10 @@
7751377454
**
7751477455
** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
7751577456
** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
7751677457
** * OP_Destroy
7751777458
** * OP_VUpdate
77518
-** * OP_VCreate
7751977459
** * OP_VRename
7752077460
** * OP_FkCounter with P2==0 (immediate foreign key constraint)
7752177461
** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine
7752277462
** (for CREATE TABLE AS SELECT ...)
7752377463
**
@@ -77541,11 +77481,10 @@
7754177481
7754277482
while( (pOp = opIterNext(&sIter))!=0 ){
7754377483
int opcode = pOp->opcode;
7754477484
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
7754577485
|| opcode==OP_VDestroy
77546
- || opcode==OP_VCreate
7754777486
|| (opcode==OP_ParseSchema && pOp->p4.z==0)
7754877487
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
7754977488
&& ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
7755077489
){
7755177490
hasAbort = 1;
@@ -78031,33 +77970,10 @@
7803177970
return sqlite3VdbeChangeToNoop(p, p->nOp-1);
7803277971
}else{
7803377972
return 0;
7803477973
}
7803577974
}
78036
-
78037
-#ifdef SQLITE_DEBUG
78038
-/*
78039
-** Generate an OP_ReleaseReg opcode to indicate that a range of
78040
-** registers, except any identified by mask, are no longer in use.
78041
-*/
78042
-SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse *pParse, int iFirst, int N, u32 mask){
78043
- assert( pParse->pVdbe );
78044
- while( N>0 && (mask&1)!=0 ){
78045
- mask >>= 1;
78046
- iFirst++;
78047
- N--;
78048
- }
78049
- while( N>0 && N<=32 && (mask & MASKBIT32(N-1))!=0 ){
78050
- mask &= ~MASKBIT32(N-1);
78051
- N--;
78052
- }
78053
- if( N>0 ){
78054
- sqlite3VdbeAddOp3(pParse->pVdbe, OP_ReleaseReg, iFirst, N, *(int*)&mask);
78055
- }
78056
-}
78057
-#endif /* SQLITE_DEBUG */
78058
-
7805977975
7806077976
/*
7806177977
** Change the value of the P4 operand for a specific instruction.
7806277978
** This routine is useful when a large program is loaded from a
7806377979
** static array using sqlite3VdbeAddOpList but we want to make a
@@ -78172,12 +78088,11 @@
7817278088
** makes the code easier to read during debugging. None of this happens
7817378089
** in a production build.
7817478090
*/
7817578091
static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
7817678092
assert( p->nOp>0 || p->aOp==0 );
78177
- assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
78178
- || p->pParse->nErr>0 );
78093
+ assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );
7817978094
if( p->nOp ){
7818078095
assert( p->aOp );
7818178096
sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
7818278097
p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);
7818378098
}
@@ -86213,15 +86128,13 @@
8621386128
testcase( pOp->p2==SQLITE_AFF_INTEGER );
8621486129
testcase( pOp->p2==SQLITE_AFF_REAL );
8621586130
pIn1 = &aMem[pOp->p1];
8621686131
memAboutToChange(p, pIn1);
8621786132
rc = ExpandBlob(pIn1);
86218
- if( rc ) goto abort_due_to_error;
86219
- rc = sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);
86220
- if( rc ) goto abort_due_to_error;
86133
+ sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);
8622186134
UPDATE_MAX_BLOBSIZE(pIn1);
86222
- REGISTER_TRACE(pOp->p1, pIn1);
86135
+ if( rc ) goto abort_due_to_error;
8622386136
break;
8622486137
}
8622586138
#endif /* SQLITE_OMIT_CAST */
8622686139
8622786140
/* Opcode: Eq P1 P2 P3 P4 P5
@@ -86376,11 +86289,16 @@
8637686289
affinity = pOp->p5 & SQLITE_AFF_MASK;
8637786290
if( affinity>=SQLITE_AFF_NUMERIC ){
8637886291
if( (flags1 | flags3)&MEM_Str ){
8637986292
if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8638086293
applyNumericAffinity(pIn1,0);
86381
- testcase( flags3!=pIn3->flags );
86294
+ assert( flags3==pIn3->flags );
86295
+ /* testcase( flags3!=pIn3->flags );
86296
+ ** this used to be possible with pIn1==pIn3, but not since
86297
+ ** the column cache was removed. The following assignment
86298
+ ** is essentially a no-op. But, it provides defense-in-depth
86299
+ ** in case our analysis is incorrect, so it is left in. */
8638286300
flags3 = pIn3->flags;
8638386301
}
8638486302
if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
8638586303
applyNumericAffinity(pIn3,0);
8638686304
}
@@ -86399,11 +86317,11 @@
8639986317
testcase( pIn1->flags & MEM_Real );
8640086318
testcase( pIn1->flags & MEM_IntReal );
8640186319
sqlite3VdbeMemStringify(pIn1, encoding, 1);
8640286320
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
8640386321
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
86404
- if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str;
86322
+ assert( pIn1!=pIn3 );
8640586323
}
8640686324
if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
8640786325
testcase( pIn3->flags & MEM_Int );
8640886326
testcase( pIn3->flags & MEM_Real );
8640986327
testcase( pIn3->flags & MEM_IntReal );
@@ -86434,14 +86352,14 @@
8643486352
static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 };
8643586353
res2 = aGTb[pOp->opcode - OP_Ne];
8643686354
}
8643786355
8643886356
/* Undo any changes made by applyAffinity() to the input registers. */
86357
+ assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
86358
+ pIn1->flags = flags1;
8643986359
assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
8644086360
pIn3->flags = flags3;
86441
- assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
86442
- pIn1->flags = flags1;
8644386361
8644486362
if( pOp->p5 & SQLITE_STOREP2 ){
8644586363
pOut = &aMem[pOp->p2];
8644686364
iCompare = res;
8644786365
if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){
@@ -86473,35 +86391,20 @@
8647386391
break;
8647486392
}
8647586393
8647686394
/* Opcode: ElseNotEq * P2 * * *
8647786395
**
86478
-** This opcode must follow an OP_Lt or OP_Gt comparison operator. There
86479
-** can be zero or more OP_ReleaseReg opcodes intervening, but no other
86480
-** opcodes are allowed to occur between this instruction and the previous
86481
-** OP_Lt or OP_Gt. Furthermore, the prior OP_Lt or OP_Gt must have the
86482
-** SQLITE_STOREP2 bit set in the P5 field.
86483
-**
86484
-** If result of an OP_Eq comparison on the same two operands as the
86485
-** prior OP_Lt or OP_Gt would have been NULL or false (0), then then
86486
-** jump to P2. If the result of an OP_Eq comparison on the two previous
86487
-** operands would have been true (1), then fall through.
86396
+** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator.
86397
+** If result of an OP_Eq comparison on the same two operands
86398
+** would have be NULL or false (0), then then jump to P2.
86399
+** If the result of an OP_Eq comparison on the two previous operands
86400
+** would have been true (1), then fall through.
8648886401
*/
8648986402
case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
86490
-
86491
-#ifdef SQLITE_DEBUG
86492
- /* Verify the preconditions of this opcode - that it follows an OP_Lt or
86493
- ** OP_Gt with the SQLITE_STOREP2 flag set, with zero or more intervening
86494
- ** OP_ReleaseReg opcodes */
86495
- int iAddr;
86496
- for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){
86497
- if( aOp[iAddr].opcode==OP_ReleaseReg ) continue;
86498
- assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt );
86499
- assert( aOp[iAddr].p5 & SQLITE_STOREP2 );
86500
- break;
86501
- }
86502
-#endif /* SQLITE_DEBUG */
86403
+ assert( pOp>aOp );
86404
+ assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
86405
+ assert( pOp[-1].p5 & SQLITE_STOREP2 );
8650386406
VdbeBranchTaken(iCompare!=0, 2);
8650486407
if( iCompare!=0 ) goto jump_to_p2;
8650586408
break;
8650686409
}
8650786410
@@ -86908,13 +86811,11 @@
8690886811
const u8 *zEndHdr; /* Pointer to first byte after the header */
8690986812
u64 offset64; /* 64-bit offset */
8691086813
u32 t; /* A type code from the record header */
8691186814
Mem *pReg; /* PseudoTable input register */
8691286815
86913
- assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8691486816
pC = p->apCsr[pOp->p1];
86915
- assert( pC!=0 );
8691686817
p2 = pOp->p2;
8691786818
8691886819
/* If the cursor cache is stale (meaning it is not currently point at
8691986820
** the correct row) then bring it up-to-date by doing the necessary
8692086821
** B-Tree seek. */
@@ -86922,10 +86823,11 @@
8692286823
if( rc ) goto abort_due_to_error;
8692386824
8692486825
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
8692586826
pDest = &aMem[pOp->p3];
8692686827
memAboutToChange(p, pDest);
86828
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
8692786829
assert( pC!=0 );
8692886830
assert( p2<pC->nField );
8692986831
aOffset = pC->aOffset;
8693086832
assert( pC->eCurType!=CURTYPE_VTAB );
8693186833
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
@@ -87178,11 +87080,11 @@
8717887080
assert( pOp->p2>0 );
8717987081
assert( zAffinity[pOp->p2]==0 );
8718087082
pIn1 = &aMem[pOp->p1];
8718187083
while( 1 /*exit-by-break*/ ){
8718287084
assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
87183
- assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) );
87085
+ assert( memIsValid(pIn1) );
8718487086
applyAffinity(pIn1, zAffinity[0], encoding);
8718587087
if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
8718687088
/* When applying REAL affinity, if the result is still an MEM_Int
8718787089
** that will fit in 6 bytes, then change the type to MEM_IntReal
8718887090
** so that we keep the high-resolution integer value but know that
@@ -87624,16 +87526,12 @@
8762487526
p->pc = (int)(pOp - aOp);
8762587527
db->autoCommit = 0;
8762687528
p->rc = rc = SQLITE_BUSY;
8762787529
goto vdbe_return;
8762887530
}
87531
+ db->isTransactionSavepoint = 0;
8762987532
rc = p->rc;
87630
- if( rc ){
87631
- db->autoCommit = 0;
87632
- }else{
87633
- db->isTransactionSavepoint = 0;
87634
- }
8763587533
}else{
8763687534
int isSchemaChange;
8763787535
iSavepoint = db->nSavepoint - iSavepoint - 1;
8763887536
if( p1==SAVEPOINT_ROLLBACK ){
8763987537
isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;
@@ -87657,11 +87555,10 @@
8765787555
sqlite3ExpirePreparedStatements(db, 0);
8765887556
sqlite3ResetAllSchemasOfConnection(db);
8765987557
db->mDbFlags |= DBFLAG_SchemaChange;
8766087558
}
8766187559
}
87662
- if( rc ) goto abort_due_to_error;
8766387560
8766487561
/* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
8766587562
** savepoints nested inside of the savepoint being operated on. */
8766687563
while( db->pSavepoint!=pSavepoint ){
8766787564
pTmp = db->pSavepoint;
@@ -88153,11 +88050,10 @@
8815388050
case OP_OpenDup: {
8815488051
VdbeCursor *pOrig; /* The original cursor to be duplicated */
8815588052
VdbeCursor *pCx; /* The new cursor */
8815688053
8815788054
pOrig = p->apCsr[pOp->p2];
88158
- assert( pOrig );
8815988055
assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */
8816088056
8816188057
pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
8816288058
if( pCx==0 ) goto no_mem;
8816388059
pCx->nullRow = 1;
@@ -91583,11 +91479,11 @@
9158391479
pVtab = pCur->uc.pVCur->pVtab;
9158491480
pModule = pVtab->pModule;
9158591481
assert( pModule->xColumn );
9158691482
memset(&sContext, 0, sizeof(sContext));
9158791483
sContext.pOut = pDest;
91588
- assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 );
91484
+ testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );
9158991485
if( pOp->p5 & OPFLAG_NOCHNG ){
9159091486
sqlite3VdbeMemSetNull(pDest);
9159191487
pDest->flags = MEM_Null|MEM_Zero;
9159291488
pDest->u.nZero = 0;
9159391489
}else{
@@ -92040,57 +91936,10 @@
9204091936
** An Abort is safe if either there have been no writes, or if there is
9204191937
** an active statement journal.
9204291938
*/
9204391939
case OP_Abortable: {
9204491940
sqlite3VdbeAssertAbortable(p);
92045
- break;
92046
-}
92047
-#endif
92048
-
92049
-#ifdef SQLITE_DEBUG
92050
-/* Opcode: ReleaseReg P1 P2 P3 * *
92051
-** Synopsis: release r[P1@P2] mask P3
92052
-**
92053
-** Release registers from service. Any content that was in the
92054
-** the registers is unreliable after this opcode completes.
92055
-**
92056
-** The registers released will be the P2 registers starting at P1,
92057
-** except if bit ii of P3 set, then do not release register P1+ii.
92058
-** In other words, P3 is a mask of registers to preserve.
92059
-**
92060
-** Releasing a register clears the Mem.pScopyFrom pointer. That means
92061
-** that if the content of the released register was set using OP_SCopy,
92062
-** a change to the value of the source register for the OP_SCopy will no longer
92063
-** generate an assertion fault in sqlite3VdbeMemAboutToChange().
92064
-**
92065
-** TODO: Released registers ought to also have their datatype set to
92066
-** MEM_Undefined so that any subsequent attempt to read the released
92067
-** register (before it is reinitialized) will generate an assertion fault.
92068
-** However, there are places in the code generator which release registers
92069
-** before their are used, under the (valid) assumption that the registers
92070
-** will not be reallocated for some other purpose before they are used and
92071
-** hence are safe to release.
92072
-**
92073
-** This opcode is only available in testing and debugging builds. It is
92074
-** not generated for release builds. The purpose of this opcode is to help
92075
-** validate the generated bytecode. This opcode does not actually contribute
92076
-** to computing an answer.
92077
-*/
92078
-case OP_ReleaseReg: {
92079
- Mem *pMem;
92080
- int i;
92081
- u32 constMask;
92082
- assert( pOp->p1>0 );
92083
- assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 );
92084
- pMem = &aMem[pOp->p1];
92085
- constMask = pOp->p3;
92086
- for(i=0; i<pOp->p2; i++, pMem++){
92087
- if( i>=32 || (constMask & MASKBIT32(i))==0 ){
92088
- pMem->pScopyFrom = 0;
92089
- /* MemSetTypeFlag(pMem, MEM_Undefined); // See the TODO */
92090
- }
92091
- }
9209291941
break;
9209391942
}
9209491943
#endif
9209591944
9209691945
/* Opcode: Noop * * * * *
@@ -96000,12 +95849,12 @@
9600095849
testcase( ExprHasProperty(pExpr, EP_Reduced) );
9600195850
while(1){
9600295851
rc = pWalker->xExprCallback(pWalker, pExpr);
9600395852
if( rc ) return rc & WRC_Abort;
9600495853
if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
96005
- assert( pExpr->x.pList==0 || pExpr->pRight==0 );
9600695854
if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
95855
+ assert( pExpr->x.pList==0 || pExpr->pRight==0 );
9600795856
if( pExpr->pRight ){
9600895857
assert( !ExprHasProperty(pExpr, EP_WinFunc) );
9600995858
pExpr = pExpr->pRight;
9601095859
continue;
9601195860
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -96689,39 +96538,22 @@
9668996538
pTopNC->nErr++;
9669096539
}
9669196540
9669296541
/* If a column from a table in pSrcList is referenced, then record
9669396542
** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
96694
- ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is
96695
- ** set if the 63rd or any subsequent column is used.
96696
- **
96697
- ** The colUsed mask is an optimization used to help determine if an
96698
- ** index is a covering index. The correct answer is still obtained
96699
- ** if the mask contains extra set bits. However, it is important to
96700
- ** avoid setting bits beyond the maximum column number of the table.
96701
- ** (See ticket [b92e5e8ec2cdbaa1]).
96702
- **
96703
- ** If a generated column is referenced, set bits for every column
96704
- ** of the table.
96543
+ ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the
96544
+ ** column number is greater than the number of bits in the bitmask
96545
+ ** then set the high-order bit of the bitmask.
9670596546
*/
9670696547
if( pExpr->iColumn>=0 && pMatch!=0 ){
9670796548
int n = pExpr->iColumn;
96708
- Table *pExTab = pExpr->y.pTab;
96709
- assert( pExTab!=0 );
96549
+ testcase( n==BMS-1 );
96550
+ if( n>=BMS ){
96551
+ n = BMS-1;
96552
+ }
9671096553
assert( pMatch->iCursor==pExpr->iTable );
96711
- if( (pExTab->tabFlags & TF_HasGenerated)!=0
96712
- && (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0
96713
- ){
96714
- testcase( pExTab->nCol==BMS-1 );
96715
- testcase( pExTab->nCol==BMS );
96716
- pMatch->colUsed = pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1;
96717
- }else{
96718
- testcase( n==BMS-1 );
96719
- testcase( n==BMS );
96720
- if( n>=BMS ) n = BMS-1;
96721
- pMatch->colUsed |= ((Bitmask)1)<<n;
96722
- }
96554
+ pMatch->colUsed |= ((Bitmask)1)<<n;
9672396555
}
9672496556
9672596557
/* Clean up and return
9672696558
*/
9672796559
sqlite3ExprDelete(db, pExpr->pLeft);
@@ -96756,68 +96588,47 @@
9675696588
*/
9675796589
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
9675896590
Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
9675996591
if( p ){
9676096592
struct SrcList_item *pItem = &pSrc->a[iSrc];
96761
- Table *pTab = p->y.pTab = pItem->pTab;
96593
+ p->y.pTab = pItem->pTab;
9676296594
p->iTable = pItem->iCursor;
9676396595
if( p->y.pTab->iPKey==iCol ){
9676496596
p->iColumn = -1;
9676596597
}else{
9676696598
p->iColumn = (ynVar)iCol;
96767
- if( (pTab->tabFlags & TF_HasGenerated)!=0
96768
- && (pTab->aCol[iCol].colFlags & COLFLAG_GENERATED)!=0
96769
- ){
96770
- testcase( pTab->nCol==63 );
96771
- testcase( pTab->nCol==64 );
96772
- pItem->colUsed = pTab->nCol>=64 ? ALLBITS : MASKBIT(pTab->nCol)-1;
96773
- }else{
96774
- testcase( iCol==BMS );
96775
- testcase( iCol==BMS-1 );
96776
- pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
96777
- }
96599
+ testcase( iCol==BMS );
96600
+ testcase( iCol==BMS-1 );
96601
+ pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
9677896602
}
9677996603
}
9678096604
return p;
9678196605
}
9678296606
9678396607
/*
9678496608
** Report an error that an expression is not valid for some set of
9678596609
** pNC->ncFlags values determined by validMask.
96786
-**
96787
-** static void notValid(
96788
-** Parse *pParse, // Leave error message here
96789
-** NameContext *pNC, // The name context
96790
-** const char *zMsg, // Type of error
96791
-** int validMask, // Set of contexts for which prohibited
96792
-** Expr *pExpr // Invalidate this expression on error
96793
-** ){...}
96794
-**
96795
-** As an optimization, since the conditional is almost always false
96796
-** (because errors are rare), the conditional is moved outside of the
96797
-** function call using a macro.
9679896610
*/
96799
-static void notValidImpl(
96800
- Parse *pParse, /* Leave error message here */
96801
- NameContext *pNC, /* The name context */
96802
- const char *zMsg, /* Type of error */
96803
- Expr *pExpr /* Invalidate this expression on error */
96611
+static void notValid(
96612
+ Parse *pParse, /* Leave error message here */
96613
+ NameContext *pNC, /* The name context */
96614
+ const char *zMsg, /* Type of error */
96615
+ int validMask /* Set of contexts for which prohibited */
9680496616
){
96805
- const char *zIn = "partial index WHERE clauses";
96806
- if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
96617
+ assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 );
96618
+ if( (pNC->ncFlags & validMask)!=0 ){
96619
+ const char *zIn = "partial index WHERE clauses";
96620
+ if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
9680796621
#ifndef SQLITE_OMIT_CHECK
96808
- else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
96622
+ else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
9680996623
#endif
9681096624
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
96811
- else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
96625
+ else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
9681296626
#endif
96813
- sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96814
- if( pExpr ) pExpr->op = TK_NULL;
96627
+ sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96628
+ }
9681596629
}
96816
-#define sqlite3ResolveNotValid(P,N,M,X,E) \
96817
- assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
96818
- if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E);
9681996630
9682096631
/*
9682196632
** Expression p should encode a floating point value between 1.0 and 0.0.
9682296633
** Return 1024 times this value. Or return -1 if p is not a floating point
9682396634
** value between 1.0 and 0.0.
@@ -96902,14 +96713,11 @@
9690296713
zDb = 0;
9690396714
zTable = 0;
9690496715
zColumn = pExpr->u.zToken;
9690596716
}else{
9690696717
Expr *pLeft = pExpr->pLeft;
96907
- testcase( pNC->ncFlags & NC_IdxExpr );
96908
- testcase( pNC->ncFlags & NC_GenCol );
96909
- sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator",
96910
- NC_IdxExpr|NC_GenCol, 0);
96718
+ notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol);
9691196719
pRight = pExpr->pRight;
9691296720
if( pRight->op==TK_ID ){
9691396721
zDb = 0;
9691496722
}else{
9691596723
assert( pRight->op==TK_DOT );
@@ -97002,12 +96810,11 @@
9700296810
}
9700396811
if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
9700496812
/* Date/time functions that use 'now', and other functions like
9700596813
** sqlite_version() that might change over time cannot be used
9700696814
** in an index. */
97007
- sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
97008
- NC_SelfRef, 0);
96815
+ notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef);
9700996816
}else{
9701096817
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
9701196818
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
9701296819
}
9701396820
if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
@@ -97105,11 +96912,11 @@
9710596912
#ifndef SQLITE_OMIT_WINDOWFUNC
9710696913
if( pWin ){
9710796914
Select *pSel = pNC->pWinSelect;
9710896915
assert( pWin==pExpr->y.pWin );
9710996916
if( IN_RENAME_OBJECT==0 ){
97110
- sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef);
96917
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef);
9711196918
}
9711296919
sqlite3WalkExprList(pWalker, pWin->pPartition);
9711396920
sqlite3WalkExprList(pWalker, pWin->pOrderBy);
9711496921
sqlite3WalkExpr(pWalker, pWin->pFilter);
9711596922
sqlite3WindowLink(pSel, pWin);
@@ -97150,16 +96957,12 @@
9715096957
#endif
9715196958
case TK_IN: {
9715296959
testcase( pExpr->op==TK_IN );
9715396960
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
9715496961
int nRef = pNC->nRef;
97155
- testcase( pNC->ncFlags & NC_IsCheck );
97156
- testcase( pNC->ncFlags & NC_PartIdx );
97157
- testcase( pNC->ncFlags & NC_IdxExpr );
97158
- testcase( pNC->ncFlags & NC_GenCol );
97159
- sqlite3ResolveNotValid(pParse, pNC, "subqueries",
97160
- NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
96962
+ notValid(pParse, pNC, "subqueries",
96963
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
9716196964
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
9716296965
assert( pNC->nRef>=nRef );
9716396966
if( nRef!=pNC->nRef ){
9716496967
ExprSetProperty(pExpr, EP_VarSelect);
9716596968
pNC->ncFlags |= NC_VarSelect;
@@ -97166,16 +96969,12 @@
9716696969
}
9716796970
}
9716896971
break;
9716996972
}
9717096973
case TK_VARIABLE: {
97171
- testcase( pNC->ncFlags & NC_IsCheck );
97172
- testcase( pNC->ncFlags & NC_PartIdx );
97173
- testcase( pNC->ncFlags & NC_IdxExpr );
97174
- testcase( pNC->ncFlags & NC_GenCol );
97175
- sqlite3ResolveNotValid(pParse, pNC, "parameters",
97176
- NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
96974
+ notValid(pParse, pNC, "parameters",
96975
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
9717796976
break;
9717896977
}
9717996978
case TK_IS:
9718096979
case TK_ISNOT: {
9718196980
Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -98404,11 +98203,10 @@
9840498203
){
9840598204
int p5;
9840698205
int addr;
9840798206
CollSeq *p4;
9840898207
98409
- if( pParse->nErr ) return 0;
9841098208
if( isCommuted ){
9841198209
p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft);
9841298210
}else{
9841398211
p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
9841498212
}
@@ -98622,11 +98420,10 @@
9862298420
int regRight = 0;
9862398421
u8 opx = op;
9862498422
int addrDone = sqlite3VdbeMakeLabel(pParse);
9862598423
int isCommuted = ExprHasProperty(pExpr,EP_Commuted);
9862698424
98627
- if( pParse->nErr ) return;
9862898425
if( nLeft!=sqlite3ExprVectorSize(pRight) ){
9862998426
sqlite3ErrorMsg(pParse, "row value misused");
9863098427
return;
9863198428
}
9863298429
assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
@@ -99971,13 +99768,11 @@
9997199768
switch( pExpr->op ){
9997299769
/* Consider functions to be constant if all their arguments are constant
9997399770
** and either pWalker->eCode==4 or 5 or the function has the
9997499771
** SQLITE_FUNC_CONST flag. */
9997599772
case TK_FUNCTION:
99976
- if( (pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc))
99977
- && !ExprHasProperty(pExpr, EP_WinFunc)
99978
- ){
99773
+ if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){
9997999774
return WRC_Continue;
9998099775
}else{
9998199776
pWalker->eCode = 0;
9998299777
return WRC_Abort;
9998399778
}
@@ -100236,13 +100031,11 @@
100236100031
case TK_BLOB:
100237100032
return 0;
100238100033
case TK_COLUMN:
100239100034
return ExprHasProperty(p, EP_CanBeNull) ||
100240100035
p->y.pTab==0 || /* Reference to column of index on expression */
100241
- (p->iColumn>=0
100242
- && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */
100243
- && p->y.pTab->aCol[p->iColumn].notNull==0);
100036
+ (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0);
100244100037
default:
100245100038
return 1;
100246100039
}
100247100040
}
100248100041
@@ -100715,14 +100508,12 @@
100715100508
** message of the form:
100716100509
**
100717100510
** "sub-select returns N columns - expected M"
100718100511
*/
100719100512
SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
100720
- if( pParse->nErr==0 ){
100721
- const char *zFmt = "sub-select returns %d columns - expected %d";
100722
- sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
100723
- }
100513
+ const char *zFmt = "sub-select returns %d columns - expected %d";
100514
+ sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
100724100515
}
100725100516
#endif
100726100517
100727100518
/*
100728100519
** Expression pExpr is a vector that has been used in a context where
@@ -101220,25 +101011,19 @@
101220101011
}
101221101012
if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
101222101013
sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
101223101014
}
101224101015
if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
101225
- int op = rLhs!=r2 ? OP_Eq : OP_NotNull;
101226
- sqlite3VdbeAddOp4(v, op, rLhs, labelOk, r2,
101016
+ sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
101227101017
(void*)pColl, P4_COLLSEQ);
101228
- VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_Eq);
101229
- VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_Eq);
101230
- VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_NotNull);
101231
- VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_NotNull);
101018
+ VdbeCoverageIf(v, ii<pList->nExpr-1);
101019
+ VdbeCoverageIf(v, ii==pList->nExpr-1);
101232101020
sqlite3VdbeChangeP5(v, zAff[0]);
101233101021
}else{
101234
- int op = rLhs!=r2 ? OP_Ne : OP_IsNull;
101235101022
assert( destIfNull==destIfFalse );
101236
- sqlite3VdbeAddOp4(v, op, rLhs, destIfFalse, r2,
101237
- (void*)pColl, P4_COLLSEQ);
101238
- VdbeCoverageIf(v, op==OP_Ne);
101239
- VdbeCoverageIf(v, op==OP_IsNull);
101023
+ sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,
101024
+ (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
101240101025
sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);
101241101026
}
101242101027
sqlite3ReleaseTempReg(pParse, regToFree);
101243101028
}
101244101029
if( regCkNull ){
@@ -101257,11 +101042,10 @@
101257101042
if( destIfNull==destIfFalse ){
101258101043
destStep2 = destIfFalse;
101259101044
}else{
101260101045
destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
101261101046
}
101262
- if( pParse->nErr ) goto sqlite3ExprCodeIN_finished;
101263101047
for(i=0; i<nVector; i++){
101264101048
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
101265101049
if( sqlite3ExprCanBeNull(p) ){
101266101050
sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
101267101051
VdbeCoverage(v);
@@ -101449,24 +101233,15 @@
101449101233
SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
101450101234
Parse *pParse,
101451101235
Column *pCol,
101452101236
int regOut
101453101237
){
101454
- int iAddr;
101455
- Vdbe *v = pParse->pVdbe;
101456
- assert( v!=0 );
101457
- assert( pParse->iSelfTab!=0 );
101458
- if( pParse->iSelfTab>0 ){
101459
- iAddr = sqlite3VdbeAddOp3(v, OP_IfNullRow, pParse->iSelfTab-1, 0, regOut);
101460
- }else{
101461
- iAddr = 0;
101462
- }
101463101238
sqlite3ExprCode(pParse, pCol->pDflt, regOut);
101464101239
if( pCol->affinity>=SQLITE_AFF_TEXT ){
101465
- sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1);
101240
+ sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0,
101241
+ &pCol->affinity, 1);
101466101242
}
101467
- if( iAddr ) sqlite3VdbeJumpHere(v, iAddr);
101468101243
}
101469101244
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101470101245
101471101246
/*
101472101247
** Generate code to extract the value of the iCol-th column of a table.
@@ -101537,21 +101312,21 @@
101537101312
u8 p5 /* P5 value for OP_Column + FLAGS */
101538101313
){
101539101314
assert( pParse->pVdbe!=0 );
101540101315
sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg);
101541101316
if( p5 ){
101542
- VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1);
101543
- if( pOp->opcode==OP_Column ) pOp->p5 = p5;
101317
+ sqlite3VdbeChangeP5(pParse->pVdbe, p5);
101544101318
}
101545101319
return iReg;
101546101320
}
101547101321
101548101322
/*
101549101323
** Generate code to move content from registers iFrom...iFrom+nReg-1
101550101324
** over to iTo..iTo+nReg-1.
101551101325
*/
101552101326
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){
101327
+ assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );
101553101328
sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);
101554101329
}
101555101330
101556101331
/*
101557101332
** Convert a scalar expression node to a TK_REGISTER referencing
@@ -101649,25 +101424,19 @@
101649101424
}
101650101425
/* Otherwise, fall thru into the TK_COLUMN case */
101651101426
}
101652101427
case TK_COLUMN: {
101653101428
int iTab = pExpr->iTable;
101654
- int iReg;
101655101429
if( ExprHasProperty(pExpr, EP_FixedCol) ){
101656101430
/* This COLUMN expression is really a constant due to WHERE clause
101657101431
** constraints, and that constant is coded by the pExpr->pLeft
101658101432
** expresssion. However, make sure the constant has the correct
101659101433
** datatype by applying the Affinity of the table column to the
101660101434
** constant.
101661101435
*/
101662
- int aff;
101663
- iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
101664
- if( pExpr->y.pTab ){
101665
- aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
101666
- }else{
101667
- aff = pExpr->affExpr;
101668
- }
101436
+ int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
101437
+ int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
101669101438
if( aff>SQLITE_AFF_BLOB ){
101670101439
static const char zAff[] = "B\000C\000D\000E";
101671101440
assert( SQLITE_AFF_BLOB=='A' );
101672101441
assert( SQLITE_AFF_TEXT=='B' );
101673101442
if( iReg!=target ){
@@ -101691,11 +101460,11 @@
101691101460
Table *pTab = pExpr->y.pTab;
101692101461
int iSrc;
101693101462
int iCol = pExpr->iColumn;
101694101463
assert( pTab!=0 );
101695101464
assert( iCol>=XN_ROWID );
101696
- assert( iCol<pTab->nCol );
101465
+ assert( iCol<pExpr->y.pTab->nCol );
101697101466
if( iCol<0 ){
101698101467
return -1-pParse->iSelfTab;
101699101468
}
101700101469
pCol = pTab->aCol + iCol;
101701101470
testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
@@ -101726,17 +101495,13 @@
101726101495
/* Coding an expression that is part of an index where column names
101727101496
** in the index refer to the table to which the index belongs */
101728101497
iTab = pParse->iSelfTab - 1;
101729101498
}
101730101499
}
101731
- iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
101500
+ return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
101732101501
pExpr->iColumn, iTab, target,
101733101502
pExpr->op2);
101734
- if( pExpr->y.pTab==0 && pExpr->affExpr==SQLITE_AFF_REAL ){
101735
- sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
101736
- }
101737
- return iReg;
101738101503
}
101739101504
case TK_INTEGER: {
101740101505
codeInteger(pParse, pExpr, 0, target);
101741101506
return target;
101742101507
}
@@ -101754,16 +101519,11 @@
101754101519
case TK_STRING: {
101755101520
assert( !ExprHasProperty(pExpr, EP_IntValue) );
101756101521
sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
101757101522
return target;
101758101523
}
101759
- default: {
101760
- /* Make NULL the default case so that if a bug causes an illegal
101761
- ** Expr node to be passed into this function, it will be handled
101762
- ** sanely and not crash. But keep the assert() to bring the problem
101763
- ** to the attention of the developers. */
101764
- assert( op==TK_NULL );
101524
+ case TK_NULL: {
101765101525
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101766101526
return target;
101767101527
}
101768101528
#ifndef SQLITE_OMIT_BLOB_LITERAL
101769101529
case TK_BLOB: {
@@ -101786,11 +101546,11 @@
101786101546
assert( pExpr->u.zToken!=0 );
101787101547
assert( pExpr->u.zToken[0]!=0 );
101788101548
sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
101789101549
if( pExpr->u.zToken[1]!=0 ){
101790101550
const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
101791
- assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) );
101551
+ assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );
101792101552
pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
101793101553
sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
101794101554
}
101795101555
return target;
101796101556
}
@@ -102099,16 +101859,12 @@
102099101859
#endif
102100101860
{
102101101861
sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
102102101862
pDef, pExpr->op2);
102103101863
}
102104
- if( nFarg ){
102105
- if( constMask==0 ){
102106
- sqlite3ReleaseTempRange(pParse, r1, nFarg);
102107
- }else{
102108
- sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask);
102109
- }
101864
+ if( nFarg && constMask==0 ){
101865
+ sqlite3ReleaseTempRange(pParse, r1, nFarg);
102110101866
}
102111101867
return target;
102112101868
}
102113101869
#ifndef SQLITE_OMIT_SUBQUERY
102114101870
case TK_EXISTS:
@@ -102200,11 +101956,11 @@
102200101956
** p1==2 -> old.b p1==5 -> new.b
102201101957
*/
102202101958
Table *pTab = pExpr->y.pTab;
102203101959
int iCol = pExpr->iColumn;
102204101960
int p1 = pExpr->iTable * (pTab->nCol+1) + 1
102205
- + sqlite3TableColumnToStorage(pTab, iCol);
101961
+ + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1);
102206101962
102207101963
assert( pExpr->iTable==0 || pExpr->iTable==1 );
102208101964
assert( iCol>=-1 && iCol<pTab->nCol );
102209101965
assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
102210101966
assert( p1>=0 && p1<(pTab->nCol*2+2) );
@@ -102274,11 +102030,11 @@
102274102030
**
102275102031
** The result of the expression is the Ri for the first matching Ei,
102276102032
** or if there is no matching Ei, the ELSE term Y, or if there is
102277102033
** no ELSE term, NULL.
102278102034
*/
102279
- case TK_CASE: {
102035
+ default: assert( op==TK_CASE ); {
102280102036
int endLabel; /* GOTO label for end of CASE stmt */
102281102037
int nextCase; /* GOTO label for next WHEN clause */
102282102038
int nExpr; /* 2x number of WHEN terms */
102283102039
int i; /* Loop counter */
102284102040
ExprList *pEList; /* List of WHEN terms */
@@ -103331,14 +103087,11 @@
103331103087
sqlite3WalkExpr(pWalker, pExpr->pRight);
103332103088
}
103333103089
return WRC_Prune;
103334103090
103335103091
case TK_BETWEEN:
103336
- if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){
103337
- assert( pWalker->eCode );
103338
- return WRC_Abort;
103339
- }
103092
+ sqlite3WalkExpr(pWalker, pExpr->pLeft);
103340103093
return WRC_Prune;
103341103094
103342103095
/* Virtual tables are allowed to use constraints like x=NULL. So
103343103096
** a term of the form x=y does not prove that y is not null if x
103344103097
** is the column of a virtual table */
@@ -103748,15 +103501,12 @@
103748103501
/*
103749103502
** Deallocate a register, making available for reuse for some other
103750103503
** purpose.
103751103504
*/
103752103505
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
103753
- if( iReg ){
103754
- sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0);
103755
- if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){
103756
- pParse->aTempReg[pParse->nTempReg++] = iReg;
103757
- }
103506
+ if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){
103507
+ pParse->aTempReg[pParse->nTempReg++] = iReg;
103758103508
}
103759103509
}
103760103510
103761103511
/*
103762103512
** Allocate or deallocate a block of nReg consecutive registers.
@@ -103778,11 +103528,10 @@
103778103528
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
103779103529
if( nReg==1 ){
103780103530
sqlite3ReleaseTempReg(pParse, iReg);
103781103531
return;
103782103532
}
103783
- sqlite3VdbeReleaseRegisters(pParse, iReg, nReg, 0);
103784103533
if( nReg>pParse->nRangeReg ){
103785103534
pParse->nRangeReg = nReg;
103786103535
pParse->iRangeReg = iReg;
103787103536
}
103788103537
}
@@ -104522,18 +104271,16 @@
104522104271
*/
104523104272
SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
104524104273
RenameToken *pNew;
104525104274
assert( pPtr || pParse->db->mallocFailed );
104526104275
renameTokenCheckAll(pParse, pPtr);
104527
- if( pParse->eParseMode!=PARSE_MODE_UNMAP ){
104528
- pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
104529
- if( pNew ){
104530
- pNew->p = pPtr;
104531
- pNew->t = *pToken;
104532
- pNew->pNext = pParse->pRename;
104533
- pParse->pRename = pNew;
104534
- }
104276
+ pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
104277
+ if( pNew ){
104278
+ pNew->p = pPtr;
104279
+ pNew->t = *pToken;
104280
+ pNew->pNext = pParse->pRename;
104281
+ pParse->pRename = pNew;
104535104282
}
104536104283
104537104284
return pPtr;
104538104285
}
104539104286
@@ -104560,38 +104307,16 @@
104560104307
Parse *pParse = pWalker->pParse;
104561104308
sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
104562104309
return WRC_Continue;
104563104310
}
104564104311
104565
-/*
104566
-** Iterate through the Select objects that are part of WITH clauses attached
104567
-** to select statement pSelect.
104568
-*/
104569
-static void renameWalkWith(Walker *pWalker, Select *pSelect){
104570
- With *pWith = pSelect->pWith;
104571
- if( pWith ){
104572
- int i;
104573
- for(i=0; i<pWith->nCte; i++){
104574
- Select *p = pWith->a[i].pSelect;
104575
- NameContext sNC;
104576
- memset(&sNC, 0, sizeof(sNC));
104577
- sNC.pParse = pWalker->pParse;
104578
- sqlite3SelectPrep(sNC.pParse, p, &sNC);
104579
- sqlite3WalkSelect(pWalker, p);
104580
- sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
104581
- }
104582
- }
104583
-}
104584
-
104585104312
/*
104586104313
** Walker callback used by sqlite3RenameExprUnmap().
104587104314
*/
104588104315
static int renameUnmapSelectCb(Walker *pWalker, Select *p){
104589104316
Parse *pParse = pWalker->pParse;
104590104317
int i;
104591
- if( pParse->nErr ) return WRC_Abort;
104592
- if( NEVER(p->selFlags & SF_View) ) return WRC_Prune;
104593104318
if( ALWAYS(p->pEList) ){
104594104319
ExprList *pList = p->pEList;
104595104320
for(i=0; i<pList->nExpr; i++){
104596104321
if( pList->a[i].zName ){
104597104322
sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName);
@@ -104600,31 +104325,25 @@
104600104325
}
104601104326
if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */
104602104327
SrcList *pSrc = p->pSrc;
104603104328
for(i=0; i<pSrc->nSrc; i++){
104604104329
sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
104605
- if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
104606104330
}
104607104331
}
104608
-
104609
- renameWalkWith(pWalker, p);
104610104332
return WRC_Continue;
104611104333
}
104612104334
104613104335
/*
104614104336
** Remove all nodes that are part of expression pExpr from the rename list.
104615104337
*/
104616104338
SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){
104617
- u8 eMode = pParse->eParseMode;
104618104339
Walker sWalker;
104619104340
memset(&sWalker, 0, sizeof(Walker));
104620104341
sWalker.pParse = pParse;
104621104342
sWalker.xExprCallback = renameUnmapExprCb;
104622104343
sWalker.xSelectCallback = renameUnmapSelectCb;
104623
- pParse->eParseMode = PARSE_MODE_UNMAP;
104624104344
sqlite3WalkExpr(&sWalker, pExpr);
104625
- pParse->eParseMode = eMode;
104626104345
}
104627104346
104628104347
/*
104629104348
** Remove all nodes that are part of expression-list pEList from the
104630104349
** rename list.
@@ -104673,18 +104392,35 @@
104673104392
pCtx->nList++;
104674104393
break;
104675104394
}
104676104395
}
104677104396
}
104397
+
104398
+/*
104399
+** Iterate through the Select objects that are part of WITH clauses attached
104400
+** to select statement pSelect.
104401
+*/
104402
+static void renameWalkWith(Walker *pWalker, Select *pSelect){
104403
+ if( pSelect->pWith ){
104404
+ int i;
104405
+ for(i=0; i<pSelect->pWith->nCte; i++){
104406
+ Select *p = pSelect->pWith->a[i].pSelect;
104407
+ NameContext sNC;
104408
+ memset(&sNC, 0, sizeof(sNC));
104409
+ sNC.pParse = pWalker->pParse;
104410
+ sqlite3SelectPrep(sNC.pParse, p, &sNC);
104411
+ sqlite3WalkSelect(pWalker, p);
104412
+ }
104413
+ }
104414
+}
104678104415
104679104416
/*
104680104417
** This is a Walker select callback. It does nothing. It is only required
104681104418
** because without a dummy callback, sqlite3WalkExpr() and similar do not
104682104419
** descend into sub-select statements.
104683104420
*/
104684104421
static int renameColumnSelectCb(Walker *pWalker, Select *p){
104685
- if( p->selFlags & SF_View ) return WRC_Prune;
104686104422
renameWalkWith(pWalker, p);
104687104423
return WRC_Continue;
104688104424
}
104689104425
104690104426
/*
@@ -104811,10 +104547,11 @@
104811104547
** is initialized by this function before it is used.
104812104548
*/
104813104549
static int renameParseSql(
104814104550
Parse *p, /* Memory to use for Parse object */
104815104551
const char *zDb, /* Name of schema SQL belongs to */
104552
+ int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */
104816104553
sqlite3 *db, /* Database handle */
104817104554
const char *zSql, /* SQL to parse */
104818104555
int bTemp /* True if SQL is from temp schema */
104819104556
){
104820104557
int rc;
@@ -104824,11 +104561,11 @@
104824104561
104825104562
/* Parse the SQL statement passed as the first argument. If no error
104826104563
** occurs and the parse does not result in a new table, index or
104827104564
** trigger object, the database must be corrupt. */
104828104565
memset(p, 0, sizeof(Parse));
104829
- p->eParseMode = PARSE_MODE_RENAME;
104566
+ p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN);
104830104567
p->db = db;
104831104568
p->nQueryLoop = 1;
104832104569
rc = sqlite3RunParser(p, zSql, &zErr);
104833104570
assert( p->zErrMsg==0 );
104834104571
assert( rc!=SQLITE_OK || zErr==0 );
@@ -105131,11 +104868,11 @@
105131104868
sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
105132104869
105133104870
#ifndef SQLITE_OMIT_AUTHORIZATION
105134104871
db->xAuth = 0;
105135104872
#endif
105136
- rc = renameParseSql(&sParse, zDb, db, zSql, bTemp);
104873
+ rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);
105137104874
105138104875
/* Find tokens that need to be replaced. */
105139104876
memset(&sWalker, 0, sizeof(Walker));
105140104877
sWalker.pParse = &sParse;
105141104878
sWalker.xExprCallback = renameColumnExprCb;
@@ -105145,13 +104882,12 @@
105145104882
sCtx.pTab = pTab;
105146104883
if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
105147104884
if( sParse.pNewTable ){
105148104885
Select *pSelect = sParse.pNewTable->pSelect;
105149104886
if( pSelect ){
105150
- pSelect->selFlags &= ~SF_View;
105151104887
sParse.rc = SQLITE_OK;
105152
- sqlite3SelectPrep(&sParse, pSelect, 0);
104888
+ sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0);
105153104889
rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
105154104890
if( rc==SQLITE_OK ){
105155104891
sqlite3WalkSelect(&sWalker, pSelect);
105156104892
}
105157104893
if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
@@ -105264,11 +105000,10 @@
105264105000
*/
105265105001
static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
105266105002
int i;
105267105003
RenameCtx *p = pWalker->u.pRename;
105268105004
SrcList *pSrc = pSelect->pSrc;
105269
- if( pSelect->selFlags & SF_View ) return WRC_Prune;
105270105005
if( pSrc==0 ){
105271105006
assert( pWalker->pParse->db->mallocFailed );
105272105007
return WRC_Abort;
105273105008
}
105274105009
for(i=0; i<pSrc->nSrc; i++){
@@ -105335,32 +105070,26 @@
105335105070
sWalker.pParse = &sParse;
105336105071
sWalker.xExprCallback = renameTableExprCb;
105337105072
sWalker.xSelectCallback = renameTableSelectCb;
105338105073
sWalker.u.pRename = &sCtx;
105339105074
105340
- rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
105075
+ rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
105341105076
105342105077
if( rc==SQLITE_OK ){
105343105078
int isLegacy = (db->flags & SQLITE_LegacyAlter);
105344105079
if( sParse.pNewTable ){
105345105080
Table *pTab = sParse.pNewTable;
105346105081
105347105082
if( pTab->pSelect ){
105348105083
if( isLegacy==0 ){
105349
- Select *pSelect = pTab->pSelect;
105350105084
NameContext sNC;
105351105085
memset(&sNC, 0, sizeof(sNC));
105352105086
sNC.pParse = &sParse;
105353105087
105354
- assert( pSelect->selFlags & SF_View );
105355
- pSelect->selFlags &= ~SF_View;
105356105088
sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
105357
- if( sParse.nErr ){
105358
- rc = sParse.rc;
105359
- }else{
105360
- sqlite3WalkSelect(&sWalker, pTab->pSelect);
105361
- }
105089
+ if( sParse.nErr ) rc = sParse.rc;
105090
+ sqlite3WalkSelect(&sWalker, pTab->pSelect);
105362105091
}
105363105092
}else{
105364105093
/* Modify any FK definitions to point to the new table. */
105365105094
#ifndef SQLITE_OMIT_FOREIGN_KEY
105366105095
if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
@@ -105477,11 +105206,11 @@
105477105206
105478105207
UNUSED_PARAMETER(NotUsed);
105479105208
if( zDb && zInput ){
105480105209
int rc;
105481105210
Parse sParse;
105482
- rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
105211
+ rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
105483105212
if( rc==SQLITE_OK ){
105484105213
if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
105485105214
NameContext sNC;
105486105215
memset(&sNC, 0, sizeof(sNC));
105487105216
sNC.pParse = &sParse;
@@ -109270,19 +108999,17 @@
109270108999
**
109271109000
** So, in other words, this routine shifts all the virtual columns to
109272109001
** the end.
109273109002
**
109274109003
** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
109275
-** this routine is a no-op macro. If the pTab does not have any virtual
109276
-** columns, then this routine is no-op that always return iCol. If iCol
109277
-** is negative (indicating the ROWID column) then this routine return iCol.
109004
+** this routine is a no-op macro.
109278109005
*/
109279109006
SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
109280109007
int i;
109281109008
i16 n;
109282109009
assert( iCol<pTab->nCol );
109283
- if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol;
109010
+ if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol;
109284109011
for(i=0, n=0; i<iCol; i++){
109285109012
if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++;
109286109013
}
109287109014
if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
109288109015
/* iCol is a virtual column itself */
@@ -109870,11 +109597,10 @@
109870109597
pTab->iPKey = iCol;
109871109598
pTab->keyConf = (u8)onError;
109872109599
assert( autoInc==0 || autoInc==1 );
109873109600
pTab->tabFlags |= autoInc*TF_Autoincrement;
109874109601
if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
109875
- (void)sqlite3HasExplicitNulls(pParse, pList);
109876109602
}else if( autoInc ){
109877109603
#ifndef SQLITE_OMIT_AUTOINCREMENT
109878109604
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
109879109605
"INTEGER PRIMARY KEY");
109880109606
#endif
@@ -109955,14 +109681,11 @@
109955109681
SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
109956109682
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
109957109683
u8 eType = COLFLAG_VIRTUAL;
109958109684
Table *pTab = pParse->pNewTable;
109959109685
Column *pCol;
109960
- if( pTab==0 ){
109961
- /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */
109962
- goto generated_done;
109963
- }
109686
+ if( NEVER(pTab==0) ) goto generated_done;
109964109687
pCol = &(pTab->aCol[pTab->nCol-1]);
109965109688
if( IN_DECLARE_VTAB ){
109966109689
sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
109967109690
goto generated_done;
109968109691
}
@@ -110566,16 +110289,10 @@
110566110289
#ifndef SQLITE_OMIT_CHECK
110567110290
/* Resolve names in all CHECK constraint expressions.
110568110291
*/
110569110292
if( p->pCheck ){
110570110293
sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
110571
- if( pParse->nErr ){
110572
- /* If errors are seen, delete the CHECK constraints now, else they might
110573
- ** actually be used if PRAGMA writable_schema=ON is set. */
110574
- sqlite3ExprListDelete(db, p->pCheck);
110575
- p->pCheck = 0;
110576
- }
110577110294
}
110578110295
#endif /* !defined(SQLITE_OMIT_CHECK) */
110579110296
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
110580110297
if( p->tabFlags & TF_HasGenerated ){
110581110298
int ii, nNG = 0;
@@ -110582,23 +110299,14 @@
110582110299
testcase( p->tabFlags & TF_HasVirtual );
110583110300
testcase( p->tabFlags & TF_HasStored );
110584110301
for(ii=0; ii<p->nCol; ii++){
110585110302
u32 colFlags = p->aCol[ii].colFlags;
110586110303
if( (colFlags & COLFLAG_GENERATED)!=0 ){
110587
- Expr *pX = p->aCol[ii].pDflt;
110588110304
testcase( colFlags & COLFLAG_VIRTUAL );
110589110305
testcase( colFlags & COLFLAG_STORED );
110590
- if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){
110591
- /* If there are errors in resolving the expression, change the
110592
- ** expression to a NULL. This prevents code generators that operate
110593
- ** on the expression from inserting extra parts into the expression
110594
- ** tree that have been allocated from lookaside memory, which is
110595
- ** illegal in a schema and will lead to errors heap corruption when
110596
- ** the database connection closes. */
110597
- sqlite3ExprDelete(db, pX);
110598
- p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
110599
- }
110306
+ sqlite3ResolveSelfReference(pParse, p, NC_GenCol,
110307
+ p->aCol[ii].pDflt, 0);
110600110308
}else{
110601110309
nNG++;
110602110310
}
110603110311
}
110604110312
if( nNG==0 ){
@@ -110824,11 +110532,10 @@
110824110532
/* Make a copy of the entire SELECT statement that defines the view.
110825110533
** This will force all the Expr.token.z values to be dynamically
110826110534
** allocated rather than point to the input string - which means that
110827110535
** they will persist after the current sqlite3_exec() call returns.
110828110536
*/
110829
- pSelect->selFlags |= SF_View;
110830110537
if( IN_RENAME_OBJECT ){
110831110538
p->pSelect = pSelect;
110832110539
pSelect = 0;
110833110540
}else{
110834110541
p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
@@ -112251,13 +111958,30 @@
112251111958
}
112252111959
112253111960
sqlite3VdbeJumpHere(v, pIndex->tnum);
112254111961
}
112255111962
}
111963
+
111964
+ /* When adding an index to the list of indices for a table, make
111965
+ ** sure all indices labeled OE_Replace come after all those labeled
111966
+ ** OE_Ignore. This is necessary for the correct constraint check
111967
+ ** processing (in sqlite3GenerateConstraintChecks()) as part of
111968
+ ** UPDATE and INSERT statements.
111969
+ */
112256111970
if( db->init.busy || pTblName==0 ){
112257
- pIndex->pNext = pTab->pIndex;
112258
- pTab->pIndex = pIndex;
111971
+ if( onError!=OE_Replace || pTab->pIndex==0
111972
+ || pTab->pIndex->onError==OE_Replace){
111973
+ pIndex->pNext = pTab->pIndex;
111974
+ pTab->pIndex = pIndex;
111975
+ }else{
111976
+ Index *pOther = pTab->pIndex;
111977
+ while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){
111978
+ pOther = pOther->pNext;
111979
+ }
111980
+ pIndex->pNext = pOther->pNext;
111981
+ pOther->pNext = pIndex;
111982
+ }
112259111983
pIndex = 0;
112260111984
}
112261111985
else if( IN_RENAME_OBJECT ){
112262111986
assert( pParse->pNewIndex==0 );
112263111987
pParse->pNewIndex = pIndex;
@@ -112265,25 +111989,10 @@
112265111989
}
112266111990
112267111991
/* Clean up before exiting */
112268111992
exit_create_index:
112269111993
if( pIndex ) sqlite3FreeIndex(db, pIndex);
112270
- if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */
112271
- Index **ppFrom = &pTab->pIndex;
112272
- Index *pThis;
112273
- for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){
112274
- Index *pNext;
112275
- if( pThis->onError!=OE_Replace ) continue;
112276
- while( (pNext = pThis->pNext)!=0 && pNext->onError!=OE_Replace ){
112277
- *ppFrom = pNext;
112278
- pThis->pNext = pNext->pNext;
112279
- pNext->pNext = pThis;
112280
- ppFrom = &pNext->pNext;
112281
- }
112282
- break;
112283
- }
112284
- }
112285111994
sqlite3ExprDelete(db, pPIWhere);
112286111995
sqlite3ExprListDelete(db, pList);
112287111996
sqlite3SrcListDelete(db, pTblName);
112288111997
sqlite3DbFree(db, zName);
112289111998
}
@@ -118522,15 +118231,14 @@
118522118231
}
118523118232
return 0;
118524118233
}
118525118234
118526118235
/* This walker callback will compute the union of colFlags flags for all
118527
-** referenced columns in a CHECK constraint or generated column expression.
118236
+** references columns in a CHECK constraint or generated column expression.
118528118237
*/
118529118238
static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){
118530
- if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 ){
118531
- assert( pExpr->iColumn < pWalker->u.pTab->nCol );
118239
+ if( pExpr->op==TK_COLUMN ){
118532118240
pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags;
118533118241
}
118534118242
return WRC_Continue;
118535118243
}
118536118244
@@ -118549,40 +118257,10 @@
118549118257
){
118550118258
int i;
118551118259
Walker w;
118552118260
Column *pRedo;
118553118261
int eProgress;
118554
- VdbeOp *pOp;
118555
-
118556
- assert( pTab->tabFlags & TF_HasGenerated );
118557
- testcase( pTab->tabFlags & TF_HasVirtual );
118558
- testcase( pTab->tabFlags & TF_HasStored );
118559
-
118560
- /* Before computing generated columns, first go through and make sure
118561
- ** that appropriate affinity has been applied to the regular columns
118562
- */
118563
- sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore);
118564
- if( (pTab->tabFlags & TF_HasStored)!=0
118565
- && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity
118566
- ){
118567
- /* Change the OP_Affinity argument to '@' (NONE) for all stored
118568
- ** columns. '@' is the no-op affinity and those columns have not
118569
- ** yet been computed. */
118570
- int ii, jj;
118571
- char *zP4 = pOp->p4.z;
118572
- assert( zP4!=0 );
118573
- assert( pOp->p4type==P4_DYNAMIC );
118574
- for(ii=jj=0; zP4[jj]; ii++){
118575
- if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){
118576
- continue;
118577
- }
118578
- if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){
118579
- zP4[jj] = SQLITE_AFF_NONE;
118580
- }
118581
- jj++;
118582
- }
118583
- }
118584118262
118585118263
/* Because there can be multiple generated columns that refer to one another,
118586118264
** this is a two-pass algorithm. On the first pass, mark all generated
118587118265
** columns as "not available".
118588118266
*/
@@ -119299,14 +118977,10 @@
119299118977
if( IsVirtual(pTab) ){
119300118978
sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
119301118979
pTab->zName);
119302118980
goto insert_cleanup;
119303118981
}
119304
- if( pTab->pSelect ){
119305
- sqlite3ErrorMsg(pParse, "cannot UPSERT a view");
119306
- goto insert_cleanup;
119307
- }
119308118982
if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){
119309118983
goto insert_cleanup;
119310118984
}
119311118985
pTabList->a[0].iCursor = iDataCur;
119312118986
pUpsert->pUpsertSrc = pTabList;
@@ -119537,12 +119211,14 @@
119537119211
119538119212
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
119539119213
/* Compute the new value for generated columns after all other
119540119214
** columns have already been computed. This must be done after
119541119215
** computing the ROWID in case one of the generated columns
119542
- ** is derived from the INTEGER PRIMARY KEY. */
119216
+ ** refers to the ROWID. */
119543119217
if( pTab->tabFlags & TF_HasGenerated ){
119218
+ testcase( pTab->tabFlags & TF_HasVirtual );
119219
+ testcase( pTab->tabFlags & TF_HasStored );
119544119220
sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
119545119221
}
119546119222
#endif
119547119223
119548119224
/* Generate code to check constraints and generate index keys and
@@ -120570,14 +120246,10 @@
120570120246
120571120247
v = sqlite3GetVdbe(pParse);
120572120248
assert( v!=0 );
120573120249
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
120574120250
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
120575
- /* All REPLACE indexes are at the end of the list */
120576
- assert( pIdx->onError!=OE_Replace
120577
- || pIdx->pNext==0
120578
- || pIdx->pNext->onError==OE_Replace );
120579120251
if( aRegIdx[i]==0 ) continue;
120580120252
if( pIdx->pPartIdxWhere ){
120581120253
sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
120582120254
VdbeCoverage(v);
120583120255
}
@@ -125041,13 +124713,11 @@
125041124713
char *zErr;
125042124714
int jmp2;
125043124715
if( j==pTab->iPKey ) continue;
125044124716
if( pTab->aCol[j].notNull==0 ) continue;
125045124717
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
125046
- if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){
125047
- sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
125048
- }
124718
+ sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
125049124719
jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
125050124720
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
125051124721
pTab->aCol[j].zName);
125052124722
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
125053124723
integrityCheckResultRow(v);
@@ -127009,14 +126679,11 @@
127009126679
};
127010126680
#define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
127011126681
127012126682
/*
127013126683
** Delete all the content of a Select structure. Deallocate the structure
127014
-** itself depending on the value of bFree
127015
-**
127016
-** If bFree==1, call sqlite3DbFree() on the p object.
127017
-** If bFree==0, Leave the first Select object unfreed
126684
+** itself only if bFree is true.
127018126685
*/
127019126686
static void clearSelect(sqlite3 *db, Select *p, int bFree){
127020126687
while( p ){
127021126688
Select *pPrior = p->pPrior;
127022126689
sqlite3ExprListDelete(db, p->pEList);
@@ -127116,24 +126783,10 @@
127116126783
*/
127117126784
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
127118126785
if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);
127119126786
}
127120126787
127121
-/*
127122
-** Delete all the substructure for p, but keep p allocated. Redefine
127123
-** p to be a single SELECT where every column of the result set has a
127124
-** value of NULL.
127125
-*/
127126
-SQLITE_PRIVATE void sqlite3SelectReset(Parse *pParse, Select *p){
127127
- if( ALWAYS(p) ){
127128
- clearSelect(pParse->db, p, 0);
127129
- memset(&p->iLimit, 0, sizeof(Select) - offsetof(Select,iLimit));
127130
- p->pEList = sqlite3ExprListAppend(pParse, 0,
127131
- sqlite3ExprAlloc(pParse->db,TK_NULL,0,0));
127132
- }
127133
-}
127134
-
127135126788
/*
127136126789
** Return a pointer to the right-most SELECT statement in a compound.
127137126790
*/
127138126791
static Select *findRightmost(Select *p){
127139126792
while( p->pNext ) p = p->pNext;
@@ -129416,11 +129069,10 @@
129416129069
assert( p->selFlags & SF_MultiValue );
129417129070
do{
129418129071
assert( p->selFlags & SF_Values );
129419129072
assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
129420129073
assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );
129421
- if( p->pWin ) return -1;
129422129074
if( p->pPrior==0 ) break;
129423129075
assert( p->pPrior->pNext==p );
129424129076
p = p->pPrior;
129425129077
nRow += bShowAll;
129426129078
}while(1);
@@ -129507,12 +129159,11 @@
129507129159
129508129160
/* Special handling for a compound-select that originates as a VALUES clause.
129509129161
*/
129510129162
if( p->selFlags & SF_MultiValue ){
129511129163
rc = multiSelectValues(pParse, p, &dest);
129512
- if( rc>=0 ) goto multi_select_end;
129513
- rc = SQLITE_OK;
129164
+ goto multi_select_end;
129514129165
}
129515129166
129516129167
/* Make sure all SELECTs in the statement have the same number of elements
129517129168
** in their result sets.
129518129169
*/
@@ -129653,13 +129304,13 @@
129653129304
129654129305
/* Convert the data in the temporary table into whatever form
129655129306
** it is that we currently need.
129656129307
*/
129657129308
assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
129658
- assert( p->pEList || db->mallocFailed );
129659
- if( dest.eDest!=priorOp && db->mallocFailed==0 ){
129309
+ if( dest.eDest!=priorOp ){
129660129310
int iCont, iBreak, iStart;
129311
+ assert( p->pEList );
129661129312
iBreak = sqlite3VdbeMakeLabel(pParse);
129662129313
iCont = sqlite3VdbeMakeLabel(pParse);
129663129314
computeLimitRegisters(pParse, p, iBreak);
129664129315
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
129665129316
iStart = sqlite3VdbeCurrentAddr(v);
@@ -129751,11 +129402,10 @@
129751129402
if( p->pNext==0 ){
129752129403
ExplainQueryPlanPop(pParse);
129753129404
}
129754129405
#endif
129755129406
}
129756
- if( pParse->nErr ) goto multi_select_end;
129757129407
129758129408
/* Compute collating sequences used by
129759129409
** temporary tables needed to implement the compound select.
129760129410
** Attach the KeyInfo structure to all temporary tables.
129761129411
**
@@ -130543,11 +130193,10 @@
130543130193
** (3) If the subquery is the right operand of a LEFT JOIN then
130544130194
** (3a) the subquery may not be a join and
130545130195
** (3b) the FROM clause of the subquery may not contain a virtual
130546130196
** table and
130547130197
** (3c) the outer query may not be an aggregate.
130548
-** (3d) the outer query may not be DISTINCT.
130549130198
**
130550130199
** (4) The subquery can not be DISTINCT.
130551130200
**
130552130201
** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
130553130202
** sub-queries that were excluded from this optimization. Restriction
@@ -130740,15 +130389,12 @@
130740130389
**
130741130390
** See also tickets #306, #350, and #3300.
130742130391
*/
130743130392
if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
130744130393
isLeftJoin = 1;
130745
- if( pSubSrc->nSrc>1 /* (3a) */
130746
- || isAgg /* (3b) */
130747
- || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */
130748
- || (p->selFlags & SF_Distinct)!=0 /* (3d) */
130749
- ){
130394
+ if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){
130395
+ /* (3a) (3c) (3b) */
130750130396
return 0;
130751130397
}
130752130398
}
130753130399
#ifdef SQLITE_EXTRA_IFNULLROW
130754130400
else if( iFrom>0 && !isAgg ){
@@ -131518,13 +131164,10 @@
131518131164
pNew->pHaving = 0;
131519131165
pNew->pOrderBy = 0;
131520131166
p->pPrior = 0;
131521131167
p->pNext = 0;
131522131168
p->pWith = 0;
131523
-#ifndef SQLITE_OMIT_WINDOWFUNC
131524
- p->pWinDefn = 0;
131525
-#endif
131526131169
p->selFlags &= ~SF_Compound;
131527131170
assert( (p->selFlags & SF_Converted)==0 );
131528131171
p->selFlags |= SF_Converted;
131529131172
assert( pNew->pPrior!=0 );
131530131173
pNew->pPrior->pNext = pNew;
@@ -132680,13 +132323,11 @@
132680132323
if( pDest->eDest==SRT_Output ){
132681132324
generateColumnNames(pParse, p);
132682132325
}
132683132326
132684132327
#ifndef SQLITE_OMIT_WINDOWFUNC
132685
- rc = sqlite3WindowRewrite(pParse, p);
132686
- if( rc ){
132687
- assert( db->mallocFailed || pParse->nErr>0 );
132328
+ if( sqlite3WindowRewrite(pParse, p) ){
132688132329
goto select_end;
132689132330
}
132690132331
#if SELECTTRACE_ENABLED
132691132332
if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
132692132333
SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
@@ -133018,11 +132659,10 @@
133018132659
** written the query must use a temp-table for at least one of the ORDER
133019132660
** BY and DISTINCT, and an index or separate temp-table for the other.
133020132661
*/
133021132662
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
133022132663
&& sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
133023
- && p->pWin==0
133024132664
){
133025132665
p->selFlags &= ~SF_Distinct;
133026132666
pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
133027132667
/* Notice that even thought SF_Distinct has been cleared from p->selFlags,
133028132668
** the sDistinct.isTnct is still set. Hence, isTnct represents the
@@ -134542,16 +134182,12 @@
134542134182
if( ALWAYS(pTrigger) ){
134543134183
if( pTrigger->pSchema==pTrigger->pTabSchema ){
134544134184
Table *pTab = tableOfTrigger(pTrigger);
134545134185
if( pTab ){
134546134186
Trigger **pp;
134547
- for(pp=&pTab->pTrigger; *pp; pp=&((*pp)->pNext)){
134548
- if( *pp==pTrigger ){
134549
- *pp = (*pp)->pNext;
134550
- break;
134551
- }
134552
- }
134187
+ for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
134188
+ *pp = (*pp)->pNext;
134553134189
}
134554134190
}
134555134191
sqlite3DeleteTrigger(db, pTrigger);
134556134192
db->mDbFlags |= DBFLAG_SchemaChange;
134557134193
}
@@ -137278,12 +136914,10 @@
137278136914
char *zWhere;
137279136915
int iDb;
137280136916
int iReg;
137281136917
Vdbe *v;
137282136918
137283
- sqlite3MayAbort(pParse);
137284
-
137285136919
/* Compute the complete text of the CREATE VIRTUAL TABLE statement */
137286136920
if( pEnd ){
137287136921
pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
137288136922
}
137289136923
zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
@@ -137305,17 +136939,17 @@
137305136939
pTab->zName,
137306136940
pTab->zName,
137307136941
zStmt,
137308136942
pParse->regRowid
137309136943
);
136944
+ sqlite3DbFree(db, zStmt);
137310136945
v = sqlite3GetVdbe(pParse);
137311136946
sqlite3ChangeCookie(pParse, iDb);
137312136947
137313136948
sqlite3VdbeAddOp0(v, OP_Expire);
137314
- zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt);
136949
+ zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
137315136950
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
137316
- sqlite3DbFree(db, zStmt);
137317136951
137318136952
iReg = ++pParse->nMem;
137319136953
sqlite3VdbeLoadString(v, iReg, pTab->zName);
137320136954
sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
137321136955
}
@@ -137713,12 +137347,11 @@
137713137347
return SQLITE_LOCKED;
137714137348
}
137715137349
}
137716137350
p = vtabDisconnectAll(db, pTab);
137717137351
xDestroy = p->pMod->pModule->xDestroy;
137718
- if( xDestroy==0 ) xDestroy = p->pMod->pModule->xDisconnect;
137719
- assert( xDestroy!=0 );
137352
+ assert( xDestroy!=0 ); /* Checked before the virtual table is created */
137720137353
pTab->nTabRef++;
137721137354
rc = xDestroy(p->pVtab);
137722137355
/* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
137723137356
if( rc==SQLITE_OK ){
137724137357
assert( pTab->pVTable==p && p->pNext==0 );
@@ -139143,12 +138776,11 @@
139143138776
int iEq, /* Look at loop terms starting here */
139144138777
WhereLoop *pLoop, /* The current loop */
139145138778
Expr *pX /* The IN expression to be reduced */
139146138779
){
139147138780
sqlite3 *db = pParse->db;
139148
- Expr *pNew;
139149
- pNew = sqlite3ExprDup(db, pX, 0);
138781
+ Expr *pNew = sqlite3ExprDup(db, pX, 0);
139150138782
if( db->mallocFailed==0 ){
139151138783
ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */
139152138784
ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */
139153138785
ExprList *pRhs = 0; /* New RHS after modifications */
139154138786
ExprList *pLhs = 0; /* New LHS after mods */
@@ -139856,13 +139488,10 @@
139856139488
pExpr->affExpr = sqlite3ExprAffinity(pExpr);
139857139489
pExpr->op = TK_COLUMN;
139858139490
pExpr->iTable = pX->iIdxCur;
139859139491
pExpr->iColumn = pX->iIdxCol;
139860139492
pExpr->y.pTab = 0;
139861
- testcase( ExprHasProperty(pExpr, EP_Skip) );
139862
- testcase( ExprHasProperty(pExpr, EP_Unlikely) );
139863
- ExprClearProperty(pExpr, EP_Skip|EP_Unlikely);
139864139493
return WRC_Prune;
139865139494
}else{
139866139495
return WRC_Continue;
139867139496
}
139868139497
}
@@ -139873,12 +139502,10 @@
139873139502
*/
139874139503
static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){
139875139504
if( pExpr->op==TK_COLUMN ){
139876139505
IdxExprTrans *pX = p->u.pIdxTrans;
139877139506
if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){
139878
- assert( pExpr->y.pTab!=0 );
139879
- pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn);
139880139507
pExpr->iTable = pX->iIdxCur;
139881139508
pExpr->iColumn = pX->iIdxCol;
139882139509
pExpr->y.pTab = 0;
139883139510
}
139884139511
}
@@ -139920,24 +139547,13 @@
139920139547
for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
139921139548
i16 iRef = pIdx->aiColumn[iIdxCol];
139922139549
if( iRef==XN_EXPR ){
139923139550
assert( aColExpr->a[iIdxCol].pExpr!=0 );
139924139551
x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
139925
- if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue;
139926139552
w.xExprCallback = whereIndexExprTransNode;
139927139553
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
139928
- }else if( iRef>=0
139929
- && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0
139930
- && (pTab->aCol[iRef].zColl==0
139931
- || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0)
139932
- ){
139933
- /* Check to see if there are direct references to generated columns
139934
- ** that are contained in the index. Pulling the generated column
139935
- ** out of the index is an optimization only - the main table is always
139936
- ** available if the index cannot be used. To avoid unnecessary
139937
- ** complication, omit this optimization if the collating sequence for
139938
- ** the column is non-standard */
139554
+ }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){
139939139555
x.iTabCol = iRef;
139940139556
w.xExprCallback = whereIndexExprTransColumn;
139941139557
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139942139558
}else{
139943139559
continue;
@@ -140597,14 +140213,14 @@
140597140213
omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
140598140214
&& (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
140599140215
if( omitTable ){
140600140216
/* pIdx is a covering index. No need to access the main table. */
140601140217
}else if( HasRowid(pIdx->pTable) ){
140602
- if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)
140603
- || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0
140604
- && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) )
140605
- ){
140218
+ if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (
140219
+ (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)
140220
+ && (pWInfo->eOnePass==ONEPASS_SINGLE)
140221
+ )){
140606140222
iRowidReg = ++pParse->nMem;
140607140223
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);
140608140224
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);
140609140225
VdbeCoverage(v);
140610140226
}else{
@@ -142439,11 +142055,10 @@
142439142055
Expr *pNewExpr;
142440142056
pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
142441142057
0, sqlite3ExprDup(db, pRight, 0));
142442142058
if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
142443142059
ExprSetProperty(pNewExpr, EP_FromJoin);
142444
- pNewExpr->iRightJoinTable = pExpr->iRightJoinTable;
142445142060
}
142446142061
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
142447142062
testcase( idxNew==0 );
142448142063
pNewTerm = &pWC->a[idxNew];
142449142064
pNewTerm->prereqRight = prereqExpr;
@@ -142496,19 +142111,15 @@
142496142111
** a virtual term for each vector component. The expression object
142497142112
** used by each such virtual term is pExpr (the full vector IN(...)
142498142113
** expression). The WhereTerm.iField variable identifies the index within
142499142114
** the vector on the LHS that the virtual term represents.
142500142115
**
142501
- ** This only works if the RHS is a simple SELECT (not a compound) that does
142502
- ** not use window functions.
142116
+ ** This only works if the RHS is a simple SELECT, not a compound
142503142117
*/
142504142118
if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
142505142119
&& pExpr->pLeft->op==TK_VECTOR
142506142120
&& pExpr->x.pSelect->pPrior==0
142507
-#ifndef SQLITE_OMIT_WINDOWFUNC
142508
- && pExpr->x.pSelect->pWin==0
142509
-#endif
142510142121
){
142511142122
int i;
142512142123
for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
142513142124
int idxNew;
142514142125
idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
@@ -142662,14 +142273,13 @@
142662142273
mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
142663142274
}else if( p->x.pList ){
142664142275
mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
142665142276
}
142666142277
#ifndef SQLITE_OMIT_WINDOWFUNC
142667
- if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){
142278
+ if( p->op==TK_FUNCTION && p->y.pWin ){
142668142279
mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition);
142669142280
mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy);
142670
- mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter);
142671142281
}
142672142282
#endif
142673142283
return mask;
142674142284
}
142675142285
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
@@ -143553,12 +143163,11 @@
143553143163
if( (idxCols & cMask)==0 ){
143554143164
Expr *pX = pTerm->pExpr;
143555143165
idxCols |= cMask;
143556143166
pIdx->aiColumn[n] = pTerm->u.leftColumn;
143557143167
pColl = sqlite3ExprCompareCollSeq(pParse, pX);
143558
- assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
143559
- pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
143168
+ pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY;
143560143169
n++;
143561143170
}
143562143171
}
143563143172
}
143564143173
assert( (u32)n==pLoop->u.btree.nEq );
@@ -143732,17 +143341,22 @@
143732143341
testcase( pTerm->eOperator & WO_IS );
143733143342
testcase( pTerm->eOperator & WO_ISNULL );
143734143343
testcase( pTerm->eOperator & WO_ALL );
143735143344
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
143736143345
if( pTerm->wtFlags & TERM_VNULL ) continue;
143737
-
143738
- /* tag-20191211-002: WHERE-clause constraints are not useful to the
143739
- ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
143740
- ** equivalent restriction for ordinary tables. */
143741143346
if( (pSrc->fg.jointype & JT_LEFT)!=0
143742143347
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
143348
+ && (pTerm->eOperator & (WO_IS|WO_ISNULL))
143743143349
){
143350
+ /* An "IS" term in the WHERE clause where the virtual table is the rhs
143351
+ ** of a LEFT JOIN. Do not pass this term to the virtual table
143352
+ ** implementation, as this can lead to incorrect results from SQL such
143353
+ ** as:
143354
+ **
143355
+ ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */
143356
+ testcase( pTerm->eOperator & WO_ISNULL );
143357
+ testcase( pTerm->eOperator & WO_IS );
143744143358
continue;
143745143359
}
143746143360
assert( pTerm->u.leftColumn>=(-1) );
143747143361
pIdxCons[j].iColumn = pTerm->u.leftColumn;
143748143362
pIdxCons[j].iTermOffset = i;
@@ -143769,12 +143383,11 @@
143769143383
assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );
143770143384
143771143385
if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
143772143386
&& sqlite3ExprIsVector(pTerm->pExpr->pRight)
143773143387
){
143774
- testcase( j!=i );
143775
- if( j<16 ) mNoOmit |= (1 << j);
143388
+ if( i<16 ) mNoOmit |= (1 << i);
143776143389
if( op==WO_LT ) pIdxCons[j].op = WO_LE;
143777143390
if( op==WO_GT ) pIdxCons[j].op = WO_GE;
143778143391
}
143779143392
}
143780143393
@@ -144515,16 +144128,14 @@
144515144128
sqlite3DebugPrintf(
144516144129
"TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x",
144517144130
iTerm, pTerm, zType, zLeft, pTerm->truthProb,
144518144131
pTerm->eOperator, pTerm->wtFlags);
144519144132
if( pTerm->iField ){
144520
- sqlite3DebugPrintf(" iField=%d", pTerm->iField);
144133
+ sqlite3DebugPrintf(" iField=%d\n", pTerm->iField);
144134
+ }else{
144135
+ sqlite3DebugPrintf("\n");
144521144136
}
144522
- if( pTerm->iParent>=0 ){
144523
- sqlite3DebugPrintf(" iParent=%d", pTerm->iParent);
144524
- }
144525
- sqlite3DebugPrintf("\n");
144526144137
sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
144527144138
}
144528144139
}
144529144140
#endif
144530144141
@@ -144567,11 +144178,11 @@
144567144178
sqlite3DebugPrintf("%20s","");
144568144179
}
144569144180
}else{
144570144181
char *z;
144571144182
if( p->u.vtab.idxStr ){
144572
- z = sqlite3_mprintf("(%d,\"%s\",%#x)",
144183
+ z = sqlite3_mprintf("(%d,\"%s\",%x)",
144573144184
p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);
144574144185
}else{
144575144186
z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
144576144187
}
144577144188
sqlite3DebugPrintf(" %-19s", z);
@@ -145222,13 +144833,13 @@
145222144833
145223144834
/* Do not allow the upper bound of a LIKE optimization range constraint
145224144835
** to mix with a lower range bound from some other source */
145225144836
if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
145226144837
145227
- /* tag-20191211-001: Do not allow constraints from the WHERE clause to
145228
- ** be used by the right table of a LEFT JOIN. Only constraints in the
145229
- ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */
144838
+ /* Do not allow constraints from the WHERE clause to be used by the
144839
+ ** right table of a LEFT JOIN. Only constraints in the ON clause are
144840
+ ** allowed */
145230144841
if( (pSrc->fg.jointype & JT_LEFT)!=0
145231144842
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
145232144843
){
145233144844
continue;
145234144845
}
@@ -145541,29 +145152,23 @@
145541145152
}
145542145153
145543145154
/* Check to see if a partial index with pPartIndexWhere can be used
145544145155
** in the current query. Return true if it can be and false if not.
145545145156
*/
145546
-static int whereUsablePartialIndex(
145547
- int iTab, /* The table for which we want an index */
145548
- int isLeft, /* True if iTab is the right table of a LEFT JOIN */
145549
- WhereClause *pWC, /* The WHERE clause of the query */
145550
- Expr *pWhere /* The WHERE clause from the partial index */
145551
-){
145157
+static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
145552145158
int i;
145553145159
WhereTerm *pTerm;
145554145160
Parse *pParse = pWC->pWInfo->pParse;
145555145161
while( pWhere->op==TK_AND ){
145556
- if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0;
145162
+ if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
145557145163
pWhere = pWhere->pRight;
145558145164
}
145559145165
if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
145560145166
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
145561145167
Expr *pExpr;
145562145168
pExpr = pTerm->pExpr;
145563145169
if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
145564
- && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
145565145170
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
145566145171
){
145567145172
return 1;
145568145173
}
145569145174
}
@@ -145722,15 +145327,12 @@
145722145327
/* Loop over all indices. If there was an INDEXED BY clause, then only
145723145328
** consider index pProbe. */
145724145329
for(; rc==SQLITE_OK && pProbe;
145725145330
pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++
145726145331
){
145727
- int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0;
145728145332
if( pProbe->pPartIdxWhere!=0
145729
- && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC,
145730
- pProbe->pPartIdxWhere)
145731
- ){
145333
+ && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
145732145334
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
145733145335
continue; /* Partial index inappropriate for this query */
145734145336
}
145735145337
if( pProbe->bNoQuery ) continue;
145736145338
rSize = pProbe->aiRowLogEst[0];
@@ -145953,18 +145555,11 @@
145953145555
assert( iTerm<pNew->nLSlot );
145954145556
pNew->aLTerm[iTerm] = pTerm;
145955145557
if( iTerm>mxTerm ) mxTerm = iTerm;
145956145558
testcase( iTerm==15 );
145957145559
testcase( iTerm==16 );
145958
- if( pUsage[i].omit ){
145959
- if( i<16 && ((1<<i)&mNoOmit)==0 ){
145960
- testcase( i!=iTerm );
145961
- pNew->u.vtab.omitMask |= 1<<iTerm;
145962
- }else{
145963
- testcase( i!=iTerm );
145964
- }
145965
- }
145560
+ if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm;
145966145561
if( (pTerm->eOperator & WO_IN)!=0 ){
145967145562
/* A virtual table that is constrained by an IN clause may not
145968145563
** consume the ORDER BY clause because (1) the order of IN terms
145969145564
** is not necessarily related to the order of output terms and
145970145565
** (2) Multiple outputs from a single IN value will not merge
@@ -145973,10 +145568,11 @@
145973145568
pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
145974145569
*pbIn = 1; assert( (mExclude & WO_IN)==0 );
145975145570
}
145976145571
}
145977145572
}
145573
+ pNew->u.vtab.omitMask &= ~mNoOmit;
145978145574
145979145575
pNew->nLTerm = mxTerm+1;
145980145576
for(i=0; i<=mxTerm; i++){
145981145577
if( pNew->aLTerm[i]==0 ){
145982145578
/* The non-zero argvIdx values must be contiguous. Raise an
@@ -147567,11 +147163,10 @@
147567147163
sSelect.pEList = pResultSet;
147568147164
sqlite3TreeViewSelect(0, &sSelect, 0);
147569147165
}
147570147166
}
147571147167
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
147572
- sqlite3DebugPrintf("---- WHERE clause at start of analysis:\n");
147573147168
sqlite3WhereClausePrint(sWLB.pWC);
147574147169
}
147575147170
#endif
147576147171
147577147172
if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
@@ -147706,17 +147301,11 @@
147706147301
}
147707147302
pWInfo->nLevel--;
147708147303
nTabList--;
147709147304
}
147710147305
}
147711
-#if defined(WHERETRACE_ENABLED)
147712
- if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
147713
- sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
147714
- sqlite3WhereClausePrint(sWLB.pWC);
147715
- }
147716147306
WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));
147717
-#endif
147718147307
pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;
147719147308
147720147309
/* If the caller is an UPDATE or DELETE statement that is requesting
147721147310
** to use a one-pass algorithm, determine if this is appropriate.
147722147311
**
@@ -148982,37 +148571,25 @@
148982148571
}
148983148572
/* Fall through. */
148984148573
148985148574
case TK_AGG_FUNCTION:
148986148575
case TK_COLUMN: {
148987
- int iCol = -1;
148988
- if( p->pSub ){
148989
- int i;
148990
- for(i=0; i<p->pSub->nExpr; i++){
148991
- if( 0==sqlite3ExprCompare(0, p->pSub->a[i].pExpr, pExpr, -1) ){
148992
- iCol = i;
148993
- break;
148994
- }
148995
- }
148996
- }
148997
- if( iCol<0 ){
148998
- Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
148999
- p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
149000
- }
148576
+ Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
148577
+ p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
149001148578
if( p->pSub ){
149002148579
assert( ExprHasProperty(pExpr, EP_Static)==0 );
149003148580
ExprSetProperty(pExpr, EP_Static);
149004148581
sqlite3ExprDelete(pParse->db, pExpr);
149005148582
ExprClearProperty(pExpr, EP_Static);
149006148583
memset(pExpr, 0, sizeof(Expr));
149007148584
149008148585
pExpr->op = TK_COLUMN;
149009
- pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol);
148586
+ pExpr->iColumn = p->pSub->nExpr-1;
149010148587
pExpr->iTable = p->pWin->iEphCsr;
149011148588
pExpr->y.pTab = p->pTab;
149012148589
}
149013
- if( pParse->db->mallocFailed ) return WRC_Abort;
148590
+
149014148591
break;
149015148592
}
149016148593
149017148594
default: /* no-op */
149018148595
break;
@@ -149090,15 +148667,13 @@
149090148667
if( pAppend ){
149091148668
int i;
149092148669
int nInit = pList ? pList->nExpr : 0;
149093148670
for(i=0; i<pAppend->nExpr; i++){
149094148671
Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
149095
- assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
149096148672
if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
149097148673
pDup->op = TK_NULL;
149098148674
pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
149099
- pDup->u.zToken = 0;
149100148675
}
149101148676
pList = sqlite3ExprListAppend(pParse, pList, pDup);
149102148677
if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
149103148678
}
149104148679
}
@@ -149129,11 +148704,11 @@
149129148704
Window *pWin; /* Window object iterator */
149130148705
Table *pTab;
149131148706
149132148707
pTab = sqlite3DbMallocZero(db, sizeof(Table));
149133148708
if( pTab==0 ){
149134
- return sqlite3ErrorToParser(db, SQLITE_NOMEM);
148709
+ return SQLITE_NOMEM;
149135148710
}
149136148711
149137148712
p->pSrc = 0;
149138148713
p->pWhere = 0;
149139148714
p->pGroupBy = 0;
@@ -149216,13 +148791,10 @@
149216148791
p->pSrc->a[0].pSelect = pSub;
149217148792
sqlite3SrcListAssignCursors(pParse, p->pSrc);
149218148793
pSub->selFlags |= SF_Expanded;
149219148794
pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
149220148795
if( pTab2==0 ){
149221
- /* Might actually be some other kind of error, but in that case
149222
- ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get
149223
- ** the correct error message regardless. */
149224148796
rc = SQLITE_NOMEM;
149225148797
}else{
149226148798
memcpy(pTab, pTab2, sizeof(Table));
149227148799
pTab->tabFlags |= TF_Ephemeral;
149228148800
p->pSrc->a[0].pTab = pTab;
@@ -149237,17 +148809,10 @@
149237148809
}
149238148810
if( db->mallocFailed ) rc = SQLITE_NOMEM;
149239148811
sqlite3DbFree(db, pTab);
149240148812
}
149241148813
149242
- if( rc ){
149243
- if( pParse->nErr==0 ){
149244
- assert( pParse->db->mallocFailed );
149245
- sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM);
149246
- }
149247
- sqlite3SelectReset(pParse, p);
149248
- }
149249148814
return rc;
149250148815
}
149251148816
149252148817
/*
149253148818
** Unlink the Window object from the Select to which it is attached,
@@ -149480,11 +149045,10 @@
149480149045
/*
149481149046
** Return 0 if the two window objects are identical, or non-zero otherwise.
149482149047
** Identical window objects can be processed in a single scan.
149483149048
*/
149484149049
SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
149485
- if( NEVER(p1==0) || NEVER(p2==0) ) return 1;
149486149050
if( p1->eFrmType!=p2->eFrmType ) return 1;
149487149051
if( p1->eStart!=p2->eStart ) return 1;
149488149052
if( p1->eEnd!=p2->eEnd ) return 1;
149489149053
if( p1->eExclude!=p2->eExclude ) return 1;
149490149054
if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
@@ -151469,22 +151033,21 @@
151469151033
#define sqlite3ParserCTX_PDECL ,Parse *pParse
151470151034
#define sqlite3ParserCTX_PARAM ,pParse
151471151035
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
151472151036
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
151473151037
#define YYFALLBACK 1
151474
-#define YYNSTATE 551
151038
+#define YYNSTATE 550
151475151039
#define YYNRULE 385
151476
-#define YYNRULE_WITH_ACTION 325
151477151040
#define YYNTOKEN 181
151478
-#define YY_MAX_SHIFT 550
151479
-#define YY_MIN_SHIFTREDUCE 801
151480
-#define YY_MAX_SHIFTREDUCE 1185
151481
-#define YY_ERROR_ACTION 1186
151482
-#define YY_ACCEPT_ACTION 1187
151483
-#define YY_NO_ACTION 1188
151484
-#define YY_MIN_REDUCE 1189
151485
-#define YY_MAX_REDUCE 1573
151041
+#define YY_MAX_SHIFT 549
151042
+#define YY_MIN_SHIFTREDUCE 800
151043
+#define YY_MAX_SHIFTREDUCE 1184
151044
+#define YY_ERROR_ACTION 1185
151045
+#define YY_ACCEPT_ACTION 1186
151046
+#define YY_NO_ACTION 1187
151047
+#define YY_MIN_REDUCE 1188
151048
+#define YY_MAX_REDUCE 1572
151486151049
/************* End control #defines *******************************************/
151487151050
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
151488151051
151489151052
/* Define the yytestcase() macro to be a no-op if is not already defined
151490151053
** otherwise.
@@ -151549,206 +151112,206 @@
151549151112
** yy_default[] Default action for each state.
151550151113
**
151551151114
*********** Begin parsing tables **********************************************/
151552151115
#define YY_ACTTAB_COUNT (1958)
151553151116
static const YYACTIONTYPE yy_action[] = {
151554
- /* 0 */ 544, 1220, 544, 449, 1258, 544, 1237, 544, 114, 111,
151555
- /* 10 */ 211, 544, 1535, 544, 1258, 521, 114, 111, 211, 390,
151556
- /* 20 */ 1230, 342, 42, 42, 42, 42, 1223, 42, 42, 71,
151557
- /* 30 */ 71, 935, 1222, 71, 71, 71, 71, 1460, 1491, 936,
151558
- /* 40 */ 818, 451, 6, 121, 122, 112, 1163, 1163, 1004, 1007,
151559
- /* 50 */ 997, 997, 119, 119, 120, 120, 120, 120, 1541, 390,
151560
- /* 60 */ 1356, 1515, 550, 2, 1191, 194, 526, 434, 143, 291,
151561
- /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1271, 525,
151562
- /* 80 */ 501, 491, 164, 121, 122, 112, 1163, 1163, 1004, 1007,
151563
- /* 90 */ 997, 997, 119, 119, 120, 120, 120, 120, 1356, 440,
151564
- /* 100 */ 1512, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151565
- /* 110 */ 115, 422, 266, 266, 266, 266, 1496, 356, 1498, 433,
151566
- /* 120 */ 355, 1496, 515, 522, 1483, 541, 1112, 541, 1112, 390,
151117
+ /* 0 */ 544, 1219, 544, 449, 1257, 544, 1236, 544, 114, 111,
151118
+ /* 10 */ 211, 544, 1534, 544, 1257, 521, 114, 111, 211, 390,
151119
+ /* 20 */ 1229, 342, 42, 42, 42, 42, 1222, 42, 42, 71,
151120
+ /* 30 */ 71, 934, 1221, 71, 71, 71, 71, 1459, 1490, 935,
151121
+ /* 40 */ 817, 451, 6, 121, 122, 112, 1162, 1162, 1003, 1006,
151122
+ /* 50 */ 996, 996, 119, 119, 120, 120, 120, 120, 1540, 390,
151123
+ /* 60 */ 1355, 1514, 549, 2, 1190, 194, 526, 434, 143, 291,
151124
+ /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1270, 525,
151125
+ /* 80 */ 501, 491, 164, 121, 122, 112, 1162, 1162, 1003, 1006,
151126
+ /* 90 */ 996, 996, 119, 119, 120, 120, 120, 120, 1355, 440,
151127
+ /* 100 */ 1511, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151128
+ /* 110 */ 115, 422, 266, 266, 266, 266, 1495, 356, 1497, 433,
151129
+ /* 120 */ 355, 1495, 515, 522, 1482, 541, 1111, 541, 1111, 390,
151567151130
/* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221,
151568
- /* 140 */ 1027, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151569
- /* 150 */ 115, 422, 1140, 121, 122, 112, 1163, 1163, 1004, 1007,
151570
- /* 160 */ 997, 997, 119, 119, 120, 120, 120, 120, 404, 426,
151571
- /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1416, 466, 123,
151131
+ /* 140 */ 1026, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151132
+ /* 150 */ 115, 422, 1139, 121, 122, 112, 1162, 1162, 1003, 1006,
151133
+ /* 160 */ 996, 996, 119, 119, 120, 120, 120, 120, 404, 426,
151134
+ /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1415, 466, 123,
151572151135
/* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151573151136
/* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390,
151574
- /* 200 */ 503, 120, 120, 120, 120, 113, 1049, 1140, 1141, 1142,
151575
- /* 210 */ 1049, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151576
- /* 220 */ 115, 422, 1459, 121, 122, 112, 1163, 1163, 1004, 1007,
151577
- /* 230 */ 997, 997, 119, 119, 120, 120, 120, 120, 390, 442,
151578
- /* 240 */ 314, 83, 461, 81, 357, 380, 1140, 80, 118, 118,
151137
+ /* 200 */ 503, 120, 120, 120, 120, 113, 1048, 1139, 1140, 1141,
151138
+ /* 210 */ 1048, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151139
+ /* 220 */ 115, 422, 1458, 121, 122, 112, 1162, 1162, 1003, 1006,
151140
+ /* 230 */ 996, 996, 119, 119, 120, 120, 120, 120, 390, 442,
151141
+ /* 240 */ 314, 83, 461, 81, 357, 380, 1139, 80, 118, 118,
151579151142
/* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179,
151580
- /* 260 */ 432, 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997,
151581
- /* 270 */ 997, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151143
+ /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996,
151144
+ /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151582151145
/* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151583
- /* 290 */ 115, 422, 541, 1107, 901, 504, 1140, 114, 111, 211,
151584
- /* 300 */ 1429, 1140, 1141, 1142, 206, 489, 1107, 390, 447, 1107,
151585
- /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1429, 1431, 17,
151146
+ /* 290 */ 115, 422, 541, 1106, 900, 504, 1139, 114, 111, 211,
151147
+ /* 300 */ 1428, 1139, 1140, 1141, 206, 489, 1106, 390, 447, 1106,
151148
+ /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1428, 1430, 17,
151586151149
/* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151587
- /* 330 */ 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997,
151588
- /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1356, 432, 1140,
151589
- /* 350 */ 480, 1140, 1141, 1142, 994, 994, 1005, 1008, 443, 118,
151150
+ /* 330 */ 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996,
151151
+ /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1355, 432, 1139,
151152
+ /* 350 */ 480, 1139, 1140, 1141, 993, 993, 1004, 1007, 443, 118,
151590151153
/* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151591
- /* 370 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151592
- /* 380 */ 119, 120, 120, 120, 120, 1052, 1052, 463, 1429, 118,
151154
+ /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151155
+ /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118,
151593151156
/* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151594
- /* 400 */ 1140, 449, 544, 1424, 1140, 1141, 1142, 233, 964, 1140,
151595
- /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 840,
151596
- /* 420 */ 474, 164, 185, 332, 71, 71, 1241, 998, 118, 118,
151157
+ /* 400 */ 1139, 449, 544, 1423, 1139, 1140, 1141, 233, 963, 1139,
151158
+ /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 839,
151159
+ /* 420 */ 474, 164, 185, 332, 71, 71, 1240, 997, 118, 118,
151597151160
/* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121,
151598
- /* 440 */ 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119,
151599
- /* 450 */ 120, 120, 120, 120, 390, 1140, 1141, 1142, 833, 12,
151600
- /* 460 */ 313, 507, 163, 354, 1140, 1141, 1142, 114, 111, 211,
151161
+ /* 440 */ 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119,
151162
+ /* 450 */ 120, 120, 120, 120, 390, 1139, 1140, 1141, 832, 12,
151163
+ /* 460 */ 313, 507, 163, 354, 1139, 1140, 1141, 114, 111, 211,
151601151164
/* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122,
151602
- /* 480 */ 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120,
151165
+ /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120,
151603151166
/* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118,
151604
- /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1140, 209,
151605
- /* 510 */ 409, 521, 1140, 1107, 1569, 376, 252, 269, 340, 485,
151606
- /* 520 */ 335, 484, 238, 390, 511, 362, 1107, 1125, 331, 1107,
151167
+ /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1139, 209,
151168
+ /* 510 */ 409, 521, 1139, 1106, 1568, 376, 252, 269, 340, 485,
151169
+ /* 520 */ 335, 484, 238, 390, 511, 362, 1106, 1124, 331, 1106,
151607151170
/* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118,
151608151171
/* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112,
151609
- /* 550 */ 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, 120,
151610
- /* 560 */ 120, 120, 390, 1140, 1141, 1142, 985, 1140, 1141, 1142,
151611
- /* 570 */ 1140, 233, 490, 1490, 479, 476, 475, 6, 163, 544,
151612
- /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1163,
151613
- /* 590 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120,
151172
+ /* 550 */ 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, 120,
151173
+ /* 560 */ 120, 120, 390, 1139, 1140, 1141, 984, 1139, 1140, 1141,
151174
+ /* 570 */ 1139, 233, 490, 1489, 479, 476, 475, 6, 163, 544,
151175
+ /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1162,
151176
+ /* 590 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151614151177
/* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117,
151615151178
/* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544,
151616
- /* 620 */ 1484, 542, 1140, 890, 890, 1140, 1141, 1142, 1471, 1140,
151617
- /* 630 */ 275, 390, 806, 807, 808, 969, 420, 420, 420, 16,
151618
- /* 640 */ 16, 55, 55, 1240, 118, 118, 118, 118, 117, 117,
151619
- /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1163, 1163,
151620
- /* 660 */ 1004, 1007, 997, 997, 119, 119, 120, 120, 120, 120,
151621
- /* 670 */ 390, 1187, 1, 1, 550, 2, 1191, 1140, 1141, 1142,
151622
- /* 680 */ 194, 291, 896, 136, 1140, 1141, 1142, 895, 519, 1490,
151623
- /* 690 */ 1271, 3, 378, 6, 121, 122, 112, 1163, 1163, 1004,
151624
- /* 700 */ 1007, 997, 997, 119, 119, 120, 120, 120, 120, 856,
151625
- /* 710 */ 544, 922, 544, 118, 118, 118, 118, 117, 117, 116,
151626
- /* 720 */ 116, 116, 115, 422, 266, 266, 1090, 1567, 1140, 549,
151627
- /* 730 */ 1567, 1191, 13, 13, 13, 13, 291, 541, 136, 390,
151628
- /* 740 */ 483, 419, 418, 964, 342, 1271, 466, 408, 857, 279,
151179
+ /* 620 */ 1483, 542, 1139, 889, 889, 1139, 1140, 1141, 1470, 1139,
151180
+ /* 630 */ 275, 390, 805, 806, 807, 968, 420, 420, 420, 16,
151181
+ /* 640 */ 16, 55, 55, 1239, 118, 118, 118, 118, 117, 117,
151182
+ /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1162, 1162,
151183
+ /* 660 */ 1003, 1006, 996, 996, 119, 119, 120, 120, 120, 120,
151184
+ /* 670 */ 390, 1186, 1, 1, 549, 2, 1190, 1139, 1140, 1141,
151185
+ /* 680 */ 194, 291, 895, 136, 1139, 1140, 1141, 894, 519, 1489,
151186
+ /* 690 */ 1270, 3, 378, 6, 121, 122, 112, 1162, 1162, 1003,
151187
+ /* 700 */ 1006, 996, 996, 119, 119, 120, 120, 120, 120, 855,
151188
+ /* 710 */ 544, 921, 544, 118, 118, 118, 118, 117, 117, 116,
151189
+ /* 720 */ 116, 116, 115, 422, 266, 266, 1089, 1566, 1139, 1518,
151190
+ /* 730 */ 1566, 1190, 13, 13, 13, 13, 291, 541, 136, 390,
151191
+ /* 740 */ 483, 419, 418, 963, 342, 1270, 466, 408, 856, 279,
151629151192
/* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116,
151630
- /* 760 */ 116, 115, 422, 121, 122, 112, 1163, 1163, 1004, 1007,
151631
- /* 770 */ 997, 997, 119, 119, 120, 120, 120, 120, 544, 266,
151632
- /* 780 */ 266, 426, 390, 1140, 1141, 1142, 1170, 828, 1170, 466,
151633
- /* 790 */ 429, 145, 541, 1144, 399, 313, 437, 301, 836, 1488,
151634
- /* 800 */ 71, 71, 410, 6, 1088, 471, 221, 100, 112, 1163,
151635
- /* 810 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120,
151193
+ /* 760 */ 116, 115, 422, 121, 122, 112, 1162, 1162, 1003, 1006,
151194
+ /* 770 */ 996, 996, 119, 119, 120, 120, 120, 120, 544, 266,
151195
+ /* 780 */ 266, 426, 390, 1139, 1140, 1141, 1169, 827, 1169, 466,
151196
+ /* 790 */ 429, 145, 541, 1143, 399, 313, 437, 301, 835, 1487,
151197
+ /* 800 */ 71, 71, 410, 6, 1087, 471, 221, 100, 112, 1162,
151198
+ /* 810 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151636151199
/* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151637
- /* 830 */ 115, 422, 237, 1423, 544, 449, 426, 287, 984, 544,
151638
- /* 840 */ 236, 235, 234, 828, 97, 527, 427, 1263, 1263, 1144,
151639
- /* 850 */ 492, 306, 428, 836, 975, 544, 71, 71, 974, 1239,
151200
+ /* 830 */ 115, 422, 237, 1422, 544, 449, 426, 287, 983, 544,
151201
+ /* 840 */ 236, 235, 234, 827, 97, 527, 427, 1262, 1262, 1143,
151202
+ /* 850 */ 492, 306, 428, 835, 974, 544, 71, 71, 973, 1238,
151640151203
/* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117,
151641151204
/* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266,
151642
- /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 974,
151643
- /* 890 */ 974, 976, 541, 526, 1107, 326, 390, 541, 493, 395,
151644
- /* 900 */ 1468, 195, 528, 13, 13, 1356, 240, 1107, 277, 280,
151645
- /* 910 */ 1107, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151646
- /* 920 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151647
- /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 984,
151648
- /* 940 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151649
- /* 950 */ 119, 120, 120, 120, 120, 975, 321, 1140, 324, 974,
151650
- /* 960 */ 121, 110, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151651
- /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1183, 118, 118,
151652
- /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1140,
151653
- /* 990 */ 974, 974, 976, 304, 9, 364, 244, 360, 118, 118,
151205
+ /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 973,
151206
+ /* 890 */ 973, 975, 541, 526, 1106, 326, 390, 541, 493, 395,
151207
+ /* 900 */ 1467, 195, 528, 13, 13, 1355, 240, 1106, 277, 280,
151208
+ /* 910 */ 1106, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151209
+ /* 920 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151210
+ /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 983,
151211
+ /* 940 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151212
+ /* 950 */ 119, 120, 120, 120, 120, 974, 321, 1139, 324, 973,
151213
+ /* 960 */ 121, 110, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151214
+ /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1182, 118, 118,
151215
+ /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1139,
151216
+ /* 990 */ 973, 973, 975, 304, 9, 364, 244, 360, 118, 118,
151654151217
/* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312,
151655
- /* 1010 */ 544, 342, 1140, 1141, 1142, 299, 290, 535, 118, 118,
151656
- /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1261,
151657
- /* 1030 */ 1261, 1161, 13, 13, 278, 419, 418, 466, 390, 921,
151658
- /* 1040 */ 260, 260, 289, 1167, 1140, 1141, 1142, 189, 1169, 266,
151659
- /* 1050 */ 266, 466, 388, 541, 1184, 544, 1168, 263, 144, 487,
151660
- /* 1060 */ 920, 544, 541, 122, 112, 1163, 1163, 1004, 1007, 997,
151661
- /* 1070 */ 997, 119, 119, 120, 120, 120, 120, 71, 71, 1140,
151662
- /* 1080 */ 1170, 1270, 1170, 13, 13, 896, 1068, 1161, 544, 466,
151663
- /* 1090 */ 895, 107, 536, 1489, 4, 1266, 1107, 6, 523, 1047,
151664
- /* 1100 */ 12, 1069, 1090, 1568, 311, 453, 1568, 518, 539, 1107,
151665
- /* 1110 */ 56, 56, 1107, 1487, 421, 1356, 1070, 6, 343, 285,
151218
+ /* 1010 */ 544, 342, 1139, 1140, 1141, 299, 290, 535, 118, 118,
151219
+ /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1260,
151220
+ /* 1030 */ 1260, 1160, 13, 13, 278, 419, 418, 466, 390, 920,
151221
+ /* 1040 */ 260, 260, 289, 1166, 1139, 1140, 1141, 189, 1168, 266,
151222
+ /* 1050 */ 266, 466, 388, 541, 1183, 544, 1167, 263, 144, 487,
151223
+ /* 1060 */ 919, 544, 541, 122, 112, 1162, 1162, 1003, 1006, 996,
151224
+ /* 1070 */ 996, 119, 119, 120, 120, 120, 120, 71, 71, 1139,
151225
+ /* 1080 */ 1169, 1269, 1169, 13, 13, 895, 1067, 1160, 544, 466,
151226
+ /* 1090 */ 894, 107, 536, 1488, 4, 1265, 1106, 6, 523, 1046,
151227
+ /* 1100 */ 12, 1068, 1089, 1567, 311, 453, 1567, 518, 539, 1106,
151228
+ /* 1110 */ 56, 56, 1106, 1486, 421, 1355, 1069, 6, 343, 285,
151666151229
/* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151667
- /* 1130 */ 422, 423, 1269, 319, 1140, 1141, 1142, 876, 266, 266,
151668
- /* 1140 */ 1275, 107, 536, 533, 4, 1486, 293, 877, 1209, 6,
151669
- /* 1150 */ 210, 541, 541, 164, 1540, 494, 414, 865, 539, 267,
151670
- /* 1160 */ 267, 1212, 396, 509, 497, 204, 266, 266, 394, 529,
151671
- /* 1170 */ 8, 984, 541, 517, 544, 920, 456, 105, 105, 541,
151672
- /* 1180 */ 1088, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151673
- /* 1190 */ 266, 974, 516, 533, 1371, 541, 15, 15, 266, 266,
151674
- /* 1200 */ 454, 1118, 541, 266, 266, 1068, 1370, 513, 290, 535,
151675
- /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 920, 125,
151676
- /* 1220 */ 1069, 984, 974, 974, 976, 977, 27, 105, 105, 399,
151677
- /* 1230 */ 341, 1509, 44, 44, 106, 1070, 423, 546, 545, 57,
151678
- /* 1240 */ 57, 974, 341, 1509, 107, 536, 544, 4, 460, 399,
151679
- /* 1250 */ 214, 1118, 457, 294, 375, 1089, 532, 297, 544, 537,
151230
+ /* 1130 */ 422, 423, 1268, 319, 1139, 1140, 1141, 875, 266, 266,
151231
+ /* 1140 */ 1274, 107, 536, 533, 4, 1485, 293, 876, 1208, 6,
151232
+ /* 1150 */ 210, 541, 541, 164, 1539, 494, 414, 864, 539, 267,
151233
+ /* 1160 */ 267, 1211, 396, 509, 497, 204, 266, 266, 394, 529,
151234
+ /* 1170 */ 8, 983, 541, 517, 544, 919, 456, 105, 105, 541,
151235
+ /* 1180 */ 1087, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151236
+ /* 1190 */ 266, 973, 516, 533, 1370, 541, 15, 15, 266, 266,
151237
+ /* 1200 */ 454, 1117, 541, 266, 266, 1067, 1369, 513, 290, 535,
151238
+ /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 919, 125,
151239
+ /* 1220 */ 1068, 983, 973, 973, 975, 976, 27, 105, 105, 399,
151240
+ /* 1230 */ 341, 1508, 44, 44, 106, 1069, 423, 546, 545, 57,
151241
+ /* 1240 */ 57, 973, 341, 1508, 107, 536, 544, 4, 460, 399,
151242
+ /* 1250 */ 214, 1117, 457, 294, 375, 1088, 532, 297, 544, 537,
151680151243
/* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58,
151681
- /* 1270 */ 544, 109, 974, 974, 976, 977, 27, 1514, 1129, 425,
151244
+ /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425,
151682151245
/* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372,
151683
- /* 1290 */ 255, 370, 60, 60, 815, 1178, 533, 544, 273, 544,
151684
- /* 1300 */ 1161, 843, 387, 386, 544, 1307, 544, 215, 210, 296,
151685
- /* 1310 */ 513, 847, 544, 265, 208, 514, 1306, 295, 274, 61,
151686
- /* 1320 */ 61, 62, 62, 436, 984, 1160, 45, 45, 46, 46,
151687
- /* 1330 */ 105, 105, 1184, 920, 47, 47, 1474, 106, 544, 423,
151688
- /* 1340 */ 546, 545, 218, 544, 974, 935, 1085, 217, 544, 377,
151689
- /* 1350 */ 395, 107, 536, 936, 4, 156, 1161, 843, 158, 544,
151246
+ /* 1290 */ 255, 370, 60, 60, 814, 1177, 533, 544, 273, 544,
151247
+ /* 1300 */ 1160, 842, 387, 386, 544, 1306, 544, 215, 210, 296,
151248
+ /* 1310 */ 513, 846, 544, 265, 208, 514, 1305, 295, 274, 61,
151249
+ /* 1320 */ 61, 62, 62, 436, 983, 1159, 45, 45, 46, 46,
151250
+ /* 1330 */ 105, 105, 1183, 919, 47, 47, 1473, 106, 544, 423,
151251
+ /* 1340 */ 546, 545, 218, 544, 973, 934, 1084, 217, 544, 377,
151252
+ /* 1350 */ 395, 107, 536, 935, 4, 156, 1160, 842, 158, 544,
151690151253
/* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307,
151691
- /* 1370 */ 63, 63, 544, 1448, 216, 974, 974, 976, 977, 27,
151692
- /* 1380 */ 444, 64, 64, 544, 1447, 65, 65, 544, 524, 14,
151254
+ /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27,
151255
+ /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14,
151693151256
/* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97,
151694
- /* 1400 */ 1034, 544, 961, 533, 268, 127, 127, 544, 391, 67,
151695
- /* 1410 */ 67, 544, 978, 290, 535, 52, 52, 513, 544, 68,
151696
- /* 1420 */ 68, 1294, 512, 69, 69, 397, 165, 855, 854, 53,
151697
- /* 1430 */ 53, 984, 966, 151, 151, 243, 430, 105, 105, 199,
151698
- /* 1440 */ 152, 152, 448, 1303, 106, 243, 423, 546, 545, 1129,
151699
- /* 1450 */ 425, 974, 320, 270, 862, 863, 1034, 220, 373, 373,
151700
- /* 1460 */ 372, 255, 370, 450, 323, 815, 243, 544, 978, 544,
151701
- /* 1470 */ 107, 536, 544, 4, 544, 938, 939, 325, 215, 1046,
151702
- /* 1480 */ 296, 1046, 974, 974, 976, 977, 27, 539, 295, 76,
151703
- /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1503, 1254,
151704
- /* 1500 */ 107, 536, 544, 4, 1045, 544, 1045, 531, 1238, 544,
151257
+ /* 1400 */ 1033, 544, 960, 533, 268, 127, 127, 544, 391, 67,
151258
+ /* 1410 */ 67, 544, 977, 290, 535, 52, 52, 513, 544, 68,
151259
+ /* 1420 */ 68, 1293, 512, 69, 69, 397, 165, 854, 853, 53,
151260
+ /* 1430 */ 53, 983, 965, 151, 151, 243, 430, 105, 105, 199,
151261
+ /* 1440 */ 152, 152, 448, 1302, 106, 243, 423, 546, 545, 1128,
151262
+ /* 1450 */ 425, 973, 320, 270, 861, 862, 1033, 220, 373, 373,
151263
+ /* 1460 */ 372, 255, 370, 450, 323, 814, 243, 544, 977, 544,
151264
+ /* 1470 */ 107, 536, 544, 4, 544, 937, 938, 325, 215, 1045,
151265
+ /* 1480 */ 296, 1045, 973, 973, 975, 976, 27, 539, 295, 76,
151266
+ /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1502, 1253,
151267
+ /* 1500 */ 107, 536, 544, 4, 1044, 544, 1044, 531, 1237, 544,
151705151268
/* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544,
151706
- /* 1520 */ 472, 1528, 533, 239, 73, 73, 156, 129, 129, 158,
151269
+ /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158,
151707151270
/* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149,
151708
- /* 1540 */ 423, 134, 134, 329, 1030, 216, 97, 239, 929, 345,
151709
- /* 1550 */ 984, 243, 533, 1315, 339, 544, 105, 105, 900, 1355,
151710
- /* 1560 */ 544, 1290, 258, 106, 338, 423, 546, 545, 544, 1301,
151711
- /* 1570 */ 974, 893, 99, 536, 109, 4, 544, 133, 133, 391,
151712
- /* 1580 */ 984, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151713
- /* 1590 */ 132, 132, 1361, 106, 1219, 423, 546, 545, 75, 75,
151714
- /* 1600 */ 974, 974, 974, 976, 977, 27, 544, 430, 826, 1211,
151715
- /* 1610 */ 894, 139, 423, 109, 544, 1200, 1199, 1201, 1522, 544,
151716
- /* 1620 */ 201, 544, 11, 374, 533, 1287, 347, 349, 77, 77,
151717
- /* 1630 */ 1340, 974, 974, 976, 977, 27, 74, 74, 351, 213,
151718
- /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1348, 382,
151719
- /* 1650 */ 353, 452, 984, 337, 1237, 1420, 1419, 205, 105, 105,
151720
- /* 1660 */ 192, 367, 193, 534, 1525, 106, 1178, 423, 546, 545,
151721
- /* 1670 */ 247, 167, 974, 270, 1467, 200, 1465, 1175, 373, 373,
151722
- /* 1680 */ 372, 255, 370, 398, 79, 815, 83, 82, 1425, 446,
151723
- /* 1690 */ 161, 177, 169, 95, 1337, 438, 172, 173, 215, 174,
151724
- /* 1700 */ 296, 175, 35, 974, 974, 976, 977, 27, 295, 1345,
151725
- /* 1710 */ 439, 470, 223, 36, 379, 445, 1414, 381, 459, 1351,
151726
- /* 1720 */ 181, 227, 88, 465, 259, 229, 1436, 318, 186, 468,
151727
- /* 1730 */ 322, 230, 384, 1202, 231, 486, 1257, 1256, 217, 411,
151728
- /* 1740 */ 1255, 1248, 90, 847, 206, 413, 156, 505, 1539, 158,
151729
- /* 1750 */ 1226, 1538, 283, 1508, 1227, 336, 385, 284, 1225, 496,
151730
- /* 1760 */ 1537, 1298, 94, 346, 348, 216, 1247, 499, 1299, 245,
151731
- /* 1770 */ 246, 1297, 416, 350, 1494, 124, 1493, 10, 524, 361,
151732
- /* 1780 */ 1400, 101, 96, 288, 508, 253, 1135, 1208, 34, 1296,
151733
- /* 1790 */ 547, 254, 256, 257, 392, 548, 1197, 1192, 359, 391,
151734
- /* 1800 */ 1280, 1279, 196, 365, 290, 535, 366, 352, 1452, 1322,
151735
- /* 1810 */ 1321, 1453, 153, 137, 281, 154, 802, 424, 155, 1451,
151736
- /* 1820 */ 1450, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151737
- /* 1830 */ 1044, 1042, 958, 168, 219, 157, 170, 879, 308, 222,
151738
- /* 1840 */ 1058, 176, 159, 962, 400, 84, 402, 178, 85, 86,
151739
- /* 1850 */ 87, 166, 160, 393, 1061, 224, 225, 1057, 146, 18,
151740
- /* 1860 */ 226, 317, 1050, 1172, 243, 464, 182, 228, 37, 183,
151741
- /* 1870 */ 817, 469, 338, 232, 330, 481, 184, 89, 845, 19,
151742
- /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 858, 147, 488,
151743
- /* 1890 */ 282, 1123, 148, 1010, 928, 1093, 39, 93, 40, 495,
151744
- /* 1900 */ 1094, 187, 498, 207, 262, 264, 923, 242, 1109, 109,
151745
- /* 1910 */ 1113, 1111, 1097, 33, 21, 1117, 520, 1025, 22, 23,
151746
- /* 1920 */ 24, 1116, 25, 190, 97, 1011, 1009, 26, 1013, 1067,
151747
- /* 1930 */ 248, 7, 1066, 249, 1014, 28, 41, 889, 979, 827,
151748
- /* 1940 */ 108, 29, 250, 540, 251, 1530, 371, 368, 1131, 1130,
151749
- /* 1950 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1529,
151271
+ /* 1540 */ 423, 134, 134, 329, 1029, 216, 97, 239, 928, 345,
151272
+ /* 1550 */ 983, 243, 533, 1314, 339, 544, 105, 105, 899, 1354,
151273
+ /* 1560 */ 544, 1289, 258, 106, 338, 423, 546, 545, 544, 1300,
151274
+ /* 1570 */ 973, 892, 99, 536, 109, 4, 544, 133, 133, 391,
151275
+ /* 1580 */ 983, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151276
+ /* 1590 */ 132, 132, 1360, 106, 1218, 423, 546, 545, 75, 75,
151277
+ /* 1600 */ 973, 973, 973, 975, 976, 27, 544, 430, 825, 1210,
151278
+ /* 1610 */ 893, 139, 423, 109, 544, 1199, 1198, 1200, 1521, 544,
151279
+ /* 1620 */ 201, 544, 11, 374, 533, 1286, 347, 349, 77, 77,
151280
+ /* 1630 */ 1339, 973, 973, 975, 976, 27, 74, 74, 351, 213,
151281
+ /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1347, 382,
151282
+ /* 1650 */ 353, 452, 983, 337, 1236, 1419, 1418, 205, 105, 105,
151283
+ /* 1660 */ 192, 367, 193, 534, 1524, 106, 1177, 423, 546, 545,
151284
+ /* 1670 */ 247, 167, 973, 270, 1466, 200, 1464, 1174, 373, 373,
151285
+ /* 1680 */ 372, 255, 370, 398, 79, 814, 83, 82, 1424, 446,
151286
+ /* 1690 */ 161, 177, 169, 95, 1336, 438, 172, 173, 215, 174,
151287
+ /* 1700 */ 296, 175, 35, 973, 973, 975, 976, 27, 295, 1344,
151288
+ /* 1710 */ 439, 470, 223, 36, 379, 445, 1413, 381, 459, 1350,
151289
+ /* 1720 */ 181, 227, 88, 465, 259, 229, 1435, 318, 186, 468,
151290
+ /* 1730 */ 322, 230, 384, 1201, 231, 486, 1256, 1255, 217, 411,
151291
+ /* 1740 */ 1254, 1247, 90, 846, 206, 413, 156, 505, 1538, 158,
151292
+ /* 1750 */ 1225, 1537, 283, 1507, 1226, 336, 385, 284, 1224, 496,
151293
+ /* 1760 */ 1536, 1297, 94, 346, 348, 216, 1246, 499, 1298, 245,
151294
+ /* 1770 */ 246, 1296, 416, 350, 1493, 124, 1492, 10, 524, 361,
151295
+ /* 1780 */ 1399, 101, 96, 288, 508, 253, 1134, 1207, 34, 1295,
151296
+ /* 1790 */ 547, 254, 256, 257, 392, 548, 1196, 1191, 359, 391,
151297
+ /* 1800 */ 1279, 1278, 196, 365, 290, 535, 366, 352, 1451, 1321,
151298
+ /* 1810 */ 1320, 1452, 153, 137, 281, 154, 801, 424, 155, 1450,
151299
+ /* 1820 */ 1449, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151300
+ /* 1830 */ 1043, 1041, 957, 168, 219, 157, 170, 878, 308, 222,
151301
+ /* 1840 */ 1057, 176, 159, 961, 400, 84, 402, 178, 85, 86,
151302
+ /* 1850 */ 87, 166, 160, 393, 1060, 224, 225, 1056, 146, 18,
151303
+ /* 1860 */ 226, 317, 1049, 1171, 243, 464, 182, 228, 37, 183,
151304
+ /* 1870 */ 816, 469, 338, 232, 330, 481, 184, 89, 844, 19,
151305
+ /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 857, 147, 488,
151306
+ /* 1890 */ 282, 1122, 148, 1009, 927, 1092, 39, 93, 40, 495,
151307
+ /* 1900 */ 1093, 187, 498, 207, 262, 264, 922, 242, 1108, 109,
151308
+ /* 1910 */ 1112, 1110, 1096, 33, 21, 1116, 520, 1024, 22, 23,
151309
+ /* 1920 */ 24, 1115, 25, 190, 97, 1010, 1008, 26, 1012, 1066,
151310
+ /* 1930 */ 248, 7, 1065, 249, 1013, 28, 41, 888, 978, 826,
151311
+ /* 1940 */ 108, 29, 250, 540, 251, 1529, 371, 368, 1129, 1187,
151312
+ /* 1950 */ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1528,
151750151313
};
151751151314
static const YYCODETYPE yy_lookahead[] = {
151752151315
/* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268,
151753151316
/* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19,
151754151317
/* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211,
@@ -151941,11 +151504,11 @@
151941151504
/* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24,
151942151505
/* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26,
151943151506
/* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34,
151944151507
/* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23,
151945151508
/* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23,
151946
- /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 1,
151509
+ /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310,
151947151510
/* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310,
151948151511
/* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151949151512
/* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151950151513
/* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151951151514
/* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
@@ -151962,13 +151525,13 @@
151962151525
/* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151963151526
/* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151964151527
/* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151965151528
/* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310,
151966151529
};
151967
-#define YY_SHIFT_COUNT (550)
151530
+#define YY_SHIFT_COUNT (549)
151968151531
#define YY_SHIFT_MIN (0)
151969
-#define YY_SHIFT_MAX (1948)
151532
+#define YY_SHIFT_MAX (1947)
151970151533
static const unsigned short int yy_shift_ofst[] = {
151971151534
/* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481,
151972151535
/* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481,
151973151536
/* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151974151537
/* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340,
@@ -152021,11 +151584,10 @@
152021151584
/* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884,
152022151585
/* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889,
152023151586
/* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905,
152024151587
/* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918,
152025151588
/* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947,
152026
- /* 550 */ 1948,
152027151589
};
152028151590
#define YY_REDUCE_COUNT (389)
152029151591
#define YY_REDUCE_MIN (-262)
152030151592
#define YY_REDUCE_MAX (1617)
152031151593
static const short yy_reduce_ofst[] = {
@@ -152068,66 +151630,65 @@
152068151630
/* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592,
152069151631
/* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600,
152070151632
/* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616,
152071151633
};
152072151634
static const YYACTIONTYPE yy_default[] = {
152073
- /* 0 */ 1573, 1573, 1573, 1409, 1186, 1295, 1186, 1186, 1186, 1409,
152074
- /* 10 */ 1409, 1409, 1186, 1325, 1325, 1462, 1217, 1186, 1186, 1186,
152075
- /* 20 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1408, 1186, 1186,
152076
- /* 30 */ 1186, 1186, 1492, 1492, 1186, 1186, 1186, 1186, 1186, 1186,
152077
- /* 40 */ 1186, 1186, 1186, 1334, 1186, 1186, 1186, 1186, 1186, 1186,
152078
- /* 50 */ 1410, 1411, 1186, 1186, 1186, 1461, 1463, 1426, 1344, 1343,
152079
- /* 60 */ 1342, 1341, 1444, 1312, 1339, 1332, 1336, 1404, 1405, 1403,
152080
- /* 70 */ 1407, 1411, 1410, 1186, 1335, 1375, 1389, 1374, 1186, 1186,
152081
- /* 80 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152082
- /* 90 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152083
- /* 100 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152084
- /* 110 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152085
- /* 120 */ 1186, 1186, 1186, 1186, 1186, 1186, 1383, 1388, 1394, 1387,
152086
- /* 130 */ 1384, 1377, 1376, 1378, 1379, 1186, 1207, 1259, 1186, 1186,
152087
- /* 140 */ 1186, 1186, 1480, 1479, 1186, 1186, 1217, 1369, 1368, 1380,
152088
- /* 150 */ 1381, 1391, 1390, 1469, 1527, 1526, 1427, 1186, 1186, 1186,
152089
- /* 160 */ 1186, 1186, 1186, 1492, 1186, 1186, 1186, 1186, 1186, 1186,
152090
- /* 170 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152091
- /* 180 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1492, 1492,
152092
- /* 190 */ 1186, 1217, 1492, 1492, 1213, 1213, 1319, 1186, 1475, 1295,
152093
- /* 200 */ 1286, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152094
- /* 210 */ 1186, 1186, 1186, 1186, 1186, 1466, 1464, 1186, 1186, 1186,
152095
- /* 220 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152096
- /* 230 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152097
- /* 240 */ 1186, 1186, 1186, 1186, 1186, 1291, 1186, 1186, 1186, 1186,
152098
- /* 250 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1521, 1186, 1439,
152099
- /* 260 */ 1273, 1291, 1291, 1291, 1291, 1293, 1274, 1272, 1285, 1218,
152100
- /* 270 */ 1193, 1565, 1338, 1314, 1314, 1562, 1338, 1338, 1562, 1234,
152101
- /* 280 */ 1543, 1229, 1325, 1325, 1325, 1314, 1319, 1319, 1406, 1292,
152102
- /* 290 */ 1285, 1186, 1565, 1300, 1300, 1564, 1564, 1300, 1427, 1347,
152103
- /* 300 */ 1353, 1262, 1338, 1268, 1268, 1268, 1268, 1300, 1204, 1338,
152104
- /* 310 */ 1338, 1347, 1353, 1262, 1262, 1338, 1300, 1204, 1443, 1559,
152105
- /* 320 */ 1300, 1204, 1417, 1300, 1204, 1300, 1204, 1417, 1260, 1260,
152106
- /* 330 */ 1260, 1249, 1186, 1186, 1417, 1260, 1234, 1260, 1249, 1260,
152107
- /* 340 */ 1260, 1510, 1417, 1421, 1421, 1417, 1318, 1313, 1318, 1313,
152108
- /* 350 */ 1318, 1313, 1318, 1313, 1300, 1502, 1502, 1328, 1328, 1333,
152109
- /* 360 */ 1319, 1412, 1300, 1186, 1333, 1331, 1329, 1338, 1210, 1252,
152110
- /* 370 */ 1524, 1524, 1520, 1520, 1520, 1570, 1570, 1475, 1536, 1217,
152111
- /* 380 */ 1217, 1217, 1217, 1536, 1236, 1236, 1218, 1218, 1217, 1536,
152112
- /* 390 */ 1186, 1186, 1186, 1186, 1186, 1186, 1531, 1186, 1428, 1304,
152113
- /* 400 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152114
- /* 410 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152115
- /* 420 */ 1186, 1186, 1186, 1358, 1186, 1189, 1472, 1186, 1186, 1470,
152116
- /* 430 */ 1186, 1186, 1186, 1186, 1186, 1186, 1305, 1186, 1186, 1186,
152117
- /* 440 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152118
- /* 450 */ 1186, 1186, 1186, 1186, 1186, 1561, 1186, 1186, 1186, 1186,
152119
- /* 460 */ 1186, 1186, 1442, 1441, 1186, 1186, 1302, 1186, 1186, 1186,
152120
- /* 470 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152121
- /* 480 */ 1232, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152122
- /* 490 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152123
- /* 500 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1330, 1186, 1186,
152124
- /* 510 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152125
- /* 520 */ 1186, 1186, 1507, 1320, 1186, 1186, 1552, 1186, 1186, 1186,
152126
- /* 530 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152127
- /* 540 */ 1186, 1547, 1276, 1360, 1186, 1359, 1363, 1186, 1198, 1186,
152128
- /* 550 */ 1186,
151635
+ /* 0 */ 1572, 1572, 1572, 1408, 1185, 1294, 1185, 1185, 1185, 1408,
151636
+ /* 10 */ 1408, 1408, 1185, 1324, 1324, 1461, 1216, 1185, 1185, 1185,
151637
+ /* 20 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1407, 1185, 1185,
151638
+ /* 30 */ 1185, 1185, 1491, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151639
+ /* 40 */ 1185, 1185, 1185, 1333, 1185, 1185, 1185, 1185, 1185, 1185,
151640
+ /* 50 */ 1409, 1410, 1185, 1185, 1185, 1460, 1462, 1425, 1343, 1342,
151641
+ /* 60 */ 1341, 1340, 1443, 1311, 1338, 1331, 1335, 1403, 1404, 1402,
151642
+ /* 70 */ 1406, 1410, 1409, 1185, 1334, 1374, 1388, 1373, 1185, 1185,
151643
+ /* 80 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151644
+ /* 90 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151645
+ /* 100 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151646
+ /* 110 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151647
+ /* 120 */ 1185, 1185, 1185, 1185, 1185, 1185, 1382, 1387, 1393, 1386,
151648
+ /* 130 */ 1383, 1376, 1375, 1377, 1378, 1185, 1206, 1258, 1185, 1185,
151649
+ /* 140 */ 1185, 1185, 1479, 1478, 1185, 1185, 1216, 1368, 1367, 1379,
151650
+ /* 150 */ 1380, 1390, 1389, 1468, 1526, 1525, 1426, 1185, 1185, 1185,
151651
+ /* 160 */ 1185, 1185, 1185, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151652
+ /* 170 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151653
+ /* 180 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1491, 1491,
151654
+ /* 190 */ 1185, 1216, 1491, 1491, 1212, 1212, 1318, 1185, 1474, 1294,
151655
+ /* 200 */ 1285, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151656
+ /* 210 */ 1185, 1185, 1185, 1185, 1185, 1465, 1463, 1185, 1185, 1185,
151657
+ /* 220 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151658
+ /* 230 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151659
+ /* 240 */ 1185, 1185, 1185, 1185, 1185, 1290, 1185, 1185, 1185, 1185,
151660
+ /* 250 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1520, 1185, 1438,
151661
+ /* 260 */ 1272, 1290, 1290, 1290, 1290, 1292, 1273, 1271, 1284, 1217,
151662
+ /* 270 */ 1192, 1564, 1337, 1313, 1313, 1561, 1337, 1337, 1561, 1233,
151663
+ /* 280 */ 1542, 1228, 1324, 1324, 1324, 1313, 1318, 1318, 1405, 1291,
151664
+ /* 290 */ 1284, 1185, 1564, 1299, 1299, 1563, 1563, 1299, 1426, 1346,
151665
+ /* 300 */ 1352, 1261, 1337, 1267, 1267, 1267, 1267, 1299, 1203, 1337,
151666
+ /* 310 */ 1337, 1346, 1352, 1261, 1261, 1337, 1299, 1203, 1442, 1558,
151667
+ /* 320 */ 1299, 1203, 1416, 1299, 1203, 1299, 1203, 1416, 1259, 1259,
151668
+ /* 330 */ 1259, 1248, 1185, 1185, 1416, 1259, 1233, 1259, 1248, 1259,
151669
+ /* 340 */ 1259, 1509, 1416, 1420, 1420, 1416, 1317, 1312, 1317, 1312,
151670
+ /* 350 */ 1317, 1312, 1317, 1312, 1299, 1501, 1501, 1327, 1327, 1332,
151671
+ /* 360 */ 1318, 1411, 1299, 1185, 1332, 1330, 1328, 1337, 1209, 1251,
151672
+ /* 370 */ 1523, 1523, 1519, 1519, 1519, 1569, 1569, 1474, 1535, 1216,
151673
+ /* 380 */ 1216, 1216, 1216, 1535, 1235, 1235, 1217, 1217, 1216, 1535,
151674
+ /* 390 */ 1185, 1185, 1185, 1185, 1185, 1185, 1530, 1185, 1427, 1303,
151675
+ /* 400 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151676
+ /* 410 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151677
+ /* 420 */ 1185, 1185, 1185, 1357, 1185, 1188, 1471, 1185, 1185, 1469,
151678
+ /* 430 */ 1185, 1185, 1185, 1185, 1185, 1185, 1304, 1185, 1185, 1185,
151679
+ /* 440 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151680
+ /* 450 */ 1185, 1185, 1185, 1185, 1185, 1560, 1185, 1185, 1185, 1185,
151681
+ /* 460 */ 1185, 1185, 1441, 1440, 1185, 1185, 1301, 1185, 1185, 1185,
151682
+ /* 470 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151683
+ /* 480 */ 1231, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151684
+ /* 490 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151685
+ /* 500 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1329, 1185, 1185,
151686
+ /* 510 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151687
+ /* 520 */ 1185, 1185, 1506, 1319, 1185, 1185, 1551, 1185, 1185, 1185,
151688
+ /* 530 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151689
+ /* 540 */ 1185, 1546, 1275, 1359, 1185, 1358, 1362, 1185, 1197, 1185,
152129151690
};
152130151691
/********** End of lemon-generated parsing tables *****************************/
152131151692
152132151693
/* The next table maps tokens (terminal symbols) into fallback tokens.
152133151694
** If a construct like the following:
@@ -153058,11 +152619,11 @@
153058152619
/* 325 */ "input ::= cmdlist",
153059152620
/* 326 */ "cmdlist ::= cmdlist ecmd",
153060152621
/* 327 */ "cmdlist ::= ecmd",
153061152622
/* 328 */ "ecmd ::= SEMI",
153062152623
/* 329 */ "ecmd ::= cmdx SEMI",
153063
- /* 330 */ "ecmd ::= explain cmdx SEMI",
152624
+ /* 330 */ "ecmd ::= explain cmdx",
153064152625
/* 331 */ "trans_opt ::=",
153065152626
/* 332 */ "trans_opt ::= TRANSACTION",
153066152627
/* 333 */ "trans_opt ::= TRANSACTION nm",
153067152628
/* 334 */ "savepoint_opt ::= SAVEPOINT",
153068152629
/* 335 */ "savepoint_opt ::=",
@@ -153950,11 +153511,11 @@
153950153511
181, /* (325) input ::= cmdlist */
153951153512
182, /* (326) cmdlist ::= cmdlist ecmd */
153952153513
182, /* (327) cmdlist ::= ecmd */
153953153514
183, /* (328) ecmd ::= SEMI */
153954153515
183, /* (329) ecmd ::= cmdx SEMI */
153955
- 183, /* (330) ecmd ::= explain cmdx SEMI */
153516
+ 183, /* (330) ecmd ::= explain cmdx */
153956153517
188, /* (331) trans_opt ::= */
153957153518
188, /* (332) trans_opt ::= TRANSACTION */
153958153519
188, /* (333) trans_opt ::= TRANSACTION nm */
153959153520
190, /* (334) savepoint_opt ::= SAVEPOINT */
153960153521
190, /* (335) savepoint_opt ::= */
@@ -154340,11 +153901,11 @@
154340153901
-1, /* (325) input ::= cmdlist */
154341153902
-2, /* (326) cmdlist ::= cmdlist ecmd */
154342153903
-1, /* (327) cmdlist ::= ecmd */
154343153904
-1, /* (328) ecmd ::= SEMI */
154344153905
-2, /* (329) ecmd ::= cmdx SEMI */
154345
- -3, /* (330) ecmd ::= explain cmdx SEMI */
153906
+ -2, /* (330) ecmd ::= explain cmdx */
154346153907
0, /* (331) trans_opt ::= */
154347153908
-1, /* (332) trans_opt ::= TRANSACTION */
154348153909
-2, /* (333) trans_opt ::= TRANSACTION nm */
154349153910
-1, /* (334) savepoint_opt ::= SAVEPOINT */
154350153911
0, /* (335) savepoint_opt ::= */
@@ -154428,19 +153989,16 @@
154428153989
yymsp = yypParser->yytos;
154429153990
#ifndef NDEBUG
154430153991
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
154431153992
yysize = yyRuleInfoNRhs[yyruleno];
154432153993
if( yysize ){
154433
- fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
153994
+ fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
154434153995
yyTracePrompt,
154435
- yyruleno, yyRuleName[yyruleno],
154436
- yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
154437
- yymsp[yysize].stateno);
153996
+ yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
154438153997
}else{
154439
- fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
154440
- yyTracePrompt, yyruleno, yyRuleName[yyruleno],
154441
- yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
153998
+ fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
153999
+ yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
154442154000
}
154443154001
}
154444154002
#endif /* NDEBUG */
154445154003
154446154004
/* Check that the stack is large enough to grow by a single entry
@@ -155847,11 +155405,11 @@
155847155405
/* (325) input ::= cmdlist */ yytestcase(yyruleno==325);
155848155406
/* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326);
155849155407
/* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327);
155850155408
/* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328);
155851155409
/* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329);
155852
- /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330);
155410
+ /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330);
155853155411
/* (331) trans_opt ::= */ yytestcase(yyruleno==331);
155854155412
/* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332);
155855155413
/* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333);
155856155414
/* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334);
155857155415
/* (335) savepoint_opt ::= */ yytestcase(yyruleno==335);
@@ -163524,13 +163082,10 @@
163524163082
# define TESTONLY(X) X
163525163083
#else
163526163084
# define TESTONLY(X)
163527163085
#endif
163528163086
163529
-#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
163530
-#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
163531
-
163532163087
#endif /* SQLITE_AMALGAMATION */
163533163088
163534163089
#ifdef SQLITE_DEBUG
163535163090
SQLITE_PRIVATE int sqlite3Fts3Corrupt(void);
163536163091
# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()
@@ -163570,11 +163125,10 @@
163570163125
sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
163571163126
char *zContentTbl; /* content=xxx option, or NULL */
163572163127
char *zLanguageid; /* languageid=xxx option, or NULL */
163573163128
int nAutoincrmerge; /* Value configured by 'automerge' */
163574163129
u32 nLeafAdd; /* Number of leaf blocks added this trans */
163575
- int bLock; /* Used to prevent recursive content= tbls */
163576163130
163577163131
/* Precompiled statements used by the implementation. Each of these
163578163132
** statements is run and reset within a single virtual table API call.
163579163133
*/
163580163134
sqlite3_stmt *aStmt[40];
@@ -163909,11 +163463,10 @@
163909163463
163910163464
/* fts3.c */
163911163465
SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
163912163466
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
163913163467
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
163914
-SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *, sqlite_uint64 *);
163915163468
SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*);
163916163469
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
163917163470
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
163918163471
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
163919163472
SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
@@ -163997,10 +163550,22 @@
163997163550
#ifndef SQLITE_CORE
163998163551
/* # include "sqlite3ext.h" */
163999163552
SQLITE_EXTENSION_INIT1
164000163553
#endif
164001163554
163555
+/*
163556
+** The following are copied from sqliteInt.h.
163557
+**
163558
+** Constants for the largest and smallest possible 64-bit signed integers.
163559
+** These macros are designed to work correctly on both 32-bit and 64-bit
163560
+** compilers.
163561
+*/
163562
+#ifndef SQLITE_AMALGAMATION
163563
+# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
163564
+# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
163565
+#endif
163566
+
164002163567
static int fts3EvalNext(Fts3Cursor *pCsr);
164003163568
static int fts3EvalStart(Fts3Cursor *pCsr);
164004163569
static int fts3TermSegReaderCursor(
164005163570
Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
164006163571
@@ -164041,11 +163606,16 @@
164041163606
if( (v & mask2)==0 ){ var = v; return ret; }
164042163607
#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
164043163608
v = (*ptr++); \
164044163609
if( (v & mask2)==0 ){ var = v; return ret; }
164045163610
164046
-SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){
163611
+/*
163612
+** Read a 64-bit variable-length integer from memory starting at p[0].
163613
+** Return the number of bytes read, or 0 on error.
163614
+** The value is stored in *v.
163615
+*/
163616
+SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
164047163617
const unsigned char *p = (const unsigned char*)pBuf;
164048163618
const unsigned char *pStart = p;
164049163619
u32 a;
164050163620
u64 b;
164051163621
int shift;
@@ -164063,19 +163633,10 @@
164063163633
}
164064163634
*v = b;
164065163635
return (int)(p - pStart);
164066163636
}
164067163637
164068
-/*
164069
-** Read a 64-bit variable-length integer from memory starting at p[0].
164070
-** Return the number of bytes read, or 0 on error.
164071
-** The value is stored in *v.
164072
-*/
164073
-SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
164074
- return sqlite3Fts3GetVarintU(pBuf, (sqlite3_uint64*)v);
164075
-}
164076
-
164077163638
/*
164078163639
** Read a 64-bit variable-length integer from memory starting at p[0] and
164079163640
** not extending past pEnd[-1].
164080163641
** Return the number of bytes read, or 0 on error.
164081163642
** The value is stored in *v.
@@ -165292,14 +164853,10 @@
165292164853
int iLangidCons = -1; /* Index of langid=x constraint, if present */
165293164854
int iDocidGe = -1; /* Index of docid>=x constraint, if present */
165294164855
int iDocidLe = -1; /* Index of docid<=x constraint, if present */
165295164856
int iIdx;
165296164857
165297
- if( p->bLock ){
165298
- return SQLITE_ERROR;
165299
- }
165300
-
165301164858
/* By default use a full table scan. This is an expensive option,
165302164859
** so search through the constraints to see if a more efficient
165303164860
** strategy is possible.
165304164861
*/
165305164862
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
@@ -165494,15 +165051,11 @@
165494165051
pCsr->pStmt = p->pSeekStmt;
165495165052
p->pSeekStmt = 0;
165496165053
}else{
165497165054
zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
165498165055
if( !zSql ) return SQLITE_NOMEM;
165499
- p->bLock++;
165500
- rc = sqlite3_prepare_v3(
165501
- p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0
165502
- );
165503
- p->bLock--;
165056
+ rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
165504165057
sqlite3_free(zSql);
165505165058
}
165506165059
if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
165507165060
}
165508165061
return rc;
@@ -165516,19 +165069,15 @@
165516165069
static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
165517165070
int rc = SQLITE_OK;
165518165071
if( pCsr->isRequireSeek ){
165519165072
rc = fts3CursorSeekStmt(pCsr);
165520165073
if( rc==SQLITE_OK ){
165521
- Fts3Table *pTab = (Fts3Table*)pCsr->base.pVtab;
165522
- pTab->bLock++;
165523165074
sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
165524165075
pCsr->isRequireSeek = 0;
165525165076
if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
165526
- pTab->bLock--;
165527165077
return SQLITE_OK;
165528165078
}else{
165529
- pTab->bLock--;
165530165079
rc = sqlite3_reset(pCsr->pStmt);
165531165080
if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){
165532165081
/* If no row was found and no error has occurred, then the %_content
165533165082
** table is missing a row that is present in the full-text index.
165534165083
** The data structures are corrupt. */
@@ -165696,11 +165245,11 @@
165696165245
165697165246
assert( piLeaf || piLeaf2 );
165698165247
165699165248
fts3GetVarint32(zNode, &iHeight);
165700165249
rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
165701
- assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
165250
+ assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
165702165251
165703165252
if( rc==SQLITE_OK && iHeight>1 ){
165704165253
char *zBlob = 0; /* Blob read from %_segments table */
165705165254
int nBlob = 0; /* Size of zBlob in bytes */
165706165255
@@ -166177,16 +165726,16 @@
166177165726
sqlite3_int64 *pVal /* IN/OUT: Integer value */
166178165727
){
166179165728
if( *pp>=pEnd ){
166180165729
*pp = 0;
166181165730
}else{
166182
- u64 iVal;
166183
- *pp += sqlite3Fts3GetVarintU(*pp, &iVal);
165731
+ sqlite3_int64 iVal;
165732
+ *pp += sqlite3Fts3GetVarint(*pp, &iVal);
166184165733
if( bDescIdx ){
166185
- *pVal = (i64)((u64)*pVal - iVal);
165734
+ *pVal -= iVal;
166186165735
}else{
166187
- *pVal = (i64)((u64)*pVal + iVal);
165736
+ *pVal += iVal;
166188165737
}
166189165738
}
166190165739
}
166191165740
166192165741
/*
@@ -166212,14 +165761,14 @@
166212165761
sqlite3_int64 iVal /* Write this value to the list */
166213165762
){
166214165763
sqlite3_uint64 iWrite;
166215165764
if( bDescIdx==0 || *pbFirst==0 ){
166216165765
assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev );
166217
- iWrite = (u64)iVal - (u64)*piPrev;
165766
+ iWrite = iVal - *piPrev;
166218165767
}else{
166219165768
assert_fts3_nc( *piPrev>=iVal );
166220
- iWrite = (u64)*piPrev - (u64)iVal;
165769
+ iWrite = *piPrev - iVal;
166221165770
}
166222165771
assert( *pbFirst || *piPrev==0 );
166223165772
assert_fts3_nc( *pbFirst==0 || iWrite>0 );
166224165773
*pp += sqlite3Fts3PutVarint(*pp, iWrite);
166225165774
*piPrev = iVal;
@@ -166234,12 +165783,11 @@
166234165783
** Otherwise, (i2-i1).
166235165784
**
166236165785
** Using this makes it easier to write code that can merge doclists that are
166237165786
** sorted in either ascending or descending order.
166238165787
*/
166239
-/* #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i64)((u64)i1-i2)) */
166240
-#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1>i2?1:((i1==i2)?0:-1)))
165788
+#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))
166241165789
166242165790
/*
166243165791
** This function does an "OR" merge of two doclists (output contains all
166244165792
** positions contained in either argument doclist). If the docids in the
166245165793
** input doclists are sorted in ascending order, parameter bDescDoclist
@@ -166649,11 +166197,11 @@
166649166197
** for the pending-terms. If this is a scan, then this call must be being
166650166198
** made by an fts4aux module, not an FTS table. In this case calling
166651166199
** Fts3SegReaderPending might segfault, as the data structures used by
166652166200
** fts4aux are not completely populated. So it's easiest to filter these
166653166201
** calls out here. */
166654
- if( iLevel<0 && p->aIndex && p->iPrevLangid==iLangid ){
166202
+ if( iLevel<0 && p->aIndex ){
166655166203
Fts3SegReader *pSeg = 0;
166656166204
rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
166657166205
if( rc==SQLITE_OK && pSeg ){
166658166206
rc = fts3SegReaderCursorAppend(pCsr, pSeg);
166659166207
}
@@ -166912,20 +166460,17 @@
166912166460
*/
166913166461
static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){
166914166462
int rc;
166915166463
Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
166916166464
if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){
166917
- Fts3Table *pTab = (Fts3Table*)pCursor->pVtab;
166918
- pTab->bLock++;
166919166465
if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){
166920166466
pCsr->isEof = 1;
166921166467
rc = sqlite3_reset(pCsr->pStmt);
166922166468
}else{
166923166469
pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);
166924166470
rc = SQLITE_OK;
166925166471
}
166926
- pTab->bLock--;
166927166472
}else{
166928166473
rc = fts3EvalNext((Fts3Cursor *)pCursor);
166929166474
}
166930166475
assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
166931166476
return rc;
@@ -166982,14 +166527,10 @@
166982166527
int iIdx;
166983166528
166984166529
UNUSED_PARAMETER(idxStr);
166985166530
UNUSED_PARAMETER(nVal);
166986166531
166987
- if( p->bLock ){
166988
- return SQLITE_ERROR;
166989
- }
166990
-
166991166532
eSearch = (idxNum & 0x0000FFFF);
166992166533
assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
166993166534
assert( p->pSegments==0 );
166994166535
166995166536
/* Collect arguments into local variables */
@@ -167057,15 +166598,11 @@
167057166598
zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
167058166599
p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
167059166600
);
167060166601
}
167061166602
if( zSql ){
167062
- p->bLock++;
167063
- rc = sqlite3_prepare_v3(
167064
- p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0
167065
- );
167066
- p->bLock--;
166603
+ rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
167067166604
sqlite3_free(zSql);
167068166605
}else{
167069166606
rc = SQLITE_NOMEM;
167070166607
}
167071166608
}else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -168220,20 +167757,19 @@
168220167757
Fts3Table *pTab,
168221167758
Fts3Doclist *pDL,
168222167759
u8 *pbEof
168223167760
){
168224167761
char *pIter; /* Used to iterate through aAll */
168225
- char *pEnd; /* 1 byte past end of aAll */
167762
+ char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */
168226167763
168227167764
if( pDL->pNextDocid ){
168228167765
pIter = pDL->pNextDocid;
168229
- assert( pDL->aAll!=0 || pIter==0 );
168230167766
}else{
168231167767
pIter = pDL->aAll;
168232167768
}
168233167769
168234
- if( pIter==0 || pIter>=(pEnd = pDL->aAll + pDL->nAll) ){
167770
+ if( pIter>=pEnd ){
168235167771
/* We have already reached the end of this doclist. EOF. */
168236167772
*pbEof = 1;
168237167773
}else{
168238167774
sqlite3_int64 iDelta;
168239167775
pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
@@ -174569,11 +174105,11 @@
174569174105
int rc = SQLITE_OK;
174570174106
174571174107
assert( !p || p->iLastDocid<=iDocid );
174572174108
174573174109
if( !p || p->iLastDocid!=iDocid ){
174574
- u64 iDelta = (u64)iDocid - (u64)(p ? p->iLastDocid : 0);
174110
+ sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);
174575174111
if( p ){
174576174112
assert( p->nData<p->nSpace );
174577174113
assert( p->aData[p->nData]==0 );
174578174114
p->nData++;
174579174115
}
@@ -175110,12 +174646,10 @@
175110174646
aByte = 0;
175111174647
}
175112174648
}
175113174649
*paBlob = aByte;
175114174650
}
175115
- }else if( rc==SQLITE_ERROR ){
175116
- rc = FTS_CORRUPT_VTAB;
175117174651
}
175118174652
175119174653
return rc;
175120174654
}
175121174655
@@ -175404,22 +174938,22 @@
175404174938
if( p>=pEnd ){
175405174939
pReader->pOffsetList = 0;
175406174940
}else{
175407174941
rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
175408174942
if( rc==SQLITE_OK ){
175409
- u64 iDelta;
175410
- pReader->pOffsetList = p + sqlite3Fts3GetVarintU(p, &iDelta);
174943
+ sqlite3_int64 iDelta;
174944
+ pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);
175411174945
if( pTab->bDescIdx ){
175412
- pReader->iDocid = (i64)((u64)pReader->iDocid - iDelta);
174946
+ pReader->iDocid -= iDelta;
175413174947
}else{
175414
- pReader->iDocid = (i64)((u64)pReader->iDocid + iDelta);
174948
+ pReader->iDocid += iDelta;
175415174949
}
175416174950
}
175417174951
}
175418174952
}
175419174953
175420
- return rc;
174954
+ return SQLITE_OK;
175421174955
}
175422174956
175423174957
175424174958
SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(
175425174959
Fts3Cursor *pCsr,
@@ -176154,11 +175688,10 @@
176154175688
176155175689
if( nData>0 && nData+nReq>p->nNodeSize ){
176156175690
int rc;
176157175691
176158175692
/* The current leaf node is full. Write it out to the database. */
176159
- if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB;
176160175693
rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
176161175694
if( rc!=SQLITE_OK ) return rc;
176162175695
p->nLeafAdd++;
176163175696
176164175697
/* Add the current term to the interior node tree. The term added to
@@ -176852,14 +176385,14 @@
176852176385
/* Calculate the 'docid' delta value to write into the merged
176853176386
** doclist. */
176854176387
sqlite3_int64 iDelta;
176855176388
if( p->bDescIdx && nDoclist>0 ){
176856176389
if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB;
176857
- iDelta = (i64)((u64)iPrev - (u64)iDocid);
176390
+ iDelta = iPrev - iDocid;
176858176391
}else{
176859176392
if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB;
176860
- iDelta = (i64)((u64)iDocid - (u64)iPrev);
176393
+ iDelta = iDocid - iPrev;
176861176394
}
176862176395
176863176396
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
176864176397
if( nDoclist+nByte>pCsr->nBuffer ){
176865176398
char *aNew;
@@ -177138,11 +176671,11 @@
177138176671
if( rc!=SQLITE_ROW ) break;
177139176672
rc = fts3SegWriterAdd(p, &pWriter, 1,
177140176673
csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);
177141176674
}
177142176675
if( rc!=SQLITE_OK ) goto finished;
177143
- assert_fts3_nc( pWriter || bIgnoreEmpty );
176676
+ assert( pWriter || bIgnoreEmpty );
177144176677
177145176678
if( iLevel!=FTS3_SEGCURSOR_PENDING ){
177146176679
rc = fts3DeleteSegdir(
177147176680
p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment
177148176681
);
@@ -178724,21 +178257,17 @@
178724178257
*/
178725178258
static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
178726178259
const int nHint = pHint->n;
178727178260
int i;
178728178261
178729
- i = pHint->n-1;
178730
- if( (pHint->a[i] & 0x80) ) return FTS_CORRUPT_VTAB;
178262
+ i = pHint->n-2;
178731178263
while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
178732
- if( i==0 ) return FTS_CORRUPT_VTAB;
178733
- i--;
178734178264
while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
178735178265
178736178266
pHint->n = i;
178737178267
i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
178738178268
i += fts3GetVarint32(&pHint->a[i], pnInput);
178739
- assert( i<=nHint );
178740178269
if( i!=nHint ) return FTS_CORRUPT_VTAB;
178741178270
178742178271
return SQLITE_OK;
178743178272
}
178744178273
@@ -179064,28 +178593,28 @@
179064178593
char *pCsr = csr.aDoclist;
179065178594
char *pEnd = &pCsr[csr.nDoclist];
179066178595
179067178596
i64 iDocid = 0;
179068178597
i64 iCol = 0;
179069
- u64 iPos = 0;
178598
+ i64 iPos = 0;
179070178599
179071178600
pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
179072178601
while( pCsr<pEnd ){
179073
- u64 iVal = 0;
179074
- pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal);
178602
+ i64 iVal = 0;
178603
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
179075178604
if( pCsr<pEnd ){
179076178605
if( iVal==0 || iVal==1 ){
179077178606
iCol = 0;
179078178607
iPos = 0;
179079178608
if( iVal ){
179080178609
pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
179081178610
}else{
179082
- pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal);
178611
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
179083178612
if( p->bDescIdx ){
179084
- iDocid = (i64)((u64)iDocid - iVal);
178613
+ iDocid -= iVal;
179085178614
}else{
179086
- iDocid = (i64)((u64)iDocid + iVal);
178615
+ iDocid += iVal;
179087178616
}
179088178617
}
179089178618
}else{
179090178619
iPos += (iVal - 2);
179091178620
cksum = cksum ^ fts3ChecksumEntry(
@@ -183357,53 +182886,22 @@
183357182886
pRoot->jnFlags |= JNODE_APPEND;
183358182887
pParse->aNode[iLabel].jnFlags |= JNODE_RAW;
183359182888
}
183360182889
return pNode;
183361182890
}
183362
- }else if( zPath[0]=='[' ){
182891
+ }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){
182892
+ if( pRoot->eType!=JSON_ARRAY ) return 0;
183363182893
i = 0;
183364182894
j = 1;
183365182895
while( safe_isdigit(zPath[j]) ){
183366182896
i = i*10 + zPath[j] - '0';
183367182897
j++;
183368182898
}
183369
- if( j<2 || zPath[j]!=']' ){
183370
- if( zPath[1]=='#' ){
183371
- JsonNode *pBase = pRoot;
183372
- int iBase = iRoot;
183373
- if( pRoot->eType!=JSON_ARRAY ) return 0;
183374
- for(;;){
183375
- while( j<=pBase->n ){
183376
- if( (pBase[j].jnFlags & JNODE_REMOVE)==0 ) i++;
183377
- j += jsonNodeSize(&pBase[j]);
183378
- }
183379
- if( (pBase->jnFlags & JNODE_APPEND)==0 ) break;
183380
- iBase += pBase->u.iAppend;
183381
- pBase = &pParse->aNode[iBase];
183382
- j = 1;
183383
- }
183384
- j = 2;
183385
- if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){
183386
- unsigned int x = 0;
183387
- j = 3;
183388
- do{
183389
- x = x*10 + zPath[j] - '0';
183390
- j++;
183391
- }while( safe_isdigit(zPath[j]) );
183392
- if( x>i ) return 0;
183393
- i -= x;
183394
- }
183395
- if( zPath[j]!=']' ){
183396
- *pzErr = zPath;
183397
- return 0;
183398
- }
183399
- }else{
183400
- *pzErr = zPath;
183401
- return 0;
183402
- }
183403
- }
183404
- if( pRoot->eType!=JSON_ARRAY ) return 0;
182899
+ if( zPath[j]!=']' ){
182900
+ *pzErr = zPath;
182901
+ return 0;
182902
+ }
183405182903
zPath += j + 1;
183406182904
j = 1;
183407182905
for(;;){
183408182906
while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
183409182907
if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;
@@ -184867,11 +184365,10 @@
184867184365
/* #include "sqlite3ext.h" */
184868184366
SQLITE_EXTENSION_INIT1
184869184367
#else
184870184368
/* #include "sqlite3.h" */
184871184369
#endif
184872
-SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */
184873184370
184874184371
#ifndef SQLITE_AMALGAMATION
184875184372
#include "sqlite3rtree.h"
184876184373
typedef sqlite3_int64 i64;
184877184374
typedef sqlite3_uint64 u64;
@@ -185131,16 +184628,10 @@
185131184628
#define RTREE_GE 0x44 /* D */
185132184629
#define RTREE_GT 0x45 /* E */
185133184630
#define RTREE_MATCH 0x46 /* F: Old-style sqlite3_rtree_geometry_callback() */
185134184631
#define RTREE_QUERY 0x47 /* G: New-style sqlite3_rtree_query_callback() */
185135184632
185136
-/* Special operators available only on cursors. Needs to be consecutive
185137
-** with the normal values above, but must be less than RTREE_MATCH. These
185138
-** are used in the cursor for contraints such as x=NULL (RTREE_FALSE) or
185139
-** x<'xyz' (RTREE_TRUE) */
185140
-#define RTREE_TRUE 0x3f /* ? */
185141
-#define RTREE_FALSE 0x40 /* @ */
185142184633
185143184634
/*
185144184635
** An rtree structure node.
185145184636
*/
185146184637
struct RtreeNode {
@@ -185870,16 +185361,13 @@
185870185361
return rc;
185871185362
}
185872185363
185873185364
185874185365
/*
185875
-** Reset a cursor back to its initial state.
185366
+** Free the RtreeCursor.aConstraint[] array and its contents.
185876185367
*/
185877
-static void resetCursor(RtreeCursor *pCsr){
185878
- Rtree *pRtree = (Rtree *)(pCsr->base.pVtab);
185879
- int ii;
185880
- sqlite3_stmt *pStmt;
185368
+static void freeCursorConstraints(RtreeCursor *pCsr){
185881185369
if( pCsr->aConstraint ){
185882185370
int i; /* Used to iterate through constraint array */
185883185371
for(i=0; i<pCsr->nConstraint; i++){
185884185372
sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;
185885185373
if( pInfo ){
@@ -185888,28 +185376,24 @@
185888185376
}
185889185377
}
185890185378
sqlite3_free(pCsr->aConstraint);
185891185379
pCsr->aConstraint = 0;
185892185380
}
185893
- for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
185894
- sqlite3_free(pCsr->aPoint);
185895
- pStmt = pCsr->pReadAux;
185896
- memset(pCsr, 0, sizeof(RtreeCursor));
185897
- pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
185898
- pCsr->pReadAux = pStmt;
185899
-
185900185381
}
185901185382
185902185383
/*
185903185384
** Rtree virtual table module xClose method.
185904185385
*/
185905185386
static int rtreeClose(sqlite3_vtab_cursor *cur){
185906185387
Rtree *pRtree = (Rtree *)(cur->pVtab);
185388
+ int ii;
185907185389
RtreeCursor *pCsr = (RtreeCursor *)cur;
185908185390
assert( pRtree->nCursor>0 );
185909
- resetCursor(pCsr);
185391
+ freeCursorConstraints(pCsr);
185910185392
sqlite3_finalize(pCsr->pReadAux);
185393
+ sqlite3_free(pCsr->aPoint);
185394
+ for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
185911185395
sqlite3_free(pCsr);
185912185396
pRtree->nCursor--;
185913185397
nodeBlobReset(pRtree);
185914185398
return SQLITE_OK;
185915185399
}
@@ -186063,16 +185547,13 @@
186063185547
** in a coordinate pair. But make pCellData point to the lower bound.
186064185548
*/
186065185549
pCellData += 8 + 4*(p->iCoord&0xfe);
186066185550
186067185551
assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
186068
- || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE
186069
- || p->op==RTREE_FALSE );
185552
+ || p->op==RTREE_GT || p->op==RTREE_EQ );
186070185553
assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
186071185554
switch( p->op ){
186072
- case RTREE_TRUE: return; /* Always satisfied */
186073
- case RTREE_FALSE: break; /* Never satisfied */
186074185555
case RTREE_LE:
186075185556
case RTREE_LT:
186076185557
case RTREE_EQ:
186077185558
RTREE_DECODE_COORD(eInt, pCellData, val);
186078185559
/* val now holds the lower bound of the coordinate pair */
@@ -186106,23 +185587,20 @@
186106185587
int *peWithin /* Adjust downward, as appropriate */
186107185588
){
186108185589
RtreeDValue xN; /* Coordinate value converted to a double */
186109185590
186110185591
assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
186111
- || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE
186112
- || p->op==RTREE_FALSE );
185592
+ || p->op==RTREE_GT || p->op==RTREE_EQ );
186113185593
pCellData += 8 + p->iCoord*4;
186114185594
assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
186115185595
RTREE_DECODE_COORD(eInt, pCellData, xN);
186116185596
switch( p->op ){
186117
- case RTREE_TRUE: return; /* Always satisfied */
186118
- case RTREE_FALSE: break; /* Never satisfied */
186119
- case RTREE_LE: if( xN <= p->u.rValue ) return; break;
186120
- case RTREE_LT: if( xN < p->u.rValue ) return; break;
186121
- case RTREE_GE: if( xN >= p->u.rValue ) return; break;
186122
- case RTREE_GT: if( xN > p->u.rValue ) return; break;
186123
- default: if( xN == p->u.rValue ) return; break;
185597
+ case RTREE_LE: if( xN <= p->u.rValue ) return; break;
185598
+ case RTREE_LT: if( xN < p->u.rValue ) return; break;
185599
+ case RTREE_GE: if( xN >= p->u.rValue ) return; break;
185600
+ case RTREE_GT: if( xN > p->u.rValue ) return; break;
185601
+ default: if( xN == p->u.rValue ) return; break;
186124185602
}
186125185603
*peWithin = NOT_WITHIN;
186126185604
}
186127185605
186128185606
/*
@@ -186611,32 +186089,30 @@
186611186089
RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
186612186090
RtreeNode *pRoot = 0;
186613186091
int ii;
186614186092
int rc = SQLITE_OK;
186615186093
int iCell = 0;
186094
+ sqlite3_stmt *pStmt;
186616186095
186617186096
rtreeReference(pRtree);
186618186097
186619186098
/* Reset the cursor to the same state as rtreeOpen() leaves it in. */
186620
- resetCursor(pCsr);
186099
+ freeCursorConstraints(pCsr);
186100
+ sqlite3_free(pCsr->aPoint);
186101
+ pStmt = pCsr->pReadAux;
186102
+ memset(pCsr, 0, sizeof(RtreeCursor));
186103
+ pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
186104
+ pCsr->pReadAux = pStmt;
186621186105
186622186106
pCsr->iStrategy = idxNum;
186623186107
if( idxNum==1 ){
186624186108
/* Special case - lookup by rowid. */
186625186109
RtreeNode *pLeaf; /* Leaf on which the required cell resides */
186626186110
RtreeSearchPoint *p; /* Search point for the leaf */
186627186111
i64 iRowid = sqlite3_value_int64(argv[0]);
186628186112
i64 iNode = 0;
186629
- int eType = sqlite3_value_numeric_type(argv[0]);
186630
- if( eType==SQLITE_INTEGER
186631
- || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid)
186632
- ){
186633
- rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
186634
- }else{
186635
- rc = SQLITE_OK;
186636
- pLeaf = 0;
186637
- }
186113
+ rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
186638186114
if( rc==SQLITE_OK && pLeaf!=0 ){
186639186115
p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
186640186116
assert( p!=0 ); /* Always returns pCsr->sPoint */
186641186117
pCsr->aNode[0] = pLeaf;
186642186118
p->id = iNode;
@@ -186662,11 +186138,10 @@
186662186138
memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));
186663186139
assert( (idxStr==0 && argc==0)
186664186140
|| (idxStr && (int)strlen(idxStr)==argc*2) );
186665186141
for(ii=0; ii<argc; ii++){
186666186142
RtreeConstraint *p = &pCsr->aConstraint[ii];
186667
- int eType = sqlite3_value_numeric_type(argv[ii]);
186668186143
p->op = idxStr[ii*2];
186669186144
p->iCoord = idxStr[ii*2+1]-'0';
186670186145
if( p->op>=RTREE_MATCH ){
186671186146
/* A MATCH operator. The right-hand-side must be a blob that
186672186147
** can be cast into an RtreeMatchArg object. One created using
@@ -186677,25 +186152,16 @@
186677186152
break;
186678186153
}
186679186154
p->pInfo->nCoord = pRtree->nDim2;
186680186155
p->pInfo->anQueue = pCsr->anQueue;
186681186156
p->pInfo->mxLevel = pRtree->iDepth + 1;
186682
- }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
186157
+ }else{
186683186158
#ifdef SQLITE_RTREE_INT_ONLY
186684186159
p->u.rValue = sqlite3_value_int64(argv[ii]);
186685186160
#else
186686186161
p->u.rValue = sqlite3_value_double(argv[ii]);
186687186162
#endif
186688
- }else{
186689
- p->u.rValue = RTREE_ZERO;
186690
- if( eType==SQLITE_NULL ){
186691
- p->op = RTREE_FALSE;
186692
- }else if( p->op==RTREE_LT || p->op==RTREE_LE ){
186693
- p->op = RTREE_TRUE;
186694
- }else{
186695
- p->op = RTREE_FALSE;
186696
- }
186697186163
}
186698186164
}
186699186165
}
186700186166
}
186701186167
if( rc==SQLITE_OK ){
@@ -188468,18 +187934,10 @@
188468187934
188469187935
sqlite3_free(zSql);
188470187936
return rc;
188471187937
}
188472187938
188473
-/*
188474
-** Return the length of a token
188475
-*/
188476
-static int rtreeTokenLength(const char *z){
188477
- int dummy = 0;
188478
- return sqlite3GetToken((const unsigned char*)z,&dummy);
188479
-}
188480
-
188481187939
/*
188482187940
** This function is the implementation of both the xConnect and xCreate
188483187941
** methods of the r-tree virtual table.
188484187942
**
188485187943
** argv[0] -> module name
@@ -188512,12 +187970,12 @@
188512187970
"Too many columns for an rtree table", /* 3 */
188513187971
"Auxiliary rtree columns must be last" /* 4 */
188514187972
};
188515187973
188516187974
assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
188517
- if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){
188518
- *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]);
187975
+ if( argc>RTREE_MAX_AUX_COLUMN+3 ){
187976
+ *pzErr = sqlite3_mprintf("%s", aErrMsg[3]);
188519187977
return SQLITE_ERROR;
188520187978
}
188521187979
188522187980
sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
188523187981
@@ -188541,22 +187999,20 @@
188541187999
/* Create/Connect to the underlying relational database schema. If
188542188000
** that is successful, call sqlite3_declare_vtab() to configure
188543188001
** the r-tree table schema.
188544188002
*/
188545188003
pSql = sqlite3_str_new(db);
188546
- sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT",
188547
- rtreeTokenLength(argv[3]), argv[3]);
188004
+ sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]);
188548188005
for(ii=4; ii<argc; ii++){
188549
- const char *zArg = argv[ii];
188550
- if( zArg[0]=='+' ){
188006
+ if( argv[ii][0]=='+' ){
188551188007
pRtree->nAux++;
188552
- sqlite3_str_appendf(pSql, ",%.*s", rtreeTokenLength(zArg+1), zArg+1);
188008
+ sqlite3_str_appendf(pSql, ",%s", argv[ii]+1);
188553188009
}else if( pRtree->nAux>0 ){
188554188010
break;
188555188011
}else{
188556188012
pRtree->nDim2++;
188557
- sqlite3_str_appendf(pSql, ",%.*s NUM", rtreeTokenLength(zArg), zArg);
188013
+ sqlite3_str_appendf(pSql, ",%s", argv[ii]);
188558188014
}
188559188015
}
188560188016
sqlite3_str_appendf(pSql, ");");
188561188017
zSql = sqlite3_str_finish(pSql);
188562188018
if( !zSql ){
@@ -190500,15 +189956,21 @@
190500189956
Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;
190501189957
RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
190502189958
RtreeNode *pRoot = 0;
190503189959
int rc = SQLITE_OK;
190504189960
int iCell = 0;
189961
+ sqlite3_stmt *pStmt;
190505189962
190506189963
rtreeReference(pRtree);
190507189964
190508189965
/* Reset the cursor to the same state as rtreeOpen() leaves it in. */
190509
- resetCursor(pCsr);
189966
+ freeCursorConstraints(pCsr);
189967
+ sqlite3_free(pCsr->aPoint);
189968
+ pStmt = pCsr->pReadAux;
189969
+ memset(pCsr, 0, sizeof(RtreeCursor));
189970
+ pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
189971
+ pCsr->pReadAux = pStmt;
190510189972
190511189973
pCsr->iStrategy = idxNum;
190512189974
if( idxNum==1 ){
190513189975
/* Special case - lookup by rowid. */
190514189976
RtreeNode *pLeaf; /* Leaf on which the required cell resides */
@@ -197528,11 +196990,11 @@
197528196990
}
197529196991
z += 2;
197530196992
}else{
197531196993
while( *z==0 ) z++;
197532196994
}
197533
- z += (n + 8 + 2);
196995
+ z += (n + 8 + 1);
197534196996
return z;
197535196997
}
197536196998
197537196999
/*
197538197000
** Open an rbu file handle.
@@ -204819,11 +204281,11 @@
204819204281
** the callback, an SQLite error code is returned.
204820204282
**
204821204283
**
204822204284
** xSetAuxdata(pFts5, pAux, xDelete)
204823204285
**
204824
-** Save the pointer passed as the second argument as the extension function's
204286
+** Save the pointer passed as the second argument as the extension functions
204825204287
** "auxiliary data". The pointer may then be retrieved by the current or any
204826204288
** future invocation of the same fts5 extension function made as part of
204827204289
** the same MATCH query using the xGetAuxdata() API.
204828204290
**
204829204291
** Each extension function is allocated a single auxiliary data slot for
@@ -205061,12 +204523,12 @@
205061204523
** all instances of "first place" or "1st place" regardless of which form
205062204524
** the user specified in the MATCH query text.
205063204525
**
205064204526
** There are several ways to approach this in FTS5:
205065204527
**
205066
-** <ol><li> By mapping all synonyms to a single token. In this case, using
205067
-** the above example, this means that the tokenizer returns the
204528
+** <ol><li> By mapping all synonyms to a single token. In this case, the
204529
+** In the above example, this means that the tokenizer returns the
205068204530
** same token for inputs "first" and "1st". Say that token is in
205069204531
** fact "first", so that when the user inserts the document "I won
205070204532
** 1st place" entries are added to the index for tokens "i", "won",
205071204533
** "first" and "place". If the user then queries for '1st + place',
205072204534
** the tokenizer substitutes "first" for "1st" and the query works
@@ -206223,11 +205685,10 @@
206223205685
#define sqlite3Fts5ParserCTX_PARAM
206224205686
#define sqlite3Fts5ParserCTX_FETCH
206225205687
#define sqlite3Fts5ParserCTX_STORE
206226205688
#define fts5YYNSTATE 35
206227205689
#define fts5YYNRULE 28
206228
-#define fts5YYNRULE_WITH_ACTION 28
206229205690
#define fts5YYNFTS5TOKEN 16
206230205691
#define fts5YY_MAX_SHIFT 34
206231205692
#define fts5YY_MIN_SHIFTREDUCE 52
206232205693
#define fts5YY_MAX_SHIFTREDUCE 79
206233205694
#define fts5YY_ERROR_ACTION 80
@@ -207053,19 +206514,16 @@
207053206514
fts5yymsp = fts5yypParser->fts5yytos;
207054206515
#ifndef NDEBUG
207055206516
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
207056206517
fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
207057206518
if( fts5yysize ){
207058
- fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
206519
+ fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
207059206520
fts5yyTracePrompt,
207060
- fts5yyruleno, fts5yyRuleName[fts5yyruleno],
207061
- fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action",
207062
- fts5yymsp[fts5yysize].stateno);
206521
+ fts5yyruleno, fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
207063206522
}else{
207064
- fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n",
207065
- fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno],
207066
- fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action");
206523
+ fprintf(fts5yyTraceFILE, "%sReduce %d [%s].\n",
206524
+ fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno]);
207067206525
}
207068206526
}
207069206527
#endif /* NDEBUG */
207070206528
207071206529
/* Check that the stack is large enough to grow by a single entry
@@ -208820,11 +208278,11 @@
208820208278
208821208279
/* Set stack variable q to the close-quote character */
208822208280
assert( q=='[' || q=='\'' || q=='"' || q=='`' );
208823208281
if( q=='[' ) q = ']';
208824208282
208825
- while( z[iIn] ){
208283
+ while( ALWAYS(z[iIn]) ){
208826208284
if( z[iIn]==q ){
208827208285
if( z[iIn+1]!=q ){
208828208286
/* Character iIn was the close quote. */
208829208287
iIn++;
208830208288
break;
@@ -212149,16 +211607,14 @@
212149211607
}
212150211608
azConfig[0] = 0;
212151211609
azConfig[1] = "main";
212152211610
azConfig[2] = "tbl";
212153211611
for(i=3; iArg<nArg; iArg++){
212154
- const char *z = (const char*)sqlite3_value_text(apVal[iArg]);
212155
- azConfig[i++] = (z ? z : "");
211612
+ azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]);
212156211613
}
212157211614
212158211615
zExpr = (const char*)sqlite3_value_text(apVal[0]);
212159
- if( zExpr==0 ) zExpr = "";
212160211616
212161211617
rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);
212162211618
if( rc==SQLITE_OK ){
212163211619
rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);
212164211620
}
@@ -218404,17 +217860,14 @@
218404217860
int n = 0;
218405217861
int i;
218406217862
for(i=0; i<nChar; i++){
218407217863
if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
218408217864
if( (unsigned char)p[n++]>=0xc0 ){
218409
- if( n>=nByte ) return 0;
217865
+ if( n>=nByte ) break;
218410217866
while( (p[n] & 0xc0)==0x80 ){
218411217867
n++;
218412
- if( n>=nByte ){
218413
- if( i+1==nChar ) break;
218414
- return 0;
218415
- }
217868
+ if( n>=nByte ) break;
218416217869
}
218417217870
}
218418217871
}
218419217872
return n;
218420217873
}
@@ -218812,41 +218265,10 @@
218812218265
218813218266
*pCksum = cksum;
218814218267
return rc;
218815218268
}
218816218269
218817
-/*
218818
-** Check if buffer z[], size n bytes, contains as series of valid utf-8
218819
-** encoded codepoints. If so, return 0. Otherwise, if the buffer does not
218820
-** contain valid utf-8, return non-zero.
218821
-*/
218822
-static int fts5TestUtf8(const char *z, int n){
218823
- assert_nc( n>0 );
218824
- int i = 0;
218825
- while( i<n ){
218826
- if( (z[i] & 0x80)==0x00 ){
218827
- i++;
218828
- }else
218829
- if( (z[i] & 0xE0)==0xC0 ){
218830
- if( i+1>=n || (z[i+1] & 0xC0)!=0x80 ) return 1;
218831
- i += 2;
218832
- }else
218833
- if( (z[i] & 0xF0)==0xE0 ){
218834
- if( i+2>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1;
218835
- i += 3;
218836
- }else
218837
- if( (z[i] & 0xF8)==0xF0 ){
218838
- if( i+3>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1;
218839
- if( (z[i+2] & 0xC0)!=0x80 ) return 1;
218840
- i += 3;
218841
- }else{
218842
- return 1;
218843
- }
218844
- }
218845
-
218846
- return 0;
218847
-}
218848218270
218849218271
/*
218850218272
** This function is also purely an internal test. It does not contribute to
218851218273
** FTS functionality, or even the integrity-check, in any way.
218852218274
*/
@@ -218883,18 +218305,12 @@
218883218305
** the index is disabled are the same. In both ASC and DESC order.
218884218306
**
218885218307
** This check may only be performed if the hash table is empty. This
218886218308
** is because the hash table only supports a single scan query at
218887218309
** a time, and the multi-iter loop from which this function is called
218888
- ** is already performing such a scan.
218889
- **
218890
- ** Also only do this if buffer zTerm contains nTerm bytes of valid
218891
- ** utf-8. Otherwise, the last part of the buffer contents might contain
218892
- ** a non-utf-8 sequence that happens to be a prefix of a valid utf-8
218893
- ** character stored in the main fts index, which will cause the
218894
- ** test to fail. */
218895
- if( p->nPendingData==0 && 0==fts5TestUtf8(zTerm, nTerm) ){
218310
+ ** is already performing such a scan. */
218311
+ if( p->nPendingData==0 ){
218896218312
if( iIdx>0 && rc==SQLITE_OK ){
218897218313
int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;
218898218314
ck2 = 0;
218899218315
rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
218900218316
if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
@@ -219023,12 +218439,12 @@
219023218439
/* Iterate through the b-tree hierarchy. */
219024218440
while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
219025218441
i64 iRow; /* Rowid for this leaf */
219026218442
Fts5Data *pLeaf; /* Data for this leaf */
219027218443
219028
- const char *zIdxTerm = (const char*)sqlite3_column_blob(pStmt, 1);
219029218444
int nIdxTerm = sqlite3_column_bytes(pStmt, 1);
218445
+ const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1);
219030218446
int iIdxLeaf = sqlite3_column_int(pStmt, 2);
219031218447
int bIdxDlidx = sqlite3_column_int(pStmt, 3);
219032218448
219033218449
/* If the leaf in question has already been trimmed from the segment,
219034218450
** ignore this b-tree entry. Otherwise, load it into memory. */
@@ -220611,28 +220027,19 @@
220611220027
case FTS5_PLAN_SORTED_MATCH: {
220612220028
rc = fts5SorterNext(pCsr);
220613220029
break;
220614220030
}
220615220031
220616
- default: {
220617
- Fts5Config *pConfig = ((Fts5Table*)pCursor->pVtab)->pConfig;
220618
- pConfig->bLock++;
220032
+ default:
220619220033
rc = sqlite3_step(pCsr->pStmt);
220620
- pConfig->bLock--;
220621220034
if( rc!=SQLITE_ROW ){
220622220035
CsrFlagSet(pCsr, FTS5CSR_EOF);
220623220036
rc = sqlite3_reset(pCsr->pStmt);
220624
- if( rc!=SQLITE_OK ){
220625
- pCursor->pVtab->zErrMsg = sqlite3_mprintf(
220626
- "%s", sqlite3_errmsg(pConfig->db)
220627
- );
220628
- }
220629220037
}else{
220630220038
rc = SQLITE_OK;
220631220039
}
220632220040
break;
220633
- }
220634220041
}
220635220042
}
220636220043
220637220044
return rc;
220638220045
}
@@ -220913,17 +220320,10 @@
220913220320
char **pzErrmsg = pConfig->pzErrmsg;
220914220321
int i;
220915220322
int iIdxStr = 0;
220916220323
Fts5Expr *pExpr = 0;
220917220324
220918
- if( pConfig->bLock ){
220919
- pTab->p.base.zErrMsg = sqlite3_mprintf(
220920
- "recursively defined fts5 content table"
220921
- );
220922
- return SQLITE_ERROR;
220923
- }
220924
-
220925220325
if( pCsr->ePlan ){
220926220326
fts5FreeCursorComponents(pCsr);
220927220327
memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
220928220328
}
220929220329
@@ -221140,28 +220540,21 @@
221140220540
assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
221141220541
assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
221142220542
}
221143220543
221144220544
if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){
221145
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
221146220545
assert( pCsr->pExpr );
221147220546
sqlite3_reset(pCsr->pStmt);
221148220547
sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));
221149
- pTab->pConfig->bLock++;
221150220548
rc = sqlite3_step(pCsr->pStmt);
221151
- pTab->pConfig->bLock--;
221152220549
if( rc==SQLITE_ROW ){
221153220550
rc = SQLITE_OK;
221154220551
CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);
221155220552
}else{
221156220553
rc = sqlite3_reset(pCsr->pStmt);
221157220554
if( rc==SQLITE_OK ){
221158220555
rc = FTS5_CORRUPT;
221159
- }else if( pTab->pConfig->pzErrmsg ){
221160
- *pTab->pConfig->pzErrmsg = sqlite3_mprintf(
221161
- "%s", sqlite3_errmsg(pTab->pConfig->db)
221162
- );
221163220556
}
221164220557
}
221165220558
}
221166220559
return rc;
221167220560
}
@@ -222173,16 +221566,14 @@
222173221566
if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
222174221567
fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
222175221568
}
222176221569
}
222177221570
}else if( !fts5IsContentless(pTab) ){
222178
- pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
222179221571
rc = fts5SeekCursor(pCsr, 1);
222180221572
if( rc==SQLITE_OK ){
222181221573
sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));
222182221574
}
222183
- pConfig->pzErrmsg = 0;
222184221575
}
222185221576
return rc;
222186221577
}
222187221578
222188221579
@@ -222455,11 +221846,11 @@
222455221846
int nArg, /* Number of args */
222456221847
sqlite3_value **apUnused /* Function arguments */
222457221848
){
222458221849
assert( nArg==0 );
222459221850
UNUSED_PARAM2(nArg, apUnused);
222460
- sqlite3_result_text(pCtx, "fts5: 2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3", -1, SQLITE_TRANSIENT);
221851
+ sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT);
222461221852
}
222462221853
222463221854
/*
222464221855
** Return true if zName is the extension on one of the shadow tables used
222465221856
** by this module.
@@ -223202,15 +222593,14 @@
223202222593
sqlite3Fts5BufferZero(&buf);
223203222594
rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
223204222595
for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
223205222596
ctx.szCol = 0;
223206222597
if( pConfig->abUnindexed[ctx.iCol]==0 ){
223207
- const char *zText = (const char*)sqlite3_column_text(pScan, ctx.iCol+1);
223208
- int nText = sqlite3_column_bytes(pScan, ctx.iCol+1);
223209222598
rc = sqlite3Fts5Tokenize(pConfig,
223210222599
FTS5_TOKENIZE_DOCUMENT,
223211
- zText, nText,
222600
+ (const char*)sqlite3_column_text(pScan, ctx.iCol+1),
222601
+ sqlite3_column_bytes(pScan, ctx.iCol+1),
223212222602
(void*)&ctx,
223213222603
fts5StorageInsertCallback
223214222604
);
223215222605
}
223216222606
sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223328,15 +222718,14 @@
223328222718
rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
223329222719
}
223330222720
for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
223331222721
ctx.szCol = 0;
223332222722
if( pConfig->abUnindexed[ctx.iCol]==0 ){
223333
- const char *zText = (const char*)sqlite3_value_text(apVal[ctx.iCol+2]);
223334
- int nText = sqlite3_value_bytes(apVal[ctx.iCol+2]);
223335222723
rc = sqlite3Fts5Tokenize(pConfig,
223336222724
FTS5_TOKENIZE_DOCUMENT,
223337
- zText, nText,
222725
+ (const char*)sqlite3_value_text(apVal[ctx.iCol+2]),
222726
+ sqlite3_value_bytes(apVal[ctx.iCol+2]),
223338222727
(void*)&ctx,
223339222728
fts5StorageInsertCallback
223340222729
);
223341222730
}
223342222731
sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223501,15 +222890,14 @@
223501222890
ctx.szCol = 0;
223502222891
if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
223503222892
rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
223504222893
}
223505222894
if( rc==SQLITE_OK ){
223506
- const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
223507
- int nText = sqlite3_column_bytes(pScan, i+1);
223508222895
rc = sqlite3Fts5Tokenize(pConfig,
223509222896
FTS5_TOKENIZE_DOCUMENT,
223510
- zText, nText,
222897
+ (const char*)sqlite3_column_text(pScan, i+1),
222898
+ sqlite3_column_bytes(pScan, i+1),
223511222899
(void*)&ctx,
223512222900
fts5StorageIntegrityCallback
223513222901
);
223514222902
}
223515222903
if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
@@ -227228,12 +226616,12 @@
227228226616
}
227229226617
#endif /* SQLITE_CORE */
227230226618
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
227231226619
227232226620
/************** End of stmt.c ************************************************/
227233
-#if __LINE__!=227233
226621
+#if __LINE__!=226621
227234226622
#undef SQLITE_SOURCE_ID
227235
-#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1befalt2"
226623
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2"
227236226624
#endif
227237226625
/* Return the source-id for this library */
227238226626
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
227239226627
/************************** End of sqlite3.c ******************************/
227240226628
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1165,11 +1165,11 @@
1165 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1166 ** [sqlite_version()] and [sqlite_source_id()].
1167 */
1168 #define SQLITE_VERSION "3.31.0"
1169 #define SQLITE_VERSION_NUMBER 3031000
1170 #define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3"
1171
1172 /*
1173 ** CAPI3REF: Run-Time Library Version Numbers
1174 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1175 **
@@ -1581,11 +1581,10 @@
1581 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
1582 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
1583 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
1584 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
1585 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
1586 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
1587
1588 /*
1589 ** CAPI3REF: Flags For File Open Operations
1590 **
1591 ** These bit values are intended for use in the
@@ -2022,20 +2021,20 @@
2022 **
2023 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
2024 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
2025 ** file-control may be invoked by SQLite on the database file handle
2026 ** shortly after it is opened in order to provide a custom VFS with access
2027 ** to the connection's busy-handler callback. The argument is of type (void**)
2028 ** - an array of two (void *) values. The first (void *) actually points
2029 ** to a function of type (int (*)(void *)). In order to invoke the connection's
2030 ** busy-handler, this function should be invoked with the second (void *) in
2031 ** the array as the only argument. If it returns non-zero, then the operation
2032 ** should be retried. If it returns zero, the custom VFS should abandon the
2033 ** current operation.
2034 **
2035 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
2036 ** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
2037 ** to have SQLite generate a
2038 ** temporary filename using the same algorithm that is followed to generate
2039 ** temporary filenames for TEMP tables and other internal uses. The
2040 ** argument should be a char** which will be filled with the filename
2041 ** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -2144,11 +2143,11 @@
2144 ** interface can be used to find if any database on the connection has changed,
2145 ** but that interface responds to changes on TEMP as well as MAIN and does
2146 ** not provide a mechanism to detect changes to MAIN only. Also, the
2147 ** [sqlite3_total_changes()] interface responds to internal changes only and
2148 ** omits changes made by other database connections. The
2149 ** [PRAGMA data_version] command provides a mechanism to detect changes to
2150 ** a single attached database that occur due to other database connections,
2151 ** but omits changes implemented by the database connection on which it is
2152 ** called. This file control is the only mechanism to detect changes that
2153 ** happen either internally or externally and that are associated with
2154 ** a particular attached database.
@@ -2232,14 +2231,14 @@
2232 ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
2233 ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
2234 ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
2235 ** may be appended to the sqlite3_vfs object and the iVersion value
2236 ** may increase again in future versions of SQLite.
2237 ** Note that due to an oversight, the structure
2238 ** of the sqlite3_vfs object changed in the transition from
2239 ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
2240 ** and yet the iVersion field was not increased.
2241 **
2242 ** The szOsFile field is the size of the subclassed [sqlite3_file]
2243 ** structure used by this VFS. mxPathname is the maximum length of
2244 ** a pathname in this VFS.
2245 **
@@ -2326,11 +2325,11 @@
2326 ** be created, and that it is an error if it already exists.
2327 ** It is <i>not</i> used to indicate the file should be opened
2328 ** for exclusive access.
2329 **
2330 ** ^At least szOsFile bytes of memory are allocated by SQLite
2331 ** to hold the [sqlite3_file] structure passed as the third
2332 ** argument to xOpen. The xOpen method does not have to
2333 ** allocate the structure; it should just fill it in. Note that
2334 ** the xOpen method must set the sqlite3_file.pMethods to either
2335 ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
2336 ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -2449,10 +2448,11 @@
2449 ** SQLite.
2450 */
2451 #define SQLITE_ACCESS_EXISTS 0
2452 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
2453 #define SQLITE_ACCESS_READ 2 /* Unused */
 
2454
2455 /*
2456 ** CAPI3REF: Flags for the xShmLock VFS method
2457 **
2458 ** These integer constants define the various locking operations
@@ -2663,11 +2663,11 @@
2663 ** Every memory allocation request coming in through [sqlite3_malloc()]
2664 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
2665 ** that causes the corresponding memory allocation to fail.
2666 **
2667 ** The xInit method initializes the memory allocator. For example,
2668 ** it might allocate any required mutexes or initialize internal data
2669 ** structures. The xShutdown method is invoked (indirectly) by
2670 ** [sqlite3_shutdown()] and should deallocate any resources acquired
2671 ** by xInit. The pAppData pointer is used as the only parameter to
2672 ** xInit and xShutdown.
2673 **
@@ -2804,11 +2804,11 @@
2804 **
2805 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
2806 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
2807 ** that SQLite can use for the database page cache with the default page
2808 ** cache implementation.
2809 ** This configuration option is a no-op if an application-defined page
2810 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
2811 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
2812 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
2813 ** and the number of cache lines (N).
2814 ** The sz argument should be the size of the largest database page
@@ -3289,11 +3289,11 @@
3289 ** </dd>
3290 **
3291 ** [[SQLITE_DBCONFIG_DQS_DML]]
3292 ** <dt>SQLITE_DBCONFIG_DQS_DML</td>
3293 ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
3294 ** the legacy [double-quoted string literal] misfeature for DML statements
3295 ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
3296 ** default value of this setting is determined by the [-DSQLITE_DQS]
3297 ** compile-time option.
3298 ** </dd>
3299 **
@@ -3550,11 +3550,11 @@
3550 ** will be rolled back automatically.
3551 **
3552 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
3553 ** SQL statements on [database connection] D complete. ^Any new SQL statements
3554 ** that are started after the sqlite3_interrupt() call and before the
3555 ** running statement count reaches zero are interrupted as if they had been
3556 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
3557 ** that are started after the running statement count reaches zero are
3558 ** not effected by the sqlite3_interrupt().
3559 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
3560 ** SQL statements is a no-op and has no effect on SQL statements
@@ -3718,13 +3718,13 @@
3718 ** Alice | 43
3719 ** Bob | 28
3720 ** Cindy | 21
3721 ** </pre></blockquote>
3722 **
3723 ** There are two columns (M==2) and three rows (N==3). Thus the
3724 ** result table has 8 entries. Suppose the result table is stored
3725 ** in an array named azResult. Then azResult holds this content:
3726 **
3727 ** <blockquote><pre>
3728 ** azResult&#91;0] = "Name";
3729 ** azResult&#91;1] = "Age";
3730 ** azResult&#91;2] = "Alice";
@@ -3873,10 +3873,23 @@
3873 ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
3874 ** sqlite3_malloc64(), and sqlite3_realloc64()
3875 ** is always aligned to at least an 8 byte boundary, or to a
3876 ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
3877 ** option is used.
 
 
 
 
 
 
 
 
 
 
 
 
 
3878 **
3879 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
3880 ** must be either NULL or else pointers obtained from a prior
3881 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
3882 ** not yet been released.
@@ -3922,11 +3935,11 @@
3922 ** CAPI3REF: Pseudo-Random Number Generator
3923 **
3924 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
3925 ** select random [ROWID | ROWIDs] when inserting new records into a table that
3926 ** already uses the largest possible [ROWID]. The PRNG is also used for
3927 ** the built-in random() and randomblob() SQL functions. This interface allows
3928 ** applications to access the same PRNG for other purposes.
3929 **
3930 ** ^A call to this routine stores N bytes of randomness into buffer P.
3931 ** ^The P parameter can be a NULL pointer.
3932 **
@@ -4523,11 +4536,11 @@
4523 ** a VFS implementation when the flags parameter to xOpen() has one or
4524 ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
4525 ** P is the name of the query parameter, then
4526 ** sqlite3_uri_parameter(F,P) returns the value of the P
4527 ** parameter if it exists or a NULL pointer if P does not appear as a
4528 ** query parameter on F. If P is a query parameter of F and it
4529 ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
4530 ** a pointer to an empty string.
4531 **
4532 ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
4533 ** parameter and returns true (1) or false (0) according to the value
@@ -4535,11 +4548,11 @@
4535 ** value of query parameter P is one of "yes", "true", or "on" in any
4536 ** case or if the value begins with a non-zero number. The
4537 ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
4538 ** query parameter P is one of "no", "false", or "off" in any case or
4539 ** if the value begins with a numeric zero. If P is not a query
4540 ** parameter on F or if the value of P does not match any of the
4541 ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
4542 **
4543 ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
4544 ** 64-bit signed integer and returns that integer, or D if P does not
4545 ** exist. If the value of P is something other than an integer, then
@@ -4872,16 +4885,16 @@
4872 ** in order to find the underlying cause of the problem. With the "v2" prepare
4873 ** interfaces, the underlying reason for the error is returned immediately.
4874 ** </li>
4875 **
4876 ** <li>
4877 ** ^If the specific value bound to a [parameter | host parameter] in the
4878 ** WHERE clause might influence the choice of query plan for a statement,
4879 ** then the statement will be automatically recompiled, as if there had been
4880 ** a schema change, on the first [sqlite3_step()] call following any change
4881 ** to the [sqlite3_bind_text | bindings] of that [parameter].
4882 ** ^The specific value of a WHERE-clause [parameter] might influence the
4883 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4884 ** or [GLOB] operator or if the parameter is compared to an indexed column
4885 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
4886 ** </li>
4887 ** </ol>
@@ -5386,19 +5399,23 @@
5386 ** the statement, where N is the second function argument.
5387 ** ^The left-most column is column 0 for these routines.
5388 **
5389 ** ^If the Nth column returned by the statement is an expression or
5390 ** subquery and is not a column value, then all of these functions return
5391 ** NULL. ^These routines might also return NULL if a memory allocation error
5392 ** occurs. ^Otherwise, they return the name of the attached database, table,
5393 ** or column that query result column was extracted from.
5394 **
5395 ** ^As with all other SQLite APIs, those whose names end with "16" return
5396 ** UTF-16 encoded strings and the other functions return UTF-8.
5397 **
5398 ** ^These APIs are only available if the library was compiled with the
5399 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
 
 
 
 
5400 **
5401 ** If two or more threads call one or more
5402 ** [sqlite3_column_database_name | column metadata interfaces]
5403 ** for the same [prepared statement] and result column
5404 ** at the same time then the results are undefined.
@@ -5532,11 +5549,11 @@
5532 ** METHOD: sqlite3_stmt
5533 **
5534 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
5535 ** current row of the result set of [prepared statement] P.
5536 ** ^If prepared statement P does not have results ready to return
5537 ** (via calls to the [sqlite3_column_int | sqlite3_column()] family of
5538 ** interfaces) then sqlite3_data_count(P) returns 0.
5539 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
5540 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
5541 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
5542 ** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -6034,16 +6051,13 @@
6034 ** These constants may be ORed together with the
6035 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
6036 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
6037 ** [sqlite3_create_function_v2()].
6038 **
6039 ** The SQLITE_DETERMINISTIC flag means that the new function always gives
6040 ** the same output when the input parameters are the same. The abs() function
6041 ** is deterministic, for example, but randomblob() is not. Functions must
6042 ** be deterministic in order to be used in certain contexts such as
6043 ** [CHECK constraints] or [generated columns]. SQLite might also optimize
6044 ** deterministic functions by factoring them out of inner loops.
6045 **
6046 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
6047 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
6048 ** a security feature which is recommended for all
6049 ** [application-defined SQL functions] that have side-effects. This flag
@@ -6118,12 +6132,12 @@
6118 **
6119 ** <b>Details:</b>
6120 **
6121 ** These routines extract type, size, and content information from
6122 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
6123 ** are used to pass parameter information into the functions that
6124 ** implement [application-defined SQL functions] and [virtual tables].
6125 **
6126 ** These routines work only with [protected sqlite3_value] objects.
6127 ** Any attempt to use these routines on an [unprotected sqlite3_value]
6128 ** is not threadsafe.
6129 **
@@ -6176,11 +6190,11 @@
6176 ** the return value is arbitrary and meaningless.
6177 **
6178 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
6179 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
6180 ** interfaces. ^If X comes from an SQL literal value, or a table column,
6181 ** or an expression, then sqlite3_value_frombind(X) returns zero.
6182 **
6183 ** Please pay particular attention to the fact that the pointer returned
6184 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
6185 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
6186 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6262,12 +6276,12 @@
6262 **
6263 ** Implementations of aggregate SQL functions use this
6264 ** routine to allocate memory for storing their state.
6265 **
6266 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
6267 ** for a particular aggregate function, SQLite allocates
6268 ** N bytes of memory, zeroes out that memory, and returns a pointer
6269 ** to the new memory. ^On second and subsequent calls to
6270 ** sqlite3_aggregate_context() for the same aggregate function instance,
6271 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
6272 ** called once for each invocation of the xStep callback and then one
6273 ** last time when the xFinal callback is invoked. ^(When no rows match
@@ -6280,11 +6294,11 @@
6280 ** when first called if N is less than or equal to zero or if a memory
6281 ** allocate error occurs.
6282 **
6283 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6284 ** determined by the N parameter on first successful call. Changing the
6285 ** value of N in any subsequents call to sqlite3_aggregate_context() within
6286 ** the same aggregate function instance will not resize the memory
6287 ** allocation.)^ Within the xFinal callback, it is customary to set
6288 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6289 ** pointless memory allocations occur.
6290 **
@@ -6628,11 +6642,11 @@
6628 ** <li> If A&lt;B THEN B&gt;A.
6629 ** <li> If A&lt;B and B&lt;C then A&lt;C.
6630 ** </ol>
6631 **
6632 ** If a collating function fails any of the above constraints and that
6633 ** collating function is registered and used, then the behavior of SQLite
6634 ** is undefined.
6635 **
6636 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
6637 ** with the addition that the xDestroy callback is invoked on pArg when
6638 ** the collating function is deleted.
@@ -6955,20 +6969,16 @@
6955
6956 /*
6957 ** CAPI3REF: Return The Filename For A Database Connection
6958 ** METHOD: sqlite3
6959 **
6960 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename
6961 ** associated with database N of connection D.
6962 ** ^If there is no attached database N on the database
6963 ** connection D, or if database N is a temporary or in-memory database, then
6964 ** this function will return either a NULL pointer or an empty string.
6965 **
6966 ** ^The string value returned by this routine is owned and managed by
6967 ** the database connection. ^The value will be valid until the database N
6968 ** is [DETACH]-ed or until the database connection closes.
6969 **
6970 ** ^The filename returned by this function is the output of the
6971 ** xFullPathname method of the [VFS]. ^In other words, the filename
6972 ** will be an absolute pathname, even if the filename used
6973 ** to open the database originally was a URI or relative pathname.
6974 */
@@ -7118,23 +7128,19 @@
7118 ** In prior versions of SQLite,
7119 ** sharing was enabled or disabled for each thread separately.
7120 **
7121 ** ^(The cache sharing mode set by this interface effects all subsequent
7122 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
7123 ** Existing database connections continue to use the sharing mode
7124 ** that was in effect at the time they were opened.)^
7125 **
7126 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
7127 ** successfully. An [error code] is returned otherwise.)^
7128 **
7129 ** ^Shared cache is disabled by default. It is recommended that it stay
7130 ** that way. In other words, do not use this routine. This interface
7131 ** continues to be provided for historical compatibility, but its use is
7132 ** discouraged. Any use of shared cache is discouraged. If shared cache
7133 ** must be used, it is recommended that shared cache only be enabled for
7134 ** individual database connections using the [sqlite3_open_v2()] interface
7135 ** with the [SQLITE_OPEN_SHAREDCACHE] flag.
7136 **
7137 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
7138 ** and will always return SQLITE_MISUSE. On those systems,
7139 ** shared cache mode should be enabled per-database connection via
7140 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -7263,11 +7269,11 @@
7263 ** information about column C of table T in database D
7264 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
7265 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
7266 ** the final five arguments with appropriate values if the specified
7267 ** column exists. ^The sqlite3_table_column_metadata() interface returns
7268 ** SQLITE_ERROR if the specified column does not exist.
7269 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
7270 ** NULL pointer, then this routine simply checks for the existence of the
7271 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
7272 ** does not. If the table name parameter T in a call to
7273 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -7405,11 +7411,11 @@
7405 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
7406 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
7407 ** to enable or disable only the C-API.)^
7408 **
7409 ** <b>Security warning:</b> It is recommended that extension loading
7410 ** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
7411 ** rather than this interface, so the [load_extension()] SQL function
7412 ** remains disabled. This will prevent SQL injections from giving attackers
7413 ** access to extension loading capabilities.
7414 */
7415 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -7492,11 +7498,11 @@
7492 /*
7493 ** CAPI3REF: Virtual Table Object
7494 ** KEYWORDS: sqlite3_module {virtual table module}
7495 **
7496 ** This structure, sometimes called a "virtual table module",
7497 ** defines the implementation of a [virtual table].
7498 ** This structure consists mostly of methods for the module.
7499 **
7500 ** ^A virtual table module is created by filling in a persistent
7501 ** instance of this structure and passing a pointer to that instance
7502 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -7589,17 +7595,11 @@
7589 ** The [xBestIndex] method must fill aConstraintUsage[] with information
7590 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
7591 ** the right-hand side of the corresponding aConstraint[] is evaluated
7592 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7593 ** is true, then the constraint is assumed to be fully handled by the
7594 ** virtual table and might not be checked again by the byte code.)^ ^(The
7595 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
7596 ** is left in its default setting of false, the constraint will always be
7597 ** checked separately in byte code. If the omit flag is change to true, then
7598 ** the constraint may or may not be checked in byte code. In other words,
7599 ** when the omit flag is true there is no guarantee that the constraint will
7600 ** not be checked again using byte code.)^
7601 **
7602 ** ^The idxNum and idxPtr values are recorded and passed into the
7603 ** [xFilter] method.
7604 ** ^[sqlite3_free()] is used to free idxPtr if and only if
7605 ** needToFreeIdxPtr is true.
@@ -7635,11 +7635,11 @@
7635 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
7636 ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
7637 ** If a virtual table extension is
7638 ** used with an SQLite version earlier than 3.8.2, the results of attempting
7639 ** to read or write the estimatedRows field are undefined (but are likely
7640 ** to include crashing the application). The estimatedRows field should
7641 ** therefore only be used if [sqlite3_libversion_number()] returns a
7642 ** value greater than or equal to 3008002. Similarly, the idxFlags field
7643 ** was added for [version 3.9.0] ([dateof:3.9.0]).
7644 ** It may therefore only be used if
7645 ** sqlite3_libversion_number() returns a value greater than or equal to
@@ -7687,11 +7687,11 @@
7687 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
7688
7689 /*
7690 ** CAPI3REF: Virtual Table Constraint Operator Codes
7691 **
7692 ** These macros define the allowed values for the
7693 ** [sqlite3_index_info].aConstraint[].op field. Each value represents
7694 ** an operator that is part of a constraint term in the wHERE clause of
7695 ** a query that uses a [virtual table].
7696 */
7697 #define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -8297,11 +8297,11 @@
8297 ** </ul>)^
8298 **
8299 ** The only difference is that the public sqlite3_XXX functions enumerated
8300 ** above silently ignore any invocations that pass a NULL pointer instead
8301 ** of a valid mutex handle. The implementations of the methods defined
8302 ** by this structure are not required to handle this case. The results
8303 ** of passing a NULL pointer instead of a valid mutex handle are undefined
8304 ** (i.e. it is acceptable to provide an implementation that segfaults if
8305 ** it is passed a NULL pointer).
8306 **
8307 ** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -8770,11 +8770,11 @@
8770 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
8771 ** no space was left in the page cache.</dd>)^
8772 **
8773 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
8774 ** <dd>This parameter records the largest memory allocation request
8775 ** handed to the [pagecache memory allocator]. Only the value returned in the
8776 ** *pHighwater parameter to [sqlite3_status()] is of interest.
8777 ** The value written into the *pCurrent parameter is undefined.</dd>)^
8778 **
8779 ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
8780 ** <dd>No longer used.</dd>
@@ -8846,11 +8846,11 @@
8846 ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
8847 ** <dd>This parameter returns the number of lookaside memory slots currently
8848 ** checked out.</dd>)^
8849 **
8850 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
8851 ** <dd>This parameter returns the number of malloc attempts that were
8852 ** satisfied using lookaside memory. Only the high-water value is meaningful;
8853 ** the current value is always zero.)^
8854 **
8855 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
8856 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -8928,11 +8928,11 @@
8928 ** <dd>This parameter returns the number of dirty cache entries that have
8929 ** been written to disk in the middle of a transaction due to the page
8930 ** cache overflowing. Transactions are more efficient if they are written
8931 ** to disk all at once. When pages spill mid-transaction, that introduces
8932 ** additional overhead. This parameter can be used help identify
8933 ** inefficiencies that can be resolved by increasing the cache size.
8934 ** </dd>
8935 **
8936 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
8937 ** <dd>This parameter returns zero for the current value if and only if
8938 ** all foreign key constraints (deferred or immediate) have been
@@ -9017,11 +9017,11 @@
9017 ** If the number of virtual machine operations exceeds 2147483647
9018 ** then the value returned by this statement status code is undefined.
9019 **
9020 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
9021 ** <dd>^This is the number of times that the prepare statement has been
9022 ** automatically regenerated due to schema changes or changes to
9023 ** [bound parameters] that might affect the query plan.
9024 **
9025 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
9026 ** <dd>^This is the number of times that the prepared statement has
9027 ** been run. A single "run" for the purposes of this counter is one
@@ -9188,11 +9188,11 @@
9188 ** NULL if allocating a new page is effectively impossible.
9189 ** </table>
9190 **
9191 ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
9192 ** will only use a createFlag of 2 after a prior call with a createFlag of 1
9193 ** failed.)^ In between the xFetch() calls, SQLite may
9194 ** attempt to unpin one or more cache pages by spilling the content of
9195 ** pinned pages to disk and synching the operating system disk cache.
9196 **
9197 ** [[the xUnpin() page cache method]]
9198 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -9506,11 +9506,11 @@
9506 ** application receives an SQLITE_LOCKED error, it may call the
9507 ** sqlite3_unlock_notify() method with the blocked connection handle as
9508 ** the first argument to register for a callback that will be invoked
9509 ** when the blocking connections current transaction is concluded. ^The
9510 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
9511 ** call that concludes the blocking connection's transaction.
9512 **
9513 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
9514 ** there is a chance that the blocking connection will have already
9515 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
9516 ** If this happens, then the specified callback is invoked immediately,
@@ -9544,11 +9544,11 @@
9544 ** However, the signature of the callback function allows SQLite to pass
9545 ** it an array of void* context pointers. The first argument passed to
9546 ** an unlock-notify callback is a pointer to an array of void* pointers,
9547 ** and the second is the number of entries in the array.
9548 **
9549 ** When a blocking connection's transaction is concluded, there may be
9550 ** more than one blocked connection that has registered for an unlock-notify
9551 ** callback. ^If two or more such blocked connections have specified the
9552 ** same callback function, then instead of invoking the callback function
9553 ** multiple times, it is invoked once with the set of void* context pointers
9554 ** specified by the blocked connections bundled together into an array.
@@ -10018,37 +10018,37 @@
10018 ** managed by the prepared statement S and will be automatically freed when
10019 ** S is finalized.
10020 **
10021 ** <dl>
10022 ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
10023 ** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be
10024 ** set to the total number of times that the X-th loop has run.</dd>
10025 **
10026 ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
10027 ** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set
10028 ** to the total number of rows examined by all iterations of the X-th loop.</dd>
10029 **
10030 ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
10031 ** <dd>^The "double" variable pointed to by the V parameter will be set to the
10032 ** query planner's estimate for the average number of rows output from each
10033 ** iteration of the X-th loop. If the query planner's estimates was accurate,
10034 ** then this value will approximate the quotient NVISIT/NLOOP and the
10035 ** product of this value for all prior loops with the same SELECTID will
10036 ** be the NLOOP value for the current loop.
10037 **
10038 ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
10039 ** <dd>^The "const char *" variable pointed to by the V parameter will be set
10040 ** to a zero-terminated UTF-8 string containing the name of the index or table
10041 ** used for the X-th loop.
10042 **
10043 ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
10044 ** <dd>^The "const char *" variable pointed to by the V parameter will be set
10045 ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
10046 ** description for the X-th loop.
10047 **
10048 ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
10049 ** <dd>^The "int" variable pointed to by the V parameter will be set to the
10050 ** "select-id" for the X-th loop. The select-id identifies which query or
10051 ** subquery the loop is part of. The main query has a select-id of zero.
10052 ** The select-id is the same value as is output in the first column
10053 ** of an [EXPLAIN QUERY PLAN] query.
10054 ** </dl>
@@ -10899,11 +10899,11 @@
10899 ** METHOD: sqlite3_session
10900 **
10901 ** The second argument (xFilter) is the "filter callback". For changes to rows
10902 ** in tables that are not attached to the Session object, the filter is called
10903 ** to determine whether changes to the table's rows should be tracked or not.
10904 ** If xFilter returns 0, changes are not tracked. Note that once a table is
10905 ** attached, xFilter will not be called again.
10906 */
10907 SQLITE_API void sqlite3session_table_filter(
10908 sqlite3_session *pSession, /* Session object */
10909 int(*xFilter)(
@@ -11073,11 +11073,11 @@
11073 ** identical.
11074 **
11075 ** It an error if database zFrom does not exist or does not contain the
11076 ** required compatible table.
11077 **
11078 ** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
11079 ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
11080 ** may be set to point to a buffer containing an English language error
11081 ** message. It is the responsibility of the caller to free this buffer using
11082 ** sqlite3_free().
11083 */
@@ -11210,11 +11210,11 @@
11210
11211 /*
11212 ** CAPI3REF: Advance A Changeset Iterator
11213 ** METHOD: sqlite3_changeset_iter
11214 **
11215 ** This function may only be used with iterators created by the function
11216 ** [sqlite3changeset_start()]. If it is called on an iterator passed to
11217 ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
11218 ** is returned and the call has no effect.
11219 **
11220 ** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -11626,12 +11626,12 @@
11626 ** in the changegroup, then the number of columns and the position of the
11627 ** primary key columns for the table must be consistent. If this is not the
11628 ** case, this function fails with SQLITE_SCHEMA. If the input changeset
11629 ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
11630 ** returned. Or, if an out-of-memory condition occurs during processing, this
11631 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state
11632 ** of the final contents of the changegroup is undefined.
11633 **
11634 ** If no error occurs, SQLITE_OK is returned.
11635 */
11636 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
11637
@@ -11802,11 +11802,11 @@
11802 ** [SQLITE_CHANGESET_REPLACE].
11803 ** </dl>
11804 **
11805 ** It is safe to execute SQL statements, including those that write to the
11806 ** table that the callback related to, from within the xConflict callback.
11807 ** This can be used to further customize the application's conflict
11808 ** resolution strategy.
11809 **
11810 ** All changes made by these functions are enclosed in a savepoint transaction.
11811 ** If any other error (aside from a constraint failure when attempting to
11812 ** write to the target database) occurs, then the savepoint transaction is
@@ -12112,11 +12112,11 @@
12112 ** CAPI3REF: Rebase a changeset
12113 ** EXPERIMENTAL
12114 **
12115 ** Argument pIn must point to a buffer containing a changeset nIn bytes
12116 ** in size. This function allocates and populates a buffer with a copy
12117 ** of the changeset rebased according to the configuration of the
12118 ** rebaser object passed as the first argument. If successful, (*ppOut)
12119 ** is set to point to the new buffer containing the rebased changeset and
12120 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
12121 ** responsibility of the caller to eventually free the new buffer using
12122 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -12520,11 +12520,11 @@
12520 ** the callback, an SQLite error code is returned.
12521 **
12522 **
12523 ** xSetAuxdata(pFts5, pAux, xDelete)
12524 **
12525 ** Save the pointer passed as the second argument as the extension function's
12526 ** "auxiliary data". The pointer may then be retrieved by the current or any
12527 ** future invocation of the same fts5 extension function made as part of
12528 ** the same MATCH query using the xGetAuxdata() API.
12529 **
12530 ** Each extension function is allocated a single auxiliary data slot for
@@ -12762,12 +12762,12 @@
12762 ** all instances of "first place" or "1st place" regardless of which form
12763 ** the user specified in the MATCH query text.
12764 **
12765 ** There are several ways to approach this in FTS5:
12766 **
12767 ** <ol><li> By mapping all synonyms to a single token. In this case, using
12768 ** the above example, this means that the tokenizer returns the
12769 ** same token for inputs "first" and "1st". Say that token is in
12770 ** fact "first", so that when the user inserts the document "I won
12771 ** 1st place" entries are added to the index for tokens "i", "won",
12772 ** "first" and "place". If the user then queries for '1st + place',
12773 ** the tokenizer substitutes "first" for "1st" and the query works
@@ -13435,30 +13435,10 @@
13435 #else
13436 # define ALWAYS(X) (X)
13437 # define NEVER(X) (X)
13438 #endif
13439
13440 /*
13441 ** The harmless(X) macro indicates that expression X is usually false
13442 ** but can be true without causing any problems, but we don't know of
13443 ** any way to cause X to be true.
13444 **
13445 ** In debugging and testing builds, this macro will abort if X is ever
13446 ** true. In this way, developers are alerted to a possible test case
13447 ** that causes X to be true. If a harmless macro ever fails, that is
13448 ** an opportunity to change the macro into a testcase() and add a new
13449 ** test case to the test suite.
13450 **
13451 ** For normal production builds, harmless(X) is a no-op, since it does
13452 ** not matter whether expression X is true or false.
13453 */
13454 #ifdef SQLITE_DEBUG
13455 # define harmless(X) assert(!(X));
13456 #else
13457 # define harmless(X)
13458 #endif
13459
13460 /*
13461 ** Some conditionals are optimizations only. In other words, if the
13462 ** conditionals are replaced with a constant 1 (true) or 0 (false) then
13463 ** the correct answer is still obtained, though perhaps not as quickly.
13464 **
@@ -15169,14 +15149,13 @@
15169 #define OP_VRename 163
15170 #define OP_Pagecount 164
15171 #define OP_MaxPgcnt 165
15172 #define OP_Trace 166
15173 #define OP_CursorHint 167
15174 #define OP_ReleaseReg 168 /* synopsis: release r[P1@P2] mask P3 */
15175 #define OP_Noop 169
15176 #define OP_Explain 170
15177 #define OP_Abortable 171
15178
15179 /* Properties such as "out2" or "jump" that are specified in
15180 ** comments following the "case" for each opcode in the vdbe.c
15181 ** are encoded into bitvectors as follows:
15182 */
@@ -15206,11 +15185,11 @@
15206 /* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\
15207 /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15208 /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\
15209 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15210 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15211 /* 168 */ 0x00, 0x00, 0x00, 0x00,}
15212
15213 /* The sqlite3P2Values() routine is able to run faster if it knows
15214 ** the value of the largest JUMP opcode. The smaller the maximum
15215 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15216 ** generated this include file strives to group all JUMP opcodes
@@ -15283,15 +15262,10 @@
15283 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
15284 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
15285 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
15286 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
15287 SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
15288 #ifdef SQLITE_DEBUG
15289 SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask);
15290 #else
15291 # define sqlite3VdbeReleaseRegisters(P,A,N,M)
15292 #endif
15293 SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
15294 SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
15295 SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
15296 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
15297 SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
@@ -16867,10 +16841,16 @@
16867 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16868 pArg, 0, xFunc, 0, 0, 0, #zName, }
16869 #define LIKEFUNC(zName, nArg, arg, flags) \
16870 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
16871 (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
 
 
 
 
 
 
16872 #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
16873 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
16874 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
16875 #define INTERNAL_FUNCTION(zName, nArg, xFunc) \
16876 {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
@@ -17998,17 +17978,17 @@
17998 ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences
17999 ** for the result set. The KeyInfo for addrOpenEphm[2] contains collating
18000 ** sequences for the ORDER BY clause.
18001 */
18002 struct Select {
 
18003 u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
18004 LogEst nSelectRow; /* Estimated number of result rows */
18005 u32 selFlags; /* Various SF_* values */
18006 int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
18007 u32 selId; /* Unique identifier number for this SELECT */
18008 int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
18009 ExprList *pEList; /* The fields of the result */
18010 SrcList *pSrc; /* The FROM clause */
18011 Expr *pWhere; /* The WHERE clause */
18012 ExprList *pGroupBy; /* The GROUP BY clause */
18013 Expr *pHaving; /* The HAVING clause */
18014 ExprList *pOrderBy; /* The ORDER BY clause */
@@ -18050,11 +18030,10 @@
18050 #define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
18051 #define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
18052 #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18053 #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18054 #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18055 #define SF_View 0x0200000 /* SELECT statement is a view */
18056
18057 /*
18058 ** The results of a SELECT can be distributed in several ways, as defined
18059 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18060 ** Type".
@@ -18330,12 +18309,12 @@
18330 #endif
18331 };
18332
18333 #define PARSE_MODE_NORMAL 0
18334 #define PARSE_MODE_DECLARE_VTAB 1
18335 #define PARSE_MODE_RENAME 2
18336 #define PARSE_MODE_UNMAP 3
18337
18338 /*
18339 ** Sizes and pointers of various parts of the Parse object.
18340 */
18341 #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -18353,11 +18332,11 @@
18353 #endif
18354
18355 #if defined(SQLITE_OMIT_ALTERTABLE)
18356 #define IN_RENAME_OBJECT 0
18357 #else
18358 #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME)
18359 #endif
18360
18361 #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
18362 #define IN_SPECIAL_PARSE 0
18363 #else
@@ -19172,11 +19151,10 @@
19172 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
19173 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
19174 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
19175 Expr*,ExprList*,u32,Expr*);
19176 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
19177 SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*);
19178 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
19179 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
19180 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
19181 #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
19182 SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -20756,11 +20734,11 @@
20756 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
20757 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
20758 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
20759 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
20760 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
20761 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
20762 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
20763 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
20764 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
20765 #ifndef SQLITE_OMIT_WINDOWFUNC
20766 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
@@ -22676,11 +22654,11 @@
22676 DO_OS_MALLOC_TEST(0);
22677 /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
22678 ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
22679 ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
22680 ** reaching the VFS. */
22681 rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut);
22682 assert( rc==SQLITE_OK || pFile->pMethods==0 );
22683 return rc;
22684 }
22685 SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
22686 DO_OS_MALLOC_TEST(0);
@@ -29311,13 +29289,12 @@
29311 zOp2[0] = 0;
29312 }
29313 sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s",
29314 pExpr->iColumn, zFlgs, zOp2);
29315 }else{
29316 sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s",
29317 pExpr->iTable, pExpr->iColumn,
29318 pExpr->y.pTab, zFlgs);
29319 }
29320 if( ExprHasProperty(pExpr, EP_FixedCol) ){
29321 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
29322 }
29323 break;
@@ -30984,11 +30961,11 @@
30984 #pragma warning(disable : 4756)
30985 #endif
30986 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
30987 #ifndef SQLITE_OMIT_FLOATING_POINT
30988 int incr;
30989 const char *zEnd;
30990 /* sign * significand * (10 ^ (esign * exponent)) */
30991 int sign = 1; /* sign of significand */
30992 i64 s = 0; /* significand */
30993 int d = 0; /* adjust exponent for shifting decimal point */
30994 int esign = 1; /* sign of exponent */
@@ -30998,15 +30975,13 @@
30998 int nDigit = 0; /* Number of digits processed */
30999 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
31000
31001 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
31002 *pResult = 0.0; /* Default return value, in case of an error */
31003 if( length==0 ) return 0;
31004
31005 if( enc==SQLITE_UTF8 ){
31006 incr = 1;
31007 zEnd = z + length;
31008 }else{
31009 int i;
31010 incr = 2;
31011 assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
31012 testcase( enc==SQLITE_UTF16LE );
@@ -32685,14 +32660,13 @@
32685 /* 163 */ "VRename" OpHelp(""),
32686 /* 164 */ "Pagecount" OpHelp(""),
32687 /* 165 */ "MaxPgcnt" OpHelp(""),
32688 /* 166 */ "Trace" OpHelp(""),
32689 /* 167 */ "CursorHint" OpHelp(""),
32690 /* 168 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
32691 /* 169 */ "Noop" OpHelp(""),
32692 /* 170 */ "Explain" OpHelp(""),
32693 /* 171 */ "Abortable" OpHelp(""),
32694 };
32695 return azName[i];
32696 }
32697 #endif
32698
@@ -36581,11 +36555,11 @@
36581 zDirname[ii] = '\0';
36582 }else{
36583 if( zDirname[0]!='/' ) zDirname[0] = '.';
36584 zDirname[1] = 0;
36585 }
36586 fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0);
36587 if( fd>=0 ){
36588 OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
36589 }
36590 *pFd = fd;
36591 if( fd>=0 ) return SQLITE_OK;
@@ -37472,16 +37446,14 @@
37472 }
37473 }
37474
37475 if( pInode->bProcessLock==0 ){
37476 if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
37477 pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW,
37478 (sStat.st_mode&0777));
37479 }
37480 if( pShmNode->hShm<0 ){
37481 pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW,
37482 (sStat.st_mode&0777));
37483 if( pShmNode->hShm<0 ){
37484 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
37485 goto shm_open_err;
37486 }
37487 pShmNode->isReadonly = 1;
@@ -38827,11 +38799,11 @@
38827 int *pOutFlags /* Output flags returned to SQLite core */
38828 ){
38829 unixFile *p = (unixFile *)pFile;
38830 int fd = -1; /* File descriptor returned by open() */
38831 int openFlags = 0; /* Flags to pass to open() */
38832 int eType = flags&0x0FFF00; /* Type of file to open */
38833 int noLock; /* True to omit locking primitives */
38834 int rc = SQLITE_OK; /* Function Return Code */
38835 int ctrlFlags = 0; /* UNIXFILE_* flags */
38836
38837 int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -38937,11 +38909,11 @@
38937 ** 'conch file' locking functions later on. */
38938 if( isReadonly ) openFlags |= O_RDONLY;
38939 if( isReadWrite ) openFlags |= O_RDWR;
38940 if( isCreate ) openFlags |= O_CREAT;
38941 if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);
38942 openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW);
38943
38944 if( fd<0 ){
38945 mode_t openMode; /* Permissions to create file with */
38946 uid_t uid; /* Userid for the file */
38947 gid_t gid; /* Groupid for the file */
@@ -39149,20 +39121,29 @@
39149 ){
39150 UNUSED_PARAMETER(NotUsed);
39151 SimulateIOError( return SQLITE_IOERR_ACCESS; );
39152 assert( pResOut!=0 );
39153
39154 /* The spec says there are three possible values for flags. But only
39155 ** two of them are actually used */
39156 assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );
 
 
39157
39158 if( flags==SQLITE_ACCESS_EXISTS ){
39159 struct stat buf;
39160 *pResOut = 0==osStat(zPath, &buf) &&
39161 (S_ISDIR(buf.st_mode) || buf.st_size>0);
39162 }else{
39163 *pResOut = osAccess(zPath, W_OK|R_OK)==0;
 
 
 
 
 
 
 
 
39164 }
39165 return SQLITE_OK;
39166 }
39167
39168 /*
@@ -39210,11 +39191,11 @@
39210 #if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)
39211 return mkFullPathname(zPath, zOut, nOut);
39212 #else
39213 int rc = SQLITE_OK;
39214 int nByte;
39215 int nLink = 0; /* Number of symbolic links followed so far */
39216 const char *zIn = zPath; /* Input path for each iteration of loop */
39217 char *zDel = 0;
39218
39219 assert( pVfs->mxPathname==MAX_PATHNAME );
39220 UNUSED_PARAMETER(pVfs);
@@ -39239,15 +39220,14 @@
39239 }else{
39240 bLink = S_ISLNK(buf.st_mode);
39241 }
39242
39243 if( bLink ){
39244 nLink++;
39245 if( zDel==0 ){
39246 zDel = sqlite3_malloc(nOut);
39247 if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;
39248 }else if( nLink>=SQLITE_MAX_SYMLINKS ){
39249 rc = SQLITE_CANTOPEN_BKPT;
39250 }
39251
39252 if( rc==SQLITE_OK ){
39253 nByte = osReadlink(zIn, zDel, nOut-1);
@@ -39279,11 +39259,10 @@
39279 if( bLink==0 ) break;
39280 zIn = zOut;
39281 }while( rc==SQLITE_OK );
39282
39283 sqlite3_free(zDel);
39284 if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK;
39285 return rc;
39286 #endif /* HAVE_READLINK && HAVE_LSTAT */
39287 }
39288
39289
@@ -39765,11 +39744,11 @@
39765 int islockfile /* if non zero missing dirs will be created */
39766 ) {
39767 int fd = -1;
39768 unixFile *pNew;
39769 int rc = SQLITE_OK;
39770 int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW;
39771 sqlite3_vfs dummyVfs;
39772 int terrno = 0;
39773 UnixUnusedFd *pUnused = NULL;
39774
39775 /* 1. first try to open/create the file
@@ -39795,11 +39774,11 @@
39795 fd = robust_open(path, openFlags, 0);
39796 }
39797 }
39798 }
39799 if( fd<0 ){
39800 openFlags = O_RDONLY | O_NOFOLLOW;
39801 fd = robust_open(path, openFlags, 0);
39802 terrno = errno;
39803 }
39804 if( fd<0 ){
39805 if( islockfile ){
@@ -39921,11 +39900,11 @@
39921 if( readLen<PROXY_PATHINDEX ){
39922 sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
39923 goto end_breaklock;
39924 }
39925 /* write it out to the temporary break file */
39926 fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0);
39927 if( fd<0 ){
39928 sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
39929 goto end_breaklock;
39930 }
39931 if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -41081,10 +41060,18 @@
41081
41082 #ifndef NTDDI_WINTHRESHOLD
41083 # define NTDDI_WINTHRESHOLD 0x06040000
41084 #endif
41085
 
 
 
 
 
 
 
 
41086 /*
41087 ** Check to see if the GetVersionEx[AW] functions are deprecated on the
41088 ** target system. GetVersionEx was first deprecated in Win8.1.
41089 */
41090 #ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46473,10 +46460,14 @@
46473 break;
46474 case SQLITE_ACCESS_READWRITE:
46475 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46476 (attr & FILE_ATTRIBUTE_READONLY)==0;
46477 break;
 
 
 
 
46478 default:
46479 assert(!"Invalid flags argument");
46480 }
46481 *pResOut = rc;
46482 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -49512,19 +49503,17 @@
49512 sqlite3_free(p);
49513 pPg = 0;
49514 }
49515 #else
49516 pPg = pcache1Alloc(pCache->szAlloc);
 
49517 #endif
49518 if( benignMalloc ){ sqlite3EndBenignMalloc(); }
49519 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
49520 pcache1EnterMutex(pCache->pGroup);
49521 #endif
49522 if( pPg==0 ) return 0;
49523 #ifndef SQLITE_PCACHE_SEPARATE_HEADER
49524 p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
49525 #endif
49526 p->page.pBuf = pPg;
49527 p->page.pExtra = &p[1];
49528 p->isBulkLocal = 0;
49529 p->isAnchor = 0;
49530 }
@@ -55793,34 +55782,31 @@
55793 ** to by zPathname, length nPathname. Or, if this is a temporary file,
55794 ** leave both nPathname and zPathname set to 0.
55795 */
55796 if( zFilename && zFilename[0] ){
55797 const char *z;
 
 
 
 
 
 
55798 nPathname = pVfs->mxPathname+1;
55799 zPathname = sqlite3DbMallocRaw(0, nPathname*2);
55800 if( zPathname==0 ){
55801 return SQLITE_NOMEM_BKPT;
55802 }
55803 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
55804 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
55805 if( rc!=SQLITE_OK ){
55806 if( rc==SQLITE_OK_SYMLINK ){
55807 if( vfsFlags & SQLITE_OPEN_NOFOLLOW ){
55808 rc = SQLITE_CANTOPEN_SYMLINK;
55809 }else{
55810 rc = SQLITE_OK;
55811 }
55812 }
55813 }
55814 nPathname = sqlite3Strlen30(zPathname);
55815 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
55816 while( *z ){
55817 z += strlen(z)+1;
55818 z += strlen(z)+1;
55819 nUri++;
55820 }
55821 nUriByte = (int)(&z[1] - zUri);
55822 assert( nUriByte>=1 );
55823 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
55824 /* This branch is taken when the journal path required by
55825 ** the database being opened will be more than pVfs->mxPathname
55826 ** bytes in length. This means the database cannot be opened,
@@ -57630,11 +57616,10 @@
57630
57631 /* This routine should not be called if a prior error has occurred.
57632 ** But if (due to a coding error elsewhere in the system) it does get
57633 ** called, just return the same error code without doing anything. */
57634 if( NEVER(pPager->errCode) ) return pPager->errCode;
57635 pPager->iDataVersion++;
57636
57637 assert( pPager->eState==PAGER_WRITER_LOCKED
57638 || pPager->eState==PAGER_WRITER_FINISHED
57639 || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)
57640 );
@@ -57659,10 +57644,11 @@
57659 pPager->eState = PAGER_READER;
57660 return SQLITE_OK;
57661 }
57662
57663 PAGERTRACE(("COMMIT %d\n", PAGERID(pPager)));
 
57664 rc = pager_end_transaction(pPager, pPager->setMaster, 1);
57665 return pager_error(pPager, rc);
57666 }
57667
57668 /*
@@ -60579,23 +60565,11 @@
60579 ** of the aReadMark[] slot. The assumption here is that if that is
60580 ** happening, the other client may only be increasing the value,
60581 ** not decreasing it. So assuming either that either the "old" or
60582 ** "new" version of the value is read, and not some arbitrary value
60583 ** that would never be written by a real client, things are still
60584 ** safe.
60585 **
60586 ** Astute readers have pointed out that the assumption stated in the
60587 ** last sentence of the previous paragraph is not guaranteed to be
60588 ** true for all conforming systems. However, the assumption is true
60589 ** for all compilers and architectures in common use today (circa
60590 ** 2019-11-27) and the alternatives are both slow and complex, and
60591 ** so we will continue to go with the current design for now. If this
60592 ** bothers you, or if you really are running on a system where aligned
60593 ** 32-bit reads and writes are not atomic, then you can simply avoid
60594 ** the use of WAL mode, or only use WAL mode together with
60595 ** PRAGMA locking_mode=EXCLUSIVE and all will be well.
60596 */
60597 u32 y = pInfo->aReadMark[i];
60598 if( mxSafeFrame>y ){
60599 assert( y<=pWal->hdr.mxFrame );
60600 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
60601 if( rc==SQLITE_OK ){
@@ -66047,17 +66021,13 @@
66047 memcpy(zFullPathname, zFilename, nFilename);
66048 }else{
66049 rc = sqlite3OsFullPathname(pVfs, zFilename,
66050 nFullPathname, zFullPathname);
66051 if( rc ){
66052 if( rc==SQLITE_OK_SYMLINK ){
66053 rc = SQLITE_OK;
66054 }else{
66055 sqlite3_free(zFullPathname);
66056 sqlite3_free(p);
66057 return rc;
66058 }
66059 }
66060 }
66061 #if SQLITE_THREADSAFE
66062 mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);
66063 sqlite3_mutex_enter(mutexOpen);
@@ -69362,15 +69332,12 @@
69362
69363 /* If the database file is corrupt, it is possible for the value of idx
69364 ** to be invalid here. This can only occur if a second cursor modifies
69365 ** the page while cursor pCur is holding a reference to it. Which can
69366 ** only happen if the database is corrupt in such a way as to link the
69367 ** page into more than one b-tree structure.
69368 **
69369 ** Update 2019-12-23: appears to long longer be possible after the
69370 ** addition of anotherValidCursor() condition on balance_deeper(). */
69371 harmless( idx>pPage->nCell );
69372
69373 if( idx>=pPage->nCell ){
69374 if( !pPage->leaf ){
69375 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
69376 if( rc ) return rc;
@@ -71955,34 +71922,10 @@
71955
71956 *ppChild = pChild;
71957 return SQLITE_OK;
71958 }
71959
71960 /*
71961 ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid
71962 ** on the same B-tree as pCur.
71963 **
71964 ** This can if a database is corrupt with two or more SQL tables
71965 ** pointing to the same b-tree. If an insert occurs on one SQL table
71966 ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL
71967 ** table linked to the same b-tree. If the secondary insert causes a
71968 ** rebalance, that can change content out from under the cursor on the
71969 ** first SQL table, violating invariants on the first insert.
71970 */
71971 static int anotherValidCursor(BtCursor *pCur){
71972 BtCursor *pOther;
71973 for(pOther=pCur->pBt->pCursor; pOther; pOther=pOther->pNext){
71974 if( pOther!=pCur
71975 && pOther->eState==CURSOR_VALID
71976 && pOther->pPage==pCur->pPage
71977 ){
71978 return SQLITE_CORRUPT_BKPT;
71979 }
71980 }
71981 return SQLITE_OK;
71982 }
71983
71984 /*
71985 ** The page that pCur currently points to has just been modified in
71986 ** some way. This function figures out if this modification means the
71987 ** tree needs to be balanced, and if so calls the appropriate balancing
71988 ** routine. Balancing routines are:
@@ -72006,11 +71949,11 @@
72006
72007 if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
72008 if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
72009 break;
72010 }else if( (iPage = pCur->iPage)==0 ){
72011 if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){
72012 /* The root page of the b-tree is overfull. In this case call the
72013 ** balance_deeper() function to create a new child for the root-page
72014 ** and copy the current contents of the root-page to it. The
72015 ** next iteration of the do-loop will balance the child page.
72016 */
@@ -72377,13 +72320,11 @@
72377 return btreeOverwriteCell(pCur, &x2);
72378 }
72379 }
72380
72381 }
72382 assert( pCur->eState==CURSOR_VALID
72383 || (pCur->eState==CURSOR_INVALID && loc)
72384 || CORRUPT_DB );
72385
72386 pPage = pCur->pPage;
72387 assert( pPage->intKey || pX->nKey>=0 );
72388 assert( pPage->leaf || !pPage->intKey );
72389 if( pPage->nFree<0 ){
@@ -75548,11 +75489,12 @@
75548 if( flags & (MEM_Int|MEM_IntReal) ){
75549 testcase( flags & MEM_IntReal );
75550 return pMem->u.i;
75551 }else if( flags & MEM_Real ){
75552 return doubleToInt64(pMem->u.r);
75553 }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){
 
75554 return memIntValue(pMem);
75555 }else{
75556 return 0;
75557 }
75558 }
@@ -75705,12 +75647,12 @@
75705 ** "aff". Casting is different from applying affinity in that a cast
75706 ** is forced. In other words, the value is converted into the desired
75707 ** affinity even if that results in loss of data. This routine is
75708 ** used (for example) to implement the SQL "cast()" operator.
75709 */
75710 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
75711 if( pMem->flags & MEM_Null ) return SQLITE_OK;
75712 switch( aff ){
75713 case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */
75714 if( (pMem->flags & MEM_Blob)==0 ){
75715 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
75716 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
@@ -75737,14 +75679,13 @@
75737 assert( MEM_Str==(MEM_Blob>>3) );
75738 pMem->flags |= (pMem->flags&MEM_Blob)>>3;
75739 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
75740 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
75741 pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero);
75742 return sqlite3VdbeChangeEncoding(pMem, encoding);
75743 }
75744 }
75745 return SQLITE_OK;
75746 }
75747
75748 /*
75749 ** Initialize bulk memory to be a consistent Mem object.
75750 **
@@ -77513,11 +77454,10 @@
77513 **
77514 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
77515 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
77516 ** * OP_Destroy
77517 ** * OP_VUpdate
77518 ** * OP_VCreate
77519 ** * OP_VRename
77520 ** * OP_FkCounter with P2==0 (immediate foreign key constraint)
77521 ** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine
77522 ** (for CREATE TABLE AS SELECT ...)
77523 **
@@ -77541,11 +77481,10 @@
77541
77542 while( (pOp = opIterNext(&sIter))!=0 ){
77543 int opcode = pOp->opcode;
77544 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
77545 || opcode==OP_VDestroy
77546 || opcode==OP_VCreate
77547 || (opcode==OP_ParseSchema && pOp->p4.z==0)
77548 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
77549 && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
77550 ){
77551 hasAbort = 1;
@@ -78031,33 +77970,10 @@
78031 return sqlite3VdbeChangeToNoop(p, p->nOp-1);
78032 }else{
78033 return 0;
78034 }
78035 }
78036
78037 #ifdef SQLITE_DEBUG
78038 /*
78039 ** Generate an OP_ReleaseReg opcode to indicate that a range of
78040 ** registers, except any identified by mask, are no longer in use.
78041 */
78042 SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse *pParse, int iFirst, int N, u32 mask){
78043 assert( pParse->pVdbe );
78044 while( N>0 && (mask&1)!=0 ){
78045 mask >>= 1;
78046 iFirst++;
78047 N--;
78048 }
78049 while( N>0 && N<=32 && (mask & MASKBIT32(N-1))!=0 ){
78050 mask &= ~MASKBIT32(N-1);
78051 N--;
78052 }
78053 if( N>0 ){
78054 sqlite3VdbeAddOp3(pParse->pVdbe, OP_ReleaseReg, iFirst, N, *(int*)&mask);
78055 }
78056 }
78057 #endif /* SQLITE_DEBUG */
78058
78059
78060 /*
78061 ** Change the value of the P4 operand for a specific instruction.
78062 ** This routine is useful when a large program is loaded from a
78063 ** static array using sqlite3VdbeAddOpList but we want to make a
@@ -78172,12 +78088,11 @@
78172 ** makes the code easier to read during debugging. None of this happens
78173 ** in a production build.
78174 */
78175 static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
78176 assert( p->nOp>0 || p->aOp==0 );
78177 assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
78178 || p->pParse->nErr>0 );
78179 if( p->nOp ){
78180 assert( p->aOp );
78181 sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
78182 p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);
78183 }
@@ -86213,15 +86128,13 @@
86213 testcase( pOp->p2==SQLITE_AFF_INTEGER );
86214 testcase( pOp->p2==SQLITE_AFF_REAL );
86215 pIn1 = &aMem[pOp->p1];
86216 memAboutToChange(p, pIn1);
86217 rc = ExpandBlob(pIn1);
86218 if( rc ) goto abort_due_to_error;
86219 rc = sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);
86220 if( rc ) goto abort_due_to_error;
86221 UPDATE_MAX_BLOBSIZE(pIn1);
86222 REGISTER_TRACE(pOp->p1, pIn1);
86223 break;
86224 }
86225 #endif /* SQLITE_OMIT_CAST */
86226
86227 /* Opcode: Eq P1 P2 P3 P4 P5
@@ -86376,11 +86289,16 @@
86376 affinity = pOp->p5 & SQLITE_AFF_MASK;
86377 if( affinity>=SQLITE_AFF_NUMERIC ){
86378 if( (flags1 | flags3)&MEM_Str ){
86379 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
86380 applyNumericAffinity(pIn1,0);
86381 testcase( flags3!=pIn3->flags );
 
 
 
 
 
86382 flags3 = pIn3->flags;
86383 }
86384 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
86385 applyNumericAffinity(pIn3,0);
86386 }
@@ -86399,11 +86317,11 @@
86399 testcase( pIn1->flags & MEM_Real );
86400 testcase( pIn1->flags & MEM_IntReal );
86401 sqlite3VdbeMemStringify(pIn1, encoding, 1);
86402 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
86403 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
86404 if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str;
86405 }
86406 if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
86407 testcase( pIn3->flags & MEM_Int );
86408 testcase( pIn3->flags & MEM_Real );
86409 testcase( pIn3->flags & MEM_IntReal );
@@ -86434,14 +86352,14 @@
86434 static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 };
86435 res2 = aGTb[pOp->opcode - OP_Ne];
86436 }
86437
86438 /* Undo any changes made by applyAffinity() to the input registers. */
 
 
86439 assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
86440 pIn3->flags = flags3;
86441 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
86442 pIn1->flags = flags1;
86443
86444 if( pOp->p5 & SQLITE_STOREP2 ){
86445 pOut = &aMem[pOp->p2];
86446 iCompare = res;
86447 if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){
@@ -86473,35 +86391,20 @@
86473 break;
86474 }
86475
86476 /* Opcode: ElseNotEq * P2 * * *
86477 **
86478 ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There
86479 ** can be zero or more OP_ReleaseReg opcodes intervening, but no other
86480 ** opcodes are allowed to occur between this instruction and the previous
86481 ** OP_Lt or OP_Gt. Furthermore, the prior OP_Lt or OP_Gt must have the
86482 ** SQLITE_STOREP2 bit set in the P5 field.
86483 **
86484 ** If result of an OP_Eq comparison on the same two operands as the
86485 ** prior OP_Lt or OP_Gt would have been NULL or false (0), then then
86486 ** jump to P2. If the result of an OP_Eq comparison on the two previous
86487 ** operands would have been true (1), then fall through.
86488 */
86489 case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
86490
86491 #ifdef SQLITE_DEBUG
86492 /* Verify the preconditions of this opcode - that it follows an OP_Lt or
86493 ** OP_Gt with the SQLITE_STOREP2 flag set, with zero or more intervening
86494 ** OP_ReleaseReg opcodes */
86495 int iAddr;
86496 for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){
86497 if( aOp[iAddr].opcode==OP_ReleaseReg ) continue;
86498 assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt );
86499 assert( aOp[iAddr].p5 & SQLITE_STOREP2 );
86500 break;
86501 }
86502 #endif /* SQLITE_DEBUG */
86503 VdbeBranchTaken(iCompare!=0, 2);
86504 if( iCompare!=0 ) goto jump_to_p2;
86505 break;
86506 }
86507
@@ -86908,13 +86811,11 @@
86908 const u8 *zEndHdr; /* Pointer to first byte after the header */
86909 u64 offset64; /* 64-bit offset */
86910 u32 t; /* A type code from the record header */
86911 Mem *pReg; /* PseudoTable input register */
86912
86913 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86914 pC = p->apCsr[pOp->p1];
86915 assert( pC!=0 );
86916 p2 = pOp->p2;
86917
86918 /* If the cursor cache is stale (meaning it is not currently point at
86919 ** the correct row) then bring it up-to-date by doing the necessary
86920 ** B-Tree seek. */
@@ -86922,10 +86823,11 @@
86922 if( rc ) goto abort_due_to_error;
86923
86924 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
86925 pDest = &aMem[pOp->p3];
86926 memAboutToChange(p, pDest);
 
86927 assert( pC!=0 );
86928 assert( p2<pC->nField );
86929 aOffset = pC->aOffset;
86930 assert( pC->eCurType!=CURTYPE_VTAB );
86931 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
@@ -87178,11 +87080,11 @@
87178 assert( pOp->p2>0 );
87179 assert( zAffinity[pOp->p2]==0 );
87180 pIn1 = &aMem[pOp->p1];
87181 while( 1 /*exit-by-break*/ ){
87182 assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
87183 assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) );
87184 applyAffinity(pIn1, zAffinity[0], encoding);
87185 if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
87186 /* When applying REAL affinity, if the result is still an MEM_Int
87187 ** that will fit in 6 bytes, then change the type to MEM_IntReal
87188 ** so that we keep the high-resolution integer value but know that
@@ -87624,16 +87526,12 @@
87624 p->pc = (int)(pOp - aOp);
87625 db->autoCommit = 0;
87626 p->rc = rc = SQLITE_BUSY;
87627 goto vdbe_return;
87628 }
 
87629 rc = p->rc;
87630 if( rc ){
87631 db->autoCommit = 0;
87632 }else{
87633 db->isTransactionSavepoint = 0;
87634 }
87635 }else{
87636 int isSchemaChange;
87637 iSavepoint = db->nSavepoint - iSavepoint - 1;
87638 if( p1==SAVEPOINT_ROLLBACK ){
87639 isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;
@@ -87657,11 +87555,10 @@
87657 sqlite3ExpirePreparedStatements(db, 0);
87658 sqlite3ResetAllSchemasOfConnection(db);
87659 db->mDbFlags |= DBFLAG_SchemaChange;
87660 }
87661 }
87662 if( rc ) goto abort_due_to_error;
87663
87664 /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
87665 ** savepoints nested inside of the savepoint being operated on. */
87666 while( db->pSavepoint!=pSavepoint ){
87667 pTmp = db->pSavepoint;
@@ -88153,11 +88050,10 @@
88153 case OP_OpenDup: {
88154 VdbeCursor *pOrig; /* The original cursor to be duplicated */
88155 VdbeCursor *pCx; /* The new cursor */
88156
88157 pOrig = p->apCsr[pOp->p2];
88158 assert( pOrig );
88159 assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */
88160
88161 pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
88162 if( pCx==0 ) goto no_mem;
88163 pCx->nullRow = 1;
@@ -91583,11 +91479,11 @@
91583 pVtab = pCur->uc.pVCur->pVtab;
91584 pModule = pVtab->pModule;
91585 assert( pModule->xColumn );
91586 memset(&sContext, 0, sizeof(sContext));
91587 sContext.pOut = pDest;
91588 assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 );
91589 if( pOp->p5 & OPFLAG_NOCHNG ){
91590 sqlite3VdbeMemSetNull(pDest);
91591 pDest->flags = MEM_Null|MEM_Zero;
91592 pDest->u.nZero = 0;
91593 }else{
@@ -92040,57 +91936,10 @@
92040 ** An Abort is safe if either there have been no writes, or if there is
92041 ** an active statement journal.
92042 */
92043 case OP_Abortable: {
92044 sqlite3VdbeAssertAbortable(p);
92045 break;
92046 }
92047 #endif
92048
92049 #ifdef SQLITE_DEBUG
92050 /* Opcode: ReleaseReg P1 P2 P3 * *
92051 ** Synopsis: release r[P1@P2] mask P3
92052 **
92053 ** Release registers from service. Any content that was in the
92054 ** the registers is unreliable after this opcode completes.
92055 **
92056 ** The registers released will be the P2 registers starting at P1,
92057 ** except if bit ii of P3 set, then do not release register P1+ii.
92058 ** In other words, P3 is a mask of registers to preserve.
92059 **
92060 ** Releasing a register clears the Mem.pScopyFrom pointer. That means
92061 ** that if the content of the released register was set using OP_SCopy,
92062 ** a change to the value of the source register for the OP_SCopy will no longer
92063 ** generate an assertion fault in sqlite3VdbeMemAboutToChange().
92064 **
92065 ** TODO: Released registers ought to also have their datatype set to
92066 ** MEM_Undefined so that any subsequent attempt to read the released
92067 ** register (before it is reinitialized) will generate an assertion fault.
92068 ** However, there are places in the code generator which release registers
92069 ** before their are used, under the (valid) assumption that the registers
92070 ** will not be reallocated for some other purpose before they are used and
92071 ** hence are safe to release.
92072 **
92073 ** This opcode is only available in testing and debugging builds. It is
92074 ** not generated for release builds. The purpose of this opcode is to help
92075 ** validate the generated bytecode. This opcode does not actually contribute
92076 ** to computing an answer.
92077 */
92078 case OP_ReleaseReg: {
92079 Mem *pMem;
92080 int i;
92081 u32 constMask;
92082 assert( pOp->p1>0 );
92083 assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 );
92084 pMem = &aMem[pOp->p1];
92085 constMask = pOp->p3;
92086 for(i=0; i<pOp->p2; i++, pMem++){
92087 if( i>=32 || (constMask & MASKBIT32(i))==0 ){
92088 pMem->pScopyFrom = 0;
92089 /* MemSetTypeFlag(pMem, MEM_Undefined); // See the TODO */
92090 }
92091 }
92092 break;
92093 }
92094 #endif
92095
92096 /* Opcode: Noop * * * * *
@@ -96000,12 +95849,12 @@
96000 testcase( ExprHasProperty(pExpr, EP_Reduced) );
96001 while(1){
96002 rc = pWalker->xExprCallback(pWalker, pExpr);
96003 if( rc ) return rc & WRC_Abort;
96004 if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
96005 assert( pExpr->x.pList==0 || pExpr->pRight==0 );
96006 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
 
96007 if( pExpr->pRight ){
96008 assert( !ExprHasProperty(pExpr, EP_WinFunc) );
96009 pExpr = pExpr->pRight;
96010 continue;
96011 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -96689,39 +96538,22 @@
96689 pTopNC->nErr++;
96690 }
96691
96692 /* If a column from a table in pSrcList is referenced, then record
96693 ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
96694 ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is
96695 ** set if the 63rd or any subsequent column is used.
96696 **
96697 ** The colUsed mask is an optimization used to help determine if an
96698 ** index is a covering index. The correct answer is still obtained
96699 ** if the mask contains extra set bits. However, it is important to
96700 ** avoid setting bits beyond the maximum column number of the table.
96701 ** (See ticket [b92e5e8ec2cdbaa1]).
96702 **
96703 ** If a generated column is referenced, set bits for every column
96704 ** of the table.
96705 */
96706 if( pExpr->iColumn>=0 && pMatch!=0 ){
96707 int n = pExpr->iColumn;
96708 Table *pExTab = pExpr->y.pTab;
96709 assert( pExTab!=0 );
 
 
96710 assert( pMatch->iCursor==pExpr->iTable );
96711 if( (pExTab->tabFlags & TF_HasGenerated)!=0
96712 && (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0
96713 ){
96714 testcase( pExTab->nCol==BMS-1 );
96715 testcase( pExTab->nCol==BMS );
96716 pMatch->colUsed = pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1;
96717 }else{
96718 testcase( n==BMS-1 );
96719 testcase( n==BMS );
96720 if( n>=BMS ) n = BMS-1;
96721 pMatch->colUsed |= ((Bitmask)1)<<n;
96722 }
96723 }
96724
96725 /* Clean up and return
96726 */
96727 sqlite3ExprDelete(db, pExpr->pLeft);
@@ -96756,68 +96588,47 @@
96756 */
96757 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
96758 Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
96759 if( p ){
96760 struct SrcList_item *pItem = &pSrc->a[iSrc];
96761 Table *pTab = p->y.pTab = pItem->pTab;
96762 p->iTable = pItem->iCursor;
96763 if( p->y.pTab->iPKey==iCol ){
96764 p->iColumn = -1;
96765 }else{
96766 p->iColumn = (ynVar)iCol;
96767 if( (pTab->tabFlags & TF_HasGenerated)!=0
96768 && (pTab->aCol[iCol].colFlags & COLFLAG_GENERATED)!=0
96769 ){
96770 testcase( pTab->nCol==63 );
96771 testcase( pTab->nCol==64 );
96772 pItem->colUsed = pTab->nCol>=64 ? ALLBITS : MASKBIT(pTab->nCol)-1;
96773 }else{
96774 testcase( iCol==BMS );
96775 testcase( iCol==BMS-1 );
96776 pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
96777 }
96778 }
96779 }
96780 return p;
96781 }
96782
96783 /*
96784 ** Report an error that an expression is not valid for some set of
96785 ** pNC->ncFlags values determined by validMask.
96786 **
96787 ** static void notValid(
96788 ** Parse *pParse, // Leave error message here
96789 ** NameContext *pNC, // The name context
96790 ** const char *zMsg, // Type of error
96791 ** int validMask, // Set of contexts for which prohibited
96792 ** Expr *pExpr // Invalidate this expression on error
96793 ** ){...}
96794 **
96795 ** As an optimization, since the conditional is almost always false
96796 ** (because errors are rare), the conditional is moved outside of the
96797 ** function call using a macro.
96798 */
96799 static void notValidImpl(
96800 Parse *pParse, /* Leave error message here */
96801 NameContext *pNC, /* The name context */
96802 const char *zMsg, /* Type of error */
96803 Expr *pExpr /* Invalidate this expression on error */
96804 ){
96805 const char *zIn = "partial index WHERE clauses";
96806 if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
 
 
96807 #ifndef SQLITE_OMIT_CHECK
96808 else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
96809 #endif
96810 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
96811 else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
96812 #endif
96813 sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96814 if( pExpr ) pExpr->op = TK_NULL;
96815 }
96816 #define sqlite3ResolveNotValid(P,N,M,X,E) \
96817 assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
96818 if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E);
96819
96820 /*
96821 ** Expression p should encode a floating point value between 1.0 and 0.0.
96822 ** Return 1024 times this value. Or return -1 if p is not a floating point
96823 ** value between 1.0 and 0.0.
@@ -96902,14 +96713,11 @@
96902 zDb = 0;
96903 zTable = 0;
96904 zColumn = pExpr->u.zToken;
96905 }else{
96906 Expr *pLeft = pExpr->pLeft;
96907 testcase( pNC->ncFlags & NC_IdxExpr );
96908 testcase( pNC->ncFlags & NC_GenCol );
96909 sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator",
96910 NC_IdxExpr|NC_GenCol, 0);
96911 pRight = pExpr->pRight;
96912 if( pRight->op==TK_ID ){
96913 zDb = 0;
96914 }else{
96915 assert( pRight->op==TK_DOT );
@@ -97002,12 +96810,11 @@
97002 }
97003 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
97004 /* Date/time functions that use 'now', and other functions like
97005 ** sqlite_version() that might change over time cannot be used
97006 ** in an index. */
97007 sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
97008 NC_SelfRef, 0);
97009 }else{
97010 assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
97011 pExpr->op2 = pNC->ncFlags & NC_SelfRef;
97012 }
97013 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
@@ -97105,11 +96912,11 @@
97105 #ifndef SQLITE_OMIT_WINDOWFUNC
97106 if( pWin ){
97107 Select *pSel = pNC->pWinSelect;
97108 assert( pWin==pExpr->y.pWin );
97109 if( IN_RENAME_OBJECT==0 ){
97110 sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef);
97111 }
97112 sqlite3WalkExprList(pWalker, pWin->pPartition);
97113 sqlite3WalkExprList(pWalker, pWin->pOrderBy);
97114 sqlite3WalkExpr(pWalker, pWin->pFilter);
97115 sqlite3WindowLink(pSel, pWin);
@@ -97150,16 +96957,12 @@
97150 #endif
97151 case TK_IN: {
97152 testcase( pExpr->op==TK_IN );
97153 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
97154 int nRef = pNC->nRef;
97155 testcase( pNC->ncFlags & NC_IsCheck );
97156 testcase( pNC->ncFlags & NC_PartIdx );
97157 testcase( pNC->ncFlags & NC_IdxExpr );
97158 testcase( pNC->ncFlags & NC_GenCol );
97159 sqlite3ResolveNotValid(pParse, pNC, "subqueries",
97160 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
97161 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
97162 assert( pNC->nRef>=nRef );
97163 if( nRef!=pNC->nRef ){
97164 ExprSetProperty(pExpr, EP_VarSelect);
97165 pNC->ncFlags |= NC_VarSelect;
@@ -97166,16 +96969,12 @@
97166 }
97167 }
97168 break;
97169 }
97170 case TK_VARIABLE: {
97171 testcase( pNC->ncFlags & NC_IsCheck );
97172 testcase( pNC->ncFlags & NC_PartIdx );
97173 testcase( pNC->ncFlags & NC_IdxExpr );
97174 testcase( pNC->ncFlags & NC_GenCol );
97175 sqlite3ResolveNotValid(pParse, pNC, "parameters",
97176 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
97177 break;
97178 }
97179 case TK_IS:
97180 case TK_ISNOT: {
97181 Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -98404,11 +98203,10 @@
98404 ){
98405 int p5;
98406 int addr;
98407 CollSeq *p4;
98408
98409 if( pParse->nErr ) return 0;
98410 if( isCommuted ){
98411 p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft);
98412 }else{
98413 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
98414 }
@@ -98622,11 +98420,10 @@
98622 int regRight = 0;
98623 u8 opx = op;
98624 int addrDone = sqlite3VdbeMakeLabel(pParse);
98625 int isCommuted = ExprHasProperty(pExpr,EP_Commuted);
98626
98627 if( pParse->nErr ) return;
98628 if( nLeft!=sqlite3ExprVectorSize(pRight) ){
98629 sqlite3ErrorMsg(pParse, "row value misused");
98630 return;
98631 }
98632 assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
@@ -99971,13 +99768,11 @@
99971 switch( pExpr->op ){
99972 /* Consider functions to be constant if all their arguments are constant
99973 ** and either pWalker->eCode==4 or 5 or the function has the
99974 ** SQLITE_FUNC_CONST flag. */
99975 case TK_FUNCTION:
99976 if( (pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc))
99977 && !ExprHasProperty(pExpr, EP_WinFunc)
99978 ){
99979 return WRC_Continue;
99980 }else{
99981 pWalker->eCode = 0;
99982 return WRC_Abort;
99983 }
@@ -100236,13 +100031,11 @@
100236 case TK_BLOB:
100237 return 0;
100238 case TK_COLUMN:
100239 return ExprHasProperty(p, EP_CanBeNull) ||
100240 p->y.pTab==0 || /* Reference to column of index on expression */
100241 (p->iColumn>=0
100242 && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */
100243 && p->y.pTab->aCol[p->iColumn].notNull==0);
100244 default:
100245 return 1;
100246 }
100247 }
100248
@@ -100715,14 +100508,12 @@
100715 ** message of the form:
100716 **
100717 ** "sub-select returns N columns - expected M"
100718 */
100719 SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
100720 if( pParse->nErr==0 ){
100721 const char *zFmt = "sub-select returns %d columns - expected %d";
100722 sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
100723 }
100724 }
100725 #endif
100726
100727 /*
100728 ** Expression pExpr is a vector that has been used in a context where
@@ -101220,25 +101011,19 @@
101220 }
101221 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
101222 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
101223 }
101224 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
101225 int op = rLhs!=r2 ? OP_Eq : OP_NotNull;
101226 sqlite3VdbeAddOp4(v, op, rLhs, labelOk, r2,
101227 (void*)pColl, P4_COLLSEQ);
101228 VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_Eq);
101229 VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_Eq);
101230 VdbeCoverageIf(v, ii<pList->nExpr-1 && op==OP_NotNull);
101231 VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_NotNull);
101232 sqlite3VdbeChangeP5(v, zAff[0]);
101233 }else{
101234 int op = rLhs!=r2 ? OP_Ne : OP_IsNull;
101235 assert( destIfNull==destIfFalse );
101236 sqlite3VdbeAddOp4(v, op, rLhs, destIfFalse, r2,
101237 (void*)pColl, P4_COLLSEQ);
101238 VdbeCoverageIf(v, op==OP_Ne);
101239 VdbeCoverageIf(v, op==OP_IsNull);
101240 sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);
101241 }
101242 sqlite3ReleaseTempReg(pParse, regToFree);
101243 }
101244 if( regCkNull ){
@@ -101257,11 +101042,10 @@
101257 if( destIfNull==destIfFalse ){
101258 destStep2 = destIfFalse;
101259 }else{
101260 destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
101261 }
101262 if( pParse->nErr ) goto sqlite3ExprCodeIN_finished;
101263 for(i=0; i<nVector; i++){
101264 Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
101265 if( sqlite3ExprCanBeNull(p) ){
101266 sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
101267 VdbeCoverage(v);
@@ -101449,24 +101233,15 @@
101449 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
101450 Parse *pParse,
101451 Column *pCol,
101452 int regOut
101453 ){
101454 int iAddr;
101455 Vdbe *v = pParse->pVdbe;
101456 assert( v!=0 );
101457 assert( pParse->iSelfTab!=0 );
101458 if( pParse->iSelfTab>0 ){
101459 iAddr = sqlite3VdbeAddOp3(v, OP_IfNullRow, pParse->iSelfTab-1, 0, regOut);
101460 }else{
101461 iAddr = 0;
101462 }
101463 sqlite3ExprCode(pParse, pCol->pDflt, regOut);
101464 if( pCol->affinity>=SQLITE_AFF_TEXT ){
101465 sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1);
 
101466 }
101467 if( iAddr ) sqlite3VdbeJumpHere(v, iAddr);
101468 }
101469 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101470
101471 /*
101472 ** Generate code to extract the value of the iCol-th column of a table.
@@ -101537,21 +101312,21 @@
101537 u8 p5 /* P5 value for OP_Column + FLAGS */
101538 ){
101539 assert( pParse->pVdbe!=0 );
101540 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg);
101541 if( p5 ){
101542 VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1);
101543 if( pOp->opcode==OP_Column ) pOp->p5 = p5;
101544 }
101545 return iReg;
101546 }
101547
101548 /*
101549 ** Generate code to move content from registers iFrom...iFrom+nReg-1
101550 ** over to iTo..iTo+nReg-1.
101551 */
101552 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){
 
101553 sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);
101554 }
101555
101556 /*
101557 ** Convert a scalar expression node to a TK_REGISTER referencing
@@ -101649,25 +101424,19 @@
101649 }
101650 /* Otherwise, fall thru into the TK_COLUMN case */
101651 }
101652 case TK_COLUMN: {
101653 int iTab = pExpr->iTable;
101654 int iReg;
101655 if( ExprHasProperty(pExpr, EP_FixedCol) ){
101656 /* This COLUMN expression is really a constant due to WHERE clause
101657 ** constraints, and that constant is coded by the pExpr->pLeft
101658 ** expresssion. However, make sure the constant has the correct
101659 ** datatype by applying the Affinity of the table column to the
101660 ** constant.
101661 */
101662 int aff;
101663 iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
101664 if( pExpr->y.pTab ){
101665 aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
101666 }else{
101667 aff = pExpr->affExpr;
101668 }
101669 if( aff>SQLITE_AFF_BLOB ){
101670 static const char zAff[] = "B\000C\000D\000E";
101671 assert( SQLITE_AFF_BLOB=='A' );
101672 assert( SQLITE_AFF_TEXT=='B' );
101673 if( iReg!=target ){
@@ -101691,11 +101460,11 @@
101691 Table *pTab = pExpr->y.pTab;
101692 int iSrc;
101693 int iCol = pExpr->iColumn;
101694 assert( pTab!=0 );
101695 assert( iCol>=XN_ROWID );
101696 assert( iCol<pTab->nCol );
101697 if( iCol<0 ){
101698 return -1-pParse->iSelfTab;
101699 }
101700 pCol = pTab->aCol + iCol;
101701 testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
@@ -101726,17 +101495,13 @@
101726 /* Coding an expression that is part of an index where column names
101727 ** in the index refer to the table to which the index belongs */
101728 iTab = pParse->iSelfTab - 1;
101729 }
101730 }
101731 iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
101732 pExpr->iColumn, iTab, target,
101733 pExpr->op2);
101734 if( pExpr->y.pTab==0 && pExpr->affExpr==SQLITE_AFF_REAL ){
101735 sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
101736 }
101737 return iReg;
101738 }
101739 case TK_INTEGER: {
101740 codeInteger(pParse, pExpr, 0, target);
101741 return target;
101742 }
@@ -101754,16 +101519,11 @@
101754 case TK_STRING: {
101755 assert( !ExprHasProperty(pExpr, EP_IntValue) );
101756 sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
101757 return target;
101758 }
101759 default: {
101760 /* Make NULL the default case so that if a bug causes an illegal
101761 ** Expr node to be passed into this function, it will be handled
101762 ** sanely and not crash. But keep the assert() to bring the problem
101763 ** to the attention of the developers. */
101764 assert( op==TK_NULL );
101765 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101766 return target;
101767 }
101768 #ifndef SQLITE_OMIT_BLOB_LITERAL
101769 case TK_BLOB: {
@@ -101786,11 +101546,11 @@
101786 assert( pExpr->u.zToken!=0 );
101787 assert( pExpr->u.zToken[0]!=0 );
101788 sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
101789 if( pExpr->u.zToken[1]!=0 ){
101790 const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
101791 assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) );
101792 pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
101793 sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
101794 }
101795 return target;
101796 }
@@ -102099,16 +101859,12 @@
102099 #endif
102100 {
102101 sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
102102 pDef, pExpr->op2);
102103 }
102104 if( nFarg ){
102105 if( constMask==0 ){
102106 sqlite3ReleaseTempRange(pParse, r1, nFarg);
102107 }else{
102108 sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask);
102109 }
102110 }
102111 return target;
102112 }
102113 #ifndef SQLITE_OMIT_SUBQUERY
102114 case TK_EXISTS:
@@ -102200,11 +101956,11 @@
102200 ** p1==2 -> old.b p1==5 -> new.b
102201 */
102202 Table *pTab = pExpr->y.pTab;
102203 int iCol = pExpr->iColumn;
102204 int p1 = pExpr->iTable * (pTab->nCol+1) + 1
102205 + sqlite3TableColumnToStorage(pTab, iCol);
102206
102207 assert( pExpr->iTable==0 || pExpr->iTable==1 );
102208 assert( iCol>=-1 && iCol<pTab->nCol );
102209 assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
102210 assert( p1>=0 && p1<(pTab->nCol*2+2) );
@@ -102274,11 +102030,11 @@
102274 **
102275 ** The result of the expression is the Ri for the first matching Ei,
102276 ** or if there is no matching Ei, the ELSE term Y, or if there is
102277 ** no ELSE term, NULL.
102278 */
102279 case TK_CASE: {
102280 int endLabel; /* GOTO label for end of CASE stmt */
102281 int nextCase; /* GOTO label for next WHEN clause */
102282 int nExpr; /* 2x number of WHEN terms */
102283 int i; /* Loop counter */
102284 ExprList *pEList; /* List of WHEN terms */
@@ -103331,14 +103087,11 @@
103331 sqlite3WalkExpr(pWalker, pExpr->pRight);
103332 }
103333 return WRC_Prune;
103334
103335 case TK_BETWEEN:
103336 if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){
103337 assert( pWalker->eCode );
103338 return WRC_Abort;
103339 }
103340 return WRC_Prune;
103341
103342 /* Virtual tables are allowed to use constraints like x=NULL. So
103343 ** a term of the form x=y does not prove that y is not null if x
103344 ** is the column of a virtual table */
@@ -103748,15 +103501,12 @@
103748 /*
103749 ** Deallocate a register, making available for reuse for some other
103750 ** purpose.
103751 */
103752 SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
103753 if( iReg ){
103754 sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0);
103755 if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){
103756 pParse->aTempReg[pParse->nTempReg++] = iReg;
103757 }
103758 }
103759 }
103760
103761 /*
103762 ** Allocate or deallocate a block of nReg consecutive registers.
@@ -103778,11 +103528,10 @@
103778 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
103779 if( nReg==1 ){
103780 sqlite3ReleaseTempReg(pParse, iReg);
103781 return;
103782 }
103783 sqlite3VdbeReleaseRegisters(pParse, iReg, nReg, 0);
103784 if( nReg>pParse->nRangeReg ){
103785 pParse->nRangeReg = nReg;
103786 pParse->iRangeReg = iReg;
103787 }
103788 }
@@ -104522,18 +104271,16 @@
104522 */
104523 SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
104524 RenameToken *pNew;
104525 assert( pPtr || pParse->db->mallocFailed );
104526 renameTokenCheckAll(pParse, pPtr);
104527 if( pParse->eParseMode!=PARSE_MODE_UNMAP ){
104528 pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
104529 if( pNew ){
104530 pNew->p = pPtr;
104531 pNew->t = *pToken;
104532 pNew->pNext = pParse->pRename;
104533 pParse->pRename = pNew;
104534 }
104535 }
104536
104537 return pPtr;
104538 }
104539
@@ -104560,38 +104307,16 @@
104560 Parse *pParse = pWalker->pParse;
104561 sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
104562 return WRC_Continue;
104563 }
104564
104565 /*
104566 ** Iterate through the Select objects that are part of WITH clauses attached
104567 ** to select statement pSelect.
104568 */
104569 static void renameWalkWith(Walker *pWalker, Select *pSelect){
104570 With *pWith = pSelect->pWith;
104571 if( pWith ){
104572 int i;
104573 for(i=0; i<pWith->nCte; i++){
104574 Select *p = pWith->a[i].pSelect;
104575 NameContext sNC;
104576 memset(&sNC, 0, sizeof(sNC));
104577 sNC.pParse = pWalker->pParse;
104578 sqlite3SelectPrep(sNC.pParse, p, &sNC);
104579 sqlite3WalkSelect(pWalker, p);
104580 sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols);
104581 }
104582 }
104583 }
104584
104585 /*
104586 ** Walker callback used by sqlite3RenameExprUnmap().
104587 */
104588 static int renameUnmapSelectCb(Walker *pWalker, Select *p){
104589 Parse *pParse = pWalker->pParse;
104590 int i;
104591 if( pParse->nErr ) return WRC_Abort;
104592 if( NEVER(p->selFlags & SF_View) ) return WRC_Prune;
104593 if( ALWAYS(p->pEList) ){
104594 ExprList *pList = p->pEList;
104595 for(i=0; i<pList->nExpr; i++){
104596 if( pList->a[i].zName ){
104597 sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName);
@@ -104600,31 +104325,25 @@
104600 }
104601 if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */
104602 SrcList *pSrc = p->pSrc;
104603 for(i=0; i<pSrc->nSrc; i++){
104604 sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
104605 if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
104606 }
104607 }
104608
104609 renameWalkWith(pWalker, p);
104610 return WRC_Continue;
104611 }
104612
104613 /*
104614 ** Remove all nodes that are part of expression pExpr from the rename list.
104615 */
104616 SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){
104617 u8 eMode = pParse->eParseMode;
104618 Walker sWalker;
104619 memset(&sWalker, 0, sizeof(Walker));
104620 sWalker.pParse = pParse;
104621 sWalker.xExprCallback = renameUnmapExprCb;
104622 sWalker.xSelectCallback = renameUnmapSelectCb;
104623 pParse->eParseMode = PARSE_MODE_UNMAP;
104624 sqlite3WalkExpr(&sWalker, pExpr);
104625 pParse->eParseMode = eMode;
104626 }
104627
104628 /*
104629 ** Remove all nodes that are part of expression-list pEList from the
104630 ** rename list.
@@ -104673,18 +104392,35 @@
104673 pCtx->nList++;
104674 break;
104675 }
104676 }
104677 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104678
104679 /*
104680 ** This is a Walker select callback. It does nothing. It is only required
104681 ** because without a dummy callback, sqlite3WalkExpr() and similar do not
104682 ** descend into sub-select statements.
104683 */
104684 static int renameColumnSelectCb(Walker *pWalker, Select *p){
104685 if( p->selFlags & SF_View ) return WRC_Prune;
104686 renameWalkWith(pWalker, p);
104687 return WRC_Continue;
104688 }
104689
104690 /*
@@ -104811,10 +104547,11 @@
104811 ** is initialized by this function before it is used.
104812 */
104813 static int renameParseSql(
104814 Parse *p, /* Memory to use for Parse object */
104815 const char *zDb, /* Name of schema SQL belongs to */
 
104816 sqlite3 *db, /* Database handle */
104817 const char *zSql, /* SQL to parse */
104818 int bTemp /* True if SQL is from temp schema */
104819 ){
104820 int rc;
@@ -104824,11 +104561,11 @@
104824
104825 /* Parse the SQL statement passed as the first argument. If no error
104826 ** occurs and the parse does not result in a new table, index or
104827 ** trigger object, the database must be corrupt. */
104828 memset(p, 0, sizeof(Parse));
104829 p->eParseMode = PARSE_MODE_RENAME;
104830 p->db = db;
104831 p->nQueryLoop = 1;
104832 rc = sqlite3RunParser(p, zSql, &zErr);
104833 assert( p->zErrMsg==0 );
104834 assert( rc!=SQLITE_OK || zErr==0 );
@@ -105131,11 +104868,11 @@
105131 sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
105132
105133 #ifndef SQLITE_OMIT_AUTHORIZATION
105134 db->xAuth = 0;
105135 #endif
105136 rc = renameParseSql(&sParse, zDb, db, zSql, bTemp);
105137
105138 /* Find tokens that need to be replaced. */
105139 memset(&sWalker, 0, sizeof(Walker));
105140 sWalker.pParse = &sParse;
105141 sWalker.xExprCallback = renameColumnExprCb;
@@ -105145,13 +104882,12 @@
105145 sCtx.pTab = pTab;
105146 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
105147 if( sParse.pNewTable ){
105148 Select *pSelect = sParse.pNewTable->pSelect;
105149 if( pSelect ){
105150 pSelect->selFlags &= ~SF_View;
105151 sParse.rc = SQLITE_OK;
105152 sqlite3SelectPrep(&sParse, pSelect, 0);
105153 rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
105154 if( rc==SQLITE_OK ){
105155 sqlite3WalkSelect(&sWalker, pSelect);
105156 }
105157 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
@@ -105264,11 +105000,10 @@
105264 */
105265 static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
105266 int i;
105267 RenameCtx *p = pWalker->u.pRename;
105268 SrcList *pSrc = pSelect->pSrc;
105269 if( pSelect->selFlags & SF_View ) return WRC_Prune;
105270 if( pSrc==0 ){
105271 assert( pWalker->pParse->db->mallocFailed );
105272 return WRC_Abort;
105273 }
105274 for(i=0; i<pSrc->nSrc; i++){
@@ -105335,32 +105070,26 @@
105335 sWalker.pParse = &sParse;
105336 sWalker.xExprCallback = renameTableExprCb;
105337 sWalker.xSelectCallback = renameTableSelectCb;
105338 sWalker.u.pRename = &sCtx;
105339
105340 rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
105341
105342 if( rc==SQLITE_OK ){
105343 int isLegacy = (db->flags & SQLITE_LegacyAlter);
105344 if( sParse.pNewTable ){
105345 Table *pTab = sParse.pNewTable;
105346
105347 if( pTab->pSelect ){
105348 if( isLegacy==0 ){
105349 Select *pSelect = pTab->pSelect;
105350 NameContext sNC;
105351 memset(&sNC, 0, sizeof(sNC));
105352 sNC.pParse = &sParse;
105353
105354 assert( pSelect->selFlags & SF_View );
105355 pSelect->selFlags &= ~SF_View;
105356 sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
105357 if( sParse.nErr ){
105358 rc = sParse.rc;
105359 }else{
105360 sqlite3WalkSelect(&sWalker, pTab->pSelect);
105361 }
105362 }
105363 }else{
105364 /* Modify any FK definitions to point to the new table. */
105365 #ifndef SQLITE_OMIT_FOREIGN_KEY
105366 if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
@@ -105477,11 +105206,11 @@
105477
105478 UNUSED_PARAMETER(NotUsed);
105479 if( zDb && zInput ){
105480 int rc;
105481 Parse sParse;
105482 rc = renameParseSql(&sParse, zDb, db, zInput, bTemp);
105483 if( rc==SQLITE_OK ){
105484 if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
105485 NameContext sNC;
105486 memset(&sNC, 0, sizeof(sNC));
105487 sNC.pParse = &sParse;
@@ -109270,19 +108999,17 @@
109270 **
109271 ** So, in other words, this routine shifts all the virtual columns to
109272 ** the end.
109273 **
109274 ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
109275 ** this routine is a no-op macro. If the pTab does not have any virtual
109276 ** columns, then this routine is no-op that always return iCol. If iCol
109277 ** is negative (indicating the ROWID column) then this routine return iCol.
109278 */
109279 SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
109280 int i;
109281 i16 n;
109282 assert( iCol<pTab->nCol );
109283 if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol;
109284 for(i=0, n=0; i<iCol; i++){
109285 if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++;
109286 }
109287 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
109288 /* iCol is a virtual column itself */
@@ -109870,11 +109597,10 @@
109870 pTab->iPKey = iCol;
109871 pTab->keyConf = (u8)onError;
109872 assert( autoInc==0 || autoInc==1 );
109873 pTab->tabFlags |= autoInc*TF_Autoincrement;
109874 if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
109875 (void)sqlite3HasExplicitNulls(pParse, pList);
109876 }else if( autoInc ){
109877 #ifndef SQLITE_OMIT_AUTOINCREMENT
109878 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
109879 "INTEGER PRIMARY KEY");
109880 #endif
@@ -109955,14 +109681,11 @@
109955 SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
109956 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
109957 u8 eType = COLFLAG_VIRTUAL;
109958 Table *pTab = pParse->pNewTable;
109959 Column *pCol;
109960 if( pTab==0 ){
109961 /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */
109962 goto generated_done;
109963 }
109964 pCol = &(pTab->aCol[pTab->nCol-1]);
109965 if( IN_DECLARE_VTAB ){
109966 sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
109967 goto generated_done;
109968 }
@@ -110566,16 +110289,10 @@
110566 #ifndef SQLITE_OMIT_CHECK
110567 /* Resolve names in all CHECK constraint expressions.
110568 */
110569 if( p->pCheck ){
110570 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
110571 if( pParse->nErr ){
110572 /* If errors are seen, delete the CHECK constraints now, else they might
110573 ** actually be used if PRAGMA writable_schema=ON is set. */
110574 sqlite3ExprListDelete(db, p->pCheck);
110575 p->pCheck = 0;
110576 }
110577 }
110578 #endif /* !defined(SQLITE_OMIT_CHECK) */
110579 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
110580 if( p->tabFlags & TF_HasGenerated ){
110581 int ii, nNG = 0;
@@ -110582,23 +110299,14 @@
110582 testcase( p->tabFlags & TF_HasVirtual );
110583 testcase( p->tabFlags & TF_HasStored );
110584 for(ii=0; ii<p->nCol; ii++){
110585 u32 colFlags = p->aCol[ii].colFlags;
110586 if( (colFlags & COLFLAG_GENERATED)!=0 ){
110587 Expr *pX = p->aCol[ii].pDflt;
110588 testcase( colFlags & COLFLAG_VIRTUAL );
110589 testcase( colFlags & COLFLAG_STORED );
110590 if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){
110591 /* If there are errors in resolving the expression, change the
110592 ** expression to a NULL. This prevents code generators that operate
110593 ** on the expression from inserting extra parts into the expression
110594 ** tree that have been allocated from lookaside memory, which is
110595 ** illegal in a schema and will lead to errors heap corruption when
110596 ** the database connection closes. */
110597 sqlite3ExprDelete(db, pX);
110598 p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0);
110599 }
110600 }else{
110601 nNG++;
110602 }
110603 }
110604 if( nNG==0 ){
@@ -110824,11 +110532,10 @@
110824 /* Make a copy of the entire SELECT statement that defines the view.
110825 ** This will force all the Expr.token.z values to be dynamically
110826 ** allocated rather than point to the input string - which means that
110827 ** they will persist after the current sqlite3_exec() call returns.
110828 */
110829 pSelect->selFlags |= SF_View;
110830 if( IN_RENAME_OBJECT ){
110831 p->pSelect = pSelect;
110832 pSelect = 0;
110833 }else{
110834 p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
@@ -112251,13 +111958,30 @@
112251 }
112252
112253 sqlite3VdbeJumpHere(v, pIndex->tnum);
112254 }
112255 }
 
 
 
 
 
 
 
112256 if( db->init.busy || pTblName==0 ){
112257 pIndex->pNext = pTab->pIndex;
112258 pTab->pIndex = pIndex;
 
 
 
 
 
 
 
 
 
 
112259 pIndex = 0;
112260 }
112261 else if( IN_RENAME_OBJECT ){
112262 assert( pParse->pNewIndex==0 );
112263 pParse->pNewIndex = pIndex;
@@ -112265,25 +111989,10 @@
112265 }
112266
112267 /* Clean up before exiting */
112268 exit_create_index:
112269 if( pIndex ) sqlite3FreeIndex(db, pIndex);
112270 if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */
112271 Index **ppFrom = &pTab->pIndex;
112272 Index *pThis;
112273 for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){
112274 Index *pNext;
112275 if( pThis->onError!=OE_Replace ) continue;
112276 while( (pNext = pThis->pNext)!=0 && pNext->onError!=OE_Replace ){
112277 *ppFrom = pNext;
112278 pThis->pNext = pNext->pNext;
112279 pNext->pNext = pThis;
112280 ppFrom = &pNext->pNext;
112281 }
112282 break;
112283 }
112284 }
112285 sqlite3ExprDelete(db, pPIWhere);
112286 sqlite3ExprListDelete(db, pList);
112287 sqlite3SrcListDelete(db, pTblName);
112288 sqlite3DbFree(db, zName);
112289 }
@@ -118522,15 +118231,14 @@
118522 }
118523 return 0;
118524 }
118525
118526 /* This walker callback will compute the union of colFlags flags for all
118527 ** referenced columns in a CHECK constraint or generated column expression.
118528 */
118529 static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){
118530 if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 ){
118531 assert( pExpr->iColumn < pWalker->u.pTab->nCol );
118532 pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags;
118533 }
118534 return WRC_Continue;
118535 }
118536
@@ -118549,40 +118257,10 @@
118549 ){
118550 int i;
118551 Walker w;
118552 Column *pRedo;
118553 int eProgress;
118554 VdbeOp *pOp;
118555
118556 assert( pTab->tabFlags & TF_HasGenerated );
118557 testcase( pTab->tabFlags & TF_HasVirtual );
118558 testcase( pTab->tabFlags & TF_HasStored );
118559
118560 /* Before computing generated columns, first go through and make sure
118561 ** that appropriate affinity has been applied to the regular columns
118562 */
118563 sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore);
118564 if( (pTab->tabFlags & TF_HasStored)!=0
118565 && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity
118566 ){
118567 /* Change the OP_Affinity argument to '@' (NONE) for all stored
118568 ** columns. '@' is the no-op affinity and those columns have not
118569 ** yet been computed. */
118570 int ii, jj;
118571 char *zP4 = pOp->p4.z;
118572 assert( zP4!=0 );
118573 assert( pOp->p4type==P4_DYNAMIC );
118574 for(ii=jj=0; zP4[jj]; ii++){
118575 if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){
118576 continue;
118577 }
118578 if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){
118579 zP4[jj] = SQLITE_AFF_NONE;
118580 }
118581 jj++;
118582 }
118583 }
118584
118585 /* Because there can be multiple generated columns that refer to one another,
118586 ** this is a two-pass algorithm. On the first pass, mark all generated
118587 ** columns as "not available".
118588 */
@@ -119299,14 +118977,10 @@
119299 if( IsVirtual(pTab) ){
119300 sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
119301 pTab->zName);
119302 goto insert_cleanup;
119303 }
119304 if( pTab->pSelect ){
119305 sqlite3ErrorMsg(pParse, "cannot UPSERT a view");
119306 goto insert_cleanup;
119307 }
119308 if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){
119309 goto insert_cleanup;
119310 }
119311 pTabList->a[0].iCursor = iDataCur;
119312 pUpsert->pUpsertSrc = pTabList;
@@ -119537,12 +119211,14 @@
119537
119538 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
119539 /* Compute the new value for generated columns after all other
119540 ** columns have already been computed. This must be done after
119541 ** computing the ROWID in case one of the generated columns
119542 ** is derived from the INTEGER PRIMARY KEY. */
119543 if( pTab->tabFlags & TF_HasGenerated ){
 
 
119544 sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
119545 }
119546 #endif
119547
119548 /* Generate code to check constraints and generate index keys and
@@ -120570,14 +120246,10 @@
120570
120571 v = sqlite3GetVdbe(pParse);
120572 assert( v!=0 );
120573 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
120574 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
120575 /* All REPLACE indexes are at the end of the list */
120576 assert( pIdx->onError!=OE_Replace
120577 || pIdx->pNext==0
120578 || pIdx->pNext->onError==OE_Replace );
120579 if( aRegIdx[i]==0 ) continue;
120580 if( pIdx->pPartIdxWhere ){
120581 sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
120582 VdbeCoverage(v);
120583 }
@@ -125041,13 +124713,11 @@
125041 char *zErr;
125042 int jmp2;
125043 if( j==pTab->iPKey ) continue;
125044 if( pTab->aCol[j].notNull==0 ) continue;
125045 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
125046 if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){
125047 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
125048 }
125049 jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
125050 zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
125051 pTab->aCol[j].zName);
125052 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
125053 integrityCheckResultRow(v);
@@ -127009,14 +126679,11 @@
127009 };
127010 #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
127011
127012 /*
127013 ** Delete all the content of a Select structure. Deallocate the structure
127014 ** itself depending on the value of bFree
127015 **
127016 ** If bFree==1, call sqlite3DbFree() on the p object.
127017 ** If bFree==0, Leave the first Select object unfreed
127018 */
127019 static void clearSelect(sqlite3 *db, Select *p, int bFree){
127020 while( p ){
127021 Select *pPrior = p->pPrior;
127022 sqlite3ExprListDelete(db, p->pEList);
@@ -127116,24 +126783,10 @@
127116 */
127117 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
127118 if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);
127119 }
127120
127121 /*
127122 ** Delete all the substructure for p, but keep p allocated. Redefine
127123 ** p to be a single SELECT where every column of the result set has a
127124 ** value of NULL.
127125 */
127126 SQLITE_PRIVATE void sqlite3SelectReset(Parse *pParse, Select *p){
127127 if( ALWAYS(p) ){
127128 clearSelect(pParse->db, p, 0);
127129 memset(&p->iLimit, 0, sizeof(Select) - offsetof(Select,iLimit));
127130 p->pEList = sqlite3ExprListAppend(pParse, 0,
127131 sqlite3ExprAlloc(pParse->db,TK_NULL,0,0));
127132 }
127133 }
127134
127135 /*
127136 ** Return a pointer to the right-most SELECT statement in a compound.
127137 */
127138 static Select *findRightmost(Select *p){
127139 while( p->pNext ) p = p->pNext;
@@ -129416,11 +129069,10 @@
129416 assert( p->selFlags & SF_MultiValue );
129417 do{
129418 assert( p->selFlags & SF_Values );
129419 assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
129420 assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );
129421 if( p->pWin ) return -1;
129422 if( p->pPrior==0 ) break;
129423 assert( p->pPrior->pNext==p );
129424 p = p->pPrior;
129425 nRow += bShowAll;
129426 }while(1);
@@ -129507,12 +129159,11 @@
129507
129508 /* Special handling for a compound-select that originates as a VALUES clause.
129509 */
129510 if( p->selFlags & SF_MultiValue ){
129511 rc = multiSelectValues(pParse, p, &dest);
129512 if( rc>=0 ) goto multi_select_end;
129513 rc = SQLITE_OK;
129514 }
129515
129516 /* Make sure all SELECTs in the statement have the same number of elements
129517 ** in their result sets.
129518 */
@@ -129653,13 +129304,13 @@
129653
129654 /* Convert the data in the temporary table into whatever form
129655 ** it is that we currently need.
129656 */
129657 assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
129658 assert( p->pEList || db->mallocFailed );
129659 if( dest.eDest!=priorOp && db->mallocFailed==0 ){
129660 int iCont, iBreak, iStart;
 
129661 iBreak = sqlite3VdbeMakeLabel(pParse);
129662 iCont = sqlite3VdbeMakeLabel(pParse);
129663 computeLimitRegisters(pParse, p, iBreak);
129664 sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
129665 iStart = sqlite3VdbeCurrentAddr(v);
@@ -129751,11 +129402,10 @@
129751 if( p->pNext==0 ){
129752 ExplainQueryPlanPop(pParse);
129753 }
129754 #endif
129755 }
129756 if( pParse->nErr ) goto multi_select_end;
129757
129758 /* Compute collating sequences used by
129759 ** temporary tables needed to implement the compound select.
129760 ** Attach the KeyInfo structure to all temporary tables.
129761 **
@@ -130543,11 +130193,10 @@
130543 ** (3) If the subquery is the right operand of a LEFT JOIN then
130544 ** (3a) the subquery may not be a join and
130545 ** (3b) the FROM clause of the subquery may not contain a virtual
130546 ** table and
130547 ** (3c) the outer query may not be an aggregate.
130548 ** (3d) the outer query may not be DISTINCT.
130549 **
130550 ** (4) The subquery can not be DISTINCT.
130551 **
130552 ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
130553 ** sub-queries that were excluded from this optimization. Restriction
@@ -130740,15 +130389,12 @@
130740 **
130741 ** See also tickets #306, #350, and #3300.
130742 */
130743 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
130744 isLeftJoin = 1;
130745 if( pSubSrc->nSrc>1 /* (3a) */
130746 || isAgg /* (3b) */
130747 || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */
130748 || (p->selFlags & SF_Distinct)!=0 /* (3d) */
130749 ){
130750 return 0;
130751 }
130752 }
130753 #ifdef SQLITE_EXTRA_IFNULLROW
130754 else if( iFrom>0 && !isAgg ){
@@ -131518,13 +131164,10 @@
131518 pNew->pHaving = 0;
131519 pNew->pOrderBy = 0;
131520 p->pPrior = 0;
131521 p->pNext = 0;
131522 p->pWith = 0;
131523 #ifndef SQLITE_OMIT_WINDOWFUNC
131524 p->pWinDefn = 0;
131525 #endif
131526 p->selFlags &= ~SF_Compound;
131527 assert( (p->selFlags & SF_Converted)==0 );
131528 p->selFlags |= SF_Converted;
131529 assert( pNew->pPrior!=0 );
131530 pNew->pPrior->pNext = pNew;
@@ -132680,13 +132323,11 @@
132680 if( pDest->eDest==SRT_Output ){
132681 generateColumnNames(pParse, p);
132682 }
132683
132684 #ifndef SQLITE_OMIT_WINDOWFUNC
132685 rc = sqlite3WindowRewrite(pParse, p);
132686 if( rc ){
132687 assert( db->mallocFailed || pParse->nErr>0 );
132688 goto select_end;
132689 }
132690 #if SELECTTRACE_ENABLED
132691 if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
132692 SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
@@ -133018,11 +132659,10 @@
133018 ** written the query must use a temp-table for at least one of the ORDER
133019 ** BY and DISTINCT, and an index or separate temp-table for the other.
133020 */
133021 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
133022 && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
133023 && p->pWin==0
133024 ){
133025 p->selFlags &= ~SF_Distinct;
133026 pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
133027 /* Notice that even thought SF_Distinct has been cleared from p->selFlags,
133028 ** the sDistinct.isTnct is still set. Hence, isTnct represents the
@@ -134542,16 +134182,12 @@
134542 if( ALWAYS(pTrigger) ){
134543 if( pTrigger->pSchema==pTrigger->pTabSchema ){
134544 Table *pTab = tableOfTrigger(pTrigger);
134545 if( pTab ){
134546 Trigger **pp;
134547 for(pp=&pTab->pTrigger; *pp; pp=&((*pp)->pNext)){
134548 if( *pp==pTrigger ){
134549 *pp = (*pp)->pNext;
134550 break;
134551 }
134552 }
134553 }
134554 }
134555 sqlite3DeleteTrigger(db, pTrigger);
134556 db->mDbFlags |= DBFLAG_SchemaChange;
134557 }
@@ -137278,12 +136914,10 @@
137278 char *zWhere;
137279 int iDb;
137280 int iReg;
137281 Vdbe *v;
137282
137283 sqlite3MayAbort(pParse);
137284
137285 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
137286 if( pEnd ){
137287 pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
137288 }
137289 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
@@ -137305,17 +136939,17 @@
137305 pTab->zName,
137306 pTab->zName,
137307 zStmt,
137308 pParse->regRowid
137309 );
 
137310 v = sqlite3GetVdbe(pParse);
137311 sqlite3ChangeCookie(pParse, iDb);
137312
137313 sqlite3VdbeAddOp0(v, OP_Expire);
137314 zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt);
137315 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
137316 sqlite3DbFree(db, zStmt);
137317
137318 iReg = ++pParse->nMem;
137319 sqlite3VdbeLoadString(v, iReg, pTab->zName);
137320 sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
137321 }
@@ -137713,12 +137347,11 @@
137713 return SQLITE_LOCKED;
137714 }
137715 }
137716 p = vtabDisconnectAll(db, pTab);
137717 xDestroy = p->pMod->pModule->xDestroy;
137718 if( xDestroy==0 ) xDestroy = p->pMod->pModule->xDisconnect;
137719 assert( xDestroy!=0 );
137720 pTab->nTabRef++;
137721 rc = xDestroy(p->pVtab);
137722 /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
137723 if( rc==SQLITE_OK ){
137724 assert( pTab->pVTable==p && p->pNext==0 );
@@ -139143,12 +138776,11 @@
139143 int iEq, /* Look at loop terms starting here */
139144 WhereLoop *pLoop, /* The current loop */
139145 Expr *pX /* The IN expression to be reduced */
139146 ){
139147 sqlite3 *db = pParse->db;
139148 Expr *pNew;
139149 pNew = sqlite3ExprDup(db, pX, 0);
139150 if( db->mallocFailed==0 ){
139151 ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */
139152 ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */
139153 ExprList *pRhs = 0; /* New RHS after modifications */
139154 ExprList *pLhs = 0; /* New LHS after mods */
@@ -139856,13 +139488,10 @@
139856 pExpr->affExpr = sqlite3ExprAffinity(pExpr);
139857 pExpr->op = TK_COLUMN;
139858 pExpr->iTable = pX->iIdxCur;
139859 pExpr->iColumn = pX->iIdxCol;
139860 pExpr->y.pTab = 0;
139861 testcase( ExprHasProperty(pExpr, EP_Skip) );
139862 testcase( ExprHasProperty(pExpr, EP_Unlikely) );
139863 ExprClearProperty(pExpr, EP_Skip|EP_Unlikely);
139864 return WRC_Prune;
139865 }else{
139866 return WRC_Continue;
139867 }
139868 }
@@ -139873,12 +139502,10 @@
139873 */
139874 static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){
139875 if( pExpr->op==TK_COLUMN ){
139876 IdxExprTrans *pX = p->u.pIdxTrans;
139877 if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){
139878 assert( pExpr->y.pTab!=0 );
139879 pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn);
139880 pExpr->iTable = pX->iIdxCur;
139881 pExpr->iColumn = pX->iIdxCol;
139882 pExpr->y.pTab = 0;
139883 }
139884 }
@@ -139920,24 +139547,13 @@
139920 for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
139921 i16 iRef = pIdx->aiColumn[iIdxCol];
139922 if( iRef==XN_EXPR ){
139923 assert( aColExpr->a[iIdxCol].pExpr!=0 );
139924 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
139925 if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue;
139926 w.xExprCallback = whereIndexExprTransNode;
139927 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
139928 }else if( iRef>=0
139929 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0
139930 && (pTab->aCol[iRef].zColl==0
139931 || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0)
139932 ){
139933 /* Check to see if there are direct references to generated columns
139934 ** that are contained in the index. Pulling the generated column
139935 ** out of the index is an optimization only - the main table is always
139936 ** available if the index cannot be used. To avoid unnecessary
139937 ** complication, omit this optimization if the collating sequence for
139938 ** the column is non-standard */
139939 x.iTabCol = iRef;
139940 w.xExprCallback = whereIndexExprTransColumn;
139941 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139942 }else{
139943 continue;
@@ -140597,14 +140213,14 @@
140597 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
140598 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
140599 if( omitTable ){
140600 /* pIdx is a covering index. No need to access the main table. */
140601 }else if( HasRowid(pIdx->pTable) ){
140602 if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)
140603 || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0
140604 && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) )
140605 ){
140606 iRowidReg = ++pParse->nMem;
140607 sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);
140608 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);
140609 VdbeCoverage(v);
140610 }else{
@@ -142439,11 +142055,10 @@
142439 Expr *pNewExpr;
142440 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
142441 0, sqlite3ExprDup(db, pRight, 0));
142442 if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
142443 ExprSetProperty(pNewExpr, EP_FromJoin);
142444 pNewExpr->iRightJoinTable = pExpr->iRightJoinTable;
142445 }
142446 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
142447 testcase( idxNew==0 );
142448 pNewTerm = &pWC->a[idxNew];
142449 pNewTerm->prereqRight = prereqExpr;
@@ -142496,19 +142111,15 @@
142496 ** a virtual term for each vector component. The expression object
142497 ** used by each such virtual term is pExpr (the full vector IN(...)
142498 ** expression). The WhereTerm.iField variable identifies the index within
142499 ** the vector on the LHS that the virtual term represents.
142500 **
142501 ** This only works if the RHS is a simple SELECT (not a compound) that does
142502 ** not use window functions.
142503 */
142504 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
142505 && pExpr->pLeft->op==TK_VECTOR
142506 && pExpr->x.pSelect->pPrior==0
142507 #ifndef SQLITE_OMIT_WINDOWFUNC
142508 && pExpr->x.pSelect->pWin==0
142509 #endif
142510 ){
142511 int i;
142512 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
142513 int idxNew;
142514 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
@@ -142662,14 +142273,13 @@
142662 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
142663 }else if( p->x.pList ){
142664 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
142665 }
142666 #ifndef SQLITE_OMIT_WINDOWFUNC
142667 if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){
142668 mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition);
142669 mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy);
142670 mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter);
142671 }
142672 #endif
142673 return mask;
142674 }
142675 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
@@ -143553,12 +143163,11 @@
143553 if( (idxCols & cMask)==0 ){
143554 Expr *pX = pTerm->pExpr;
143555 idxCols |= cMask;
143556 pIdx->aiColumn[n] = pTerm->u.leftColumn;
143557 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
143558 assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
143559 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
143560 n++;
143561 }
143562 }
143563 }
143564 assert( (u32)n==pLoop->u.btree.nEq );
@@ -143732,17 +143341,22 @@
143732 testcase( pTerm->eOperator & WO_IS );
143733 testcase( pTerm->eOperator & WO_ISNULL );
143734 testcase( pTerm->eOperator & WO_ALL );
143735 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
143736 if( pTerm->wtFlags & TERM_VNULL ) continue;
143737
143738 /* tag-20191211-002: WHERE-clause constraints are not useful to the
143739 ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
143740 ** equivalent restriction for ordinary tables. */
143741 if( (pSrc->fg.jointype & JT_LEFT)!=0
143742 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
 
143743 ){
 
 
 
 
 
 
 
 
143744 continue;
143745 }
143746 assert( pTerm->u.leftColumn>=(-1) );
143747 pIdxCons[j].iColumn = pTerm->u.leftColumn;
143748 pIdxCons[j].iTermOffset = i;
@@ -143769,12 +143383,11 @@
143769 assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );
143770
143771 if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
143772 && sqlite3ExprIsVector(pTerm->pExpr->pRight)
143773 ){
143774 testcase( j!=i );
143775 if( j<16 ) mNoOmit |= (1 << j);
143776 if( op==WO_LT ) pIdxCons[j].op = WO_LE;
143777 if( op==WO_GT ) pIdxCons[j].op = WO_GE;
143778 }
143779 }
143780
@@ -144515,16 +144128,14 @@
144515 sqlite3DebugPrintf(
144516 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x",
144517 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
144518 pTerm->eOperator, pTerm->wtFlags);
144519 if( pTerm->iField ){
144520 sqlite3DebugPrintf(" iField=%d", pTerm->iField);
 
 
144521 }
144522 if( pTerm->iParent>=0 ){
144523 sqlite3DebugPrintf(" iParent=%d", pTerm->iParent);
144524 }
144525 sqlite3DebugPrintf("\n");
144526 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
144527 }
144528 }
144529 #endif
144530
@@ -144567,11 +144178,11 @@
144567 sqlite3DebugPrintf("%20s","");
144568 }
144569 }else{
144570 char *z;
144571 if( p->u.vtab.idxStr ){
144572 z = sqlite3_mprintf("(%d,\"%s\",%#x)",
144573 p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);
144574 }else{
144575 z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
144576 }
144577 sqlite3DebugPrintf(" %-19s", z);
@@ -145222,13 +144833,13 @@
145222
145223 /* Do not allow the upper bound of a LIKE optimization range constraint
145224 ** to mix with a lower range bound from some other source */
145225 if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
145226
145227 /* tag-20191211-001: Do not allow constraints from the WHERE clause to
145228 ** be used by the right table of a LEFT JOIN. Only constraints in the
145229 ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */
145230 if( (pSrc->fg.jointype & JT_LEFT)!=0
145231 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
145232 ){
145233 continue;
145234 }
@@ -145541,29 +145152,23 @@
145541 }
145542
145543 /* Check to see if a partial index with pPartIndexWhere can be used
145544 ** in the current query. Return true if it can be and false if not.
145545 */
145546 static int whereUsablePartialIndex(
145547 int iTab, /* The table for which we want an index */
145548 int isLeft, /* True if iTab is the right table of a LEFT JOIN */
145549 WhereClause *pWC, /* The WHERE clause of the query */
145550 Expr *pWhere /* The WHERE clause from the partial index */
145551 ){
145552 int i;
145553 WhereTerm *pTerm;
145554 Parse *pParse = pWC->pWInfo->pParse;
145555 while( pWhere->op==TK_AND ){
145556 if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0;
145557 pWhere = pWhere->pRight;
145558 }
145559 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
145560 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
145561 Expr *pExpr;
145562 pExpr = pTerm->pExpr;
145563 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
145564 && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
145565 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
145566 ){
145567 return 1;
145568 }
145569 }
@@ -145722,15 +145327,12 @@
145722 /* Loop over all indices. If there was an INDEXED BY clause, then only
145723 ** consider index pProbe. */
145724 for(; rc==SQLITE_OK && pProbe;
145725 pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++
145726 ){
145727 int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0;
145728 if( pProbe->pPartIdxWhere!=0
145729 && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC,
145730 pProbe->pPartIdxWhere)
145731 ){
145732 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
145733 continue; /* Partial index inappropriate for this query */
145734 }
145735 if( pProbe->bNoQuery ) continue;
145736 rSize = pProbe->aiRowLogEst[0];
@@ -145953,18 +145555,11 @@
145953 assert( iTerm<pNew->nLSlot );
145954 pNew->aLTerm[iTerm] = pTerm;
145955 if( iTerm>mxTerm ) mxTerm = iTerm;
145956 testcase( iTerm==15 );
145957 testcase( iTerm==16 );
145958 if( pUsage[i].omit ){
145959 if( i<16 && ((1<<i)&mNoOmit)==0 ){
145960 testcase( i!=iTerm );
145961 pNew->u.vtab.omitMask |= 1<<iTerm;
145962 }else{
145963 testcase( i!=iTerm );
145964 }
145965 }
145966 if( (pTerm->eOperator & WO_IN)!=0 ){
145967 /* A virtual table that is constrained by an IN clause may not
145968 ** consume the ORDER BY clause because (1) the order of IN terms
145969 ** is not necessarily related to the order of output terms and
145970 ** (2) Multiple outputs from a single IN value will not merge
@@ -145973,10 +145568,11 @@
145973 pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
145974 *pbIn = 1; assert( (mExclude & WO_IN)==0 );
145975 }
145976 }
145977 }
 
145978
145979 pNew->nLTerm = mxTerm+1;
145980 for(i=0; i<=mxTerm; i++){
145981 if( pNew->aLTerm[i]==0 ){
145982 /* The non-zero argvIdx values must be contiguous. Raise an
@@ -147567,11 +147163,10 @@
147567 sSelect.pEList = pResultSet;
147568 sqlite3TreeViewSelect(0, &sSelect, 0);
147569 }
147570 }
147571 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
147572 sqlite3DebugPrintf("---- WHERE clause at start of analysis:\n");
147573 sqlite3WhereClausePrint(sWLB.pWC);
147574 }
147575 #endif
147576
147577 if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
@@ -147706,17 +147301,11 @@
147706 }
147707 pWInfo->nLevel--;
147708 nTabList--;
147709 }
147710 }
147711 #if defined(WHERETRACE_ENABLED)
147712 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
147713 sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
147714 sqlite3WhereClausePrint(sWLB.pWC);
147715 }
147716 WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));
147717 #endif
147718 pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;
147719
147720 /* If the caller is an UPDATE or DELETE statement that is requesting
147721 ** to use a one-pass algorithm, determine if this is appropriate.
147722 **
@@ -148982,37 +148571,25 @@
148982 }
148983 /* Fall through. */
148984
148985 case TK_AGG_FUNCTION:
148986 case TK_COLUMN: {
148987 int iCol = -1;
148988 if( p->pSub ){
148989 int i;
148990 for(i=0; i<p->pSub->nExpr; i++){
148991 if( 0==sqlite3ExprCompare(0, p->pSub->a[i].pExpr, pExpr, -1) ){
148992 iCol = i;
148993 break;
148994 }
148995 }
148996 }
148997 if( iCol<0 ){
148998 Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
148999 p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
149000 }
149001 if( p->pSub ){
149002 assert( ExprHasProperty(pExpr, EP_Static)==0 );
149003 ExprSetProperty(pExpr, EP_Static);
149004 sqlite3ExprDelete(pParse->db, pExpr);
149005 ExprClearProperty(pExpr, EP_Static);
149006 memset(pExpr, 0, sizeof(Expr));
149007
149008 pExpr->op = TK_COLUMN;
149009 pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol);
149010 pExpr->iTable = p->pWin->iEphCsr;
149011 pExpr->y.pTab = p->pTab;
149012 }
149013 if( pParse->db->mallocFailed ) return WRC_Abort;
149014 break;
149015 }
149016
149017 default: /* no-op */
149018 break;
@@ -149090,15 +148667,13 @@
149090 if( pAppend ){
149091 int i;
149092 int nInit = pList ? pList->nExpr : 0;
149093 for(i=0; i<pAppend->nExpr; i++){
149094 Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
149095 assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
149096 if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
149097 pDup->op = TK_NULL;
149098 pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
149099 pDup->u.zToken = 0;
149100 }
149101 pList = sqlite3ExprListAppend(pParse, pList, pDup);
149102 if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
149103 }
149104 }
@@ -149129,11 +148704,11 @@
149129 Window *pWin; /* Window object iterator */
149130 Table *pTab;
149131
149132 pTab = sqlite3DbMallocZero(db, sizeof(Table));
149133 if( pTab==0 ){
149134 return sqlite3ErrorToParser(db, SQLITE_NOMEM);
149135 }
149136
149137 p->pSrc = 0;
149138 p->pWhere = 0;
149139 p->pGroupBy = 0;
@@ -149216,13 +148791,10 @@
149216 p->pSrc->a[0].pSelect = pSub;
149217 sqlite3SrcListAssignCursors(pParse, p->pSrc);
149218 pSub->selFlags |= SF_Expanded;
149219 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
149220 if( pTab2==0 ){
149221 /* Might actually be some other kind of error, but in that case
149222 ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get
149223 ** the correct error message regardless. */
149224 rc = SQLITE_NOMEM;
149225 }else{
149226 memcpy(pTab, pTab2, sizeof(Table));
149227 pTab->tabFlags |= TF_Ephemeral;
149228 p->pSrc->a[0].pTab = pTab;
@@ -149237,17 +148809,10 @@
149237 }
149238 if( db->mallocFailed ) rc = SQLITE_NOMEM;
149239 sqlite3DbFree(db, pTab);
149240 }
149241
149242 if( rc ){
149243 if( pParse->nErr==0 ){
149244 assert( pParse->db->mallocFailed );
149245 sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM);
149246 }
149247 sqlite3SelectReset(pParse, p);
149248 }
149249 return rc;
149250 }
149251
149252 /*
149253 ** Unlink the Window object from the Select to which it is attached,
@@ -149480,11 +149045,10 @@
149480 /*
149481 ** Return 0 if the two window objects are identical, or non-zero otherwise.
149482 ** Identical window objects can be processed in a single scan.
149483 */
149484 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
149485 if( NEVER(p1==0) || NEVER(p2==0) ) return 1;
149486 if( p1->eFrmType!=p2->eFrmType ) return 1;
149487 if( p1->eStart!=p2->eStart ) return 1;
149488 if( p1->eEnd!=p2->eEnd ) return 1;
149489 if( p1->eExclude!=p2->eExclude ) return 1;
149490 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
@@ -151469,22 +151033,21 @@
151469 #define sqlite3ParserCTX_PDECL ,Parse *pParse
151470 #define sqlite3ParserCTX_PARAM ,pParse
151471 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
151472 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
151473 #define YYFALLBACK 1
151474 #define YYNSTATE 551
151475 #define YYNRULE 385
151476 #define YYNRULE_WITH_ACTION 325
151477 #define YYNTOKEN 181
151478 #define YY_MAX_SHIFT 550
151479 #define YY_MIN_SHIFTREDUCE 801
151480 #define YY_MAX_SHIFTREDUCE 1185
151481 #define YY_ERROR_ACTION 1186
151482 #define YY_ACCEPT_ACTION 1187
151483 #define YY_NO_ACTION 1188
151484 #define YY_MIN_REDUCE 1189
151485 #define YY_MAX_REDUCE 1573
151486 /************* End control #defines *******************************************/
151487 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
151488
151489 /* Define the yytestcase() macro to be a no-op if is not already defined
151490 ** otherwise.
@@ -151549,206 +151112,206 @@
151549 ** yy_default[] Default action for each state.
151550 **
151551 *********** Begin parsing tables **********************************************/
151552 #define YY_ACTTAB_COUNT (1958)
151553 static const YYACTIONTYPE yy_action[] = {
151554 /* 0 */ 544, 1220, 544, 449, 1258, 544, 1237, 544, 114, 111,
151555 /* 10 */ 211, 544, 1535, 544, 1258, 521, 114, 111, 211, 390,
151556 /* 20 */ 1230, 342, 42, 42, 42, 42, 1223, 42, 42, 71,
151557 /* 30 */ 71, 935, 1222, 71, 71, 71, 71, 1460, 1491, 936,
151558 /* 40 */ 818, 451, 6, 121, 122, 112, 1163, 1163, 1004, 1007,
151559 /* 50 */ 997, 997, 119, 119, 120, 120, 120, 120, 1541, 390,
151560 /* 60 */ 1356, 1515, 550, 2, 1191, 194, 526, 434, 143, 291,
151561 /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1271, 525,
151562 /* 80 */ 501, 491, 164, 121, 122, 112, 1163, 1163, 1004, 1007,
151563 /* 90 */ 997, 997, 119, 119, 120, 120, 120, 120, 1356, 440,
151564 /* 100 */ 1512, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151565 /* 110 */ 115, 422, 266, 266, 266, 266, 1496, 356, 1498, 433,
151566 /* 120 */ 355, 1496, 515, 522, 1483, 541, 1112, 541, 1112, 390,
151567 /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221,
151568 /* 140 */ 1027, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151569 /* 150 */ 115, 422, 1140, 121, 122, 112, 1163, 1163, 1004, 1007,
151570 /* 160 */ 997, 997, 119, 119, 120, 120, 120, 120, 404, 426,
151571 /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1416, 466, 123,
151572 /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151573 /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390,
151574 /* 200 */ 503, 120, 120, 120, 120, 113, 1049, 1140, 1141, 1142,
151575 /* 210 */ 1049, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151576 /* 220 */ 115, 422, 1459, 121, 122, 112, 1163, 1163, 1004, 1007,
151577 /* 230 */ 997, 997, 119, 119, 120, 120, 120, 120, 390, 442,
151578 /* 240 */ 314, 83, 461, 81, 357, 380, 1140, 80, 118, 118,
151579 /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179,
151580 /* 260 */ 432, 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997,
151581 /* 270 */ 997, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151582 /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151583 /* 290 */ 115, 422, 541, 1107, 901, 504, 1140, 114, 111, 211,
151584 /* 300 */ 1429, 1140, 1141, 1142, 206, 489, 1107, 390, 447, 1107,
151585 /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1429, 1431, 17,
151586 /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151587 /* 330 */ 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997,
151588 /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1356, 432, 1140,
151589 /* 350 */ 480, 1140, 1141, 1142, 994, 994, 1005, 1008, 443, 118,
151590 /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151591 /* 370 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151592 /* 380 */ 119, 120, 120, 120, 120, 1052, 1052, 463, 1429, 118,
151593 /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151594 /* 400 */ 1140, 449, 544, 1424, 1140, 1141, 1142, 233, 964, 1140,
151595 /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 840,
151596 /* 420 */ 474, 164, 185, 332, 71, 71, 1241, 998, 118, 118,
151597 /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121,
151598 /* 440 */ 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119,
151599 /* 450 */ 120, 120, 120, 120, 390, 1140, 1141, 1142, 833, 12,
151600 /* 460 */ 313, 507, 163, 354, 1140, 1141, 1142, 114, 111, 211,
151601 /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122,
151602 /* 480 */ 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120,
151603 /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118,
151604 /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1140, 209,
151605 /* 510 */ 409, 521, 1140, 1107, 1569, 376, 252, 269, 340, 485,
151606 /* 520 */ 335, 484, 238, 390, 511, 362, 1107, 1125, 331, 1107,
151607 /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118,
151608 /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112,
151609 /* 550 */ 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, 120,
151610 /* 560 */ 120, 120, 390, 1140, 1141, 1142, 985, 1140, 1141, 1142,
151611 /* 570 */ 1140, 233, 490, 1490, 479, 476, 475, 6, 163, 544,
151612 /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1163,
151613 /* 590 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120,
151614 /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117,
151615 /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544,
151616 /* 620 */ 1484, 542, 1140, 890, 890, 1140, 1141, 1142, 1471, 1140,
151617 /* 630 */ 275, 390, 806, 807, 808, 969, 420, 420, 420, 16,
151618 /* 640 */ 16, 55, 55, 1240, 118, 118, 118, 118, 117, 117,
151619 /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1163, 1163,
151620 /* 660 */ 1004, 1007, 997, 997, 119, 119, 120, 120, 120, 120,
151621 /* 670 */ 390, 1187, 1, 1, 550, 2, 1191, 1140, 1141, 1142,
151622 /* 680 */ 194, 291, 896, 136, 1140, 1141, 1142, 895, 519, 1490,
151623 /* 690 */ 1271, 3, 378, 6, 121, 122, 112, 1163, 1163, 1004,
151624 /* 700 */ 1007, 997, 997, 119, 119, 120, 120, 120, 120, 856,
151625 /* 710 */ 544, 922, 544, 118, 118, 118, 118, 117, 117, 116,
151626 /* 720 */ 116, 116, 115, 422, 266, 266, 1090, 1567, 1140, 549,
151627 /* 730 */ 1567, 1191, 13, 13, 13, 13, 291, 541, 136, 390,
151628 /* 740 */ 483, 419, 418, 964, 342, 1271, 466, 408, 857, 279,
151629 /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116,
151630 /* 760 */ 116, 115, 422, 121, 122, 112, 1163, 1163, 1004, 1007,
151631 /* 770 */ 997, 997, 119, 119, 120, 120, 120, 120, 544, 266,
151632 /* 780 */ 266, 426, 390, 1140, 1141, 1142, 1170, 828, 1170, 466,
151633 /* 790 */ 429, 145, 541, 1144, 399, 313, 437, 301, 836, 1488,
151634 /* 800 */ 71, 71, 410, 6, 1088, 471, 221, 100, 112, 1163,
151635 /* 810 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120,
151636 /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151637 /* 830 */ 115, 422, 237, 1423, 544, 449, 426, 287, 984, 544,
151638 /* 840 */ 236, 235, 234, 828, 97, 527, 427, 1263, 1263, 1144,
151639 /* 850 */ 492, 306, 428, 836, 975, 544, 71, 71, 974, 1239,
151640 /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117,
151641 /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266,
151642 /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 974,
151643 /* 890 */ 974, 976, 541, 526, 1107, 326, 390, 541, 493, 395,
151644 /* 900 */ 1468, 195, 528, 13, 13, 1356, 240, 1107, 277, 280,
151645 /* 910 */ 1107, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151646 /* 920 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151647 /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 984,
151648 /* 940 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151649 /* 950 */ 119, 120, 120, 120, 120, 975, 321, 1140, 324, 974,
151650 /* 960 */ 121, 110, 112, 1163, 1163, 1004, 1007, 997, 997, 119,
151651 /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1183, 118, 118,
151652 /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1140,
151653 /* 990 */ 974, 974, 976, 304, 9, 364, 244, 360, 118, 118,
151654 /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312,
151655 /* 1010 */ 544, 342, 1140, 1141, 1142, 299, 290, 535, 118, 118,
151656 /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1261,
151657 /* 1030 */ 1261, 1161, 13, 13, 278, 419, 418, 466, 390, 921,
151658 /* 1040 */ 260, 260, 289, 1167, 1140, 1141, 1142, 189, 1169, 266,
151659 /* 1050 */ 266, 466, 388, 541, 1184, 544, 1168, 263, 144, 487,
151660 /* 1060 */ 920, 544, 541, 122, 112, 1163, 1163, 1004, 1007, 997,
151661 /* 1070 */ 997, 119, 119, 120, 120, 120, 120, 71, 71, 1140,
151662 /* 1080 */ 1170, 1270, 1170, 13, 13, 896, 1068, 1161, 544, 466,
151663 /* 1090 */ 895, 107, 536, 1489, 4, 1266, 1107, 6, 523, 1047,
151664 /* 1100 */ 12, 1069, 1090, 1568, 311, 453, 1568, 518, 539, 1107,
151665 /* 1110 */ 56, 56, 1107, 1487, 421, 1356, 1070, 6, 343, 285,
151666 /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151667 /* 1130 */ 422, 423, 1269, 319, 1140, 1141, 1142, 876, 266, 266,
151668 /* 1140 */ 1275, 107, 536, 533, 4, 1486, 293, 877, 1209, 6,
151669 /* 1150 */ 210, 541, 541, 164, 1540, 494, 414, 865, 539, 267,
151670 /* 1160 */ 267, 1212, 396, 509, 497, 204, 266, 266, 394, 529,
151671 /* 1170 */ 8, 984, 541, 517, 544, 920, 456, 105, 105, 541,
151672 /* 1180 */ 1088, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151673 /* 1190 */ 266, 974, 516, 533, 1371, 541, 15, 15, 266, 266,
151674 /* 1200 */ 454, 1118, 541, 266, 266, 1068, 1370, 513, 290, 535,
151675 /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 920, 125,
151676 /* 1220 */ 1069, 984, 974, 974, 976, 977, 27, 105, 105, 399,
151677 /* 1230 */ 341, 1509, 44, 44, 106, 1070, 423, 546, 545, 57,
151678 /* 1240 */ 57, 974, 341, 1509, 107, 536, 544, 4, 460, 399,
151679 /* 1250 */ 214, 1118, 457, 294, 375, 1089, 532, 297, 544, 537,
151680 /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58,
151681 /* 1270 */ 544, 109, 974, 974, 976, 977, 27, 1514, 1129, 425,
151682 /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372,
151683 /* 1290 */ 255, 370, 60, 60, 815, 1178, 533, 544, 273, 544,
151684 /* 1300 */ 1161, 843, 387, 386, 544, 1307, 544, 215, 210, 296,
151685 /* 1310 */ 513, 847, 544, 265, 208, 514, 1306, 295, 274, 61,
151686 /* 1320 */ 61, 62, 62, 436, 984, 1160, 45, 45, 46, 46,
151687 /* 1330 */ 105, 105, 1184, 920, 47, 47, 1474, 106, 544, 423,
151688 /* 1340 */ 546, 545, 218, 544, 974, 935, 1085, 217, 544, 377,
151689 /* 1350 */ 395, 107, 536, 936, 4, 156, 1161, 843, 158, 544,
151690 /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307,
151691 /* 1370 */ 63, 63, 544, 1448, 216, 974, 974, 976, 977, 27,
151692 /* 1380 */ 444, 64, 64, 544, 1447, 65, 65, 544, 524, 14,
151693 /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97,
151694 /* 1400 */ 1034, 544, 961, 533, 268, 127, 127, 544, 391, 67,
151695 /* 1410 */ 67, 544, 978, 290, 535, 52, 52, 513, 544, 68,
151696 /* 1420 */ 68, 1294, 512, 69, 69, 397, 165, 855, 854, 53,
151697 /* 1430 */ 53, 984, 966, 151, 151, 243, 430, 105, 105, 199,
151698 /* 1440 */ 152, 152, 448, 1303, 106, 243, 423, 546, 545, 1129,
151699 /* 1450 */ 425, 974, 320, 270, 862, 863, 1034, 220, 373, 373,
151700 /* 1460 */ 372, 255, 370, 450, 323, 815, 243, 544, 978, 544,
151701 /* 1470 */ 107, 536, 544, 4, 544, 938, 939, 325, 215, 1046,
151702 /* 1480 */ 296, 1046, 974, 974, 976, 977, 27, 539, 295, 76,
151703 /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1503, 1254,
151704 /* 1500 */ 107, 536, 544, 4, 1045, 544, 1045, 531, 1238, 544,
151705 /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544,
151706 /* 1520 */ 472, 1528, 533, 239, 73, 73, 156, 129, 129, 158,
151707 /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149,
151708 /* 1540 */ 423, 134, 134, 329, 1030, 216, 97, 239, 929, 345,
151709 /* 1550 */ 984, 243, 533, 1315, 339, 544, 105, 105, 900, 1355,
151710 /* 1560 */ 544, 1290, 258, 106, 338, 423, 546, 545, 544, 1301,
151711 /* 1570 */ 974, 893, 99, 536, 109, 4, 544, 133, 133, 391,
151712 /* 1580 */ 984, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151713 /* 1590 */ 132, 132, 1361, 106, 1219, 423, 546, 545, 75, 75,
151714 /* 1600 */ 974, 974, 974, 976, 977, 27, 544, 430, 826, 1211,
151715 /* 1610 */ 894, 139, 423, 109, 544, 1200, 1199, 1201, 1522, 544,
151716 /* 1620 */ 201, 544, 11, 374, 533, 1287, 347, 349, 77, 77,
151717 /* 1630 */ 1340, 974, 974, 976, 977, 27, 74, 74, 351, 213,
151718 /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1348, 382,
151719 /* 1650 */ 353, 452, 984, 337, 1237, 1420, 1419, 205, 105, 105,
151720 /* 1660 */ 192, 367, 193, 534, 1525, 106, 1178, 423, 546, 545,
151721 /* 1670 */ 247, 167, 974, 270, 1467, 200, 1465, 1175, 373, 373,
151722 /* 1680 */ 372, 255, 370, 398, 79, 815, 83, 82, 1425, 446,
151723 /* 1690 */ 161, 177, 169, 95, 1337, 438, 172, 173, 215, 174,
151724 /* 1700 */ 296, 175, 35, 974, 974, 976, 977, 27, 295, 1345,
151725 /* 1710 */ 439, 470, 223, 36, 379, 445, 1414, 381, 459, 1351,
151726 /* 1720 */ 181, 227, 88, 465, 259, 229, 1436, 318, 186, 468,
151727 /* 1730 */ 322, 230, 384, 1202, 231, 486, 1257, 1256, 217, 411,
151728 /* 1740 */ 1255, 1248, 90, 847, 206, 413, 156, 505, 1539, 158,
151729 /* 1750 */ 1226, 1538, 283, 1508, 1227, 336, 385, 284, 1225, 496,
151730 /* 1760 */ 1537, 1298, 94, 346, 348, 216, 1247, 499, 1299, 245,
151731 /* 1770 */ 246, 1297, 416, 350, 1494, 124, 1493, 10, 524, 361,
151732 /* 1780 */ 1400, 101, 96, 288, 508, 253, 1135, 1208, 34, 1296,
151733 /* 1790 */ 547, 254, 256, 257, 392, 548, 1197, 1192, 359, 391,
151734 /* 1800 */ 1280, 1279, 196, 365, 290, 535, 366, 352, 1452, 1322,
151735 /* 1810 */ 1321, 1453, 153, 137, 281, 154, 802, 424, 155, 1451,
151736 /* 1820 */ 1450, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151737 /* 1830 */ 1044, 1042, 958, 168, 219, 157, 170, 879, 308, 222,
151738 /* 1840 */ 1058, 176, 159, 962, 400, 84, 402, 178, 85, 86,
151739 /* 1850 */ 87, 166, 160, 393, 1061, 224, 225, 1057, 146, 18,
151740 /* 1860 */ 226, 317, 1050, 1172, 243, 464, 182, 228, 37, 183,
151741 /* 1870 */ 817, 469, 338, 232, 330, 481, 184, 89, 845, 19,
151742 /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 858, 147, 488,
151743 /* 1890 */ 282, 1123, 148, 1010, 928, 1093, 39, 93, 40, 495,
151744 /* 1900 */ 1094, 187, 498, 207, 262, 264, 923, 242, 1109, 109,
151745 /* 1910 */ 1113, 1111, 1097, 33, 21, 1117, 520, 1025, 22, 23,
151746 /* 1920 */ 24, 1116, 25, 190, 97, 1011, 1009, 26, 1013, 1067,
151747 /* 1930 */ 248, 7, 1066, 249, 1014, 28, 41, 889, 979, 827,
151748 /* 1940 */ 108, 29, 250, 540, 251, 1530, 371, 368, 1131, 1130,
151749 /* 1950 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1529,
151750 };
151751 static const YYCODETYPE yy_lookahead[] = {
151752 /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268,
151753 /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19,
151754 /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211,
@@ -151941,11 +151504,11 @@
151941 /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24,
151942 /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26,
151943 /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34,
151944 /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23,
151945 /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23,
151946 /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 1,
151947 /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310,
151948 /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151949 /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151950 /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151951 /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
@@ -151962,13 +151525,13 @@
151962 /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151963 /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151964 /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151965 /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310,
151966 };
151967 #define YY_SHIFT_COUNT (550)
151968 #define YY_SHIFT_MIN (0)
151969 #define YY_SHIFT_MAX (1948)
151970 static const unsigned short int yy_shift_ofst[] = {
151971 /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481,
151972 /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481,
151973 /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151974 /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340,
@@ -152021,11 +151584,10 @@
152021 /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884,
152022 /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889,
152023 /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905,
152024 /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918,
152025 /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947,
152026 /* 550 */ 1948,
152027 };
152028 #define YY_REDUCE_COUNT (389)
152029 #define YY_REDUCE_MIN (-262)
152030 #define YY_REDUCE_MAX (1617)
152031 static const short yy_reduce_ofst[] = {
@@ -152068,66 +151630,65 @@
152068 /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592,
152069 /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600,
152070 /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616,
152071 };
152072 static const YYACTIONTYPE yy_default[] = {
152073 /* 0 */ 1573, 1573, 1573, 1409, 1186, 1295, 1186, 1186, 1186, 1409,
152074 /* 10 */ 1409, 1409, 1186, 1325, 1325, 1462, 1217, 1186, 1186, 1186,
152075 /* 20 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1408, 1186, 1186,
152076 /* 30 */ 1186, 1186, 1492, 1492, 1186, 1186, 1186, 1186, 1186, 1186,
152077 /* 40 */ 1186, 1186, 1186, 1334, 1186, 1186, 1186, 1186, 1186, 1186,
152078 /* 50 */ 1410, 1411, 1186, 1186, 1186, 1461, 1463, 1426, 1344, 1343,
152079 /* 60 */ 1342, 1341, 1444, 1312, 1339, 1332, 1336, 1404, 1405, 1403,
152080 /* 70 */ 1407, 1411, 1410, 1186, 1335, 1375, 1389, 1374, 1186, 1186,
152081 /* 80 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152082 /* 90 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152083 /* 100 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152084 /* 110 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152085 /* 120 */ 1186, 1186, 1186, 1186, 1186, 1186, 1383, 1388, 1394, 1387,
152086 /* 130 */ 1384, 1377, 1376, 1378, 1379, 1186, 1207, 1259, 1186, 1186,
152087 /* 140 */ 1186, 1186, 1480, 1479, 1186, 1186, 1217, 1369, 1368, 1380,
152088 /* 150 */ 1381, 1391, 1390, 1469, 1527, 1526, 1427, 1186, 1186, 1186,
152089 /* 160 */ 1186, 1186, 1186, 1492, 1186, 1186, 1186, 1186, 1186, 1186,
152090 /* 170 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152091 /* 180 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1492, 1492,
152092 /* 190 */ 1186, 1217, 1492, 1492, 1213, 1213, 1319, 1186, 1475, 1295,
152093 /* 200 */ 1286, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152094 /* 210 */ 1186, 1186, 1186, 1186, 1186, 1466, 1464, 1186, 1186, 1186,
152095 /* 220 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152096 /* 230 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152097 /* 240 */ 1186, 1186, 1186, 1186, 1186, 1291, 1186, 1186, 1186, 1186,
152098 /* 250 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1521, 1186, 1439,
152099 /* 260 */ 1273, 1291, 1291, 1291, 1291, 1293, 1274, 1272, 1285, 1218,
152100 /* 270 */ 1193, 1565, 1338, 1314, 1314, 1562, 1338, 1338, 1562, 1234,
152101 /* 280 */ 1543, 1229, 1325, 1325, 1325, 1314, 1319, 1319, 1406, 1292,
152102 /* 290 */ 1285, 1186, 1565, 1300, 1300, 1564, 1564, 1300, 1427, 1347,
152103 /* 300 */ 1353, 1262, 1338, 1268, 1268, 1268, 1268, 1300, 1204, 1338,
152104 /* 310 */ 1338, 1347, 1353, 1262, 1262, 1338, 1300, 1204, 1443, 1559,
152105 /* 320 */ 1300, 1204, 1417, 1300, 1204, 1300, 1204, 1417, 1260, 1260,
152106 /* 330 */ 1260, 1249, 1186, 1186, 1417, 1260, 1234, 1260, 1249, 1260,
152107 /* 340 */ 1260, 1510, 1417, 1421, 1421, 1417, 1318, 1313, 1318, 1313,
152108 /* 350 */ 1318, 1313, 1318, 1313, 1300, 1502, 1502, 1328, 1328, 1333,
152109 /* 360 */ 1319, 1412, 1300, 1186, 1333, 1331, 1329, 1338, 1210, 1252,
152110 /* 370 */ 1524, 1524, 1520, 1520, 1520, 1570, 1570, 1475, 1536, 1217,
152111 /* 380 */ 1217, 1217, 1217, 1536, 1236, 1236, 1218, 1218, 1217, 1536,
152112 /* 390 */ 1186, 1186, 1186, 1186, 1186, 1186, 1531, 1186, 1428, 1304,
152113 /* 400 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152114 /* 410 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152115 /* 420 */ 1186, 1186, 1186, 1358, 1186, 1189, 1472, 1186, 1186, 1470,
152116 /* 430 */ 1186, 1186, 1186, 1186, 1186, 1186, 1305, 1186, 1186, 1186,
152117 /* 440 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152118 /* 450 */ 1186, 1186, 1186, 1186, 1186, 1561, 1186, 1186, 1186, 1186,
152119 /* 460 */ 1186, 1186, 1442, 1441, 1186, 1186, 1302, 1186, 1186, 1186,
152120 /* 470 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152121 /* 480 */ 1232, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152122 /* 490 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152123 /* 500 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1330, 1186, 1186,
152124 /* 510 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152125 /* 520 */ 1186, 1186, 1507, 1320, 1186, 1186, 1552, 1186, 1186, 1186,
152126 /* 530 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186,
152127 /* 540 */ 1186, 1547, 1276, 1360, 1186, 1359, 1363, 1186, 1198, 1186,
152128 /* 550 */ 1186,
152129 };
152130 /********** End of lemon-generated parsing tables *****************************/
152131
152132 /* The next table maps tokens (terminal symbols) into fallback tokens.
152133 ** If a construct like the following:
@@ -153058,11 +152619,11 @@
153058 /* 325 */ "input ::= cmdlist",
153059 /* 326 */ "cmdlist ::= cmdlist ecmd",
153060 /* 327 */ "cmdlist ::= ecmd",
153061 /* 328 */ "ecmd ::= SEMI",
153062 /* 329 */ "ecmd ::= cmdx SEMI",
153063 /* 330 */ "ecmd ::= explain cmdx SEMI",
153064 /* 331 */ "trans_opt ::=",
153065 /* 332 */ "trans_opt ::= TRANSACTION",
153066 /* 333 */ "trans_opt ::= TRANSACTION nm",
153067 /* 334 */ "savepoint_opt ::= SAVEPOINT",
153068 /* 335 */ "savepoint_opt ::=",
@@ -153950,11 +153511,11 @@
153950 181, /* (325) input ::= cmdlist */
153951 182, /* (326) cmdlist ::= cmdlist ecmd */
153952 182, /* (327) cmdlist ::= ecmd */
153953 183, /* (328) ecmd ::= SEMI */
153954 183, /* (329) ecmd ::= cmdx SEMI */
153955 183, /* (330) ecmd ::= explain cmdx SEMI */
153956 188, /* (331) trans_opt ::= */
153957 188, /* (332) trans_opt ::= TRANSACTION */
153958 188, /* (333) trans_opt ::= TRANSACTION nm */
153959 190, /* (334) savepoint_opt ::= SAVEPOINT */
153960 190, /* (335) savepoint_opt ::= */
@@ -154340,11 +153901,11 @@
154340 -1, /* (325) input ::= cmdlist */
154341 -2, /* (326) cmdlist ::= cmdlist ecmd */
154342 -1, /* (327) cmdlist ::= ecmd */
154343 -1, /* (328) ecmd ::= SEMI */
154344 -2, /* (329) ecmd ::= cmdx SEMI */
154345 -3, /* (330) ecmd ::= explain cmdx SEMI */
154346 0, /* (331) trans_opt ::= */
154347 -1, /* (332) trans_opt ::= TRANSACTION */
154348 -2, /* (333) trans_opt ::= TRANSACTION nm */
154349 -1, /* (334) savepoint_opt ::= SAVEPOINT */
154350 0, /* (335) savepoint_opt ::= */
@@ -154428,19 +153989,16 @@
154428 yymsp = yypParser->yytos;
154429 #ifndef NDEBUG
154430 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
154431 yysize = yyRuleInfoNRhs[yyruleno];
154432 if( yysize ){
154433 fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
154434 yyTracePrompt,
154435 yyruleno, yyRuleName[yyruleno],
154436 yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
154437 yymsp[yysize].stateno);
154438 }else{
154439 fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
154440 yyTracePrompt, yyruleno, yyRuleName[yyruleno],
154441 yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
154442 }
154443 }
154444 #endif /* NDEBUG */
154445
154446 /* Check that the stack is large enough to grow by a single entry
@@ -155847,11 +155405,11 @@
155847 /* (325) input ::= cmdlist */ yytestcase(yyruleno==325);
155848 /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326);
155849 /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327);
155850 /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328);
155851 /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329);
155852 /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330);
155853 /* (331) trans_opt ::= */ yytestcase(yyruleno==331);
155854 /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332);
155855 /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333);
155856 /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334);
155857 /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335);
@@ -163524,13 +163082,10 @@
163524 # define TESTONLY(X) X
163525 #else
163526 # define TESTONLY(X)
163527 #endif
163528
163529 #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
163530 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
163531
163532 #endif /* SQLITE_AMALGAMATION */
163533
163534 #ifdef SQLITE_DEBUG
163535 SQLITE_PRIVATE int sqlite3Fts3Corrupt(void);
163536 # define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()
@@ -163570,11 +163125,10 @@
163570 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
163571 char *zContentTbl; /* content=xxx option, or NULL */
163572 char *zLanguageid; /* languageid=xxx option, or NULL */
163573 int nAutoincrmerge; /* Value configured by 'automerge' */
163574 u32 nLeafAdd; /* Number of leaf blocks added this trans */
163575 int bLock; /* Used to prevent recursive content= tbls */
163576
163577 /* Precompiled statements used by the implementation. Each of these
163578 ** statements is run and reset within a single virtual table API call.
163579 */
163580 sqlite3_stmt *aStmt[40];
@@ -163909,11 +163463,10 @@
163909
163910 /* fts3.c */
163911 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
163912 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
163913 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
163914 SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *, sqlite_uint64 *);
163915 SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*);
163916 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
163917 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
163918 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
163919 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
@@ -163997,10 +163550,22 @@
163997 #ifndef SQLITE_CORE
163998 /* # include "sqlite3ext.h" */
163999 SQLITE_EXTENSION_INIT1
164000 #endif
164001
 
 
 
 
 
 
 
 
 
 
 
 
164002 static int fts3EvalNext(Fts3Cursor *pCsr);
164003 static int fts3EvalStart(Fts3Cursor *pCsr);
164004 static int fts3TermSegReaderCursor(
164005 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
164006
@@ -164041,11 +163606,16 @@
164041 if( (v & mask2)==0 ){ var = v; return ret; }
164042 #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
164043 v = (*ptr++); \
164044 if( (v & mask2)==0 ){ var = v; return ret; }
164045
164046 SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){
 
 
 
 
 
164047 const unsigned char *p = (const unsigned char*)pBuf;
164048 const unsigned char *pStart = p;
164049 u32 a;
164050 u64 b;
164051 int shift;
@@ -164063,19 +163633,10 @@
164063 }
164064 *v = b;
164065 return (int)(p - pStart);
164066 }
164067
164068 /*
164069 ** Read a 64-bit variable-length integer from memory starting at p[0].
164070 ** Return the number of bytes read, or 0 on error.
164071 ** The value is stored in *v.
164072 */
164073 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
164074 return sqlite3Fts3GetVarintU(pBuf, (sqlite3_uint64*)v);
164075 }
164076
164077 /*
164078 ** Read a 64-bit variable-length integer from memory starting at p[0] and
164079 ** not extending past pEnd[-1].
164080 ** Return the number of bytes read, or 0 on error.
164081 ** The value is stored in *v.
@@ -165292,14 +164853,10 @@
165292 int iLangidCons = -1; /* Index of langid=x constraint, if present */
165293 int iDocidGe = -1; /* Index of docid>=x constraint, if present */
165294 int iDocidLe = -1; /* Index of docid<=x constraint, if present */
165295 int iIdx;
165296
165297 if( p->bLock ){
165298 return SQLITE_ERROR;
165299 }
165300
165301 /* By default use a full table scan. This is an expensive option,
165302 ** so search through the constraints to see if a more efficient
165303 ** strategy is possible.
165304 */
165305 pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
@@ -165494,15 +165051,11 @@
165494 pCsr->pStmt = p->pSeekStmt;
165495 p->pSeekStmt = 0;
165496 }else{
165497 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
165498 if( !zSql ) return SQLITE_NOMEM;
165499 p->bLock++;
165500 rc = sqlite3_prepare_v3(
165501 p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0
165502 );
165503 p->bLock--;
165504 sqlite3_free(zSql);
165505 }
165506 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
165507 }
165508 return rc;
@@ -165516,19 +165069,15 @@
165516 static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
165517 int rc = SQLITE_OK;
165518 if( pCsr->isRequireSeek ){
165519 rc = fts3CursorSeekStmt(pCsr);
165520 if( rc==SQLITE_OK ){
165521 Fts3Table *pTab = (Fts3Table*)pCsr->base.pVtab;
165522 pTab->bLock++;
165523 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
165524 pCsr->isRequireSeek = 0;
165525 if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
165526 pTab->bLock--;
165527 return SQLITE_OK;
165528 }else{
165529 pTab->bLock--;
165530 rc = sqlite3_reset(pCsr->pStmt);
165531 if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){
165532 /* If no row was found and no error has occurred, then the %_content
165533 ** table is missing a row that is present in the full-text index.
165534 ** The data structures are corrupt. */
@@ -165696,11 +165245,11 @@
165696
165697 assert( piLeaf || piLeaf2 );
165698
165699 fts3GetVarint32(zNode, &iHeight);
165700 rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
165701 assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
165702
165703 if( rc==SQLITE_OK && iHeight>1 ){
165704 char *zBlob = 0; /* Blob read from %_segments table */
165705 int nBlob = 0; /* Size of zBlob in bytes */
165706
@@ -166177,16 +165726,16 @@
166177 sqlite3_int64 *pVal /* IN/OUT: Integer value */
166178 ){
166179 if( *pp>=pEnd ){
166180 *pp = 0;
166181 }else{
166182 u64 iVal;
166183 *pp += sqlite3Fts3GetVarintU(*pp, &iVal);
166184 if( bDescIdx ){
166185 *pVal = (i64)((u64)*pVal - iVal);
166186 }else{
166187 *pVal = (i64)((u64)*pVal + iVal);
166188 }
166189 }
166190 }
166191
166192 /*
@@ -166212,14 +165761,14 @@
166212 sqlite3_int64 iVal /* Write this value to the list */
166213 ){
166214 sqlite3_uint64 iWrite;
166215 if( bDescIdx==0 || *pbFirst==0 ){
166216 assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev );
166217 iWrite = (u64)iVal - (u64)*piPrev;
166218 }else{
166219 assert_fts3_nc( *piPrev>=iVal );
166220 iWrite = (u64)*piPrev - (u64)iVal;
166221 }
166222 assert( *pbFirst || *piPrev==0 );
166223 assert_fts3_nc( *pbFirst==0 || iWrite>0 );
166224 *pp += sqlite3Fts3PutVarint(*pp, iWrite);
166225 *piPrev = iVal;
@@ -166234,12 +165783,11 @@
166234 ** Otherwise, (i2-i1).
166235 **
166236 ** Using this makes it easier to write code that can merge doclists that are
166237 ** sorted in either ascending or descending order.
166238 */
166239 /* #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i64)((u64)i1-i2)) */
166240 #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1>i2?1:((i1==i2)?0:-1)))
166241
166242 /*
166243 ** This function does an "OR" merge of two doclists (output contains all
166244 ** positions contained in either argument doclist). If the docids in the
166245 ** input doclists are sorted in ascending order, parameter bDescDoclist
@@ -166649,11 +166197,11 @@
166649 ** for the pending-terms. If this is a scan, then this call must be being
166650 ** made by an fts4aux module, not an FTS table. In this case calling
166651 ** Fts3SegReaderPending might segfault, as the data structures used by
166652 ** fts4aux are not completely populated. So it's easiest to filter these
166653 ** calls out here. */
166654 if( iLevel<0 && p->aIndex && p->iPrevLangid==iLangid ){
166655 Fts3SegReader *pSeg = 0;
166656 rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
166657 if( rc==SQLITE_OK && pSeg ){
166658 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
166659 }
@@ -166912,20 +166460,17 @@
166912 */
166913 static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){
166914 int rc;
166915 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
166916 if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){
166917 Fts3Table *pTab = (Fts3Table*)pCursor->pVtab;
166918 pTab->bLock++;
166919 if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){
166920 pCsr->isEof = 1;
166921 rc = sqlite3_reset(pCsr->pStmt);
166922 }else{
166923 pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);
166924 rc = SQLITE_OK;
166925 }
166926 pTab->bLock--;
166927 }else{
166928 rc = fts3EvalNext((Fts3Cursor *)pCursor);
166929 }
166930 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
166931 return rc;
@@ -166982,14 +166527,10 @@
166982 int iIdx;
166983
166984 UNUSED_PARAMETER(idxStr);
166985 UNUSED_PARAMETER(nVal);
166986
166987 if( p->bLock ){
166988 return SQLITE_ERROR;
166989 }
166990
166991 eSearch = (idxNum & 0x0000FFFF);
166992 assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
166993 assert( p->pSegments==0 );
166994
166995 /* Collect arguments into local variables */
@@ -167057,15 +166598,11 @@
167057 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
167058 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
167059 );
167060 }
167061 if( zSql ){
167062 p->bLock++;
167063 rc = sqlite3_prepare_v3(
167064 p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0
167065 );
167066 p->bLock--;
167067 sqlite3_free(zSql);
167068 }else{
167069 rc = SQLITE_NOMEM;
167070 }
167071 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -168220,20 +167757,19 @@
168220 Fts3Table *pTab,
168221 Fts3Doclist *pDL,
168222 u8 *pbEof
168223 ){
168224 char *pIter; /* Used to iterate through aAll */
168225 char *pEnd; /* 1 byte past end of aAll */
168226
168227 if( pDL->pNextDocid ){
168228 pIter = pDL->pNextDocid;
168229 assert( pDL->aAll!=0 || pIter==0 );
168230 }else{
168231 pIter = pDL->aAll;
168232 }
168233
168234 if( pIter==0 || pIter>=(pEnd = pDL->aAll + pDL->nAll) ){
168235 /* We have already reached the end of this doclist. EOF. */
168236 *pbEof = 1;
168237 }else{
168238 sqlite3_int64 iDelta;
168239 pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
@@ -174569,11 +174105,11 @@
174569 int rc = SQLITE_OK;
174570
174571 assert( !p || p->iLastDocid<=iDocid );
174572
174573 if( !p || p->iLastDocid!=iDocid ){
174574 u64 iDelta = (u64)iDocid - (u64)(p ? p->iLastDocid : 0);
174575 if( p ){
174576 assert( p->nData<p->nSpace );
174577 assert( p->aData[p->nData]==0 );
174578 p->nData++;
174579 }
@@ -175110,12 +174646,10 @@
175110 aByte = 0;
175111 }
175112 }
175113 *paBlob = aByte;
175114 }
175115 }else if( rc==SQLITE_ERROR ){
175116 rc = FTS_CORRUPT_VTAB;
175117 }
175118
175119 return rc;
175120 }
175121
@@ -175404,22 +174938,22 @@
175404 if( p>=pEnd ){
175405 pReader->pOffsetList = 0;
175406 }else{
175407 rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
175408 if( rc==SQLITE_OK ){
175409 u64 iDelta;
175410 pReader->pOffsetList = p + sqlite3Fts3GetVarintU(p, &iDelta);
175411 if( pTab->bDescIdx ){
175412 pReader->iDocid = (i64)((u64)pReader->iDocid - iDelta);
175413 }else{
175414 pReader->iDocid = (i64)((u64)pReader->iDocid + iDelta);
175415 }
175416 }
175417 }
175418 }
175419
175420 return rc;
175421 }
175422
175423
175424 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(
175425 Fts3Cursor *pCsr,
@@ -176154,11 +175688,10 @@
176154
176155 if( nData>0 && nData+nReq>p->nNodeSize ){
176156 int rc;
176157
176158 /* The current leaf node is full. Write it out to the database. */
176159 if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB;
176160 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
176161 if( rc!=SQLITE_OK ) return rc;
176162 p->nLeafAdd++;
176163
176164 /* Add the current term to the interior node tree. The term added to
@@ -176852,14 +176385,14 @@
176852 /* Calculate the 'docid' delta value to write into the merged
176853 ** doclist. */
176854 sqlite3_int64 iDelta;
176855 if( p->bDescIdx && nDoclist>0 ){
176856 if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB;
176857 iDelta = (i64)((u64)iPrev - (u64)iDocid);
176858 }else{
176859 if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB;
176860 iDelta = (i64)((u64)iDocid - (u64)iPrev);
176861 }
176862
176863 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
176864 if( nDoclist+nByte>pCsr->nBuffer ){
176865 char *aNew;
@@ -177138,11 +176671,11 @@
177138 if( rc!=SQLITE_ROW ) break;
177139 rc = fts3SegWriterAdd(p, &pWriter, 1,
177140 csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);
177141 }
177142 if( rc!=SQLITE_OK ) goto finished;
177143 assert_fts3_nc( pWriter || bIgnoreEmpty );
177144
177145 if( iLevel!=FTS3_SEGCURSOR_PENDING ){
177146 rc = fts3DeleteSegdir(
177147 p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment
177148 );
@@ -178724,21 +178257,17 @@
178724 */
178725 static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
178726 const int nHint = pHint->n;
178727 int i;
178728
178729 i = pHint->n-1;
178730 if( (pHint->a[i] & 0x80) ) return FTS_CORRUPT_VTAB;
178731 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
178732 if( i==0 ) return FTS_CORRUPT_VTAB;
178733 i--;
178734 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
178735
178736 pHint->n = i;
178737 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
178738 i += fts3GetVarint32(&pHint->a[i], pnInput);
178739 assert( i<=nHint );
178740 if( i!=nHint ) return FTS_CORRUPT_VTAB;
178741
178742 return SQLITE_OK;
178743 }
178744
@@ -179064,28 +178593,28 @@
179064 char *pCsr = csr.aDoclist;
179065 char *pEnd = &pCsr[csr.nDoclist];
179066
179067 i64 iDocid = 0;
179068 i64 iCol = 0;
179069 u64 iPos = 0;
179070
179071 pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
179072 while( pCsr<pEnd ){
179073 u64 iVal = 0;
179074 pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal);
179075 if( pCsr<pEnd ){
179076 if( iVal==0 || iVal==1 ){
179077 iCol = 0;
179078 iPos = 0;
179079 if( iVal ){
179080 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
179081 }else{
179082 pCsr += sqlite3Fts3GetVarintU(pCsr, &iVal);
179083 if( p->bDescIdx ){
179084 iDocid = (i64)((u64)iDocid - iVal);
179085 }else{
179086 iDocid = (i64)((u64)iDocid + iVal);
179087 }
179088 }
179089 }else{
179090 iPos += (iVal - 2);
179091 cksum = cksum ^ fts3ChecksumEntry(
@@ -183357,53 +182886,22 @@
183357 pRoot->jnFlags |= JNODE_APPEND;
183358 pParse->aNode[iLabel].jnFlags |= JNODE_RAW;
183359 }
183360 return pNode;
183361 }
183362 }else if( zPath[0]=='[' ){
 
183363 i = 0;
183364 j = 1;
183365 while( safe_isdigit(zPath[j]) ){
183366 i = i*10 + zPath[j] - '0';
183367 j++;
183368 }
183369 if( j<2 || zPath[j]!=']' ){
183370 if( zPath[1]=='#' ){
183371 JsonNode *pBase = pRoot;
183372 int iBase = iRoot;
183373 if( pRoot->eType!=JSON_ARRAY ) return 0;
183374 for(;;){
183375 while( j<=pBase->n ){
183376 if( (pBase[j].jnFlags & JNODE_REMOVE)==0 ) i++;
183377 j += jsonNodeSize(&pBase[j]);
183378 }
183379 if( (pBase->jnFlags & JNODE_APPEND)==0 ) break;
183380 iBase += pBase->u.iAppend;
183381 pBase = &pParse->aNode[iBase];
183382 j = 1;
183383 }
183384 j = 2;
183385 if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){
183386 unsigned int x = 0;
183387 j = 3;
183388 do{
183389 x = x*10 + zPath[j] - '0';
183390 j++;
183391 }while( safe_isdigit(zPath[j]) );
183392 if( x>i ) return 0;
183393 i -= x;
183394 }
183395 if( zPath[j]!=']' ){
183396 *pzErr = zPath;
183397 return 0;
183398 }
183399 }else{
183400 *pzErr = zPath;
183401 return 0;
183402 }
183403 }
183404 if( pRoot->eType!=JSON_ARRAY ) return 0;
183405 zPath += j + 1;
183406 j = 1;
183407 for(;;){
183408 while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
183409 if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;
@@ -184867,11 +184365,10 @@
184867 /* #include "sqlite3ext.h" */
184868 SQLITE_EXTENSION_INIT1
184869 #else
184870 /* #include "sqlite3.h" */
184871 #endif
184872 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */
184873
184874 #ifndef SQLITE_AMALGAMATION
184875 #include "sqlite3rtree.h"
184876 typedef sqlite3_int64 i64;
184877 typedef sqlite3_uint64 u64;
@@ -185131,16 +184628,10 @@
185131 #define RTREE_GE 0x44 /* D */
185132 #define RTREE_GT 0x45 /* E */
185133 #define RTREE_MATCH 0x46 /* F: Old-style sqlite3_rtree_geometry_callback() */
185134 #define RTREE_QUERY 0x47 /* G: New-style sqlite3_rtree_query_callback() */
185135
185136 /* Special operators available only on cursors. Needs to be consecutive
185137 ** with the normal values above, but must be less than RTREE_MATCH. These
185138 ** are used in the cursor for contraints such as x=NULL (RTREE_FALSE) or
185139 ** x<'xyz' (RTREE_TRUE) */
185140 #define RTREE_TRUE 0x3f /* ? */
185141 #define RTREE_FALSE 0x40 /* @ */
185142
185143 /*
185144 ** An rtree structure node.
185145 */
185146 struct RtreeNode {
@@ -185870,16 +185361,13 @@
185870 return rc;
185871 }
185872
185873
185874 /*
185875 ** Reset a cursor back to its initial state.
185876 */
185877 static void resetCursor(RtreeCursor *pCsr){
185878 Rtree *pRtree = (Rtree *)(pCsr->base.pVtab);
185879 int ii;
185880 sqlite3_stmt *pStmt;
185881 if( pCsr->aConstraint ){
185882 int i; /* Used to iterate through constraint array */
185883 for(i=0; i<pCsr->nConstraint; i++){
185884 sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;
185885 if( pInfo ){
@@ -185888,28 +185376,24 @@
185888 }
185889 }
185890 sqlite3_free(pCsr->aConstraint);
185891 pCsr->aConstraint = 0;
185892 }
185893 for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
185894 sqlite3_free(pCsr->aPoint);
185895 pStmt = pCsr->pReadAux;
185896 memset(pCsr, 0, sizeof(RtreeCursor));
185897 pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
185898 pCsr->pReadAux = pStmt;
185899
185900 }
185901
185902 /*
185903 ** Rtree virtual table module xClose method.
185904 */
185905 static int rtreeClose(sqlite3_vtab_cursor *cur){
185906 Rtree *pRtree = (Rtree *)(cur->pVtab);
 
185907 RtreeCursor *pCsr = (RtreeCursor *)cur;
185908 assert( pRtree->nCursor>0 );
185909 resetCursor(pCsr);
185910 sqlite3_finalize(pCsr->pReadAux);
 
 
185911 sqlite3_free(pCsr);
185912 pRtree->nCursor--;
185913 nodeBlobReset(pRtree);
185914 return SQLITE_OK;
185915 }
@@ -186063,16 +185547,13 @@
186063 ** in a coordinate pair. But make pCellData point to the lower bound.
186064 */
186065 pCellData += 8 + 4*(p->iCoord&0xfe);
186066
186067 assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
186068 || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE
186069 || p->op==RTREE_FALSE );
186070 assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
186071 switch( p->op ){
186072 case RTREE_TRUE: return; /* Always satisfied */
186073 case RTREE_FALSE: break; /* Never satisfied */
186074 case RTREE_LE:
186075 case RTREE_LT:
186076 case RTREE_EQ:
186077 RTREE_DECODE_COORD(eInt, pCellData, val);
186078 /* val now holds the lower bound of the coordinate pair */
@@ -186106,23 +185587,20 @@
186106 int *peWithin /* Adjust downward, as appropriate */
186107 ){
186108 RtreeDValue xN; /* Coordinate value converted to a double */
186109
186110 assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
186111 || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE
186112 || p->op==RTREE_FALSE );
186113 pCellData += 8 + p->iCoord*4;
186114 assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
186115 RTREE_DECODE_COORD(eInt, pCellData, xN);
186116 switch( p->op ){
186117 case RTREE_TRUE: return; /* Always satisfied */
186118 case RTREE_FALSE: break; /* Never satisfied */
186119 case RTREE_LE: if( xN <= p->u.rValue ) return; break;
186120 case RTREE_LT: if( xN < p->u.rValue ) return; break;
186121 case RTREE_GE: if( xN >= p->u.rValue ) return; break;
186122 case RTREE_GT: if( xN > p->u.rValue ) return; break;
186123 default: if( xN == p->u.rValue ) return; break;
186124 }
186125 *peWithin = NOT_WITHIN;
186126 }
186127
186128 /*
@@ -186611,32 +186089,30 @@
186611 RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
186612 RtreeNode *pRoot = 0;
186613 int ii;
186614 int rc = SQLITE_OK;
186615 int iCell = 0;
 
186616
186617 rtreeReference(pRtree);
186618
186619 /* Reset the cursor to the same state as rtreeOpen() leaves it in. */
186620 resetCursor(pCsr);
 
 
 
 
 
186621
186622 pCsr->iStrategy = idxNum;
186623 if( idxNum==1 ){
186624 /* Special case - lookup by rowid. */
186625 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
186626 RtreeSearchPoint *p; /* Search point for the leaf */
186627 i64 iRowid = sqlite3_value_int64(argv[0]);
186628 i64 iNode = 0;
186629 int eType = sqlite3_value_numeric_type(argv[0]);
186630 if( eType==SQLITE_INTEGER
186631 || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid)
186632 ){
186633 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
186634 }else{
186635 rc = SQLITE_OK;
186636 pLeaf = 0;
186637 }
186638 if( rc==SQLITE_OK && pLeaf!=0 ){
186639 p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
186640 assert( p!=0 ); /* Always returns pCsr->sPoint */
186641 pCsr->aNode[0] = pLeaf;
186642 p->id = iNode;
@@ -186662,11 +186138,10 @@
186662 memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));
186663 assert( (idxStr==0 && argc==0)
186664 || (idxStr && (int)strlen(idxStr)==argc*2) );
186665 for(ii=0; ii<argc; ii++){
186666 RtreeConstraint *p = &pCsr->aConstraint[ii];
186667 int eType = sqlite3_value_numeric_type(argv[ii]);
186668 p->op = idxStr[ii*2];
186669 p->iCoord = idxStr[ii*2+1]-'0';
186670 if( p->op>=RTREE_MATCH ){
186671 /* A MATCH operator. The right-hand-side must be a blob that
186672 ** can be cast into an RtreeMatchArg object. One created using
@@ -186677,25 +186152,16 @@
186677 break;
186678 }
186679 p->pInfo->nCoord = pRtree->nDim2;
186680 p->pInfo->anQueue = pCsr->anQueue;
186681 p->pInfo->mxLevel = pRtree->iDepth + 1;
186682 }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
186683 #ifdef SQLITE_RTREE_INT_ONLY
186684 p->u.rValue = sqlite3_value_int64(argv[ii]);
186685 #else
186686 p->u.rValue = sqlite3_value_double(argv[ii]);
186687 #endif
186688 }else{
186689 p->u.rValue = RTREE_ZERO;
186690 if( eType==SQLITE_NULL ){
186691 p->op = RTREE_FALSE;
186692 }else if( p->op==RTREE_LT || p->op==RTREE_LE ){
186693 p->op = RTREE_TRUE;
186694 }else{
186695 p->op = RTREE_FALSE;
186696 }
186697 }
186698 }
186699 }
186700 }
186701 if( rc==SQLITE_OK ){
@@ -188468,18 +187934,10 @@
188468
188469 sqlite3_free(zSql);
188470 return rc;
188471 }
188472
188473 /*
188474 ** Return the length of a token
188475 */
188476 static int rtreeTokenLength(const char *z){
188477 int dummy = 0;
188478 return sqlite3GetToken((const unsigned char*)z,&dummy);
188479 }
188480
188481 /*
188482 ** This function is the implementation of both the xConnect and xCreate
188483 ** methods of the r-tree virtual table.
188484 **
188485 ** argv[0] -> module name
@@ -188512,12 +187970,12 @@
188512 "Too many columns for an rtree table", /* 3 */
188513 "Auxiliary rtree columns must be last" /* 4 */
188514 };
188515
188516 assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
188517 if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){
188518 *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]);
188519 return SQLITE_ERROR;
188520 }
188521
188522 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
188523
@@ -188541,22 +187999,20 @@
188541 /* Create/Connect to the underlying relational database schema. If
188542 ** that is successful, call sqlite3_declare_vtab() to configure
188543 ** the r-tree table schema.
188544 */
188545 pSql = sqlite3_str_new(db);
188546 sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT",
188547 rtreeTokenLength(argv[3]), argv[3]);
188548 for(ii=4; ii<argc; ii++){
188549 const char *zArg = argv[ii];
188550 if( zArg[0]=='+' ){
188551 pRtree->nAux++;
188552 sqlite3_str_appendf(pSql, ",%.*s", rtreeTokenLength(zArg+1), zArg+1);
188553 }else if( pRtree->nAux>0 ){
188554 break;
188555 }else{
188556 pRtree->nDim2++;
188557 sqlite3_str_appendf(pSql, ",%.*s NUM", rtreeTokenLength(zArg), zArg);
188558 }
188559 }
188560 sqlite3_str_appendf(pSql, ");");
188561 zSql = sqlite3_str_finish(pSql);
188562 if( !zSql ){
@@ -190500,15 +189956,21 @@
190500 Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;
190501 RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
190502 RtreeNode *pRoot = 0;
190503 int rc = SQLITE_OK;
190504 int iCell = 0;
 
190505
190506 rtreeReference(pRtree);
190507
190508 /* Reset the cursor to the same state as rtreeOpen() leaves it in. */
190509 resetCursor(pCsr);
 
 
 
 
 
190510
190511 pCsr->iStrategy = idxNum;
190512 if( idxNum==1 ){
190513 /* Special case - lookup by rowid. */
190514 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
@@ -197528,11 +196990,11 @@
197528 }
197529 z += 2;
197530 }else{
197531 while( *z==0 ) z++;
197532 }
197533 z += (n + 8 + 2);
197534 return z;
197535 }
197536
197537 /*
197538 ** Open an rbu file handle.
@@ -204819,11 +204281,11 @@
204819 ** the callback, an SQLite error code is returned.
204820 **
204821 **
204822 ** xSetAuxdata(pFts5, pAux, xDelete)
204823 **
204824 ** Save the pointer passed as the second argument as the extension function's
204825 ** "auxiliary data". The pointer may then be retrieved by the current or any
204826 ** future invocation of the same fts5 extension function made as part of
204827 ** the same MATCH query using the xGetAuxdata() API.
204828 **
204829 ** Each extension function is allocated a single auxiliary data slot for
@@ -205061,12 +204523,12 @@
205061 ** all instances of "first place" or "1st place" regardless of which form
205062 ** the user specified in the MATCH query text.
205063 **
205064 ** There are several ways to approach this in FTS5:
205065 **
205066 ** <ol><li> By mapping all synonyms to a single token. In this case, using
205067 ** the above example, this means that the tokenizer returns the
205068 ** same token for inputs "first" and "1st". Say that token is in
205069 ** fact "first", so that when the user inserts the document "I won
205070 ** 1st place" entries are added to the index for tokens "i", "won",
205071 ** "first" and "place". If the user then queries for '1st + place',
205072 ** the tokenizer substitutes "first" for "1st" and the query works
@@ -206223,11 +205685,10 @@
206223 #define sqlite3Fts5ParserCTX_PARAM
206224 #define sqlite3Fts5ParserCTX_FETCH
206225 #define sqlite3Fts5ParserCTX_STORE
206226 #define fts5YYNSTATE 35
206227 #define fts5YYNRULE 28
206228 #define fts5YYNRULE_WITH_ACTION 28
206229 #define fts5YYNFTS5TOKEN 16
206230 #define fts5YY_MAX_SHIFT 34
206231 #define fts5YY_MIN_SHIFTREDUCE 52
206232 #define fts5YY_MAX_SHIFTREDUCE 79
206233 #define fts5YY_ERROR_ACTION 80
@@ -207053,19 +206514,16 @@
207053 fts5yymsp = fts5yypParser->fts5yytos;
207054 #ifndef NDEBUG
207055 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
207056 fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
207057 if( fts5yysize ){
207058 fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
207059 fts5yyTracePrompt,
207060 fts5yyruleno, fts5yyRuleName[fts5yyruleno],
207061 fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action",
207062 fts5yymsp[fts5yysize].stateno);
207063 }else{
207064 fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n",
207065 fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno],
207066 fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action");
207067 }
207068 }
207069 #endif /* NDEBUG */
207070
207071 /* Check that the stack is large enough to grow by a single entry
@@ -208820,11 +208278,11 @@
208820
208821 /* Set stack variable q to the close-quote character */
208822 assert( q=='[' || q=='\'' || q=='"' || q=='`' );
208823 if( q=='[' ) q = ']';
208824
208825 while( z[iIn] ){
208826 if( z[iIn]==q ){
208827 if( z[iIn+1]!=q ){
208828 /* Character iIn was the close quote. */
208829 iIn++;
208830 break;
@@ -212149,16 +211607,14 @@
212149 }
212150 azConfig[0] = 0;
212151 azConfig[1] = "main";
212152 azConfig[2] = "tbl";
212153 for(i=3; iArg<nArg; iArg++){
212154 const char *z = (const char*)sqlite3_value_text(apVal[iArg]);
212155 azConfig[i++] = (z ? z : "");
212156 }
212157
212158 zExpr = (const char*)sqlite3_value_text(apVal[0]);
212159 if( zExpr==0 ) zExpr = "";
212160
212161 rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);
212162 if( rc==SQLITE_OK ){
212163 rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);
212164 }
@@ -218404,17 +217860,14 @@
218404 int n = 0;
218405 int i;
218406 for(i=0; i<nChar; i++){
218407 if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
218408 if( (unsigned char)p[n++]>=0xc0 ){
218409 if( n>=nByte ) return 0;
218410 while( (p[n] & 0xc0)==0x80 ){
218411 n++;
218412 if( n>=nByte ){
218413 if( i+1==nChar ) break;
218414 return 0;
218415 }
218416 }
218417 }
218418 }
218419 return n;
218420 }
@@ -218812,41 +218265,10 @@
218812
218813 *pCksum = cksum;
218814 return rc;
218815 }
218816
218817 /*
218818 ** Check if buffer z[], size n bytes, contains as series of valid utf-8
218819 ** encoded codepoints. If so, return 0. Otherwise, if the buffer does not
218820 ** contain valid utf-8, return non-zero.
218821 */
218822 static int fts5TestUtf8(const char *z, int n){
218823 assert_nc( n>0 );
218824 int i = 0;
218825 while( i<n ){
218826 if( (z[i] & 0x80)==0x00 ){
218827 i++;
218828 }else
218829 if( (z[i] & 0xE0)==0xC0 ){
218830 if( i+1>=n || (z[i+1] & 0xC0)!=0x80 ) return 1;
218831 i += 2;
218832 }else
218833 if( (z[i] & 0xF0)==0xE0 ){
218834 if( i+2>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1;
218835 i += 3;
218836 }else
218837 if( (z[i] & 0xF8)==0xF0 ){
218838 if( i+3>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1;
218839 if( (z[i+2] & 0xC0)!=0x80 ) return 1;
218840 i += 3;
218841 }else{
218842 return 1;
218843 }
218844 }
218845
218846 return 0;
218847 }
218848
218849 /*
218850 ** This function is also purely an internal test. It does not contribute to
218851 ** FTS functionality, or even the integrity-check, in any way.
218852 */
@@ -218883,18 +218305,12 @@
218883 ** the index is disabled are the same. In both ASC and DESC order.
218884 **
218885 ** This check may only be performed if the hash table is empty. This
218886 ** is because the hash table only supports a single scan query at
218887 ** a time, and the multi-iter loop from which this function is called
218888 ** is already performing such a scan.
218889 **
218890 ** Also only do this if buffer zTerm contains nTerm bytes of valid
218891 ** utf-8. Otherwise, the last part of the buffer contents might contain
218892 ** a non-utf-8 sequence that happens to be a prefix of a valid utf-8
218893 ** character stored in the main fts index, which will cause the
218894 ** test to fail. */
218895 if( p->nPendingData==0 && 0==fts5TestUtf8(zTerm, nTerm) ){
218896 if( iIdx>0 && rc==SQLITE_OK ){
218897 int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;
218898 ck2 = 0;
218899 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
218900 if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
@@ -219023,12 +218439,12 @@
219023 /* Iterate through the b-tree hierarchy. */
219024 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
219025 i64 iRow; /* Rowid for this leaf */
219026 Fts5Data *pLeaf; /* Data for this leaf */
219027
219028 const char *zIdxTerm = (const char*)sqlite3_column_blob(pStmt, 1);
219029 int nIdxTerm = sqlite3_column_bytes(pStmt, 1);
 
219030 int iIdxLeaf = sqlite3_column_int(pStmt, 2);
219031 int bIdxDlidx = sqlite3_column_int(pStmt, 3);
219032
219033 /* If the leaf in question has already been trimmed from the segment,
219034 ** ignore this b-tree entry. Otherwise, load it into memory. */
@@ -220611,28 +220027,19 @@
220611 case FTS5_PLAN_SORTED_MATCH: {
220612 rc = fts5SorterNext(pCsr);
220613 break;
220614 }
220615
220616 default: {
220617 Fts5Config *pConfig = ((Fts5Table*)pCursor->pVtab)->pConfig;
220618 pConfig->bLock++;
220619 rc = sqlite3_step(pCsr->pStmt);
220620 pConfig->bLock--;
220621 if( rc!=SQLITE_ROW ){
220622 CsrFlagSet(pCsr, FTS5CSR_EOF);
220623 rc = sqlite3_reset(pCsr->pStmt);
220624 if( rc!=SQLITE_OK ){
220625 pCursor->pVtab->zErrMsg = sqlite3_mprintf(
220626 "%s", sqlite3_errmsg(pConfig->db)
220627 );
220628 }
220629 }else{
220630 rc = SQLITE_OK;
220631 }
220632 break;
220633 }
220634 }
220635 }
220636
220637 return rc;
220638 }
@@ -220913,17 +220320,10 @@
220913 char **pzErrmsg = pConfig->pzErrmsg;
220914 int i;
220915 int iIdxStr = 0;
220916 Fts5Expr *pExpr = 0;
220917
220918 if( pConfig->bLock ){
220919 pTab->p.base.zErrMsg = sqlite3_mprintf(
220920 "recursively defined fts5 content table"
220921 );
220922 return SQLITE_ERROR;
220923 }
220924
220925 if( pCsr->ePlan ){
220926 fts5FreeCursorComponents(pCsr);
220927 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
220928 }
220929
@@ -221140,28 +220540,21 @@
221140 assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
221141 assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
221142 }
221143
221144 if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){
221145 Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
221146 assert( pCsr->pExpr );
221147 sqlite3_reset(pCsr->pStmt);
221148 sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));
221149 pTab->pConfig->bLock++;
221150 rc = sqlite3_step(pCsr->pStmt);
221151 pTab->pConfig->bLock--;
221152 if( rc==SQLITE_ROW ){
221153 rc = SQLITE_OK;
221154 CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);
221155 }else{
221156 rc = sqlite3_reset(pCsr->pStmt);
221157 if( rc==SQLITE_OK ){
221158 rc = FTS5_CORRUPT;
221159 }else if( pTab->pConfig->pzErrmsg ){
221160 *pTab->pConfig->pzErrmsg = sqlite3_mprintf(
221161 "%s", sqlite3_errmsg(pTab->pConfig->db)
221162 );
221163 }
221164 }
221165 }
221166 return rc;
221167 }
@@ -222173,16 +221566,14 @@
222173 if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
222174 fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
222175 }
222176 }
222177 }else if( !fts5IsContentless(pTab) ){
222178 pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
222179 rc = fts5SeekCursor(pCsr, 1);
222180 if( rc==SQLITE_OK ){
222181 sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));
222182 }
222183 pConfig->pzErrmsg = 0;
222184 }
222185 return rc;
222186 }
222187
222188
@@ -222455,11 +221846,11 @@
222455 int nArg, /* Number of args */
222456 sqlite3_value **apUnused /* Function arguments */
222457 ){
222458 assert( nArg==0 );
222459 UNUSED_PARAM2(nArg, apUnused);
222460 sqlite3_result_text(pCtx, "fts5: 2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3", -1, SQLITE_TRANSIENT);
222461 }
222462
222463 /*
222464 ** Return true if zName is the extension on one of the shadow tables used
222465 ** by this module.
@@ -223202,15 +222593,14 @@
223202 sqlite3Fts5BufferZero(&buf);
223203 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
223204 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
223205 ctx.szCol = 0;
223206 if( pConfig->abUnindexed[ctx.iCol]==0 ){
223207 const char *zText = (const char*)sqlite3_column_text(pScan, ctx.iCol+1);
223208 int nText = sqlite3_column_bytes(pScan, ctx.iCol+1);
223209 rc = sqlite3Fts5Tokenize(pConfig,
223210 FTS5_TOKENIZE_DOCUMENT,
223211 zText, nText,
 
223212 (void*)&ctx,
223213 fts5StorageInsertCallback
223214 );
223215 }
223216 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223328,15 +222718,14 @@
223328 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
223329 }
223330 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
223331 ctx.szCol = 0;
223332 if( pConfig->abUnindexed[ctx.iCol]==0 ){
223333 const char *zText = (const char*)sqlite3_value_text(apVal[ctx.iCol+2]);
223334 int nText = sqlite3_value_bytes(apVal[ctx.iCol+2]);
223335 rc = sqlite3Fts5Tokenize(pConfig,
223336 FTS5_TOKENIZE_DOCUMENT,
223337 zText, nText,
 
223338 (void*)&ctx,
223339 fts5StorageInsertCallback
223340 );
223341 }
223342 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223501,15 +222890,14 @@
223501 ctx.szCol = 0;
223502 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
223503 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
223504 }
223505 if( rc==SQLITE_OK ){
223506 const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
223507 int nText = sqlite3_column_bytes(pScan, i+1);
223508 rc = sqlite3Fts5Tokenize(pConfig,
223509 FTS5_TOKENIZE_DOCUMENT,
223510 zText, nText,
 
223511 (void*)&ctx,
223512 fts5StorageIntegrityCallback
223513 );
223514 }
223515 if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
@@ -227228,12 +226616,12 @@
227228 }
227229 #endif /* SQLITE_CORE */
227230 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
227231
227232 /************** End of stmt.c ************************************************/
227233 #if __LINE__!=227233
227234 #undef SQLITE_SOURCE_ID
227235 #define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1befalt2"
227236 #endif
227237 /* Return the source-id for this library */
227238 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
227239 /************************** End of sqlite3.c ******************************/
227240
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1165,11 +1165,11 @@
1165 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1166 ** [sqlite_version()] and [sqlite_source_id()].
1167 */
1168 #define SQLITE_VERSION "3.31.0"
1169 #define SQLITE_VERSION_NUMBER 3031000
1170 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
1171
1172 /*
1173 ** CAPI3REF: Run-Time Library Version Numbers
1174 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1175 **
@@ -1581,11 +1581,10 @@
1581 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
1582 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
1583 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
1584 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
1585 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
 
1586
1587 /*
1588 ** CAPI3REF: Flags For File Open Operations
1589 **
1590 ** These bit values are intended for use in the
@@ -2022,20 +2021,20 @@
2021 **
2022 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
2023 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
2024 ** file-control may be invoked by SQLite on the database file handle
2025 ** shortly after it is opened in order to provide a custom VFS with access
2026 ** to the connections busy-handler callback. The argument is of type (void **)
2027 ** - an array of two (void *) values. The first (void *) actually points
2028 ** to a function of type (int (*)(void *)). In order to invoke the connections
2029 ** busy-handler, this function should be invoked with the second (void *) in
2030 ** the array as the only argument. If it returns non-zero, then the operation
2031 ** should be retried. If it returns zero, the custom VFS should abandon the
2032 ** current operation.
2033 **
2034 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
2035 ** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
2036 ** to have SQLite generate a
2037 ** temporary filename using the same algorithm that is followed to generate
2038 ** temporary filenames for TEMP tables and other internal uses. The
2039 ** argument should be a char** which will be filled with the filename
2040 ** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -2144,11 +2143,11 @@
2143 ** interface can be used to find if any database on the connection has changed,
2144 ** but that interface responds to changes on TEMP as well as MAIN and does
2145 ** not provide a mechanism to detect changes to MAIN only. Also, the
2146 ** [sqlite3_total_changes()] interface responds to internal changes only and
2147 ** omits changes made by other database connections. The
2148 ** [PRAGMA data_version] command provide a mechanism to detect changes to
2149 ** a single attached database that occur due to other database connections,
2150 ** but omits changes implemented by the database connection on which it is
2151 ** called. This file control is the only mechanism to detect changes that
2152 ** happen either internally or externally and that are associated with
2153 ** a particular attached database.
@@ -2232,14 +2231,14 @@
2231 ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
2232 ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
2233 ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
2234 ** may be appended to the sqlite3_vfs object and the iVersion value
2235 ** may increase again in future versions of SQLite.
2236 ** Note that the structure
2237 ** of the sqlite3_vfs object changes in the transition from
2238 ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
2239 ** and yet the iVersion field was not modified.
2240 **
2241 ** The szOsFile field is the size of the subclassed [sqlite3_file]
2242 ** structure used by this VFS. mxPathname is the maximum length of
2243 ** a pathname in this VFS.
2244 **
@@ -2326,11 +2325,11 @@
2325 ** be created, and that it is an error if it already exists.
2326 ** It is <i>not</i> used to indicate the file should be opened
2327 ** for exclusive access.
2328 **
2329 ** ^At least szOsFile bytes of memory are allocated by SQLite
2330 ** to hold the [sqlite3_file] structure passed as the third
2331 ** argument to xOpen. The xOpen method does not have to
2332 ** allocate the structure; it should just fill it in. Note that
2333 ** the xOpen method must set the sqlite3_file.pMethods to either
2334 ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
2335 ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -2449,10 +2448,11 @@
2448 ** SQLite.
2449 */
2450 #define SQLITE_ACCESS_EXISTS 0
2451 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
2452 #define SQLITE_ACCESS_READ 2 /* Unused */
2453 #define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
2454
2455 /*
2456 ** CAPI3REF: Flags for the xShmLock VFS method
2457 **
2458 ** These integer constants define the various locking operations
@@ -2663,11 +2663,11 @@
2663 ** Every memory allocation request coming in through [sqlite3_malloc()]
2664 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
2665 ** that causes the corresponding memory allocation to fail.
2666 **
2667 ** The xInit method initializes the memory allocator. For example,
2668 ** it might allocate any require mutexes or initialize internal data
2669 ** structures. The xShutdown method is invoked (indirectly) by
2670 ** [sqlite3_shutdown()] and should deallocate any resources acquired
2671 ** by xInit. The pAppData pointer is used as the only parameter to
2672 ** xInit and xShutdown.
2673 **
@@ -2804,11 +2804,11 @@
2804 **
2805 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
2806 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
2807 ** that SQLite can use for the database page cache with the default page
2808 ** cache implementation.
2809 ** This configuration option is a no-op if an application-define page
2810 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
2811 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
2812 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
2813 ** and the number of cache lines (N).
2814 ** The sz argument should be the size of the largest database page
@@ -3289,11 +3289,11 @@
3289 ** </dd>
3290 **
3291 ** [[SQLITE_DBCONFIG_DQS_DML]]
3292 ** <dt>SQLITE_DBCONFIG_DQS_DML</td>
3293 ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
3294 ** the legacy [double-quoted string literal] misfeature for DML statement
3295 ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
3296 ** default value of this setting is determined by the [-DSQLITE_DQS]
3297 ** compile-time option.
3298 ** </dd>
3299 **
@@ -3550,11 +3550,11 @@
3550 ** will be rolled back automatically.
3551 **
3552 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
3553 ** SQL statements on [database connection] D complete. ^Any new SQL statements
3554 ** that are started after the sqlite3_interrupt() call and before the
3555 ** running statements reaches zero are interrupted as if they had been
3556 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
3557 ** that are started after the running statement count reaches zero are
3558 ** not effected by the sqlite3_interrupt().
3559 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
3560 ** SQL statements is a no-op and has no effect on SQL statements
@@ -3718,13 +3718,13 @@
3718 ** Alice | 43
3719 ** Bob | 28
3720 ** Cindy | 21
3721 ** </pre></blockquote>
3722 **
3723 ** There are two column (M==2) and three rows (N==3). Thus the
3724 ** result table has 8 entries. Suppose the result table is stored
3725 ** in an array names azResult. Then azResult holds this content:
3726 **
3727 ** <blockquote><pre>
3728 ** azResult&#91;0] = "Name";
3729 ** azResult&#91;1] = "Age";
3730 ** azResult&#91;2] = "Alice";
@@ -3873,10 +3873,23 @@
3873 ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
3874 ** sqlite3_malloc64(), and sqlite3_realloc64()
3875 ** is always aligned to at least an 8 byte boundary, or to a
3876 ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
3877 ** option is used.
3878 **
3879 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
3880 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
3881 ** implementation of these routines to be omitted. That capability
3882 ** is no longer provided. Only built-in memory allocators can be used.
3883 **
3884 ** Prior to SQLite version 3.7.10, the Windows OS interface layer called
3885 ** the system malloc() and free() directly when converting
3886 ** filenames between the UTF-8 encoding used by SQLite
3887 ** and whatever filename encoding is used by the particular Windows
3888 ** installation. Memory allocation errors were detected, but
3889 ** they were reported back as [SQLITE_CANTOPEN] or
3890 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
3891 **
3892 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
3893 ** must be either NULL or else pointers obtained from a prior
3894 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
3895 ** not yet been released.
@@ -3922,11 +3935,11 @@
3935 ** CAPI3REF: Pseudo-Random Number Generator
3936 **
3937 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
3938 ** select random [ROWID | ROWIDs] when inserting new records into a table that
3939 ** already uses the largest possible [ROWID]. The PRNG is also used for
3940 ** the build-in random() and randomblob() SQL functions. This interface allows
3941 ** applications to access the same PRNG for other purposes.
3942 **
3943 ** ^A call to this routine stores N bytes of randomness into buffer P.
3944 ** ^The P parameter can be a NULL pointer.
3945 **
@@ -4523,11 +4536,11 @@
4536 ** a VFS implementation when the flags parameter to xOpen() has one or
4537 ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
4538 ** P is the name of the query parameter, then
4539 ** sqlite3_uri_parameter(F,P) returns the value of the P
4540 ** parameter if it exists or a NULL pointer if P does not appear as a
4541 ** query parameter on F. If P is a query parameter of F
4542 ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
4543 ** a pointer to an empty string.
4544 **
4545 ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
4546 ** parameter and returns true (1) or false (0) according to the value
@@ -4535,11 +4548,11 @@
4548 ** value of query parameter P is one of "yes", "true", or "on" in any
4549 ** case or if the value begins with a non-zero number. The
4550 ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
4551 ** query parameter P is one of "no", "false", or "off" in any case or
4552 ** if the value begins with a numeric zero. If P is not a query
4553 ** parameter on F or if the value of P is does not match any of the
4554 ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
4555 **
4556 ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
4557 ** 64-bit signed integer and returns that integer, or D if P does not
4558 ** exist. If the value of P is something other than an integer, then
@@ -4872,16 +4885,16 @@
4885 ** in order to find the underlying cause of the problem. With the "v2" prepare
4886 ** interfaces, the underlying reason for the error is returned immediately.
4887 ** </li>
4888 **
4889 ** <li>
4890 ** ^If the specific value bound to [parameter | host parameter] in the
4891 ** WHERE clause might influence the choice of query plan for a statement,
4892 ** then the statement will be automatically recompiled, as if there had been
4893 ** a schema change, on the first [sqlite3_step()] call following any change
4894 ** to the [sqlite3_bind_text | bindings] of that [parameter].
4895 ** ^The specific value of WHERE-clause [parameter] might influence the
4896 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
4897 ** or [GLOB] operator or if the parameter is compared to an indexed column
4898 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
4899 ** </li>
4900 ** </ol>
@@ -5386,19 +5399,23 @@
5399 ** the statement, where N is the second function argument.
5400 ** ^The left-most column is column 0 for these routines.
5401 **
5402 ** ^If the Nth column returned by the statement is an expression or
5403 ** subquery and is not a column value, then all of these functions return
5404 ** NULL. ^These routine might also return NULL if a memory allocation error
5405 ** occurs. ^Otherwise, they return the name of the attached database, table,
5406 ** or column that query result column was extracted from.
5407 **
5408 ** ^As with all other SQLite APIs, those whose names end with "16" return
5409 ** UTF-16 encoded strings and the other functions return UTF-8.
5410 **
5411 ** ^These APIs are only available if the library was compiled with the
5412 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
5413 **
5414 ** If two or more threads call one or more of these routines against the same
5415 ** prepared statement and column at the same time then the results are
5416 ** undefined.
5417 **
5418 ** If two or more threads call one or more
5419 ** [sqlite3_column_database_name | column metadata interfaces]
5420 ** for the same [prepared statement] and result column
5421 ** at the same time then the results are undefined.
@@ -5532,11 +5549,11 @@
5549 ** METHOD: sqlite3_stmt
5550 **
5551 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
5552 ** current row of the result set of [prepared statement] P.
5553 ** ^If prepared statement P does not have results ready to return
5554 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
5555 ** interfaces) then sqlite3_data_count(P) returns 0.
5556 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
5557 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
5558 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
5559 ** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -6034,16 +6051,13 @@
6051 ** These constants may be ORed together with the
6052 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
6053 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
6054 ** [sqlite3_create_function_v2()].
6055 **
6056 ** The SQLITE_DETERMINISTIC flag means that the new function will always
6057 ** maps the same inputs into the same output. The abs() function is
6058 ** deterministic, for example, but randomblob() is not.
 
 
 
6059 **
6060 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
6061 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
6062 ** a security feature which is recommended for all
6063 ** [application-defined SQL functions] that have side-effects. This flag
@@ -6118,12 +6132,12 @@
6132 **
6133 ** <b>Details:</b>
6134 **
6135 ** These routines extract type, size, and content information from
6136 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
6137 ** are used to pass parameter information into implementation of
6138 ** [application-defined SQL functions] and [virtual tables].
6139 **
6140 ** These routines work only with [protected sqlite3_value] objects.
6141 ** Any attempt to use these routines on an [unprotected sqlite3_value]
6142 ** is not threadsafe.
6143 **
@@ -6176,11 +6190,11 @@
6190 ** the return value is arbitrary and meaningless.
6191 **
6192 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
6193 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
6194 ** interfaces. ^If X comes from an SQL literal value, or a table column,
6195 ** and expression, then sqlite3_value_frombind(X) returns zero.
6196 **
6197 ** Please pay particular attention to the fact that the pointer returned
6198 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
6199 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
6200 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6262,12 +6276,12 @@
6276 **
6277 ** Implementations of aggregate SQL functions use this
6278 ** routine to allocate memory for storing their state.
6279 **
6280 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
6281 ** for a particular aggregate function, SQLite
6282 ** allocates N of memory, zeroes out that memory, and returns a pointer
6283 ** to the new memory. ^On second and subsequent calls to
6284 ** sqlite3_aggregate_context() for the same aggregate function instance,
6285 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
6286 ** called once for each invocation of the xStep callback and then one
6287 ** last time when the xFinal callback is invoked. ^(When no rows match
@@ -6280,11 +6294,11 @@
6294 ** when first called if N is less than or equal to zero or if a memory
6295 ** allocate error occurs.
6296 **
6297 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6298 ** determined by the N parameter on first successful call. Changing the
6299 ** value of N in subsequent call to sqlite3_aggregate_context() within
6300 ** the same aggregate function instance will not resize the memory
6301 ** allocation.)^ Within the xFinal callback, it is customary to set
6302 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6303 ** pointless memory allocations occur.
6304 **
@@ -6628,11 +6642,11 @@
6642 ** <li> If A&lt;B THEN B&gt;A.
6643 ** <li> If A&lt;B and B&lt;C then A&lt;C.
6644 ** </ol>
6645 **
6646 ** If a collating function fails any of the above constraints and that
6647 ** collating function is registered and used, then the behavior of SQLite
6648 ** is undefined.
6649 **
6650 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
6651 ** with the addition that the xDestroy callback is invoked on pArg when
6652 ** the collating function is deleted.
@@ -6955,20 +6969,16 @@
6969
6970 /*
6971 ** CAPI3REF: Return The Filename For A Database Connection
6972 ** METHOD: sqlite3
6973 **
6974 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
6975 ** associated with database N of connection D. ^The main database file
6976 ** has the name "main". If there is no attached database N on the database
6977 ** connection D, or if database N is a temporary or in-memory database, then
6978 ** this function will return either a NULL pointer or an empty string.
6979 **
 
 
 
 
6980 ** ^The filename returned by this function is the output of the
6981 ** xFullPathname method of the [VFS]. ^In other words, the filename
6982 ** will be an absolute pathname, even if the filename used
6983 ** to open the database originally was a URI or relative pathname.
6984 */
@@ -7118,23 +7128,19 @@
7128 ** In prior versions of SQLite,
7129 ** sharing was enabled or disabled for each thread separately.
7130 **
7131 ** ^(The cache sharing mode set by this interface effects all subsequent
7132 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
7133 ** Existing database connections continue use the sharing mode
7134 ** that was in effect at the time they were opened.)^
7135 **
7136 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
7137 ** successfully. An [error code] is returned otherwise.)^
7138 **
7139 ** ^Shared cache is disabled by default. But this might change in
7140 ** future releases of SQLite. Applications that care about shared
7141 ** cache setting should set it explicitly.
 
 
 
 
7142 **
7143 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
7144 ** and will always return SQLITE_MISUSE. On those systems,
7145 ** shared cache mode should be enabled per-database connection via
7146 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -7263,11 +7269,11 @@
7269 ** information about column C of table T in database D
7270 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
7271 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
7272 ** the final five arguments with appropriate values if the specified
7273 ** column exists. ^The sqlite3_table_column_metadata() interface returns
7274 ** SQLITE_ERROR and if the specified column does not exist.
7275 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
7276 ** NULL pointer, then this routine simply checks for the existence of the
7277 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
7278 ** does not. If the table name parameter T in a call to
7279 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -7405,11 +7411,11 @@
7411 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
7412 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
7413 ** to enable or disable only the C-API.)^
7414 **
7415 ** <b>Security warning:</b> It is recommended that extension loading
7416 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
7417 ** rather than this interface, so the [load_extension()] SQL function
7418 ** remains disabled. This will prevent SQL injections from giving attackers
7419 ** access to extension loading capabilities.
7420 */
7421 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -7492,11 +7498,11 @@
7498 /*
7499 ** CAPI3REF: Virtual Table Object
7500 ** KEYWORDS: sqlite3_module {virtual table module}
7501 **
7502 ** This structure, sometimes called a "virtual table module",
7503 ** defines the implementation of a [virtual tables].
7504 ** This structure consists mostly of methods for the module.
7505 **
7506 ** ^A virtual table module is created by filling in a persistent
7507 ** instance of this structure and passing a pointer to that instance
7508 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -7589,17 +7595,11 @@
7595 ** The [xBestIndex] method must fill aConstraintUsage[] with information
7596 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
7597 ** the right-hand side of the corresponding aConstraint[] is evaluated
7598 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
7599 ** is true, then the constraint is assumed to be fully handled by the
7600 ** virtual table and is not checked again by SQLite.)^
 
 
 
 
 
 
7601 **
7602 ** ^The idxNum and idxPtr values are recorded and passed into the
7603 ** [xFilter] method.
7604 ** ^[sqlite3_free()] is used to free idxPtr if and only if
7605 ** needToFreeIdxPtr is true.
@@ -7635,11 +7635,11 @@
7635 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
7636 ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
7637 ** If a virtual table extension is
7638 ** used with an SQLite version earlier than 3.8.2, the results of attempting
7639 ** to read or write the estimatedRows field are undefined (but are likely
7640 ** to included crashing the application). The estimatedRows field should
7641 ** therefore only be used if [sqlite3_libversion_number()] returns a
7642 ** value greater than or equal to 3008002. Similarly, the idxFlags field
7643 ** was added for [version 3.9.0] ([dateof:3.9.0]).
7644 ** It may therefore only be used if
7645 ** sqlite3_libversion_number() returns a value greater than or equal to
@@ -7687,11 +7687,11 @@
7687 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
7688
7689 /*
7690 ** CAPI3REF: Virtual Table Constraint Operator Codes
7691 **
7692 ** These macros defined the allowed values for the
7693 ** [sqlite3_index_info].aConstraint[].op field. Each value represents
7694 ** an operator that is part of a constraint term in the wHERE clause of
7695 ** a query that uses a [virtual table].
7696 */
7697 #define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -8297,11 +8297,11 @@
8297 ** </ul>)^
8298 **
8299 ** The only difference is that the public sqlite3_XXX functions enumerated
8300 ** above silently ignore any invocations that pass a NULL pointer instead
8301 ** of a valid mutex handle. The implementations of the methods defined
8302 ** by this structure are not required to handle this case, the results
8303 ** of passing a NULL pointer instead of a valid mutex handle are undefined
8304 ** (i.e. it is acceptable to provide an implementation that segfaults if
8305 ** it is passed a NULL pointer).
8306 **
8307 ** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -8770,11 +8770,11 @@
8770 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
8771 ** no space was left in the page cache.</dd>)^
8772 **
8773 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
8774 ** <dd>This parameter records the largest memory allocation request
8775 ** handed to [pagecache memory allocator]. Only the value returned in the
8776 ** *pHighwater parameter to [sqlite3_status()] is of interest.
8777 ** The value written into the *pCurrent parameter is undefined.</dd>)^
8778 **
8779 ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
8780 ** <dd>No longer used.</dd>
@@ -8846,11 +8846,11 @@
8846 ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
8847 ** <dd>This parameter returns the number of lookaside memory slots currently
8848 ** checked out.</dd>)^
8849 **
8850 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
8851 ** <dd>This parameter returns the number malloc attempts that were
8852 ** satisfied using lookaside memory. Only the high-water value is meaningful;
8853 ** the current value is always zero.)^
8854 **
8855 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
8856 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -8928,11 +8928,11 @@
8928 ** <dd>This parameter returns the number of dirty cache entries that have
8929 ** been written to disk in the middle of a transaction due to the page
8930 ** cache overflowing. Transactions are more efficient if they are written
8931 ** to disk all at once. When pages spill mid-transaction, that introduces
8932 ** additional overhead. This parameter can be used help identify
8933 ** inefficiencies that can be resolve by increasing the cache size.
8934 ** </dd>
8935 **
8936 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
8937 ** <dd>This parameter returns zero for the current value if and only if
8938 ** all foreign key constraints (deferred or immediate) have been
@@ -9017,11 +9017,11 @@
9017 ** If the number of virtual machine operations exceeds 2147483647
9018 ** then the value returned by this statement status code is undefined.
9019 **
9020 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
9021 ** <dd>^This is the number of times that the prepare statement has been
9022 ** automatically regenerated due to schema changes or change to
9023 ** [bound parameters] that might affect the query plan.
9024 **
9025 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
9026 ** <dd>^This is the number of times that the prepared statement has
9027 ** been run. A single "run" for the purposes of this counter is one
@@ -9188,11 +9188,11 @@
9188 ** NULL if allocating a new page is effectively impossible.
9189 ** </table>
9190 **
9191 ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
9192 ** will only use a createFlag of 2 after a prior call with a createFlag of 1
9193 ** failed.)^ In between the to xFetch() calls, SQLite may
9194 ** attempt to unpin one or more cache pages by spilling the content of
9195 ** pinned pages to disk and synching the operating system disk cache.
9196 **
9197 ** [[the xUnpin() page cache method]]
9198 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -9506,11 +9506,11 @@
9506 ** application receives an SQLITE_LOCKED error, it may call the
9507 ** sqlite3_unlock_notify() method with the blocked connection handle as
9508 ** the first argument to register for a callback that will be invoked
9509 ** when the blocking connections current transaction is concluded. ^The
9510 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
9511 ** call that concludes the blocking connections transaction.
9512 **
9513 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
9514 ** there is a chance that the blocking connection will have already
9515 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
9516 ** If this happens, then the specified callback is invoked immediately,
@@ -9544,11 +9544,11 @@
9544 ** However, the signature of the callback function allows SQLite to pass
9545 ** it an array of void* context pointers. The first argument passed to
9546 ** an unlock-notify callback is a pointer to an array of void* pointers,
9547 ** and the second is the number of entries in the array.
9548 **
9549 ** When a blocking connections transaction is concluded, there may be
9550 ** more than one blocked connection that has registered for an unlock-notify
9551 ** callback. ^If two or more such blocked connections have specified the
9552 ** same callback function, then instead of invoking the callback function
9553 ** multiple times, it is invoked once with the set of void* context pointers
9554 ** specified by the blocked connections bundled together into an array.
@@ -10018,37 +10018,37 @@
10018 ** managed by the prepared statement S and will be automatically freed when
10019 ** S is finalized.
10020 **
10021 ** <dl>
10022 ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
10023 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
10024 ** set to the total number of times that the X-th loop has run.</dd>
10025 **
10026 ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
10027 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
10028 ** to the total number of rows examined by all iterations of the X-th loop.</dd>
10029 **
10030 ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
10031 ** <dd>^The "double" variable pointed to by the T parameter will be set to the
10032 ** query planner's estimate for the average number of rows output from each
10033 ** iteration of the X-th loop. If the query planner's estimates was accurate,
10034 ** then this value will approximate the quotient NVISIT/NLOOP and the
10035 ** product of this value for all prior loops with the same SELECTID will
10036 ** be the NLOOP value for the current loop.
10037 **
10038 ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
10039 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
10040 ** to a zero-terminated UTF-8 string containing the name of the index or table
10041 ** used for the X-th loop.
10042 **
10043 ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
10044 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
10045 ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
10046 ** description for the X-th loop.
10047 **
10048 ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
10049 ** <dd>^The "int" variable pointed to by the T parameter will be set to the
10050 ** "select-id" for the X-th loop. The select-id identifies which query or
10051 ** subquery the loop is part of. The main query has a select-id of zero.
10052 ** The select-id is the same value as is output in the first column
10053 ** of an [EXPLAIN QUERY PLAN] query.
10054 ** </dl>
@@ -10899,11 +10899,11 @@
10899 ** METHOD: sqlite3_session
10900 **
10901 ** The second argument (xFilter) is the "filter callback". For changes to rows
10902 ** in tables that are not attached to the Session object, the filter is called
10903 ** to determine whether changes to the table's rows should be tracked or not.
10904 ** If xFilter returns 0, changes is not tracked. Note that once a table is
10905 ** attached, xFilter will not be called again.
10906 */
10907 SQLITE_API void sqlite3session_table_filter(
10908 sqlite3_session *pSession, /* Session object */
10909 int(*xFilter)(
@@ -11073,11 +11073,11 @@
11073 ** identical.
11074 **
11075 ** It an error if database zFrom does not exist or does not contain the
11076 ** required compatible table.
11077 **
11078 ** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
11079 ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
11080 ** may be set to point to a buffer containing an English language error
11081 ** message. It is the responsibility of the caller to free this buffer using
11082 ** sqlite3_free().
11083 */
@@ -11210,11 +11210,11 @@
11210
11211 /*
11212 ** CAPI3REF: Advance A Changeset Iterator
11213 ** METHOD: sqlite3_changeset_iter
11214 **
11215 ** This function may only be used with iterators created by function
11216 ** [sqlite3changeset_start()]. If it is called on an iterator passed to
11217 ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
11218 ** is returned and the call has no effect.
11219 **
11220 ** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -11626,12 +11626,12 @@
11626 ** in the changegroup, then the number of columns and the position of the
11627 ** primary key columns for the table must be consistent. If this is not the
11628 ** case, this function fails with SQLITE_SCHEMA. If the input changeset
11629 ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
11630 ** returned. Or, if an out-of-memory condition occurs during processing, this
11631 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
11632 ** final contents of the changegroup is undefined.
11633 **
11634 ** If no error occurs, SQLITE_OK is returned.
11635 */
11636 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
11637
@@ -11802,11 +11802,11 @@
11802 ** [SQLITE_CHANGESET_REPLACE].
11803 ** </dl>
11804 **
11805 ** It is safe to execute SQL statements, including those that write to the
11806 ** table that the callback related to, from within the xConflict callback.
11807 ** This can be used to further customize the applications conflict
11808 ** resolution strategy.
11809 **
11810 ** All changes made by these functions are enclosed in a savepoint transaction.
11811 ** If any other error (aside from a constraint failure when attempting to
11812 ** write to the target database) occurs, then the savepoint transaction is
@@ -12112,11 +12112,11 @@
12112 ** CAPI3REF: Rebase a changeset
12113 ** EXPERIMENTAL
12114 **
12115 ** Argument pIn must point to a buffer containing a changeset nIn bytes
12116 ** in size. This function allocates and populates a buffer with a copy
12117 ** of the changeset rebased rebased according to the configuration of the
12118 ** rebaser object passed as the first argument. If successful, (*ppOut)
12119 ** is set to point to the new buffer containing the rebased changeset and
12120 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
12121 ** responsibility of the caller to eventually free the new buffer using
12122 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -12520,11 +12520,11 @@
12520 ** the callback, an SQLite error code is returned.
12521 **
12522 **
12523 ** xSetAuxdata(pFts5, pAux, xDelete)
12524 **
12525 ** Save the pointer passed as the second argument as the extension functions
12526 ** "auxiliary data". The pointer may then be retrieved by the current or any
12527 ** future invocation of the same fts5 extension function made as part of
12528 ** the same MATCH query using the xGetAuxdata() API.
12529 **
12530 ** Each extension function is allocated a single auxiliary data slot for
@@ -12762,12 +12762,12 @@
12762 ** all instances of "first place" or "1st place" regardless of which form
12763 ** the user specified in the MATCH query text.
12764 **
12765 ** There are several ways to approach this in FTS5:
12766 **
12767 ** <ol><li> By mapping all synonyms to a single token. In this case, the
12768 ** In the above example, this means that the tokenizer returns the
12769 ** same token for inputs "first" and "1st". Say that token is in
12770 ** fact "first", so that when the user inserts the document "I won
12771 ** 1st place" entries are added to the index for tokens "i", "won",
12772 ** "first" and "place". If the user then queries for '1st + place',
12773 ** the tokenizer substitutes "first" for "1st" and the query works
@@ -13435,30 +13435,10 @@
13435 #else
13436 # define ALWAYS(X) (X)
13437 # define NEVER(X) (X)
13438 #endif
13439
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13440 /*
13441 ** Some conditionals are optimizations only. In other words, if the
13442 ** conditionals are replaced with a constant 1 (true) or 0 (false) then
13443 ** the correct answer is still obtained, though perhaps not as quickly.
13444 **
@@ -15169,14 +15149,13 @@
15149 #define OP_VRename 163
15150 #define OP_Pagecount 164
15151 #define OP_MaxPgcnt 165
15152 #define OP_Trace 166
15153 #define OP_CursorHint 167
15154 #define OP_Noop 168
15155 #define OP_Explain 169
15156 #define OP_Abortable 170
 
15157
15158 /* Properties such as "out2" or "jump" that are specified in
15159 ** comments following the "case" for each opcode in the vdbe.c
15160 ** are encoded into bitvectors as follows:
15161 */
@@ -15206,11 +15185,11 @@
15185 /* 128 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00,\
15186 /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15187 /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x10, 0x00,\
15188 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15189 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15190 /* 168 */ 0x00, 0x00, 0x00,}
15191
15192 /* The sqlite3P2Values() routine is able to run faster if it knows
15193 ** the value of the largest JUMP opcode. The smaller the maximum
15194 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15195 ** generated this include file strives to group all JUMP opcodes
@@ -15283,15 +15262,10 @@
15262 SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
15263 SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
15264 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
15265 SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
15266 SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
 
 
 
 
 
15267 SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
15268 SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
15269 SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
15270 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
15271 SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
@@ -16867,10 +16841,16 @@
16841 {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
16842 pArg, 0, xFunc, 0, 0, 0, #zName, }
16843 #define LIKEFUNC(zName, nArg, arg, flags) \
16844 {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
16845 (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
16846 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
16847 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
16848 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
16849 #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
16850 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
16851 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
16852 #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
16853 {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
16854 SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
16855 #define INTERNAL_FUNCTION(zName, nArg, xFunc) \
16856 {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
@@ -17998,17 +17978,17 @@
17978 ** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences
17979 ** for the result set. The KeyInfo for addrOpenEphm[2] contains collating
17980 ** sequences for the ORDER BY clause.
17981 */
17982 struct Select {
17983 ExprList *pEList; /* The fields of the result */
17984 u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
17985 LogEst nSelectRow; /* Estimated number of result rows */
17986 u32 selFlags; /* Various SF_* values */
17987 int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */
17988 u32 selId; /* Unique identifier number for this SELECT */
17989 int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
 
17990 SrcList *pSrc; /* The FROM clause */
17991 Expr *pWhere; /* The WHERE clause */
17992 ExprList *pGroupBy; /* The GROUP BY clause */
17993 Expr *pHaving; /* The HAVING clause */
17994 ExprList *pOrderBy; /* The ORDER BY clause */
@@ -18050,11 +18030,10 @@
18030 #define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */
18031 #define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */
18032 #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18033 #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18034 #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
 
18035
18036 /*
18037 ** The results of a SELECT can be distributed in several ways, as defined
18038 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18039 ** Type".
@@ -18330,12 +18309,12 @@
18309 #endif
18310 };
18311
18312 #define PARSE_MODE_NORMAL 0
18313 #define PARSE_MODE_DECLARE_VTAB 1
18314 #define PARSE_MODE_RENAME_COLUMN 2
18315 #define PARSE_MODE_RENAME_TABLE 3
18316
18317 /*
18318 ** Sizes and pointers of various parts of the Parse object.
18319 */
18320 #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -18353,11 +18332,11 @@
18332 #endif
18333
18334 #if defined(SQLITE_OMIT_ALTERTABLE)
18335 #define IN_RENAME_OBJECT 0
18336 #else
18337 #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN)
18338 #endif
18339
18340 #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
18341 #define IN_SPECIAL_PARSE 0
18342 #else
@@ -19172,11 +19151,10 @@
19151 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
19152 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
19153 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
19154 Expr*,ExprList*,u32,Expr*);
19155 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
 
19156 SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
19157 SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
19158 SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
19159 #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
19160 SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
@@ -20756,11 +20734,11 @@
20734 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
20735 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
20736 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
20737 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
20738 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
20739 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);
20740 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
20741 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
20742 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
20743 #ifndef SQLITE_OMIT_WINDOWFUNC
20744 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
@@ -22676,11 +22654,11 @@
22654 DO_OS_MALLOC_TEST(0);
22655 /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
22656 ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example,
22657 ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
22658 ** reaching the VFS. */
22659 rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);
22660 assert( rc==SQLITE_OK || pFile->pMethods==0 );
22661 return rc;
22662 }
22663 SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
22664 DO_OS_MALLOC_TEST(0);
@@ -29311,13 +29289,12 @@
29289 zOp2[0] = 0;
29290 }
29291 sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s",
29292 pExpr->iColumn, zFlgs, zOp2);
29293 }else{
29294 sqlite3TreeViewLine(pView, "{%d:%d}%s",
29295 pExpr->iTable, pExpr->iColumn, zFlgs);
 
29296 }
29297 if( ExprHasProperty(pExpr, EP_FixedCol) ){
29298 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
29299 }
29300 break;
@@ -30984,11 +30961,11 @@
30961 #pragma warning(disable : 4756)
30962 #endif
30963 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
30964 #ifndef SQLITE_OMIT_FLOATING_POINT
30965 int incr;
30966 const char *zEnd = z + length;
30967 /* sign * significand * (10 ^ (esign * exponent)) */
30968 int sign = 1; /* sign of significand */
30969 i64 s = 0; /* significand */
30970 int d = 0; /* adjust exponent for shifting decimal point */
30971 int esign = 1; /* sign of exponent */
@@ -30998,15 +30975,13 @@
30975 int nDigit = 0; /* Number of digits processed */
30976 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
30977
30978 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
30979 *pResult = 0.0; /* Default return value, in case of an error */
 
30980
30981 if( enc==SQLITE_UTF8 ){
30982 incr = 1;
 
30983 }else{
30984 int i;
30985 incr = 2;
30986 assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
30987 testcase( enc==SQLITE_UTF16LE );
@@ -32685,14 +32660,13 @@
32660 /* 163 */ "VRename" OpHelp(""),
32661 /* 164 */ "Pagecount" OpHelp(""),
32662 /* 165 */ "MaxPgcnt" OpHelp(""),
32663 /* 166 */ "Trace" OpHelp(""),
32664 /* 167 */ "CursorHint" OpHelp(""),
32665 /* 168 */ "Noop" OpHelp(""),
32666 /* 169 */ "Explain" OpHelp(""),
32667 /* 170 */ "Abortable" OpHelp(""),
 
32668 };
32669 return azName[i];
32670 }
32671 #endif
32672
@@ -36581,11 +36555,11 @@
36555 zDirname[ii] = '\0';
36556 }else{
36557 if( zDirname[0]!='/' ) zDirname[0] = '.';
36558 zDirname[1] = 0;
36559 }
36560 fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);
36561 if( fd>=0 ){
36562 OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
36563 }
36564 *pFd = fd;
36565 if( fd>=0 ) return SQLITE_OK;
@@ -37472,16 +37446,14 @@
37446 }
37447 }
37448
37449 if( pInode->bProcessLock==0 ){
37450 if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){
37451 pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777));
 
37452 }
37453 if( pShmNode->hShm<0 ){
37454 pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));
 
37455 if( pShmNode->hShm<0 ){
37456 rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm);
37457 goto shm_open_err;
37458 }
37459 pShmNode->isReadonly = 1;
@@ -38827,11 +38799,11 @@
38799 int *pOutFlags /* Output flags returned to SQLite core */
38800 ){
38801 unixFile *p = (unixFile *)pFile;
38802 int fd = -1; /* File descriptor returned by open() */
38803 int openFlags = 0; /* Flags to pass to open() */
38804 int eType = flags&0xFFFFFF00; /* Type of file to open */
38805 int noLock; /* True to omit locking primitives */
38806 int rc = SQLITE_OK; /* Function Return Code */
38807 int ctrlFlags = 0; /* UNIXFILE_* flags */
38808
38809 int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -38937,11 +38909,11 @@
38909 ** 'conch file' locking functions later on. */
38910 if( isReadonly ) openFlags |= O_RDONLY;
38911 if( isReadWrite ) openFlags |= O_RDWR;
38912 if( isCreate ) openFlags |= O_CREAT;
38913 if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);
38914 openFlags |= (O_LARGEFILE|O_BINARY);
38915
38916 if( fd<0 ){
38917 mode_t openMode; /* Permissions to create file with */
38918 uid_t uid; /* Userid for the file */
38919 gid_t gid; /* Groupid for the file */
@@ -39149,20 +39121,29 @@
39121 ){
39122 UNUSED_PARAMETER(NotUsed);
39123 SimulateIOError( return SQLITE_IOERR_ACCESS; );
39124 assert( pResOut!=0 );
39125
39126 /* The spec says there are four possible values for flags. But the
39127 ** SQLITE_ACCESS_READ flag is never used */
39128 assert( flags==SQLITE_ACCESS_EXISTS
39129 || flags==SQLITE_ACCESS_READWRITE
39130 || flags==SQLITE_ACCESS_SYMLINK );
39131
39132 if( flags==SQLITE_ACCESS_EXISTS ){
39133 struct stat buf;
39134 *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);
39135 }else if( flags==SQLITE_ACCESS_READWRITE ){
 
39136 *pResOut = osAccess(zPath, W_OK|R_OK)==0;
39137 }else{
39138 #if !defined(HAVE_LSTAT)
39139 *pResOut = 0;
39140 #else
39141 struct stat buf;
39142 *pResOut = (0==osLstat(zPath, &buf) && S_ISLNK(buf.st_mode));
39143 #endif
39144 assert( flags==SQLITE_ACCESS_SYMLINK );
39145 }
39146 return SQLITE_OK;
39147 }
39148
39149 /*
@@ -39210,11 +39191,11 @@
39191 #if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)
39192 return mkFullPathname(zPath, zOut, nOut);
39193 #else
39194 int rc = SQLITE_OK;
39195 int nByte;
39196 int nLink = 1; /* Number of symbolic links followed so far */
39197 const char *zIn = zPath; /* Input path for each iteration of loop */
39198 char *zDel = 0;
39199
39200 assert( pVfs->mxPathname==MAX_PATHNAME );
39201 UNUSED_PARAMETER(pVfs);
@@ -39239,15 +39220,14 @@
39220 }else{
39221 bLink = S_ISLNK(buf.st_mode);
39222 }
39223
39224 if( bLink ){
 
39225 if( zDel==0 ){
39226 zDel = sqlite3_malloc(nOut);
39227 if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;
39228 }else if( ++nLink>SQLITE_MAX_SYMLINKS ){
39229 rc = SQLITE_CANTOPEN_BKPT;
39230 }
39231
39232 if( rc==SQLITE_OK ){
39233 nByte = osReadlink(zIn, zDel, nOut-1);
@@ -39279,11 +39259,10 @@
39259 if( bLink==0 ) break;
39260 zIn = zOut;
39261 }while( rc==SQLITE_OK );
39262
39263 sqlite3_free(zDel);
 
39264 return rc;
39265 #endif /* HAVE_READLINK && HAVE_LSTAT */
39266 }
39267
39268
@@ -39765,11 +39744,11 @@
39744 int islockfile /* if non zero missing dirs will be created */
39745 ) {
39746 int fd = -1;
39747 unixFile *pNew;
39748 int rc = SQLITE_OK;
39749 int openFlags = O_RDWR | O_CREAT;
39750 sqlite3_vfs dummyVfs;
39751 int terrno = 0;
39752 UnixUnusedFd *pUnused = NULL;
39753
39754 /* 1. first try to open/create the file
@@ -39795,11 +39774,11 @@
39774 fd = robust_open(path, openFlags, 0);
39775 }
39776 }
39777 }
39778 if( fd<0 ){
39779 openFlags = O_RDONLY;
39780 fd = robust_open(path, openFlags, 0);
39781 terrno = errno;
39782 }
39783 if( fd<0 ){
39784 if( islockfile ){
@@ -39921,11 +39900,11 @@
39900 if( readLen<PROXY_PATHINDEX ){
39901 sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen);
39902 goto end_breaklock;
39903 }
39904 /* write it out to the temporary break file */
39905 fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);
39906 if( fd<0 ){
39907 sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno);
39908 goto end_breaklock;
39909 }
39910 if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
@@ -41081,10 +41060,18 @@
41060
41061 #ifndef NTDDI_WINTHRESHOLD
41062 # define NTDDI_WINTHRESHOLD 0x06040000
41063 #endif
41064
41065 /*
41066 ** This constant is needed by the winAccess function; therefore, define
41067 ** it when it is missing from the SDK header files.
41068 */
41069 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
41070 # define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
41071 #endif
41072
41073 /*
41074 ** Check to see if the GetVersionEx[AW] functions are deprecated on the
41075 ** target system. GetVersionEx was first deprecated in Win8.1.
41076 */
41077 #ifndef SQLITE_WIN32_GETVERSIONEX
@@ -46473,10 +46460,14 @@
46460 break;
46461 case SQLITE_ACCESS_READWRITE:
46462 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46463 (attr & FILE_ATTRIBUTE_READONLY)==0;
46464 break;
46465 case SQLITE_ACCESS_SYMLINK:
46466 rc = attr!=INVALID_FILE_ATTRIBUTES &&
46467 (attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0;
46468 break;
46469 default:
46470 assert(!"Invalid flags argument");
46471 }
46472 *pResOut = rc;
46473 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
@@ -49512,19 +49503,17 @@
49503 sqlite3_free(p);
49504 pPg = 0;
49505 }
49506 #else
49507 pPg = pcache1Alloc(pCache->szAlloc);
49508 p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
49509 #endif
49510 if( benignMalloc ){ sqlite3EndBenignMalloc(); }
49511 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
49512 pcache1EnterMutex(pCache->pGroup);
49513 #endif
49514 if( pPg==0 ) return 0;
 
 
 
49515 p->page.pBuf = pPg;
49516 p->page.pExtra = &p[1];
49517 p->isBulkLocal = 0;
49518 p->isAnchor = 0;
49519 }
@@ -55793,34 +55782,31 @@
55782 ** to by zPathname, length nPathname. Or, if this is a temporary file,
55783 ** leave both nPathname and zPathname set to 0.
55784 */
55785 if( zFilename && zFilename[0] ){
55786 const char *z;
55787 if( (vfsFlags & SQLITE_OPEN_NOFOLLOW)!=0 ){
55788 int isLink = 0;
55789 int rc = sqlite3OsAccess(pVfs, zFilename, SQLITE_ACCESS_SYMLINK, &isLink);
55790 if( rc==SQLITE_OK && isLink ) rc = SQLITE_CANTOPEN_SYMLINK;
55791 if( rc ) return rc;
55792 }
55793 nPathname = pVfs->mxPathname+1;
55794 zPathname = sqlite3DbMallocRaw(0, nPathname*2);
55795 if( zPathname==0 ){
55796 return SQLITE_NOMEM_BKPT;
55797 }
55798 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
55799 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
 
 
 
 
 
 
 
 
 
55800 nPathname = sqlite3Strlen30(zPathname);
55801 z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
55802 while( *z ){
55803 z += strlen(z)+1;
55804 z += strlen(z)+1;
55805 nUri++;
55806 }
55807 nUriByte = (int)(&z[2] - zUri);
55808 assert( nUriByte>=1 );
55809 if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
55810 /* This branch is taken when the journal path required by
55811 ** the database being opened will be more than pVfs->mxPathname
55812 ** bytes in length. This means the database cannot be opened,
@@ -57630,11 +57616,10 @@
57616
57617 /* This routine should not be called if a prior error has occurred.
57618 ** But if (due to a coding error elsewhere in the system) it does get
57619 ** called, just return the same error code without doing anything. */
57620 if( NEVER(pPager->errCode) ) return pPager->errCode;
 
57621
57622 assert( pPager->eState==PAGER_WRITER_LOCKED
57623 || pPager->eState==PAGER_WRITER_FINISHED
57624 || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)
57625 );
@@ -57659,10 +57644,11 @@
57644 pPager->eState = PAGER_READER;
57645 return SQLITE_OK;
57646 }
57647
57648 PAGERTRACE(("COMMIT %d\n", PAGERID(pPager)));
57649 pPager->iDataVersion++;
57650 rc = pager_end_transaction(pPager, pPager->setMaster, 1);
57651 return pager_error(pPager, rc);
57652 }
57653
57654 /*
@@ -60579,23 +60565,11 @@
60565 ** of the aReadMark[] slot. The assumption here is that if that is
60566 ** happening, the other client may only be increasing the value,
60567 ** not decreasing it. So assuming either that either the "old" or
60568 ** "new" version of the value is read, and not some arbitrary value
60569 ** that would never be written by a real client, things are still
60570 ** safe. */
 
 
 
 
 
 
 
 
 
 
 
 
60571 u32 y = pInfo->aReadMark[i];
60572 if( mxSafeFrame>y ){
60573 assert( y<=pWal->hdr.mxFrame );
60574 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
60575 if( rc==SQLITE_OK ){
@@ -66047,17 +66021,13 @@
66021 memcpy(zFullPathname, zFilename, nFilename);
66022 }else{
66023 rc = sqlite3OsFullPathname(pVfs, zFilename,
66024 nFullPathname, zFullPathname);
66025 if( rc ){
66026 sqlite3_free(zFullPathname);
66027 sqlite3_free(p);
66028 return rc;
 
 
 
 
66029 }
66030 }
66031 #if SQLITE_THREADSAFE
66032 mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);
66033 sqlite3_mutex_enter(mutexOpen);
@@ -69362,15 +69332,12 @@
69332
69333 /* If the database file is corrupt, it is possible for the value of idx
69334 ** to be invalid here. This can only occur if a second cursor modifies
69335 ** the page while cursor pCur is holding a reference to it. Which can
69336 ** only happen if the database is corrupt in such a way as to link the
69337 ** page into more than one b-tree structure. */
69338 testcase( idx>pPage->nCell );
 
 
 
69339
69340 if( idx>=pPage->nCell ){
69341 if( !pPage->leaf ){
69342 rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
69343 if( rc ) return rc;
@@ -71955,34 +71922,10 @@
71922
71923 *ppChild = pChild;
71924 return SQLITE_OK;
71925 }
71926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71927 /*
71928 ** The page that pCur currently points to has just been modified in
71929 ** some way. This function figures out if this modification means the
71930 ** tree needs to be balanced, and if so calls the appropriate balancing
71931 ** routine. Balancing routines are:
@@ -72006,11 +71949,11 @@
71949
71950 if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
71951 if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
71952 break;
71953 }else if( (iPage = pCur->iPage)==0 ){
71954 if( pPage->nOverflow ){
71955 /* The root page of the b-tree is overfull. In this case call the
71956 ** balance_deeper() function to create a new child for the root-page
71957 ** and copy the current contents of the root-page to it. The
71958 ** next iteration of the do-loop will balance the child page.
71959 */
@@ -72377,13 +72320,11 @@
72320 return btreeOverwriteCell(pCur, &x2);
72321 }
72322 }
72323
72324 }
72325 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
 
 
72326
72327 pPage = pCur->pPage;
72328 assert( pPage->intKey || pX->nKey>=0 );
72329 assert( pPage->leaf || !pPage->intKey );
72330 if( pPage->nFree<0 ){
@@ -75548,11 +75489,12 @@
75489 if( flags & (MEM_Int|MEM_IntReal) ){
75490 testcase( flags & MEM_IntReal );
75491 return pMem->u.i;
75492 }else if( flags & MEM_Real ){
75493 return doubleToInt64(pMem->u.r);
75494 }else if( flags & (MEM_Str|MEM_Blob) ){
75495 assert( pMem->z || pMem->n==0 );
75496 return memIntValue(pMem);
75497 }else{
75498 return 0;
75499 }
75500 }
@@ -75705,12 +75647,12 @@
75647 ** "aff". Casting is different from applying affinity in that a cast
75648 ** is forced. In other words, the value is converted into the desired
75649 ** affinity even if that results in loss of data. This routine is
75650 ** used (for example) to implement the SQL "cast()" operator.
75651 */
75652 SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
75653 if( pMem->flags & MEM_Null ) return;
75654 switch( aff ){
75655 case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */
75656 if( (pMem->flags & MEM_Blob)==0 ){
75657 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
75658 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
@@ -75737,14 +75679,13 @@
75679 assert( MEM_Str==(MEM_Blob>>3) );
75680 pMem->flags |= (pMem->flags&MEM_Blob)>>3;
75681 sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);
75682 assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );
75683 pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero);
75684 break;
75685 }
75686 }
 
75687 }
75688
75689 /*
75690 ** Initialize bulk memory to be a consistent Mem object.
75691 **
@@ -77513,11 +77454,10 @@
77454 **
77455 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
77456 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
77457 ** * OP_Destroy
77458 ** * OP_VUpdate
 
77459 ** * OP_VRename
77460 ** * OP_FkCounter with P2==0 (immediate foreign key constraint)
77461 ** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine
77462 ** (for CREATE TABLE AS SELECT ...)
77463 **
@@ -77541,11 +77481,10 @@
77481
77482 while( (pOp = opIterNext(&sIter))!=0 ){
77483 int opcode = pOp->opcode;
77484 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
77485 || opcode==OP_VDestroy
 
77486 || (opcode==OP_ParseSchema && pOp->p4.z==0)
77487 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
77488 && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
77489 ){
77490 hasAbort = 1;
@@ -78031,33 +77970,10 @@
77970 return sqlite3VdbeChangeToNoop(p, p->nOp-1);
77971 }else{
77972 return 0;
77973 }
77974 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77975
77976 /*
77977 ** Change the value of the P4 operand for a specific instruction.
77978 ** This routine is useful when a large program is loaded from a
77979 ** static array using sqlite3VdbeAddOpList but we want to make a
@@ -78172,12 +78088,11 @@
78088 ** makes the code easier to read during debugging. None of this happens
78089 ** in a production build.
78090 */
78091 static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
78092 assert( p->nOp>0 || p->aOp==0 );
78093 assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );
 
78094 if( p->nOp ){
78095 assert( p->aOp );
78096 sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
78097 p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);
78098 }
@@ -86213,15 +86128,13 @@
86128 testcase( pOp->p2==SQLITE_AFF_INTEGER );
86129 testcase( pOp->p2==SQLITE_AFF_REAL );
86130 pIn1 = &aMem[pOp->p1];
86131 memAboutToChange(p, pIn1);
86132 rc = ExpandBlob(pIn1);
86133 sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);
 
 
86134 UPDATE_MAX_BLOBSIZE(pIn1);
86135 if( rc ) goto abort_due_to_error;
86136 break;
86137 }
86138 #endif /* SQLITE_OMIT_CAST */
86139
86140 /* Opcode: Eq P1 P2 P3 P4 P5
@@ -86376,11 +86289,16 @@
86289 affinity = pOp->p5 & SQLITE_AFF_MASK;
86290 if( affinity>=SQLITE_AFF_NUMERIC ){
86291 if( (flags1 | flags3)&MEM_Str ){
86292 if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
86293 applyNumericAffinity(pIn1,0);
86294 assert( flags3==pIn3->flags );
86295 /* testcase( flags3!=pIn3->flags );
86296 ** this used to be possible with pIn1==pIn3, but not since
86297 ** the column cache was removed. The following assignment
86298 ** is essentially a no-op. But, it provides defense-in-depth
86299 ** in case our analysis is incorrect, so it is left in. */
86300 flags3 = pIn3->flags;
86301 }
86302 if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){
86303 applyNumericAffinity(pIn3,0);
86304 }
@@ -86399,11 +86317,11 @@
86317 testcase( pIn1->flags & MEM_Real );
86318 testcase( pIn1->flags & MEM_IntReal );
86319 sqlite3VdbeMemStringify(pIn1, encoding, 1);
86320 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
86321 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
86322 assert( pIn1!=pIn3 );
86323 }
86324 if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
86325 testcase( pIn3->flags & MEM_Int );
86326 testcase( pIn3->flags & MEM_Real );
86327 testcase( pIn3->flags & MEM_IntReal );
@@ -86434,14 +86352,14 @@
86352 static const unsigned char aGTb[] = { 1, 0, 1, 0, 0, 1 };
86353 res2 = aGTb[pOp->opcode - OP_Ne];
86354 }
86355
86356 /* Undo any changes made by applyAffinity() to the input registers. */
86357 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
86358 pIn1->flags = flags1;
86359 assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
86360 pIn3->flags = flags3;
 
 
86361
86362 if( pOp->p5 & SQLITE_STOREP2 ){
86363 pOut = &aMem[pOp->p2];
86364 iCompare = res;
86365 if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){
@@ -86473,35 +86391,20 @@
86391 break;
86392 }
86393
86394 /* Opcode: ElseNotEq * P2 * * *
86395 **
86396 ** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator.
86397 ** If result of an OP_Eq comparison on the same two operands
86398 ** would have be NULL or false (0), then then jump to P2.
86399 ** If the result of an OP_Eq comparison on the two previous operands
86400 ** would have been true (1), then fall through.
 
 
 
 
 
86401 */
86402 case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
86403 assert( pOp>aOp );
86404 assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
86405 assert( pOp[-1].p5 & SQLITE_STOREP2 );
 
 
 
 
 
 
 
 
 
 
86406 VdbeBranchTaken(iCompare!=0, 2);
86407 if( iCompare!=0 ) goto jump_to_p2;
86408 break;
86409 }
86410
@@ -86908,13 +86811,11 @@
86811 const u8 *zEndHdr; /* Pointer to first byte after the header */
86812 u64 offset64; /* 64-bit offset */
86813 u32 t; /* A type code from the record header */
86814 Mem *pReg; /* PseudoTable input register */
86815
 
86816 pC = p->apCsr[pOp->p1];
 
86817 p2 = pOp->p2;
86818
86819 /* If the cursor cache is stale (meaning it is not currently point at
86820 ** the correct row) then bring it up-to-date by doing the necessary
86821 ** B-Tree seek. */
@@ -86922,10 +86823,11 @@
86823 if( rc ) goto abort_due_to_error;
86824
86825 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
86826 pDest = &aMem[pOp->p3];
86827 memAboutToChange(p, pDest);
86828 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
86829 assert( pC!=0 );
86830 assert( p2<pC->nField );
86831 aOffset = pC->aOffset;
86832 assert( pC->eCurType!=CURTYPE_VTAB );
86833 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
@@ -87178,11 +87080,11 @@
87080 assert( pOp->p2>0 );
87081 assert( zAffinity[pOp->p2]==0 );
87082 pIn1 = &aMem[pOp->p1];
87083 while( 1 /*exit-by-break*/ ){
87084 assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );
87085 assert( memIsValid(pIn1) );
87086 applyAffinity(pIn1, zAffinity[0], encoding);
87087 if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
87088 /* When applying REAL affinity, if the result is still an MEM_Int
87089 ** that will fit in 6 bytes, then change the type to MEM_IntReal
87090 ** so that we keep the high-resolution integer value but know that
@@ -87624,16 +87526,12 @@
87526 p->pc = (int)(pOp - aOp);
87527 db->autoCommit = 0;
87528 p->rc = rc = SQLITE_BUSY;
87529 goto vdbe_return;
87530 }
87531 db->isTransactionSavepoint = 0;
87532 rc = p->rc;
 
 
 
 
 
87533 }else{
87534 int isSchemaChange;
87535 iSavepoint = db->nSavepoint - iSavepoint - 1;
87536 if( p1==SAVEPOINT_ROLLBACK ){
87537 isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;
@@ -87657,11 +87555,10 @@
87555 sqlite3ExpirePreparedStatements(db, 0);
87556 sqlite3ResetAllSchemasOfConnection(db);
87557 db->mDbFlags |= DBFLAG_SchemaChange;
87558 }
87559 }
 
87560
87561 /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
87562 ** savepoints nested inside of the savepoint being operated on. */
87563 while( db->pSavepoint!=pSavepoint ){
87564 pTmp = db->pSavepoint;
@@ -88153,11 +88050,10 @@
88050 case OP_OpenDup: {
88051 VdbeCursor *pOrig; /* The original cursor to be duplicated */
88052 VdbeCursor *pCx; /* The new cursor */
88053
88054 pOrig = p->apCsr[pOp->p2];
 
88055 assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */
88056
88057 pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
88058 if( pCx==0 ) goto no_mem;
88059 pCx->nullRow = 1;
@@ -91583,11 +91479,11 @@
91479 pVtab = pCur->uc.pVCur->pVtab;
91480 pModule = pVtab->pModule;
91481 assert( pModule->xColumn );
91482 memset(&sContext, 0, sizeof(sContext));
91483 sContext.pOut = pDest;
91484 testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );
91485 if( pOp->p5 & OPFLAG_NOCHNG ){
91486 sqlite3VdbeMemSetNull(pDest);
91487 pDest->flags = MEM_Null|MEM_Zero;
91488 pDest->u.nZero = 0;
91489 }else{
@@ -92040,57 +91936,10 @@
91936 ** An Abort is safe if either there have been no writes, or if there is
91937 ** an active statement journal.
91938 */
91939 case OP_Abortable: {
91940 sqlite3VdbeAssertAbortable(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91941 break;
91942 }
91943 #endif
91944
91945 /* Opcode: Noop * * * * *
@@ -96000,12 +95849,12 @@
95849 testcase( ExprHasProperty(pExpr, EP_Reduced) );
95850 while(1){
95851 rc = pWalker->xExprCallback(pWalker, pExpr);
95852 if( rc ) return rc & WRC_Abort;
95853 if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
 
95854 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
95855 assert( pExpr->x.pList==0 || pExpr->pRight==0 );
95856 if( pExpr->pRight ){
95857 assert( !ExprHasProperty(pExpr, EP_WinFunc) );
95858 pExpr = pExpr->pRight;
95859 continue;
95860 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -96689,39 +96538,22 @@
96538 pTopNC->nErr++;
96539 }
96540
96541 /* If a column from a table in pSrcList is referenced, then record
96542 ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
96543 ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the
96544 ** column number is greater than the number of bits in the bitmask
96545 ** then set the high-order bit of the bitmask.
 
 
 
 
 
 
 
 
96546 */
96547 if( pExpr->iColumn>=0 && pMatch!=0 ){
96548 int n = pExpr->iColumn;
96549 testcase( n==BMS-1 );
96550 if( n>=BMS ){
96551 n = BMS-1;
96552 }
96553 assert( pMatch->iCursor==pExpr->iTable );
96554 pMatch->colUsed |= ((Bitmask)1)<<n;
 
 
 
 
 
 
 
 
 
 
 
96555 }
96556
96557 /* Clean up and return
96558 */
96559 sqlite3ExprDelete(db, pExpr->pLeft);
@@ -96756,68 +96588,47 @@
96588 */
96589 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
96590 Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
96591 if( p ){
96592 struct SrcList_item *pItem = &pSrc->a[iSrc];
96593 p->y.pTab = pItem->pTab;
96594 p->iTable = pItem->iCursor;
96595 if( p->y.pTab->iPKey==iCol ){
96596 p->iColumn = -1;
96597 }else{
96598 p->iColumn = (ynVar)iCol;
96599 testcase( iCol==BMS );
96600 testcase( iCol==BMS-1 );
96601 pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
 
 
 
 
 
 
 
 
96602 }
96603 }
96604 return p;
96605 }
96606
96607 /*
96608 ** Report an error that an expression is not valid for some set of
96609 ** pNC->ncFlags values determined by validMask.
 
 
 
 
 
 
 
 
 
 
 
 
96610 */
96611 static void notValid(
96612 Parse *pParse, /* Leave error message here */
96613 NameContext *pNC, /* The name context */
96614 const char *zMsg, /* Type of error */
96615 int validMask /* Set of contexts for which prohibited */
96616 ){
96617 assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 );
96618 if( (pNC->ncFlags & validMask)!=0 ){
96619 const char *zIn = "partial index WHERE clauses";
96620 if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
96621 #ifndef SQLITE_OMIT_CHECK
96622 else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints";
96623 #endif
96624 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
96625 else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns";
96626 #endif
96627 sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
96628 }
96629 }
 
 
 
96630
96631 /*
96632 ** Expression p should encode a floating point value between 1.0 and 0.0.
96633 ** Return 1024 times this value. Or return -1 if p is not a floating point
96634 ** value between 1.0 and 0.0.
@@ -96902,14 +96713,11 @@
96713 zDb = 0;
96714 zTable = 0;
96715 zColumn = pExpr->u.zToken;
96716 }else{
96717 Expr *pLeft = pExpr->pLeft;
96718 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr|NC_GenCol);
 
 
 
96719 pRight = pExpr->pRight;
96720 if( pRight->op==TK_ID ){
96721 zDb = 0;
96722 }else{
96723 assert( pRight->op==TK_DOT );
@@ -97002,12 +96810,11 @@
96810 }
96811 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
96812 /* Date/time functions that use 'now', and other functions like
96813 ** sqlite_version() that might change over time cannot be used
96814 ** in an index. */
96815 notValid(pParse, pNC, "non-deterministic functions", NC_SelfRef);
 
96816 }else{
96817 assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
96818 pExpr->op2 = pNC->ncFlags & NC_SelfRef;
96819 }
96820 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
@@ -97105,11 +96912,11 @@
96912 #ifndef SQLITE_OMIT_WINDOWFUNC
96913 if( pWin ){
96914 Select *pSel = pNC->pWinSelect;
96915 assert( pWin==pExpr->y.pWin );
96916 if( IN_RENAME_OBJECT==0 ){
96917 sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef);
96918 }
96919 sqlite3WalkExprList(pWalker, pWin->pPartition);
96920 sqlite3WalkExprList(pWalker, pWin->pOrderBy);
96921 sqlite3WalkExpr(pWalker, pWin->pFilter);
96922 sqlite3WindowLink(pSel, pWin);
@@ -97150,16 +96957,12 @@
96957 #endif
96958 case TK_IN: {
96959 testcase( pExpr->op==TK_IN );
96960 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
96961 int nRef = pNC->nRef;
96962 notValid(pParse, pNC, "subqueries",
96963 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
 
 
 
 
96964 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
96965 assert( pNC->nRef>=nRef );
96966 if( nRef!=pNC->nRef ){
96967 ExprSetProperty(pExpr, EP_VarSelect);
96968 pNC->ncFlags |= NC_VarSelect;
@@ -97166,16 +96969,12 @@
96969 }
96970 }
96971 break;
96972 }
96973 case TK_VARIABLE: {
96974 notValid(pParse, pNC, "parameters",
96975 NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol);
 
 
 
 
96976 break;
96977 }
96978 case TK_IS:
96979 case TK_ISNOT: {
96980 Expr *pRight = sqlite3ExprSkipCollateAndLikely(pExpr->pRight);
@@ -98404,11 +98203,10 @@
98203 ){
98204 int p5;
98205 int addr;
98206 CollSeq *p4;
98207
 
98208 if( isCommuted ){
98209 p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft);
98210 }else{
98211 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
98212 }
@@ -98622,11 +98420,10 @@
98420 int regRight = 0;
98421 u8 opx = op;
98422 int addrDone = sqlite3VdbeMakeLabel(pParse);
98423 int isCommuted = ExprHasProperty(pExpr,EP_Commuted);
98424
 
98425 if( nLeft!=sqlite3ExprVectorSize(pRight) ){
98426 sqlite3ErrorMsg(pParse, "row value misused");
98427 return;
98428 }
98429 assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
@@ -99971,13 +99768,11 @@
99768 switch( pExpr->op ){
99769 /* Consider functions to be constant if all their arguments are constant
99770 ** and either pWalker->eCode==4 or 5 or the function has the
99771 ** SQLITE_FUNC_CONST flag. */
99772 case TK_FUNCTION:
99773 if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){
 
 
99774 return WRC_Continue;
99775 }else{
99776 pWalker->eCode = 0;
99777 return WRC_Abort;
99778 }
@@ -100236,13 +100031,11 @@
100031 case TK_BLOB:
100032 return 0;
100033 case TK_COLUMN:
100034 return ExprHasProperty(p, EP_CanBeNull) ||
100035 p->y.pTab==0 || /* Reference to column of index on expression */
100036 (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0);
 
 
100037 default:
100038 return 1;
100039 }
100040 }
100041
@@ -100715,14 +100508,12 @@
100508 ** message of the form:
100509 **
100510 ** "sub-select returns N columns - expected M"
100511 */
100512 SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
100513 const char *zFmt = "sub-select returns %d columns - expected %d";
100514 sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
 
 
100515 }
100516 #endif
100517
100518 /*
100519 ** Expression pExpr is a vector that has been used in a context where
@@ -101220,25 +101011,19 @@
101011 }
101012 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
101013 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
101014 }
101015 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
101016 sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
 
101017 (void*)pColl, P4_COLLSEQ);
101018 VdbeCoverageIf(v, ii<pList->nExpr-1);
101019 VdbeCoverageIf(v, ii==pList->nExpr-1);
 
 
101020 sqlite3VdbeChangeP5(v, zAff[0]);
101021 }else{
 
101022 assert( destIfNull==destIfFalse );
101023 sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,
101024 (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
 
 
101025 sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);
101026 }
101027 sqlite3ReleaseTempReg(pParse, regToFree);
101028 }
101029 if( regCkNull ){
@@ -101257,11 +101042,10 @@
101042 if( destIfNull==destIfFalse ){
101043 destStep2 = destIfFalse;
101044 }else{
101045 destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
101046 }
 
101047 for(i=0; i<nVector; i++){
101048 Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
101049 if( sqlite3ExprCanBeNull(p) ){
101050 sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
101051 VdbeCoverage(v);
@@ -101449,24 +101233,15 @@
101233 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
101234 Parse *pParse,
101235 Column *pCol,
101236 int regOut
101237 ){
 
 
 
 
 
 
 
 
 
101238 sqlite3ExprCode(pParse, pCol->pDflt, regOut);
101239 if( pCol->affinity>=SQLITE_AFF_TEXT ){
101240 sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, regOut, 1, 0,
101241 &pCol->affinity, 1);
101242 }
 
101243 }
101244 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
101245
101246 /*
101247 ** Generate code to extract the value of the iCol-th column of a table.
@@ -101537,21 +101312,21 @@
101312 u8 p5 /* P5 value for OP_Column + FLAGS */
101313 ){
101314 assert( pParse->pVdbe!=0 );
101315 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg);
101316 if( p5 ){
101317 sqlite3VdbeChangeP5(pParse->pVdbe, p5);
 
101318 }
101319 return iReg;
101320 }
101321
101322 /*
101323 ** Generate code to move content from registers iFrom...iFrom+nReg-1
101324 ** over to iTo..iTo+nReg-1.
101325 */
101326 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){
101327 assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );
101328 sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);
101329 }
101330
101331 /*
101332 ** Convert a scalar expression node to a TK_REGISTER referencing
@@ -101649,25 +101424,19 @@
101424 }
101425 /* Otherwise, fall thru into the TK_COLUMN case */
101426 }
101427 case TK_COLUMN: {
101428 int iTab = pExpr->iTable;
 
101429 if( ExprHasProperty(pExpr, EP_FixedCol) ){
101430 /* This COLUMN expression is really a constant due to WHERE clause
101431 ** constraints, and that constant is coded by the pExpr->pLeft
101432 ** expresssion. However, make sure the constant has the correct
101433 ** datatype by applying the Affinity of the table column to the
101434 ** constant.
101435 */
101436 int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
101437 int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
 
 
 
 
 
101438 if( aff>SQLITE_AFF_BLOB ){
101439 static const char zAff[] = "B\000C\000D\000E";
101440 assert( SQLITE_AFF_BLOB=='A' );
101441 assert( SQLITE_AFF_TEXT=='B' );
101442 if( iReg!=target ){
@@ -101691,11 +101460,11 @@
101460 Table *pTab = pExpr->y.pTab;
101461 int iSrc;
101462 int iCol = pExpr->iColumn;
101463 assert( pTab!=0 );
101464 assert( iCol>=XN_ROWID );
101465 assert( iCol<pExpr->y.pTab->nCol );
101466 if( iCol<0 ){
101467 return -1-pParse->iSelfTab;
101468 }
101469 pCol = pTab->aCol + iCol;
101470 testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
@@ -101726,17 +101495,13 @@
101495 /* Coding an expression that is part of an index where column names
101496 ** in the index refer to the table to which the index belongs */
101497 iTab = pParse->iSelfTab - 1;
101498 }
101499 }
101500 return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
101501 pExpr->iColumn, iTab, target,
101502 pExpr->op2);
 
 
 
 
101503 }
101504 case TK_INTEGER: {
101505 codeInteger(pParse, pExpr, 0, target);
101506 return target;
101507 }
@@ -101754,16 +101519,11 @@
101519 case TK_STRING: {
101520 assert( !ExprHasProperty(pExpr, EP_IntValue) );
101521 sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
101522 return target;
101523 }
101524 case TK_NULL: {
 
 
 
 
 
101525 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
101526 return target;
101527 }
101528 #ifndef SQLITE_OMIT_BLOB_LITERAL
101529 case TK_BLOB: {
@@ -101786,11 +101546,11 @@
101546 assert( pExpr->u.zToken!=0 );
101547 assert( pExpr->u.zToken[0]!=0 );
101548 sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
101549 if( pExpr->u.zToken[1]!=0 ){
101550 const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
101551 assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );
101552 pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
101553 sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
101554 }
101555 return target;
101556 }
@@ -102099,16 +101859,12 @@
101859 #endif
101860 {
101861 sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
101862 pDef, pExpr->op2);
101863 }
101864 if( nFarg && constMask==0 ){
101865 sqlite3ReleaseTempRange(pParse, r1, nFarg);
 
 
 
 
101866 }
101867 return target;
101868 }
101869 #ifndef SQLITE_OMIT_SUBQUERY
101870 case TK_EXISTS:
@@ -102200,11 +101956,11 @@
101956 ** p1==2 -> old.b p1==5 -> new.b
101957 */
101958 Table *pTab = pExpr->y.pTab;
101959 int iCol = pExpr->iColumn;
101960 int p1 = pExpr->iTable * (pTab->nCol+1) + 1
101961 + (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1);
101962
101963 assert( pExpr->iTable==0 || pExpr->iTable==1 );
101964 assert( iCol>=-1 && iCol<pTab->nCol );
101965 assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
101966 assert( p1>=0 && p1<(pTab->nCol*2+2) );
@@ -102274,11 +102030,11 @@
102030 **
102031 ** The result of the expression is the Ri for the first matching Ei,
102032 ** or if there is no matching Ei, the ELSE term Y, or if there is
102033 ** no ELSE term, NULL.
102034 */
102035 default: assert( op==TK_CASE ); {
102036 int endLabel; /* GOTO label for end of CASE stmt */
102037 int nextCase; /* GOTO label for next WHEN clause */
102038 int nExpr; /* 2x number of WHEN terms */
102039 int i; /* Loop counter */
102040 ExprList *pEList; /* List of WHEN terms */
@@ -103331,14 +103087,11 @@
103087 sqlite3WalkExpr(pWalker, pExpr->pRight);
103088 }
103089 return WRC_Prune;
103090
103091 case TK_BETWEEN:
103092 sqlite3WalkExpr(pWalker, pExpr->pLeft);
 
 
 
103093 return WRC_Prune;
103094
103095 /* Virtual tables are allowed to use constraints like x=NULL. So
103096 ** a term of the form x=y does not prove that y is not null if x
103097 ** is the column of a virtual table */
@@ -103748,15 +103501,12 @@
103501 /*
103502 ** Deallocate a register, making available for reuse for some other
103503 ** purpose.
103504 */
103505 SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
103506 if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){
103507 pParse->aTempReg[pParse->nTempReg++] = iReg;
 
 
 
103508 }
103509 }
103510
103511 /*
103512 ** Allocate or deallocate a block of nReg consecutive registers.
@@ -103778,11 +103528,10 @@
103528 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
103529 if( nReg==1 ){
103530 sqlite3ReleaseTempReg(pParse, iReg);
103531 return;
103532 }
 
103533 if( nReg>pParse->nRangeReg ){
103534 pParse->nRangeReg = nReg;
103535 pParse->iRangeReg = iReg;
103536 }
103537 }
@@ -104522,18 +104271,16 @@
104271 */
104272 SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
104273 RenameToken *pNew;
104274 assert( pPtr || pParse->db->mallocFailed );
104275 renameTokenCheckAll(pParse, pPtr);
104276 pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
104277 if( pNew ){
104278 pNew->p = pPtr;
104279 pNew->t = *pToken;
104280 pNew->pNext = pParse->pRename;
104281 pParse->pRename = pNew;
 
 
104282 }
104283
104284 return pPtr;
104285 }
104286
@@ -104560,38 +104307,16 @@
104307 Parse *pParse = pWalker->pParse;
104308 sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
104309 return WRC_Continue;
104310 }
104311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104312 /*
104313 ** Walker callback used by sqlite3RenameExprUnmap().
104314 */
104315 static int renameUnmapSelectCb(Walker *pWalker, Select *p){
104316 Parse *pParse = pWalker->pParse;
104317 int i;
 
 
104318 if( ALWAYS(p->pEList) ){
104319 ExprList *pList = p->pEList;
104320 for(i=0; i<pList->nExpr; i++){
104321 if( pList->a[i].zName ){
104322 sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName);
@@ -104600,31 +104325,25 @@
104325 }
104326 if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */
104327 SrcList *pSrc = p->pSrc;
104328 for(i=0; i<pSrc->nSrc; i++){
104329 sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
 
104330 }
104331 }
 
 
104332 return WRC_Continue;
104333 }
104334
104335 /*
104336 ** Remove all nodes that are part of expression pExpr from the rename list.
104337 */
104338 SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){
 
104339 Walker sWalker;
104340 memset(&sWalker, 0, sizeof(Walker));
104341 sWalker.pParse = pParse;
104342 sWalker.xExprCallback = renameUnmapExprCb;
104343 sWalker.xSelectCallback = renameUnmapSelectCb;
 
104344 sqlite3WalkExpr(&sWalker, pExpr);
 
104345 }
104346
104347 /*
104348 ** Remove all nodes that are part of expression-list pEList from the
104349 ** rename list.
@@ -104673,18 +104392,35 @@
104392 pCtx->nList++;
104393 break;
104394 }
104395 }
104396 }
104397
104398 /*
104399 ** Iterate through the Select objects that are part of WITH clauses attached
104400 ** to select statement pSelect.
104401 */
104402 static void renameWalkWith(Walker *pWalker, Select *pSelect){
104403 if( pSelect->pWith ){
104404 int i;
104405 for(i=0; i<pSelect->pWith->nCte; i++){
104406 Select *p = pSelect->pWith->a[i].pSelect;
104407 NameContext sNC;
104408 memset(&sNC, 0, sizeof(sNC));
104409 sNC.pParse = pWalker->pParse;
104410 sqlite3SelectPrep(sNC.pParse, p, &sNC);
104411 sqlite3WalkSelect(pWalker, p);
104412 }
104413 }
104414 }
104415
104416 /*
104417 ** This is a Walker select callback. It does nothing. It is only required
104418 ** because without a dummy callback, sqlite3WalkExpr() and similar do not
104419 ** descend into sub-select statements.
104420 */
104421 static int renameColumnSelectCb(Walker *pWalker, Select *p){
 
104422 renameWalkWith(pWalker, p);
104423 return WRC_Continue;
104424 }
104425
104426 /*
@@ -104811,10 +104547,11 @@
104547 ** is initialized by this function before it is used.
104548 */
104549 static int renameParseSql(
104550 Parse *p, /* Memory to use for Parse object */
104551 const char *zDb, /* Name of schema SQL belongs to */
104552 int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */
104553 sqlite3 *db, /* Database handle */
104554 const char *zSql, /* SQL to parse */
104555 int bTemp /* True if SQL is from temp schema */
104556 ){
104557 int rc;
@@ -104824,11 +104561,11 @@
104561
104562 /* Parse the SQL statement passed as the first argument. If no error
104563 ** occurs and the parse does not result in a new table, index or
104564 ** trigger object, the database must be corrupt. */
104565 memset(p, 0, sizeof(Parse));
104566 p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN);
104567 p->db = db;
104568 p->nQueryLoop = 1;
104569 rc = sqlite3RunParser(p, zSql, &zErr);
104570 assert( p->zErrMsg==0 );
104571 assert( rc!=SQLITE_OK || zErr==0 );
@@ -105131,11 +104868,11 @@
104868 sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
104869
104870 #ifndef SQLITE_OMIT_AUTHORIZATION
104871 db->xAuth = 0;
104872 #endif
104873 rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);
104874
104875 /* Find tokens that need to be replaced. */
104876 memset(&sWalker, 0, sizeof(Walker));
104877 sWalker.pParse = &sParse;
104878 sWalker.xExprCallback = renameColumnExprCb;
@@ -105145,13 +104882,12 @@
104882 sCtx.pTab = pTab;
104883 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
104884 if( sParse.pNewTable ){
104885 Select *pSelect = sParse.pNewTable->pSelect;
104886 if( pSelect ){
 
104887 sParse.rc = SQLITE_OK;
104888 sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0);
104889 rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
104890 if( rc==SQLITE_OK ){
104891 sqlite3WalkSelect(&sWalker, pSelect);
104892 }
104893 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
@@ -105264,11 +105000,10 @@
105000 */
105001 static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
105002 int i;
105003 RenameCtx *p = pWalker->u.pRename;
105004 SrcList *pSrc = pSelect->pSrc;
 
105005 if( pSrc==0 ){
105006 assert( pWalker->pParse->db->mallocFailed );
105007 return WRC_Abort;
105008 }
105009 for(i=0; i<pSrc->nSrc; i++){
@@ -105335,32 +105070,26 @@
105070 sWalker.pParse = &sParse;
105071 sWalker.xExprCallback = renameTableExprCb;
105072 sWalker.xSelectCallback = renameTableSelectCb;
105073 sWalker.u.pRename = &sCtx;
105074
105075 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
105076
105077 if( rc==SQLITE_OK ){
105078 int isLegacy = (db->flags & SQLITE_LegacyAlter);
105079 if( sParse.pNewTable ){
105080 Table *pTab = sParse.pNewTable;
105081
105082 if( pTab->pSelect ){
105083 if( isLegacy==0 ){
 
105084 NameContext sNC;
105085 memset(&sNC, 0, sizeof(sNC));
105086 sNC.pParse = &sParse;
105087
 
 
105088 sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
105089 if( sParse.nErr ) rc = sParse.rc;
105090 sqlite3WalkSelect(&sWalker, pTab->pSelect);
 
 
 
105091 }
105092 }else{
105093 /* Modify any FK definitions to point to the new table. */
105094 #ifndef SQLITE_OMIT_FOREIGN_KEY
105095 if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){
@@ -105477,11 +105206,11 @@
105206
105207 UNUSED_PARAMETER(NotUsed);
105208 if( zDb && zInput ){
105209 int rc;
105210 Parse sParse;
105211 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
105212 if( rc==SQLITE_OK ){
105213 if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){
105214 NameContext sNC;
105215 memset(&sNC, 0, sizeof(sNC));
105216 sNC.pParse = &sParse;
@@ -109270,19 +108999,17 @@
108999 **
109000 ** So, in other words, this routine shifts all the virtual columns to
109001 ** the end.
109002 **
109003 ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
109004 ** this routine is a no-op macro.
 
 
109005 */
109006 SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){
109007 int i;
109008 i16 n;
109009 assert( iCol<pTab->nCol );
109010 if( (pTab->tabFlags & TF_HasVirtual)==0 ) return iCol;
109011 for(i=0, n=0; i<iCol; i++){
109012 if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++;
109013 }
109014 if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
109015 /* iCol is a virtual column itself */
@@ -109870,11 +109597,10 @@
109597 pTab->iPKey = iCol;
109598 pTab->keyConf = (u8)onError;
109599 assert( autoInc==0 || autoInc==1 );
109600 pTab->tabFlags |= autoInc*TF_Autoincrement;
109601 if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags;
 
109602 }else if( autoInc ){
109603 #ifndef SQLITE_OMIT_AUTOINCREMENT
109604 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
109605 "INTEGER PRIMARY KEY");
109606 #endif
@@ -109955,14 +109681,11 @@
109681 SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){
109682 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
109683 u8 eType = COLFLAG_VIRTUAL;
109684 Table *pTab = pParse->pNewTable;
109685 Column *pCol;
109686 if( NEVER(pTab==0) ) goto generated_done;
 
 
 
109687 pCol = &(pTab->aCol[pTab->nCol-1]);
109688 if( IN_DECLARE_VTAB ){
109689 sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns");
109690 goto generated_done;
109691 }
@@ -110566,16 +110289,10 @@
110289 #ifndef SQLITE_OMIT_CHECK
110290 /* Resolve names in all CHECK constraint expressions.
110291 */
110292 if( p->pCheck ){
110293 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
 
 
 
 
 
 
110294 }
110295 #endif /* !defined(SQLITE_OMIT_CHECK) */
110296 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
110297 if( p->tabFlags & TF_HasGenerated ){
110298 int ii, nNG = 0;
@@ -110582,23 +110299,14 @@
110299 testcase( p->tabFlags & TF_HasVirtual );
110300 testcase( p->tabFlags & TF_HasStored );
110301 for(ii=0; ii<p->nCol; ii++){
110302 u32 colFlags = p->aCol[ii].colFlags;
110303 if( (colFlags & COLFLAG_GENERATED)!=0 ){
 
110304 testcase( colFlags & COLFLAG_VIRTUAL );
110305 testcase( colFlags & COLFLAG_STORED );
110306 sqlite3ResolveSelfReference(pParse, p, NC_GenCol,
110307 p->aCol[ii].pDflt, 0);
 
 
 
 
 
 
 
 
110308 }else{
110309 nNG++;
110310 }
110311 }
110312 if( nNG==0 ){
@@ -110824,11 +110532,10 @@
110532 /* Make a copy of the entire SELECT statement that defines the view.
110533 ** This will force all the Expr.token.z values to be dynamically
110534 ** allocated rather than point to the input string - which means that
110535 ** they will persist after the current sqlite3_exec() call returns.
110536 */
 
110537 if( IN_RENAME_OBJECT ){
110538 p->pSelect = pSelect;
110539 pSelect = 0;
110540 }else{
110541 p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
@@ -112251,13 +111958,30 @@
111958 }
111959
111960 sqlite3VdbeJumpHere(v, pIndex->tnum);
111961 }
111962 }
111963
111964 /* When adding an index to the list of indices for a table, make
111965 ** sure all indices labeled OE_Replace come after all those labeled
111966 ** OE_Ignore. This is necessary for the correct constraint check
111967 ** processing (in sqlite3GenerateConstraintChecks()) as part of
111968 ** UPDATE and INSERT statements.
111969 */
111970 if( db->init.busy || pTblName==0 ){
111971 if( onError!=OE_Replace || pTab->pIndex==0
111972 || pTab->pIndex->onError==OE_Replace){
111973 pIndex->pNext = pTab->pIndex;
111974 pTab->pIndex = pIndex;
111975 }else{
111976 Index *pOther = pTab->pIndex;
111977 while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){
111978 pOther = pOther->pNext;
111979 }
111980 pIndex->pNext = pOther->pNext;
111981 pOther->pNext = pIndex;
111982 }
111983 pIndex = 0;
111984 }
111985 else if( IN_RENAME_OBJECT ){
111986 assert( pParse->pNewIndex==0 );
111987 pParse->pNewIndex = pIndex;
@@ -112265,25 +111989,10 @@
111989 }
111990
111991 /* Clean up before exiting */
111992 exit_create_index:
111993 if( pIndex ) sqlite3FreeIndex(db, pIndex);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111994 sqlite3ExprDelete(db, pPIWhere);
111995 sqlite3ExprListDelete(db, pList);
111996 sqlite3SrcListDelete(db, pTblName);
111997 sqlite3DbFree(db, zName);
111998 }
@@ -118522,15 +118231,14 @@
118231 }
118232 return 0;
118233 }
118234
118235 /* This walker callback will compute the union of colFlags flags for all
118236 ** references columns in a CHECK constraint or generated column expression.
118237 */
118238 static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){
118239 if( pExpr->op==TK_COLUMN ){
 
118240 pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags;
118241 }
118242 return WRC_Continue;
118243 }
118244
@@ -118549,40 +118257,10 @@
118257 ){
118258 int i;
118259 Walker w;
118260 Column *pRedo;
118261 int eProgress;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118262
118263 /* Because there can be multiple generated columns that refer to one another,
118264 ** this is a two-pass algorithm. On the first pass, mark all generated
118265 ** columns as "not available".
118266 */
@@ -119299,14 +118977,10 @@
118977 if( IsVirtual(pTab) ){
118978 sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
118979 pTab->zName);
118980 goto insert_cleanup;
118981 }
 
 
 
 
118982 if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){
118983 goto insert_cleanup;
118984 }
118985 pTabList->a[0].iCursor = iDataCur;
118986 pUpsert->pUpsertSrc = pTabList;
@@ -119537,12 +119211,14 @@
119211
119212 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
119213 /* Compute the new value for generated columns after all other
119214 ** columns have already been computed. This must be done after
119215 ** computing the ROWID in case one of the generated columns
119216 ** refers to the ROWID. */
119217 if( pTab->tabFlags & TF_HasGenerated ){
119218 testcase( pTab->tabFlags & TF_HasVirtual );
119219 testcase( pTab->tabFlags & TF_HasStored );
119220 sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab);
119221 }
119222 #endif
119223
119224 /* Generate code to check constraints and generate index keys and
@@ -120570,14 +120246,10 @@
120246
120247 v = sqlite3GetVdbe(pParse);
120248 assert( v!=0 );
120249 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
120250 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
 
 
 
 
120251 if( aRegIdx[i]==0 ) continue;
120252 if( pIdx->pPartIdxWhere ){
120253 sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
120254 VdbeCoverage(v);
120255 }
@@ -125041,13 +124713,11 @@
124713 char *zErr;
124714 int jmp2;
124715 if( j==pTab->iPKey ) continue;
124716 if( pTab->aCol[j].notNull==0 ) continue;
124717 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
124718 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
 
 
124719 jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
124720 zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
124721 pTab->aCol[j].zName);
124722 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
124723 integrityCheckResultRow(v);
@@ -127009,14 +126679,11 @@
126679 };
126680 #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
126681
126682 /*
126683 ** Delete all the content of a Select structure. Deallocate the structure
126684 ** itself only if bFree is true.
 
 
 
126685 */
126686 static void clearSelect(sqlite3 *db, Select *p, int bFree){
126687 while( p ){
126688 Select *pPrior = p->pPrior;
126689 sqlite3ExprListDelete(db, p->pEList);
@@ -127116,24 +126783,10 @@
126783 */
126784 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
126785 if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);
126786 }
126787
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126788 /*
126789 ** Return a pointer to the right-most SELECT statement in a compound.
126790 */
126791 static Select *findRightmost(Select *p){
126792 while( p->pNext ) p = p->pNext;
@@ -129416,11 +129069,10 @@
129069 assert( p->selFlags & SF_MultiValue );
129070 do{
129071 assert( p->selFlags & SF_Values );
129072 assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
129073 assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );
 
129074 if( p->pPrior==0 ) break;
129075 assert( p->pPrior->pNext==p );
129076 p = p->pPrior;
129077 nRow += bShowAll;
129078 }while(1);
@@ -129507,12 +129159,11 @@
129159
129160 /* Special handling for a compound-select that originates as a VALUES clause.
129161 */
129162 if( p->selFlags & SF_MultiValue ){
129163 rc = multiSelectValues(pParse, p, &dest);
129164 goto multi_select_end;
 
129165 }
129166
129167 /* Make sure all SELECTs in the statement have the same number of elements
129168 ** in their result sets.
129169 */
@@ -129653,13 +129304,13 @@
129304
129305 /* Convert the data in the temporary table into whatever form
129306 ** it is that we currently need.
129307 */
129308 assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
129309 if( dest.eDest!=priorOp ){
 
129310 int iCont, iBreak, iStart;
129311 assert( p->pEList );
129312 iBreak = sqlite3VdbeMakeLabel(pParse);
129313 iCont = sqlite3VdbeMakeLabel(pParse);
129314 computeLimitRegisters(pParse, p, iBreak);
129315 sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
129316 iStart = sqlite3VdbeCurrentAddr(v);
@@ -129751,11 +129402,10 @@
129402 if( p->pNext==0 ){
129403 ExplainQueryPlanPop(pParse);
129404 }
129405 #endif
129406 }
 
129407
129408 /* Compute collating sequences used by
129409 ** temporary tables needed to implement the compound select.
129410 ** Attach the KeyInfo structure to all temporary tables.
129411 **
@@ -130543,11 +130193,10 @@
130193 ** (3) If the subquery is the right operand of a LEFT JOIN then
130194 ** (3a) the subquery may not be a join and
130195 ** (3b) the FROM clause of the subquery may not contain a virtual
130196 ** table and
130197 ** (3c) the outer query may not be an aggregate.
 
130198 **
130199 ** (4) The subquery can not be DISTINCT.
130200 **
130201 ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT
130202 ** sub-queries that were excluded from this optimization. Restriction
@@ -130740,15 +130389,12 @@
130389 **
130390 ** See also tickets #306, #350, and #3300.
130391 */
130392 if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){
130393 isLeftJoin = 1;
130394 if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){
130395 /* (3a) (3c) (3b) */
 
 
 
130396 return 0;
130397 }
130398 }
130399 #ifdef SQLITE_EXTRA_IFNULLROW
130400 else if( iFrom>0 && !isAgg ){
@@ -131518,13 +131164,10 @@
131164 pNew->pHaving = 0;
131165 pNew->pOrderBy = 0;
131166 p->pPrior = 0;
131167 p->pNext = 0;
131168 p->pWith = 0;
 
 
 
131169 p->selFlags &= ~SF_Compound;
131170 assert( (p->selFlags & SF_Converted)==0 );
131171 p->selFlags |= SF_Converted;
131172 assert( pNew->pPrior!=0 );
131173 pNew->pPrior->pNext = pNew;
@@ -132680,13 +132323,11 @@
132323 if( pDest->eDest==SRT_Output ){
132324 generateColumnNames(pParse, p);
132325 }
132326
132327 #ifndef SQLITE_OMIT_WINDOWFUNC
132328 if( sqlite3WindowRewrite(pParse, p) ){
 
 
132329 goto select_end;
132330 }
132331 #if SELECTTRACE_ENABLED
132332 if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){
132333 SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
@@ -133018,11 +132659,10 @@
132659 ** written the query must use a temp-table for at least one of the ORDER
132660 ** BY and DISTINCT, and an index or separate temp-table for the other.
132661 */
132662 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
132663 && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
 
132664 ){
132665 p->selFlags &= ~SF_Distinct;
132666 pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
132667 /* Notice that even thought SF_Distinct has been cleared from p->selFlags,
132668 ** the sDistinct.isTnct is still set. Hence, isTnct represents the
@@ -134542,16 +134182,12 @@
134182 if( ALWAYS(pTrigger) ){
134183 if( pTrigger->pSchema==pTrigger->pTabSchema ){
134184 Table *pTab = tableOfTrigger(pTrigger);
134185 if( pTab ){
134186 Trigger **pp;
134187 for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));
134188 *pp = (*pp)->pNext;
 
 
 
 
134189 }
134190 }
134191 sqlite3DeleteTrigger(db, pTrigger);
134192 db->mDbFlags |= DBFLAG_SchemaChange;
134193 }
@@ -137278,12 +136914,10 @@
136914 char *zWhere;
136915 int iDb;
136916 int iReg;
136917 Vdbe *v;
136918
 
 
136919 /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
136920 if( pEnd ){
136921 pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
136922 }
136923 zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
@@ -137305,17 +136939,17 @@
136939 pTab->zName,
136940 pTab->zName,
136941 zStmt,
136942 pParse->regRowid
136943 );
136944 sqlite3DbFree(db, zStmt);
136945 v = sqlite3GetVdbe(pParse);
136946 sqlite3ChangeCookie(pParse, iDb);
136947
136948 sqlite3VdbeAddOp0(v, OP_Expire);
136949 zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
136950 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
 
136951
136952 iReg = ++pParse->nMem;
136953 sqlite3VdbeLoadString(v, iReg, pTab->zName);
136954 sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
136955 }
@@ -137713,12 +137347,11 @@
137347 return SQLITE_LOCKED;
137348 }
137349 }
137350 p = vtabDisconnectAll(db, pTab);
137351 xDestroy = p->pMod->pModule->xDestroy;
137352 assert( xDestroy!=0 ); /* Checked before the virtual table is created */
 
137353 pTab->nTabRef++;
137354 rc = xDestroy(p->pVtab);
137355 /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
137356 if( rc==SQLITE_OK ){
137357 assert( pTab->pVTable==p && p->pNext==0 );
@@ -139143,12 +138776,11 @@
138776 int iEq, /* Look at loop terms starting here */
138777 WhereLoop *pLoop, /* The current loop */
138778 Expr *pX /* The IN expression to be reduced */
138779 ){
138780 sqlite3 *db = pParse->db;
138781 Expr *pNew = sqlite3ExprDup(db, pX, 0);
 
138782 if( db->mallocFailed==0 ){
138783 ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */
138784 ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */
138785 ExprList *pRhs = 0; /* New RHS after modifications */
138786 ExprList *pLhs = 0; /* New LHS after mods */
@@ -139856,13 +139488,10 @@
139488 pExpr->affExpr = sqlite3ExprAffinity(pExpr);
139489 pExpr->op = TK_COLUMN;
139490 pExpr->iTable = pX->iIdxCur;
139491 pExpr->iColumn = pX->iIdxCol;
139492 pExpr->y.pTab = 0;
 
 
 
139493 return WRC_Prune;
139494 }else{
139495 return WRC_Continue;
139496 }
139497 }
@@ -139873,12 +139502,10 @@
139502 */
139503 static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){
139504 if( pExpr->op==TK_COLUMN ){
139505 IdxExprTrans *pX = p->u.pIdxTrans;
139506 if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){
 
 
139507 pExpr->iTable = pX->iIdxCur;
139508 pExpr->iColumn = pX->iIdxCol;
139509 pExpr->y.pTab = 0;
139510 }
139511 }
@@ -139920,24 +139547,13 @@
139547 for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){
139548 i16 iRef = pIdx->aiColumn[iIdxCol];
139549 if( iRef==XN_EXPR ){
139550 assert( aColExpr->a[iIdxCol].pExpr!=0 );
139551 x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;
 
139552 w.xExprCallback = whereIndexExprTransNode;
139553 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
139554 }else if( iRef>=0 && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 ){
 
 
 
 
 
 
 
 
 
 
139555 x.iTabCol = iRef;
139556 w.xExprCallback = whereIndexExprTransColumn;
139557 #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
139558 }else{
139559 continue;
@@ -140597,14 +140213,14 @@
140213 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
140214 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
140215 if( omitTable ){
140216 /* pIdx is a covering index. No need to access the main table. */
140217 }else if( HasRowid(pIdx->pTable) ){
140218 if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (
140219 (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)
140220 && (pWInfo->eOnePass==ONEPASS_SINGLE)
140221 )){
140222 iRowidReg = ++pParse->nMem;
140223 sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);
140224 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);
140225 VdbeCoverage(v);
140226 }else{
@@ -142439,11 +142055,10 @@
142055 Expr *pNewExpr;
142056 pNewExpr = sqlite3PExpr(pParse, TK_MATCH,
142057 0, sqlite3ExprDup(db, pRight, 0));
142058 if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
142059 ExprSetProperty(pNewExpr, EP_FromJoin);
 
142060 }
142061 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
142062 testcase( idxNew==0 );
142063 pNewTerm = &pWC->a[idxNew];
142064 pNewTerm->prereqRight = prereqExpr;
@@ -142496,19 +142111,15 @@
142111 ** a virtual term for each vector component. The expression object
142112 ** used by each such virtual term is pExpr (the full vector IN(...)
142113 ** expression). The WhereTerm.iField variable identifies the index within
142114 ** the vector on the LHS that the virtual term represents.
142115 **
142116 ** This only works if the RHS is a simple SELECT, not a compound
 
142117 */
142118 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
142119 && pExpr->pLeft->op==TK_VECTOR
142120 && pExpr->x.pSelect->pPrior==0
 
 
 
142121 ){
142122 int i;
142123 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
142124 int idxNew;
142125 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
@@ -142662,14 +142273,13 @@
142273 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
142274 }else if( p->x.pList ){
142275 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
142276 }
142277 #ifndef SQLITE_OMIT_WINDOWFUNC
142278 if( p->op==TK_FUNCTION && p->y.pWin ){
142279 mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition);
142280 mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy);
 
142281 }
142282 #endif
142283 return mask;
142284 }
142285 SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
@@ -143553,12 +143163,11 @@
143163 if( (idxCols & cMask)==0 ){
143164 Expr *pX = pTerm->pExpr;
143165 idxCols |= cMask;
143166 pIdx->aiColumn[n] = pTerm->u.leftColumn;
143167 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
143168 pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : sqlite3StrBINARY;
 
143169 n++;
143170 }
143171 }
143172 }
143173 assert( (u32)n==pLoop->u.btree.nEq );
@@ -143732,17 +143341,22 @@
143341 testcase( pTerm->eOperator & WO_IS );
143342 testcase( pTerm->eOperator & WO_ISNULL );
143343 testcase( pTerm->eOperator & WO_ALL );
143344 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
143345 if( pTerm->wtFlags & TERM_VNULL ) continue;
 
 
 
 
143346 if( (pSrc->fg.jointype & JT_LEFT)!=0
143347 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
143348 && (pTerm->eOperator & (WO_IS|WO_ISNULL))
143349 ){
143350 /* An "IS" term in the WHERE clause where the virtual table is the rhs
143351 ** of a LEFT JOIN. Do not pass this term to the virtual table
143352 ** implementation, as this can lead to incorrect results from SQL such
143353 ** as:
143354 **
143355 ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */
143356 testcase( pTerm->eOperator & WO_ISNULL );
143357 testcase( pTerm->eOperator & WO_IS );
143358 continue;
143359 }
143360 assert( pTerm->u.leftColumn>=(-1) );
143361 pIdxCons[j].iColumn = pTerm->u.leftColumn;
143362 pIdxCons[j].iTermOffset = i;
@@ -143769,12 +143383,11 @@
143383 assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );
143384
143385 if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
143386 && sqlite3ExprIsVector(pTerm->pExpr->pRight)
143387 ){
143388 if( i<16 ) mNoOmit |= (1 << i);
 
143389 if( op==WO_LT ) pIdxCons[j].op = WO_LE;
143390 if( op==WO_GT ) pIdxCons[j].op = WO_GE;
143391 }
143392 }
143393
@@ -144515,16 +144128,14 @@
144128 sqlite3DebugPrintf(
144129 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x",
144130 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
144131 pTerm->eOperator, pTerm->wtFlags);
144132 if( pTerm->iField ){
144133 sqlite3DebugPrintf(" iField=%d\n", pTerm->iField);
144134 }else{
144135 sqlite3DebugPrintf("\n");
144136 }
 
 
 
 
144137 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
144138 }
144139 }
144140 #endif
144141
@@ -144567,11 +144178,11 @@
144178 sqlite3DebugPrintf("%20s","");
144179 }
144180 }else{
144181 char *z;
144182 if( p->u.vtab.idxStr ){
144183 z = sqlite3_mprintf("(%d,\"%s\",%x)",
144184 p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);
144185 }else{
144186 z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
144187 }
144188 sqlite3DebugPrintf(" %-19s", z);
@@ -145222,13 +144833,13 @@
144833
144834 /* Do not allow the upper bound of a LIKE optimization range constraint
144835 ** to mix with a lower range bound from some other source */
144836 if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
144837
144838 /* Do not allow constraints from the WHERE clause to be used by the
144839 ** right table of a LEFT JOIN. Only constraints in the ON clause are
144840 ** allowed */
144841 if( (pSrc->fg.jointype & JT_LEFT)!=0
144842 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
144843 ){
144844 continue;
144845 }
@@ -145541,29 +145152,23 @@
145152 }
145153
145154 /* Check to see if a partial index with pPartIndexWhere can be used
145155 ** in the current query. Return true if it can be and false if not.
145156 */
145157 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
 
 
 
 
 
145158 int i;
145159 WhereTerm *pTerm;
145160 Parse *pParse = pWC->pWInfo->pParse;
145161 while( pWhere->op==TK_AND ){
145162 if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;
145163 pWhere = pWhere->pRight;
145164 }
145165 if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
145166 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
145167 Expr *pExpr;
145168 pExpr = pTerm->pExpr;
145169 if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
 
145170 && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
145171 ){
145172 return 1;
145173 }
145174 }
@@ -145722,15 +145327,12 @@
145327 /* Loop over all indices. If there was an INDEXED BY clause, then only
145328 ** consider index pProbe. */
145329 for(; rc==SQLITE_OK && pProbe;
145330 pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++
145331 ){
 
145332 if( pProbe->pPartIdxWhere!=0
145333 && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
 
 
145334 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
145335 continue; /* Partial index inappropriate for this query */
145336 }
145337 if( pProbe->bNoQuery ) continue;
145338 rSize = pProbe->aiRowLogEst[0];
@@ -145953,18 +145555,11 @@
145555 assert( iTerm<pNew->nLSlot );
145556 pNew->aLTerm[iTerm] = pTerm;
145557 if( iTerm>mxTerm ) mxTerm = iTerm;
145558 testcase( iTerm==15 );
145559 testcase( iTerm==16 );
145560 if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm;
 
 
 
 
 
 
 
145561 if( (pTerm->eOperator & WO_IN)!=0 ){
145562 /* A virtual table that is constrained by an IN clause may not
145563 ** consume the ORDER BY clause because (1) the order of IN terms
145564 ** is not necessarily related to the order of output terms and
145565 ** (2) Multiple outputs from a single IN value will not merge
@@ -145973,10 +145568,11 @@
145568 pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
145569 *pbIn = 1; assert( (mExclude & WO_IN)==0 );
145570 }
145571 }
145572 }
145573 pNew->u.vtab.omitMask &= ~mNoOmit;
145574
145575 pNew->nLTerm = mxTerm+1;
145576 for(i=0; i<=mxTerm; i++){
145577 if( pNew->aLTerm[i]==0 ){
145578 /* The non-zero argvIdx values must be contiguous. Raise an
@@ -147567,11 +147163,10 @@
147163 sSelect.pEList = pResultSet;
147164 sqlite3TreeViewSelect(0, &sSelect, 0);
147165 }
147166 }
147167 if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
 
147168 sqlite3WhereClausePrint(sWLB.pWC);
147169 }
147170 #endif
147171
147172 if( nTabList!=1 || whereShortCut(&sWLB)==0 ){
@@ -147706,17 +147301,11 @@
147301 }
147302 pWInfo->nLevel--;
147303 nTabList--;
147304 }
147305 }
 
 
 
 
 
147306 WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));
 
147307 pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;
147308
147309 /* If the caller is an UPDATE or DELETE statement that is requesting
147310 ** to use a one-pass algorithm, determine if this is appropriate.
147311 **
@@ -148982,37 +148571,25 @@
148571 }
148572 /* Fall through. */
148573
148574 case TK_AGG_FUNCTION:
148575 case TK_COLUMN: {
148576 Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
148577 p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
 
 
 
 
 
 
 
 
 
 
 
 
148578 if( p->pSub ){
148579 assert( ExprHasProperty(pExpr, EP_Static)==0 );
148580 ExprSetProperty(pExpr, EP_Static);
148581 sqlite3ExprDelete(pParse->db, pExpr);
148582 ExprClearProperty(pExpr, EP_Static);
148583 memset(pExpr, 0, sizeof(Expr));
148584
148585 pExpr->op = TK_COLUMN;
148586 pExpr->iColumn = p->pSub->nExpr-1;
148587 pExpr->iTable = p->pWin->iEphCsr;
148588 pExpr->y.pTab = p->pTab;
148589 }
148590
148591 break;
148592 }
148593
148594 default: /* no-op */
148595 break;
@@ -149090,15 +148667,13 @@
148667 if( pAppend ){
148668 int i;
148669 int nInit = pList ? pList->nExpr : 0;
148670 for(i=0; i<pAppend->nExpr; i++){
148671 Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
 
148672 if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
148673 pDup->op = TK_NULL;
148674 pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
 
148675 }
148676 pList = sqlite3ExprListAppend(pParse, pList, pDup);
148677 if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
148678 }
148679 }
@@ -149129,11 +148704,11 @@
148704 Window *pWin; /* Window object iterator */
148705 Table *pTab;
148706
148707 pTab = sqlite3DbMallocZero(db, sizeof(Table));
148708 if( pTab==0 ){
148709 return SQLITE_NOMEM;
148710 }
148711
148712 p->pSrc = 0;
148713 p->pWhere = 0;
148714 p->pGroupBy = 0;
@@ -149216,13 +148791,10 @@
148791 p->pSrc->a[0].pSelect = pSub;
148792 sqlite3SrcListAssignCursors(pParse, p->pSrc);
148793 pSub->selFlags |= SF_Expanded;
148794 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
148795 if( pTab2==0 ){
 
 
 
148796 rc = SQLITE_NOMEM;
148797 }else{
148798 memcpy(pTab, pTab2, sizeof(Table));
148799 pTab->tabFlags |= TF_Ephemeral;
148800 p->pSrc->a[0].pTab = pTab;
@@ -149237,17 +148809,10 @@
148809 }
148810 if( db->mallocFailed ) rc = SQLITE_NOMEM;
148811 sqlite3DbFree(db, pTab);
148812 }
148813
 
 
 
 
 
 
 
148814 return rc;
148815 }
148816
148817 /*
148818 ** Unlink the Window object from the Select to which it is attached,
@@ -149480,11 +149045,10 @@
149045 /*
149046 ** Return 0 if the two window objects are identical, or non-zero otherwise.
149047 ** Identical window objects can be processed in a single scan.
149048 */
149049 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){
 
149050 if( p1->eFrmType!=p2->eFrmType ) return 1;
149051 if( p1->eStart!=p2->eStart ) return 1;
149052 if( p1->eEnd!=p2->eEnd ) return 1;
149053 if( p1->eExclude!=p2->eExclude ) return 1;
149054 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
@@ -151469,22 +151033,21 @@
151033 #define sqlite3ParserCTX_PDECL ,Parse *pParse
151034 #define sqlite3ParserCTX_PARAM ,pParse
151035 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
151036 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
151037 #define YYFALLBACK 1
151038 #define YYNSTATE 550
151039 #define YYNRULE 385
 
151040 #define YYNTOKEN 181
151041 #define YY_MAX_SHIFT 549
151042 #define YY_MIN_SHIFTREDUCE 800
151043 #define YY_MAX_SHIFTREDUCE 1184
151044 #define YY_ERROR_ACTION 1185
151045 #define YY_ACCEPT_ACTION 1186
151046 #define YY_NO_ACTION 1187
151047 #define YY_MIN_REDUCE 1188
151048 #define YY_MAX_REDUCE 1572
151049 /************* End control #defines *******************************************/
151050 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
151051
151052 /* Define the yytestcase() macro to be a no-op if is not already defined
151053 ** otherwise.
@@ -151549,206 +151112,206 @@
151112 ** yy_default[] Default action for each state.
151113 **
151114 *********** Begin parsing tables **********************************************/
151115 #define YY_ACTTAB_COUNT (1958)
151116 static const YYACTIONTYPE yy_action[] = {
151117 /* 0 */ 544, 1219, 544, 449, 1257, 544, 1236, 544, 114, 111,
151118 /* 10 */ 211, 544, 1534, 544, 1257, 521, 114, 111, 211, 390,
151119 /* 20 */ 1229, 342, 42, 42, 42, 42, 1222, 42, 42, 71,
151120 /* 30 */ 71, 934, 1221, 71, 71, 71, 71, 1459, 1490, 935,
151121 /* 40 */ 817, 451, 6, 121, 122, 112, 1162, 1162, 1003, 1006,
151122 /* 50 */ 996, 996, 119, 119, 120, 120, 120, 120, 1540, 390,
151123 /* 60 */ 1355, 1514, 549, 2, 1190, 194, 526, 434, 143, 291,
151124 /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1270, 525,
151125 /* 80 */ 501, 491, 164, 121, 122, 112, 1162, 1162, 1003, 1006,
151126 /* 90 */ 996, 996, 119, 119, 120, 120, 120, 120, 1355, 440,
151127 /* 100 */ 1511, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151128 /* 110 */ 115, 422, 266, 266, 266, 266, 1495, 356, 1497, 433,
151129 /* 120 */ 355, 1495, 515, 522, 1482, 541, 1111, 541, 1111, 390,
151130 /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221,
151131 /* 140 */ 1026, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151132 /* 150 */ 115, 422, 1139, 121, 122, 112, 1162, 1162, 1003, 1006,
151133 /* 160 */ 996, 996, 119, 119, 120, 120, 120, 120, 404, 426,
151134 /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1415, 466, 123,
151135 /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151136 /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390,
151137 /* 200 */ 503, 120, 120, 120, 120, 113, 1048, 1139, 1140, 1141,
151138 /* 210 */ 1048, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151139 /* 220 */ 115, 422, 1458, 121, 122, 112, 1162, 1162, 1003, 1006,
151140 /* 230 */ 996, 996, 119, 119, 120, 120, 120, 120, 390, 442,
151141 /* 240 */ 314, 83, 461, 81, 357, 380, 1139, 80, 118, 118,
151142 /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179,
151143 /* 260 */ 432, 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996,
151144 /* 270 */ 996, 119, 119, 120, 120, 120, 120, 432, 431, 266,
151145 /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151146 /* 290 */ 115, 422, 541, 1106, 900, 504, 1139, 114, 111, 211,
151147 /* 300 */ 1428, 1139, 1140, 1141, 206, 489, 1106, 390, 447, 1106,
151148 /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1428, 1430, 17,
151149 /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151150 /* 330 */ 422, 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996,
151151 /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1355, 432, 1139,
151152 /* 350 */ 480, 1139, 1140, 1141, 993, 993, 1004, 1007, 443, 118,
151153 /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151154 /* 370 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151155 /* 380 */ 119, 120, 120, 120, 120, 1051, 1051, 463, 1428, 118,
151156 /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422,
151157 /* 400 */ 1139, 449, 544, 1423, 1139, 1140, 1141, 233, 963, 1139,
151158 /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 839,
151159 /* 420 */ 474, 164, 185, 332, 71, 71, 1240, 997, 118, 118,
151160 /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121,
151161 /* 440 */ 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119,
151162 /* 450 */ 120, 120, 120, 120, 390, 1139, 1140, 1141, 832, 12,
151163 /* 460 */ 313, 507, 163, 354, 1139, 1140, 1141, 114, 111, 211,
151164 /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122,
151165 /* 480 */ 112, 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120,
151166 /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118,
151167 /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1139, 209,
151168 /* 510 */ 409, 521, 1139, 1106, 1568, 376, 252, 269, 340, 485,
151169 /* 520 */ 335, 484, 238, 390, 511, 362, 1106, 1124, 331, 1106,
151170 /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118,
151171 /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112,
151172 /* 550 */ 1162, 1162, 1003, 1006, 996, 996, 119, 119, 120, 120,
151173 /* 560 */ 120, 120, 390, 1139, 1140, 1141, 984, 1139, 1140, 1141,
151174 /* 570 */ 1139, 233, 490, 1489, 479, 476, 475, 6, 163, 544,
151175 /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1162,
151176 /* 590 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151177 /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117,
151178 /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544,
151179 /* 620 */ 1483, 542, 1139, 889, 889, 1139, 1140, 1141, 1470, 1139,
151180 /* 630 */ 275, 390, 805, 806, 807, 968, 420, 420, 420, 16,
151181 /* 640 */ 16, 55, 55, 1239, 118, 118, 118, 118, 117, 117,
151182 /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1162, 1162,
151183 /* 660 */ 1003, 1006, 996, 996, 119, 119, 120, 120, 120, 120,
151184 /* 670 */ 390, 1186, 1, 1, 549, 2, 1190, 1139, 1140, 1141,
151185 /* 680 */ 194, 291, 895, 136, 1139, 1140, 1141, 894, 519, 1489,
151186 /* 690 */ 1270, 3, 378, 6, 121, 122, 112, 1162, 1162, 1003,
151187 /* 700 */ 1006, 996, 996, 119, 119, 120, 120, 120, 120, 855,
151188 /* 710 */ 544, 921, 544, 118, 118, 118, 118, 117, 117, 116,
151189 /* 720 */ 116, 116, 115, 422, 266, 266, 1089, 1566, 1139, 1518,
151190 /* 730 */ 1566, 1190, 13, 13, 13, 13, 291, 541, 136, 390,
151191 /* 740 */ 483, 419, 418, 963, 342, 1270, 466, 408, 856, 279,
151192 /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116,
151193 /* 760 */ 116, 115, 422, 121, 122, 112, 1162, 1162, 1003, 1006,
151194 /* 770 */ 996, 996, 119, 119, 120, 120, 120, 120, 544, 266,
151195 /* 780 */ 266, 426, 390, 1139, 1140, 1141, 1169, 827, 1169, 466,
151196 /* 790 */ 429, 145, 541, 1143, 399, 313, 437, 301, 835, 1487,
151197 /* 800 */ 71, 71, 410, 6, 1087, 471, 221, 100, 112, 1162,
151198 /* 810 */ 1162, 1003, 1006, 996, 996, 119, 119, 120, 120, 120,
151199 /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116,
151200 /* 830 */ 115, 422, 237, 1422, 544, 449, 426, 287, 983, 544,
151201 /* 840 */ 236, 235, 234, 827, 97, 527, 427, 1262, 1262, 1143,
151202 /* 850 */ 492, 306, 428, 835, 974, 544, 71, 71, 973, 1238,
151203 /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117,
151204 /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266,
151205 /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 973,
151206 /* 890 */ 973, 975, 541, 526, 1106, 326, 390, 541, 493, 395,
151207 /* 900 */ 1467, 195, 528, 13, 13, 1355, 240, 1106, 277, 280,
151208 /* 910 */ 1106, 280, 303, 455, 305, 331, 390, 31, 188, 417,
151209 /* 920 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151210 /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 983,
151211 /* 940 */ 121, 122, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151212 /* 950 */ 119, 120, 120, 120, 120, 974, 321, 1139, 324, 973,
151213 /* 960 */ 121, 110, 112, 1162, 1162, 1003, 1006, 996, 996, 119,
151214 /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1182, 118, 118,
151215 /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1139,
151216 /* 990 */ 973, 973, 975, 304, 9, 364, 244, 360, 118, 118,
151217 /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312,
151218 /* 1010 */ 544, 342, 1139, 1140, 1141, 299, 290, 535, 118, 118,
151219 /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1260,
151220 /* 1030 */ 1260, 1160, 13, 13, 278, 419, 418, 466, 390, 920,
151221 /* 1040 */ 260, 260, 289, 1166, 1139, 1140, 1141, 189, 1168, 266,
151222 /* 1050 */ 266, 466, 388, 541, 1183, 544, 1167, 263, 144, 487,
151223 /* 1060 */ 919, 544, 541, 122, 112, 1162, 1162, 1003, 1006, 996,
151224 /* 1070 */ 996, 119, 119, 120, 120, 120, 120, 71, 71, 1139,
151225 /* 1080 */ 1169, 1269, 1169, 13, 13, 895, 1067, 1160, 544, 466,
151226 /* 1090 */ 894, 107, 536, 1488, 4, 1265, 1106, 6, 523, 1046,
151227 /* 1100 */ 12, 1068, 1089, 1567, 311, 453, 1567, 518, 539, 1106,
151228 /* 1110 */ 56, 56, 1106, 1486, 421, 1355, 1069, 6, 343, 285,
151229 /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115,
151230 /* 1130 */ 422, 423, 1268, 319, 1139, 1140, 1141, 875, 266, 266,
151231 /* 1140 */ 1274, 107, 536, 533, 4, 1485, 293, 876, 1208, 6,
151232 /* 1150 */ 210, 541, 541, 164, 1539, 494, 414, 864, 539, 267,
151233 /* 1160 */ 267, 1211, 396, 509, 497, 204, 266, 266, 394, 529,
151234 /* 1170 */ 8, 983, 541, 517, 544, 919, 456, 105, 105, 541,
151235 /* 1180 */ 1087, 423, 266, 266, 106, 415, 423, 546, 545, 266,
151236 /* 1190 */ 266, 973, 516, 533, 1370, 541, 15, 15, 266, 266,
151237 /* 1200 */ 454, 1117, 541, 266, 266, 1067, 1369, 513, 290, 535,
151238 /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 919, 125,
151239 /* 1220 */ 1068, 983, 973, 973, 975, 976, 27, 105, 105, 399,
151240 /* 1230 */ 341, 1508, 44, 44, 106, 1069, 423, 546, 545, 57,
151241 /* 1240 */ 57, 973, 341, 1508, 107, 536, 544, 4, 460, 399,
151242 /* 1250 */ 214, 1117, 457, 294, 375, 1088, 532, 297, 544, 537,
151243 /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58,
151244 /* 1270 */ 544, 109, 973, 973, 975, 976, 27, 1513, 1128, 425,
151245 /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372,
151246 /* 1290 */ 255, 370, 60, 60, 814, 1177, 533, 544, 273, 544,
151247 /* 1300 */ 1160, 842, 387, 386, 544, 1306, 544, 215, 210, 296,
151248 /* 1310 */ 513, 846, 544, 265, 208, 514, 1305, 295, 274, 61,
151249 /* 1320 */ 61, 62, 62, 436, 983, 1159, 45, 45, 46, 46,
151250 /* 1330 */ 105, 105, 1183, 919, 47, 47, 1473, 106, 544, 423,
151251 /* 1340 */ 546, 545, 218, 544, 973, 934, 1084, 217, 544, 377,
151252 /* 1350 */ 395, 107, 536, 935, 4, 156, 1160, 842, 158, 544,
151253 /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307,
151254 /* 1370 */ 63, 63, 544, 1447, 216, 973, 973, 975, 976, 27,
151255 /* 1380 */ 444, 64, 64, 544, 1446, 65, 65, 544, 524, 14,
151256 /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97,
151257 /* 1400 */ 1033, 544, 960, 533, 268, 127, 127, 544, 391, 67,
151258 /* 1410 */ 67, 544, 977, 290, 535, 52, 52, 513, 544, 68,
151259 /* 1420 */ 68, 1293, 512, 69, 69, 397, 165, 854, 853, 53,
151260 /* 1430 */ 53, 983, 965, 151, 151, 243, 430, 105, 105, 199,
151261 /* 1440 */ 152, 152, 448, 1302, 106, 243, 423, 546, 545, 1128,
151262 /* 1450 */ 425, 973, 320, 270, 861, 862, 1033, 220, 373, 373,
151263 /* 1460 */ 372, 255, 370, 450, 323, 814, 243, 544, 977, 544,
151264 /* 1470 */ 107, 536, 544, 4, 544, 937, 938, 325, 215, 1045,
151265 /* 1480 */ 296, 1045, 973, 973, 975, 976, 27, 539, 295, 76,
151266 /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1502, 1253,
151267 /* 1500 */ 107, 536, 544, 4, 1044, 544, 1044, 531, 1237, 544,
151268 /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544,
151269 /* 1520 */ 472, 1527, 533, 239, 73, 73, 156, 129, 129, 158,
151270 /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149,
151271 /* 1540 */ 423, 134, 134, 329, 1029, 216, 97, 239, 928, 345,
151272 /* 1550 */ 983, 243, 533, 1314, 339, 544, 105, 105, 899, 1354,
151273 /* 1560 */ 544, 1289, 258, 106, 338, 423, 546, 545, 544, 1300,
151274 /* 1570 */ 973, 892, 99, 536, 109, 4, 544, 133, 133, 391,
151275 /* 1580 */ 983, 197, 131, 131, 290, 535, 105, 105, 530, 539,
151276 /* 1590 */ 132, 132, 1360, 106, 1218, 423, 546, 545, 75, 75,
151277 /* 1600 */ 973, 973, 973, 975, 976, 27, 544, 430, 825, 1210,
151278 /* 1610 */ 893, 139, 423, 109, 544, 1199, 1198, 1200, 1521, 544,
151279 /* 1620 */ 201, 544, 11, 374, 533, 1286, 347, 349, 77, 77,
151280 /* 1630 */ 1339, 973, 973, 975, 976, 27, 74, 74, 351, 213,
151281 /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1347, 382,
151282 /* 1650 */ 353, 452, 983, 337, 1236, 1419, 1418, 205, 105, 105,
151283 /* 1660 */ 192, 367, 193, 534, 1524, 106, 1177, 423, 546, 545,
151284 /* 1670 */ 247, 167, 973, 270, 1466, 200, 1464, 1174, 373, 373,
151285 /* 1680 */ 372, 255, 370, 398, 79, 814, 83, 82, 1424, 446,
151286 /* 1690 */ 161, 177, 169, 95, 1336, 438, 172, 173, 215, 174,
151287 /* 1700 */ 296, 175, 35, 973, 973, 975, 976, 27, 295, 1344,
151288 /* 1710 */ 439, 470, 223, 36, 379, 445, 1413, 381, 459, 1350,
151289 /* 1720 */ 181, 227, 88, 465, 259, 229, 1435, 318, 186, 468,
151290 /* 1730 */ 322, 230, 384, 1201, 231, 486, 1256, 1255, 217, 411,
151291 /* 1740 */ 1254, 1247, 90, 846, 206, 413, 156, 505, 1538, 158,
151292 /* 1750 */ 1225, 1537, 283, 1507, 1226, 336, 385, 284, 1224, 496,
151293 /* 1760 */ 1536, 1297, 94, 346, 348, 216, 1246, 499, 1298, 245,
151294 /* 1770 */ 246, 1296, 416, 350, 1493, 124, 1492, 10, 524, 361,
151295 /* 1780 */ 1399, 101, 96, 288, 508, 253, 1134, 1207, 34, 1295,
151296 /* 1790 */ 547, 254, 256, 257, 392, 548, 1196, 1191, 359, 391,
151297 /* 1800 */ 1279, 1278, 196, 365, 290, 535, 366, 352, 1451, 1321,
151298 /* 1810 */ 1320, 1452, 153, 137, 281, 154, 801, 424, 155, 1450,
151299 /* 1820 */ 1449, 198, 292, 202, 203, 78, 212, 430, 271, 135,
151300 /* 1830 */ 1043, 1041, 957, 168, 219, 157, 170, 878, 308, 222,
151301 /* 1840 */ 1057, 176, 159, 961, 400, 84, 402, 178, 85, 86,
151302 /* 1850 */ 87, 166, 160, 393, 1060, 224, 225, 1056, 146, 18,
151303 /* 1860 */ 226, 317, 1049, 1171, 243, 464, 182, 228, 37, 183,
151304 /* 1870 */ 816, 469, 338, 232, 330, 481, 184, 89, 844, 19,
151305 /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 857, 147, 488,
151306 /* 1890 */ 282, 1122, 148, 1009, 927, 1092, 39, 93, 40, 495,
151307 /* 1900 */ 1093, 187, 498, 207, 262, 264, 922, 242, 1108, 109,
151308 /* 1910 */ 1112, 1110, 1096, 33, 21, 1116, 520, 1024, 22, 23,
151309 /* 1920 */ 24, 1115, 25, 190, 97, 1010, 1008, 26, 1012, 1066,
151310 /* 1930 */ 248, 7, 1065, 249, 1013, 28, 41, 888, 978, 826,
151311 /* 1940 */ 108, 29, 250, 540, 251, 1529, 371, 368, 1129, 1187,
151312 /* 1950 */ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1528,
151313 };
151314 static const YYCODETYPE yy_lookahead[] = {
151315 /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268,
151316 /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19,
151317 /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211,
@@ -151941,11 +151504,11 @@
151504 /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24,
151505 /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26,
151506 /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34,
151507 /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23,
151508 /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23,
151509 /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 310,
151510 /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310,
151511 /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151512 /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151513 /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151514 /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
@@ -151962,13 +151525,13 @@
151525 /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151526 /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151527 /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310,
151528 /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310,
151529 };
151530 #define YY_SHIFT_COUNT (549)
151531 #define YY_SHIFT_MIN (0)
151532 #define YY_SHIFT_MAX (1947)
151533 static const unsigned short int yy_shift_ofst[] = {
151534 /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481,
151535 /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481,
151536 /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481,
151537 /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340,
@@ -152021,11 +151584,10 @@
151584 /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884,
151585 /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889,
151586 /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905,
151587 /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918,
151588 /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947,
 
151589 };
151590 #define YY_REDUCE_COUNT (389)
151591 #define YY_REDUCE_MIN (-262)
151592 #define YY_REDUCE_MAX (1617)
151593 static const short yy_reduce_ofst[] = {
@@ -152068,66 +151630,65 @@
151630 /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592,
151631 /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600,
151632 /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616,
151633 };
151634 static const YYACTIONTYPE yy_default[] = {
151635 /* 0 */ 1572, 1572, 1572, 1408, 1185, 1294, 1185, 1185, 1185, 1408,
151636 /* 10 */ 1408, 1408, 1185, 1324, 1324, 1461, 1216, 1185, 1185, 1185,
151637 /* 20 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1407, 1185, 1185,
151638 /* 30 */ 1185, 1185, 1491, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151639 /* 40 */ 1185, 1185, 1185, 1333, 1185, 1185, 1185, 1185, 1185, 1185,
151640 /* 50 */ 1409, 1410, 1185, 1185, 1185, 1460, 1462, 1425, 1343, 1342,
151641 /* 60 */ 1341, 1340, 1443, 1311, 1338, 1331, 1335, 1403, 1404, 1402,
151642 /* 70 */ 1406, 1410, 1409, 1185, 1334, 1374, 1388, 1373, 1185, 1185,
151643 /* 80 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151644 /* 90 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151645 /* 100 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151646 /* 110 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151647 /* 120 */ 1185, 1185, 1185, 1185, 1185, 1185, 1382, 1387, 1393, 1386,
151648 /* 130 */ 1383, 1376, 1375, 1377, 1378, 1185, 1206, 1258, 1185, 1185,
151649 /* 140 */ 1185, 1185, 1479, 1478, 1185, 1185, 1216, 1368, 1367, 1379,
151650 /* 150 */ 1380, 1390, 1389, 1468, 1526, 1525, 1426, 1185, 1185, 1185,
151651 /* 160 */ 1185, 1185, 1185, 1491, 1185, 1185, 1185, 1185, 1185, 1185,
151652 /* 170 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151653 /* 180 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1491, 1491,
151654 /* 190 */ 1185, 1216, 1491, 1491, 1212, 1212, 1318, 1185, 1474, 1294,
151655 /* 200 */ 1285, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151656 /* 210 */ 1185, 1185, 1185, 1185, 1185, 1465, 1463, 1185, 1185, 1185,
151657 /* 220 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151658 /* 230 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151659 /* 240 */ 1185, 1185, 1185, 1185, 1185, 1290, 1185, 1185, 1185, 1185,
151660 /* 250 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1520, 1185, 1438,
151661 /* 260 */ 1272, 1290, 1290, 1290, 1290, 1292, 1273, 1271, 1284, 1217,
151662 /* 270 */ 1192, 1564, 1337, 1313, 1313, 1561, 1337, 1337, 1561, 1233,
151663 /* 280 */ 1542, 1228, 1324, 1324, 1324, 1313, 1318, 1318, 1405, 1291,
151664 /* 290 */ 1284, 1185, 1564, 1299, 1299, 1563, 1563, 1299, 1426, 1346,
151665 /* 300 */ 1352, 1261, 1337, 1267, 1267, 1267, 1267, 1299, 1203, 1337,
151666 /* 310 */ 1337, 1346, 1352, 1261, 1261, 1337, 1299, 1203, 1442, 1558,
151667 /* 320 */ 1299, 1203, 1416, 1299, 1203, 1299, 1203, 1416, 1259, 1259,
151668 /* 330 */ 1259, 1248, 1185, 1185, 1416, 1259, 1233, 1259, 1248, 1259,
151669 /* 340 */ 1259, 1509, 1416, 1420, 1420, 1416, 1317, 1312, 1317, 1312,
151670 /* 350 */ 1317, 1312, 1317, 1312, 1299, 1501, 1501, 1327, 1327, 1332,
151671 /* 360 */ 1318, 1411, 1299, 1185, 1332, 1330, 1328, 1337, 1209, 1251,
151672 /* 370 */ 1523, 1523, 1519, 1519, 1519, 1569, 1569, 1474, 1535, 1216,
151673 /* 380 */ 1216, 1216, 1216, 1535, 1235, 1235, 1217, 1217, 1216, 1535,
151674 /* 390 */ 1185, 1185, 1185, 1185, 1185, 1185, 1530, 1185, 1427, 1303,
151675 /* 400 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151676 /* 410 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151677 /* 420 */ 1185, 1185, 1185, 1357, 1185, 1188, 1471, 1185, 1185, 1469,
151678 /* 430 */ 1185, 1185, 1185, 1185, 1185, 1185, 1304, 1185, 1185, 1185,
151679 /* 440 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151680 /* 450 */ 1185, 1185, 1185, 1185, 1185, 1560, 1185, 1185, 1185, 1185,
151681 /* 460 */ 1185, 1185, 1441, 1440, 1185, 1185, 1301, 1185, 1185, 1185,
151682 /* 470 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151683 /* 480 */ 1231, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151684 /* 490 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151685 /* 500 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1329, 1185, 1185,
151686 /* 510 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151687 /* 520 */ 1185, 1185, 1506, 1319, 1185, 1185, 1551, 1185, 1185, 1185,
151688 /* 530 */ 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
151689 /* 540 */ 1185, 1546, 1275, 1359, 1185, 1358, 1362, 1185, 1197, 1185,
 
151690 };
151691 /********** End of lemon-generated parsing tables *****************************/
151692
151693 /* The next table maps tokens (terminal symbols) into fallback tokens.
151694 ** If a construct like the following:
@@ -153058,11 +152619,11 @@
152619 /* 325 */ "input ::= cmdlist",
152620 /* 326 */ "cmdlist ::= cmdlist ecmd",
152621 /* 327 */ "cmdlist ::= ecmd",
152622 /* 328 */ "ecmd ::= SEMI",
152623 /* 329 */ "ecmd ::= cmdx SEMI",
152624 /* 330 */ "ecmd ::= explain cmdx",
152625 /* 331 */ "trans_opt ::=",
152626 /* 332 */ "trans_opt ::= TRANSACTION",
152627 /* 333 */ "trans_opt ::= TRANSACTION nm",
152628 /* 334 */ "savepoint_opt ::= SAVEPOINT",
152629 /* 335 */ "savepoint_opt ::=",
@@ -153950,11 +153511,11 @@
153511 181, /* (325) input ::= cmdlist */
153512 182, /* (326) cmdlist ::= cmdlist ecmd */
153513 182, /* (327) cmdlist ::= ecmd */
153514 183, /* (328) ecmd ::= SEMI */
153515 183, /* (329) ecmd ::= cmdx SEMI */
153516 183, /* (330) ecmd ::= explain cmdx */
153517 188, /* (331) trans_opt ::= */
153518 188, /* (332) trans_opt ::= TRANSACTION */
153519 188, /* (333) trans_opt ::= TRANSACTION nm */
153520 190, /* (334) savepoint_opt ::= SAVEPOINT */
153521 190, /* (335) savepoint_opt ::= */
@@ -154340,11 +153901,11 @@
153901 -1, /* (325) input ::= cmdlist */
153902 -2, /* (326) cmdlist ::= cmdlist ecmd */
153903 -1, /* (327) cmdlist ::= ecmd */
153904 -1, /* (328) ecmd ::= SEMI */
153905 -2, /* (329) ecmd ::= cmdx SEMI */
153906 -2, /* (330) ecmd ::= explain cmdx */
153907 0, /* (331) trans_opt ::= */
153908 -1, /* (332) trans_opt ::= TRANSACTION */
153909 -2, /* (333) trans_opt ::= TRANSACTION nm */
153910 -1, /* (334) savepoint_opt ::= SAVEPOINT */
153911 0, /* (335) savepoint_opt ::= */
@@ -154428,19 +153989,16 @@
153989 yymsp = yypParser->yytos;
153990 #ifndef NDEBUG
153991 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
153992 yysize = yyRuleInfoNRhs[yyruleno];
153993 if( yysize ){
153994 fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
153995 yyTracePrompt,
153996 yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
 
 
153997 }else{
153998 fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
153999 yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
 
154000 }
154001 }
154002 #endif /* NDEBUG */
154003
154004 /* Check that the stack is large enough to grow by a single entry
@@ -155847,11 +155405,11 @@
155405 /* (325) input ::= cmdlist */ yytestcase(yyruleno==325);
155406 /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326);
155407 /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327);
155408 /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328);
155409 /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329);
155410 /* (330) ecmd ::= explain cmdx */ yytestcase(yyruleno==330);
155411 /* (331) trans_opt ::= */ yytestcase(yyruleno==331);
155412 /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332);
155413 /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333);
155414 /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334);
155415 /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335);
@@ -163524,13 +163082,10 @@
163082 # define TESTONLY(X) X
163083 #else
163084 # define TESTONLY(X)
163085 #endif
163086
 
 
 
163087 #endif /* SQLITE_AMALGAMATION */
163088
163089 #ifdef SQLITE_DEBUG
163090 SQLITE_PRIVATE int sqlite3Fts3Corrupt(void);
163091 # define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()
@@ -163570,11 +163125,10 @@
163125 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
163126 char *zContentTbl; /* content=xxx option, or NULL */
163127 char *zLanguageid; /* languageid=xxx option, or NULL */
163128 int nAutoincrmerge; /* Value configured by 'automerge' */
163129 u32 nLeafAdd; /* Number of leaf blocks added this trans */
 
163130
163131 /* Precompiled statements used by the implementation. Each of these
163132 ** statements is run and reset within a single virtual table API call.
163133 */
163134 sqlite3_stmt *aStmt[40];
@@ -163909,11 +163463,10 @@
163463
163464 /* fts3.c */
163465 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
163466 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
163467 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
 
163468 SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*);
163469 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
163470 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
163471 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
163472 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
@@ -163997,10 +163550,22 @@
163550 #ifndef SQLITE_CORE
163551 /* # include "sqlite3ext.h" */
163552 SQLITE_EXTENSION_INIT1
163553 #endif
163554
163555 /*
163556 ** The following are copied from sqliteInt.h.
163557 **
163558 ** Constants for the largest and smallest possible 64-bit signed integers.
163559 ** These macros are designed to work correctly on both 32-bit and 64-bit
163560 ** compilers.
163561 */
163562 #ifndef SQLITE_AMALGAMATION
163563 # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
163564 # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
163565 #endif
163566
163567 static int fts3EvalNext(Fts3Cursor *pCsr);
163568 static int fts3EvalStart(Fts3Cursor *pCsr);
163569 static int fts3TermSegReaderCursor(
163570 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
163571
@@ -164041,11 +163606,16 @@
163606 if( (v & mask2)==0 ){ var = v; return ret; }
163607 #define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
163608 v = (*ptr++); \
163609 if( (v & mask2)==0 ){ var = v; return ret; }
163610
163611 /*
163612 ** Read a 64-bit variable-length integer from memory starting at p[0].
163613 ** Return the number of bytes read, or 0 on error.
163614 ** The value is stored in *v.
163615 */
163616 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
163617 const unsigned char *p = (const unsigned char*)pBuf;
163618 const unsigned char *pStart = p;
163619 u32 a;
163620 u64 b;
163621 int shift;
@@ -164063,19 +163633,10 @@
163633 }
163634 *v = b;
163635 return (int)(p - pStart);
163636 }
163637
 
 
 
 
 
 
 
 
 
163638 /*
163639 ** Read a 64-bit variable-length integer from memory starting at p[0] and
163640 ** not extending past pEnd[-1].
163641 ** Return the number of bytes read, or 0 on error.
163642 ** The value is stored in *v.
@@ -165292,14 +164853,10 @@
164853 int iLangidCons = -1; /* Index of langid=x constraint, if present */
164854 int iDocidGe = -1; /* Index of docid>=x constraint, if present */
164855 int iDocidLe = -1; /* Index of docid<=x constraint, if present */
164856 int iIdx;
164857
 
 
 
 
164858 /* By default use a full table scan. This is an expensive option,
164859 ** so search through the constraints to see if a more efficient
164860 ** strategy is possible.
164861 */
164862 pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
@@ -165494,15 +165051,11 @@
165051 pCsr->pStmt = p->pSeekStmt;
165052 p->pSeekStmt = 0;
165053 }else{
165054 zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist);
165055 if( !zSql ) return SQLITE_NOMEM;
165056 rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
 
 
 
 
165057 sqlite3_free(zSql);
165058 }
165059 if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;
165060 }
165061 return rc;
@@ -165516,19 +165069,15 @@
165069 static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
165070 int rc = SQLITE_OK;
165071 if( pCsr->isRequireSeek ){
165072 rc = fts3CursorSeekStmt(pCsr);
165073 if( rc==SQLITE_OK ){
 
 
165074 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
165075 pCsr->isRequireSeek = 0;
165076 if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
 
165077 return SQLITE_OK;
165078 }else{
 
165079 rc = sqlite3_reset(pCsr->pStmt);
165080 if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){
165081 /* If no row was found and no error has occurred, then the %_content
165082 ** table is missing a row that is present in the full-text index.
165083 ** The data structures are corrupt. */
@@ -165696,11 +165245,11 @@
165245
165246 assert( piLeaf || piLeaf2 );
165247
165248 fts3GetVarint32(zNode, &iHeight);
165249 rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
165250 assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
165251
165252 if( rc==SQLITE_OK && iHeight>1 ){
165253 char *zBlob = 0; /* Blob read from %_segments table */
165254 int nBlob = 0; /* Size of zBlob in bytes */
165255
@@ -166177,16 +165726,16 @@
165726 sqlite3_int64 *pVal /* IN/OUT: Integer value */
165727 ){
165728 if( *pp>=pEnd ){
165729 *pp = 0;
165730 }else{
165731 sqlite3_int64 iVal;
165732 *pp += sqlite3Fts3GetVarint(*pp, &iVal);
165733 if( bDescIdx ){
165734 *pVal -= iVal;
165735 }else{
165736 *pVal += iVal;
165737 }
165738 }
165739 }
165740
165741 /*
@@ -166212,14 +165761,14 @@
165761 sqlite3_int64 iVal /* Write this value to the list */
165762 ){
165763 sqlite3_uint64 iWrite;
165764 if( bDescIdx==0 || *pbFirst==0 ){
165765 assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev );
165766 iWrite = iVal - *piPrev;
165767 }else{
165768 assert_fts3_nc( *piPrev>=iVal );
165769 iWrite = *piPrev - iVal;
165770 }
165771 assert( *pbFirst || *piPrev==0 );
165772 assert_fts3_nc( *pbFirst==0 || iWrite>0 );
165773 *pp += sqlite3Fts3PutVarint(*pp, iWrite);
165774 *piPrev = iVal;
@@ -166234,12 +165783,11 @@
165783 ** Otherwise, (i2-i1).
165784 **
165785 ** Using this makes it easier to write code that can merge doclists that are
165786 ** sorted in either ascending or descending order.
165787 */
165788 #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))
 
165789
165790 /*
165791 ** This function does an "OR" merge of two doclists (output contains all
165792 ** positions contained in either argument doclist). If the docids in the
165793 ** input doclists are sorted in ascending order, parameter bDescDoclist
@@ -166649,11 +166197,11 @@
166197 ** for the pending-terms. If this is a scan, then this call must be being
166198 ** made by an fts4aux module, not an FTS table. In this case calling
166199 ** Fts3SegReaderPending might segfault, as the data structures used by
166200 ** fts4aux are not completely populated. So it's easiest to filter these
166201 ** calls out here. */
166202 if( iLevel<0 && p->aIndex ){
166203 Fts3SegReader *pSeg = 0;
166204 rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
166205 if( rc==SQLITE_OK && pSeg ){
166206 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
166207 }
@@ -166912,20 +166460,17 @@
166460 */
166461 static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){
166462 int rc;
166463 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
166464 if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){
 
 
166465 if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){
166466 pCsr->isEof = 1;
166467 rc = sqlite3_reset(pCsr->pStmt);
166468 }else{
166469 pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);
166470 rc = SQLITE_OK;
166471 }
 
166472 }else{
166473 rc = fts3EvalNext((Fts3Cursor *)pCursor);
166474 }
166475 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
166476 return rc;
@@ -166982,14 +166527,10 @@
166527 int iIdx;
166528
166529 UNUSED_PARAMETER(idxStr);
166530 UNUSED_PARAMETER(nVal);
166531
 
 
 
 
166532 eSearch = (idxNum & 0x0000FFFF);
166533 assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );
166534 assert( p->pSegments==0 );
166535
166536 /* Collect arguments into local variables */
@@ -167057,15 +166598,11 @@
166598 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
166599 p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
166600 );
166601 }
166602 if( zSql ){
166603 rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);
 
 
 
 
166604 sqlite3_free(zSql);
166605 }else{
166606 rc = SQLITE_NOMEM;
166607 }
166608 }else if( eSearch==FTS3_DOCID_SEARCH ){
@@ -168220,20 +167757,19 @@
167757 Fts3Table *pTab,
167758 Fts3Doclist *pDL,
167759 u8 *pbEof
167760 ){
167761 char *pIter; /* Used to iterate through aAll */
167762 char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */
167763
167764 if( pDL->pNextDocid ){
167765 pIter = pDL->pNextDocid;
 
167766 }else{
167767 pIter = pDL->aAll;
167768 }
167769
167770 if( pIter>=pEnd ){
167771 /* We have already reached the end of this doclist. EOF. */
167772 *pbEof = 1;
167773 }else{
167774 sqlite3_int64 iDelta;
167775 pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
@@ -174569,11 +174105,11 @@
174105 int rc = SQLITE_OK;
174106
174107 assert( !p || p->iLastDocid<=iDocid );
174108
174109 if( !p || p->iLastDocid!=iDocid ){
174110 sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);
174111 if( p ){
174112 assert( p->nData<p->nSpace );
174113 assert( p->aData[p->nData]==0 );
174114 p->nData++;
174115 }
@@ -175110,12 +174646,10 @@
174646 aByte = 0;
174647 }
174648 }
174649 *paBlob = aByte;
174650 }
 
 
174651 }
174652
174653 return rc;
174654 }
174655
@@ -175404,22 +174938,22 @@
174938 if( p>=pEnd ){
174939 pReader->pOffsetList = 0;
174940 }else{
174941 rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);
174942 if( rc==SQLITE_OK ){
174943 sqlite3_int64 iDelta;
174944 pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);
174945 if( pTab->bDescIdx ){
174946 pReader->iDocid -= iDelta;
174947 }else{
174948 pReader->iDocid += iDelta;
174949 }
174950 }
174951 }
174952 }
174953
174954 return SQLITE_OK;
174955 }
174956
174957
174958 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(
174959 Fts3Cursor *pCsr,
@@ -176154,11 +175688,10 @@
175688
175689 if( nData>0 && nData+nReq>p->nNodeSize ){
175690 int rc;
175691
175692 /* The current leaf node is full. Write it out to the database. */
 
175693 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
175694 if( rc!=SQLITE_OK ) return rc;
175695 p->nLeafAdd++;
175696
175697 /* Add the current term to the interior node tree. The term added to
@@ -176852,14 +176385,14 @@
176385 /* Calculate the 'docid' delta value to write into the merged
176386 ** doclist. */
176387 sqlite3_int64 iDelta;
176388 if( p->bDescIdx && nDoclist>0 ){
176389 if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB;
176390 iDelta = iPrev - iDocid;
176391 }else{
176392 if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB;
176393 iDelta = iDocid - iPrev;
176394 }
176395
176396 nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
176397 if( nDoclist+nByte>pCsr->nBuffer ){
176398 char *aNew;
@@ -177138,11 +176671,11 @@
176671 if( rc!=SQLITE_ROW ) break;
176672 rc = fts3SegWriterAdd(p, &pWriter, 1,
176673 csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);
176674 }
176675 if( rc!=SQLITE_OK ) goto finished;
176676 assert( pWriter || bIgnoreEmpty );
176677
176678 if( iLevel!=FTS3_SEGCURSOR_PENDING ){
176679 rc = fts3DeleteSegdir(
176680 p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment
176681 );
@@ -178724,21 +178257,17 @@
178257 */
178258 static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
178259 const int nHint = pHint->n;
178260 int i;
178261
178262 i = pHint->n-2;
 
178263 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
 
 
178264 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
178265
178266 pHint->n = i;
178267 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
178268 i += fts3GetVarint32(&pHint->a[i], pnInput);
 
178269 if( i!=nHint ) return FTS_CORRUPT_VTAB;
178270
178271 return SQLITE_OK;
178272 }
178273
@@ -179064,28 +178593,28 @@
178593 char *pCsr = csr.aDoclist;
178594 char *pEnd = &pCsr[csr.nDoclist];
178595
178596 i64 iDocid = 0;
178597 i64 iCol = 0;
178598 i64 iPos = 0;
178599
178600 pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
178601 while( pCsr<pEnd ){
178602 i64 iVal = 0;
178603 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
178604 if( pCsr<pEnd ){
178605 if( iVal==0 || iVal==1 ){
178606 iCol = 0;
178607 iPos = 0;
178608 if( iVal ){
178609 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
178610 }else{
178611 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
178612 if( p->bDescIdx ){
178613 iDocid -= iVal;
178614 }else{
178615 iDocid += iVal;
178616 }
178617 }
178618 }else{
178619 iPos += (iVal - 2);
178620 cksum = cksum ^ fts3ChecksumEntry(
@@ -183357,53 +182886,22 @@
182886 pRoot->jnFlags |= JNODE_APPEND;
182887 pParse->aNode[iLabel].jnFlags |= JNODE_RAW;
182888 }
182889 return pNode;
182890 }
182891 }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){
182892 if( pRoot->eType!=JSON_ARRAY ) return 0;
182893 i = 0;
182894 j = 1;
182895 while( safe_isdigit(zPath[j]) ){
182896 i = i*10 + zPath[j] - '0';
182897 j++;
182898 }
182899 if( zPath[j]!=']' ){
182900 *pzErr = zPath;
182901 return 0;
182902 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182903 zPath += j + 1;
182904 j = 1;
182905 for(;;){
182906 while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
182907 if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;
@@ -184867,11 +184365,10 @@
184365 /* #include "sqlite3ext.h" */
184366 SQLITE_EXTENSION_INIT1
184367 #else
184368 /* #include "sqlite3.h" */
184369 #endif
 
184370
184371 #ifndef SQLITE_AMALGAMATION
184372 #include "sqlite3rtree.h"
184373 typedef sqlite3_int64 i64;
184374 typedef sqlite3_uint64 u64;
@@ -185131,16 +184628,10 @@
184628 #define RTREE_GE 0x44 /* D */
184629 #define RTREE_GT 0x45 /* E */
184630 #define RTREE_MATCH 0x46 /* F: Old-style sqlite3_rtree_geometry_callback() */
184631 #define RTREE_QUERY 0x47 /* G: New-style sqlite3_rtree_query_callback() */
184632
 
 
 
 
 
 
184633
184634 /*
184635 ** An rtree structure node.
184636 */
184637 struct RtreeNode {
@@ -185870,16 +185361,13 @@
185361 return rc;
185362 }
185363
185364
185365 /*
185366 ** Free the RtreeCursor.aConstraint[] array and its contents.
185367 */
185368 static void freeCursorConstraints(RtreeCursor *pCsr){
 
 
 
185369 if( pCsr->aConstraint ){
185370 int i; /* Used to iterate through constraint array */
185371 for(i=0; i<pCsr->nConstraint; i++){
185372 sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;
185373 if( pInfo ){
@@ -185888,28 +185376,24 @@
185376 }
185377 }
185378 sqlite3_free(pCsr->aConstraint);
185379 pCsr->aConstraint = 0;
185380 }
 
 
 
 
 
 
 
185381 }
185382
185383 /*
185384 ** Rtree virtual table module xClose method.
185385 */
185386 static int rtreeClose(sqlite3_vtab_cursor *cur){
185387 Rtree *pRtree = (Rtree *)(cur->pVtab);
185388 int ii;
185389 RtreeCursor *pCsr = (RtreeCursor *)cur;
185390 assert( pRtree->nCursor>0 );
185391 freeCursorConstraints(pCsr);
185392 sqlite3_finalize(pCsr->pReadAux);
185393 sqlite3_free(pCsr->aPoint);
185394 for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);
185395 sqlite3_free(pCsr);
185396 pRtree->nCursor--;
185397 nodeBlobReset(pRtree);
185398 return SQLITE_OK;
185399 }
@@ -186063,16 +185547,13 @@
185547 ** in a coordinate pair. But make pCellData point to the lower bound.
185548 */
185549 pCellData += 8 + 4*(p->iCoord&0xfe);
185550
185551 assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
185552 || p->op==RTREE_GT || p->op==RTREE_EQ );
 
185553 assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
185554 switch( p->op ){
 
 
185555 case RTREE_LE:
185556 case RTREE_LT:
185557 case RTREE_EQ:
185558 RTREE_DECODE_COORD(eInt, pCellData, val);
185559 /* val now holds the lower bound of the coordinate pair */
@@ -186106,23 +185587,20 @@
185587 int *peWithin /* Adjust downward, as appropriate */
185588 ){
185589 RtreeDValue xN; /* Coordinate value converted to a double */
185590
185591 assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE
185592 || p->op==RTREE_GT || p->op==RTREE_EQ );
 
185593 pCellData += 8 + p->iCoord*4;
185594 assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */
185595 RTREE_DECODE_COORD(eInt, pCellData, xN);
185596 switch( p->op ){
185597 case RTREE_LE: if( xN <= p->u.rValue ) return; break;
185598 case RTREE_LT: if( xN < p->u.rValue ) return; break;
185599 case RTREE_GE: if( xN >= p->u.rValue ) return; break;
185600 case RTREE_GT: if( xN > p->u.rValue ) return; break;
185601 default: if( xN == p->u.rValue ) return; break;
 
 
185602 }
185603 *peWithin = NOT_WITHIN;
185604 }
185605
185606 /*
@@ -186611,32 +186089,30 @@
186089 RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
186090 RtreeNode *pRoot = 0;
186091 int ii;
186092 int rc = SQLITE_OK;
186093 int iCell = 0;
186094 sqlite3_stmt *pStmt;
186095
186096 rtreeReference(pRtree);
186097
186098 /* Reset the cursor to the same state as rtreeOpen() leaves it in. */
186099 freeCursorConstraints(pCsr);
186100 sqlite3_free(pCsr->aPoint);
186101 pStmt = pCsr->pReadAux;
186102 memset(pCsr, 0, sizeof(RtreeCursor));
186103 pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
186104 pCsr->pReadAux = pStmt;
186105
186106 pCsr->iStrategy = idxNum;
186107 if( idxNum==1 ){
186108 /* Special case - lookup by rowid. */
186109 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
186110 RtreeSearchPoint *p; /* Search point for the leaf */
186111 i64 iRowid = sqlite3_value_int64(argv[0]);
186112 i64 iNode = 0;
186113 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
 
 
 
 
 
 
 
 
186114 if( rc==SQLITE_OK && pLeaf!=0 ){
186115 p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
186116 assert( p!=0 ); /* Always returns pCsr->sPoint */
186117 pCsr->aNode[0] = pLeaf;
186118 p->id = iNode;
@@ -186662,11 +186138,10 @@
186138 memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));
186139 assert( (idxStr==0 && argc==0)
186140 || (idxStr && (int)strlen(idxStr)==argc*2) );
186141 for(ii=0; ii<argc; ii++){
186142 RtreeConstraint *p = &pCsr->aConstraint[ii];
 
186143 p->op = idxStr[ii*2];
186144 p->iCoord = idxStr[ii*2+1]-'0';
186145 if( p->op>=RTREE_MATCH ){
186146 /* A MATCH operator. The right-hand-side must be a blob that
186147 ** can be cast into an RtreeMatchArg object. One created using
@@ -186677,25 +186152,16 @@
186152 break;
186153 }
186154 p->pInfo->nCoord = pRtree->nDim2;
186155 p->pInfo->anQueue = pCsr->anQueue;
186156 p->pInfo->mxLevel = pRtree->iDepth + 1;
186157 }else{
186158 #ifdef SQLITE_RTREE_INT_ONLY
186159 p->u.rValue = sqlite3_value_int64(argv[ii]);
186160 #else
186161 p->u.rValue = sqlite3_value_double(argv[ii]);
186162 #endif
 
 
 
 
 
 
 
 
 
186163 }
186164 }
186165 }
186166 }
186167 if( rc==SQLITE_OK ){
@@ -188468,18 +187934,10 @@
187934
187935 sqlite3_free(zSql);
187936 return rc;
187937 }
187938
 
 
 
 
 
 
 
 
187939 /*
187940 ** This function is the implementation of both the xConnect and xCreate
187941 ** methods of the r-tree virtual table.
187942 **
187943 ** argv[0] -> module name
@@ -188512,12 +187970,12 @@
187970 "Too many columns for an rtree table", /* 3 */
187971 "Auxiliary rtree columns must be last" /* 4 */
187972 };
187973
187974 assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
187975 if( argc>RTREE_MAX_AUX_COLUMN+3 ){
187976 *pzErr = sqlite3_mprintf("%s", aErrMsg[3]);
187977 return SQLITE_ERROR;
187978 }
187979
187980 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
187981
@@ -188541,22 +187999,20 @@
187999 /* Create/Connect to the underlying relational database schema. If
188000 ** that is successful, call sqlite3_declare_vtab() to configure
188001 ** the r-tree table schema.
188002 */
188003 pSql = sqlite3_str_new(db);
188004 sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]);
 
188005 for(ii=4; ii<argc; ii++){
188006 if( argv[ii][0]=='+' ){
 
188007 pRtree->nAux++;
188008 sqlite3_str_appendf(pSql, ",%s", argv[ii]+1);
188009 }else if( pRtree->nAux>0 ){
188010 break;
188011 }else{
188012 pRtree->nDim2++;
188013 sqlite3_str_appendf(pSql, ",%s", argv[ii]);
188014 }
188015 }
188016 sqlite3_str_appendf(pSql, ");");
188017 zSql = sqlite3_str_finish(pSql);
188018 if( !zSql ){
@@ -190500,15 +189956,21 @@
189956 Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;
189957 RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
189958 RtreeNode *pRoot = 0;
189959 int rc = SQLITE_OK;
189960 int iCell = 0;
189961 sqlite3_stmt *pStmt;
189962
189963 rtreeReference(pRtree);
189964
189965 /* Reset the cursor to the same state as rtreeOpen() leaves it in. */
189966 freeCursorConstraints(pCsr);
189967 sqlite3_free(pCsr->aPoint);
189968 pStmt = pCsr->pReadAux;
189969 memset(pCsr, 0, sizeof(RtreeCursor));
189970 pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
189971 pCsr->pReadAux = pStmt;
189972
189973 pCsr->iStrategy = idxNum;
189974 if( idxNum==1 ){
189975 /* Special case - lookup by rowid. */
189976 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
@@ -197528,11 +196990,11 @@
196990 }
196991 z += 2;
196992 }else{
196993 while( *z==0 ) z++;
196994 }
196995 z += (n + 8 + 1);
196996 return z;
196997 }
196998
196999 /*
197000 ** Open an rbu file handle.
@@ -204819,11 +204281,11 @@
204281 ** the callback, an SQLite error code is returned.
204282 **
204283 **
204284 ** xSetAuxdata(pFts5, pAux, xDelete)
204285 **
204286 ** Save the pointer passed as the second argument as the extension functions
204287 ** "auxiliary data". The pointer may then be retrieved by the current or any
204288 ** future invocation of the same fts5 extension function made as part of
204289 ** the same MATCH query using the xGetAuxdata() API.
204290 **
204291 ** Each extension function is allocated a single auxiliary data slot for
@@ -205061,12 +204523,12 @@
204523 ** all instances of "first place" or "1st place" regardless of which form
204524 ** the user specified in the MATCH query text.
204525 **
204526 ** There are several ways to approach this in FTS5:
204527 **
204528 ** <ol><li> By mapping all synonyms to a single token. In this case, the
204529 ** In the above example, this means that the tokenizer returns the
204530 ** same token for inputs "first" and "1st". Say that token is in
204531 ** fact "first", so that when the user inserts the document "I won
204532 ** 1st place" entries are added to the index for tokens "i", "won",
204533 ** "first" and "place". If the user then queries for '1st + place',
204534 ** the tokenizer substitutes "first" for "1st" and the query works
@@ -206223,11 +205685,10 @@
205685 #define sqlite3Fts5ParserCTX_PARAM
205686 #define sqlite3Fts5ParserCTX_FETCH
205687 #define sqlite3Fts5ParserCTX_STORE
205688 #define fts5YYNSTATE 35
205689 #define fts5YYNRULE 28
 
205690 #define fts5YYNFTS5TOKEN 16
205691 #define fts5YY_MAX_SHIFT 34
205692 #define fts5YY_MIN_SHIFTREDUCE 52
205693 #define fts5YY_MAX_SHIFTREDUCE 79
205694 #define fts5YY_ERROR_ACTION 80
@@ -207053,19 +206514,16 @@
206514 fts5yymsp = fts5yypParser->fts5yytos;
206515 #ifndef NDEBUG
206516 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
206517 fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
206518 if( fts5yysize ){
206519 fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
206520 fts5yyTracePrompt,
206521 fts5yyruleno, fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);
 
 
206522 }else{
206523 fprintf(fts5yyTraceFILE, "%sReduce %d [%s].\n",
206524 fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno]);
 
206525 }
206526 }
206527 #endif /* NDEBUG */
206528
206529 /* Check that the stack is large enough to grow by a single entry
@@ -208820,11 +208278,11 @@
208278
208279 /* Set stack variable q to the close-quote character */
208280 assert( q=='[' || q=='\'' || q=='"' || q=='`' );
208281 if( q=='[' ) q = ']';
208282
208283 while( ALWAYS(z[iIn]) ){
208284 if( z[iIn]==q ){
208285 if( z[iIn+1]!=q ){
208286 /* Character iIn was the close quote. */
208287 iIn++;
208288 break;
@@ -212149,16 +211607,14 @@
211607 }
211608 azConfig[0] = 0;
211609 azConfig[1] = "main";
211610 azConfig[2] = "tbl";
211611 for(i=3; iArg<nArg; iArg++){
211612 azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]);
 
211613 }
211614
211615 zExpr = (const char*)sqlite3_value_text(apVal[0]);
 
211616
211617 rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);
211618 if( rc==SQLITE_OK ){
211619 rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);
211620 }
@@ -218404,17 +217860,14 @@
217860 int n = 0;
217861 int i;
217862 for(i=0; i<nChar; i++){
217863 if( n>=nByte ) return 0; /* Input contains fewer than nChar chars */
217864 if( (unsigned char)p[n++]>=0xc0 ){
217865 if( n>=nByte ) break;
217866 while( (p[n] & 0xc0)==0x80 ){
217867 n++;
217868 if( n>=nByte ) break;
 
 
 
217869 }
217870 }
217871 }
217872 return n;
217873 }
@@ -218812,41 +218265,10 @@
218265
218266 *pCksum = cksum;
218267 return rc;
218268 }
218269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218270
218271 /*
218272 ** This function is also purely an internal test. It does not contribute to
218273 ** FTS functionality, or even the integrity-check, in any way.
218274 */
@@ -218883,18 +218305,12 @@
218305 ** the index is disabled are the same. In both ASC and DESC order.
218306 **
218307 ** This check may only be performed if the hash table is empty. This
218308 ** is because the hash table only supports a single scan query at
218309 ** a time, and the multi-iter loop from which this function is called
218310 ** is already performing such a scan. */
218311 if( p->nPendingData==0 ){
 
 
 
 
 
 
218312 if( iIdx>0 && rc==SQLITE_OK ){
218313 int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;
218314 ck2 = 0;
218315 rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);
218316 if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;
@@ -219023,12 +218439,12 @@
218439 /* Iterate through the b-tree hierarchy. */
218440 while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
218441 i64 iRow; /* Rowid for this leaf */
218442 Fts5Data *pLeaf; /* Data for this leaf */
218443
 
218444 int nIdxTerm = sqlite3_column_bytes(pStmt, 1);
218445 const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1);
218446 int iIdxLeaf = sqlite3_column_int(pStmt, 2);
218447 int bIdxDlidx = sqlite3_column_int(pStmt, 3);
218448
218449 /* If the leaf in question has already been trimmed from the segment,
218450 ** ignore this b-tree entry. Otherwise, load it into memory. */
@@ -220611,28 +220027,19 @@
220027 case FTS5_PLAN_SORTED_MATCH: {
220028 rc = fts5SorterNext(pCsr);
220029 break;
220030 }
220031
220032 default:
 
 
220033 rc = sqlite3_step(pCsr->pStmt);
 
220034 if( rc!=SQLITE_ROW ){
220035 CsrFlagSet(pCsr, FTS5CSR_EOF);
220036 rc = sqlite3_reset(pCsr->pStmt);
 
 
 
 
 
220037 }else{
220038 rc = SQLITE_OK;
220039 }
220040 break;
 
220041 }
220042 }
220043
220044 return rc;
220045 }
@@ -220913,17 +220320,10 @@
220320 char **pzErrmsg = pConfig->pzErrmsg;
220321 int i;
220322 int iIdxStr = 0;
220323 Fts5Expr *pExpr = 0;
220324
 
 
 
 
 
 
 
220325 if( pCsr->ePlan ){
220326 fts5FreeCursorComponents(pCsr);
220327 memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));
220328 }
220329
@@ -221140,28 +220540,21 @@
220540 assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
220541 assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
220542 }
220543
220544 if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){
 
220545 assert( pCsr->pExpr );
220546 sqlite3_reset(pCsr->pStmt);
220547 sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));
 
220548 rc = sqlite3_step(pCsr->pStmt);
 
220549 if( rc==SQLITE_ROW ){
220550 rc = SQLITE_OK;
220551 CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);
220552 }else{
220553 rc = sqlite3_reset(pCsr->pStmt);
220554 if( rc==SQLITE_OK ){
220555 rc = FTS5_CORRUPT;
 
 
 
 
220556 }
220557 }
220558 }
220559 return rc;
220560 }
@@ -222173,16 +221566,14 @@
221566 if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
221567 fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
221568 }
221569 }
221570 }else if( !fts5IsContentless(pTab) ){
 
221571 rc = fts5SeekCursor(pCsr, 1);
221572 if( rc==SQLITE_OK ){
221573 sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));
221574 }
 
221575 }
221576 return rc;
221577 }
221578
221579
@@ -222455,11 +221846,11 @@
221846 int nArg, /* Number of args */
221847 sqlite3_value **apUnused /* Function arguments */
221848 ){
221849 assert( nArg==0 );
221850 UNUSED_PARAM2(nArg, apUnused);
221851 sqlite3_result_text(pCtx, "fts5: 2019-11-20 12:07:40 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8", -1, SQLITE_TRANSIENT);
221852 }
221853
221854 /*
221855 ** Return true if zName is the extension on one of the shadow tables used
221856 ** by this module.
@@ -223202,15 +222593,14 @@
222593 sqlite3Fts5BufferZero(&buf);
222594 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
222595 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
222596 ctx.szCol = 0;
222597 if( pConfig->abUnindexed[ctx.iCol]==0 ){
 
 
222598 rc = sqlite3Fts5Tokenize(pConfig,
222599 FTS5_TOKENIZE_DOCUMENT,
222600 (const char*)sqlite3_column_text(pScan, ctx.iCol+1),
222601 sqlite3_column_bytes(pScan, ctx.iCol+1),
222602 (void*)&ctx,
222603 fts5StorageInsertCallback
222604 );
222605 }
222606 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223328,15 +222718,14 @@
222718 rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);
222719 }
222720 for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){
222721 ctx.szCol = 0;
222722 if( pConfig->abUnindexed[ctx.iCol]==0 ){
 
 
222723 rc = sqlite3Fts5Tokenize(pConfig,
222724 FTS5_TOKENIZE_DOCUMENT,
222725 (const char*)sqlite3_value_text(apVal[ctx.iCol+2]),
222726 sqlite3_value_bytes(apVal[ctx.iCol+2]),
222727 (void*)&ctx,
222728 fts5StorageInsertCallback
222729 );
222730 }
222731 sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);
@@ -223501,15 +222890,14 @@
222890 ctx.szCol = 0;
222891 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
222892 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
222893 }
222894 if( rc==SQLITE_OK ){
 
 
222895 rc = sqlite3Fts5Tokenize(pConfig,
222896 FTS5_TOKENIZE_DOCUMENT,
222897 (const char*)sqlite3_column_text(pScan, i+1),
222898 sqlite3_column_bytes(pScan, i+1),
222899 (void*)&ctx,
222900 fts5StorageIntegrityCallback
222901 );
222902 }
222903 if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
@@ -227228,12 +226616,12 @@
226616 }
226617 #endif /* SQLITE_CORE */
226618 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
226619
226620 /************** End of stmt.c ************************************************/
226621 #if __LINE__!=226621
226622 #undef SQLITE_SOURCE_ID
226623 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9alt2"
226624 #endif
226625 /* Return the source-id for this library */
226626 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
226627 /************************** End of sqlite3.c ******************************/
226628
+88 -88
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.31.0"
127127
#define SQLITE_VERSION_NUMBER 3031000
128
-#define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3"
128
+#define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -539,11 +539,10 @@
539539
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
540540
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
541541
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
542542
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
543543
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
544
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
545544
546545
/*
547546
** CAPI3REF: Flags For File Open Operations
548547
**
549548
** These bit values are intended for use in the
@@ -980,20 +979,20 @@
980979
**
981980
** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
982981
** ^The [SQLITE_FCNTL_BUSYHANDLER]
983982
** file-control may be invoked by SQLite on the database file handle
984983
** shortly after it is opened in order to provide a custom VFS with access
985
-** to the connection's busy-handler callback. The argument is of type (void**)
984
+** to the connections busy-handler callback. The argument is of type (void **)
986985
** - an array of two (void *) values. The first (void *) actually points
987
-** to a function of type (int (*)(void *)). In order to invoke the connection's
986
+** to a function of type (int (*)(void *)). In order to invoke the connections
988987
** busy-handler, this function should be invoked with the second (void *) in
989988
** the array as the only argument. If it returns non-zero, then the operation
990989
** should be retried. If it returns zero, the custom VFS should abandon the
991990
** current operation.
992991
**
993992
** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
994
-** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
993
+** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
995994
** to have SQLite generate a
996995
** temporary filename using the same algorithm that is followed to generate
997996
** temporary filenames for TEMP tables and other internal uses. The
998997
** argument should be a char** which will be filled with the filename
999998
** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -1102,11 +1101,11 @@
11021101
** interface can be used to find if any database on the connection has changed,
11031102
** but that interface responds to changes on TEMP as well as MAIN and does
11041103
** not provide a mechanism to detect changes to MAIN only. Also, the
11051104
** [sqlite3_total_changes()] interface responds to internal changes only and
11061105
** omits changes made by other database connections. The
1107
-** [PRAGMA data_version] command provides a mechanism to detect changes to
1106
+** [PRAGMA data_version] command provide a mechanism to detect changes to
11081107
** a single attached database that occur due to other database connections,
11091108
** but omits changes implemented by the database connection on which it is
11101109
** called. This file control is the only mechanism to detect changes that
11111110
** happen either internally or externally and that are associated with
11121111
** a particular attached database.
@@ -1190,14 +1189,14 @@
11901189
** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
11911190
** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
11921191
** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
11931192
** may be appended to the sqlite3_vfs object and the iVersion value
11941193
** may increase again in future versions of SQLite.
1195
-** Note that due to an oversight, the structure
1196
-** of the sqlite3_vfs object changed in the transition from
1194
+** Note that the structure
1195
+** of the sqlite3_vfs object changes in the transition from
11971196
** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
1198
-** and yet the iVersion field was not increased.
1197
+** and yet the iVersion field was not modified.
11991198
**
12001199
** The szOsFile field is the size of the subclassed [sqlite3_file]
12011200
** structure used by this VFS. mxPathname is the maximum length of
12021201
** a pathname in this VFS.
12031202
**
@@ -1284,11 +1283,11 @@
12841283
** be created, and that it is an error if it already exists.
12851284
** It is <i>not</i> used to indicate the file should be opened
12861285
** for exclusive access.
12871286
**
12881287
** ^At least szOsFile bytes of memory are allocated by SQLite
1289
-** to hold the [sqlite3_file] structure passed as the third
1288
+** to hold the [sqlite3_file] structure passed as the third
12901289
** argument to xOpen. The xOpen method does not have to
12911290
** allocate the structure; it should just fill it in. Note that
12921291
** the xOpen method must set the sqlite3_file.pMethods to either
12931292
** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
12941293
** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -1407,10 +1406,11 @@
14071406
** SQLite.
14081407
*/
14091408
#define SQLITE_ACCESS_EXISTS 0
14101409
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
14111410
#define SQLITE_ACCESS_READ 2 /* Unused */
1411
+#define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
14121412
14131413
/*
14141414
** CAPI3REF: Flags for the xShmLock VFS method
14151415
**
14161416
** These integer constants define the various locking operations
@@ -1621,11 +1621,11 @@
16211621
** Every memory allocation request coming in through [sqlite3_malloc()]
16221622
** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
16231623
** that causes the corresponding memory allocation to fail.
16241624
**
16251625
** The xInit method initializes the memory allocator. For example,
1626
-** it might allocate any required mutexes or initialize internal data
1626
+** it might allocate any require mutexes or initialize internal data
16271627
** structures. The xShutdown method is invoked (indirectly) by
16281628
** [sqlite3_shutdown()] and should deallocate any resources acquired
16291629
** by xInit. The pAppData pointer is used as the only parameter to
16301630
** xInit and xShutdown.
16311631
**
@@ -1762,11 +1762,11 @@
17621762
**
17631763
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
17641764
** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
17651765
** that SQLite can use for the database page cache with the default page
17661766
** cache implementation.
1767
-** This configuration option is a no-op if an application-defined page
1767
+** This configuration option is a no-op if an application-define page
17681768
** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
17691769
** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
17701770
** 8-byte aligned memory (pMem), the size of each page cache line (sz),
17711771
** and the number of cache lines (N).
17721772
** The sz argument should be the size of the largest database page
@@ -2247,11 +2247,11 @@
22472247
** </dd>
22482248
**
22492249
** [[SQLITE_DBCONFIG_DQS_DML]]
22502250
** <dt>SQLITE_DBCONFIG_DQS_DML</td>
22512251
** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2252
-** the legacy [double-quoted string literal] misfeature for DML statements
2252
+** the legacy [double-quoted string literal] misfeature for DML statement
22532253
** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
22542254
** default value of this setting is determined by the [-DSQLITE_DQS]
22552255
** compile-time option.
22562256
** </dd>
22572257
**
@@ -2508,11 +2508,11 @@
25082508
** will be rolled back automatically.
25092509
**
25102510
** ^The sqlite3_interrupt(D) call is in effect until all currently running
25112511
** SQL statements on [database connection] D complete. ^Any new SQL statements
25122512
** that are started after the sqlite3_interrupt() call and before the
2513
-** running statement count reaches zero are interrupted as if they had been
2513
+** running statements reaches zero are interrupted as if they had been
25142514
** running prior to the sqlite3_interrupt() call. ^New SQL statements
25152515
** that are started after the running statement count reaches zero are
25162516
** not effected by the sqlite3_interrupt().
25172517
** ^A call to sqlite3_interrupt(D) that occurs when there are no running
25182518
** SQL statements is a no-op and has no effect on SQL statements
@@ -2676,13 +2676,13 @@
26762676
** Alice | 43
26772677
** Bob | 28
26782678
** Cindy | 21
26792679
** </pre></blockquote>
26802680
**
2681
-** There are two columns (M==2) and three rows (N==3). Thus the
2681
+** There are two column (M==2) and three rows (N==3). Thus the
26822682
** result table has 8 entries. Suppose the result table is stored
2683
-** in an array named azResult. Then azResult holds this content:
2683
+** in an array names azResult. Then azResult holds this content:
26842684
**
26852685
** <blockquote><pre>
26862686
** azResult&#91;0] = "Name";
26872687
** azResult&#91;1] = "Age";
26882688
** azResult&#91;2] = "Alice";
@@ -2831,10 +2831,23 @@
28312831
** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
28322832
** sqlite3_malloc64(), and sqlite3_realloc64()
28332833
** is always aligned to at least an 8 byte boundary, or to a
28342834
** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
28352835
** option is used.
2836
+**
2837
+** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2838
+** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
2839
+** implementation of these routines to be omitted. That capability
2840
+** is no longer provided. Only built-in memory allocators can be used.
2841
+**
2842
+** Prior to SQLite version 3.7.10, the Windows OS interface layer called
2843
+** the system malloc() and free() directly when converting
2844
+** filenames between the UTF-8 encoding used by SQLite
2845
+** and whatever filename encoding is used by the particular Windows
2846
+** installation. Memory allocation errors were detected, but
2847
+** they were reported back as [SQLITE_CANTOPEN] or
2848
+** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
28362849
**
28372850
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
28382851
** must be either NULL or else pointers obtained from a prior
28392852
** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
28402853
** not yet been released.
@@ -2880,11 +2893,11 @@
28802893
** CAPI3REF: Pseudo-Random Number Generator
28812894
**
28822895
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
28832896
** select random [ROWID | ROWIDs] when inserting new records into a table that
28842897
** already uses the largest possible [ROWID]. The PRNG is also used for
2885
-** the built-in random() and randomblob() SQL functions. This interface allows
2898
+** the build-in random() and randomblob() SQL functions. This interface allows
28862899
** applications to access the same PRNG for other purposes.
28872900
**
28882901
** ^A call to this routine stores N bytes of randomness into buffer P.
28892902
** ^The P parameter can be a NULL pointer.
28902903
**
@@ -3481,11 +3494,11 @@
34813494
** a VFS implementation when the flags parameter to xOpen() has one or
34823495
** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
34833496
** P is the name of the query parameter, then
34843497
** sqlite3_uri_parameter(F,P) returns the value of the P
34853498
** parameter if it exists or a NULL pointer if P does not appear as a
3486
-** query parameter on F. If P is a query parameter of F and it
3499
+** query parameter on F. If P is a query parameter of F
34873500
** has no explicit value, then sqlite3_uri_parameter(F,P) returns
34883501
** a pointer to an empty string.
34893502
**
34903503
** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
34913504
** parameter and returns true (1) or false (0) according to the value
@@ -3493,11 +3506,11 @@
34933506
** value of query parameter P is one of "yes", "true", or "on" in any
34943507
** case or if the value begins with a non-zero number. The
34953508
** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
34963509
** query parameter P is one of "no", "false", or "off" in any case or
34973510
** if the value begins with a numeric zero. If P is not a query
3498
-** parameter on F or if the value of P does not match any of the
3511
+** parameter on F or if the value of P is does not match any of the
34993512
** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
35003513
**
35013514
** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
35023515
** 64-bit signed integer and returns that integer, or D if P does not
35033516
** exist. If the value of P is something other than an integer, then
@@ -3830,16 +3843,16 @@
38303843
** in order to find the underlying cause of the problem. With the "v2" prepare
38313844
** interfaces, the underlying reason for the error is returned immediately.
38323845
** </li>
38333846
**
38343847
** <li>
3835
-** ^If the specific value bound to a [parameter | host parameter] in the
3848
+** ^If the specific value bound to [parameter | host parameter] in the
38363849
** WHERE clause might influence the choice of query plan for a statement,
38373850
** then the statement will be automatically recompiled, as if there had been
3838
-** a schema change, on the first [sqlite3_step()] call following any change
3851
+** a schema change, on the first [sqlite3_step()] call following any change
38393852
** to the [sqlite3_bind_text | bindings] of that [parameter].
3840
-** ^The specific value of a WHERE-clause [parameter] might influence the
3853
+** ^The specific value of WHERE-clause [parameter] might influence the
38413854
** choice of query plan if the parameter is the left-hand side of a [LIKE]
38423855
** or [GLOB] operator or if the parameter is compared to an indexed column
38433856
** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
38443857
** </li>
38453858
** </ol>
@@ -4344,19 +4357,23 @@
43444357
** the statement, where N is the second function argument.
43454358
** ^The left-most column is column 0 for these routines.
43464359
**
43474360
** ^If the Nth column returned by the statement is an expression or
43484361
** subquery and is not a column value, then all of these functions return
4349
-** NULL. ^These routines might also return NULL if a memory allocation error
4362
+** NULL. ^These routine might also return NULL if a memory allocation error
43504363
** occurs. ^Otherwise, they return the name of the attached database, table,
43514364
** or column that query result column was extracted from.
43524365
**
43534366
** ^As with all other SQLite APIs, those whose names end with "16" return
43544367
** UTF-16 encoded strings and the other functions return UTF-8.
43554368
**
43564369
** ^These APIs are only available if the library was compiled with the
43574370
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
4371
+**
4372
+** If two or more threads call one or more of these routines against the same
4373
+** prepared statement and column at the same time then the results are
4374
+** undefined.
43584375
**
43594376
** If two or more threads call one or more
43604377
** [sqlite3_column_database_name | column metadata interfaces]
43614378
** for the same [prepared statement] and result column
43624379
** at the same time then the results are undefined.
@@ -4490,11 +4507,11 @@
44904507
** METHOD: sqlite3_stmt
44914508
**
44924509
** ^The sqlite3_data_count(P) interface returns the number of columns in the
44934510
** current row of the result set of [prepared statement] P.
44944511
** ^If prepared statement P does not have results ready to return
4495
-** (via calls to the [sqlite3_column_int | sqlite3_column()] family of
4512
+** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
44964513
** interfaces) then sqlite3_data_count(P) returns 0.
44974514
** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
44984515
** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
44994516
** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
45004517
** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -4992,16 +5009,13 @@
49925009
** These constants may be ORed together with the
49935010
** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
49945011
** to [sqlite3_create_function()], [sqlite3_create_function16()], or
49955012
** [sqlite3_create_function_v2()].
49965013
**
4997
-** The SQLITE_DETERMINISTIC flag means that the new function always gives
4998
-** the same output when the input parameters are the same. The abs() function
4999
-** is deterministic, for example, but randomblob() is not. Functions must
5000
-** be deterministic in order to be used in certain contexts such as
5001
-** [CHECK constraints] or [generated columns]. SQLite might also optimize
5002
-** deterministic functions by factoring them out of inner loops.
5014
+** The SQLITE_DETERMINISTIC flag means that the new function will always
5015
+** maps the same inputs into the same output. The abs() function is
5016
+** deterministic, for example, but randomblob() is not.
50035017
**
50045018
** The SQLITE_DIRECTONLY flag means that the function may only be invoked
50055019
** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
50065020
** a security feature which is recommended for all
50075021
** [application-defined SQL functions] that have side-effects. This flag
@@ -5076,12 +5090,12 @@
50765090
**
50775091
** <b>Details:</b>
50785092
**
50795093
** These routines extract type, size, and content information from
50805094
** [protected sqlite3_value] objects. Protected sqlite3_value objects
5081
-** are used to pass parameter information into the functions that
5082
-** implement [application-defined SQL functions] and [virtual tables].
5095
+** are used to pass parameter information into implementation of
5096
+** [application-defined SQL functions] and [virtual tables].
50835097
**
50845098
** These routines work only with [protected sqlite3_value] objects.
50855099
** Any attempt to use these routines on an [unprotected sqlite3_value]
50865100
** is not threadsafe.
50875101
**
@@ -5134,11 +5148,11 @@
51345148
** the return value is arbitrary and meaningless.
51355149
**
51365150
** ^The sqlite3_value_frombind(X) interface returns non-zero if the
51375151
** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
51385152
** interfaces. ^If X comes from an SQL literal value, or a table column,
5139
-** or an expression, then sqlite3_value_frombind(X) returns zero.
5153
+** and expression, then sqlite3_value_frombind(X) returns zero.
51405154
**
51415155
** Please pay particular attention to the fact that the pointer returned
51425156
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
51435157
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
51445158
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5220,12 +5234,12 @@
52205234
**
52215235
** Implementations of aggregate SQL functions use this
52225236
** routine to allocate memory for storing their state.
52235237
**
52245238
** ^The first time the sqlite3_aggregate_context(C,N) routine is called
5225
-** for a particular aggregate function, SQLite allocates
5226
-** N bytes of memory, zeroes out that memory, and returns a pointer
5239
+** for a particular aggregate function, SQLite
5240
+** allocates N of memory, zeroes out that memory, and returns a pointer
52275241
** to the new memory. ^On second and subsequent calls to
52285242
** sqlite3_aggregate_context() for the same aggregate function instance,
52295243
** the same buffer is returned. Sqlite3_aggregate_context() is normally
52305244
** called once for each invocation of the xStep callback and then one
52315245
** last time when the xFinal callback is invoked. ^(When no rows match
@@ -5238,11 +5252,11 @@
52385252
** when first called if N is less than or equal to zero or if a memory
52395253
** allocate error occurs.
52405254
**
52415255
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
52425256
** determined by the N parameter on first successful call. Changing the
5243
-** value of N in any subsequents call to sqlite3_aggregate_context() within
5257
+** value of N in subsequent call to sqlite3_aggregate_context() within
52445258
** the same aggregate function instance will not resize the memory
52455259
** allocation.)^ Within the xFinal callback, it is customary to set
52465260
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
52475261
** pointless memory allocations occur.
52485262
**
@@ -5586,11 +5600,11 @@
55865600
** <li> If A&lt;B THEN B&gt;A.
55875601
** <li> If A&lt;B and B&lt;C then A&lt;C.
55885602
** </ol>
55895603
**
55905604
** If a collating function fails any of the above constraints and that
5591
-** collating function is registered and used, then the behavior of SQLite
5605
+** collating function is registered and used, then the behavior of SQLite
55925606
** is undefined.
55935607
**
55945608
** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
55955609
** with the addition that the xDestroy callback is invoked on pArg when
55965610
** the collating function is deleted.
@@ -5913,20 +5927,16 @@
59135927
59145928
/*
59155929
** CAPI3REF: Return The Filename For A Database Connection
59165930
** METHOD: sqlite3
59175931
**
5918
-** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename
5919
-** associated with database N of connection D.
5920
-** ^If there is no attached database N on the database
5932
+** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
5933
+** associated with database N of connection D. ^The main database file
5934
+** has the name "main". If there is no attached database N on the database
59215935
** connection D, or if database N is a temporary or in-memory database, then
59225936
** this function will return either a NULL pointer or an empty string.
59235937
**
5924
-** ^The string value returned by this routine is owned and managed by
5925
-** the database connection. ^The value will be valid until the database N
5926
-** is [DETACH]-ed or until the database connection closes.
5927
-**
59285938
** ^The filename returned by this function is the output of the
59295939
** xFullPathname method of the [VFS]. ^In other words, the filename
59305940
** will be an absolute pathname, even if the filename used
59315941
** to open the database originally was a URI or relative pathname.
59325942
*/
@@ -6076,23 +6086,19 @@
60766086
** In prior versions of SQLite,
60776087
** sharing was enabled or disabled for each thread separately.
60786088
**
60796089
** ^(The cache sharing mode set by this interface effects all subsequent
60806090
** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
6081
-** Existing database connections continue to use the sharing mode
6091
+** Existing database connections continue use the sharing mode
60826092
** that was in effect at the time they were opened.)^
60836093
**
60846094
** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
60856095
** successfully. An [error code] is returned otherwise.)^
60866096
**
6087
-** ^Shared cache is disabled by default. It is recommended that it stay
6088
-** that way. In other words, do not use this routine. This interface
6089
-** continues to be provided for historical compatibility, but its use is
6090
-** discouraged. Any use of shared cache is discouraged. If shared cache
6091
-** must be used, it is recommended that shared cache only be enabled for
6092
-** individual database connections using the [sqlite3_open_v2()] interface
6093
-** with the [SQLITE_OPEN_SHAREDCACHE] flag.
6097
+** ^Shared cache is disabled by default. But this might change in
6098
+** future releases of SQLite. Applications that care about shared
6099
+** cache setting should set it explicitly.
60946100
**
60956101
** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
60966102
** and will always return SQLITE_MISUSE. On those systems,
60976103
** shared cache mode should be enabled per-database connection via
60986104
** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -6221,11 +6227,11 @@
62216227
** information about column C of table T in database D
62226228
** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
62236229
** interface returns SQLITE_OK and fills in the non-NULL pointers in
62246230
** the final five arguments with appropriate values if the specified
62256231
** column exists. ^The sqlite3_table_column_metadata() interface returns
6226
-** SQLITE_ERROR if the specified column does not exist.
6232
+** SQLITE_ERROR and if the specified column does not exist.
62276233
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
62286234
** NULL pointer, then this routine simply checks for the existence of the
62296235
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
62306236
** does not. If the table name parameter T in a call to
62316237
** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -6363,11 +6369,11 @@
63636369
** [sqlite3_load_extension()] and the SQL function [load_extension()].
63646370
** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
63656371
** to enable or disable only the C-API.)^
63666372
**
63676373
** <b>Security warning:</b> It is recommended that extension loading
6368
-** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
6374
+** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
63696375
** rather than this interface, so the [load_extension()] SQL function
63706376
** remains disabled. This will prevent SQL injections from giving attackers
63716377
** access to extension loading capabilities.
63726378
*/
63736379
SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -6450,11 +6456,11 @@
64506456
/*
64516457
** CAPI3REF: Virtual Table Object
64526458
** KEYWORDS: sqlite3_module {virtual table module}
64536459
**
64546460
** This structure, sometimes called a "virtual table module",
6455
-** defines the implementation of a [virtual table].
6461
+** defines the implementation of a [virtual tables].
64566462
** This structure consists mostly of methods for the module.
64576463
**
64586464
** ^A virtual table module is created by filling in a persistent
64596465
** instance of this structure and passing a pointer to that instance
64606466
** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -6547,17 +6553,11 @@
65476553
** The [xBestIndex] method must fill aConstraintUsage[] with information
65486554
** about what parameters to pass to xFilter. ^If argvIndex>0 then
65496555
** the right-hand side of the corresponding aConstraint[] is evaluated
65506556
** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
65516557
** is true, then the constraint is assumed to be fully handled by the
6552
-** virtual table and might not be checked again by the byte code.)^ ^(The
6553
-** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
6554
-** is left in its default setting of false, the constraint will always be
6555
-** checked separately in byte code. If the omit flag is change to true, then
6556
-** the constraint may or may not be checked in byte code. In other words,
6557
-** when the omit flag is true there is no guarantee that the constraint will
6558
-** not be checked again using byte code.)^
6558
+** virtual table and is not checked again by SQLite.)^
65596559
**
65606560
** ^The idxNum and idxPtr values are recorded and passed into the
65616561
** [xFilter] method.
65626562
** ^[sqlite3_free()] is used to free idxPtr if and only if
65636563
** needToFreeIdxPtr is true.
@@ -6593,11 +6593,11 @@
65936593
** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
65946594
** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
65956595
** If a virtual table extension is
65966596
** used with an SQLite version earlier than 3.8.2, the results of attempting
65976597
** to read or write the estimatedRows field are undefined (but are likely
6598
-** to include crashing the application). The estimatedRows field should
6598
+** to included crashing the application). The estimatedRows field should
65996599
** therefore only be used if [sqlite3_libversion_number()] returns a
66006600
** value greater than or equal to 3008002. Similarly, the idxFlags field
66016601
** was added for [version 3.9.0] ([dateof:3.9.0]).
66026602
** It may therefore only be used if
66036603
** sqlite3_libversion_number() returns a value greater than or equal to
@@ -6645,11 +6645,11 @@
66456645
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
66466646
66476647
/*
66486648
** CAPI3REF: Virtual Table Constraint Operator Codes
66496649
**
6650
-** These macros define the allowed values for the
6650
+** These macros defined the allowed values for the
66516651
** [sqlite3_index_info].aConstraint[].op field. Each value represents
66526652
** an operator that is part of a constraint term in the wHERE clause of
66536653
** a query that uses a [virtual table].
66546654
*/
66556655
#define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -7255,11 +7255,11 @@
72557255
** </ul>)^
72567256
**
72577257
** The only difference is that the public sqlite3_XXX functions enumerated
72587258
** above silently ignore any invocations that pass a NULL pointer instead
72597259
** of a valid mutex handle. The implementations of the methods defined
7260
-** by this structure are not required to handle this case. The results
7260
+** by this structure are not required to handle this case, the results
72617261
** of passing a NULL pointer instead of a valid mutex handle are undefined
72627262
** (i.e. it is acceptable to provide an implementation that segfaults if
72637263
** it is passed a NULL pointer).
72647264
**
72657265
** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -7728,11 +7728,11 @@
77287728
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
77297729
** no space was left in the page cache.</dd>)^
77307730
**
77317731
** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
77327732
** <dd>This parameter records the largest memory allocation request
7733
-** handed to the [pagecache memory allocator]. Only the value returned in the
7733
+** handed to [pagecache memory allocator]. Only the value returned in the
77347734
** *pHighwater parameter to [sqlite3_status()] is of interest.
77357735
** The value written into the *pCurrent parameter is undefined.</dd>)^
77367736
**
77377737
** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
77387738
** <dd>No longer used.</dd>
@@ -7804,11 +7804,11 @@
78047804
** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
78057805
** <dd>This parameter returns the number of lookaside memory slots currently
78067806
** checked out.</dd>)^
78077807
**
78087808
** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
7809
-** <dd>This parameter returns the number of malloc attempts that were
7809
+** <dd>This parameter returns the number malloc attempts that were
78107810
** satisfied using lookaside memory. Only the high-water value is meaningful;
78117811
** the current value is always zero.)^
78127812
**
78137813
** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
78147814
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -7886,11 +7886,11 @@
78867886
** <dd>This parameter returns the number of dirty cache entries that have
78877887
** been written to disk in the middle of a transaction due to the page
78887888
** cache overflowing. Transactions are more efficient if they are written
78897889
** to disk all at once. When pages spill mid-transaction, that introduces
78907890
** additional overhead. This parameter can be used help identify
7891
-** inefficiencies that can be resolved by increasing the cache size.
7891
+** inefficiencies that can be resolve by increasing the cache size.
78927892
** </dd>
78937893
**
78947894
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
78957895
** <dd>This parameter returns zero for the current value if and only if
78967896
** all foreign key constraints (deferred or immediate) have been
@@ -7975,11 +7975,11 @@
79757975
** If the number of virtual machine operations exceeds 2147483647
79767976
** then the value returned by this statement status code is undefined.
79777977
**
79787978
** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
79797979
** <dd>^This is the number of times that the prepare statement has been
7980
-** automatically regenerated due to schema changes or changes to
7980
+** automatically regenerated due to schema changes or change to
79817981
** [bound parameters] that might affect the query plan.
79827982
**
79837983
** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
79847984
** <dd>^This is the number of times that the prepared statement has
79857985
** been run. A single "run" for the purposes of this counter is one
@@ -8146,11 +8146,11 @@
81468146
** NULL if allocating a new page is effectively impossible.
81478147
** </table>
81488148
**
81498149
** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
81508150
** will only use a createFlag of 2 after a prior call with a createFlag of 1
8151
-** failed.)^ In between the xFetch() calls, SQLite may
8151
+** failed.)^ In between the to xFetch() calls, SQLite may
81528152
** attempt to unpin one or more cache pages by spilling the content of
81538153
** pinned pages to disk and synching the operating system disk cache.
81548154
**
81558155
** [[the xUnpin() page cache method]]
81568156
** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -8464,11 +8464,11 @@
84648464
** application receives an SQLITE_LOCKED error, it may call the
84658465
** sqlite3_unlock_notify() method with the blocked connection handle as
84668466
** the first argument to register for a callback that will be invoked
84678467
** when the blocking connections current transaction is concluded. ^The
84688468
** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
8469
-** call that concludes the blocking connection's transaction.
8469
+** call that concludes the blocking connections transaction.
84708470
**
84718471
** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
84728472
** there is a chance that the blocking connection will have already
84738473
** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
84748474
** If this happens, then the specified callback is invoked immediately,
@@ -8502,11 +8502,11 @@
85028502
** However, the signature of the callback function allows SQLite to pass
85038503
** it an array of void* context pointers. The first argument passed to
85048504
** an unlock-notify callback is a pointer to an array of void* pointers,
85058505
** and the second is the number of entries in the array.
85068506
**
8507
-** When a blocking connection's transaction is concluded, there may be
8507
+** When a blocking connections transaction is concluded, there may be
85088508
** more than one blocked connection that has registered for an unlock-notify
85098509
** callback. ^If two or more such blocked connections have specified the
85108510
** same callback function, then instead of invoking the callback function
85118511
** multiple times, it is invoked once with the set of void* context pointers
85128512
** specified by the blocked connections bundled together into an array.
@@ -8976,37 +8976,37 @@
89768976
** managed by the prepared statement S and will be automatically freed when
89778977
** S is finalized.
89788978
**
89798979
** <dl>
89808980
** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
8981
-** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be
8981
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
89828982
** set to the total number of times that the X-th loop has run.</dd>
89838983
**
89848984
** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
8985
-** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set
8985
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
89868986
** to the total number of rows examined by all iterations of the X-th loop.</dd>
89878987
**
89888988
** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
8989
-** <dd>^The "double" variable pointed to by the V parameter will be set to the
8989
+** <dd>^The "double" variable pointed to by the T parameter will be set to the
89908990
** query planner's estimate for the average number of rows output from each
89918991
** iteration of the X-th loop. If the query planner's estimates was accurate,
89928992
** then this value will approximate the quotient NVISIT/NLOOP and the
89938993
** product of this value for all prior loops with the same SELECTID will
89948994
** be the NLOOP value for the current loop.
89958995
**
89968996
** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
8997
-** <dd>^The "const char *" variable pointed to by the V parameter will be set
8997
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
89988998
** to a zero-terminated UTF-8 string containing the name of the index or table
89998999
** used for the X-th loop.
90009000
**
90019001
** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
9002
-** <dd>^The "const char *" variable pointed to by the V parameter will be set
9002
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
90039003
** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
90049004
** description for the X-th loop.
90059005
**
90069006
** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
9007
-** <dd>^The "int" variable pointed to by the V parameter will be set to the
9007
+** <dd>^The "int" variable pointed to by the T parameter will be set to the
90089008
** "select-id" for the X-th loop. The select-id identifies which query or
90099009
** subquery the loop is part of. The main query has a select-id of zero.
90109010
** The select-id is the same value as is output in the first column
90119011
** of an [EXPLAIN QUERY PLAN] query.
90129012
** </dl>
@@ -9857,11 +9857,11 @@
98579857
** METHOD: sqlite3_session
98589858
**
98599859
** The second argument (xFilter) is the "filter callback". For changes to rows
98609860
** in tables that are not attached to the Session object, the filter is called
98619861
** to determine whether changes to the table's rows should be tracked or not.
9862
-** If xFilter returns 0, changes are not tracked. Note that once a table is
9862
+** If xFilter returns 0, changes is not tracked. Note that once a table is
98639863
** attached, xFilter will not be called again.
98649864
*/
98659865
SQLITE_API void sqlite3session_table_filter(
98669866
sqlite3_session *pSession, /* Session object */
98679867
int(*xFilter)(
@@ -10031,11 +10031,11 @@
1003110031
** identical.
1003210032
**
1003310033
** It an error if database zFrom does not exist or does not contain the
1003410034
** required compatible table.
1003510035
**
10036
-** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
10036
+** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
1003710037
** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
1003810038
** may be set to point to a buffer containing an English language error
1003910039
** message. It is the responsibility of the caller to free this buffer using
1004010040
** sqlite3_free().
1004110041
*/
@@ -10168,11 +10168,11 @@
1016810168
1016910169
/*
1017010170
** CAPI3REF: Advance A Changeset Iterator
1017110171
** METHOD: sqlite3_changeset_iter
1017210172
**
10173
-** This function may only be used with iterators created by the function
10173
+** This function may only be used with iterators created by function
1017410174
** [sqlite3changeset_start()]. If it is called on an iterator passed to
1017510175
** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
1017610176
** is returned and the call has no effect.
1017710177
**
1017810178
** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -10584,12 +10584,12 @@
1058410584
** in the changegroup, then the number of columns and the position of the
1058510585
** primary key columns for the table must be consistent. If this is not the
1058610586
** case, this function fails with SQLITE_SCHEMA. If the input changeset
1058710587
** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
1058810588
** returned. Or, if an out-of-memory condition occurs during processing, this
10589
-** function returns SQLITE_NOMEM. In all cases, if an error occurs the state
10590
-** of the final contents of the changegroup is undefined.
10589
+** function returns SQLITE_NOMEM. In all cases, if an error occurs the
10590
+** final contents of the changegroup is undefined.
1059110591
**
1059210592
** If no error occurs, SQLITE_OK is returned.
1059310593
*/
1059410594
SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
1059510595
@@ -10760,11 +10760,11 @@
1076010760
** [SQLITE_CHANGESET_REPLACE].
1076110761
** </dl>
1076210762
**
1076310763
** It is safe to execute SQL statements, including those that write to the
1076410764
** table that the callback related to, from within the xConflict callback.
10765
-** This can be used to further customize the application's conflict
10765
+** This can be used to further customize the applications conflict
1076610766
** resolution strategy.
1076710767
**
1076810768
** All changes made by these functions are enclosed in a savepoint transaction.
1076910769
** If any other error (aside from a constraint failure when attempting to
1077010770
** write to the target database) occurs, then the savepoint transaction is
@@ -11070,11 +11070,11 @@
1107011070
** CAPI3REF: Rebase a changeset
1107111071
** EXPERIMENTAL
1107211072
**
1107311073
** Argument pIn must point to a buffer containing a changeset nIn bytes
1107411074
** in size. This function allocates and populates a buffer with a copy
11075
-** of the changeset rebased according to the configuration of the
11075
+** of the changeset rebased rebased according to the configuration of the
1107611076
** rebaser object passed as the first argument. If successful, (*ppOut)
1107711077
** is set to point to the new buffer containing the rebased changeset and
1107811078
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
1107911079
** responsibility of the caller to eventually free the new buffer using
1108011080
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -11478,11 +11478,11 @@
1147811478
** the callback, an SQLite error code is returned.
1147911479
**
1148011480
**
1148111481
** xSetAuxdata(pFts5, pAux, xDelete)
1148211482
**
11483
-** Save the pointer passed as the second argument as the extension function's
11483
+** Save the pointer passed as the second argument as the extension functions
1148411484
** "auxiliary data". The pointer may then be retrieved by the current or any
1148511485
** future invocation of the same fts5 extension function made as part of
1148611486
** the same MATCH query using the xGetAuxdata() API.
1148711487
**
1148811488
** Each extension function is allocated a single auxiliary data slot for
@@ -11720,12 +11720,12 @@
1172011720
** all instances of "first place" or "1st place" regardless of which form
1172111721
** the user specified in the MATCH query text.
1172211722
**
1172311723
** There are several ways to approach this in FTS5:
1172411724
**
11725
-** <ol><li> By mapping all synonyms to a single token. In this case, using
11726
-** the above example, this means that the tokenizer returns the
11725
+** <ol><li> By mapping all synonyms to a single token. In this case, the
11726
+** In the above example, this means that the tokenizer returns the
1172711727
** same token for inputs "first" and "1st". Say that token is in
1172811728
** fact "first", so that when the user inserts the document "I won
1172911729
** 1st place" entries are added to the index for tokens "i", "won",
1173011730
** "first" and "place". If the user then queries for '1st + place',
1173111731
** the tokenizer substitutes "first" for "1st" and the query works
1173211732
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.31.0"
127 #define SQLITE_VERSION_NUMBER 3031000
128 #define SQLITE_SOURCE_ID "2019-12-26 01:10:17 f482a4cdfa768941e22c399de8ec29a55e729529eeae86d3832077ad1bef22f3"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -539,11 +539,10 @@
539 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
540 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
541 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
542 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
543 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
544 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
545
546 /*
547 ** CAPI3REF: Flags For File Open Operations
548 **
549 ** These bit values are intended for use in the
@@ -980,20 +979,20 @@
980 **
981 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
982 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
983 ** file-control may be invoked by SQLite on the database file handle
984 ** shortly after it is opened in order to provide a custom VFS with access
985 ** to the connection's busy-handler callback. The argument is of type (void**)
986 ** - an array of two (void *) values. The first (void *) actually points
987 ** to a function of type (int (*)(void *)). In order to invoke the connection's
988 ** busy-handler, this function should be invoked with the second (void *) in
989 ** the array as the only argument. If it returns non-zero, then the operation
990 ** should be retried. If it returns zero, the custom VFS should abandon the
991 ** current operation.
992 **
993 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
994 ** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
995 ** to have SQLite generate a
996 ** temporary filename using the same algorithm that is followed to generate
997 ** temporary filenames for TEMP tables and other internal uses. The
998 ** argument should be a char** which will be filled with the filename
999 ** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -1102,11 +1101,11 @@
1102 ** interface can be used to find if any database on the connection has changed,
1103 ** but that interface responds to changes on TEMP as well as MAIN and does
1104 ** not provide a mechanism to detect changes to MAIN only. Also, the
1105 ** [sqlite3_total_changes()] interface responds to internal changes only and
1106 ** omits changes made by other database connections. The
1107 ** [PRAGMA data_version] command provides a mechanism to detect changes to
1108 ** a single attached database that occur due to other database connections,
1109 ** but omits changes implemented by the database connection on which it is
1110 ** called. This file control is the only mechanism to detect changes that
1111 ** happen either internally or externally and that are associated with
1112 ** a particular attached database.
@@ -1190,14 +1189,14 @@
1190 ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
1191 ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
1192 ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
1193 ** may be appended to the sqlite3_vfs object and the iVersion value
1194 ** may increase again in future versions of SQLite.
1195 ** Note that due to an oversight, the structure
1196 ** of the sqlite3_vfs object changed in the transition from
1197 ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
1198 ** and yet the iVersion field was not increased.
1199 **
1200 ** The szOsFile field is the size of the subclassed [sqlite3_file]
1201 ** structure used by this VFS. mxPathname is the maximum length of
1202 ** a pathname in this VFS.
1203 **
@@ -1284,11 +1283,11 @@
1284 ** be created, and that it is an error if it already exists.
1285 ** It is <i>not</i> used to indicate the file should be opened
1286 ** for exclusive access.
1287 **
1288 ** ^At least szOsFile bytes of memory are allocated by SQLite
1289 ** to hold the [sqlite3_file] structure passed as the third
1290 ** argument to xOpen. The xOpen method does not have to
1291 ** allocate the structure; it should just fill it in. Note that
1292 ** the xOpen method must set the sqlite3_file.pMethods to either
1293 ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
1294 ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -1407,10 +1406,11 @@
1407 ** SQLite.
1408 */
1409 #define SQLITE_ACCESS_EXISTS 0
1410 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
1411 #define SQLITE_ACCESS_READ 2 /* Unused */
 
1412
1413 /*
1414 ** CAPI3REF: Flags for the xShmLock VFS method
1415 **
1416 ** These integer constants define the various locking operations
@@ -1621,11 +1621,11 @@
1621 ** Every memory allocation request coming in through [sqlite3_malloc()]
1622 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
1623 ** that causes the corresponding memory allocation to fail.
1624 **
1625 ** The xInit method initializes the memory allocator. For example,
1626 ** it might allocate any required mutexes or initialize internal data
1627 ** structures. The xShutdown method is invoked (indirectly) by
1628 ** [sqlite3_shutdown()] and should deallocate any resources acquired
1629 ** by xInit. The pAppData pointer is used as the only parameter to
1630 ** xInit and xShutdown.
1631 **
@@ -1762,11 +1762,11 @@
1762 **
1763 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1764 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
1765 ** that SQLite can use for the database page cache with the default page
1766 ** cache implementation.
1767 ** This configuration option is a no-op if an application-defined page
1768 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
1769 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
1770 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
1771 ** and the number of cache lines (N).
1772 ** The sz argument should be the size of the largest database page
@@ -2247,11 +2247,11 @@
2247 ** </dd>
2248 **
2249 ** [[SQLITE_DBCONFIG_DQS_DML]]
2250 ** <dt>SQLITE_DBCONFIG_DQS_DML</td>
2251 ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2252 ** the legacy [double-quoted string literal] misfeature for DML statements
2253 ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
2254 ** default value of this setting is determined by the [-DSQLITE_DQS]
2255 ** compile-time option.
2256 ** </dd>
2257 **
@@ -2508,11 +2508,11 @@
2508 ** will be rolled back automatically.
2509 **
2510 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
2511 ** SQL statements on [database connection] D complete. ^Any new SQL statements
2512 ** that are started after the sqlite3_interrupt() call and before the
2513 ** running statement count reaches zero are interrupted as if they had been
2514 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
2515 ** that are started after the running statement count reaches zero are
2516 ** not effected by the sqlite3_interrupt().
2517 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
2518 ** SQL statements is a no-op and has no effect on SQL statements
@@ -2676,13 +2676,13 @@
2676 ** Alice | 43
2677 ** Bob | 28
2678 ** Cindy | 21
2679 ** </pre></blockquote>
2680 **
2681 ** There are two columns (M==2) and three rows (N==3). Thus the
2682 ** result table has 8 entries. Suppose the result table is stored
2683 ** in an array named azResult. Then azResult holds this content:
2684 **
2685 ** <blockquote><pre>
2686 ** azResult&#91;0] = "Name";
2687 ** azResult&#91;1] = "Age";
2688 ** azResult&#91;2] = "Alice";
@@ -2831,10 +2831,23 @@
2831 ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
2832 ** sqlite3_malloc64(), and sqlite3_realloc64()
2833 ** is always aligned to at least an 8 byte boundary, or to a
2834 ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
2835 ** option is used.
 
 
 
 
 
 
 
 
 
 
 
 
 
2836 **
2837 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
2838 ** must be either NULL or else pointers obtained from a prior
2839 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
2840 ** not yet been released.
@@ -2880,11 +2893,11 @@
2880 ** CAPI3REF: Pseudo-Random Number Generator
2881 **
2882 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
2883 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2884 ** already uses the largest possible [ROWID]. The PRNG is also used for
2885 ** the built-in random() and randomblob() SQL functions. This interface allows
2886 ** applications to access the same PRNG for other purposes.
2887 **
2888 ** ^A call to this routine stores N bytes of randomness into buffer P.
2889 ** ^The P parameter can be a NULL pointer.
2890 **
@@ -3481,11 +3494,11 @@
3481 ** a VFS implementation when the flags parameter to xOpen() has one or
3482 ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
3483 ** P is the name of the query parameter, then
3484 ** sqlite3_uri_parameter(F,P) returns the value of the P
3485 ** parameter if it exists or a NULL pointer if P does not appear as a
3486 ** query parameter on F. If P is a query parameter of F and it
3487 ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
3488 ** a pointer to an empty string.
3489 **
3490 ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
3491 ** parameter and returns true (1) or false (0) according to the value
@@ -3493,11 +3506,11 @@
3493 ** value of query parameter P is one of "yes", "true", or "on" in any
3494 ** case or if the value begins with a non-zero number. The
3495 ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
3496 ** query parameter P is one of "no", "false", or "off" in any case or
3497 ** if the value begins with a numeric zero. If P is not a query
3498 ** parameter on F or if the value of P does not match any of the
3499 ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
3500 **
3501 ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
3502 ** 64-bit signed integer and returns that integer, or D if P does not
3503 ** exist. If the value of P is something other than an integer, then
@@ -3830,16 +3843,16 @@
3830 ** in order to find the underlying cause of the problem. With the "v2" prepare
3831 ** interfaces, the underlying reason for the error is returned immediately.
3832 ** </li>
3833 **
3834 ** <li>
3835 ** ^If the specific value bound to a [parameter | host parameter] in the
3836 ** WHERE clause might influence the choice of query plan for a statement,
3837 ** then the statement will be automatically recompiled, as if there had been
3838 ** a schema change, on the first [sqlite3_step()] call following any change
3839 ** to the [sqlite3_bind_text | bindings] of that [parameter].
3840 ** ^The specific value of a WHERE-clause [parameter] might influence the
3841 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3842 ** or [GLOB] operator or if the parameter is compared to an indexed column
3843 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
3844 ** </li>
3845 ** </ol>
@@ -4344,19 +4357,23 @@
4344 ** the statement, where N is the second function argument.
4345 ** ^The left-most column is column 0 for these routines.
4346 **
4347 ** ^If the Nth column returned by the statement is an expression or
4348 ** subquery and is not a column value, then all of these functions return
4349 ** NULL. ^These routines might also return NULL if a memory allocation error
4350 ** occurs. ^Otherwise, they return the name of the attached database, table,
4351 ** or column that query result column was extracted from.
4352 **
4353 ** ^As with all other SQLite APIs, those whose names end with "16" return
4354 ** UTF-16 encoded strings and the other functions return UTF-8.
4355 **
4356 ** ^These APIs are only available if the library was compiled with the
4357 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
 
 
 
 
4358 **
4359 ** If two or more threads call one or more
4360 ** [sqlite3_column_database_name | column metadata interfaces]
4361 ** for the same [prepared statement] and result column
4362 ** at the same time then the results are undefined.
@@ -4490,11 +4507,11 @@
4490 ** METHOD: sqlite3_stmt
4491 **
4492 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
4493 ** current row of the result set of [prepared statement] P.
4494 ** ^If prepared statement P does not have results ready to return
4495 ** (via calls to the [sqlite3_column_int | sqlite3_column()] family of
4496 ** interfaces) then sqlite3_data_count(P) returns 0.
4497 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
4498 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
4499 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
4500 ** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -4992,16 +5009,13 @@
4992 ** These constants may be ORed together with the
4993 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
4994 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
4995 ** [sqlite3_create_function_v2()].
4996 **
4997 ** The SQLITE_DETERMINISTIC flag means that the new function always gives
4998 ** the same output when the input parameters are the same. The abs() function
4999 ** is deterministic, for example, but randomblob() is not. Functions must
5000 ** be deterministic in order to be used in certain contexts such as
5001 ** [CHECK constraints] or [generated columns]. SQLite might also optimize
5002 ** deterministic functions by factoring them out of inner loops.
5003 **
5004 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
5005 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
5006 ** a security feature which is recommended for all
5007 ** [application-defined SQL functions] that have side-effects. This flag
@@ -5076,12 +5090,12 @@
5076 **
5077 ** <b>Details:</b>
5078 **
5079 ** These routines extract type, size, and content information from
5080 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
5081 ** are used to pass parameter information into the functions that
5082 ** implement [application-defined SQL functions] and [virtual tables].
5083 **
5084 ** These routines work only with [protected sqlite3_value] objects.
5085 ** Any attempt to use these routines on an [unprotected sqlite3_value]
5086 ** is not threadsafe.
5087 **
@@ -5134,11 +5148,11 @@
5134 ** the return value is arbitrary and meaningless.
5135 **
5136 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
5137 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
5138 ** interfaces. ^If X comes from an SQL literal value, or a table column,
5139 ** or an expression, then sqlite3_value_frombind(X) returns zero.
5140 **
5141 ** Please pay particular attention to the fact that the pointer returned
5142 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
5143 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
5144 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5220,12 +5234,12 @@
5220 **
5221 ** Implementations of aggregate SQL functions use this
5222 ** routine to allocate memory for storing their state.
5223 **
5224 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
5225 ** for a particular aggregate function, SQLite allocates
5226 ** N bytes of memory, zeroes out that memory, and returns a pointer
5227 ** to the new memory. ^On second and subsequent calls to
5228 ** sqlite3_aggregate_context() for the same aggregate function instance,
5229 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
5230 ** called once for each invocation of the xStep callback and then one
5231 ** last time when the xFinal callback is invoked. ^(When no rows match
@@ -5238,11 +5252,11 @@
5238 ** when first called if N is less than or equal to zero or if a memory
5239 ** allocate error occurs.
5240 **
5241 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5242 ** determined by the N parameter on first successful call. Changing the
5243 ** value of N in any subsequents call to sqlite3_aggregate_context() within
5244 ** the same aggregate function instance will not resize the memory
5245 ** allocation.)^ Within the xFinal callback, it is customary to set
5246 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
5247 ** pointless memory allocations occur.
5248 **
@@ -5586,11 +5600,11 @@
5586 ** <li> If A&lt;B THEN B&gt;A.
5587 ** <li> If A&lt;B and B&lt;C then A&lt;C.
5588 ** </ol>
5589 **
5590 ** If a collating function fails any of the above constraints and that
5591 ** collating function is registered and used, then the behavior of SQLite
5592 ** is undefined.
5593 **
5594 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
5595 ** with the addition that the xDestroy callback is invoked on pArg when
5596 ** the collating function is deleted.
@@ -5913,20 +5927,16 @@
5913
5914 /*
5915 ** CAPI3REF: Return The Filename For A Database Connection
5916 ** METHOD: sqlite3
5917 **
5918 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename
5919 ** associated with database N of connection D.
5920 ** ^If there is no attached database N on the database
5921 ** connection D, or if database N is a temporary or in-memory database, then
5922 ** this function will return either a NULL pointer or an empty string.
5923 **
5924 ** ^The string value returned by this routine is owned and managed by
5925 ** the database connection. ^The value will be valid until the database N
5926 ** is [DETACH]-ed or until the database connection closes.
5927 **
5928 ** ^The filename returned by this function is the output of the
5929 ** xFullPathname method of the [VFS]. ^In other words, the filename
5930 ** will be an absolute pathname, even if the filename used
5931 ** to open the database originally was a URI or relative pathname.
5932 */
@@ -6076,23 +6086,19 @@
6076 ** In prior versions of SQLite,
6077 ** sharing was enabled or disabled for each thread separately.
6078 **
6079 ** ^(The cache sharing mode set by this interface effects all subsequent
6080 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
6081 ** Existing database connections continue to use the sharing mode
6082 ** that was in effect at the time they were opened.)^
6083 **
6084 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
6085 ** successfully. An [error code] is returned otherwise.)^
6086 **
6087 ** ^Shared cache is disabled by default. It is recommended that it stay
6088 ** that way. In other words, do not use this routine. This interface
6089 ** continues to be provided for historical compatibility, but its use is
6090 ** discouraged. Any use of shared cache is discouraged. If shared cache
6091 ** must be used, it is recommended that shared cache only be enabled for
6092 ** individual database connections using the [sqlite3_open_v2()] interface
6093 ** with the [SQLITE_OPEN_SHAREDCACHE] flag.
6094 **
6095 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
6096 ** and will always return SQLITE_MISUSE. On those systems,
6097 ** shared cache mode should be enabled per-database connection via
6098 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -6221,11 +6227,11 @@
6221 ** information about column C of table T in database D
6222 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
6223 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
6224 ** the final five arguments with appropriate values if the specified
6225 ** column exists. ^The sqlite3_table_column_metadata() interface returns
6226 ** SQLITE_ERROR if the specified column does not exist.
6227 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
6228 ** NULL pointer, then this routine simply checks for the existence of the
6229 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
6230 ** does not. If the table name parameter T in a call to
6231 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -6363,11 +6369,11 @@
6363 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
6364 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
6365 ** to enable or disable only the C-API.)^
6366 **
6367 ** <b>Security warning:</b> It is recommended that extension loading
6368 ** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
6369 ** rather than this interface, so the [load_extension()] SQL function
6370 ** remains disabled. This will prevent SQL injections from giving attackers
6371 ** access to extension loading capabilities.
6372 */
6373 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -6450,11 +6456,11 @@
6450 /*
6451 ** CAPI3REF: Virtual Table Object
6452 ** KEYWORDS: sqlite3_module {virtual table module}
6453 **
6454 ** This structure, sometimes called a "virtual table module",
6455 ** defines the implementation of a [virtual table].
6456 ** This structure consists mostly of methods for the module.
6457 **
6458 ** ^A virtual table module is created by filling in a persistent
6459 ** instance of this structure and passing a pointer to that instance
6460 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -6547,17 +6553,11 @@
6547 ** The [xBestIndex] method must fill aConstraintUsage[] with information
6548 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
6549 ** the right-hand side of the corresponding aConstraint[] is evaluated
6550 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
6551 ** is true, then the constraint is assumed to be fully handled by the
6552 ** virtual table and might not be checked again by the byte code.)^ ^(The
6553 ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag
6554 ** is left in its default setting of false, the constraint will always be
6555 ** checked separately in byte code. If the omit flag is change to true, then
6556 ** the constraint may or may not be checked in byte code. In other words,
6557 ** when the omit flag is true there is no guarantee that the constraint will
6558 ** not be checked again using byte code.)^
6559 **
6560 ** ^The idxNum and idxPtr values are recorded and passed into the
6561 ** [xFilter] method.
6562 ** ^[sqlite3_free()] is used to free idxPtr if and only if
6563 ** needToFreeIdxPtr is true.
@@ -6593,11 +6593,11 @@
6593 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
6594 ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
6595 ** If a virtual table extension is
6596 ** used with an SQLite version earlier than 3.8.2, the results of attempting
6597 ** to read or write the estimatedRows field are undefined (but are likely
6598 ** to include crashing the application). The estimatedRows field should
6599 ** therefore only be used if [sqlite3_libversion_number()] returns a
6600 ** value greater than or equal to 3008002. Similarly, the idxFlags field
6601 ** was added for [version 3.9.0] ([dateof:3.9.0]).
6602 ** It may therefore only be used if
6603 ** sqlite3_libversion_number() returns a value greater than or equal to
@@ -6645,11 +6645,11 @@
6645 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
6646
6647 /*
6648 ** CAPI3REF: Virtual Table Constraint Operator Codes
6649 **
6650 ** These macros define the allowed values for the
6651 ** [sqlite3_index_info].aConstraint[].op field. Each value represents
6652 ** an operator that is part of a constraint term in the wHERE clause of
6653 ** a query that uses a [virtual table].
6654 */
6655 #define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -7255,11 +7255,11 @@
7255 ** </ul>)^
7256 **
7257 ** The only difference is that the public sqlite3_XXX functions enumerated
7258 ** above silently ignore any invocations that pass a NULL pointer instead
7259 ** of a valid mutex handle. The implementations of the methods defined
7260 ** by this structure are not required to handle this case. The results
7261 ** of passing a NULL pointer instead of a valid mutex handle are undefined
7262 ** (i.e. it is acceptable to provide an implementation that segfaults if
7263 ** it is passed a NULL pointer).
7264 **
7265 ** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -7728,11 +7728,11 @@
7728 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
7729 ** no space was left in the page cache.</dd>)^
7730 **
7731 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
7732 ** <dd>This parameter records the largest memory allocation request
7733 ** handed to the [pagecache memory allocator]. Only the value returned in the
7734 ** *pHighwater parameter to [sqlite3_status()] is of interest.
7735 ** The value written into the *pCurrent parameter is undefined.</dd>)^
7736 **
7737 ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
7738 ** <dd>No longer used.</dd>
@@ -7804,11 +7804,11 @@
7804 ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
7805 ** <dd>This parameter returns the number of lookaside memory slots currently
7806 ** checked out.</dd>)^
7807 **
7808 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
7809 ** <dd>This parameter returns the number of malloc attempts that were
7810 ** satisfied using lookaside memory. Only the high-water value is meaningful;
7811 ** the current value is always zero.)^
7812 **
7813 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
7814 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -7886,11 +7886,11 @@
7886 ** <dd>This parameter returns the number of dirty cache entries that have
7887 ** been written to disk in the middle of a transaction due to the page
7888 ** cache overflowing. Transactions are more efficient if they are written
7889 ** to disk all at once. When pages spill mid-transaction, that introduces
7890 ** additional overhead. This parameter can be used help identify
7891 ** inefficiencies that can be resolved by increasing the cache size.
7892 ** </dd>
7893 **
7894 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
7895 ** <dd>This parameter returns zero for the current value if and only if
7896 ** all foreign key constraints (deferred or immediate) have been
@@ -7975,11 +7975,11 @@
7975 ** If the number of virtual machine operations exceeds 2147483647
7976 ** then the value returned by this statement status code is undefined.
7977 **
7978 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7979 ** <dd>^This is the number of times that the prepare statement has been
7980 ** automatically regenerated due to schema changes or changes to
7981 ** [bound parameters] that might affect the query plan.
7982 **
7983 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7984 ** <dd>^This is the number of times that the prepared statement has
7985 ** been run. A single "run" for the purposes of this counter is one
@@ -8146,11 +8146,11 @@
8146 ** NULL if allocating a new page is effectively impossible.
8147 ** </table>
8148 **
8149 ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
8150 ** will only use a createFlag of 2 after a prior call with a createFlag of 1
8151 ** failed.)^ In between the xFetch() calls, SQLite may
8152 ** attempt to unpin one or more cache pages by spilling the content of
8153 ** pinned pages to disk and synching the operating system disk cache.
8154 **
8155 ** [[the xUnpin() page cache method]]
8156 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -8464,11 +8464,11 @@
8464 ** application receives an SQLITE_LOCKED error, it may call the
8465 ** sqlite3_unlock_notify() method with the blocked connection handle as
8466 ** the first argument to register for a callback that will be invoked
8467 ** when the blocking connections current transaction is concluded. ^The
8468 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
8469 ** call that concludes the blocking connection's transaction.
8470 **
8471 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
8472 ** there is a chance that the blocking connection will have already
8473 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
8474 ** If this happens, then the specified callback is invoked immediately,
@@ -8502,11 +8502,11 @@
8502 ** However, the signature of the callback function allows SQLite to pass
8503 ** it an array of void* context pointers. The first argument passed to
8504 ** an unlock-notify callback is a pointer to an array of void* pointers,
8505 ** and the second is the number of entries in the array.
8506 **
8507 ** When a blocking connection's transaction is concluded, there may be
8508 ** more than one blocked connection that has registered for an unlock-notify
8509 ** callback. ^If two or more such blocked connections have specified the
8510 ** same callback function, then instead of invoking the callback function
8511 ** multiple times, it is invoked once with the set of void* context pointers
8512 ** specified by the blocked connections bundled together into an array.
@@ -8976,37 +8976,37 @@
8976 ** managed by the prepared statement S and will be automatically freed when
8977 ** S is finalized.
8978 **
8979 ** <dl>
8980 ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
8981 ** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be
8982 ** set to the total number of times that the X-th loop has run.</dd>
8983 **
8984 ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
8985 ** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be set
8986 ** to the total number of rows examined by all iterations of the X-th loop.</dd>
8987 **
8988 ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
8989 ** <dd>^The "double" variable pointed to by the V parameter will be set to the
8990 ** query planner's estimate for the average number of rows output from each
8991 ** iteration of the X-th loop. If the query planner's estimates was accurate,
8992 ** then this value will approximate the quotient NVISIT/NLOOP and the
8993 ** product of this value for all prior loops with the same SELECTID will
8994 ** be the NLOOP value for the current loop.
8995 **
8996 ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
8997 ** <dd>^The "const char *" variable pointed to by the V parameter will be set
8998 ** to a zero-terminated UTF-8 string containing the name of the index or table
8999 ** used for the X-th loop.
9000 **
9001 ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
9002 ** <dd>^The "const char *" variable pointed to by the V parameter will be set
9003 ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
9004 ** description for the X-th loop.
9005 **
9006 ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
9007 ** <dd>^The "int" variable pointed to by the V parameter will be set to the
9008 ** "select-id" for the X-th loop. The select-id identifies which query or
9009 ** subquery the loop is part of. The main query has a select-id of zero.
9010 ** The select-id is the same value as is output in the first column
9011 ** of an [EXPLAIN QUERY PLAN] query.
9012 ** </dl>
@@ -9857,11 +9857,11 @@
9857 ** METHOD: sqlite3_session
9858 **
9859 ** The second argument (xFilter) is the "filter callback". For changes to rows
9860 ** in tables that are not attached to the Session object, the filter is called
9861 ** to determine whether changes to the table's rows should be tracked or not.
9862 ** If xFilter returns 0, changes are not tracked. Note that once a table is
9863 ** attached, xFilter will not be called again.
9864 */
9865 SQLITE_API void sqlite3session_table_filter(
9866 sqlite3_session *pSession, /* Session object */
9867 int(*xFilter)(
@@ -10031,11 +10031,11 @@
10031 ** identical.
10032 **
10033 ** It an error if database zFrom does not exist or does not contain the
10034 ** required compatible table.
10035 **
10036 ** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
10037 ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
10038 ** may be set to point to a buffer containing an English language error
10039 ** message. It is the responsibility of the caller to free this buffer using
10040 ** sqlite3_free().
10041 */
@@ -10168,11 +10168,11 @@
10168
10169 /*
10170 ** CAPI3REF: Advance A Changeset Iterator
10171 ** METHOD: sqlite3_changeset_iter
10172 **
10173 ** This function may only be used with iterators created by the function
10174 ** [sqlite3changeset_start()]. If it is called on an iterator passed to
10175 ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
10176 ** is returned and the call has no effect.
10177 **
10178 ** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -10584,12 +10584,12 @@
10584 ** in the changegroup, then the number of columns and the position of the
10585 ** primary key columns for the table must be consistent. If this is not the
10586 ** case, this function fails with SQLITE_SCHEMA. If the input changeset
10587 ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
10588 ** returned. Or, if an out-of-memory condition occurs during processing, this
10589 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state
10590 ** of the final contents of the changegroup is undefined.
10591 **
10592 ** If no error occurs, SQLITE_OK is returned.
10593 */
10594 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
10595
@@ -10760,11 +10760,11 @@
10760 ** [SQLITE_CHANGESET_REPLACE].
10761 ** </dl>
10762 **
10763 ** It is safe to execute SQL statements, including those that write to the
10764 ** table that the callback related to, from within the xConflict callback.
10765 ** This can be used to further customize the application's conflict
10766 ** resolution strategy.
10767 **
10768 ** All changes made by these functions are enclosed in a savepoint transaction.
10769 ** If any other error (aside from a constraint failure when attempting to
10770 ** write to the target database) occurs, then the savepoint transaction is
@@ -11070,11 +11070,11 @@
11070 ** CAPI3REF: Rebase a changeset
11071 ** EXPERIMENTAL
11072 **
11073 ** Argument pIn must point to a buffer containing a changeset nIn bytes
11074 ** in size. This function allocates and populates a buffer with a copy
11075 ** of the changeset rebased according to the configuration of the
11076 ** rebaser object passed as the first argument. If successful, (*ppOut)
11077 ** is set to point to the new buffer containing the rebased changeset and
11078 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
11079 ** responsibility of the caller to eventually free the new buffer using
11080 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -11478,11 +11478,11 @@
11478 ** the callback, an SQLite error code is returned.
11479 **
11480 **
11481 ** xSetAuxdata(pFts5, pAux, xDelete)
11482 **
11483 ** Save the pointer passed as the second argument as the extension function's
11484 ** "auxiliary data". The pointer may then be retrieved by the current or any
11485 ** future invocation of the same fts5 extension function made as part of
11486 ** the same MATCH query using the xGetAuxdata() API.
11487 **
11488 ** Each extension function is allocated a single auxiliary data slot for
@@ -11720,12 +11720,12 @@
11720 ** all instances of "first place" or "1st place" regardless of which form
11721 ** the user specified in the MATCH query text.
11722 **
11723 ** There are several ways to approach this in FTS5:
11724 **
11725 ** <ol><li> By mapping all synonyms to a single token. In this case, using
11726 ** the above example, this means that the tokenizer returns the
11727 ** same token for inputs "first" and "1st". Say that token is in
11728 ** fact "first", so that when the user inserts the document "I won
11729 ** 1st place" entries are added to the index for tokens "i", "won",
11730 ** "first" and "place". If the user then queries for '1st + place',
11731 ** the tokenizer substitutes "first" for "1st" and the query works
11732
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.31.0"
127 #define SQLITE_VERSION_NUMBER 3031000
128 #define SQLITE_SOURCE_ID "2019-11-20 13:31:52 a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -539,11 +539,10 @@
539 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
540 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
541 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
542 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
543 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
 
544
545 /*
546 ** CAPI3REF: Flags For File Open Operations
547 **
548 ** These bit values are intended for use in the
@@ -980,20 +979,20 @@
979 **
980 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
981 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
982 ** file-control may be invoked by SQLite on the database file handle
983 ** shortly after it is opened in order to provide a custom VFS with access
984 ** to the connections busy-handler callback. The argument is of type (void **)
985 ** - an array of two (void *) values. The first (void *) actually points
986 ** to a function of type (int (*)(void *)). In order to invoke the connections
987 ** busy-handler, this function should be invoked with the second (void *) in
988 ** the array as the only argument. If it returns non-zero, then the operation
989 ** should be retried. If it returns zero, the custom VFS should abandon the
990 ** current operation.
991 **
992 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
993 ** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
994 ** to have SQLite generate a
995 ** temporary filename using the same algorithm that is followed to generate
996 ** temporary filenames for TEMP tables and other internal uses. The
997 ** argument should be a char** which will be filled with the filename
998 ** written into memory obtained from [sqlite3_malloc()]. The caller should
@@ -1102,11 +1101,11 @@
1101 ** interface can be used to find if any database on the connection has changed,
1102 ** but that interface responds to changes on TEMP as well as MAIN and does
1103 ** not provide a mechanism to detect changes to MAIN only. Also, the
1104 ** [sqlite3_total_changes()] interface responds to internal changes only and
1105 ** omits changes made by other database connections. The
1106 ** [PRAGMA data_version] command provide a mechanism to detect changes to
1107 ** a single attached database that occur due to other database connections,
1108 ** but omits changes implemented by the database connection on which it is
1109 ** called. This file control is the only mechanism to detect changes that
1110 ** happen either internally or externally and that are associated with
1111 ** a particular attached database.
@@ -1190,14 +1189,14 @@
1189 ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
1190 ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
1191 ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields
1192 ** may be appended to the sqlite3_vfs object and the iVersion value
1193 ** may increase again in future versions of SQLite.
1194 ** Note that the structure
1195 ** of the sqlite3_vfs object changes in the transition from
1196 ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
1197 ** and yet the iVersion field was not modified.
1198 **
1199 ** The szOsFile field is the size of the subclassed [sqlite3_file]
1200 ** structure used by this VFS. mxPathname is the maximum length of
1201 ** a pathname in this VFS.
1202 **
@@ -1284,11 +1283,11 @@
1283 ** be created, and that it is an error if it already exists.
1284 ** It is <i>not</i> used to indicate the file should be opened
1285 ** for exclusive access.
1286 **
1287 ** ^At least szOsFile bytes of memory are allocated by SQLite
1288 ** to hold the [sqlite3_file] structure passed as the third
1289 ** argument to xOpen. The xOpen method does not have to
1290 ** allocate the structure; it should just fill it in. Note that
1291 ** the xOpen method must set the sqlite3_file.pMethods to either
1292 ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
1293 ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
@@ -1407,10 +1406,11 @@
1406 ** SQLite.
1407 */
1408 #define SQLITE_ACCESS_EXISTS 0
1409 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
1410 #define SQLITE_ACCESS_READ 2 /* Unused */
1411 #define SQLITE_ACCESS_SYMLINK 3 /* Test if file is symbolic link */
1412
1413 /*
1414 ** CAPI3REF: Flags for the xShmLock VFS method
1415 **
1416 ** These integer constants define the various locking operations
@@ -1621,11 +1621,11 @@
1621 ** Every memory allocation request coming in through [sqlite3_malloc()]
1622 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
1623 ** that causes the corresponding memory allocation to fail.
1624 **
1625 ** The xInit method initializes the memory allocator. For example,
1626 ** it might allocate any require mutexes or initialize internal data
1627 ** structures. The xShutdown method is invoked (indirectly) by
1628 ** [sqlite3_shutdown()] and should deallocate any resources acquired
1629 ** by xInit. The pAppData pointer is used as the only parameter to
1630 ** xInit and xShutdown.
1631 **
@@ -1762,11 +1762,11 @@
1762 **
1763 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1764 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
1765 ** that SQLite can use for the database page cache with the default page
1766 ** cache implementation.
1767 ** This configuration option is a no-op if an application-define page
1768 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
1769 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
1770 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
1771 ** and the number of cache lines (N).
1772 ** The sz argument should be the size of the largest database page
@@ -2247,11 +2247,11 @@
2247 ** </dd>
2248 **
2249 ** [[SQLITE_DBCONFIG_DQS_DML]]
2250 ** <dt>SQLITE_DBCONFIG_DQS_DML</td>
2251 ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2252 ** the legacy [double-quoted string literal] misfeature for DML statement
2253 ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
2254 ** default value of this setting is determined by the [-DSQLITE_DQS]
2255 ** compile-time option.
2256 ** </dd>
2257 **
@@ -2508,11 +2508,11 @@
2508 ** will be rolled back automatically.
2509 **
2510 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
2511 ** SQL statements on [database connection] D complete. ^Any new SQL statements
2512 ** that are started after the sqlite3_interrupt() call and before the
2513 ** running statements reaches zero are interrupted as if they had been
2514 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
2515 ** that are started after the running statement count reaches zero are
2516 ** not effected by the sqlite3_interrupt().
2517 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
2518 ** SQL statements is a no-op and has no effect on SQL statements
@@ -2676,13 +2676,13 @@
2676 ** Alice | 43
2677 ** Bob | 28
2678 ** Cindy | 21
2679 ** </pre></blockquote>
2680 **
2681 ** There are two column (M==2) and three rows (N==3). Thus the
2682 ** result table has 8 entries. Suppose the result table is stored
2683 ** in an array names azResult. Then azResult holds this content:
2684 **
2685 ** <blockquote><pre>
2686 ** azResult&#91;0] = "Name";
2687 ** azResult&#91;1] = "Age";
2688 ** azResult&#91;2] = "Alice";
@@ -2831,10 +2831,23 @@
2831 ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
2832 ** sqlite3_malloc64(), and sqlite3_realloc64()
2833 ** is always aligned to at least an 8 byte boundary, or to a
2834 ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
2835 ** option is used.
2836 **
2837 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2838 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
2839 ** implementation of these routines to be omitted. That capability
2840 ** is no longer provided. Only built-in memory allocators can be used.
2841 **
2842 ** Prior to SQLite version 3.7.10, the Windows OS interface layer called
2843 ** the system malloc() and free() directly when converting
2844 ** filenames between the UTF-8 encoding used by SQLite
2845 ** and whatever filename encoding is used by the particular Windows
2846 ** installation. Memory allocation errors were detected, but
2847 ** they were reported back as [SQLITE_CANTOPEN] or
2848 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
2849 **
2850 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
2851 ** must be either NULL or else pointers obtained from a prior
2852 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
2853 ** not yet been released.
@@ -2880,11 +2893,11 @@
2893 ** CAPI3REF: Pseudo-Random Number Generator
2894 **
2895 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
2896 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2897 ** already uses the largest possible [ROWID]. The PRNG is also used for
2898 ** the build-in random() and randomblob() SQL functions. This interface allows
2899 ** applications to access the same PRNG for other purposes.
2900 **
2901 ** ^A call to this routine stores N bytes of randomness into buffer P.
2902 ** ^The P parameter can be a NULL pointer.
2903 **
@@ -3481,11 +3494,11 @@
3494 ** a VFS implementation when the flags parameter to xOpen() has one or
3495 ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
3496 ** P is the name of the query parameter, then
3497 ** sqlite3_uri_parameter(F,P) returns the value of the P
3498 ** parameter if it exists or a NULL pointer if P does not appear as a
3499 ** query parameter on F. If P is a query parameter of F
3500 ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
3501 ** a pointer to an empty string.
3502 **
3503 ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
3504 ** parameter and returns true (1) or false (0) according to the value
@@ -3493,11 +3506,11 @@
3506 ** value of query parameter P is one of "yes", "true", or "on" in any
3507 ** case or if the value begins with a non-zero number. The
3508 ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
3509 ** query parameter P is one of "no", "false", or "off" in any case or
3510 ** if the value begins with a numeric zero. If P is not a query
3511 ** parameter on F or if the value of P is does not match any of the
3512 ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
3513 **
3514 ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
3515 ** 64-bit signed integer and returns that integer, or D if P does not
3516 ** exist. If the value of P is something other than an integer, then
@@ -3830,16 +3843,16 @@
3843 ** in order to find the underlying cause of the problem. With the "v2" prepare
3844 ** interfaces, the underlying reason for the error is returned immediately.
3845 ** </li>
3846 **
3847 ** <li>
3848 ** ^If the specific value bound to [parameter | host parameter] in the
3849 ** WHERE clause might influence the choice of query plan for a statement,
3850 ** then the statement will be automatically recompiled, as if there had been
3851 ** a schema change, on the first [sqlite3_step()] call following any change
3852 ** to the [sqlite3_bind_text | bindings] of that [parameter].
3853 ** ^The specific value of WHERE-clause [parameter] might influence the
3854 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3855 ** or [GLOB] operator or if the parameter is compared to an indexed column
3856 ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled.
3857 ** </li>
3858 ** </ol>
@@ -4344,19 +4357,23 @@
4357 ** the statement, where N is the second function argument.
4358 ** ^The left-most column is column 0 for these routines.
4359 **
4360 ** ^If the Nth column returned by the statement is an expression or
4361 ** subquery and is not a column value, then all of these functions return
4362 ** NULL. ^These routine might also return NULL if a memory allocation error
4363 ** occurs. ^Otherwise, they return the name of the attached database, table,
4364 ** or column that query result column was extracted from.
4365 **
4366 ** ^As with all other SQLite APIs, those whose names end with "16" return
4367 ** UTF-16 encoded strings and the other functions return UTF-8.
4368 **
4369 ** ^These APIs are only available if the library was compiled with the
4370 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
4371 **
4372 ** If two or more threads call one or more of these routines against the same
4373 ** prepared statement and column at the same time then the results are
4374 ** undefined.
4375 **
4376 ** If two or more threads call one or more
4377 ** [sqlite3_column_database_name | column metadata interfaces]
4378 ** for the same [prepared statement] and result column
4379 ** at the same time then the results are undefined.
@@ -4490,11 +4507,11 @@
4507 ** METHOD: sqlite3_stmt
4508 **
4509 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
4510 ** current row of the result set of [prepared statement] P.
4511 ** ^If prepared statement P does not have results ready to return
4512 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
4513 ** interfaces) then sqlite3_data_count(P) returns 0.
4514 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
4515 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
4516 ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
4517 ** will return non-zero if previous call to [sqlite3_step](P) returned
@@ -4992,16 +5009,13 @@
5009 ** These constants may be ORed together with the
5010 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
5011 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
5012 ** [sqlite3_create_function_v2()].
5013 **
5014 ** The SQLITE_DETERMINISTIC flag means that the new function will always
5015 ** maps the same inputs into the same output. The abs() function is
5016 ** deterministic, for example, but randomblob() is not.
 
 
 
5017 **
5018 ** The SQLITE_DIRECTONLY flag means that the function may only be invoked
5019 ** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is
5020 ** a security feature which is recommended for all
5021 ** [application-defined SQL functions] that have side-effects. This flag
@@ -5076,12 +5090,12 @@
5090 **
5091 ** <b>Details:</b>
5092 **
5093 ** These routines extract type, size, and content information from
5094 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
5095 ** are used to pass parameter information into implementation of
5096 ** [application-defined SQL functions] and [virtual tables].
5097 **
5098 ** These routines work only with [protected sqlite3_value] objects.
5099 ** Any attempt to use these routines on an [unprotected sqlite3_value]
5100 ** is not threadsafe.
5101 **
@@ -5134,11 +5148,11 @@
5148 ** the return value is arbitrary and meaningless.
5149 **
5150 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
5151 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
5152 ** interfaces. ^If X comes from an SQL literal value, or a table column,
5153 ** and expression, then sqlite3_value_frombind(X) returns zero.
5154 **
5155 ** Please pay particular attention to the fact that the pointer returned
5156 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
5157 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
5158 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5220,12 +5234,12 @@
5234 **
5235 ** Implementations of aggregate SQL functions use this
5236 ** routine to allocate memory for storing their state.
5237 **
5238 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
5239 ** for a particular aggregate function, SQLite
5240 ** allocates N of memory, zeroes out that memory, and returns a pointer
5241 ** to the new memory. ^On second and subsequent calls to
5242 ** sqlite3_aggregate_context() for the same aggregate function instance,
5243 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
5244 ** called once for each invocation of the xStep callback and then one
5245 ** last time when the xFinal callback is invoked. ^(When no rows match
@@ -5238,11 +5252,11 @@
5252 ** when first called if N is less than or equal to zero or if a memory
5253 ** allocate error occurs.
5254 **
5255 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5256 ** determined by the N parameter on first successful call. Changing the
5257 ** value of N in subsequent call to sqlite3_aggregate_context() within
5258 ** the same aggregate function instance will not resize the memory
5259 ** allocation.)^ Within the xFinal callback, it is customary to set
5260 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
5261 ** pointless memory allocations occur.
5262 **
@@ -5586,11 +5600,11 @@
5600 ** <li> If A&lt;B THEN B&gt;A.
5601 ** <li> If A&lt;B and B&lt;C then A&lt;C.
5602 ** </ol>
5603 **
5604 ** If a collating function fails any of the above constraints and that
5605 ** collating function is registered and used, then the behavior of SQLite
5606 ** is undefined.
5607 **
5608 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
5609 ** with the addition that the xDestroy callback is invoked on pArg when
5610 ** the collating function is deleted.
@@ -5913,20 +5927,16 @@
5927
5928 /*
5929 ** CAPI3REF: Return The Filename For A Database Connection
5930 ** METHOD: sqlite3
5931 **
5932 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
5933 ** associated with database N of connection D. ^The main database file
5934 ** has the name "main". If there is no attached database N on the database
5935 ** connection D, or if database N is a temporary or in-memory database, then
5936 ** this function will return either a NULL pointer or an empty string.
5937 **
 
 
 
 
5938 ** ^The filename returned by this function is the output of the
5939 ** xFullPathname method of the [VFS]. ^In other words, the filename
5940 ** will be an absolute pathname, even if the filename used
5941 ** to open the database originally was a URI or relative pathname.
5942 */
@@ -6076,23 +6086,19 @@
6086 ** In prior versions of SQLite,
6087 ** sharing was enabled or disabled for each thread separately.
6088 **
6089 ** ^(The cache sharing mode set by this interface effects all subsequent
6090 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
6091 ** Existing database connections continue use the sharing mode
6092 ** that was in effect at the time they were opened.)^
6093 **
6094 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
6095 ** successfully. An [error code] is returned otherwise.)^
6096 **
6097 ** ^Shared cache is disabled by default. But this might change in
6098 ** future releases of SQLite. Applications that care about shared
6099 ** cache setting should set it explicitly.
 
 
 
 
6100 **
6101 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
6102 ** and will always return SQLITE_MISUSE. On those systems,
6103 ** shared cache mode should be enabled per-database connection via
6104 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
@@ -6221,11 +6227,11 @@
6227 ** information about column C of table T in database D
6228 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
6229 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
6230 ** the final five arguments with appropriate values if the specified
6231 ** column exists. ^The sqlite3_table_column_metadata() interface returns
6232 ** SQLITE_ERROR and if the specified column does not exist.
6233 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
6234 ** NULL pointer, then this routine simply checks for the existence of the
6235 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
6236 ** does not. If the table name parameter T in a call to
6237 ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is
@@ -6363,11 +6369,11 @@
6369 ** [sqlite3_load_extension()] and the SQL function [load_extension()].
6370 ** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
6371 ** to enable or disable only the C-API.)^
6372 **
6373 ** <b>Security warning:</b> It is recommended that extension loading
6374 ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
6375 ** rather than this interface, so the [load_extension()] SQL function
6376 ** remains disabled. This will prevent SQL injections from giving attackers
6377 ** access to extension loading capabilities.
6378 */
6379 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
@@ -6450,11 +6456,11 @@
6456 /*
6457 ** CAPI3REF: Virtual Table Object
6458 ** KEYWORDS: sqlite3_module {virtual table module}
6459 **
6460 ** This structure, sometimes called a "virtual table module",
6461 ** defines the implementation of a [virtual tables].
6462 ** This structure consists mostly of methods for the module.
6463 **
6464 ** ^A virtual table module is created by filling in a persistent
6465 ** instance of this structure and passing a pointer to that instance
6466 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
@@ -6547,17 +6553,11 @@
6553 ** The [xBestIndex] method must fill aConstraintUsage[] with information
6554 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
6555 ** the right-hand side of the corresponding aConstraint[] is evaluated
6556 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
6557 ** is true, then the constraint is assumed to be fully handled by the
6558 ** virtual table and is not checked again by SQLite.)^
 
 
 
 
 
 
6559 **
6560 ** ^The idxNum and idxPtr values are recorded and passed into the
6561 ** [xFilter] method.
6562 ** ^[sqlite3_free()] is used to free idxPtr if and only if
6563 ** needToFreeIdxPtr is true.
@@ -6593,11 +6593,11 @@
6593 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
6594 ** structure for SQLite [version 3.8.2] ([dateof:3.8.2]).
6595 ** If a virtual table extension is
6596 ** used with an SQLite version earlier than 3.8.2, the results of attempting
6597 ** to read or write the estimatedRows field are undefined (but are likely
6598 ** to included crashing the application). The estimatedRows field should
6599 ** therefore only be used if [sqlite3_libversion_number()] returns a
6600 ** value greater than or equal to 3008002. Similarly, the idxFlags field
6601 ** was added for [version 3.9.0] ([dateof:3.9.0]).
6602 ** It may therefore only be used if
6603 ** sqlite3_libversion_number() returns a value greater than or equal to
@@ -6645,11 +6645,11 @@
6645 #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
6646
6647 /*
6648 ** CAPI3REF: Virtual Table Constraint Operator Codes
6649 **
6650 ** These macros defined the allowed values for the
6651 ** [sqlite3_index_info].aConstraint[].op field. Each value represents
6652 ** an operator that is part of a constraint term in the wHERE clause of
6653 ** a query that uses a [virtual table].
6654 */
6655 #define SQLITE_INDEX_CONSTRAINT_EQ 2
@@ -7255,11 +7255,11 @@
7255 ** </ul>)^
7256 **
7257 ** The only difference is that the public sqlite3_XXX functions enumerated
7258 ** above silently ignore any invocations that pass a NULL pointer instead
7259 ** of a valid mutex handle. The implementations of the methods defined
7260 ** by this structure are not required to handle this case, the results
7261 ** of passing a NULL pointer instead of a valid mutex handle are undefined
7262 ** (i.e. it is acceptable to provide an implementation that segfaults if
7263 ** it is passed a NULL pointer).
7264 **
7265 ** The xMutexInit() method must be threadsafe. It must be harmless to
@@ -7728,11 +7728,11 @@
7728 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
7729 ** no space was left in the page cache.</dd>)^
7730 **
7731 ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
7732 ** <dd>This parameter records the largest memory allocation request
7733 ** handed to [pagecache memory allocator]. Only the value returned in the
7734 ** *pHighwater parameter to [sqlite3_status()] is of interest.
7735 ** The value written into the *pCurrent parameter is undefined.</dd>)^
7736 **
7737 ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>
7738 ** <dd>No longer used.</dd>
@@ -7804,11 +7804,11 @@
7804 ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
7805 ** <dd>This parameter returns the number of lookaside memory slots currently
7806 ** checked out.</dd>)^
7807 **
7808 ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
7809 ** <dd>This parameter returns the number malloc attempts that were
7810 ** satisfied using lookaside memory. Only the high-water value is meaningful;
7811 ** the current value is always zero.)^
7812 **
7813 ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
7814 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
@@ -7886,11 +7886,11 @@
7886 ** <dd>This parameter returns the number of dirty cache entries that have
7887 ** been written to disk in the middle of a transaction due to the page
7888 ** cache overflowing. Transactions are more efficient if they are written
7889 ** to disk all at once. When pages spill mid-transaction, that introduces
7890 ** additional overhead. This parameter can be used help identify
7891 ** inefficiencies that can be resolve by increasing the cache size.
7892 ** </dd>
7893 **
7894 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
7895 ** <dd>This parameter returns zero for the current value if and only if
7896 ** all foreign key constraints (deferred or immediate) have been
@@ -7975,11 +7975,11 @@
7975 ** If the number of virtual machine operations exceeds 2147483647
7976 ** then the value returned by this statement status code is undefined.
7977 **
7978 ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>
7979 ** <dd>^This is the number of times that the prepare statement has been
7980 ** automatically regenerated due to schema changes or change to
7981 ** [bound parameters] that might affect the query plan.
7982 **
7983 ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>
7984 ** <dd>^This is the number of times that the prepared statement has
7985 ** been run. A single "run" for the purposes of this counter is one
@@ -8146,11 +8146,11 @@
8146 ** NULL if allocating a new page is effectively impossible.
8147 ** </table>
8148 **
8149 ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite
8150 ** will only use a createFlag of 2 after a prior call with a createFlag of 1
8151 ** failed.)^ In between the to xFetch() calls, SQLite may
8152 ** attempt to unpin one or more cache pages by spilling the content of
8153 ** pinned pages to disk and synching the operating system disk cache.
8154 **
8155 ** [[the xUnpin() page cache method]]
8156 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
@@ -8464,11 +8464,11 @@
8464 ** application receives an SQLITE_LOCKED error, it may call the
8465 ** sqlite3_unlock_notify() method with the blocked connection handle as
8466 ** the first argument to register for a callback that will be invoked
8467 ** when the blocking connections current transaction is concluded. ^The
8468 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
8469 ** call that concludes the blocking connections transaction.
8470 **
8471 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
8472 ** there is a chance that the blocking connection will have already
8473 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
8474 ** If this happens, then the specified callback is invoked immediately,
@@ -8502,11 +8502,11 @@
8502 ** However, the signature of the callback function allows SQLite to pass
8503 ** it an array of void* context pointers. The first argument passed to
8504 ** an unlock-notify callback is a pointer to an array of void* pointers,
8505 ** and the second is the number of entries in the array.
8506 **
8507 ** When a blocking connections transaction is concluded, there may be
8508 ** more than one blocked connection that has registered for an unlock-notify
8509 ** callback. ^If two or more such blocked connections have specified the
8510 ** same callback function, then instead of invoking the callback function
8511 ** multiple times, it is invoked once with the set of void* context pointers
8512 ** specified by the blocked connections bundled together into an array.
@@ -8976,37 +8976,37 @@
8976 ** managed by the prepared statement S and will be automatically freed when
8977 ** S is finalized.
8978 **
8979 ** <dl>
8980 ** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
8981 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
8982 ** set to the total number of times that the X-th loop has run.</dd>
8983 **
8984 ** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
8985 ** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
8986 ** to the total number of rows examined by all iterations of the X-th loop.</dd>
8987 **
8988 ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
8989 ** <dd>^The "double" variable pointed to by the T parameter will be set to the
8990 ** query planner's estimate for the average number of rows output from each
8991 ** iteration of the X-th loop. If the query planner's estimates was accurate,
8992 ** then this value will approximate the quotient NVISIT/NLOOP and the
8993 ** product of this value for all prior loops with the same SELECTID will
8994 ** be the NLOOP value for the current loop.
8995 **
8996 ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
8997 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
8998 ** to a zero-terminated UTF-8 string containing the name of the index or table
8999 ** used for the X-th loop.
9000 **
9001 ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
9002 ** <dd>^The "const char *" variable pointed to by the T parameter will be set
9003 ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
9004 ** description for the X-th loop.
9005 **
9006 ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
9007 ** <dd>^The "int" variable pointed to by the T parameter will be set to the
9008 ** "select-id" for the X-th loop. The select-id identifies which query or
9009 ** subquery the loop is part of. The main query has a select-id of zero.
9010 ** The select-id is the same value as is output in the first column
9011 ** of an [EXPLAIN QUERY PLAN] query.
9012 ** </dl>
@@ -9857,11 +9857,11 @@
9857 ** METHOD: sqlite3_session
9858 **
9859 ** The second argument (xFilter) is the "filter callback". For changes to rows
9860 ** in tables that are not attached to the Session object, the filter is called
9861 ** to determine whether changes to the table's rows should be tracked or not.
9862 ** If xFilter returns 0, changes is not tracked. Note that once a table is
9863 ** attached, xFilter will not be called again.
9864 */
9865 SQLITE_API void sqlite3session_table_filter(
9866 sqlite3_session *pSession, /* Session object */
9867 int(*xFilter)(
@@ -10031,11 +10031,11 @@
10031 ** identical.
10032 **
10033 ** It an error if database zFrom does not exist or does not contain the
10034 ** required compatible table.
10035 **
10036 ** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
10037 ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
10038 ** may be set to point to a buffer containing an English language error
10039 ** message. It is the responsibility of the caller to free this buffer using
10040 ** sqlite3_free().
10041 */
@@ -10168,11 +10168,11 @@
10168
10169 /*
10170 ** CAPI3REF: Advance A Changeset Iterator
10171 ** METHOD: sqlite3_changeset_iter
10172 **
10173 ** This function may only be used with iterators created by function
10174 ** [sqlite3changeset_start()]. If it is called on an iterator passed to
10175 ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
10176 ** is returned and the call has no effect.
10177 **
10178 ** Immediately after an iterator is created by sqlite3changeset_start(), it
@@ -10584,12 +10584,12 @@
10584 ** in the changegroup, then the number of columns and the position of the
10585 ** primary key columns for the table must be consistent. If this is not the
10586 ** case, this function fails with SQLITE_SCHEMA. If the input changeset
10587 ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
10588 ** returned. Or, if an out-of-memory condition occurs during processing, this
10589 ** function returns SQLITE_NOMEM. In all cases, if an error occurs the
10590 ** final contents of the changegroup is undefined.
10591 **
10592 ** If no error occurs, SQLITE_OK is returned.
10593 */
10594 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
10595
@@ -10760,11 +10760,11 @@
10760 ** [SQLITE_CHANGESET_REPLACE].
10761 ** </dl>
10762 **
10763 ** It is safe to execute SQL statements, including those that write to the
10764 ** table that the callback related to, from within the xConflict callback.
10765 ** This can be used to further customize the applications conflict
10766 ** resolution strategy.
10767 **
10768 ** All changes made by these functions are enclosed in a savepoint transaction.
10769 ** If any other error (aside from a constraint failure when attempting to
10770 ** write to the target database) occurs, then the savepoint transaction is
@@ -11070,11 +11070,11 @@
11070 ** CAPI3REF: Rebase a changeset
11071 ** EXPERIMENTAL
11072 **
11073 ** Argument pIn must point to a buffer containing a changeset nIn bytes
11074 ** in size. This function allocates and populates a buffer with a copy
11075 ** of the changeset rebased rebased according to the configuration of the
11076 ** rebaser object passed as the first argument. If successful, (*ppOut)
11077 ** is set to point to the new buffer containing the rebased changeset and
11078 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
11079 ** responsibility of the caller to eventually free the new buffer using
11080 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
@@ -11478,11 +11478,11 @@
11478 ** the callback, an SQLite error code is returned.
11479 **
11480 **
11481 ** xSetAuxdata(pFts5, pAux, xDelete)
11482 **
11483 ** Save the pointer passed as the second argument as the extension functions
11484 ** "auxiliary data". The pointer may then be retrieved by the current or any
11485 ** future invocation of the same fts5 extension function made as part of
11486 ** the same MATCH query using the xGetAuxdata() API.
11487 **
11488 ** Each extension function is allocated a single auxiliary data slot for
@@ -11720,12 +11720,12 @@
11720 ** all instances of "first place" or "1st place" regardless of which form
11721 ** the user specified in the MATCH query text.
11722 **
11723 ** There are several ways to approach this in FTS5:
11724 **
11725 ** <ol><li> By mapping all synonyms to a single token. In this case, the
11726 ** In the above example, this means that the tokenizer returns the
11727 ** same token for inputs "first" and "1st". Say that token is in
11728 ** fact "first", so that when the user inserts the document "I won
11729 ** 1st place" entries are added to the index for tokens "i", "won",
11730 ** "first" and "place". If the user then queries for '1st + place',
11731 ** the tokenizer substitutes "first" for "1st" and the query works
11732
+19 -1
--- src/style.c
+++ src/style.c
@@ -1139,20 +1139,38 @@
11391139
** the error message is shown.
11401140
**
11411141
** If zFormat is an empty string, then this is the /test_env page.
11421142
*/
11431143
void webpage_error(const char *zFormat, ...){
1144
+ int i;
11441145
int showAll;
11451146
char *zErr = 0;
11461147
int isAuth = 0;
11471148
char zCap[100];
1149
+ static const char *const azCgiVars[] = {
1150
+ "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1151
+ "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1152
+ "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1153
+ "HTTP_CONNECTION", "HTTP_HOST",
1154
+ "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1155
+ "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1156
+ "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1157
+ "REMOTE_USER", "REQUEST_METHOD",
1158
+ "REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_PROTOCOL",
1159
+ "HOME", "FOSSIL_HOME", "USERNAME", "USER", "FOSSIL_USER",
1160
+ "SQLITE_TMPDIR", "TMPDIR",
1161
+ "TEMP", "TMP", "FOSSIL_VFS",
1162
+ "FOSSIL_FORCE_TICKET_MODERATION", "FOSSIL_FORCE_WIKI_MODERATION",
1163
+ "FOSSIL_TCL_PATH", "TH1_DELETE_INTERP", "TH1_ENABLE_DOCS",
1164
+ "TH1_ENABLE_HOOKS", "TH1_ENABLE_TCL", "REMOTE_HOST",
1165
+ };
11481166
11491167
login_check_credentials();
11501168
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
11511169
isAuth = 1;
11521170
}
1153
- cgi_load_environment();
1171
+ for(i=0; i<count(azCgiVars); i++) (void)P(azCgiVars[i]);
11541172
if( zFormat[0] ){
11551173
va_list ap;
11561174
va_start(ap, zFormat);
11571175
zErr = vmprintf(zFormat, ap);
11581176
va_end(ap);
11591177
--- src/style.c
+++ src/style.c
@@ -1139,20 +1139,38 @@
1139 ** the error message is shown.
1140 **
1141 ** If zFormat is an empty string, then this is the /test_env page.
1142 */
1143 void webpage_error(const char *zFormat, ...){
 
1144 int showAll;
1145 char *zErr = 0;
1146 int isAuth = 0;
1147 char zCap[100];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1148
1149 login_check_credentials();
1150 if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
1151 isAuth = 1;
1152 }
1153 cgi_load_environment();
1154 if( zFormat[0] ){
1155 va_list ap;
1156 va_start(ap, zFormat);
1157 zErr = vmprintf(zFormat, ap);
1158 va_end(ap);
1159
--- src/style.c
+++ src/style.c
@@ -1139,20 +1139,38 @@
1139 ** the error message is shown.
1140 **
1141 ** If zFormat is an empty string, then this is the /test_env page.
1142 */
1143 void webpage_error(const char *zFormat, ...){
1144 int i;
1145 int showAll;
1146 char *zErr = 0;
1147 int isAuth = 0;
1148 char zCap[100];
1149 static const char *const azCgiVars[] = {
1150 "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1151 "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1152 "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1153 "HTTP_CONNECTION", "HTTP_HOST",
1154 "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1155 "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1156 "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1157 "REMOTE_USER", "REQUEST_METHOD",
1158 "REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_PROTOCOL",
1159 "HOME", "FOSSIL_HOME", "USERNAME", "USER", "FOSSIL_USER",
1160 "SQLITE_TMPDIR", "TMPDIR",
1161 "TEMP", "TMP", "FOSSIL_VFS",
1162 "FOSSIL_FORCE_TICKET_MODERATION", "FOSSIL_FORCE_WIKI_MODERATION",
1163 "FOSSIL_TCL_PATH", "TH1_DELETE_INTERP", "TH1_ENABLE_DOCS",
1164 "TH1_ENABLE_HOOKS", "TH1_ENABLE_TCL", "REMOTE_HOST",
1165 };
1166
1167 login_check_credentials();
1168 if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
1169 isAuth = 1;
1170 }
1171 for(i=0; i<count(azCgiVars); i++) (void)P(azCgiVars[i]);
1172 if( zFormat[0] ){
1173 va_list ap;
1174 va_start(ap, zFormat);
1175 zErr = vmprintf(zFormat, ap);
1176 va_end(ap);
1177
+7 -9
--- src/sync.c
+++ src/sync.c
@@ -200,14 +200,13 @@
200200
/*
201201
** COMMAND: pull
202202
**
203203
** Usage: %fossil pull ?URL? ?options?
204204
**
205
-** Pull all sharable changes from a remote repository into the local
206
-** repository. Sharable changes include public check-ins, edits to
207
-** wiki pages, tickets, and tech-notes, as well as forum content. Add
208
-** the --private option to pull private branches. Use the
205
+** Pull all sharable changes from a remote repository into the local repository.
206
+** Sharable changes include public check-ins, and wiki, ticket, and tech-note
207
+** edits. Add the --private option to pull private branches. Use the
209208
** "configuration pull" command to pull website configuration details.
210209
**
211210
** If URL is not specified, then the URL from the most recent clone, push,
212211
** pull, remote-url, or sync command is used. See "fossil help clone" for
213212
** details on the URL formats.
@@ -247,15 +246,14 @@
247246
/*
248247
** COMMAND: push
249248
**
250249
** Usage: %fossil push ?URL? ?options?
251250
**
252
-** Push all sharable changes from the local repository to a remote
253
-** repository. Sharable changes include public check-ins, edits to
254
-** wiki pages, tickets, and tech-notes, as well as forum content. Use
255
-** --private to also push private branches. Use the "configuration
256
-** push" command to push website configuration details.
251
+** Push all sharable changes from the local repository to a remote repository.
252
+** Sharable changes include public check-ins, and wiki, ticket, and tech-note
253
+** edits. Use --private to also push private branches. Use the
254
+** "configuration push" command to push website configuration details.
257255
**
258256
** If URL is not specified, then the URL from the most recent clone, push,
259257
** pull, remote-url, or sync command is used. See "fossil help clone" for
260258
** details on the URL formats.
261259
**
262260
--- src/sync.c
+++ src/sync.c
@@ -200,14 +200,13 @@
200 /*
201 ** COMMAND: pull
202 **
203 ** Usage: %fossil pull ?URL? ?options?
204 **
205 ** Pull all sharable changes from a remote repository into the local
206 ** repository. Sharable changes include public check-ins, edits to
207 ** wiki pages, tickets, and tech-notes, as well as forum content. Add
208 ** the --private option to pull private branches. Use the
209 ** "configuration pull" command to pull website configuration details.
210 **
211 ** If URL is not specified, then the URL from the most recent clone, push,
212 ** pull, remote-url, or sync command is used. See "fossil help clone" for
213 ** details on the URL formats.
@@ -247,15 +246,14 @@
247 /*
248 ** COMMAND: push
249 **
250 ** Usage: %fossil push ?URL? ?options?
251 **
252 ** Push all sharable changes from the local repository to a remote
253 ** repository. Sharable changes include public check-ins, edits to
254 ** wiki pages, tickets, and tech-notes, as well as forum content. Use
255 ** --private to also push private branches. Use the "configuration
256 ** push" command to push website configuration details.
257 **
258 ** If URL is not specified, then the URL from the most recent clone, push,
259 ** pull, remote-url, or sync command is used. See "fossil help clone" for
260 ** details on the URL formats.
261 **
262
--- src/sync.c
+++ src/sync.c
@@ -200,14 +200,13 @@
200 /*
201 ** COMMAND: pull
202 **
203 ** Usage: %fossil pull ?URL? ?options?
204 **
205 ** Pull all sharable changes from a remote repository into the local repository.
206 ** Sharable changes include public check-ins, and wiki, ticket, and tech-note
207 ** edits. Add the --private option to pull private branches. Use the
 
208 ** "configuration pull" command to pull website configuration details.
209 **
210 ** If URL is not specified, then the URL from the most recent clone, push,
211 ** pull, remote-url, or sync command is used. See "fossil help clone" for
212 ** details on the URL formats.
@@ -247,15 +246,14 @@
246 /*
247 ** COMMAND: push
248 **
249 ** Usage: %fossil push ?URL? ?options?
250 **
251 ** Push all sharable changes from the local repository to a remote repository.
252 ** Sharable changes include public check-ins, and wiki, ticket, and tech-note
253 ** edits. Use --private to also push private branches. Use the
254 ** "configuration push" command to push website configuration details.
 
255 **
256 ** If URL is not specified, then the URL from the most recent clone, push,
257 ** pull, remote-url, or sync command is used. See "fossil help clone" for
258 ** details on the URL formats.
259 **
260
+5 -7
--- src/tag.c
+++ src/tag.c
@@ -423,11 +423,10 @@
423423
** takes one of: propagated, singleton, cancel.
424424
**
425425
** Options:
426426
** --raw List tags raw names of tags
427427
** --tagtype TYPE List only tags of type TYPE
428
-** -v|--inverse Inverse the meaning of --tagtype TYPE.
429428
**
430429
** The option --raw allows the manipulation of all types of tags
431430
** used for various internal purposes in fossil. It also shows
432431
** "cancel" tags for the "find" and "list" subcommands. You should
433432
** not use this option to make changes unless you are sure what
@@ -549,13 +548,12 @@
549548
}
550549
}else
551550
552551
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
553552
Stmt q;
554
- const int fRaw = find_option("raw","",0)!=0;
553
+ int fRaw = find_option("raw","",0)!=0;
555554
const char *zTagType = find_option("tagtype","t",1);
556
- const int fInverse = find_option("inverse","v",0)!=0;
557555
int nTagType = fRaw ? -1 : 0;
558556
if( zTagType!=0 ){
559557
int l = strlen(zTagType);
560558
if( strncmp(zTagType,"cancel",l)==0 ){
561559
nTagType = 0;
@@ -570,13 +568,13 @@
570568
if( g.argc==3 ){
571569
db_prepare(&q,
572570
"SELECT tagname FROM tag"
573571
" WHERE EXISTS(SELECT 1 FROM tagxref"
574572
" WHERE tagid=tag.tagid"
575
- " AND tagtype%s%d)"
573
+ " AND tagtype%c%d)"
576574
" ORDER BY tagname",
577
- zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
575
+ zTagType!=0 ? '=' : '>',
578576
nTagType
579577
);
580578
while( db_step(&q)==SQLITE_ROW ){
581579
const char *zName = db_column_text(&q, 0);
582580
if( fRaw ){
@@ -589,14 +587,14 @@
589587
}else if( g.argc==4 ){
590588
int rid = name_to_rid(g.argv[3]);
591589
db_prepare(&q,
592590
"SELECT tagname, value FROM tagxref, tag"
593591
" WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
594
- " AND tagtype%s%d"
592
+ " AND tagtype%c%d"
595593
" ORDER BY tagname",
596594
rid,
597
- zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
595
+ zTagType!=0 ? '=' : '>',
598596
nTagType
599597
);
600598
while( db_step(&q)==SQLITE_ROW ){
601599
const char *zName = db_column_text(&q, 0);
602600
const char *zValue = db_column_text(&q, 1);
603601
--- src/tag.c
+++ src/tag.c
@@ -423,11 +423,10 @@
423 ** takes one of: propagated, singleton, cancel.
424 **
425 ** Options:
426 ** --raw List tags raw names of tags
427 ** --tagtype TYPE List only tags of type TYPE
428 ** -v|--inverse Inverse the meaning of --tagtype TYPE.
429 **
430 ** The option --raw allows the manipulation of all types of tags
431 ** used for various internal purposes in fossil. It also shows
432 ** "cancel" tags for the "find" and "list" subcommands. You should
433 ** not use this option to make changes unless you are sure what
@@ -549,13 +548,12 @@
549 }
550 }else
551
552 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
553 Stmt q;
554 const int fRaw = find_option("raw","",0)!=0;
555 const char *zTagType = find_option("tagtype","t",1);
556 const int fInverse = find_option("inverse","v",0)!=0;
557 int nTagType = fRaw ? -1 : 0;
558 if( zTagType!=0 ){
559 int l = strlen(zTagType);
560 if( strncmp(zTagType,"cancel",l)==0 ){
561 nTagType = 0;
@@ -570,13 +568,13 @@
570 if( g.argc==3 ){
571 db_prepare(&q,
572 "SELECT tagname FROM tag"
573 " WHERE EXISTS(SELECT 1 FROM tagxref"
574 " WHERE tagid=tag.tagid"
575 " AND tagtype%s%d)"
576 " ORDER BY tagname",
577 zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
578 nTagType
579 );
580 while( db_step(&q)==SQLITE_ROW ){
581 const char *zName = db_column_text(&q, 0);
582 if( fRaw ){
@@ -589,14 +587,14 @@
589 }else if( g.argc==4 ){
590 int rid = name_to_rid(g.argv[3]);
591 db_prepare(&q,
592 "SELECT tagname, value FROM tagxref, tag"
593 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
594 " AND tagtype%s%d"
595 " ORDER BY tagname",
596 rid,
597 zTagType!=0 ? (fInverse!=0?"<>":"=") : ">"/*safe-for-%s*/,
598 nTagType
599 );
600 while( db_step(&q)==SQLITE_ROW ){
601 const char *zName = db_column_text(&q, 0);
602 const char *zValue = db_column_text(&q, 1);
603
--- src/tag.c
+++ src/tag.c
@@ -423,11 +423,10 @@
423 ** takes one of: propagated, singleton, cancel.
424 **
425 ** Options:
426 ** --raw List tags raw names of tags
427 ** --tagtype TYPE List only tags of type TYPE
 
428 **
429 ** The option --raw allows the manipulation of all types of tags
430 ** used for various internal purposes in fossil. It also shows
431 ** "cancel" tags for the "find" and "list" subcommands. You should
432 ** not use this option to make changes unless you are sure what
@@ -549,13 +548,12 @@
548 }
549 }else
550
551 if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
552 Stmt q;
553 int fRaw = find_option("raw","",0)!=0;
554 const char *zTagType = find_option("tagtype","t",1);
 
555 int nTagType = fRaw ? -1 : 0;
556 if( zTagType!=0 ){
557 int l = strlen(zTagType);
558 if( strncmp(zTagType,"cancel",l)==0 ){
559 nTagType = 0;
@@ -570,13 +568,13 @@
568 if( g.argc==3 ){
569 db_prepare(&q,
570 "SELECT tagname FROM tag"
571 " WHERE EXISTS(SELECT 1 FROM tagxref"
572 " WHERE tagid=tag.tagid"
573 " AND tagtype%c%d)"
574 " ORDER BY tagname",
575 zTagType!=0 ? '=' : '>',
576 nTagType
577 );
578 while( db_step(&q)==SQLITE_ROW ){
579 const char *zName = db_column_text(&q, 0);
580 if( fRaw ){
@@ -589,14 +587,14 @@
587 }else if( g.argc==4 ){
588 int rid = name_to_rid(g.argv[3]);
589 db_prepare(&q,
590 "SELECT tagname, value FROM tagxref, tag"
591 " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid"
592 " AND tagtype%c%d"
593 " ORDER BY tagname",
594 rid,
595 zTagType!=0 ? '=' : '>',
596 nTagType
597 );
598 while( db_step(&q)==SQLITE_ROW ){
599 const char *zName = db_column_text(&q, 0);
600 const char *zValue = db_column_text(&q, 1);
601
--- src/th_main.c
+++ src/th_main.c
@@ -530,37 +530,10 @@
530530
}
531531
login_verify_csrf_secret();
532532
return TH_OK;
533533
}
534534
535
-/*
536
-** TH1 command: verifyLogin
537
-**
538
-** Returns non-zero if the specified user name and password represent a
539
-** valid login for the repository.
540
-*/
541
-static int verifyLoginCmd(
542
- Th_Interp *interp,
543
- void *p,
544
- int argc,
545
- const char **argv,
546
- int *argl
547
-){
548
- const char *zUser;
549
- const char *zPass;
550
- int uid;
551
- if( argc!=3 ){
552
- return Th_WrongNumArgs(interp, "verifyLogin userName password");
553
- }
554
- zUser = argv[1];
555
- zPass = argv[2];
556
- uid = login_search_uid(&zUser, zPass);
557
- Th_SetResultInt(interp, uid!=0);
558
- if( uid==0 ) sqlite3_sleep(100);
559
- return TH_OK;
560
-}
561
-
562535
/*
563536
** TH1 command: markdown STRING
564537
**
565538
** Renders the input string as markdown. The result is a two-element list.
566539
** The first element is the text-only title string. The second element
@@ -2138,11 +2111,10 @@
21382111
{"trace", traceCmd, 0},
21392112
{"stime", stimeCmd, 0},
21402113
{"unversioned", unversionedCmd, 0},
21412114
{"utime", utimeCmd, 0},
21422115
{"verifyCsrf", verifyCsrfCmd, 0},
2143
- {"verifyLogin", verifyLoginCmd, 0},
21442116
{"wiki", wikiCmd, (void*)&aFlags[0]},
21452117
{0, 0, 0}
21462118
};
21472119
if( g.thTrace ){
21482120
Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
21492121
--- src/th_main.c
+++ src/th_main.c
@@ -530,37 +530,10 @@
530 }
531 login_verify_csrf_secret();
532 return TH_OK;
533 }
534
535 /*
536 ** TH1 command: verifyLogin
537 **
538 ** Returns non-zero if the specified user name and password represent a
539 ** valid login for the repository.
540 */
541 static int verifyLoginCmd(
542 Th_Interp *interp,
543 void *p,
544 int argc,
545 const char **argv,
546 int *argl
547 ){
548 const char *zUser;
549 const char *zPass;
550 int uid;
551 if( argc!=3 ){
552 return Th_WrongNumArgs(interp, "verifyLogin userName password");
553 }
554 zUser = argv[1];
555 zPass = argv[2];
556 uid = login_search_uid(&zUser, zPass);
557 Th_SetResultInt(interp, uid!=0);
558 if( uid==0 ) sqlite3_sleep(100);
559 return TH_OK;
560 }
561
562 /*
563 ** TH1 command: markdown STRING
564 **
565 ** Renders the input string as markdown. The result is a two-element list.
566 ** The first element is the text-only title string. The second element
@@ -2138,11 +2111,10 @@
2138 {"trace", traceCmd, 0},
2139 {"stime", stimeCmd, 0},
2140 {"unversioned", unversionedCmd, 0},
2141 {"utime", utimeCmd, 0},
2142 {"verifyCsrf", verifyCsrfCmd, 0},
2143 {"verifyLogin", verifyLoginCmd, 0},
2144 {"wiki", wikiCmd, (void*)&aFlags[0]},
2145 {0, 0, 0}
2146 };
2147 if( g.thTrace ){
2148 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
2149
--- src/th_main.c
+++ src/th_main.c
@@ -530,37 +530,10 @@
530 }
531 login_verify_csrf_secret();
532 return TH_OK;
533 }
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535 /*
536 ** TH1 command: markdown STRING
537 **
538 ** Renders the input string as markdown. The result is a two-element list.
539 ** The first element is the text-only title string. The second element
@@ -2138,11 +2111,10 @@
2111 {"trace", traceCmd, 0},
2112 {"stime", stimeCmd, 0},
2113 {"unversioned", unversionedCmd, 0},
2114 {"utime", utimeCmd, 0},
2115 {"verifyCsrf", verifyCsrfCmd, 0},
 
2116 {"wiki", wikiCmd, (void*)&aFlags[0]},
2117 {0, 0, 0}
2118 };
2119 if( g.thTrace ){
2120 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
2121
+11 -41
--- src/timeline.c
+++ src/timeline.c
@@ -114,11 +114,10 @@
114114
#define TIMELINE_NOSCROLL 0x0100000 /* Don't scroll to the selection */
115115
#define TIMELINE_FILEDIFF 0x0200000 /* Show File differences, not ckin diffs */
116116
#define TIMELINE_CHPICK 0x0400000 /* Show cherrypick merges */
117117
#define TIMELINE_FILLGAPS 0x0800000 /* Dotted lines for missing nodes */
118118
#define TIMELINE_XMERGE 0x1000000 /* Omit merges from off-graph nodes */
119
-#define TIMELINE_NOTKT 0x2000000 /* Omit extra ticket classes */
120119
#endif
121120
122121
/*
123122
** Hash a string and use the hash to determine a background color.
124123
*/
@@ -325,11 +324,10 @@
325324
int modPending; /* Pending moderation */
326325
char *zDateLink; /* URL for the link on the timestamp */
327326
int drawDetailEllipsis; /* True to show ellipsis in place of detail */
328327
int gidx = 0; /* Graph row identifier */
329328
int isSelectedOrCurrent = 0; /* True if current row is selected */
330
- const char *zExtraClass = "";
331329
char zTime[20];
332330
333331
if( zDate==0 ){
334332
zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
335333
}
@@ -407,23 +405,10 @@
407405
@ <tr class="timelineCurrent">
408406
isSelectedOrCurrent = 1;
409407
}else {
410408
@ <tr>
411409
}
412
- if( zType[0]=='t' && tagid && (tmFlags & TIMELINE_NOTKT)==0 ){
413
- char *zTktid = db_text(0, "SELECT substr(tagname,5) FROM tag"
414
- " WHERE tagid=%d", tagid);
415
- if( zTktid ){
416
- int isClosed = 0;
417
- if( is_ticket(zTktid, &isClosed) && isClosed ){
418
- zExtraClass = " tktTlClosed";
419
- }else{
420
- zExtraClass = " tktTlOpen";
421
- }
422
- fossil_free(zTktid);
423
- }
424
- }
425410
if( zType[0]=='e' && tagid ){
426411
if( bTimestampLinksToInfo ){
427412
char *zId;
428413
zId = db_text(0, "SELECT substr(tagname, 7) FROM tag WHERE tagid=%d",
429414
tagid);
@@ -501,13 +486,13 @@
501486
gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
502487
@ <div id="m%d(gidx)" class="tl-nodemark"></div>
503488
}
504489
@</td>
505490
if( !isSelectedOrCurrent ){
506
- @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)" id='mc%d(gidx)'>
491
+ @ <td class="timeline%s(zStyle)Cell" id='mc%d(gidx)'>
507492
}else{
508
- @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)">
493
+ @ <td class="timeline%s(zStyle)Cell">
509494
}
510495
if( pGraph && zType[0]!='c' ){
511496
@ &bull;
512497
}
513498
if( modPending ){
@@ -558,17 +543,13 @@
558543
}
559544
}
560545
if( zType[0]!='c' ){
561546
/* Comments for anything other than a check-in are generated by
562547
** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
563
- if( zType[0]=='w' ){
564
- wiki_hyperlink_override(zUuid);
565
- wiki_convert(&comment, 0, WIKI_INLINE);
566
- wiki_hyperlink_override(0);
567
- }else{
568
- wiki_convert(&comment, 0, WIKI_INLINE);
569
- }
548
+ if( zType[0]=='w' ) wiki_hyperlink_override(zUuid);
549
+ wiki_convert(&comment, 0, WIKI_INLINE);
550
+ wiki_hyperlink_override(0);
570551
}else{
571552
if( bCommentGitStyle ){
572553
/* Truncate comment at first blank line */
573554
int ii, jj;
574555
int n = blob_size(&comment);
@@ -603,13 +584,13 @@
603584
@ <span class='timelineEllipsis' id='ellipsis-%d(rid)' \
604585
@ data-id='%d(rid)'>...</span>
605586
}
606587
if( tmFlags & TIMELINE_COLUMNAR ){
607588
if( !isSelectedOrCurrent ){
608
- @ <td class="timelineDetailCell%s(zExtraClass)" id='md%d(gidx)'>
589
+ @ <td class="timelineDetailCell" id='md%d(gidx)'>
609590
}else{
610
- @ <td class="timelineDetailCell%s(zExtraClass)">
591
+ @ <td class="timelineDetailCell">
611592
}
612593
}
613594
if( tmFlags & TIMELINE_COMPACT ){
614595
cgi_printf("<span class='clutter' id='detail-%d'>",rid);
615596
}
@@ -634,12 +615,11 @@
634615
cgi_printf("technote:&nbsp;");
635616
hyperlink_to_event_tagid(tagid<0?-tagid:tagid);
636617
}else{
637618
cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
638619
}
639
- }else if( zType[0]=='g' || zType[0]=='w' || zType[0]=='t'
640
- || zType[0]=='n' || zType[0]=='f'){
620
+ }else if( zType[0]=='g' || zType[0]=='w' || zType[0]=='t' || zType[0]=='f'){
641621
cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
642622
}
643623
644624
if( g.perm.Hyperlink && fossil_strcmp(zDispUser, zThisUser)!=0 ){
645625
char *zLink = mprintf("%R/timeline?u=%h&c=%t&y=a", zDispUser, zDate);
@@ -1165,11 +1145,11 @@
11651145
** set the y= parameter that determines which elements to display
11661146
** on the timeline.
11671147
*/
11681148
static void timeline_y_submenu(int isDisabled){
11691149
static int i = 0;
1170
- static const char *az[16];
1150
+ static const char *az[14];
11711151
if( i==0 ){
11721152
az[0] = "all";
11731153
az[1] = "Any Type";
11741154
i = 2;
11751155
if( g.perm.Read ){
@@ -1183,12 +1163,10 @@
11831163
az[i++] = "Tech Notes";
11841164
}
11851165
if( g.perm.RdTkt ){
11861166
az[i++] = "t";
11871167
az[i++] = "Tickets";
1188
- az[i++] = "n";
1189
- az[i++] = "New Tickets";
11901168
}
11911169
if( g.perm.RdWiki ){
11921170
az[i++] = "w";
11931171
az[i++] = "Wiki";
11941172
}
@@ -1538,11 +1516,11 @@
15381516
** rel Show related check-ins as well as those matching t=TAG
15391517
** mionly Limit rel to show ancestors but not descendants
15401518
** nowiki Do not show wiki associated with branch or tag
15411519
** ms=MATCHSTYLE Set tag match style to EXACT, GLOB, LIKE, REGEXP
15421520
** u=USER Only show items associated with USER
1543
-** y=TYPE 'ci', 'w', 't', 'n', 'e', 'f', or 'all'.
1521
+** y=TYPE 'ci', 'w', 't', 'e', 'f', or 'all'.
15441522
** ss=VIEWSTYLE c: "Compact" v: "Verbose" m: "Modern" j: "Columnar"
15451523
** advm Use the "Advanced" or "Busy" menu design.
15461524
** ng No Graph.
15471525
** ncp Omit cherrypick merges
15481526
** nd Do not highlight the focus check-in
@@ -2162,11 +2140,10 @@
21622140
}
21632141
}
21642142
}
21652143
if( (zType[0]=='w' && !g.perm.RdWiki)
21662144
|| (zType[0]=='t' && !g.perm.RdTkt)
2167
- || (zType[0]=='n' && !g.perm.RdTkt)
21682145
|| (zType[0]=='e' && !g.perm.RdWiki)
21692146
|| (zType[0]=='c' && !g.perm.Read)
21702147
|| (zType[0]=='g' && !g.perm.Read)
21712148
|| (zType[0]=='f' && !g.perm.RdForum)
21722149
){
@@ -2193,24 +2170,17 @@
21932170
cSep = ',';
21942171
}
21952172
blob_append_sql(&cond, ")");
21962173
}
21972174
}else{ /* zType!="all" */
2198
- if( zType[0]=='n' ){
2199
- blob_append_sql(&cond,
2200
- " AND event.type='t' AND event.comment GLOB 'New ticket*'");
2201
- }else{
2202
- blob_append_sql(&cond, " AND event.type=%Q", zType);
2203
- }
2175
+ blob_append_sql(&cond, " AND event.type=%Q", zType);
22042176
if( zType[0]=='c' ){
22052177
zEType = "check-in";
22062178
}else if( zType[0]=='w' ){
22072179
zEType = "wiki";
22082180
}else if( zType[0]=='t' ){
22092181
zEType = "ticket change";
2210
- }else if( zType[0]=='n' ){
2211
- zEType = "new tickets";
22122182
}else if( zType[0]=='e' ){
22132183
zEType = "technical note";
22142184
}else if( zType[0]=='g' ){
22152185
zEType = "tag";
22162186
}else if( zType[0]=='f' ){
22172187
--- src/timeline.c
+++ src/timeline.c
@@ -114,11 +114,10 @@
114 #define TIMELINE_NOSCROLL 0x0100000 /* Don't scroll to the selection */
115 #define TIMELINE_FILEDIFF 0x0200000 /* Show File differences, not ckin diffs */
116 #define TIMELINE_CHPICK 0x0400000 /* Show cherrypick merges */
117 #define TIMELINE_FILLGAPS 0x0800000 /* Dotted lines for missing nodes */
118 #define TIMELINE_XMERGE 0x1000000 /* Omit merges from off-graph nodes */
119 #define TIMELINE_NOTKT 0x2000000 /* Omit extra ticket classes */
120 #endif
121
122 /*
123 ** Hash a string and use the hash to determine a background color.
124 */
@@ -325,11 +324,10 @@
325 int modPending; /* Pending moderation */
326 char *zDateLink; /* URL for the link on the timestamp */
327 int drawDetailEllipsis; /* True to show ellipsis in place of detail */
328 int gidx = 0; /* Graph row identifier */
329 int isSelectedOrCurrent = 0; /* True if current row is selected */
330 const char *zExtraClass = "";
331 char zTime[20];
332
333 if( zDate==0 ){
334 zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
335 }
@@ -407,23 +405,10 @@
407 @ <tr class="timelineCurrent">
408 isSelectedOrCurrent = 1;
409 }else {
410 @ <tr>
411 }
412 if( zType[0]=='t' && tagid && (tmFlags & TIMELINE_NOTKT)==0 ){
413 char *zTktid = db_text(0, "SELECT substr(tagname,5) FROM tag"
414 " WHERE tagid=%d", tagid);
415 if( zTktid ){
416 int isClosed = 0;
417 if( is_ticket(zTktid, &isClosed) && isClosed ){
418 zExtraClass = " tktTlClosed";
419 }else{
420 zExtraClass = " tktTlOpen";
421 }
422 fossil_free(zTktid);
423 }
424 }
425 if( zType[0]=='e' && tagid ){
426 if( bTimestampLinksToInfo ){
427 char *zId;
428 zId = db_text(0, "SELECT substr(tagname, 7) FROM tag WHERE tagid=%d",
429 tagid);
@@ -501,13 +486,13 @@
501 gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
502 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
503 }
504 @</td>
505 if( !isSelectedOrCurrent ){
506 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)" id='mc%d(gidx)'>
507 }else{
508 @ <td class="timeline%s(zStyle)Cell%s(zExtraClass)">
509 }
510 if( pGraph && zType[0]!='c' ){
511 @ &bull;
512 }
513 if( modPending ){
@@ -558,17 +543,13 @@
558 }
559 }
560 if( zType[0]!='c' ){
561 /* Comments for anything other than a check-in are generated by
562 ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
563 if( zType[0]=='w' ){
564 wiki_hyperlink_override(zUuid);
565 wiki_convert(&comment, 0, WIKI_INLINE);
566 wiki_hyperlink_override(0);
567 }else{
568 wiki_convert(&comment, 0, WIKI_INLINE);
569 }
570 }else{
571 if( bCommentGitStyle ){
572 /* Truncate comment at first blank line */
573 int ii, jj;
574 int n = blob_size(&comment);
@@ -603,13 +584,13 @@
603 @ <span class='timelineEllipsis' id='ellipsis-%d(rid)' \
604 @ data-id='%d(rid)'>...</span>
605 }
606 if( tmFlags & TIMELINE_COLUMNAR ){
607 if( !isSelectedOrCurrent ){
608 @ <td class="timelineDetailCell%s(zExtraClass)" id='md%d(gidx)'>
609 }else{
610 @ <td class="timelineDetailCell%s(zExtraClass)">
611 }
612 }
613 if( tmFlags & TIMELINE_COMPACT ){
614 cgi_printf("<span class='clutter' id='detail-%d'>",rid);
615 }
@@ -634,12 +615,11 @@
634 cgi_printf("technote:&nbsp;");
635 hyperlink_to_event_tagid(tagid<0?-tagid:tagid);
636 }else{
637 cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
638 }
639 }else if( zType[0]=='g' || zType[0]=='w' || zType[0]=='t'
640 || zType[0]=='n' || zType[0]=='f'){
641 cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
642 }
643
644 if( g.perm.Hyperlink && fossil_strcmp(zDispUser, zThisUser)!=0 ){
645 char *zLink = mprintf("%R/timeline?u=%h&c=%t&y=a", zDispUser, zDate);
@@ -1165,11 +1145,11 @@
1165 ** set the y= parameter that determines which elements to display
1166 ** on the timeline.
1167 */
1168 static void timeline_y_submenu(int isDisabled){
1169 static int i = 0;
1170 static const char *az[16];
1171 if( i==0 ){
1172 az[0] = "all";
1173 az[1] = "Any Type";
1174 i = 2;
1175 if( g.perm.Read ){
@@ -1183,12 +1163,10 @@
1183 az[i++] = "Tech Notes";
1184 }
1185 if( g.perm.RdTkt ){
1186 az[i++] = "t";
1187 az[i++] = "Tickets";
1188 az[i++] = "n";
1189 az[i++] = "New Tickets";
1190 }
1191 if( g.perm.RdWiki ){
1192 az[i++] = "w";
1193 az[i++] = "Wiki";
1194 }
@@ -1538,11 +1516,11 @@
1538 ** rel Show related check-ins as well as those matching t=TAG
1539 ** mionly Limit rel to show ancestors but not descendants
1540 ** nowiki Do not show wiki associated with branch or tag
1541 ** ms=MATCHSTYLE Set tag match style to EXACT, GLOB, LIKE, REGEXP
1542 ** u=USER Only show items associated with USER
1543 ** y=TYPE 'ci', 'w', 't', 'n', 'e', 'f', or 'all'.
1544 ** ss=VIEWSTYLE c: "Compact" v: "Verbose" m: "Modern" j: "Columnar"
1545 ** advm Use the "Advanced" or "Busy" menu design.
1546 ** ng No Graph.
1547 ** ncp Omit cherrypick merges
1548 ** nd Do not highlight the focus check-in
@@ -2162,11 +2140,10 @@
2162 }
2163 }
2164 }
2165 if( (zType[0]=='w' && !g.perm.RdWiki)
2166 || (zType[0]=='t' && !g.perm.RdTkt)
2167 || (zType[0]=='n' && !g.perm.RdTkt)
2168 || (zType[0]=='e' && !g.perm.RdWiki)
2169 || (zType[0]=='c' && !g.perm.Read)
2170 || (zType[0]=='g' && !g.perm.Read)
2171 || (zType[0]=='f' && !g.perm.RdForum)
2172 ){
@@ -2193,24 +2170,17 @@
2193 cSep = ',';
2194 }
2195 blob_append_sql(&cond, ")");
2196 }
2197 }else{ /* zType!="all" */
2198 if( zType[0]=='n' ){
2199 blob_append_sql(&cond,
2200 " AND event.type='t' AND event.comment GLOB 'New ticket*'");
2201 }else{
2202 blob_append_sql(&cond, " AND event.type=%Q", zType);
2203 }
2204 if( zType[0]=='c' ){
2205 zEType = "check-in";
2206 }else if( zType[0]=='w' ){
2207 zEType = "wiki";
2208 }else if( zType[0]=='t' ){
2209 zEType = "ticket change";
2210 }else if( zType[0]=='n' ){
2211 zEType = "new tickets";
2212 }else if( zType[0]=='e' ){
2213 zEType = "technical note";
2214 }else if( zType[0]=='g' ){
2215 zEType = "tag";
2216 }else if( zType[0]=='f' ){
2217
--- src/timeline.c
+++ src/timeline.c
@@ -114,11 +114,10 @@
114 #define TIMELINE_NOSCROLL 0x0100000 /* Don't scroll to the selection */
115 #define TIMELINE_FILEDIFF 0x0200000 /* Show File differences, not ckin diffs */
116 #define TIMELINE_CHPICK 0x0400000 /* Show cherrypick merges */
117 #define TIMELINE_FILLGAPS 0x0800000 /* Dotted lines for missing nodes */
118 #define TIMELINE_XMERGE 0x1000000 /* Omit merges from off-graph nodes */
 
119 #endif
120
121 /*
122 ** Hash a string and use the hash to determine a background color.
123 */
@@ -325,11 +324,10 @@
324 int modPending; /* Pending moderation */
325 char *zDateLink; /* URL for the link on the timestamp */
326 int drawDetailEllipsis; /* True to show ellipsis in place of detail */
327 int gidx = 0; /* Graph row identifier */
328 int isSelectedOrCurrent = 0; /* True if current row is selected */
 
329 char zTime[20];
330
331 if( zDate==0 ){
332 zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
333 }
@@ -407,23 +405,10 @@
405 @ <tr class="timelineCurrent">
406 isSelectedOrCurrent = 1;
407 }else {
408 @ <tr>
409 }
 
 
 
 
 
 
 
 
 
 
 
 
 
410 if( zType[0]=='e' && tagid ){
411 if( bTimestampLinksToInfo ){
412 char *zId;
413 zId = db_text(0, "SELECT substr(tagname, 7) FROM tag WHERE tagid=%d",
414 tagid);
@@ -501,13 +486,13 @@
486 gidx = graph_add_row(pGraph, rid, -1, 0, 0, zBr, zBgClr, zUuid, 0);
487 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
488 }
489 @</td>
490 if( !isSelectedOrCurrent ){
491 @ <td class="timeline%s(zStyle)Cell" id='mc%d(gidx)'>
492 }else{
493 @ <td class="timeline%s(zStyle)Cell">
494 }
495 if( pGraph && zType[0]!='c' ){
496 @ &bull;
497 }
498 if( modPending ){
@@ -558,17 +543,13 @@
543 }
544 }
545 if( zType[0]!='c' ){
546 /* Comments for anything other than a check-in are generated by
547 ** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
548 if( zType[0]=='w' ) wiki_hyperlink_override(zUuid);
549 wiki_convert(&comment, 0, WIKI_INLINE);
550 wiki_hyperlink_override(0);
 
 
 
 
551 }else{
552 if( bCommentGitStyle ){
553 /* Truncate comment at first blank line */
554 int ii, jj;
555 int n = blob_size(&comment);
@@ -603,13 +584,13 @@
584 @ <span class='timelineEllipsis' id='ellipsis-%d(rid)' \
585 @ data-id='%d(rid)'>...</span>
586 }
587 if( tmFlags & TIMELINE_COLUMNAR ){
588 if( !isSelectedOrCurrent ){
589 @ <td class="timelineDetailCell" id='md%d(gidx)'>
590 }else{
591 @ <td class="timelineDetailCell">
592 }
593 }
594 if( tmFlags & TIMELINE_COMPACT ){
595 cgi_printf("<span class='clutter' id='detail-%d'>",rid);
596 }
@@ -634,12 +615,11 @@
615 cgi_printf("technote:&nbsp;");
616 hyperlink_to_event_tagid(tagid<0?-tagid:tagid);
617 }else{
618 cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
619 }
620 }else if( zType[0]=='g' || zType[0]=='w' || zType[0]=='t' || zType[0]=='f'){
 
621 cgi_printf("artifact:&nbsp;%z%S</a> ",href("%R/info/%!S",zUuid),zUuid);
622 }
623
624 if( g.perm.Hyperlink && fossil_strcmp(zDispUser, zThisUser)!=0 ){
625 char *zLink = mprintf("%R/timeline?u=%h&c=%t&y=a", zDispUser, zDate);
@@ -1165,11 +1145,11 @@
1145 ** set the y= parameter that determines which elements to display
1146 ** on the timeline.
1147 */
1148 static void timeline_y_submenu(int isDisabled){
1149 static int i = 0;
1150 static const char *az[14];
1151 if( i==0 ){
1152 az[0] = "all";
1153 az[1] = "Any Type";
1154 i = 2;
1155 if( g.perm.Read ){
@@ -1183,12 +1163,10 @@
1163 az[i++] = "Tech Notes";
1164 }
1165 if( g.perm.RdTkt ){
1166 az[i++] = "t";
1167 az[i++] = "Tickets";
 
 
1168 }
1169 if( g.perm.RdWiki ){
1170 az[i++] = "w";
1171 az[i++] = "Wiki";
1172 }
@@ -1538,11 +1516,11 @@
1516 ** rel Show related check-ins as well as those matching t=TAG
1517 ** mionly Limit rel to show ancestors but not descendants
1518 ** nowiki Do not show wiki associated with branch or tag
1519 ** ms=MATCHSTYLE Set tag match style to EXACT, GLOB, LIKE, REGEXP
1520 ** u=USER Only show items associated with USER
1521 ** y=TYPE 'ci', 'w', 't', 'e', 'f', or 'all'.
1522 ** ss=VIEWSTYLE c: "Compact" v: "Verbose" m: "Modern" j: "Columnar"
1523 ** advm Use the "Advanced" or "Busy" menu design.
1524 ** ng No Graph.
1525 ** ncp Omit cherrypick merges
1526 ** nd Do not highlight the focus check-in
@@ -2162,11 +2140,10 @@
2140 }
2141 }
2142 }
2143 if( (zType[0]=='w' && !g.perm.RdWiki)
2144 || (zType[0]=='t' && !g.perm.RdTkt)
 
2145 || (zType[0]=='e' && !g.perm.RdWiki)
2146 || (zType[0]=='c' && !g.perm.Read)
2147 || (zType[0]=='g' && !g.perm.Read)
2148 || (zType[0]=='f' && !g.perm.RdForum)
2149 ){
@@ -2193,24 +2170,17 @@
2170 cSep = ',';
2171 }
2172 blob_append_sql(&cond, ")");
2173 }
2174 }else{ /* zType!="all" */
2175 blob_append_sql(&cond, " AND event.type=%Q", zType);
 
 
 
 
 
2176 if( zType[0]=='c' ){
2177 zEType = "check-in";
2178 }else if( zType[0]=='w' ){
2179 zEType = "wiki";
2180 }else if( zType[0]=='t' ){
2181 zEType = "ticket change";
 
 
2182 }else if( zType[0]=='e' ){
2183 zEType = "technical note";
2184 }else if( zType[0]=='g' ){
2185 zEType = "tag";
2186 }else if( zType[0]=='f' ){
2187
+33 -60
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364364
365365
/*
366366
** Recreate the TICKET and TICKETCHNG tables.
367367
*/
368368
void ticket_create_table(int separateConnection){
369
- char *zSql;
369
+ const char *zSql;
370370
371371
db_multi_exec(
372372
"DROP TABLE IF EXISTS ticket;"
373373
"DROP TABLE IF EXISTS ticketchng;"
374374
);
@@ -377,11 +377,10 @@
377377
if( db_transaction_nesting_depth() ) db_end_transaction(0);
378378
db_init_database(g.zRepositoryName, zSql, 0);
379379
}else{
380380
db_multi_exec("%s", zSql/*safe-for-%s*/);
381381
}
382
- fossil_free(zSql);
383382
}
384383
385384
/*
386385
** Repopulate the TICKET and TICKETCHNG tables from scratch using all
387386
** available ticket artifacts.
@@ -445,30 +444,27 @@
445444
@ </ul></div>
446445
}
447446
448447
/*
449448
** WEBPAGE: tktview
450
-** URL: tktview?name=HASH
449
+** URL: tktview?name=UUID
451450
**
452451
** View a ticket identified by the name= query parameter.
453
-** Other query parameters:
454
-**
455
-** tl Show a timeline of the ticket above the status
456452
*/
457453
void tktview_page(void){
458454
const char *zScript;
459455
char *zFullName;
460456
const char *zUuid = PD("name","");
461
- int showTimeline = P("tl")!=0;
462457
463458
login_check_credentials();
464459
if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
465460
if( g.anon.WrTkt || g.anon.ApndTkt ){
466461
style_submenu_element("Edit", "%s/tktedit?name=%T", g.zTop, PD("name",""));
467462
}
468463
if( g.perm.Hyperlink ){
469464
style_submenu_element("History", "%s/tkthistory/%T", g.zTop, zUuid);
465
+ style_submenu_element("Timeline", "%s/tkttimeline/%T", g.zTop, zUuid);
470466
style_submenu_element("Check-ins", "%s/tkttimeline/%T?y=ci", g.zTop, zUuid);
471467
}
472468
if( g.anon.NewTkt ){
473469
style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
474470
}
@@ -480,23 +476,10 @@
480476
style_submenu_element("Formatted", "%R/tktview/%s", zUuid);
481477
}else{
482478
style_submenu_element("Plaintext", "%R/tktview/%s?plaintext", zUuid);
483479
}
484480
style_header("View Ticket");
485
- if( showTimeline ){
486
- int tagid = db_int(0,"SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
487
- zUuid);
488
- if( tagid ){
489
- tkt_draw_timeline(tagid, "a");
490
- @ <hr>
491
- }else{
492
- showTimeline = 0;
493
- }
494
- }
495
- if( !showTimeline && g.perm.Hyperlink ){
496
- style_submenu_element("Timeline", "%s/info/%T", g.zTop, zUuid);
497
- }
498481
if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1);
499482
ticket_init();
500483
initializeVariablesFromCGI();
501484
getAllTicketFields();
502485
initializeVariablesFromDb();
@@ -842,58 +825,22 @@
842825
sqlite3_close(db);
843826
}
844827
return zErr;
845828
}
846829
847
-/*
848
-** Draw a timeline for a ticket with tag.tagid given by the tagid
849
-** parameter.
850
-*/
851
-void tkt_draw_timeline(int tagid, const char *zType){
852
- Stmt q;
853
- char *zFullUuid;
854
- char *zSQL;
855
- zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d",
856
- tagid);
857
- if( zType[0]=='c' ){
858
- zSQL = mprintf(
859
- "%s AND event.objid IN "
860
- " (SELECT srcid FROM backlink WHERE target GLOB '%.4s*' "
861
- "AND '%s' GLOB (target||'*')) "
862
- "ORDER BY mtime DESC",
863
- timeline_query_for_www(), zFullUuid, zFullUuid
864
- );
865
- }else{
866
- zSQL = mprintf(
867
- "%s AND event.objid IN "
868
- " (SELECT rid FROM tagxref WHERE tagid=%d"
869
- " UNION SELECT srcid FROM backlink"
870
- " WHERE target GLOB '%.4s*'"
871
- " AND '%s' GLOB (target||'*')"
872
- " UNION SELECT attachid FROM attachment"
873
- " WHERE target=%Q) "
874
- "ORDER BY mtime DESC",
875
- timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
876
- );
877
- }
878
- db_prepare(&q, "%z", zSQL/*safe-for-%s*/);
879
- www_print_timeline(&q,
880
- TIMELINE_ARTID | TIMELINE_DISJOINT | TIMELINE_GRAPH | TIMELINE_NOTKT,
881
- 0, 0, 0, 0, 0, 0);
882
- db_finalize(&q);
883
- fossil_free(zFullUuid);
884
-}
885
-
886830
/*
887831
** WEBPAGE: tkttimeline
888832
** URL: /tkttimeline?name=TICKETUUID&y=TYPE
889833
**
890834
** Show the change history for a single ticket in timeline format.
891835
*/
892836
void tkttimeline_page(void){
837
+ Stmt q;
893838
char *zTitle;
839
+ char *zSQL;
894840
const char *zUuid;
841
+ char *zFullUuid;
895842
int tagid;
896843
char zGlobPattern[50];
897844
const char *zType;
898845
899846
login_check_credentials();
@@ -924,11 +871,37 @@
924871
if( tagid==0 ){
925872
@ No such ticket: %h(zUuid)
926873
style_footer();
927874
return;
928875
}
929
- tkt_draw_timeline(tagid, zType);
876
+ zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d",
877
+ tagid);
878
+ if( zType[0]=='c' ){
879
+ zSQL = mprintf(
880
+ "%s AND event.objid IN "
881
+ " (SELECT srcid FROM backlink WHERE target GLOB '%.4s*' "
882
+ "AND '%s' GLOB (target||'*')) "
883
+ "ORDER BY mtime DESC",
884
+ timeline_query_for_www(), zFullUuid, zFullUuid
885
+ );
886
+ }else{
887
+ zSQL = mprintf(
888
+ "%s AND event.objid IN "
889
+ " (SELECT rid FROM tagxref WHERE tagid=%d"
890
+ " UNION SELECT srcid FROM backlink"
891
+ " WHERE target GLOB '%.4s*'"
892
+ " AND '%s' GLOB (target||'*')"
893
+ " UNION SELECT attachid FROM attachment"
894
+ " WHERE target=%Q) "
895
+ "ORDER BY mtime DESC",
896
+ timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
897
+ );
898
+ }
899
+ db_prepare(&q, "%z", zSQL/*safe-for-%s*/);
900
+ www_print_timeline(&q, TIMELINE_ARTID|TIMELINE_DISJOINT|TIMELINE_GRAPH,
901
+ 0, 0, 0, 0, 0, 0);
902
+ db_finalize(&q);
930903
style_footer();
931904
}
932905
933906
/*
934907
** WEBPAGE: tkthistory
935908
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364
365 /*
366 ** Recreate the TICKET and TICKETCHNG tables.
367 */
368 void ticket_create_table(int separateConnection){
369 char *zSql;
370
371 db_multi_exec(
372 "DROP TABLE IF EXISTS ticket;"
373 "DROP TABLE IF EXISTS ticketchng;"
374 );
@@ -377,11 +377,10 @@
377 if( db_transaction_nesting_depth() ) db_end_transaction(0);
378 db_init_database(g.zRepositoryName, zSql, 0);
379 }else{
380 db_multi_exec("%s", zSql/*safe-for-%s*/);
381 }
382 fossil_free(zSql);
383 }
384
385 /*
386 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
387 ** available ticket artifacts.
@@ -445,30 +444,27 @@
445 @ </ul></div>
446 }
447
448 /*
449 ** WEBPAGE: tktview
450 ** URL: tktview?name=HASH
451 **
452 ** View a ticket identified by the name= query parameter.
453 ** Other query parameters:
454 **
455 ** tl Show a timeline of the ticket above the status
456 */
457 void tktview_page(void){
458 const char *zScript;
459 char *zFullName;
460 const char *zUuid = PD("name","");
461 int showTimeline = P("tl")!=0;
462
463 login_check_credentials();
464 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
465 if( g.anon.WrTkt || g.anon.ApndTkt ){
466 style_submenu_element("Edit", "%s/tktedit?name=%T", g.zTop, PD("name",""));
467 }
468 if( g.perm.Hyperlink ){
469 style_submenu_element("History", "%s/tkthistory/%T", g.zTop, zUuid);
 
470 style_submenu_element("Check-ins", "%s/tkttimeline/%T?y=ci", g.zTop, zUuid);
471 }
472 if( g.anon.NewTkt ){
473 style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
474 }
@@ -480,23 +476,10 @@
480 style_submenu_element("Formatted", "%R/tktview/%s", zUuid);
481 }else{
482 style_submenu_element("Plaintext", "%R/tktview/%s?plaintext", zUuid);
483 }
484 style_header("View Ticket");
485 if( showTimeline ){
486 int tagid = db_int(0,"SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
487 zUuid);
488 if( tagid ){
489 tkt_draw_timeline(tagid, "a");
490 @ <hr>
491 }else{
492 showTimeline = 0;
493 }
494 }
495 if( !showTimeline && g.perm.Hyperlink ){
496 style_submenu_element("Timeline", "%s/info/%T", g.zTop, zUuid);
497 }
498 if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1);
499 ticket_init();
500 initializeVariablesFromCGI();
501 getAllTicketFields();
502 initializeVariablesFromDb();
@@ -842,58 +825,22 @@
842 sqlite3_close(db);
843 }
844 return zErr;
845 }
846
847 /*
848 ** Draw a timeline for a ticket with tag.tagid given by the tagid
849 ** parameter.
850 */
851 void tkt_draw_timeline(int tagid, const char *zType){
852 Stmt q;
853 char *zFullUuid;
854 char *zSQL;
855 zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d",
856 tagid);
857 if( zType[0]=='c' ){
858 zSQL = mprintf(
859 "%s AND event.objid IN "
860 " (SELECT srcid FROM backlink WHERE target GLOB '%.4s*' "
861 "AND '%s' GLOB (target||'*')) "
862 "ORDER BY mtime DESC",
863 timeline_query_for_www(), zFullUuid, zFullUuid
864 );
865 }else{
866 zSQL = mprintf(
867 "%s AND event.objid IN "
868 " (SELECT rid FROM tagxref WHERE tagid=%d"
869 " UNION SELECT srcid FROM backlink"
870 " WHERE target GLOB '%.4s*'"
871 " AND '%s' GLOB (target||'*')"
872 " UNION SELECT attachid FROM attachment"
873 " WHERE target=%Q) "
874 "ORDER BY mtime DESC",
875 timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
876 );
877 }
878 db_prepare(&q, "%z", zSQL/*safe-for-%s*/);
879 www_print_timeline(&q,
880 TIMELINE_ARTID | TIMELINE_DISJOINT | TIMELINE_GRAPH | TIMELINE_NOTKT,
881 0, 0, 0, 0, 0, 0);
882 db_finalize(&q);
883 fossil_free(zFullUuid);
884 }
885
886 /*
887 ** WEBPAGE: tkttimeline
888 ** URL: /tkttimeline?name=TICKETUUID&y=TYPE
889 **
890 ** Show the change history for a single ticket in timeline format.
891 */
892 void tkttimeline_page(void){
 
893 char *zTitle;
 
894 const char *zUuid;
 
895 int tagid;
896 char zGlobPattern[50];
897 const char *zType;
898
899 login_check_credentials();
@@ -924,11 +871,37 @@
924 if( tagid==0 ){
925 @ No such ticket: %h(zUuid)
926 style_footer();
927 return;
928 }
929 tkt_draw_timeline(tagid, zType);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
930 style_footer();
931 }
932
933 /*
934 ** WEBPAGE: tkthistory
935
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364
365 /*
366 ** Recreate the TICKET and TICKETCHNG tables.
367 */
368 void ticket_create_table(int separateConnection){
369 const char *zSql;
370
371 db_multi_exec(
372 "DROP TABLE IF EXISTS ticket;"
373 "DROP TABLE IF EXISTS ticketchng;"
374 );
@@ -377,11 +377,10 @@
377 if( db_transaction_nesting_depth() ) db_end_transaction(0);
378 db_init_database(g.zRepositoryName, zSql, 0);
379 }else{
380 db_multi_exec("%s", zSql/*safe-for-%s*/);
381 }
 
382 }
383
384 /*
385 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
386 ** available ticket artifacts.
@@ -445,30 +444,27 @@
444 @ </ul></div>
445 }
446
447 /*
448 ** WEBPAGE: tktview
449 ** URL: tktview?name=UUID
450 **
451 ** View a ticket identified by the name= query parameter.
 
 
 
452 */
453 void tktview_page(void){
454 const char *zScript;
455 char *zFullName;
456 const char *zUuid = PD("name","");
 
457
458 login_check_credentials();
459 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
460 if( g.anon.WrTkt || g.anon.ApndTkt ){
461 style_submenu_element("Edit", "%s/tktedit?name=%T", g.zTop, PD("name",""));
462 }
463 if( g.perm.Hyperlink ){
464 style_submenu_element("History", "%s/tkthistory/%T", g.zTop, zUuid);
465 style_submenu_element("Timeline", "%s/tkttimeline/%T", g.zTop, zUuid);
466 style_submenu_element("Check-ins", "%s/tkttimeline/%T?y=ci", g.zTop, zUuid);
467 }
468 if( g.anon.NewTkt ){
469 style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
470 }
@@ -480,23 +476,10 @@
476 style_submenu_element("Formatted", "%R/tktview/%s", zUuid);
477 }else{
478 style_submenu_element("Plaintext", "%R/tktview/%s?plaintext", zUuid);
479 }
480 style_header("View Ticket");
 
 
 
 
 
 
 
 
 
 
 
 
 
481 if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1);
482 ticket_init();
483 initializeVariablesFromCGI();
484 getAllTicketFields();
485 initializeVariablesFromDb();
@@ -842,58 +825,22 @@
825 sqlite3_close(db);
826 }
827 return zErr;
828 }
829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
830 /*
831 ** WEBPAGE: tkttimeline
832 ** URL: /tkttimeline?name=TICKETUUID&y=TYPE
833 **
834 ** Show the change history for a single ticket in timeline format.
835 */
836 void tkttimeline_page(void){
837 Stmt q;
838 char *zTitle;
839 char *zSQL;
840 const char *zUuid;
841 char *zFullUuid;
842 int tagid;
843 char zGlobPattern[50];
844 const char *zType;
845
846 login_check_credentials();
@@ -924,11 +871,37 @@
871 if( tagid==0 ){
872 @ No such ticket: %h(zUuid)
873 style_footer();
874 return;
875 }
876 zFullUuid = db_text(0, "SELECT substr(tagname, 5) FROM tag WHERE tagid=%d",
877 tagid);
878 if( zType[0]=='c' ){
879 zSQL = mprintf(
880 "%s AND event.objid IN "
881 " (SELECT srcid FROM backlink WHERE target GLOB '%.4s*' "
882 "AND '%s' GLOB (target||'*')) "
883 "ORDER BY mtime DESC",
884 timeline_query_for_www(), zFullUuid, zFullUuid
885 );
886 }else{
887 zSQL = mprintf(
888 "%s AND event.objid IN "
889 " (SELECT rid FROM tagxref WHERE tagid=%d"
890 " UNION SELECT srcid FROM backlink"
891 " WHERE target GLOB '%.4s*'"
892 " AND '%s' GLOB (target||'*')"
893 " UNION SELECT attachid FROM attachment"
894 " WHERE target=%Q) "
895 "ORDER BY mtime DESC",
896 timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
897 );
898 }
899 db_prepare(&q, "%z", zSQL/*safe-for-%s*/);
900 www_print_timeline(&q, TIMELINE_ARTID|TIMELINE_DISJOINT|TIMELINE_GRAPH,
901 0, 0, 0, 0, 0, 0);
902 db_finalize(&q);
903 style_footer();
904 }
905
906 /*
907 ** WEBPAGE: tkthistory
908
+5 -9
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,14 +96,13 @@
9696
@ );
9797
@ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
9898
;
9999
100100
/*
101
-** Return the ticket table definition in heap-allocated
102
-** memory owned by the caller.
101
+** Return the ticket table definition
103102
*/
104
-char *ticket_table_schema(void){
103
+const char *ticket_table_schema(void){
105104
return db_get("ticket-table", zDefaultTicketTable);
106105
}
107106
108107
/*
109108
** Common implementation for the ticket setup editor pages.
@@ -910,26 +909,23 @@
910909
911910
@ <hr />
912911
entry_attribute("Ticket Title", 40, "ticket-title-expr", "t",
913912
"title", 0);
914913
@ <p>An SQL expression in a query against the TICKET table that will
915
- @ return the title of the ticket for display purposes.
916
- @ (Property: ticket-title-expr)</p>
914
+ @ return the title of the ticket for display purposes.</p>
917915
918916
@ <hr />
919917
entry_attribute("Ticket Status", 40, "ticket-status-column", "s",
920918
"status", 0);
921919
@ <p>The name of the column in the TICKET table that contains the ticket
922
- @ status in human-readable form. Case sensitive.
923
- @ (Property: ticket-status-column)</p>
920
+ @ status in human-readable form. Case sensitive.</p>
924921
925922
@ <hr />
926923
entry_attribute("Ticket Closed", 40, "ticket-closed-expr", "c",
927924
"status='Closed'", 0);
928925
@ <p>An SQL expression that evaluates to true in a TICKET table query if
929
- @ the ticket is closed.
930
- @ (Property: ticket-closed-expr)</p>
926
+ @ the ticket is closed.</p>
931927
932928
@ <hr />
933929
@ <p>
934930
@ <input type="submit" name="submit" value="Apply Changes" />
935931
@ <input type="submit" name="setup" value="Cancel" />
936932
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,14 +96,13 @@
96 @ );
97 @ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
98 ;
99
100 /*
101 ** Return the ticket table definition in heap-allocated
102 ** memory owned by the caller.
103 */
104 char *ticket_table_schema(void){
105 return db_get("ticket-table", zDefaultTicketTable);
106 }
107
108 /*
109 ** Common implementation for the ticket setup editor pages.
@@ -910,26 +909,23 @@
910
911 @ <hr />
912 entry_attribute("Ticket Title", 40, "ticket-title-expr", "t",
913 "title", 0);
914 @ <p>An SQL expression in a query against the TICKET table that will
915 @ return the title of the ticket for display purposes.
916 @ (Property: ticket-title-expr)</p>
917
918 @ <hr />
919 entry_attribute("Ticket Status", 40, "ticket-status-column", "s",
920 "status", 0);
921 @ <p>The name of the column in the TICKET table that contains the ticket
922 @ status in human-readable form. Case sensitive.
923 @ (Property: ticket-status-column)</p>
924
925 @ <hr />
926 entry_attribute("Ticket Closed", 40, "ticket-closed-expr", "c",
927 "status='Closed'", 0);
928 @ <p>An SQL expression that evaluates to true in a TICKET table query if
929 @ the ticket is closed.
930 @ (Property: ticket-closed-expr)</p>
931
932 @ <hr />
933 @ <p>
934 @ <input type="submit" name="submit" value="Apply Changes" />
935 @ <input type="submit" name="setup" value="Cancel" />
936
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,14 +96,13 @@
96 @ );
97 @ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
98 ;
99
100 /*
101 ** Return the ticket table definition
 
102 */
103 const char *ticket_table_schema(void){
104 return db_get("ticket-table", zDefaultTicketTable);
105 }
106
107 /*
108 ** Common implementation for the ticket setup editor pages.
@@ -910,26 +909,23 @@
909
910 @ <hr />
911 entry_attribute("Ticket Title", 40, "ticket-title-expr", "t",
912 "title", 0);
913 @ <p>An SQL expression in a query against the TICKET table that will
914 @ return the title of the ticket for display purposes.</p>
 
915
916 @ <hr />
917 entry_attribute("Ticket Status", 40, "ticket-status-column", "s",
918 "status", 0);
919 @ <p>The name of the column in the TICKET table that contains the ticket
920 @ status in human-readable form. Case sensitive.</p>
 
921
922 @ <hr />
923 entry_attribute("Ticket Closed", 40, "ticket-closed-expr", "c",
924 "status='Closed'", 0);
925 @ <p>An SQL expression that evaluates to true in a TICKET table query if
926 @ the ticket is closed.</p>
 
927
928 @ <hr />
929 @ <p>
930 @ <input type="submit" name="submit" value="Apply Changes" />
931 @ <input type="submit" name="setup" value="Cancel" />
932
+1 -1
--- src/verify.c
+++ src/verify.c
@@ -68,11 +68,11 @@
6868
** Invoke verify_rid() on every record that has been added or modified
6969
** in the repository, in order to make sure that the repository is sane.
7070
*/
7171
static int verify_at_commit(void){
7272
int rid;
73
- content_clear_cache(0);
73
+ content_clear_cache();
7474
inFinalVerify = 1;
7575
rid = bag_first(&toVerify);
7676
while( rid>0 ){
7777
verify_rid(rid);
7878
rid = bag_next(&toVerify, rid);
7979
--- src/verify.c
+++ src/verify.c
@@ -68,11 +68,11 @@
68 ** Invoke verify_rid() on every record that has been added or modified
69 ** in the repository, in order to make sure that the repository is sane.
70 */
71 static int verify_at_commit(void){
72 int rid;
73 content_clear_cache(0);
74 inFinalVerify = 1;
75 rid = bag_first(&toVerify);
76 while( rid>0 ){
77 verify_rid(rid);
78 rid = bag_next(&toVerify, rid);
79
--- src/verify.c
+++ src/verify.c
@@ -68,11 +68,11 @@
68 ** Invoke verify_rid() on every record that has been added or modified
69 ** in the repository, in order to make sure that the repository is sane.
70 */
71 static int verify_at_commit(void){
72 int rid;
73 content_clear_cache();
74 inFinalVerify = 1;
75 rid = bag_first(&toVerify);
76 while( rid>0 ){
77 verify_rid(rid);
78 rid = bag_next(&toVerify, rid);
79
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1100,11 +1100,11 @@
11001100
** zTarget is guaranteed to be a UUID. It might be the UUID of a ticket.
11011101
** If it is, store in *pClosed a true or false depending on whether or not
11021102
** the ticket is closed and return true. If zTarget
11031103
** is not the UUID of a ticket, return false.
11041104
*/
1105
-int is_ticket(
1105
+static int is_ticket(
11061106
const char *zTarget, /* Ticket UUID */
11071107
int *pClosed /* True if the ticket is closed */
11081108
){
11091109
static Stmt q;
11101110
int n;
11111111
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1100,11 +1100,11 @@
1100 ** zTarget is guaranteed to be a UUID. It might be the UUID of a ticket.
1101 ** If it is, store in *pClosed a true or false depending on whether or not
1102 ** the ticket is closed and return true. If zTarget
1103 ** is not the UUID of a ticket, return false.
1104 */
1105 int is_ticket(
1106 const char *zTarget, /* Ticket UUID */
1107 int *pClosed /* True if the ticket is closed */
1108 ){
1109 static Stmt q;
1110 int n;
1111
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1100,11 +1100,11 @@
1100 ** zTarget is guaranteed to be a UUID. It might be the UUID of a ticket.
1101 ** If it is, store in *pClosed a true or false depending on whether or not
1102 ** the ticket is closed and return true. If zTarget
1103 ** is not the UUID of a ticket, return false.
1104 */
1105 static int is_ticket(
1106 const char *zTarget, /* Ticket UUID */
1107 int *pClosed /* True if the ticket is closed */
1108 ){
1109 static Stmt q;
1110 int n;
1111
+1 -2
--- test/th1.test
+++ test/th1.test
@@ -1041,12 +1041,11 @@
10411041
encode64 error expr for getParameter glob_match globalState hascap \
10421042
hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
10431043
list llength lsearch markdown nonce proc puts query randhex redirect\
10441044
regexp reinitialize rename render repository return searchable set\
10451045
setParameter setting stime string styleFooter styleHeader styleScript\
1046
- tclReady trace unset unversioned uplevel upvar utime verifyCsrf\
1047
- verifyLogin wiki}
1046
+ tclReady trace unset unversioned uplevel upvar utime verifyCsrf wiki}
10481047
set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
10491048
if {$th1Tcl} {
10501049
test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
10511050
} else {
10521051
test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
10531052
--- test/th1.test
+++ test/th1.test
@@ -1041,12 +1041,11 @@
1041 encode64 error expr for getParameter glob_match globalState hascap \
1042 hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
1043 list llength lsearch markdown nonce proc puts query randhex redirect\
1044 regexp reinitialize rename render repository return searchable set\
1045 setParameter setting stime string styleFooter styleHeader styleScript\
1046 tclReady trace unset unversioned uplevel upvar utime verifyCsrf\
1047 verifyLogin wiki}
1048 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1049 if {$th1Tcl} {
1050 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
1051 } else {
1052 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
1053
--- test/th1.test
+++ test/th1.test
@@ -1041,12 +1041,11 @@
1041 encode64 error expr for getParameter glob_match globalState hascap \
1042 hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
1043 list llength lsearch markdown nonce proc puts query randhex redirect\
1044 regexp reinitialize rename render repository return searchable set\
1045 setParameter setting stime string styleFooter styleHeader styleScript\
1046 tclReady trace unset unversioned uplevel upvar utime verifyCsrf wiki}
 
1047 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1048 if {$th1Tcl} {
1049 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
1050 } else {
1051 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
1052
--- www/blockchain.md
+++ www/blockchain.md
@@ -12,19 +12,19 @@
1212
1313
By that definition, Fossil is clearly an implementation of blockchain.
1414
The blocks are ["manifests" artifacts](./fileformat.wiki#manifest).
1515
Each manifest has a SHA1 or SHA3 hash of its parent or parents,
1616
a timestamp, and other transactional data. The repository grows by
17
-adding new manifests onto the list.
17
+add new manifests onto the list.
1818
1919
Some people have come to associate blockchain with cryptocurrency, however,
2020
and since Fossil has nothing to do with cryptocurrency, the claim that
21
-Fossil is built around blockchain is met with skepticism. The key thing
21
+Fossil is build around blockchain is met with skepticism. The key thing
2222
to note here is that cryptocurrency implementations like BitCoin are
2323
built around blockchain, but they are not synonymous with blockchain.
2424
Blockchain is a much broader concept. Blockchain is a mechanism for
25
-constructing a distributed ledger of transactions.
25
+constructed a distributed ledger of transactions.
2626
Yes, you can use a distributed
2727
ledger to implement a cryptocurrency, but you can also use a distributed
2828
ledger to implement a version control system, and probably many other kinds
2929
of applications as well. Blockchain is a much broader idea than
3030
cryptocurrency.
3131
--- www/blockchain.md
+++ www/blockchain.md
@@ -12,19 +12,19 @@
12
13 By that definition, Fossil is clearly an implementation of blockchain.
14 The blocks are ["manifests" artifacts](./fileformat.wiki#manifest).
15 Each manifest has a SHA1 or SHA3 hash of its parent or parents,
16 a timestamp, and other transactional data. The repository grows by
17 adding new manifests onto the list.
18
19 Some people have come to associate blockchain with cryptocurrency, however,
20 and since Fossil has nothing to do with cryptocurrency, the claim that
21 Fossil is built around blockchain is met with skepticism. The key thing
22 to note here is that cryptocurrency implementations like BitCoin are
23 built around blockchain, but they are not synonymous with blockchain.
24 Blockchain is a much broader concept. Blockchain is a mechanism for
25 constructing a distributed ledger of transactions.
26 Yes, you can use a distributed
27 ledger to implement a cryptocurrency, but you can also use a distributed
28 ledger to implement a version control system, and probably many other kinds
29 of applications as well. Blockchain is a much broader idea than
30 cryptocurrency.
31
--- www/blockchain.md
+++ www/blockchain.md
@@ -12,19 +12,19 @@
12
13 By that definition, Fossil is clearly an implementation of blockchain.
14 The blocks are ["manifests" artifacts](./fileformat.wiki#manifest).
15 Each manifest has a SHA1 or SHA3 hash of its parent or parents,
16 a timestamp, and other transactional data. The repository grows by
17 add new manifests onto the list.
18
19 Some people have come to associate blockchain with cryptocurrency, however,
20 and since Fossil has nothing to do with cryptocurrency, the claim that
21 Fossil is build around blockchain is met with skepticism. The key thing
22 to note here is that cryptocurrency implementations like BitCoin are
23 built around blockchain, but they are not synonymous with blockchain.
24 Blockchain is a much broader concept. Blockchain is a mechanism for
25 constructed a distributed ledger of transactions.
26 Yes, you can use a distributed
27 ledger to implement a cryptocurrency, but you can also use a distributed
28 ledger to implement a version control system, and probably many other kinds
29 of applications as well. Blockchain is a much broader idea than
30 cryptocurrency.
31
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -136,10 +136,5 @@
136136
This parameter can be repeated as many times as necessary.
137137
138138
<h2 id="HOME">HOME: <i>PATH</i></h2>
139139
140140
This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
141
-
142
-<h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2>
143
-
144
-Cause CGI-related debugging information to be appended in <i>FILE</i>. Use
145
-this to help debug CGI problems.
146141
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -136,10 +136,5 @@
136 This parameter can be repeated as many times as necessary.
137
138 <h2 id="HOME">HOME: <i>PATH</i></h2>
139
140 This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
141
142 <h2 id="cgi-debug">cgi-debug: <i>FILE</i></h2>
143
144 Cause CGI-related debugging information to be appended in <i>FILE</i>. Use
145 this to help debug CGI problems.
146
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -136,10 +136,5 @@
136 This parameter can be repeated as many times as necessary.
137
138 <h2 id="HOME">HOME: <i>PATH</i></h2>
139
140 This parameter is a short-hand for "<b>setenv HOME <i>PATH</i></b>".
 
 
 
 
 
141
+2 -11
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,21 +1,12 @@
11
<title>Change Log</title>
22
33
<a name='v2_11'></a>
44
<h2>Changes for Version 2.11 (pending)</h2>
55
6
- * Support Markdown in the default ticket configuration.
7
- * Rework the "[/help?cmd=grep|fossil grep]" command to be more useful.
8
- * Expose the [/help?cmd=redirect-to-https|redirect-to-https]
9
- setting to the [/help?cmd=settings|settings] command.
10
- * Improve support for CGI on IIS web servers.
11
- * The [/help?cmd=/ext|/ext page] can now render index files,
12
- analog to how the embedded docs do.
13
- * Most commands now support the Unix-conventional "<tt>--</tt>"
14
- flag to treat all following arguments as filenames
15
- instead of flags.
16
- * Several minor enhancements to existing features.
6
+ * Support Markdown in the default ticket configuration
7
+ * Rework the "fossil grep" command to be more useful
178
189
<a name='v2_10'></a>
1910
<h2>Changes for Version 2.10 (2019-10-04)</h2>
2011
2112
* Added support for [./serverext.wiki|CGI-based Server Extensions].
2213
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,21 +1,12 @@
1 <title>Change Log</title>
2
3 <a name='v2_11'></a>
4 <h2>Changes for Version 2.11 (pending)</h2>
5
6 * Support Markdown in the default ticket configuration.
7 * Rework the "[/help?cmd=grep|fossil grep]" command to be more useful.
8 * Expose the [/help?cmd=redirect-to-https|redirect-to-https]
9 setting to the [/help?cmd=settings|settings] command.
10 * Improve support for CGI on IIS web servers.
11 * The [/help?cmd=/ext|/ext page] can now render index files,
12 analog to how the embedded docs do.
13 * Most commands now support the Unix-conventional "<tt>--</tt>"
14 flag to treat all following arguments as filenames
15 instead of flags.
16 * Several minor enhancements to existing features.
17
18 <a name='v2_10'></a>
19 <h2>Changes for Version 2.10 (2019-10-04)</h2>
20
21 * Added support for [./serverext.wiki|CGI-based Server Extensions].
22
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,21 +1,12 @@
1 <title>Change Log</title>
2
3 <a name='v2_11'></a>
4 <h2>Changes for Version 2.11 (pending)</h2>
5
6 * Support Markdown in the default ticket configuration
7 * Rework the "fossil grep" command to be more useful
 
 
 
 
 
 
 
 
 
8
9 <a name='v2_10'></a>
10 <h2>Changes for Version 2.10 (2019-10-04)</h2>
11
12 * Added support for [./serverext.wiki|CGI-based Server Extensions].
13
--- www/customskin.md
+++ www/customskin.md
@@ -25,11 +25,11 @@
2525
And the footer looks like this:
2626
2727
<div class="footer">
2828
... skin-specific stuff here ...
2929
</div>
30
- <script nonce="$<nonce>">
30
+ <script nonce=$nonce>
3131
<th1>styleScript</th1>
3232
</script>
3333
3434
Notice that there are no `<html>` or `<head>` elements in the header,
3535
nor is there an `</html>` closing tag in the footer. Fossil generates
3636
--- www/customskin.md
+++ www/customskin.md
@@ -25,11 +25,11 @@
25 And the footer looks like this:
26
27 <div class="footer">
28 ... skin-specific stuff here ...
29 </div>
30 <script nonce="$<nonce>">
31 <th1>styleScript</th1>
32 </script>
33
34 Notice that there are no `<html>` or `<head>` elements in the header,
35 nor is there an `</html>` closing tag in the footer. Fossil generates
36
--- www/customskin.md
+++ www/customskin.md
@@ -25,11 +25,11 @@
25 And the footer looks like this:
26
27 <div class="footer">
28 ... skin-specific stuff here ...
29 </div>
30 <script nonce=$nonce>
31 <th1>styleScript</th1>
32 </script>
33
34 Notice that there are no `<html>` or `<head>` elements in the header,
35 nor is there an `</html>` closing tag in the footer. Fossil generates
36
--- www/javascript.md
+++ www/javascript.md
@@ -178,25 +178,10 @@
178178
with this parameter included/excluded to implement the toggle via a
179179
server round-trip.
180180
181181
[mainc]: https://fossil-scm.org/fossil/artifact?ln&name=87d67e745
182182
183
-
184
-### <a id="sxsdiff"></a>Side-by-Side Diff Mode
185
-
186
-The default “diff” view is a side-by-side mode. If either of the boxes
187
-of output — the “from” and “to” versions of the repo contents for that
188
-check-in — requires a horizontal scroll bar given the box content, font
189
-size, browser window width, etc., both boxes will usually end up needing
190
-to scroll since they should contain roughly similar content. Fossil
191
-therefore scrolls both boxes when you drag the scroll bar on one because
192
-if you want to examine part of a line scrolled out of the HTML element
193
-in one box, you probably want to examine the same point on that line in
194
-the other box.
195
-
196
-_Graceful Fallback:_ Manually scroll both boxes to sync their views.
197
-
198183
199184
### <a id="sort"></a>Table Sorting
200185
201186
On pages showing a data table, the column headers may be clickable to do
202187
a client-side sort of the data on that column.
203188
204189
DELETED www/mdtest/test1.md
--- www/javascript.md
+++ www/javascript.md
@@ -178,25 +178,10 @@
178 with this parameter included/excluded to implement the toggle via a
179 server round-trip.
180
181 [mainc]: https://fossil-scm.org/fossil/artifact?ln&name=87d67e745
182
183
184 ### <a id="sxsdiff"></a>Side-by-Side Diff Mode
185
186 The default “diff” view is a side-by-side mode. If either of the boxes
187 of output — the “from” and “to” versions of the repo contents for that
188 check-in — requires a horizontal scroll bar given the box content, font
189 size, browser window width, etc., both boxes will usually end up needing
190 to scroll since they should contain roughly similar content. Fossil
191 therefore scrolls both boxes when you drag the scroll bar on one because
192 if you want to examine part of a line scrolled out of the HTML element
193 in one box, you probably want to examine the same point on that line in
194 the other box.
195
196 _Graceful Fallback:_ Manually scroll both boxes to sync their views.
197
198
199 ### <a id="sort"></a>Table Sorting
200
201 On pages showing a data table, the column headers may be clickable to do
202 a client-side sort of the data on that column.
203
204 ELETED www/mdtest/test1.md
--- www/javascript.md
+++ www/javascript.md
@@ -178,25 +178,10 @@
178 with this parameter included/excluded to implement the toggle via a
179 server round-trip.
180
181 [mainc]: https://fossil-scm.org/fossil/artifact?ln&name=87d67e745
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
184 ### <a id="sort"></a>Table Sorting
185
186 On pages showing a data table, the column headers may be clickable to do
187 a client-side sort of the data on that column.
188
189 ELETED www/mdtest/test1.md
D www/mdtest/test1.md
-53
--- a/www/mdtest/test1.md
+++ b/www/mdtest/test1.md
@@ -1,53 +0,0 @@
1
-# Markdown Lin-test
2
-
3
-This document exists solely as a test for some of the hyperlinking
4
-capabilities of Markdown as implemented by Fossil.
5
-
6
-## Relative-Path Links
7
-
8
- * The index: [](../index.wiki)
9
-
10
- * Load management: [](../loadmgmt.md)
11
-
12
- * Site-map: [](../../../../sitemap)
13
-
14
- * Windows CGI: [](../server/windows/cgi.md)
15
-
16
-## The Magic $ROOT Path Prefix
17
-
18
-In text of the form `href="$ROOT/..."` in the HTML that markdown
19
-generates, the $ROOT is replaced by th complete URI for the root
20
-of the document tree.
21
-Note that the $ROOT translation only occurs within the `<a href="...">`
22
-element, not within the text of the hyperlink. So you should see the
23
-$ROOT text on this page, but if you mouse-over the hyperlink the $ROOT
24
-value should have been expanded to the actual document root.
25
-
26
- * Timeline: []($ROOT/timeline)
27
-
28
- * Site-map: []($ROOT/sitemap)
29
-
30
-The $ROOT prefix on markdown links is superfluous. The same link
31
-works without the $ROOT prefix. (Though: the $ROOT prefix is required
32
-for HTML documents.)
33
-
34
- * Timeline: [](/time?cmd=helpTimeline: []($ROOT/time/sitemap)
35
-
36
-## The Magic $SELF Document Version Translation
37
-
38
-In URI text of the form `.../doc/$SELF/...` the
39
-$SELFversion number of the document
40
-currently being displayed. This conversion happens after translation
41
-into HTML and only occurs on href='...' attributes so it does not occur
42
-for plain text.
43
-
44
- * Document index: [](/doc/$SELF$ROOT and the $SELFhe same link.
45
-
46
- * Document index: []($ROOT/doc/$CURRENT/www/index.wiki)
47
-
48
-ThSELF$ROOT and the $CURThe translations must be contained within HTML markup in order to work.
49
-They do not work for ordinary text that appears to be an href= attribute.
50
-
51
- * `x href='$ROOT/timeline'`
52
- * `x action="$ROOT/whatever"`
53
- * `x href="https://some-other-siSELF/tail"`
--- a/www/mdtest/test1.md
+++ b/www/mdtest/test1.md
@@ -1,53 +0,0 @@
1 # Markdown Lin-test
2
3 This document exists solely as a test for some of the hyperlinking
4 capabilities of Markdown as implemented by Fossil.
5
6 ## Relative-Path Links
7
8 * The index: [](../index.wiki)
9
10 * Load management: [](../loadmgmt.md)
11
12 * Site-map: [](../../../../sitemap)
13
14 * Windows CGI: [](../server/windows/cgi.md)
15
16 ## The Magic $ROOT Path Prefix
17
18 In text of the form `href="$ROOT/..."` in the HTML that markdown
19 generates, the $ROOT is replaced by th complete URI for the root
20 of the document tree.
21 Note that the $ROOT translation only occurs within the `<a href="...">`
22 element, not within the text of the hyperlink. So you should see the
23 $ROOT text on this page, but if you mouse-over the hyperlink the $ROOT
24 value should have been expanded to the actual document root.
25
26 * Timeline: []($ROOT/timeline)
27
28 * Site-map: []($ROOT/sitemap)
29
30 The $ROOT prefix on markdown links is superfluous. The same link
31 works without the $ROOT prefix. (Though: the $ROOT prefix is required
32 for HTML documents.)
33
34 * Timeline: [](/time?cmd=helpTimeline: []($ROOT/time/sitemap)
35
36 ## The Magic $SELF Document Version Translation
37
38 In URI text of the form `.../doc/$SELF/...` the
39 $SELFversion number of the document
40 currently being displayed. This conversion happens after translation
41 into HTML and only occurs on href='...' attributes so it does not occur
42 for plain text.
43
44 * Document index: [](/doc/$SELF$ROOT and the $SELFhe same link.
45
46 * Document index: []($ROOT/doc/$CURRENT/www/index.wiki)
47
48 ThSELF$ROOT and the $CURThe translations must be contained within HTML markup in order to work.
49 They do not work for ordinary text that appears to be an href= attribute.
50
51 * `x href='$ROOT/timeline'`
52 * `x action="$ROOT/whatever"`
53 * `x href="https://some-other-siSELF/tail"`
--- a/www/mdtest/test1.md
+++ b/www/mdtest/test1.md
@@ -1,53 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -201,11 +201,11 @@
201201
202202
<blockquote><verbatim>
203203
<script nonce='$FOSSIL_NONCE'>...</script>
204204
</verbatim></blockquote>
205205
206
-Except, of course, the $FOSSIL_NONCE is replaced by the value of the
206
+Except, of course, the $FOSSIL_NONCE is replace by the value of the
207207
FOSSIL_NONCE environment variable.
208208
209209
If the HTTP request includes content (for example if this is a POST request)
210210
then the CONTENT_LENGTH value will be positive and the data for the content
211211
will be readable on standard input.
212212
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -201,11 +201,11 @@
201
202 <blockquote><verbatim>
203 <script nonce='$FOSSIL_NONCE'>...</script>
204 </verbatim></blockquote>
205
206 Except, of course, the $FOSSIL_NONCE is replaced by the value of the
207 FOSSIL_NONCE environment variable.
208
209 If the HTTP request includes content (for example if this is a POST request)
210 then the CONTENT_LENGTH value will be positive and the data for the content
211 will be readable on standard input.
212
--- www/serverext.wiki
+++ www/serverext.wiki
@@ -201,11 +201,11 @@
201
202 <blockquote><verbatim>
203 <script nonce='$FOSSIL_NONCE'>...</script>
204 </verbatim></blockquote>
205
206 Except, of course, the $FOSSIL_NONCE is replace by the value of the
207 FOSSIL_NONCE environment variable.
208
209 If the HTTP request includes content (for example if this is a POST request)
210 then the CONTENT_LENGTH value will be positive and the data for the content
211 will be readable on standard input.
212
-8
--- www/th1.md
+++ www/th1.md
@@ -215,11 +215,10 @@
215215
* trace
216216
* unversioned content
217217
* unversioned list
218218
* utime
219219
* verifyCsrf
220
- * verifyLogin
221220
* wiki
222221
223222
Each of the commands above is documented by a block comment above their
224223
implementation in the th\_main.c or th\_tcl.c source files.
225224
@@ -735,18 +734,10 @@
735734
that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
736735
is missing or is incorrect, that indicates a cross-site scripting attack.
737736
If the event of an attack is detected, an error message is generated and
738737
all further processing is aborted.
739738
740
-<a name="verifyLogin"></a>TH1 verifyLogin Command
--------------------------------------------------
741
-
742
- * verifyLogin
743
-
744
-Returns non-zero if the specified user name and password represent a
745
-valid login for the repository.
746
-
747739
<a name="wiki"></a>TH1 wiki Command
748740
-----------------------------------
749741
750742
* wiki STRING
751743
752744
--- www/th1.md
+++ www/th1.md
@@ -215,11 +215,10 @@
215 * trace
216 * unversioned content
217 * unversioned list
218 * utime
219 * verifyCsrf
220 * verifyLogin
221 * wiki
222
223 Each of the commands above is documented by a block comment above their
224 implementation in the th\_main.c or th\_tcl.c source files.
225
@@ -735,18 +734,10 @@
735 that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
736 is missing or is incorrect, that indicates a cross-site scripting attack.
737 If the event of an attack is detected, an error message is generated and
738 all further processing is aborted.
739
740 <a name="verifyLogin"></a>TH1 verifyLogin Command
--------------------------------------------------
741
742 * verifyLogin
743
744 Returns non-zero if the specified user name and password represent a
745 valid login for the repository.
746
747 <a name="wiki"></a>TH1 wiki Command
748 -----------------------------------
749
750 * wiki STRING
751
752
--- www/th1.md
+++ www/th1.md
@@ -215,11 +215,10 @@
215 * trace
216 * unversioned content
217 * unversioned list
218 * utime
219 * verifyCsrf
 
220 * wiki
221
222 Each of the commands above is documented by a block comment above their
223 implementation in the th\_main.c or th\_tcl.c source files.
224
@@ -735,18 +734,10 @@
734 that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
735 is missing or is incorrect, that indicates a cross-site scripting attack.
736 If the event of an attack is detected, an error message is generated and
737 all further processing is aborted.
738
 
--------------------------------------------------
 
 
 
 
 
 
739 <a name="wiki"></a>TH1 wiki Command
740 -----------------------------------
741
742 * wiki STRING
743
744

Keyboard Shortcuts

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