Fossil SCM

merge trunk. Adapt patch to latest SQLite changes (the MAX_PATH fix in os_win.c)

jan.nijtmans 2013-08-08 21:32 UTC possible-cygwin-fix merge
Commit 13594a125ab19f2f2ae7234e9fa1821be2e7b87b
+22
--- src/cgi.c
+++ src/cgi.c
@@ -1131,10 +1131,24 @@
11311131
va_end(ap);
11321132
cgi_reply();
11331133
fossil_exit(1);
11341134
}
11351135
}
1136
+
1137
+/* z[] is the value of an X-FORWARDED-FOR: line in an HTTP header.
1138
+** Return a pointer to a string containing the real IP address, or a
1139
+** NULL pointer to stick with the IP address previously computed and
1140
+** loaded into g.zIpAddr.
1141
+*/
1142
+static const char *cgi_accept_forwarded_for(const char *z){
1143
+ int i;
1144
+ if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0;
1145
+
1146
+ i = strlen(z)-1;
1147
+ while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--;
1148
+ return &z[++i];
1149
+}
11361150
11371151
/*
11381152
** Remove the first space-delimited token from a string and return
11391153
** a pointer to it. Add a NULL to the string to terminate the token.
11401154
** Make *zLeftOver point to the start of the next token.
@@ -1175,10 +1189,11 @@
11751189
char zLine[2000]; /* A single line of input. */
11761190
g.fullHttpReply = 1;
11771191
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
11781192
malformed_request();
11791193
}
1194
+ blob_append(&g.httpHeader, zLine, -1);
11801195
cgi_trace(zLine);
11811196
zToken = extract_token(zLine, &z);
11821197
if( zToken==0 ){
11831198
malformed_request();
11841199
}
@@ -1213,10 +1228,11 @@
12131228
while( fgets(zLine,sizeof(zLine),g.httpIn) ){
12141229
char *zFieldName;
12151230
char *zVal;
12161231
12171232
cgi_trace(zLine);
1233
+ blob_append(&g.httpHeader, zLine, -1);
12181234
zFieldName = extract_token(zLine,&zVal);
12191235
if( zFieldName==0 || *zFieldName==0 ) break;
12201236
while( fossil_isspace(*zVal) ){ zVal++; }
12211237
i = strlen(zVal);
12221238
while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
@@ -1242,10 +1258,16 @@
12421258
}else if( fossil_strcmp(zFieldName,"referer:")==0 ){
12431259
cgi_setenv("HTTP_REFERER", zVal);
12441260
#endif
12451261
}else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){
12461262
cgi_setenv("HTTP_USER_AGENT", zVal);
1263
+ }else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){
1264
+ const char *zIpAddr = cgi_accept_forwarded_for(zVal);
1265
+ if( zIpAddr!=0 ){
1266
+ g.zIpAddr = mprintf("%s", zIpAddr);
1267
+ cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
1268
+ }
12471269
}
12481270
}
12491271
cgi_init();
12501272
cgi_trace(0);
12511273
}
12521274
--- src/cgi.c
+++ src/cgi.c
@@ -1131,10 +1131,24 @@
1131 va_end(ap);
1132 cgi_reply();
1133 fossil_exit(1);
1134 }
1135 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1136
1137 /*
1138 ** Remove the first space-delimited token from a string and return
1139 ** a pointer to it. Add a NULL to the string to terminate the token.
1140 ** Make *zLeftOver point to the start of the next token.
@@ -1175,10 +1189,11 @@
1175 char zLine[2000]; /* A single line of input. */
1176 g.fullHttpReply = 1;
1177 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
1178 malformed_request();
1179 }
 
1180 cgi_trace(zLine);
1181 zToken = extract_token(zLine, &z);
1182 if( zToken==0 ){
1183 malformed_request();
1184 }
@@ -1213,10 +1228,11 @@
1213 while( fgets(zLine,sizeof(zLine),g.httpIn) ){
1214 char *zFieldName;
1215 char *zVal;
1216
1217 cgi_trace(zLine);
 
1218 zFieldName = extract_token(zLine,&zVal);
1219 if( zFieldName==0 || *zFieldName==0 ) break;
1220 while( fossil_isspace(*zVal) ){ zVal++; }
1221 i = strlen(zVal);
1222 while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
@@ -1242,10 +1258,16 @@
1242 }else if( fossil_strcmp(zFieldName,"referer:")==0 ){
1243 cgi_setenv("HTTP_REFERER", zVal);
1244 #endif
1245 }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){
1246 cgi_setenv("HTTP_USER_AGENT", zVal);
 
 
 
 
 
 
1247 }
1248 }
1249 cgi_init();
1250 cgi_trace(0);
1251 }
1252
--- src/cgi.c
+++ src/cgi.c
@@ -1131,10 +1131,24 @@
1131 va_end(ap);
1132 cgi_reply();
1133 fossil_exit(1);
1134 }
1135 }
1136
1137 /* z[] is the value of an X-FORWARDED-FOR: line in an HTTP header.
1138 ** Return a pointer to a string containing the real IP address, or a
1139 ** NULL pointer to stick with the IP address previously computed and
1140 ** loaded into g.zIpAddr.
1141 */
1142 static const char *cgi_accept_forwarded_for(const char *z){
1143 int i;
1144 if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0;
1145
1146 i = strlen(z)-1;
1147 while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--;
1148 return &z[++i];
1149 }
1150
1151 /*
1152 ** Remove the first space-delimited token from a string and return
1153 ** a pointer to it. Add a NULL to the string to terminate the token.
1154 ** Make *zLeftOver point to the start of the next token.
@@ -1175,10 +1189,11 @@
1189 char zLine[2000]; /* A single line of input. */
1190 g.fullHttpReply = 1;
1191 if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
1192 malformed_request();
1193 }
1194 blob_append(&g.httpHeader, zLine, -1);
1195 cgi_trace(zLine);
1196 zToken = extract_token(zLine, &z);
1197 if( zToken==0 ){
1198 malformed_request();
1199 }
@@ -1213,10 +1228,11 @@
1228 while( fgets(zLine,sizeof(zLine),g.httpIn) ){
1229 char *zFieldName;
1230 char *zVal;
1231
1232 cgi_trace(zLine);
1233 blob_append(&g.httpHeader, zLine, -1);
1234 zFieldName = extract_token(zLine,&zVal);
1235 if( zFieldName==0 || *zFieldName==0 ) break;
1236 while( fossil_isspace(*zVal) ){ zVal++; }
1237 i = strlen(zVal);
1238 while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
@@ -1242,10 +1258,16 @@
1258 }else if( fossil_strcmp(zFieldName,"referer:")==0 ){
1259 cgi_setenv("HTTP_REFERER", zVal);
1260 #endif
1261 }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){
1262 cgi_setenv("HTTP_USER_AGENT", zVal);
1263 }else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){
1264 const char *zIpAddr = cgi_accept_forwarded_for(zVal);
1265 if( zIpAddr!=0 ){
1266 g.zIpAddr = mprintf("%s", zIpAddr);
1267 cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
1268 }
1269 }
1270 }
1271 cgi_init();
1272 cgi_trace(0);
1273 }
1274
+3 -3
--- src/info.c
+++ src/info.c
@@ -1443,11 +1443,11 @@
14431443
if( !g.perm.Read ){ login_needed(); return; }
14441444
if( rid==0 ) fossil_redirect_home();
14451445
if( g.perm.Admin ){
14461446
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
14471447
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1448
- style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1448
+ style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#delshun",
14491449
g.zTop, zUuid);
14501450
}else{
14511451
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
14521452
g.zTop, zUuid);
14531453
}
@@ -1593,11 +1593,11 @@
15931593
if( !g.perm.Read ){ login_needed(); return; }
15941594
if( rid==0 ) fossil_redirect_home();
15951595
if( g.perm.Admin ){
15961596
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
15971597
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1598
- style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1598
+ style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
15991599
g.zTop, zUuid);
16001600
}else{
16011601
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
16021602
g.zTop, zUuid);
16031603
}
@@ -1701,11 +1701,11 @@
17011701
rid = name_to_rid_www("name");
17021702
if( rid==0 ){ fossil_redirect_home(); }
17031703
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
17041704
if( g.perm.Admin ){
17051705
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1706
- style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1706
+ style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
17071707
g.zTop, zUuid);
17081708
}else{
17091709
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
17101710
g.zTop, zUuid);
17111711
}
17121712
--- src/info.c
+++ src/info.c
@@ -1443,11 +1443,11 @@
1443 if( !g.perm.Read ){ login_needed(); return; }
1444 if( rid==0 ) fossil_redirect_home();
1445 if( g.perm.Admin ){
1446 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1447 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1448 style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1449 g.zTop, zUuid);
1450 }else{
1451 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1452 g.zTop, zUuid);
1453 }
@@ -1593,11 +1593,11 @@
1593 if( !g.perm.Read ){ login_needed(); return; }
1594 if( rid==0 ) fossil_redirect_home();
1595 if( g.perm.Admin ){
1596 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1597 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1598 style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1599 g.zTop, zUuid);
1600 }else{
1601 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1602 g.zTop, zUuid);
1603 }
@@ -1701,11 +1701,11 @@
1701 rid = name_to_rid_www("name");
1702 if( rid==0 ){ fossil_redirect_home(); }
1703 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1704 if( g.perm.Admin ){
1705 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1706 style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
1707 g.zTop, zUuid);
1708 }else{
1709 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1710 g.zTop, zUuid);
1711 }
1712
--- src/info.c
+++ src/info.c
@@ -1443,11 +1443,11 @@
1443 if( !g.perm.Read ){ login_needed(); return; }
1444 if( rid==0 ) fossil_redirect_home();
1445 if( g.perm.Admin ){
1446 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1447 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1448 style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#delshun",
1449 g.zTop, zUuid);
1450 }else{
1451 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1452 g.zTop, zUuid);
1453 }
@@ -1593,11 +1593,11 @@
1593 if( !g.perm.Read ){ login_needed(); return; }
1594 if( rid==0 ) fossil_redirect_home();
1595 if( g.perm.Admin ){
1596 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1597 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1598 style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
1599 g.zTop, zUuid);
1600 }else{
1601 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1602 g.zTop, zUuid);
1603 }
@@ -1701,11 +1701,11 @@
1701 rid = name_to_rid_www("name");
1702 if( rid==0 ){ fossil_redirect_home(); }
1703 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1704 if( g.perm.Admin ){
1705 if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
1706 style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
1707 g.zTop, zUuid);
1708 }else{
1709 style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
1710 g.zTop, zUuid);
1711 }
1712
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
10461046
** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
10471047
*/
10481048
void login_replace_capabilities(const char *zCap, unsigned flags){
10491049
memset(&g.perm, 0, sizeof(g.perm));
10501050
login_set_capabilities(zCap, flags);
1051
+ login_anon_once = 1;
10511052
}
10521053
10531054
/*
10541055
** If the current login lacks any of the capabilities listed in
10551056
** the input, then return 0. If all capabilities are present, then
10561057
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
1046 ** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
1047 */
1048 void login_replace_capabilities(const char *zCap, unsigned flags){
1049 memset(&g.perm, 0, sizeof(g.perm));
1050 login_set_capabilities(zCap, flags);
 
1051 }
1052
1053 /*
1054 ** If the current login lacks any of the capabilities listed in
1055 ** the input, then return 0. If all capabilities are present, then
1056
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
1046 ** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
1047 */
1048 void login_replace_capabilities(const char *zCap, unsigned flags){
1049 memset(&g.perm, 0, sizeof(g.perm));
1050 login_set_capabilities(zCap, flags);
1051 login_anon_once = 1;
1052 }
1053
1054 /*
1055 ** If the current login lacks any of the capabilities listed in
1056 ** the input, then return 0. If all capabilities are present, then
1057
+2
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159159
int markPrivate; /* All new artifacts are private if true */
160160
int clockSkewSeen; /* True if clocks on client and server out of sync */
161161
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162162
char isHTTP; /* True if server/CGI modes, else assume CLI. */
163163
char javascriptHyperlink; /* If true, set href= using script, not HTML */
164
+ Blob httpHeader; /* Complete text of the HTTP request header */
164165
165166
int urlIsFile; /* True if a "file:" url */
166167
int urlIsHttps; /* True if a "https:" url */
167168
int urlIsSsh; /* True if an "ssh:" url */
168169
char *urlName; /* Hostname for http: or filename for file: */
@@ -529,10 +530,11 @@
529530
int idx;
530531
int rc;
531532
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
532533
memset(&g, 0, sizeof(g));
533534
g.now = time(0);
535
+ g.httpHeader = empty_blob;
534536
#ifdef FOSSIL_ENABLE_JSON
535537
#if defined(NDEBUG)
536538
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
537539
One problem we have here is that this
538540
code is needed before the db is opened,
539541
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159 int markPrivate; /* All new artifacts are private if true */
160 int clockSkewSeen; /* True if clocks on client and server out of sync */
161 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162 char isHTTP; /* True if server/CGI modes, else assume CLI. */
163 char javascriptHyperlink; /* If true, set href= using script, not HTML */
 
164
165 int urlIsFile; /* True if a "file:" url */
166 int urlIsHttps; /* True if a "https:" url */
167 int urlIsSsh; /* True if an "ssh:" url */
168 char *urlName; /* Hostname for http: or filename for file: */
@@ -529,10 +530,11 @@
529 int idx;
530 int rc;
531 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
532 memset(&g, 0, sizeof(g));
533 g.now = time(0);
 
534 #ifdef FOSSIL_ENABLE_JSON
535 #if defined(NDEBUG)
536 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
537 One problem we have here is that this
538 code is needed before the db is opened,
539
--- src/main.c
+++ src/main.c
@@ -159,10 +159,11 @@
159 int markPrivate; /* All new artifacts are private if true */
160 int clockSkewSeen; /* True if clocks on client and server out of sync */
161 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
162 char isHTTP; /* True if server/CGI modes, else assume CLI. */
163 char javascriptHyperlink; /* If true, set href= using script, not HTML */
164 Blob httpHeader; /* Complete text of the HTTP request header */
165
166 int urlIsFile; /* True if a "file:" url */
167 int urlIsHttps; /* True if a "https:" url */
168 int urlIsSsh; /* True if an "ssh:" url */
169 char *urlName; /* Hostname for http: or filename for file: */
@@ -529,10 +530,11 @@
530 int idx;
531 int rc;
532 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
533 memset(&g, 0, sizeof(g));
534 g.now = time(0);
535 g.httpHeader = empty_blob;
536 #ifdef FOSSIL_ENABLE_JSON
537 #if defined(NDEBUG)
538 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
539 One problem we have here is that this
540 code is needed before the db is opened,
541
+8 -11
--- src/shell.c
+++ src/shell.c
@@ -63,18 +63,23 @@
6363
#if defined(_WIN32) || defined(WIN32)
6464
# include <io.h>
6565
#define isatty(h) _isatty(h)
6666
#define access(f,m) _access((f),(m))
6767
#undef popen
68
-#define popen(a,b) _popen((a),(b))
68
+#define popen _popen
6969
#undef pclose
7070
#define pclose _pclose
7171
#else
7272
/* Make sure isatty() has a prototype.
7373
*/
7474
extern int isatty(int);
7575
#endif
76
+
77
+/* popen and pclose are not C89 functions and so are sometimes omitted from
78
+** the <stdio.h> header */
79
+FILE *popen(const char*,const char*);
80
+int pclose(FILE*);
7681
7782
#if defined(_WIN32_WCE)
7883
/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
7984
* thus we always assume that we have a console. That can be
8085
* overridden with the -batch command line option.
@@ -1795,21 +1800,18 @@
17951800
n = strlen30(azArg[0]);
17961801
c = azArg[0][0];
17971802
if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){
17981803
const char *zDestFile = 0;
17991804
const char *zDb = 0;
1800
- const char *zKey = 0;
18011805
sqlite3 *pDest;
18021806
sqlite3_backup *pBackup;
18031807
int j;
18041808
for(j=1; j<nArg; j++){
18051809
const char *z = azArg[j];
18061810
if( z[0]=='-' ){
18071811
while( z[0]=='-' ) z++;
1808
- if( strcmp(z,"key")==0 && j<nArg-1 ){
1809
- zKey = azArg[++j];
1810
- }else
1812
+ /* No options to process at this time */
18111813
{
18121814
fprintf(stderr, "unknown option: %s\n", azArg[j]);
18131815
return 1;
18141816
}
18151817
}else if( zDestFile==0 ){
@@ -1831,15 +1833,10 @@
18311833
if( rc!=SQLITE_OK ){
18321834
fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
18331835
sqlite3_close(pDest);
18341836
return 1;
18351837
}
1836
-#ifdef SQLITE_HAS_CODEC
1837
- sqlite3_key(pDest, zKey, (int)strlen(zKey));
1838
-#else
1839
- (void)zKey;
1840
-#endif
18411838
open_db(p);
18421839
pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
18431840
if( pBackup==0 ){
18441841
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
18451842
sqlite3_close(pDest);
@@ -2665,11 +2662,11 @@
26652662
break;
26662663
26672664
/* sqlite3_test_control(int, uint) */
26682665
case SQLITE_TESTCTRL_PENDING_BYTE:
26692666
if( nArg==3 ){
2670
- unsigned int opt = (unsigned int)integerValue(azArg[2]);
2667
+ unsigned int opt = (unsigned int)integerValue(azArg[2]);
26712668
rc = sqlite3_test_control(testctrl, opt);
26722669
fprintf(p->out, "%d (0x%08x)\n", rc, rc);
26732670
} else {
26742671
fprintf(stderr,"Error: testctrl %s takes a single unsigned"
26752672
" int option\n", azArg[1]);
26762673
--- src/shell.c
+++ src/shell.c
@@ -63,18 +63,23 @@
63 #if defined(_WIN32) || defined(WIN32)
64 # include <io.h>
65 #define isatty(h) _isatty(h)
66 #define access(f,m) _access((f),(m))
67 #undef popen
68 #define popen(a,b) _popen((a),(b))
69 #undef pclose
70 #define pclose _pclose
71 #else
72 /* Make sure isatty() has a prototype.
73 */
74 extern int isatty(int);
75 #endif
 
 
 
 
 
76
77 #if defined(_WIN32_WCE)
78 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
79 * thus we always assume that we have a console. That can be
80 * overridden with the -batch command line option.
@@ -1795,21 +1800,18 @@
1795 n = strlen30(azArg[0]);
1796 c = azArg[0][0];
1797 if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){
1798 const char *zDestFile = 0;
1799 const char *zDb = 0;
1800 const char *zKey = 0;
1801 sqlite3 *pDest;
1802 sqlite3_backup *pBackup;
1803 int j;
1804 for(j=1; j<nArg; j++){
1805 const char *z = azArg[j];
1806 if( z[0]=='-' ){
1807 while( z[0]=='-' ) z++;
1808 if( strcmp(z,"key")==0 && j<nArg-1 ){
1809 zKey = azArg[++j];
1810 }else
1811 {
1812 fprintf(stderr, "unknown option: %s\n", azArg[j]);
1813 return 1;
1814 }
1815 }else if( zDestFile==0 ){
@@ -1831,15 +1833,10 @@
1831 if( rc!=SQLITE_OK ){
1832 fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
1833 sqlite3_close(pDest);
1834 return 1;
1835 }
1836 #ifdef SQLITE_HAS_CODEC
1837 sqlite3_key(pDest, zKey, (int)strlen(zKey));
1838 #else
1839 (void)zKey;
1840 #endif
1841 open_db(p);
1842 pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
1843 if( pBackup==0 ){
1844 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
1845 sqlite3_close(pDest);
@@ -2665,11 +2662,11 @@
2665 break;
2666
2667 /* sqlite3_test_control(int, uint) */
2668 case SQLITE_TESTCTRL_PENDING_BYTE:
2669 if( nArg==3 ){
2670 unsigned int opt = (unsigned int)integerValue(azArg[2]);
2671 rc = sqlite3_test_control(testctrl, opt);
2672 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
2673 } else {
2674 fprintf(stderr,"Error: testctrl %s takes a single unsigned"
2675 " int option\n", azArg[1]);
2676
--- src/shell.c
+++ src/shell.c
@@ -63,18 +63,23 @@
63 #if defined(_WIN32) || defined(WIN32)
64 # include <io.h>
65 #define isatty(h) _isatty(h)
66 #define access(f,m) _access((f),(m))
67 #undef popen
68 #define popen _popen
69 #undef pclose
70 #define pclose _pclose
71 #else
72 /* Make sure isatty() has a prototype.
73 */
74 extern int isatty(int);
75 #endif
76
77 /* popen and pclose are not C89 functions and so are sometimes omitted from
78 ** the <stdio.h> header */
79 FILE *popen(const char*,const char*);
80 int pclose(FILE*);
81
82 #if defined(_WIN32_WCE)
83 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
84 * thus we always assume that we have a console. That can be
85 * overridden with the -batch command line option.
@@ -1795,21 +1800,18 @@
1800 n = strlen30(azArg[0]);
1801 c = azArg[0][0];
1802 if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){
1803 const char *zDestFile = 0;
1804 const char *zDb = 0;
 
1805 sqlite3 *pDest;
1806 sqlite3_backup *pBackup;
1807 int j;
1808 for(j=1; j<nArg; j++){
1809 const char *z = azArg[j];
1810 if( z[0]=='-' ){
1811 while( z[0]=='-' ) z++;
1812 /* No options to process at this time */
 
 
1813 {
1814 fprintf(stderr, "unknown option: %s\n", azArg[j]);
1815 return 1;
1816 }
1817 }else if( zDestFile==0 ){
@@ -1831,15 +1833,10 @@
1833 if( rc!=SQLITE_OK ){
1834 fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
1835 sqlite3_close(pDest);
1836 return 1;
1837 }
 
 
 
 
 
1838 open_db(p);
1839 pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
1840 if( pBackup==0 ){
1841 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
1842 sqlite3_close(pDest);
@@ -2665,11 +2662,11 @@
2662 break;
2663
2664 /* sqlite3_test_control(int, uint) */
2665 case SQLITE_TESTCTRL_PENDING_BYTE:
2666 if( nArg==3 ){
2667 unsigned int opt = (unsigned int)integerValue(azArg[2]);
2668 rc = sqlite3_test_control(testctrl, opt);
2669 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
2670 } else {
2671 fprintf(stderr,"Error: testctrl %s takes a single unsigned"
2672 " int option\n", azArg[1]);
2673
+4 -1
--- src/shun.c
+++ src/shun.c
@@ -66,10 +66,11 @@
6666
zUuid = zCanonical;
6767
}
6868
}
6969
style_header("Shunned Artifacts");
7070
if( zUuid && P("sub") ){
71
+ login_verify_csrf_secret();
7172
db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
7273
if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
7374
@ <p class="noMoreShun">Artifact
7475
@ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
7576
@ longer being shunned.</p>
@@ -132,19 +133,21 @@
132133
@ <input type="text" name="uuid" value="%h(PD("shun",""))" size="50" />
133134
@ <input type="submit" name="add" value="Shun" />
134135
@ </div></form>
135136
@ </blockquote>
136137
@
138
+ @ <a name="delshun"></a>
137139
@ <p>Enter the UUID of a previous shunned artifact to cause it to be
138140
@ accepted again in the repository. The artifact content is not
139141
@ restored because the content is unknown. The only change is that
140142
@ the formerly shunned artifact will be accepted on subsequent sync
141143
@ operations.</p>
142144
@
143145
@ <blockquote>
144146
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
145
- @ <input type="text" name="uuid" size="50" />
147
+ login_insert_csrf_secret();
148
+ @ <input type="text" name="uuid" value="%h(PD("accept", ""))" size="50" />
146149
@ <input type="submit" name="sub" value="Accept" />
147150
@ </div></form>
148151
@ </blockquote>
149152
@
150153
@ <p>Press the Rebuild button below to rebuild the repository. The
151154
--- src/shun.c
+++ src/shun.c
@@ -66,10 +66,11 @@
66 zUuid = zCanonical;
67 }
68 }
69 style_header("Shunned Artifacts");
70 if( zUuid && P("sub") ){
 
71 db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
72 if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
73 @ <p class="noMoreShun">Artifact
74 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
75 @ longer being shunned.</p>
@@ -132,19 +133,21 @@
132 @ <input type="text" name="uuid" value="%h(PD("shun",""))" size="50" />
133 @ <input type="submit" name="add" value="Shun" />
134 @ </div></form>
135 @ </blockquote>
136 @
 
137 @ <p>Enter the UUID of a previous shunned artifact to cause it to be
138 @ accepted again in the repository. The artifact content is not
139 @ restored because the content is unknown. The only change is that
140 @ the formerly shunned artifact will be accepted on subsequent sync
141 @ operations.</p>
142 @
143 @ <blockquote>
144 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
145 @ <input type="text" name="uuid" size="50" />
 
146 @ <input type="submit" name="sub" value="Accept" />
147 @ </div></form>
148 @ </blockquote>
149 @
150 @ <p>Press the Rebuild button below to rebuild the repository. The
151
--- src/shun.c
+++ src/shun.c
@@ -66,10 +66,11 @@
66 zUuid = zCanonical;
67 }
68 }
69 style_header("Shunned Artifacts");
70 if( zUuid && P("sub") ){
71 login_verify_csrf_secret();
72 db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
73 if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
74 @ <p class="noMoreShun">Artifact
75 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
76 @ longer being shunned.</p>
@@ -132,19 +133,21 @@
133 @ <input type="text" name="uuid" value="%h(PD("shun",""))" size="50" />
134 @ <input type="submit" name="add" value="Shun" />
135 @ </div></form>
136 @ </blockquote>
137 @
138 @ <a name="delshun"></a>
139 @ <p>Enter the UUID of a previous shunned artifact to cause it to be
140 @ accepted again in the repository. The artifact content is not
141 @ restored because the content is unknown. The only change is that
142 @ the formerly shunned artifact will be accepted on subsequent sync
143 @ operations.</p>
144 @
145 @ <blockquote>
146 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
147 login_insert_csrf_secret();
148 @ <input type="text" name="uuid" value="%h(PD("accept", ""))" size="50" />
149 @ <input type="submit" name="sub" value="Accept" />
150 @ </div></form>
151 @ </blockquote>
152 @
153 @ <p>Press the Rebuild button below to rebuild the repository. The
154
+1221 -996
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403403
**
404
-** (Historical note: There used to be several other options, but we've
405
-** pared it down to just these three.)
406
-**
407404
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408405
** the default.
409406
*/
410407
#if defined(SQLITE_SYSTEM_MALLOC) \
411408
+ defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439436
*/
440437
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441438
# define _XOPEN_SOURCE 600
442439
#endif
443440
444
-/*
445
-** The TCL headers are only needed when compiling the TCL bindings.
446
-*/
447
-#if defined(SQLITE_TCL) || defined(TCLSH)
448
-# include <tcl.h>
449
-#endif
450
-
451441
/*
452442
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453443
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454444
** make it true by defining or undefining NDEBUG.
455445
**
456
-** Setting NDEBUG makes the code smaller and run faster by disabling the
457
-** number assert() statements in the code. So we want the default action
446
+** Setting NDEBUG makes the code smaller and faster by disabling the
447
+** assert() statements in the code. So we want the default action
458448
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459449
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460450
** feature.
461451
*/
462452
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522512
** hint of unplanned behavior.
523513
**
524514
** In other words, ALWAYS and NEVER are added for defensive code.
525515
**
526516
** When doing coverage testing ALWAYS and NEVER are hard-coded to
527
-** be true and false so that the unreachable code then specify will
517
+** be true and false so that the unreachable code they specify will
528518
** not be counted as untested code.
529519
*/
530520
#if defined(SQLITE_COVERAGE_TEST)
531521
# define ALWAYS(X) (1)
532522
# define NEVER(X) (0)
@@ -546,20 +536,16 @@
546536
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547537
548538
/*
549539
** The macro unlikely() is a hint that surrounds a boolean
550540
** expression that is usually false. Macro likely() surrounds
551
-** a boolean expression that is usually true. GCC is able to
552
-** use these hints to generate better code, sometimes.
541
+** a boolean expression that is usually true. These hints could,
542
+** in theory, be used by the compiler to generate better code, but
543
+** currently they are just comments for human readers.
553544
*/
554
-#if defined(__GNUC__) && 0
555
-# define likely(X) __builtin_expect((X),1)
556
-# define unlikely(X) __builtin_expect((X),0)
557
-#else
558
-# define likely(X) !!(X)
559
-# define unlikely(X) !!(X)
560
-#endif
545
+#define likely(X) (X)
546
+#define unlikely(X) (X)
561547
562548
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563549
/************** Begin file sqlite3.h *****************************************/
564550
/*
565551
** 2001 September 15
@@ -670,11 +656,11 @@
670656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671657
** [sqlite_version()] and [sqlite_source_id()].
672658
*/
673659
#define SQLITE_VERSION "3.8.0"
674660
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
661
+#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
676662
677663
/*
678664
** CAPI3REF: Run-Time Library Version Numbers
679665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680666
**
@@ -1039,10 +1025,11 @@
10391025
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10401026
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10411027
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10421028
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10431029
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10441031
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10451032
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10461033
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10471034
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10481035
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
31223109
** interface is to keep a GUI updated during a large query.
31233110
**
31243111
** ^The parameter P is passed through as the only parameter to the
31253112
** callback function X. ^The parameter N is the approximate number of
31263113
** [virtual machine instructions] that are evaluated between successive
3127
-** invocations of the callback X.
3114
+** invocations of the callback X. ^If N is less than one then the progress
3115
+** handler is disabled.
31283116
**
31293117
** ^Only a single progress handler may be defined at one time per
31303118
** [database connection]; setting a new progress handler cancels the
31313119
** old one. ^Setting parameter X to NULL disables the progress handler.
31323120
** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
47424730
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
47434731
47444732
/*
47454733
** CAPI3REF: Function Auxiliary Data
47464734
**
4747
-** The following two functions may be used by scalar SQL functions to
4735
+** These functions may be used by (non-aggregate) SQL functions to
47484736
** associate metadata with argument values. If the same value is passed to
47494737
** multiple invocations of the same SQL function during query execution, under
4750
-** some circumstances the associated metadata may be preserved. This might
4751
-** be used, for example, in a regular-expression matching
4752
-** function. The compiled version of the regular expression is stored as
4753
-** metadata associated with the SQL value passed as the regular expression
4754
-** pattern. The compiled regular expression can be reused on multiple
4755
-** invocations of the same function so that the original pattern string
4756
-** does not need to be recompiled on each invocation.
4738
+** some circumstances the associated metadata may be preserved. An example
4739
+** of where this might be useful is in a regular-expression matching
4740
+** function. The compiled version of the regular expression can be stored as
4741
+** metadata associated with the pattern string.
4742
+** Then as long as the pattern string remains the same,
4743
+** the compiled regular expression can be reused on multiple
4744
+** invocations of the same function.
47574745
**
47584746
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
47594747
** associated by the sqlite3_set_auxdata() function with the Nth argument
4760
-** value to the application-defined function. ^If no metadata has been ever
4761
-** been set for the Nth argument of the function, or if the corresponding
4762
-** function parameter has changed since the meta-data was set,
4763
-** then sqlite3_get_auxdata() returns a NULL pointer.
4748
+** value to the application-defined function. ^If there is no metadata
4749
+** associated with the function argument, this sqlite3_get_auxdata() interface
4750
+** returns a NULL pointer.
47644751
**
47654752
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
47664753
** argument of the application-defined function. ^Subsequent
47674754
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768
-** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769
-** NULL if the data has been dropped.
4770
-** ^(If it is not NULL, SQLite will invoke the destructor
4771
-** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772
-** <li> the corresponding function parameter changes,
4773
-** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774
-** SQL statement,
4775
-** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776
-** <li> a memory allocation error occurs. </ul>)^
4755
+** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756
+** NULL if the metadata has been discarded.
4757
+** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758
+** SQLite will invoke the destructor function X with parameter P exactly
4759
+** once, when the metadata is discarded.
4760
+** SQLite is free to discard the metadata at any time, including: <ul>
4761
+** <li> when the corresponding function parameter changes, or
4762
+** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763
+** SQL statement, or
4764
+** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765
+** <li> during the original sqlite3_set_auxdata() call when a memory
4766
+** allocation error occurs. </ul>)^
47774767
**
4778
-** SQLite is free to call the destructor and drop metadata on any
4779
-** parameter of any function at any time. ^The only guarantee is that
4780
-** the destructor will be called when the [prepared statement] is destroyed.
4781
-** Note in particular that the destructor X in the call to
4782
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783
-** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4768
+** Note the last bullet in particular. The destructor X in
4769
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770
+** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
47844771
** should be called near the end of the function implementation and the
4785
-** implementation should not make any use of P after sqlite3_set_auxdata()
4786
-** has been called.
4772
+** function implementation should not make any use of P after
4773
+** sqlite3_set_auxdata() has been called.
47874774
**
47884775
** ^(In practice, metadata is preserved between function calls for
47894776
** function parameters that are compile-time constants, including literal
47904777
** values and [parameters] and expressions composed from the same.)^
47914778
**
@@ -6829,13 +6816,13 @@
68296816
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
68306817
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
68316818
** </dd>
68326819
**
68336820
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6834
-** <dd>This parameter returns the zero for the current value if and only if
6835
-** there all foreign key constraints (deferred or immediate) have been
6836
-** resolved. The highwater mark is always 0.
6821
+** <dd>This parameter returns zero for the current value if and only if
6822
+** all foreign key constraints (deferred or immediate) have been
6823
+** resolved.)^ ^The highwater mark is always 0.
68376824
** </dd>
68386825
** </dl>
68396826
*/
68406827
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
68416828
#define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
88248811
88258812
/*
88268813
** The names of the following types declared in vdbeInt.h are required
88278814
** for the VdbeOp definition.
88288815
*/
8829
-typedef struct VdbeFunc VdbeFunc;
88308816
typedef struct Mem Mem;
88318817
typedef struct SubProgram SubProgram;
88328818
88338819
/*
88348820
** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
88488834
void *p; /* Generic pointer */
88498835
char *z; /* Pointer to data for string (char array) types */
88508836
i64 *pI64; /* Used when p4type is P4_INT64 */
88518837
double *pReal; /* Used when p4type is P4_REAL */
88528838
FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853
- VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
88548839
CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
88558840
Mem *pMem; /* Used when p4type is P4_MEM */
88568841
VTable *pVtab; /* Used when p4type is P4_VTAB */
88578842
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
88588843
int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
89028887
#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
89038888
#define P4_STATIC (-2) /* Pointer to a static string */
89048889
#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
89058890
#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
89068891
#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907
-#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
89088892
#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
89098893
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
89108894
#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
89118895
#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
89128896
#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
89598943
*/
89608944
/************** Include opcodes.h in the middle of vdbe.h ********************/
89618945
/************** Begin file opcodes.h *****************************************/
89628946
/* Automatically generated. Do not edit */
89638947
/* See the mkopcodeh.awk script for details */
8964
-#define OP_Goto 1
8965
-#define OP_Gosub 2
8966
-#define OP_Return 3
8967
-#define OP_Yield 4
8968
-#define OP_HaltIfNull 5
8969
-#define OP_Halt 6
8970
-#define OP_Integer 7
8971
-#define OP_Int64 8
8972
-#define OP_Real 130 /* same as TK_FLOAT */
8973
-#define OP_String8 94 /* same as TK_STRING */
8974
-#define OP_String 9
8975
-#define OP_Null 10
8976
-#define OP_Blob 11
8977
-#define OP_Variable 12
8978
-#define OP_Move 13
8979
-#define OP_Copy 14
8980
-#define OP_SCopy 15
8981
-#define OP_ResultRow 16
8982
-#define OP_Concat 91 /* same as TK_CONCAT */
8948
+#define OP_Function 1
8949
+#define OP_Savepoint 2
8950
+#define OP_AutoCommit 3
8951
+#define OP_Transaction 4
8952
+#define OP_SorterNext 5
8953
+#define OP_Prev 6
8954
+#define OP_Next 7
8955
+#define OP_AggStep 8
8956
+#define OP_Checkpoint 9
8957
+#define OP_JournalMode 10
8958
+#define OP_Vacuum 11
8959
+#define OP_VFilter 12
8960
+#define OP_VUpdate 13
8961
+#define OP_Goto 14
8962
+#define OP_Gosub 15
8963
+#define OP_Return 16
8964
+#define OP_Yield 17
8965
+#define OP_HaltIfNull 18
8966
+#define OP_Not 19 /* same as TK_NOT */
8967
+#define OP_Halt 20
8968
+#define OP_Integer 21
8969
+#define OP_Int64 22
8970
+#define OP_String 23
8971
+#define OP_Null 24
8972
+#define OP_Blob 25
8973
+#define OP_Variable 26
8974
+#define OP_Move 27
8975
+#define OP_Copy 28
8976
+#define OP_SCopy 29
8977
+#define OP_ResultRow 30
8978
+#define OP_CollSeq 31
8979
+#define OP_AddImm 32
8980
+#define OP_MustBeInt 33
8981
+#define OP_RealAffinity 34
8982
+#define OP_Permutation 35
8983
+#define OP_Compare 36
8984
+#define OP_Jump 37
8985
+#define OP_Once 38
8986
+#define OP_If 39
8987
+#define OP_IfNot 40
8988
+#define OP_Column 41
8989
+#define OP_Affinity 42
8990
+#define OP_MakeRecord 43
8991
+#define OP_Count 44
8992
+#define OP_ReadCookie 45
8993
+#define OP_SetCookie 46
8994
+#define OP_VerifyCookie 47
8995
+#define OP_OpenRead 48
8996
+#define OP_OpenWrite 49
8997
+#define OP_OpenAutoindex 50
8998
+#define OP_OpenEphemeral 51
8999
+#define OP_SorterOpen 52
9000
+#define OP_OpenPseudo 53
9001
+#define OP_Close 54
9002
+#define OP_SeekLt 55
9003
+#define OP_SeekLe 56
9004
+#define OP_SeekGe 57
9005
+#define OP_SeekGt 58
9006
+#define OP_Seek 59
9007
+#define OP_NotFound 60
9008
+#define OP_Found 61
9009
+#define OP_IsUnique 62
9010
+#define OP_NotExists 63
9011
+#define OP_Sequence 64
9012
+#define OP_NewRowid 65
9013
+#define OP_Insert 66
9014
+#define OP_InsertInt 67
9015
+#define OP_Or 68 /* same as TK_OR */
9016
+#define OP_And 69 /* same as TK_AND */
9017
+#define OP_Delete 70
9018
+#define OP_ResetCount 71
9019
+#define OP_SorterCompare 72
9020
+#define OP_IsNull 73 /* same as TK_ISNULL */
9021
+#define OP_NotNull 74 /* same as TK_NOTNULL */
9022
+#define OP_Ne 75 /* same as TK_NE */
9023
+#define OP_Eq 76 /* same as TK_EQ */
9024
+#define OP_Gt 77 /* same as TK_GT */
9025
+#define OP_Le 78 /* same as TK_LE */
9026
+#define OP_Lt 79 /* same as TK_LT */
9027
+#define OP_Ge 80 /* same as TK_GE */
9028
+#define OP_SorterData 81
9029
+#define OP_BitAnd 82 /* same as TK_BITAND */
9030
+#define OP_BitOr 83 /* same as TK_BITOR */
9031
+#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032
+#define OP_ShiftRight 85 /* same as TK_RSHIFT */
89839033
#define OP_Add 86 /* same as TK_PLUS */
89849034
#define OP_Subtract 87 /* same as TK_MINUS */
89859035
#define OP_Multiply 88 /* same as TK_STAR */
89869036
#define OP_Divide 89 /* same as TK_SLASH */
89879037
#define OP_Remainder 90 /* same as TK_REM */
8988
-#define OP_CollSeq 17
8989
-#define OP_Function 18
8990
-#define OP_BitAnd 82 /* same as TK_BITAND */
8991
-#define OP_BitOr 83 /* same as TK_BITOR */
8992
-#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8993
-#define OP_ShiftRight 85 /* same as TK_RSHIFT */
8994
-#define OP_AddImm 20
8995
-#define OP_MustBeInt 21
8996
-#define OP_RealAffinity 22
9038
+#define OP_Concat 91 /* same as TK_CONCAT */
9039
+#define OP_RowKey 92
9040
+#define OP_BitNot 93 /* same as TK_BITNOT */
9041
+#define OP_String8 94 /* same as TK_STRING */
9042
+#define OP_RowData 95
9043
+#define OP_Rowid 96
9044
+#define OP_NullRow 97
9045
+#define OP_Last 98
9046
+#define OP_SorterSort 99
9047
+#define OP_Sort 100
9048
+#define OP_Rewind 101
9049
+#define OP_SorterInsert 102
9050
+#define OP_IdxInsert 103
9051
+#define OP_IdxDelete 104
9052
+#define OP_IdxRowid 105
9053
+#define OP_IdxLT 106
9054
+#define OP_IdxGE 107
9055
+#define OP_Destroy 108
9056
+#define OP_Clear 109
9057
+#define OP_CreateIndex 110
9058
+#define OP_CreateTable 111
9059
+#define OP_ParseSchema 112
9060
+#define OP_LoadAnalysis 113
9061
+#define OP_DropTable 114
9062
+#define OP_DropIndex 115
9063
+#define OP_DropTrigger 116
9064
+#define OP_IntegrityCk 117
9065
+#define OP_RowSetAdd 118
9066
+#define OP_RowSetRead 119
9067
+#define OP_RowSetTest 120
9068
+#define OP_Program 121
9069
+#define OP_Param 122
9070
+#define OP_FkCounter 123
9071
+#define OP_FkIfZero 124
9072
+#define OP_MemMax 125
9073
+#define OP_IfPos 126
9074
+#define OP_IfNeg 127
9075
+#define OP_IfZero 128
9076
+#define OP_AggFinal 129
9077
+#define OP_Real 130 /* same as TK_FLOAT */
9078
+#define OP_IncrVacuum 131
9079
+#define OP_Expire 132
9080
+#define OP_TableLock 133
9081
+#define OP_VBegin 134
9082
+#define OP_VCreate 135
9083
+#define OP_VDestroy 136
9084
+#define OP_VOpen 137
9085
+#define OP_VColumn 138
9086
+#define OP_VNext 139
9087
+#define OP_VRename 140
89979088
#define OP_ToText 141 /* same as TK_TO_TEXT */
89989089
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
89999090
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
90009091
#define OP_ToInt 144 /* same as TK_TO_INT */
90019092
#define OP_ToReal 145 /* same as TK_TO_REAL */
9002
-#define OP_Eq 76 /* same as TK_EQ */
9003
-#define OP_Ne 75 /* same as TK_NE */
9004
-#define OP_Lt 79 /* same as TK_LT */
9005
-#define OP_Le 78 /* same as TK_LE */
9006
-#define OP_Gt 77 /* same as TK_GT */
9007
-#define OP_Ge 80 /* same as TK_GE */
9008
-#define OP_Permutation 23
9009
-#define OP_Compare 24
9010
-#define OP_Jump 25
9011
-#define OP_And 69 /* same as TK_AND */
9012
-#define OP_Or 68 /* same as TK_OR */
9013
-#define OP_Not 19 /* same as TK_NOT */
9014
-#define OP_BitNot 93 /* same as TK_BITNOT */
9015
-#define OP_Once 26
9016
-#define OP_If 27
9017
-#define OP_IfNot 28
9018
-#define OP_IsNull 73 /* same as TK_ISNULL */
9019
-#define OP_NotNull 74 /* same as TK_NOTNULL */
9020
-#define OP_Column 29
9021
-#define OP_Affinity 30
9022
-#define OP_MakeRecord 31
9023
-#define OP_Count 32
9024
-#define OP_Savepoint 33
9025
-#define OP_AutoCommit 34
9026
-#define OP_Transaction 35
9027
-#define OP_ReadCookie 36
9028
-#define OP_SetCookie 37
9029
-#define OP_VerifyCookie 38
9030
-#define OP_OpenRead 39
9031
-#define OP_OpenWrite 40
9032
-#define OP_OpenAutoindex 41
9033
-#define OP_OpenEphemeral 42
9034
-#define OP_SorterOpen 43
9035
-#define OP_OpenPseudo 44
9036
-#define OP_Close 45
9037
-#define OP_SeekLt 46
9038
-#define OP_SeekLe 47
9039
-#define OP_SeekGe 48
9040
-#define OP_SeekGt 49
9041
-#define OP_Seek 50
9042
-#define OP_NotFound 51
9043
-#define OP_Found 52
9044
-#define OP_IsUnique 53
9045
-#define OP_NotExists 54
9046
-#define OP_Sequence 55
9047
-#define OP_NewRowid 56
9048
-#define OP_Insert 57
9049
-#define OP_InsertInt 58
9050
-#define OP_Delete 59
9051
-#define OP_ResetCount 60
9052
-#define OP_SorterCompare 61
9053
-#define OP_SorterData 62
9054
-#define OP_RowKey 63
9055
-#define OP_RowData 64
9056
-#define OP_Rowid 65
9057
-#define OP_NullRow 66
9058
-#define OP_Last 67
9059
-#define OP_SorterSort 70
9060
-#define OP_Sort 71
9061
-#define OP_Rewind 72
9062
-#define OP_SorterNext 81
9063
-#define OP_Prev 92
9064
-#define OP_Next 95
9065
-#define OP_SorterInsert 96
9066
-#define OP_IdxInsert 97
9067
-#define OP_IdxDelete 98
9068
-#define OP_IdxRowid 99
9069
-#define OP_IdxLT 100
9070
-#define OP_IdxGE 101
9071
-#define OP_Destroy 102
9072
-#define OP_Clear 103
9073
-#define OP_CreateIndex 104
9074
-#define OP_CreateTable 105
9075
-#define OP_ParseSchema 106
9076
-#define OP_LoadAnalysis 107
9077
-#define OP_DropTable 108
9078
-#define OP_DropIndex 109
9079
-#define OP_DropTrigger 110
9080
-#define OP_IntegrityCk 111
9081
-#define OP_RowSetAdd 112
9082
-#define OP_RowSetRead 113
9083
-#define OP_RowSetTest 114
9084
-#define OP_Program 115
9085
-#define OP_Param 116
9086
-#define OP_FkCounter 117
9087
-#define OP_FkIfZero 118
9088
-#define OP_MemMax 119
9089
-#define OP_IfPos 120
9090
-#define OP_IfNeg 121
9091
-#define OP_IfZero 122
9092
-#define OP_AggStep 123
9093
-#define OP_AggFinal 124
9094
-#define OP_Checkpoint 125
9095
-#define OP_JournalMode 126
9096
-#define OP_Vacuum 127
9097
-#define OP_IncrVacuum 128
9098
-#define OP_Expire 129
9099
-#define OP_TableLock 131
9100
-#define OP_VBegin 132
9101
-#define OP_VCreate 133
9102
-#define OP_VDestroy 134
9103
-#define OP_VOpen 135
9104
-#define OP_VFilter 136
9105
-#define OP_VColumn 137
9106
-#define OP_VNext 138
9107
-#define OP_VRename 139
9108
-#define OP_VUpdate 140
91099093
#define OP_Pagecount 146
91109094
#define OP_MaxPgcnt 147
91119095
#define OP_Trace 148
91129096
#define OP_Noop 149
91139097
#define OP_Explain 150
@@ -9123,28 +9107,28 @@
91239107
#define OPFLG_IN2 0x0008 /* in2: P2 is an input */
91249108
#define OPFLG_IN3 0x0010 /* in3: P3 is an input */
91259109
#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
91269110
#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
91279111
#define OPFLG_INITIALIZER {\
9128
-/* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9129
-/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9130
-/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9131
-/* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9132
-/* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9133
-/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9134
-/* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9135
-/* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9136
-/* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9137
-/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9138
-/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9139
-/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9140
-/* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9141
-/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9142
-/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9143
-/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9144
-/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9145
-/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9112
+/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113
+/* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114
+/* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115
+/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116
+/* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117
+/* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118
+/* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119
+/* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120
+/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121
+/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122
+/* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123
+/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124
+/* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125
+/* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126
+/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127
+/* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128
+/* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129
+/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
91469130
/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
91479131
91489132
/************** End of opcodes.h *********************************************/
91499133
/************** Continuing where we left off in vdbe.h ***********************/
91509134
@@ -9190,11 +9174,11 @@
91909174
SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
91919175
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
91929176
SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
91939177
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
91949178
SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9195
-SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
9179
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
91969180
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
91979181
#ifndef SQLITE_OMIT_TRACE
91989182
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
91999183
#endif
92009184
@@ -10688,16 +10672,20 @@
1068810672
1068910673
/*
1069010674
** An instance of the following structure is passed as the first
1069110675
** argument to sqlite3VdbeKeyCompare and is used to control the
1069210676
** comparison of the two index keys.
10677
+**
10678
+** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679
+** are nField slots for the columns of an index then one extra slot
10680
+** for the rowid at the end.
1069310681
*/
1069410682
struct KeyInfo {
1069510683
sqlite3 *db; /* The database connection */
1069610684
u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10697
- u16 nField; /* Number of entries in aColl[] */
10698
- u8 *aSortOrder; /* Sort order for each column. May be NULL */
10685
+ u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686
+ u8 *aSortOrder; /* Sort order for each column. */
1069910687
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
1070010688
};
1070110689
1070210690
/*
1070310691
** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
1076210750
char *zColAff; /* String defining the affinity of each column */
1076310751
Index *pNext; /* The next index associated with the same table */
1076410752
Schema *pSchema; /* Schema containing this index */
1076510753
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
1076610754
char **azColl; /* Array of collation sequence names for index */
10755
+ Expr *pPartIdxWhere; /* WHERE clause for partial indices */
1076710756
int tnum; /* DB Page containing root of this index */
1076810757
u16 nColumn; /* Number of columns in table used by this index */
1076910758
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
1077010759
unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
1077110760
unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
1124211231
#define NC_HasAgg 0x02 /* One or more aggregate functions seen */
1124311232
#define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
1124411233
#define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
1124511234
#define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
1124611235
** if no other resolution is available */
11236
+#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
1124711237
1124811238
/*
1124911239
** An instance of the following structure contains all information
1125011240
** needed to generate code for a single SELECT statement.
1125111241
**
@@ -11296,10 +11286,11 @@
1129611286
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
1129711287
#define SF_UseSorter 0x0040 /* Sort using a sorter */
1129811288
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
1129911289
#define SF_Materialize 0x0100 /* Force materialization of views */
1130011290
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291
+#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
1130111292
1130211293
1130311294
/*
1130411295
** The results of a select can be distributed in several ways. The
1130511296
** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
1141711408
u8 nTempInUse; /* Number of aTempReg[] currently checked out */
1141811409
u8 nColCache; /* Number of entries in aColCache[] */
1141911410
u8 iColCache; /* Next entry in aColCache[] to replace */
1142011411
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
1142111412
u8 mayAbort; /* True if statement may throw an ABORT exception */
11413
+ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
1142211414
int aTempReg[8]; /* Holding area for temporary registers */
1142311415
int nRangeReg; /* Size of the temporary register block */
1142411416
int iRangeReg; /* First register in temporary register block */
1142511417
int nErr; /* Number of errors seen */
1142611418
int nTab; /* Number of previously allocated VDBE cursors */
1142711419
int nMem; /* Number of memory cells used so far */
1142811420
int nSet; /* Number of sets used so far */
1142911421
int nOnce; /* Number of OP_Once instructions so far */
1143011422
int ckBase; /* Base register of data during check constraints */
11423
+ int iPartIdxTab; /* Table corresponding to a partial index */
1143111424
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
1143211425
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
1143311426
struct yColCache {
1143411427
int iTable; /* Table cursor number */
1143511428
int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
1200712000
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1200812001
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1200912002
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1201012003
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
1201112004
SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12012
- Token*, int, int);
12005
+ Expr*, int, int);
1201312006
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1201412007
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1201512008
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1201612009
Expr*,ExprList*,u16,Expr*,Expr*);
1201712010
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
1205512048
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1205612049
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1205712050
SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
1205812051
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
1205912052
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12060
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
12061
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
12053
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12054
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12055
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1206212056
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1206312057
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1206412058
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1206512059
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
1206612060
SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
1208312077
SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
1208412078
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
1208512079
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
1208612080
SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
1208712081
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12088
-SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
12082
+SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
1208912083
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
1209012084
int*,int,int,int,int,int*);
1209112085
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
1209212086
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
1209312087
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
1228612280
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
1228712281
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1228812282
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
1228912283
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
1229012284
SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12285
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
1229112286
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
1229212287
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
1229312288
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
1229412289
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
1229512290
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
1230512300
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
1230612301
SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
1230712302
SQLITE_PRIVATE void sqlite3SchemaClear(void *);
1230812303
SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
1230912304
SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
1231012306
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
1231112307
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
1231212308
void (*)(sqlite3_context*,int,sqlite3_value **),
1231312309
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
1231412310
FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
1325713253
typedef struct VdbeSorter VdbeSorter;
1325813254
1325913255
/* Opaque type used by the explainer */
1326013256
typedef struct Explain Explain;
1326113257
13258
+/* Elements of the linked list at Vdbe.pAuxData */
13259
+typedef struct AuxData AuxData;
13260
+
1326213261
/*
1326313262
** A cursor is a pointer into a single BTree within a database file.
1326413263
** The cursor can seek to a BTree entry with a particular key, or
1326513264
** loop over all entries of the Btree. You can also insert new BTree
1326613265
** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
1344313442
*/
1344413443
#ifdef SQLITE_DEBUG
1344513444
#define memIsValid(M) ((M)->flags & MEM_Invalid)==0
1344613445
#endif
1344713446
13448
-
13449
-/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450
-** additional information about auxiliary information bound to arguments
13451
-** of the function. This is used to implement the sqlite3_get_auxdata()
13452
-** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453
-** that can be associated with a constant argument to a function. This
13454
-** allows functions such as "regexp" to compile their constant regular
13455
-** expression argument once and reused the compiled code for multiple
13456
-** invocations.
13447
+/*
13448
+** Each auxilliary data pointer stored by a user defined function
13449
+** implementation calling sqlite3_set_auxdata() is stored in an instance
13450
+** of this structure. All such structures associated with a single VM
13451
+** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13452
+** when the VM is halted (if not before).
1345713453
*/
13458
-struct VdbeFunc {
13459
- FuncDef *pFunc; /* The definition of the function */
13460
- int nAux; /* Number of entries allocated for apAux[] */
13461
- struct AuxData {
13462
- void *pAux; /* Aux data for the i-th argument */
13463
- void (*xDelete)(void *); /* Destructor for the aux data */
13464
- } apAux[1]; /* One slot for each function argument */
13454
+struct AuxData {
13455
+ int iOp; /* Instruction number of OP_Function opcode */
13456
+ int iArg; /* Index of function argument. */
13457
+ void *pAux; /* Aux data pointer */
13458
+ void (*xDelete)(void *); /* Destructor for the aux data */
13459
+ AuxData *pNext; /* Next element in list */
1346513460
};
1346613461
1346713462
/*
1346813463
** The "context" argument for a installable function. A pointer to an
1346913464
** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
1347713472
** This structure is defined inside of vdbeInt.h because it uses substructures
1347813473
** (Mem) which are only defined there.
1347913474
*/
1348013475
struct sqlite3_context {
1348113476
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482
- VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
1348313477
Mem s; /* The return value is stored here */
1348413478
Mem *pMem; /* Memory cell used to store aggregate context */
1348513479
CollSeq *pColl; /* Collating sequence */
1348613480
int isError; /* Error code returned by the function. */
1348713481
int skipFlag; /* Skip skip accumulator loading if true */
13482
+ int iOp; /* Instruction number of OP_Function */
13483
+ Vdbe *pVdbe; /* The VM that owns this context */
1348813484
};
1348913485
1349013486
/*
1349113487
** An Explain object accumulates indented output which is helpful
1349213488
** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
1358113577
int nFrame; /* Number of frames in pFrame list */
1358213578
u32 expmask; /* Binding to these vars invalidates VM */
1358313579
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1358413580
int nOnceFlag; /* Size of array aOnceFlag[] */
1358513581
u8 *aOnceFlag; /* Flags for OP_Once */
13582
+ AuxData *pAuxData; /* Linked list of auxdata allocations */
1358613583
};
1358713584
1358813585
/*
1358913586
** The following are allowed values for Vdbe.magic
1359013587
*/
@@ -13604,11 +13601,11 @@
1360413601
#endif
1360513602
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1360613603
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
1360713604
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
1360813605
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13606
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
1361013607
1361113608
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
1361213609
SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
1361313610
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
1361413611
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
2270322700
/* Automatically generated. Do not edit */
2270422701
/* See the mkopcodec.awk script for details. */
2270522702
#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
2270622703
SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
2270722704
static const char *const azName[] = { "?",
22708
- /* 1 */ "Goto",
22709
- /* 2 */ "Gosub",
22710
- /* 3 */ "Return",
22711
- /* 4 */ "Yield",
22712
- /* 5 */ "HaltIfNull",
22713
- /* 6 */ "Halt",
22714
- /* 7 */ "Integer",
22715
- /* 8 */ "Int64",
22716
- /* 9 */ "String",
22717
- /* 10 */ "Null",
22718
- /* 11 */ "Blob",
22719
- /* 12 */ "Variable",
22720
- /* 13 */ "Move",
22721
- /* 14 */ "Copy",
22722
- /* 15 */ "SCopy",
22723
- /* 16 */ "ResultRow",
22724
- /* 17 */ "CollSeq",
22725
- /* 18 */ "Function",
22705
+ /* 1 */ "Function",
22706
+ /* 2 */ "Savepoint",
22707
+ /* 3 */ "AutoCommit",
22708
+ /* 4 */ "Transaction",
22709
+ /* 5 */ "SorterNext",
22710
+ /* 6 */ "Prev",
22711
+ /* 7 */ "Next",
22712
+ /* 8 */ "AggStep",
22713
+ /* 9 */ "Checkpoint",
22714
+ /* 10 */ "JournalMode",
22715
+ /* 11 */ "Vacuum",
22716
+ /* 12 */ "VFilter",
22717
+ /* 13 */ "VUpdate",
22718
+ /* 14 */ "Goto",
22719
+ /* 15 */ "Gosub",
22720
+ /* 16 */ "Return",
22721
+ /* 17 */ "Yield",
22722
+ /* 18 */ "HaltIfNull",
2272622723
/* 19 */ "Not",
22727
- /* 20 */ "AddImm",
22728
- /* 21 */ "MustBeInt",
22729
- /* 22 */ "RealAffinity",
22730
- /* 23 */ "Permutation",
22731
- /* 24 */ "Compare",
22732
- /* 25 */ "Jump",
22733
- /* 26 */ "Once",
22734
- /* 27 */ "If",
22735
- /* 28 */ "IfNot",
22736
- /* 29 */ "Column",
22737
- /* 30 */ "Affinity",
22738
- /* 31 */ "MakeRecord",
22739
- /* 32 */ "Count",
22740
- /* 33 */ "Savepoint",
22741
- /* 34 */ "AutoCommit",
22742
- /* 35 */ "Transaction",
22743
- /* 36 */ "ReadCookie",
22744
- /* 37 */ "SetCookie",
22745
- /* 38 */ "VerifyCookie",
22746
- /* 39 */ "OpenRead",
22747
- /* 40 */ "OpenWrite",
22748
- /* 41 */ "OpenAutoindex",
22749
- /* 42 */ "OpenEphemeral",
22750
- /* 43 */ "SorterOpen",
22751
- /* 44 */ "OpenPseudo",
22752
- /* 45 */ "Close",
22753
- /* 46 */ "SeekLt",
22754
- /* 47 */ "SeekLe",
22755
- /* 48 */ "SeekGe",
22756
- /* 49 */ "SeekGt",
22757
- /* 50 */ "Seek",
22758
- /* 51 */ "NotFound",
22759
- /* 52 */ "Found",
22760
- /* 53 */ "IsUnique",
22761
- /* 54 */ "NotExists",
22762
- /* 55 */ "Sequence",
22763
- /* 56 */ "NewRowid",
22764
- /* 57 */ "Insert",
22765
- /* 58 */ "InsertInt",
22766
- /* 59 */ "Delete",
22767
- /* 60 */ "ResetCount",
22768
- /* 61 */ "SorterCompare",
22769
- /* 62 */ "SorterData",
22770
- /* 63 */ "RowKey",
22771
- /* 64 */ "RowData",
22772
- /* 65 */ "Rowid",
22773
- /* 66 */ "NullRow",
22774
- /* 67 */ "Last",
22724
+ /* 20 */ "Halt",
22725
+ /* 21 */ "Integer",
22726
+ /* 22 */ "Int64",
22727
+ /* 23 */ "String",
22728
+ /* 24 */ "Null",
22729
+ /* 25 */ "Blob",
22730
+ /* 26 */ "Variable",
22731
+ /* 27 */ "Move",
22732
+ /* 28 */ "Copy",
22733
+ /* 29 */ "SCopy",
22734
+ /* 30 */ "ResultRow",
22735
+ /* 31 */ "CollSeq",
22736
+ /* 32 */ "AddImm",
22737
+ /* 33 */ "MustBeInt",
22738
+ /* 34 */ "RealAffinity",
22739
+ /* 35 */ "Permutation",
22740
+ /* 36 */ "Compare",
22741
+ /* 37 */ "Jump",
22742
+ /* 38 */ "Once",
22743
+ /* 39 */ "If",
22744
+ /* 40 */ "IfNot",
22745
+ /* 41 */ "Column",
22746
+ /* 42 */ "Affinity",
22747
+ /* 43 */ "MakeRecord",
22748
+ /* 44 */ "Count",
22749
+ /* 45 */ "ReadCookie",
22750
+ /* 46 */ "SetCookie",
22751
+ /* 47 */ "VerifyCookie",
22752
+ /* 48 */ "OpenRead",
22753
+ /* 49 */ "OpenWrite",
22754
+ /* 50 */ "OpenAutoindex",
22755
+ /* 51 */ "OpenEphemeral",
22756
+ /* 52 */ "SorterOpen",
22757
+ /* 53 */ "OpenPseudo",
22758
+ /* 54 */ "Close",
22759
+ /* 55 */ "SeekLt",
22760
+ /* 56 */ "SeekLe",
22761
+ /* 57 */ "SeekGe",
22762
+ /* 58 */ "SeekGt",
22763
+ /* 59 */ "Seek",
22764
+ /* 60 */ "NotFound",
22765
+ /* 61 */ "Found",
22766
+ /* 62 */ "IsUnique",
22767
+ /* 63 */ "NotExists",
22768
+ /* 64 */ "Sequence",
22769
+ /* 65 */ "NewRowid",
22770
+ /* 66 */ "Insert",
22771
+ /* 67 */ "InsertInt",
2277522772
/* 68 */ "Or",
2277622773
/* 69 */ "And",
22777
- /* 70 */ "SorterSort",
22778
- /* 71 */ "Sort",
22779
- /* 72 */ "Rewind",
22774
+ /* 70 */ "Delete",
22775
+ /* 71 */ "ResetCount",
22776
+ /* 72 */ "SorterCompare",
2278022777
/* 73 */ "IsNull",
2278122778
/* 74 */ "NotNull",
2278222779
/* 75 */ "Ne",
2278322780
/* 76 */ "Eq",
2278422781
/* 77 */ "Gt",
2278522782
/* 78 */ "Le",
2278622783
/* 79 */ "Lt",
2278722784
/* 80 */ "Ge",
22788
- /* 81 */ "SorterNext",
22785
+ /* 81 */ "SorterData",
2278922786
/* 82 */ "BitAnd",
2279022787
/* 83 */ "BitOr",
2279122788
/* 84 */ "ShiftLeft",
2279222789
/* 85 */ "ShiftRight",
2279322790
/* 86 */ "Add",
@@ -22794,59 +22791,59 @@
2279422791
/* 87 */ "Subtract",
2279522792
/* 88 */ "Multiply",
2279622793
/* 89 */ "Divide",
2279722794
/* 90 */ "Remainder",
2279822795
/* 91 */ "Concat",
22799
- /* 92 */ "Prev",
22796
+ /* 92 */ "RowKey",
2280022797
/* 93 */ "BitNot",
2280122798
/* 94 */ "String8",
22802
- /* 95 */ "Next",
22803
- /* 96 */ "SorterInsert",
22804
- /* 97 */ "IdxInsert",
22805
- /* 98 */ "IdxDelete",
22806
- /* 99 */ "IdxRowid",
22807
- /* 100 */ "IdxLT",
22808
- /* 101 */ "IdxGE",
22809
- /* 102 */ "Destroy",
22810
- /* 103 */ "Clear",
22811
- /* 104 */ "CreateIndex",
22812
- /* 105 */ "CreateTable",
22813
- /* 106 */ "ParseSchema",
22814
- /* 107 */ "LoadAnalysis",
22815
- /* 108 */ "DropTable",
22816
- /* 109 */ "DropIndex",
22817
- /* 110 */ "DropTrigger",
22818
- /* 111 */ "IntegrityCk",
22819
- /* 112 */ "RowSetAdd",
22820
- /* 113 */ "RowSetRead",
22821
- /* 114 */ "RowSetTest",
22822
- /* 115 */ "Program",
22823
- /* 116 */ "Param",
22824
- /* 117 */ "FkCounter",
22825
- /* 118 */ "FkIfZero",
22826
- /* 119 */ "MemMax",
22827
- /* 120 */ "IfPos",
22828
- /* 121 */ "IfNeg",
22829
- /* 122 */ "IfZero",
22830
- /* 123 */ "AggStep",
22831
- /* 124 */ "AggFinal",
22832
- /* 125 */ "Checkpoint",
22833
- /* 126 */ "JournalMode",
22834
- /* 127 */ "Vacuum",
22835
- /* 128 */ "IncrVacuum",
22836
- /* 129 */ "Expire",
22799
+ /* 95 */ "RowData",
22800
+ /* 96 */ "Rowid",
22801
+ /* 97 */ "NullRow",
22802
+ /* 98 */ "Last",
22803
+ /* 99 */ "SorterSort",
22804
+ /* 100 */ "Sort",
22805
+ /* 101 */ "Rewind",
22806
+ /* 102 */ "SorterInsert",
22807
+ /* 103 */ "IdxInsert",
22808
+ /* 104 */ "IdxDelete",
22809
+ /* 105 */ "IdxRowid",
22810
+ /* 106 */ "IdxLT",
22811
+ /* 107 */ "IdxGE",
22812
+ /* 108 */ "Destroy",
22813
+ /* 109 */ "Clear",
22814
+ /* 110 */ "CreateIndex",
22815
+ /* 111 */ "CreateTable",
22816
+ /* 112 */ "ParseSchema",
22817
+ /* 113 */ "LoadAnalysis",
22818
+ /* 114 */ "DropTable",
22819
+ /* 115 */ "DropIndex",
22820
+ /* 116 */ "DropTrigger",
22821
+ /* 117 */ "IntegrityCk",
22822
+ /* 118 */ "RowSetAdd",
22823
+ /* 119 */ "RowSetRead",
22824
+ /* 120 */ "RowSetTest",
22825
+ /* 121 */ "Program",
22826
+ /* 122 */ "Param",
22827
+ /* 123 */ "FkCounter",
22828
+ /* 124 */ "FkIfZero",
22829
+ /* 125 */ "MemMax",
22830
+ /* 126 */ "IfPos",
22831
+ /* 127 */ "IfNeg",
22832
+ /* 128 */ "IfZero",
22833
+ /* 129 */ "AggFinal",
2283722834
/* 130 */ "Real",
22838
- /* 131 */ "TableLock",
22839
- /* 132 */ "VBegin",
22840
- /* 133 */ "VCreate",
22841
- /* 134 */ "VDestroy",
22842
- /* 135 */ "VOpen",
22843
- /* 136 */ "VFilter",
22844
- /* 137 */ "VColumn",
22845
- /* 138 */ "VNext",
22846
- /* 139 */ "VRename",
22847
- /* 140 */ "VUpdate",
22835
+ /* 131 */ "IncrVacuum",
22836
+ /* 132 */ "Expire",
22837
+ /* 133 */ "TableLock",
22838
+ /* 134 */ "VBegin",
22839
+ /* 135 */ "VCreate",
22840
+ /* 136 */ "VDestroy",
22841
+ /* 137 */ "VOpen",
22842
+ /* 138 */ "VColumn",
22843
+ /* 139 */ "VNext",
22844
+ /* 140 */ "VRename",
2284822845
/* 141 */ "ToText",
2284922846
/* 142 */ "ToBlob",
2285022847
/* 143 */ "ToNumeric",
2285122848
/* 144 */ "ToInt",
2285222849
/* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
3049930496
*/
3050030497
#if SQLITE_OS_WIN /* This file is used for Windows only */
3050130498
3050230499
#ifdef __CYGWIN__
3050330500
# include <sys/cygwin.h>
30501
+/* # include <errno.h> */
3050430502
#endif
3050530503
3050630504
/*
3050730505
** Include code that is common to all os_*.c files
3050830506
*/
@@ -30727,19 +30725,19 @@
3072730725
3072830726
/*
3072930727
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
3073030728
** based on the sub-platform)?
3073130729
*/
30732
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30730
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
3073330731
# define SQLITE_WIN32_HAS_ANSI
3073430732
#endif
3073530733
3073630734
/*
3073730735
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
3073830736
** based on the sub-platform)?
3073930737
*/
30740
-#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT || defined(__CYGWIN__)
30738
+#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
3074130739
# define SQLITE_WIN32_HAS_WIDE
3074230740
#endif
3074330741
3074430742
/*
3074530743
** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
3091930917
* zero for the default behavior.
3092030918
*/
3092130919
#ifndef SQLITE_WIN32_HEAP_FLAGS
3092230920
# define SQLITE_WIN32_HEAP_FLAGS (0)
3092330921
#endif
30922
+
3092430923
3092530924
/*
3092630925
** The winMemData structure stores information required by the Win32-specific
3092730926
** sqlite3_mem_methods implementation.
3092830927
*/
@@ -31267,11 +31266,11 @@
3126731266
{ "GetTempPathA", (SYSCALL)0, 0 },
3126831267
#endif
3126931268
3127031269
#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
3127131270
31272
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
31271
+#if !SQLITE_OS_WINRT && !defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE)
3127331272
{ "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
3127431273
#else
3127531274
{ "GetTempPathW", (SYSCALL)0, 0 },
3127631275
#endif
3127731276
@@ -34384,14 +34383,14 @@
3438434383
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3438534384
osGetCurrentProcessId(), pFd));
3438634385
return SQLITE_OK;
3438734386
}
3438834387
assert( (nMap % winSysInfo.dwPageSize)==0 );
34389
-#if SQLITE_OS_WINRT
34390
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391
-#else
3439234388
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34389
+#if SQLITE_OS_WINRT
34390
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34391
+#else
3439334392
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3439434393
#endif
3439534394
if( pNew==NULL ){
3439634395
osCloseHandle(pFd->hMap);
3439734396
pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
3455634555
#endif
3455734556
/* caller will handle out of memory */
3455834557
return zConverted;
3455934558
}
3456034559
34560
+/*
34561
+** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34562
+** in characters, so we allocate 3 bytes per character assuming worst-case
34563
+** 3-bytes-per-character UTF8.
34564
+*/
34565
+#ifndef SQLITE_WIN32_MAX_PATH
34566
+# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34567
+#endif
34568
+
3456134569
static int winIsDir(const void *zConverted);
3456234570
3456334571
/*
3456434572
** Create a temporary file name in zBuf. zBuf must be big enough to
3456534573
** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
3456934577
"abcdefghijklmnopqrstuvwxyz"
3457034578
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457134579
"0123456789";
3457234580
size_t i, j;
3457334581
int nTempPath;
34574
- char zTempPath[MAX_PATH+2];
34582
+ char zTempPath[SQLITE_WIN32_MAX_PATH+2];
3457534583
3457634584
/* It's odd to simulate an io-error here, but really this is just
3457734585
** using the io-error infrastructure to test that SQLite handles this
3457834586
** function failing.
3457934587
*/
3458034588
SimulateIOError( return SQLITE_IOERR );
3458134589
34582
- memset(zTempPath, 0, MAX_PATH+2);
34583
-
3458434590
if( sqlite3_temp_directory ){
34585
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
34591
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34592
+ sqlite3_temp_directory);
3458634593
}
3458734594
#if defined(__CYGWIN__)
3458834595
else{
3458934596
static const char *azDirs[] = {
3459034597
0,
@@ -34621,42 +34628,64 @@
3462134628
if( winIsDir(zWidePath) ){
3462234629
break;
3462334630
}
3462434631
azDirs[i] = ""; /* Don't retry in future call */
3462534632
}
34626
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34633
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zDir);
3462734634
}
3462834635
#elif !SQLITE_OS_WINRT
3462934636
else if( isNT() ){
3463034637
char *zMulti;
3463134638
WCHAR zWidePath[MAX_PATH];
34632
- osGetTempPathW(MAX_PATH-30, zWidePath);
34639
+ if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34640
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34641
+ return SQLITE_IOERR_GETTEMPPATH;
34642
+ }
3463334643
zMulti = unicodeToUtf8(zWidePath);
3463434644
if( zMulti ){
34635
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34645
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
3463634646
sqlite3_free(zMulti);
3463734647
}else{
3463834648
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3463934649
return SQLITE_IOERR_NOMEM;
3464034650
}
3464134651
}
3464234652
#ifdef SQLITE_WIN32_HAS_ANSI
3464334653
else{
3464434654
char *zUtf8;
34645
- char zMbcsPath[MAX_PATH];
34646
- osGetTempPathA(MAX_PATH-30, zMbcsPath);
34655
+ char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34656
+ if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34657
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34658
+ return SQLITE_IOERR_GETTEMPPATH;
34659
+ }
3464734660
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3464834661
if( zUtf8 ){
34649
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34662
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
3465034663
sqlite3_free(zUtf8);
3465134664
}else{
3465234665
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3465334666
return SQLITE_IOERR_NOMEM;
3465434667
}
3465534668
}
34656
-#endif
34657
-#endif
34669
+#else
34670
+ else{
34671
+ /*
34672
+ ** Compiled without ANSI support and the current operating system
34673
+ ** is not Windows NT; therefore, just zero the temporary buffer.
34674
+ */
34675
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34676
+ }
34677
+#endif /* SQLITE_WIN32_HAS_ANSI */
34678
+#else
34679
+ else{
34680
+ /*
34681
+ ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34682
+ ** therefore, just zero the temporary buffer.
34683
+ */
34684
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34685
+ }
34686
+#endif /* !SQLITE_OS_WINRT */
3465834687
3465934688
/* Check that the output buffer is large enough for the temporary file
3466034689
** name. If it is not, return SQLITE_ERROR.
3466134690
*/
3466234691
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
3473834767
int cnt = 0;
3473934768
3474034769
/* If argument zPath is a NULL pointer, this function is required to open
3474134770
** a temporary file. Use this buffer to store the file name in.
3474234771
*/
34743
- char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34772
+ char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
3474434773
3474534774
int rc = SQLITE_OK; /* Function Return Code */
3474634775
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3474734776
int eType = flags&0xFFFFFF00; /* Type of file to open */
3474834777
#endif
@@ -34804,12 +34833,11 @@
3480434833
/* If the second argument to this function is NULL, generate a
3480534834
** temporary file name to use
3480634835
*/
3480734836
if( !zUtf8Name ){
3480834837
assert(isDelete && !isOpenJournal);
34809
- memset(zTmpname, 0, MAX_PATH+2);
34810
- rc = getTempname(MAX_PATH+2, zTmpname);
34838
+ rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
3481134839
if( rc!=SQLITE_OK ){
3481234840
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3481334841
return rc;
3481434842
}
3481534843
zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
3523635264
){
3523735265
3523835266
#if defined(__CYGWIN__)
3523935267
SimulateIOError( return SQLITE_ERROR );
3524035268
UNUSED_PARAMETER(nFull);
35241
- assert( pVfs->mxPathname>=MAX_PATH );
35269
+ assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
3524235270
assert( nFull>=pVfs->mxPathname );
3524335271
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3524435272
/*
3524535273
** NOTE: We are dealing with a relative path name and the data
3524635274
** directory has been set. Therefore, use it as the basis
3524735275
** for converting the relative path name to an absolute
3524835276
** one by prepending the data directory and a slash.
3524935277
*/
35250
- char zOut[MAX_PATH+1];
35251
- memset(zOut, 0, MAX_PATH+1);
35252
- cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253
- MAX_PATH+1);
35278
+ char zOut[SQLITE_WIN32_MAX_PATH+1];
35279
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35280
+ SQLITE_WIN32_MAX_PATH+1)<0 ){
35281
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
+ zRelative);
35283
+ return SQLITE_CANTOPEN_FULLPATH;
35284
+ }
3525435285
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3525535286
sqlite3_data_directory, zOut);
3525635287
}else{
35257
- cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
35288
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35289
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35290
+ zRelative);
35291
+ return SQLITE_CANTOPEN_FULLPATH;
35292
+ }
3525835293
}
3525935294
return SQLITE_OK;
3526035295
#endif
3526135296
3526235297
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
3559435629
*/
3559535630
SQLITE_API int sqlite3_os_init(void){
3559635631
static sqlite3_vfs winVfs = {
3559735632
3, /* iVersion */
3559835633
sizeof(winFile), /* szOsFile */
35599
- MAX_PATH, /* mxPathname */
35634
+ SQLITE_WIN32_MAX_PATH, /* mxPathname */
3560035635
0, /* pNext */
3560135636
"win32", /* zName */
3560235637
0, /* pAppData */
3560335638
winOpen, /* xOpen */
3560435639
winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
6021960254
** a prior call to sqlite3VdbeMakeLabel().
6022060255
*/
6022160256
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
6022260257
int j = -1-x;
6022360258
assert( p->magic==VDBE_MAGIC_INIT );
60224
- assert( j>=0 && j<p->nLabel );
60225
- if( p->aLabel ){
60259
+ assert( j<p->nLabel );
60260
+ if( j>=0 && p->aLabel ){
6022660261
p->aLabel[j] = p->nOp;
6022760262
}
6022860263
}
6022960264
6023060265
/*
@@ -60376,44 +60411,64 @@
6037660411
p->readOnly = 1;
6037760412
p->bIsReader = 0;
6037860413
for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
6037960414
u8 opcode = pOp->opcode;
6038060415
60381
- pOp->opflags = sqlite3OpcodeProperty[opcode];
60382
- if( opcode==OP_Function || opcode==OP_AggStep ){
60383
- if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60384
- }else if( opcode==OP_Transaction ){
60385
- if( pOp->p2!=0 ) p->readOnly = 0;
60386
- p->bIsReader = 1;
60387
- }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60388
- p->bIsReader = 1;
60389
- }else if( opcode==OP_Vacuum
60390
- || opcode==OP_JournalMode
60416
+ /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60417
+ ** cases from this switch! */
60418
+ switch( opcode ){
60419
+ case OP_Function:
60420
+ case OP_AggStep: {
60421
+ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60422
+ break;
60423
+ }
60424
+ case OP_Transaction: {
60425
+ if( pOp->p2!=0 ) p->readOnly = 0;
60426
+ /* fall thru */
60427
+ }
60428
+ case OP_AutoCommit:
60429
+ case OP_Savepoint: {
60430
+ p->bIsReader = 1;
60431
+ break;
60432
+ }
6039160433
#ifndef SQLITE_OMIT_WAL
60392
- || opcode==OP_Checkpoint
60434
+ case OP_Checkpoint:
6039360435
#endif
60394
- ){
60395
- p->readOnly = 0;
60396
- p->bIsReader = 1;
60436
+ case OP_Vacuum:
60437
+ case OP_JournalMode: {
60438
+ p->readOnly = 0;
60439
+ p->bIsReader = 1;
60440
+ break;
60441
+ }
6039760442
#ifndef SQLITE_OMIT_VIRTUALTABLE
60398
- }else if( opcode==OP_VUpdate ){
60399
- if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60400
- }else if( opcode==OP_VFilter ){
60401
- int n;
60402
- assert( p->nOp - i >= 3 );
60403
- assert( pOp[-1].opcode==OP_Integer );
60404
- n = pOp[-1].p1;
60405
- if( n>nMaxArgs ) nMaxArgs = n;
60406
-#endif
60407
- }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60408
- pOp->p4.xAdvance = sqlite3BtreeNext;
60409
- pOp->p4type = P4_ADVANCE;
60410
- }else if( opcode==OP_Prev ){
60411
- pOp->p4.xAdvance = sqlite3BtreePrevious;
60412
- pOp->p4type = P4_ADVANCE;
60413
- }
60414
-
60443
+ case OP_VUpdate: {
60444
+ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60445
+ break;
60446
+ }
60447
+ case OP_VFilter: {
60448
+ int n;
60449
+ assert( p->nOp - i >= 3 );
60450
+ assert( pOp[-1].opcode==OP_Integer );
60451
+ n = pOp[-1].p1;
60452
+ if( n>nMaxArgs ) nMaxArgs = n;
60453
+ break;
60454
+ }
60455
+#endif
60456
+ case OP_Next:
60457
+ case OP_SorterNext: {
60458
+ pOp->p4.xAdvance = sqlite3BtreeNext;
60459
+ pOp->p4type = P4_ADVANCE;
60460
+ break;
60461
+ }
60462
+ case OP_Prev: {
60463
+ pOp->p4.xAdvance = sqlite3BtreePrevious;
60464
+ pOp->p4type = P4_ADVANCE;
60465
+ break;
60466
+ }
60467
+ }
60468
+
60469
+ pOp->opflags = sqlite3OpcodeProperty[opcode];
6041560470
if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
6041660471
assert( -1-pOp->p2<p->nLabel );
6041760472
pOp->p2 = aLabel[-1-pOp->p2];
6041860473
}
6041960474
}
@@ -60544,12 +60599,11 @@
6054460599
/*
6054560600
** Change the P2 operand of instruction addr so that it points to
6054660601
** the address of the next instruction to be coded.
6054760602
*/
6054860603
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60549
- assert( addr>=0 || p->db->mallocFailed );
60550
- if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60604
+ if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
6055160605
}
6055260606
6055360607
6055460608
/*
6055560609
** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
6058160635
}
6058260636
case P4_MPRINTF: {
6058360637
if( db->pnBytesFreed==0 ) sqlite3_free(p4);
6058460638
break;
6058560639
}
60586
- case P4_VDBEFUNC: {
60587
- VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588
- freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589
- if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590
- sqlite3DbFree(db, pVdbeFunc);
60591
- break;
60592
- }
6059360640
case P4_FUNCDEF: {
6059460641
freeEphemeralFunction(db, (FuncDef*)p4);
6059560642
break;
6059660643
}
6059760644
case P4_MEM: {
@@ -60706,24 +60753,17 @@
6070660753
pOp->p4type = P4_INT32;
6070760754
}else if( zP4==0 ){
6070860755
pOp->p4.p = 0;
6070960756
pOp->p4type = P4_NOTUSED;
6071060757
}else if( n==P4_KEYINFO ){
60711
- KeyInfo *pKeyInfo;
60712
- int nField, nByte;
60713
-
60714
- nField = ((KeyInfo*)zP4)->nField;
60715
- nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60716
- pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60717
- pOp->p4.pKeyInfo = pKeyInfo;
60718
- if( pKeyInfo ){
60719
- u8 *aSortOrder;
60720
- memcpy((char*)pKeyInfo, zP4, nByte - nField);
60721
- aSortOrder = pKeyInfo->aSortOrder;
60722
- assert( aSortOrder!=0 );
60723
- pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60724
- memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60758
+ KeyInfo *pOrig, *pNew;
60759
+
60760
+ pOrig = (KeyInfo*)zP4;
60761
+ pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60762
+ if( pNew ){
60763
+ memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60764
+ memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
6072560765
pOp->p4type = P4_KEYINFO;
6072660766
}else{
6072760767
p->db->mallocFailed = 1;
6072860768
pOp->p4type = P4_NOTUSED;
6072960769
}
@@ -61617,10 +61657,14 @@
6161761657
while( p->pDelFrame ){
6161861658
VdbeFrame *pDel = p->pDelFrame;
6161961659
p->pDelFrame = pDel->pParent;
6162061660
sqlite3VdbeFrameDelete(pDel);
6162161661
}
61662
+
61663
+ /* Delete any auxdata allocations made by the VM */
61664
+ sqlite3VdbeDeleteAuxData(p, -1, 0);
61665
+ assert( p->pAuxData==0 );
6162261666
}
6162361667
6162461668
/*
6162561669
** Clean up the VM after execution.
6162661670
**
@@ -62415,24 +62459,39 @@
6241562459
sqlite3VdbeDelete(p);
6241662460
return rc;
6241762461
}
6241862462
6241962463
/*
62420
-** Call the destructor for each auxdata entry in pVdbeFunc for which
62421
-** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422
-** are always destroyed. To destroy all auxdata entries, call this
62423
-** routine with mask==0.
62464
+** If parameter iOp is less than zero, then invoke the destructor for
62465
+** all auxiliary data pointers currently cached by the VM passed as
62466
+** the first argument.
62467
+**
62468
+** Or, if iOp is greater than or equal to zero, then the destructor is
62469
+** only invoked for those auxiliary data pointers created by the user
62470
+** function invoked by the OP_Function opcode at instruction iOp of
62471
+** VM pVdbe, and only then if:
62472
+**
62473
+** * the associated function parameter is the 32nd or later (counting
62474
+** from left to right), or
62475
+**
62476
+** * the corresponding bit in argument mask is clear (where the first
62477
+** function parameter corrsponds to bit 0 etc.).
6242462478
*/
62425
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426
- int i;
62427
- for(i=0; i<pVdbeFunc->nAux; i++){
62428
- struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429
- if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
62479
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62480
+ AuxData **pp = &pVdbe->pAuxData;
62481
+ while( *pp ){
62482
+ AuxData *pAux = *pp;
62483
+ if( (iOp<0)
62484
+ || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62485
+ ){
6243062486
if( pAux->xDelete ){
6243162487
pAux->xDelete(pAux->pAux);
6243262488
}
62433
- pAux->pAux = 0;
62489
+ *pp = pAux->pNext;
62490
+ sqlite3DbFree(pVdbe->db, pAux);
62491
+ }else{
62492
+ pp= &pAux->pNext;
6243462493
}
6243562494
}
6243662495
}
6243762496
6243862497
/*
@@ -62947,15 +63006,14 @@
6294763006
*/
6294863007
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
6294963008
int nKey1, const void *pKey1, /* Left key */
6295063009
UnpackedRecord *pPKey2 /* Right key */
6295163010
){
62952
- int d1; /* Offset into aKey[] of next data element */
63011
+ u32 d1; /* Offset into aKey[] of next data element */
6295363012
u32 idx1; /* Offset into aKey[] of next header element */
6295463013
u32 szHdr1; /* Number of bytes in header */
6295563014
int i = 0;
62956
- int nField;
6295763015
int rc = 0;
6295863016
const unsigned char *aKey1 = (const unsigned char *)pKey1;
6295963017
KeyInfo *pKeyInfo;
6296063018
Mem mem1;
6296163019
@@ -62974,32 +63032,42 @@
6297463032
*/
6297563033
/* mem1.u.i = 0; // not needed, here to silence compiler warning */
6297663034
6297763035
idx1 = getVarint32(aKey1, szHdr1);
6297863036
d1 = szHdr1;
62979
- nField = pKeyInfo->nField;
63037
+ assert( pKeyInfo->nField+1>=pPKey2->nField );
6298063038
assert( pKeyInfo->aSortOrder!=0 );
6298163039
while( idx1<szHdr1 && i<pPKey2->nField ){
6298263040
u32 serial_type1;
6298363041
6298463042
/* Read the serial types for the next element in each key. */
6298563043
idx1 += getVarint32( aKey1+idx1, serial_type1 );
62986
- if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
63044
+
63045
+ /* Verify that there is enough key space remaining to avoid
63046
+ ** a buffer overread. The "d1+serial_type1+2" subexpression will
63047
+ ** always be greater than or equal to the amount of required key space.
63048
+ ** Use that approximation to avoid the more expensive call to
63049
+ ** sqlite3VdbeSerialTypeLen() in the common case.
63050
+ */
63051
+ if( d1+serial_type1+2>(u32)nKey1
63052
+ && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63053
+ ){
63054
+ break;
63055
+ }
6298763056
6298863057
/* Extract the values to be compared.
6298963058
*/
6299063059
d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
6299163060
6299263061
/* Do the comparison
6299363062
*/
62994
- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62995
- i<nField ? pKeyInfo->aColl[i] : 0);
63063
+ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
6299663064
if( rc!=0 ){
6299763065
assert( mem1.zMalloc==0 ); /* See comment below */
6299863066
6299963067
/* Invert the result if we are using DESC sort order. */
63000
- if( i<nField && pKeyInfo->aSortOrder[i] ){
63068
+ if( pKeyInfo->aSortOrder[i] ){
6300163069
rc = -rc;
6300263070
}
6300363071
6300463072
/* If the PREFIX_SEARCH flag is set and all fields except the final
6300563073
** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
6321063278
** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
6321163279
** constants) to the value before returning it.
6321263280
**
6321363281
** The returned value must be freed by the caller using sqlite3ValueFree().
6321463282
*/
63215
-SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63283
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
6321663284
assert( iVar>0 );
6321763285
if( v ){
6321863286
Mem *pMem = &v->aVar[iVar-1];
6321963287
if( 0==(pMem->flags & MEM_Null) ){
6322063288
sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
6382763895
/*
6382863896
** Return the auxilary data pointer, if any, for the iArg'th argument to
6382963897
** the user-function defined by pCtx.
6383063898
*/
6383163899
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832
- VdbeFunc *pVdbeFunc;
63900
+ AuxData *pAuxData;
6383363901
6383463902
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835
- pVdbeFunc = pCtx->pVdbeFunc;
63836
- if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837
- return 0;
63903
+ for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63904
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
6383863905
}
63839
- return pVdbeFunc->apAux[iArg].pAux;
63906
+
63907
+ return (pAuxData ? pAuxData->pAux : 0);
6384063908
}
6384163909
6384263910
/*
6384363911
** Set the auxilary data pointer and delete function, for the iArg'th
6384463912
** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
6384863916
sqlite3_context *pCtx,
6384963917
int iArg,
6385063918
void *pAux,
6385163919
void (*xDelete)(void*)
6385263920
){
63853
- struct AuxData *pAuxData;
63854
- VdbeFunc *pVdbeFunc;
63855
- if( iArg<0 ) goto failed;
63921
+ AuxData *pAuxData;
63922
+ Vdbe *pVdbe = pCtx->pVdbe;
6385663923
6385763924
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858
- pVdbeFunc = pCtx->pVdbeFunc;
63859
- if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860
- int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861
- int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862
- pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863
- if( !pVdbeFunc ){
63864
- goto failed;
63865
- }
63866
- pCtx->pVdbeFunc = pVdbeFunc;
63867
- memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868
- pVdbeFunc->nAux = iArg+1;
63869
- pVdbeFunc->pFunc = pCtx->pFunc;
63870
- }
63871
-
63872
- pAuxData = &pVdbeFunc->apAux[iArg];
63873
- if( pAuxData->pAux && pAuxData->xDelete ){
63925
+ if( iArg<0 ) goto failed;
63926
+
63927
+ for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63928
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63929
+ }
63930
+ if( pAuxData==0 ){
63931
+ pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63932
+ if( !pAuxData ) goto failed;
63933
+ pAuxData->iOp = pCtx->iOp;
63934
+ pAuxData->iArg = iArg;
63935
+ pAuxData->pNext = pVdbe->pAuxData;
63936
+ pVdbe->pAuxData = pAuxData;
63937
+ }else if( pAuxData->xDelete ){
6387463938
pAuxData->xDelete(pAuxData->pAux);
6387563939
}
63940
+
6387663941
pAuxData->pAux = pAux;
6387763942
pAuxData->xDelete = xDelete;
6387863943
return;
6387963944
6388063945
failed:
@@ -65482,11 +65547,11 @@
6548265547
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6548365548
u8 encoding = ENC(db); /* The database encoding */
6548465549
int iCompare = 0; /* Result of last OP_Compare operation */
6548565550
unsigned nVmStep = 0; /* Number of virtual machine steps */
6548665551
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487
- unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65552
+ unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
6548865553
#endif
6548965554
Mem *aMem = p->aMem; /* Copy of p->aMem */
6549065555
Mem *pIn1 = 0; /* 1st input operand */
6549165556
Mem *pIn2 = 0; /* 2nd input operand */
6549265557
Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
6594166006
assert( p->explain==0 );
6594266007
p->pResultSet = 0;
6594366008
db->busyHandler.nBusy = 0;
6594466009
CHECK_FOR_INTERRUPT;
6594566010
sqlite3VdbeIOTraceSql(p);
66011
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
66012
+ if( db->xProgress ){
66013
+ assert( 0 < db->nProgressOps );
66014
+ nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
66015
+ if( nProgressLimit==0 ){
66016
+ nProgressLimit = db->nProgressOps;
66017
+ }else{
66018
+ nProgressLimit %= (unsigned)db->nProgressOps;
66019
+ }
66020
+ }
66021
+#endif
6594666022
#ifdef SQLITE_DEBUG
6594766023
sqlite3BeginBenignMalloc();
6594866024
if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
6594966025
int i;
6595066026
printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
6610166177
** of VDBE ops have been executed (either since this invocation of
6610266178
** sqlite3VdbeExec() or since last time the progress callback was called).
6610366179
** If the progress callback returns non-zero, exit the virtual machine with
6610466180
** a return code SQLITE_ABORT.
6610566181
*/
66106
- if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66182
+ if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
6610766183
int prc;
6610866184
prc = db->xProgress(db->pProgressArg);
6610966185
if( prc!=0 ){
6611066186
rc = SQLITE_INTERRUPT;
6611166187
goto vdbe_error_halt;
6611266188
}
66113
- nProgressOps = nVmStep;
66189
+ if( db->xProgress!=0 ){
66190
+ nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66191
+ }
6611466192
}
6611566193
#endif
6611666194
6611766195
break;
6611866196
}
@@ -66794,23 +66872,18 @@
6679466872
Deephemeralize(u.ai.pArg);
6679566873
sqlite3VdbeMemStoreType(u.ai.pArg);
6679666874
REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
6679766875
}
6679866876
66799
- assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800
- if( pOp->p4type==P4_FUNCDEF ){
66801
- u.ai.ctx.pFunc = pOp->p4.pFunc;
66802
- u.ai.ctx.pVdbeFunc = 0;
66803
- }else{
66804
- u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805
- u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806
- }
66807
-
66877
+ assert( pOp->p4type==P4_FUNCDEF );
66878
+ u.ai.ctx.pFunc = pOp->p4.pFunc;
6680866879
u.ai.ctx.s.flags = MEM_Null;
6680966880
u.ai.ctx.s.db = db;
6681066881
u.ai.ctx.s.xDel = 0;
6681166882
u.ai.ctx.s.zMalloc = 0;
66883
+ u.ai.ctx.iOp = pc;
66884
+ u.ai.ctx.pVdbe = p;
6681266885
6681366886
/* The output cell may already have a buffer allocated. Move
6681466887
** the pointer to u.ai.ctx.s so in case the user-function can use
6681566888
** the already allocated buffer instead of allocating a new one.
6681666889
*/
@@ -66829,15 +66902,11 @@
6682966902
lastRowid = db->lastRowid;
6683066903
6683166904
/* If any auxiliary data functions have been called by this user function,
6683266905
** immediately call the destructor for any non-static values.
6683366906
*/
66834
- if( u.ai.ctx.pVdbeFunc ){
66835
- sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836
- pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837
- pOp->p4type = P4_VDBEFUNC;
66838
- }
66907
+ sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
6683966908
6684066909
if( db->mallocFailed ){
6684166910
/* Even though a malloc() has failed, the implementation of the
6684266911
** user function may have called an sqlite3_result_XXX() function
6684366912
** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
7420074269
/* Translate the schema name in zDb into a pointer to the corresponding
7420174270
** schema. If not found, pSchema will remain NULL and nothing will match
7420274271
** resulting in an appropriate error message toward the end of this routine
7420374272
*/
7420474273
if( zDb ){
74205
- for(i=0; i<db->nDb; i++){
74206
- assert( db->aDb[i].zName );
74207
- if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74208
- pSchema = db->aDb[i].pSchema;
74209
- break;
74274
+ testcase( pNC->ncFlags & NC_PartIdx );
74275
+ testcase( pNC->ncFlags & NC_IsCheck );
74276
+ if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74277
+ /* Silently ignore database qualifiers inside CHECK constraints and partial
74278
+ ** indices. Do not raise errors because that might break legacy and
74279
+ ** because it does not hurt anything to just ignore the database name. */
74280
+ zDb = 0;
74281
+ }else{
74282
+ for(i=0; i<db->nDb; i++){
74283
+ assert( db->aDb[i].zName );
74284
+ if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74285
+ pSchema = db->aDb[i].pSchema;
74286
+ break;
74287
+ }
7421074288
}
7421174289
}
7421274290
}
7421374291
7421474292
/* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
7448174559
}
7448274560
ExprSetProperty(p, EP_Resolved);
7448374561
}
7448474562
return p;
7448574563
}
74564
+
74565
+/*
74566
+** Report an error that an expression is not valid for a partial index WHERE
74567
+** clause.
74568
+*/
74569
+static void notValidPartIdxWhere(
74570
+ Parse *pParse, /* Leave error message here */
74571
+ NameContext *pNC, /* The name context */
74572
+ const char *zMsg /* Type of error */
74573
+){
74574
+ if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74575
+ sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74576
+ zMsg);
74577
+ }
74578
+}
74579
+
74580
+#ifndef SQLITE_OMIT_CHECK
74581
+/*
74582
+** Report an error that an expression is not valid for a CHECK constraint.
74583
+*/
74584
+static void notValidCheckConstraint(
74585
+ Parse *pParse, /* Leave error message here */
74586
+ NameContext *pNC, /* The name context */
74587
+ const char *zMsg /* Type of error */
74588
+){
74589
+ if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74590
+ sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74591
+ }
74592
+}
74593
+#else
74594
+# define notValidCheckConstraint(P,N,M)
74595
+#endif
74596
+
7448674597
7448774598
/*
7448874599
** This routine is callback for sqlite3WalkExpr().
7448974600
**
7449074601
** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
7458174692
FuncDef *pDef; /* Information about the function */
7458274693
u8 enc = ENC(pParse->db); /* The database encoding */
7458374694
7458474695
testcase( pExpr->op==TK_CONST_FUNC );
7458574696
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74697
+ notValidPartIdxWhere(pParse, pNC, "functions");
7458674698
zId = pExpr->u.zToken;
7458774699
nId = sqlite3Strlen30(zId);
7458874700
pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
7458974701
if( pDef==0 ){
7459074702
pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
7464674758
#endif
7464774759
case TK_IN: {
7464874760
testcase( pExpr->op==TK_IN );
7464974761
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7465074762
int nRef = pNC->nRef;
74651
-#ifndef SQLITE_OMIT_CHECK
74652
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74653
- sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74654
- }
74655
-#endif
74763
+ notValidCheckConstraint(pParse, pNC, "subqueries");
74764
+ notValidPartIdxWhere(pParse, pNC, "subqueries");
7465674765
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
7465774766
assert( pNC->nRef>=nRef );
7465874767
if( nRef!=pNC->nRef ){
7465974768
ExprSetProperty(pExpr, EP_VarSelect);
7466074769
}
7466174770
}
7466274771
break;
7466374772
}
74664
-#ifndef SQLITE_OMIT_CHECK
7466574773
case TK_VARIABLE: {
74666
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74667
- sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74668
- }
74774
+ notValidCheckConstraint(pParse, pNC, "parameters");
74775
+ notValidPartIdxWhere(pParse, pNC, "parameters");
7466974776
break;
7467074777
}
74671
-#endif
7467274778
}
7467374779
return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
7467474780
}
7467574781
7467674782
/*
@@ -74757,11 +74863,11 @@
7475774863
/* Try to match the ORDER BY expression against an expression
7475874864
** in the result set. Return an 1-based index of the matching
7475974865
** result-set entry.
7476074866
*/
7476174867
for(i=0; i<pEList->nExpr; i++){
74762
- if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74868
+ if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
7476374869
return i+1;
7476474870
}
7476574871
}
7476674872
7476774873
/* If no match, return 0. */
@@ -74985,11 +75091,11 @@
7498575091
pItem->iOrderByCol = 0;
7498675092
if( sqlite3ResolveExprNames(pNC, pE) ){
7498775093
return 1;
7498875094
}
7498975095
for(j=0; j<pSelect->pEList->nExpr; j++){
74990
- if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
75096
+ if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
7499175097
pItem->iOrderByCol = j+1;
7499275098
}
7499375099
}
7499475100
}
7499575101
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
7529175397
w.xSelectCallback = resolveSelectStep;
7529275398
w.pParse = pParse;
7529375399
w.u.pNC = pOuterNC;
7529475400
sqlite3WalkSelect(&w, p);
7529575401
}
75402
+
75403
+/*
75404
+** Resolve names in expressions that can only reference a single table:
75405
+**
75406
+** * CHECK constraints
75407
+** * WHERE clauses on partial indices
75408
+**
75409
+** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75410
+** is set to -1 and the Expr.iColumn value is set to the column number.
75411
+**
75412
+** Any errors cause an error message to be set in pParse.
75413
+*/
75414
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75415
+ Parse *pParse, /* Parsing context */
75416
+ Table *pTab, /* The table being referenced */
75417
+ int type, /* NC_IsCheck or NC_PartIdx */
75418
+ Expr *pExpr, /* Expression to resolve. May be NULL. */
75419
+ ExprList *pList /* Expression list to resolve. May be NUL. */
75420
+){
75421
+ SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75422
+ NameContext sNC; /* Name context for pParse->pNewTable */
75423
+ int i; /* Loop counter */
75424
+
75425
+ assert( type==NC_IsCheck || type==NC_PartIdx );
75426
+ memset(&sNC, 0, sizeof(sNC));
75427
+ memset(&sSrc, 0, sizeof(sSrc));
75428
+ sSrc.nSrc = 1;
75429
+ sSrc.a[0].zName = pTab->zName;
75430
+ sSrc.a[0].pTab = pTab;
75431
+ sSrc.a[0].iCursor = -1;
75432
+ sNC.pParse = pParse;
75433
+ sNC.pSrcList = &sSrc;
75434
+ sNC.ncFlags = type;
75435
+ if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75436
+ if( pList ){
75437
+ for(i=0; i<pList->nExpr; i++){
75438
+ if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75439
+ return;
75440
+ }
75441
+ }
75442
+ }
75443
+}
7529675444
7529775445
/************** End of resolve.c *********************************************/
7529875446
/************** Begin file expr.c ********************************************/
7529975447
/*
7530075448
** 2001 September 15
@@ -76987,14 +77135,13 @@
7698777135
#endif
7698877136
7698977137
switch( pExpr->op ){
7699077138
case TK_IN: {
7699177139
char affinity; /* Affinity of the LHS of the IN */
76992
- KeyInfo keyInfo; /* Keyinfo for the generated table */
76993
- static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
7699477140
int addr; /* Address of OP_OpenEphemeral instruction */
7699577141
Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77142
+ KeyInfo *pKeyInfo = 0; /* Key information */
7699677143
7699777144
if( rMayHaveNull ){
7699877145
sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
7699977146
}
7700077147
@@ -77014,13 +77161,11 @@
7701477161
** is used.
7701577162
*/
7701677163
pExpr->iTable = pParse->nTab++;
7701777164
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
7701877165
if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77019
- memset(&keyInfo, 0, sizeof(keyInfo));
77020
- keyInfo.nField = 1;
77021
- keyInfo.aSortOrder = &sortOrder;
77166
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
7702277167
7702377168
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7702477169
/* Case 1: expr IN (SELECT ...)
7702577170
**
7702677171
** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
7703377178
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
7703477179
dest.affSdst = (u8)affinity;
7703577180
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
7703677181
pExpr->x.pSelect->iLimit = 0;
7703777182
if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77183
+ sqlite3DbFree(pParse->db, pKeyInfo);
7703877184
return 0;
7703977185
}
7704077186
pEList = pExpr->x.pSelect->pEList;
77041
- if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77042
- keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77187
+ if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77188
+ pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
7704377189
pEList->a[0].pExpr);
7704477190
}
7704577191
}else if( ALWAYS(pExpr->x.pList!=0) ){
7704677192
/* Case 2: expr IN (exprlist)
7704777193
**
@@ -77056,12 +77202,13 @@
7705677202
int r1, r2, r3;
7705777203
7705877204
if( !affinity ){
7705977205
affinity = SQLITE_AFF_NONE;
7706077206
}
77061
- keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77062
- keyInfo.aSortOrder = &sortOrder;
77207
+ if( pKeyInfo ){
77208
+ pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77209
+ }
7706377210
7706477211
/* Loop through each expression in <exprlist>. */
7706577212
r1 = sqlite3GetTempReg(pParse);
7706677213
r2 = sqlite3GetTempReg(pParse);
7706777214
sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
7709677243
}
7709777244
}
7709877245
sqlite3ReleaseTempReg(pParse, r1);
7709977246
sqlite3ReleaseTempReg(pParse, r2);
7710077247
}
77101
- if( !isRowid ){
77102
- sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77248
+ if( pKeyInfo ){
77249
+ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
7710377250
}
7710477251
break;
7710577252
}
7710677253
7710777254
case TK_EXISTS:
@@ -77657,19 +77804,24 @@
7765777804
break;
7765877805
}
7765977806
/* Otherwise, fall thru into the TK_COLUMN case */
7766077807
}
7766177808
case TK_COLUMN: {
77662
- if( pExpr->iTable<0 ){
77663
- /* This only happens when coding check constraints */
77664
- assert( pParse->ckBase>0 );
77665
- inReg = pExpr->iColumn + pParse->ckBase;
77666
- }else{
77667
- inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77668
- pExpr->iColumn, pExpr->iTable, target,
77669
- pExpr->op2);
77670
- }
77809
+ int iTab = pExpr->iTable;
77810
+ if( iTab<0 ){
77811
+ if( pParse->ckBase>0 ){
77812
+ /* Generating CHECK constraints or inserting into partial index */
77813
+ inReg = pExpr->iColumn + pParse->ckBase;
77814
+ break;
77815
+ }else{
77816
+ /* Deleting from a partial index */
77817
+ iTab = pParse->iPartIdxTab;
77818
+ }
77819
+ }
77820
+ inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77821
+ pExpr->iColumn, iTab, target,
77822
+ pExpr->op2);
7767177823
break;
7767277824
}
7767377825
case TK_INTEGER: {
7767477826
codeInteger(pParse, pExpr, 0, target);
7767577827
break;
@@ -79088,10 +79240,16 @@
7908879240
** Do a deep comparison of two expression trees. Return 0 if the two
7908979241
** expressions are completely identical. Return 1 if they differ only
7909079242
** by a COLLATE operator at the top level. Return 2 if there are differences
7909179243
** other than the top-level COLLATE operator.
7909279244
**
79245
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79246
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79247
+**
79248
+** The pA side might be using TK_REGISTER. If that is the case and pB is
79249
+** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79250
+**
7909379251
** Sometimes this routine will return 2 even if the two expressions
7909479252
** really are equivalent. If we cannot prove that the expressions are
7909579253
** identical, we return 2 just to be safe. So if this routine
7909679254
** returns 2, then you do not really know for certain if the two
7909779255
** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
7909879256
** can be sure the expressions are the same. In the places where
7909979257
** this routine is used, it does not hurt to get an extra 2 - that
7910079258
** just might result in some slightly slower code. But returning
7910179259
** an incorrect 0 or 1 could lead to a malfunction.
7910279260
*/
79103
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79261
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
7910479262
if( pA==0||pB==0 ){
7910579263
return pB==pA ? 0 : 2;
7910679264
}
7910779265
assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
7910879266
assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
7910979267
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
7911079268
return 2;
7911179269
}
7911279270
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79113
- if( pA->op!=pB->op ){
79114
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79271
+ if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79272
+ if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
7911579273
return 1;
7911679274
}
79117
- if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79275
+ if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
7911879276
return 1;
7911979277
}
7912079278
return 2;
7912179279
}
79122
- if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79123
- if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79124
- if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79125
- if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
79280
+ if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79281
+ if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79282
+ if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79283
+ if( pA->iColumn!=pB->iColumn ) return 2;
79284
+ if( pA->iTable!=pB->iTable
79285
+ && pA->op!=TK_REGISTER
79286
+ && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
7912679287
if( ExprHasProperty(pA, EP_IntValue) ){
7912779288
if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
7912879289
return 2;
7912979290
}
7913079291
}else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
7913879299
7913979300
/*
7914079301
** Compare two ExprList objects. Return 0 if they are identical and
7914179302
** non-zero if they differ in any way.
7914279303
**
79304
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79305
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79306
+**
7914379307
** This routine might return non-zero for equivalent ExprLists. The
7914479308
** only consequence will be disabled optimizations. But this routine
7914579309
** must never return 0 if the two ExprList objects are different, or
7914679310
** a malfunction will result.
7914779311
**
7914879312
** Two NULL pointers are considered to be the same. But a NULL pointer
7914979313
** always differs from a non-NULL pointer.
7915079314
*/
79151
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79315
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
7915279316
int i;
7915379317
if( pA==0 && pB==0 ) return 0;
7915479318
if( pA==0 || pB==0 ) return 1;
7915579319
if( pA->nExpr!=pB->nExpr ) return 1;
7915679320
for(i=0; i<pA->nExpr; i++){
7915779321
Expr *pExprA = pA->a[i].pExpr;
7915879322
Expr *pExprB = pB->a[i].pExpr;
7915979323
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79160
- if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
79324
+ if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79325
+ }
79326
+ return 0;
79327
+}
79328
+
79329
+/*
79330
+** Return true if we can prove the pE2 will always be true if pE1 is
79331
+** true. Return false if we cannot complete the proof or if pE2 might
79332
+** be false. Examples:
79333
+**
79334
+** pE1: x==5 pE2: x==5 Result: true
79335
+** pE1: x>0 pE2: x==5 Result: false
79336
+** pE1: x=21 pE2: x=21 OR y=43 Result: true
79337
+** pE1: x!=123 pE2: x IS NOT NULL Result: true
79338
+** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79339
+** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79340
+** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79341
+**
79342
+** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79343
+** Expr.iTable<0 then assume a table number given by iTab.
79344
+**
79345
+** When in doubt, return false. Returning true might give a performance
79346
+** improvement. Returning false might cause a performance reduction, but
79347
+** it will always give the correct answer and is hence always safe.
79348
+*/
79349
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79350
+ if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79351
+ return 1;
79352
+ }
79353
+ if( pE2->op==TK_OR
79354
+ && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79355
+ || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79356
+ ){
79357
+ return 1;
79358
+ }
79359
+ if( pE2->op==TK_NOTNULL
79360
+ && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79361
+ && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79362
+ ){
79363
+ return 1;
7916179364
}
7916279365
return 0;
7916379366
}
7916479367
7916579368
/*
@@ -79340,11 +79543,11 @@
7934079543
/* Check to see if pExpr is a duplicate of another aggregate
7934179544
** function that is already in the pAggInfo structure
7934279545
*/
7934379546
struct AggInfo_func *pItem = pAggInfo->aFunc;
7934479547
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79345
- if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79548
+ if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
7934679549
break;
7934779550
}
7934879551
}
7934979552
if( i>=pAggInfo->nFunc ){
7935079553
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
8075780960
int i; /* Loop counter */
8075880961
int topOfLoop; /* The top of the loop */
8075980962
int endOfLoop; /* The end of the loop */
8076080963
int jZeroRows = -1; /* Jump from here if number of rows is zero */
8076180964
int iDb; /* Index of database containing pTab */
80965
+ u8 needTableCnt = 1; /* True to count the table */
8076280966
int regTabname = iMem++; /* Register containing table name */
8076380967
int regIdxname = iMem++; /* Register containing index name */
8076480968
int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
8076580969
#ifdef SQLITE_ENABLE_STAT3
8076680970
int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
8081681020
KeyInfo *pKey;
8081781021
int addrIfNot = 0; /* address of OP_IfNot */
8081881022
int *aChngAddr; /* Array of jump instruction addresses */
8081981023
8082081024
if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
81025
+ if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
8082181026
VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
8082281027
nCol = pIdx->nColumn;
8082381028
aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
8082481029
if( aChngAddr==0 ) continue;
8082581030
pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
8097581180
** If K==0 then no entry is made into the sqlite_stat1 table.
8097681181
** If K>0 then it is always the case the D>0 so division by zero
8097781182
** is never possible.
8097881183
*/
8097981184
sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80980
- if( jZeroRows<0 ){
80981
- jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80982
- }
81185
+ jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
8098381186
for(i=0; i<nCol; i++){
8098481187
sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
8098581188
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8098681189
sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
8098781190
sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
8098881191
sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
8098981192
sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
8099081193
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8099181194
}
81195
+ if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8099281196
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
8099381197
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
8099481198
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
8099581199
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81200
+ if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8099681201
}
8099781202
80998
- /* If the table has no indices, create a single sqlite_stat1 entry
80999
- ** containing NULL as the index name and the row count as the content.
81203
+ /* Create a single sqlite_stat1 entry containing NULL as the index
81204
+ ** name and the row count as the content.
8100081205
*/
81001
- if( pTab->pIndex==0 ){
81206
+ if( pOnlyIdx==0 && needTableCnt ){
8100281207
sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
8100381208
VdbeComment((v, "%s", pTab->zName));
8100481209
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
8100581210
sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
8100681211
jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81007
- }else{
81008
- sqlite3VdbeJumpHere(v, jZeroRows);
81009
- jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
81010
- }
81011
- sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81012
- sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81013
- sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81014
- sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81015
- sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81016
- if( pParse->nMem<regRec ) pParse->nMem = regRec;
81017
- sqlite3VdbeJumpHere(v, jZeroRows);
81212
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81213
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81214
+ sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81215
+ sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81216
+ sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81217
+ sqlite3VdbeJumpHere(v, jZeroRows);
81218
+ }
81219
+ if( pParse->nMem<regRec ) pParse->nMem = regRec;
8101881220
}
8101981221
8102081222
8102181223
/*
8102281224
** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
8119581397
v = 0;
8119681398
while( (c=z[0])>='0' && c<='9' ){
8119781399
v = v*10 + c - '0';
8119881400
z++;
8119981401
}
81200
- if( i==0 ) pTable->nRowEst = v;
81201
- if( pIndex==0 ) break;
81402
+ if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81403
+ if( v>0 ) pTable->nRowEst = v;
81404
+ if( pIndex==0 ) break;
81405
+ }
8120281406
pIndex->aiRowEst[i] = v;
8120381407
if( *z==' ' ) z++;
8120481408
if( strcmp(z, "unordered")==0 ){
8120581409
pIndex->bUnordered = 1;
8120681410
break;
@@ -82636,10 +82840,11 @@
8263682840
*/
8263782841
static void freeIndex(sqlite3 *db, Index *p){
8263882842
#ifndef SQLITE_OMIT_ANALYZE
8263982843
sqlite3DeleteIndexSamples(db, p);
8264082844
#endif
82845
+ sqlite3ExprDelete(db, p->pPartIdxWhere);
8264182846
sqlite3DbFree(db, p->zColAff);
8264282847
sqlite3DbFree(db, p);
8264382848
}
8264482849
8264582850
/*
@@ -83479,11 +83684,12 @@
8347983684
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
8348083685
"INTEGER PRIMARY KEY");
8348183686
#endif
8348283687
}else{
8348383688
Index *p;
83484
- p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
83689
+ p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83690
+ 0, sortOrder, 0);
8348583691
if( p ){
8348683692
p->autoIndex = 2;
8348783693
}
8348883694
pList = 0;
8348983695
}
@@ -83774,30 +83980,11 @@
8377483980
8377583981
#ifndef SQLITE_OMIT_CHECK
8377683982
/* Resolve names in all CHECK constraint expressions.
8377783983
*/
8377883984
if( p->pCheck ){
83779
- SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83780
- NameContext sNC; /* Name context for pParse->pNewTable */
83781
- ExprList *pList; /* List of all CHECK constraints */
83782
- int i; /* Loop counter */
83783
-
83784
- memset(&sNC, 0, sizeof(sNC));
83785
- memset(&sSrc, 0, sizeof(sSrc));
83786
- sSrc.nSrc = 1;
83787
- sSrc.a[0].zName = p->zName;
83788
- sSrc.a[0].pTab = p;
83789
- sSrc.a[0].iCursor = -1;
83790
- sNC.pParse = pParse;
83791
- sNC.pSrcList = &sSrc;
83792
- sNC.ncFlags = NC_IsCheck;
83793
- pList = p->pCheck;
83794
- for(i=0; i<pList->nExpr; i++){
83795
- if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83796
- return;
83797
- }
83798
- }
83985
+ sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
8379983986
}
8380083987
#endif /* !defined(SQLITE_OMIT_CHECK) */
8380183988
8380283989
/* If the db->init.busy is 1 it means we are reading the SQL off the
8380383990
** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
8464584832
int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
8464684833
int iSorter; /* Cursor opened by OpenSorter (if in use) */
8464784834
int addr1; /* Address of top of loop */
8464884835
int addr2; /* Address to jump to for next iteration */
8464984836
int tnum; /* Root page of index */
84837
+ int iPartIdxLabel; /* Jump to this label to skip a row */
8465084838
Vdbe *v; /* Generate code into this virtual machine */
8465184839
KeyInfo *pKey; /* KeyInfo for index */
8465284840
int regRecord; /* Register holding assemblied index record */
8465384841
sqlite3 *db = pParse->db; /* The database connection */
8465484842
int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
8468484872
** records into the sorter. */
8468584873
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
8468684874
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
8468784875
regRecord = sqlite3GetTempReg(pParse);
8468884876
84689
- sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84877
+ sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
8469084878
sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84879
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8469184880
sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
8469284881
sqlite3VdbeJumpHere(v, addr1);
8469384882
addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
8469484883
if( pIndex->onError!=OE_None ){
8469584884
int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
8473684925
Token *pName2, /* Second part of index name. May be NULL */
8473784926
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
8473884927
ExprList *pList, /* A list of columns to be indexed */
8473984928
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
8474084929
Token *pStart, /* The CREATE token that begins this statement */
84741
- Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84930
+ Expr *pPIWhere, /* WHERE clause for partial indices */
8474284931
int sortOrder, /* Sort order of primary key when pList==NULL */
8474384932
int ifNotExist /* Omit error if index already exists */
8474484933
){
8474584934
Index *pRet = 0; /* Pointer to return */
8474684935
Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
8475884947
struct ExprList_item *pListItem; /* For looping over pList */
8475984948
int nCol;
8476084949
int nExtra = 0;
8476184950
char *zExtra;
8476284951
84763
- assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
8476484952
assert( pParse->nErr==0 ); /* Never called with prior errors */
8476584953
if( db->mallocFailed || IN_DECLARE_VTAB ){
8476684954
goto exit_create_index;
8476784955
}
8476884956
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
8480484992
assert(0);
8480584993
}
8480684994
pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
8480784995
assert( db->mallocFailed==0 || pTab==0 );
8480884996
if( pTab==0 ) goto exit_create_index;
84809
- assert( db->aDb[iDb].pSchema==pTab->pSchema );
84997
+ if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84998
+ sqlite3ErrorMsg(pParse,
84999
+ "cannot create a TEMP index on non-TEMP table \"%s\"",
85000
+ pTab->zName);
85001
+ goto exit_create_index;
85002
+ }
8481085003
}else{
8481185004
assert( pName==0 );
8481285005
assert( pStart==0 );
8481385006
pTab = pParse->pNewTable;
8481485007
if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
8495385146
pIndex->nColumn = pList->nExpr;
8495485147
pIndex->onError = (u8)onError;
8495585148
pIndex->uniqNotNull = onError==OE_Abort;
8495685149
pIndex->autoIndex = (u8)(pName==0);
8495785150
pIndex->pSchema = db->aDb[iDb].pSchema;
85151
+ if( pPIWhere ){
85152
+ sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85153
+ pIndex->pPartIdxWhere = pPIWhere;
85154
+ pPIWhere = 0;
85155
+ }
8495885156
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
8495985157
8496085158
/* Check to see if we should honor DESC requests on index columns
8496185159
*/
8496285160
if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
8510885306
** If pTblName==0 it means this index is generated as a primary key
8510985307
** or UNIQUE constraint of a CREATE TABLE statement. Since the table
8511085308
** has just been created, it contains no data and the index initialization
8511185309
** step can be skipped.
8511285310
*/
85113
- else{ /* if( db->init.busy==0 ) */
85311
+ else if( pParse->nErr==0 ){
8511485312
Vdbe *v;
8511585313
char *zStmt;
8511685314
int iMem = ++pParse->nMem;
8511785315
8511885316
v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
8512685324
8512785325
/* Gather the complete text of the CREATE INDEX statement into
8512885326
** the zStmt variable
8512985327
*/
8513085328
if( pStart ){
85131
- assert( pEnd!=0 );
85329
+ int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85330
+ if( pName->z[n-1]==';' ) n--;
8513285331
/* A named index with an explicit CREATE INDEX statement */
8513385332
zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85134
- onError==OE_None ? "" : " UNIQUE",
85135
- (int)(pEnd->z - pName->z) + 1,
85136
- pName->z);
85333
+ onError==OE_None ? "" : " UNIQUE", n, pName->z);
8513785334
}else{
8513885335
/* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
8513985336
/* zStmt = sqlite3MPrintf(""); */
8514085337
zStmt = 0;
8514185338
}
@@ -85187,14 +85384,12 @@
8518785384
pIndex = 0;
8518885385
}
8518985386
8519085387
/* Clean up before exiting */
8519185388
exit_create_index:
85192
- if( pIndex ){
85193
- sqlite3DbFree(db, pIndex->zColAff);
85194
- sqlite3DbFree(db, pIndex);
85195
- }
85389
+ if( pIndex ) freeIndex(db, pIndex);
85390
+ sqlite3ExprDelete(db, pPIWhere);
8519685391
sqlite3ExprListDelete(db, pList);
8519785392
sqlite3SrcListDelete(db, pTblName);
8519885393
sqlite3DbFree(db, zName);
8519985394
return pRet;
8520085395
}
@@ -86068,29 +86263,24 @@
8606886263
** the error.
8606986264
*/
8607086265
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
8607186266
int i;
8607286267
int nCol = pIdx->nColumn;
86073
- int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86074
- sqlite3 *db = pParse->db;
86075
- KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86076
-
86077
- if( pKey ){
86078
- pKey->db = pParse->db;
86079
- pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86080
- assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86268
+ KeyInfo *pKey;
86269
+
86270
+ pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86271
+ if( pKey ){
8608186272
for(i=0; i<nCol; i++){
8608286273
char *zColl = pIdx->azColl[i];
8608386274
assert( zColl );
8608486275
pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
8608586276
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
8608686277
}
86087
- pKey->nField = (u16)nCol;
8608886278
}
8608986279
8609086280
if( pParse->nErr ){
86091
- sqlite3DbFree(db, pKey);
86281
+ sqlite3DbFree(pParse->db, pKey);
8609286282
pKey = 0;
8609386283
}
8609486284
return pKey;
8609586285
}
8609686286
@@ -87166,15 +87356,18 @@
8716687356
int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
8716787357
){
8716887358
int i;
8716987359
Index *pIdx;
8717087360
int r1;
87361
+ int iPartIdxLabel;
87362
+ Vdbe *v = pParse->pVdbe;
8717187363
8717287364
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
8717387365
if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87174
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87175
- sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
87366
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87367
+ sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87368
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8717687369
}
8717787370
}
8717887371
8717987372
/*
8718087373
** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
8718487377
**
8718587378
** Return a register number which is the first in a block of
8718687379
** registers that holds the elements of the index key. The
8718787380
** block of registers has already been deallocated by the time
8718887381
** this routine returns.
87382
+**
87383
+** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87384
+** to that label if pIdx is a partial index that should be skipped.
87385
+** A partial index should be skipped if its WHERE clause evaluates
87386
+** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87387
+** will be set to zero which is an empty label that is ignored by
87388
+** sqlite3VdbeResolveLabel().
8718987389
*/
8719087390
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87191
- Parse *pParse, /* Parsing context */
87192
- Index *pIdx, /* The index for which to generate a key */
87193
- int iCur, /* Cursor number for the pIdx->pTable table */
87194
- int regOut, /* Write the new index key to this register */
87195
- int doMakeRec /* Run the OP_MakeRecord instruction if true */
87391
+ Parse *pParse, /* Parsing context */
87392
+ Index *pIdx, /* The index for which to generate a key */
87393
+ int iCur, /* Cursor number for the pIdx->pTable table */
87394
+ int regOut, /* Write the new index key to this register */
87395
+ int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87396
+ int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
8719687397
){
8719787398
Vdbe *v = pParse->pVdbe;
8719887399
int j;
8719987400
Table *pTab = pIdx->pTable;
8720087401
int regBase;
8720187402
int nCol;
8720287403
87404
+ if( piPartIdxLabel ){
87405
+ if( pIdx->pPartIdxWhere ){
87406
+ *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87407
+ pParse->iPartIdxTab = iCur;
87408
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87409
+ SQLITE_JUMPIFNULL);
87410
+ }else{
87411
+ *piPartIdxLabel = 0;
87412
+ }
87413
+ }
8720387414
nCol = pIdx->nColumn;
8720487415
regBase = sqlite3GetTempRange(pParse, nCol+1);
8720587416
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
8720687417
for(j=0; j<nCol; j++){
8720787418
int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
9156191772
** Add the new records to the indices as we go.
9156291773
*/
9156391774
for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
9156491775
int regIdx;
9156591776
int regR;
91777
+ int addrSkipRow = 0;
9156691778
9156791779
if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91780
+
91781
+ if( pIdx->pPartIdxWhere ){
91782
+ sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91783
+ addrSkipRow = sqlite3VdbeMakeLabel(v);
91784
+ pParse->ckBase = regData;
91785
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91786
+ SQLITE_JUMPIFNULL);
91787
+ pParse->ckBase = 0;
91788
+ }
9156891789
9156991790
/* Create a key for accessing the index entry */
9157091791
regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
9157191792
for(i=0; i<pIdx->nColumn; i++){
9157291793
int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
9158391804
9158491805
/* Find out what action to take in case there is an indexing conflict */
9158591806
onError = pIdx->onError;
9158691807
if( onError==OE_None ){
9158791808
sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91809
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9158891810
continue; /* pIdx is not a UNIQUE index */
9158991811
}
9159091812
if( overrideError!=OE_Default ){
9159191813
onError = overrideError;
9159291814
}else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
9165291874
seenReplace = 1;
9165391875
break;
9165491876
}
9165591877
}
9165691878
sqlite3VdbeJumpHere(v, j3);
91879
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9165791880
sqlite3ReleaseTempReg(pParse, regR);
9165891881
}
9165991882
9166091883
if( pbMayReplace ){
9166191884
*pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
9168191904
int appendBias, /* True if this is likely to be an append */
9168291905
int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
9168391906
){
9168491907
int i;
9168591908
Vdbe *v;
91686
- int nIdx;
9168791909
Index *pIdx;
9168891910
u8 pik_flags;
9168991911
int regData;
9169091912
int regRec;
9169191913
9169291914
v = sqlite3GetVdbe(pParse);
9169391915
assert( v!=0 );
9169491916
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91695
- for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91696
- for(i=nIdx-1; i>=0; i--){
91917
+ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
9169791918
if( aRegIdx[i]==0 ) continue;
91919
+ if( pIdx->pPartIdxWhere ){
91920
+ sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91921
+ }
9169891922
sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
9169991923
if( useSeekResult ){
9170091924
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
9170191925
}
9170291926
}
@@ -91794,10 +92018,11 @@
9179492018
**
9179592019
** * The index is over the same set of columns
9179692020
** * The same DESC and ASC markings occurs on all columns
9179792021
** * The same onError processing (OE_Abort, OE_Ignore, etc)
9179892022
** * The same collating sequence on each column
92023
+** * The index has the exact same WHERE clause
9179992024
*/
9180092025
static int xferCompatibleIndex(Index *pDest, Index *pSrc){
9180192026
int i;
9180292027
assert( pDest && pSrc );
9180392028
assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
9181592040
return 0; /* Different sort orders */
9181692041
}
9181792042
if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
9181892043
return 0; /* Different collating sequences */
9181992044
}
92045
+ }
92046
+ if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
92047
+ return 0; /* Different WHERE clauses */
9182092048
}
9182192049
9182292050
/* If no test above fails then the indices must be compatible */
9182392051
return 1;
9182492052
}
@@ -91971,11 +92199,11 @@
9197192199
if( pSrcIdx==0 ){
9197292200
return 0; /* pDestIdx has no corresponding index in pSrc */
9197392201
}
9197492202
}
9197592203
#ifndef SQLITE_OMIT_CHECK
91976
- if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
92204
+ if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
9197792205
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
9197892206
}
9197992207
#endif
9198092208
#ifndef SQLITE_OMIT_FOREIGN_KEY
9198192209
/* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
9488495112
cnt++;
9488595113
}
9488695114
}
9488795115
9488895116
/* Make sure sufficient number of registers have been allocated */
94889
- if( pParse->nMem < cnt+4 ){
94890
- pParse->nMem = cnt+4;
94891
- }
95117
+ pParse->nMem = MAX( pParse->nMem, cnt+7 );
9489295118
9489395119
/* Do the b-tree integrity checks */
9489495120
sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
9489595121
sqlite3VdbeChangeP5(v, (u8)i);
9489695122
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
9491195137
9491295138
if( pTab->pIndex==0 ) continue;
9491395139
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
9491495140
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
9491595141
sqlite3VdbeJumpHere(v, addr);
95142
+ sqlite3ExprCacheClear(pParse);
9491695143
sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94917
- sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94918
- loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94919
- sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
95144
+ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95145
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95146
+ }
95147
+ pParse->nMem = MAX(pParse->nMem, 7+j);
95148
+ loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
9492095149
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94921
- int jmp2;
95150
+ int jmp2, jmp3;
9492295151
int r1;
9492395152
static const VdbeOpList idxErr[] = {
9492495153
{ OP_AddImm, 1, -1, 0},
9492595154
{ OP_String8, 0, 3, 0}, /* 1 */
9492695155
{ OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
9493195160
{ OP_Concat, 6, 3, 3},
9493295161
{ OP_ResultRow, 3, 1, 0},
9493395162
{ OP_IfPos, 1, 0, 0}, /* 9 */
9493495163
{ OP_Halt, 0, 0, 0},
9493595164
};
94936
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
95165
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95166
+ sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
9493795167
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
9493895168
addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
9493995169
sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
9494095170
sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
9494195171
sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
9494295172
sqlite3VdbeJumpHere(v, addr+9);
9494395173
sqlite3VdbeJumpHere(v, jmp2);
95174
+ sqlite3VdbeResolveLabel(v, jmp3);
9494495175
}
94945
- sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94946
- sqlite3VdbeJumpHere(v, loopTop);
95176
+ sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95177
+ sqlite3VdbeJumpHere(v, loopTop-1);
95178
+#ifndef SQLITE_OMIT_BTREECOUNT
95179
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95180
+ "wrong # of entries in index ", P4_STATIC);
9494795181
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94948
- static const VdbeOpList cntIdx[] = {
94949
- { OP_Integer, 0, 3, 0},
94950
- { OP_Rewind, 0, 0, 0}, /* 1 */
94951
- { OP_AddImm, 3, 1, 0},
94952
- { OP_Next, 0, 0, 0}, /* 3 */
94953
- { OP_Eq, 2, 0, 3}, /* 4 */
94954
- { OP_AddImm, 1, -1, 0},
94955
- { OP_String8, 0, 2, 0}, /* 6 */
94956
- { OP_String8, 0, 3, 0}, /* 7 */
94957
- { OP_Concat, 3, 2, 2},
94958
- { OP_ResultRow, 2, 1, 0},
94959
- };
94960
- addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
95182
+ addr = sqlite3VdbeCurrentAddr(v);
95183
+ sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
9496195184
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94962
- sqlite3VdbeJumpHere(v, addr);
94963
- addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94964
- sqlite3VdbeChangeP1(v, addr+1, j+2);
94965
- sqlite3VdbeChangeP2(v, addr+1, addr+4);
94966
- sqlite3VdbeChangeP1(v, addr+3, j+2);
94967
- sqlite3VdbeChangeP2(v, addr+3, addr+2);
94968
- sqlite3VdbeJumpHere(v, addr+4);
94969
- sqlite3VdbeChangeP4(v, addr+6,
94970
- "wrong # of entries in index ", P4_STATIC);
94971
- sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94972
- }
95185
+ sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95186
+ sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95187
+ sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95188
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95189
+ sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95190
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95191
+ }
95192
+#endif /* SQLITE_OMIT_BTREECOUNT */
9497395193
}
9497495194
}
9497595195
addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
9497695196
sqlite3VdbeChangeP2(v, addr, -mxErr);
9497795197
sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
9699497214
*/
9699597215
if( pOrderBy==0 && p->iLimit ){
9699697216
sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
9699797217
}
9699897218
}
97219
+
97220
+/*
97221
+** Allocate a KeyInfo object sufficient for an index of N columns.
97222
+**
97223
+** Actually, always allocate one extra column for the rowid at the end
97224
+** of the index. So the KeyInfo returned will have space sufficient for
97225
+** N+1 columns.
97226
+*/
97227
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97228
+ KeyInfo *p = sqlite3DbMallocZero(db,
97229
+ sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97230
+ if( p ){
97231
+ p->aSortOrder = (u8*)&p->aColl[N+1];
97232
+ p->nField = (u16)N;
97233
+ p->enc = ENC(db);
97234
+ p->db = db;
97235
+ }
97236
+ return p;
97237
+}
9699997238
9700097239
/*
9700197240
** Given an expression list, generate a KeyInfo structure that records
9700297241
** the collating sequence for each expression in that expression list.
9700397242
**
@@ -97011,29 +97250,23 @@
9701197250
** function is responsible for seeing that this structure is eventually
9701297251
** freed. Add the KeyInfo structure to the P4 field of an opcode using
9701397252
** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
9701497253
*/
9701597254
static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97016
- sqlite3 *db = pParse->db;
9701797255
int nExpr;
9701897256
KeyInfo *pInfo;
9701997257
struct ExprList_item *pItem;
97258
+ sqlite3 *db = pParse->db;
9702097259
int i;
9702197260
9702297261
nExpr = pList->nExpr;
97023
- pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97262
+ pInfo = sqlite3KeyInfoAlloc(db, nExpr);
9702497263
if( pInfo ){
97025
- pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97026
- pInfo->nField = (u16)nExpr;
97027
- pInfo->enc = ENC(db);
97028
- pInfo->db = db;
9702997264
for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
9703097265
CollSeq *pColl;
9703197266
pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97032
- if( !pColl ){
97033
- pColl = db->pDfltColl;
97034
- }
97267
+ if( !pColl ) pColl = db->pDfltColl;
9703597268
pInfo->aColl[i] = pColl;
9703697269
pInfo->aSortOrder[i] = pItem->sortOrder;
9703797270
}
9703897271
}
9703997272
return pInfo;
@@ -98135,27 +98368,21 @@
9813598368
CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
9813698369
int nCol; /* Number of columns in result set */
9813798370
9813898371
assert( p->pRightmost==p );
9813998372
nCol = p->pEList->nExpr;
98140
- pKeyInfo = sqlite3DbMallocZero(db,
98141
- sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98373
+ pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
9814298374
if( !pKeyInfo ){
9814398375
rc = SQLITE_NOMEM;
9814498376
goto multi_select_end;
9814598377
}
98146
-
98147
- pKeyInfo->enc = ENC(db);
98148
- pKeyInfo->nField = (u16)nCol;
98149
-
9815098378
for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
9815198379
*apColl = multiSelectCollSeq(pParse, p, i);
9815298380
if( 0==*apColl ){
9815398381
*apColl = db->pDfltColl;
9815498382
}
9815598383
}
98156
- pKeyInfo->aSortOrder = (u8*)apColl;
9815798384
9815898385
for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
9815998386
for(i=0; i<2; i++){
9816098387
int addr = pLoop->addrOpenEphm[i];
9816198388
if( addr<0 ){
@@ -98520,16 +98747,12 @@
9852098747
struct ExprList_item *pItem;
9852198748
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
9852298749
assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
9852398750
aPermute[i] = pItem->iOrderByCol - 1;
9852498751
}
98525
- pKeyMerge =
98526
- sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98752
+ pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
9852798753
if( pKeyMerge ){
98528
- pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98529
- pKeyMerge->nField = (u16)nOrderBy;
98530
- pKeyMerge->enc = ENC(db);
9853198754
for(i=0; i<nOrderBy; i++){
9853298755
CollSeq *pColl;
9853398756
Expr *pTerm = pOrderBy->a[i].pExpr;
9853498757
if( pTerm->flags & EP_Collate ){
9853598758
pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
9856298785
int nExpr = p->pEList->nExpr;
9856398786
assert( nOrderBy>=nExpr || db->mallocFailed );
9856498787
regPrev = pParse->nMem+1;
9856598788
pParse->nMem += nExpr+1;
9856698789
sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98567
- pKeyDup = sqlite3DbMallocZero(db,
98568
- sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98790
+ pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
9856998791
if( pKeyDup ){
98570
- pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98571
- pKeyDup->nField = (u16)nExpr;
98572
- pKeyDup->enc = ENC(db);
9857398792
for(i=0; i<nExpr; i++){
9857498793
pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
9857598794
pKeyDup->aSortOrder[i] = 0;
9857698795
}
9857798796
}
@@ -99833,14 +100052,16 @@
99833100052
** and/or pParse->db->mallocFailed.
99834100053
*/
99835100054
static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99836100055
Walker w;
99837100056
memset(&w, 0, sizeof(w));
99838
- w.xSelectCallback = convertCompoundSelectToSubquery;
99839100057
w.xExprCallback = exprWalkNoop;
99840100058
w.pParse = pParse;
99841
- sqlite3WalkSelect(&w, pSelect);
100059
+ if( pParse->hasCompound ){
100060
+ w.xSelectCallback = convertCompoundSelectToSubquery;
100061
+ sqlite3WalkSelect(&w, pSelect);
100062
+ }
99842100063
w.xSelectCallback = selectExpander;
99843100064
sqlite3WalkSelect(&w, pSelect);
99844100065
}
99845100066
99846100067
@@ -100370,11 +100591,11 @@
100370100591
** will cause elements to come out in the correct order. This is
100371100592
** an optimization - the correct answer should result regardless.
100372100593
** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100373100594
** to disable this optimization for testing purposes.
100374100595
*/
100375
- if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100596
+ if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100376100597
&& OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100377100598
pOrderBy = 0;
100378100599
}
100379100600
100380100601
/* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100391100612
** used for both the ORDER BY and DISTINCT processing. As originally
100392100613
** written the query must use a temp-table for at least one of the ORDER
100393100614
** BY and DISTINCT, and an index or separate temp-table for the other.
100394100615
*/
100395100616
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100396
- && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100617
+ && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100397100618
){
100398100619
p->selFlags &= ~SF_Distinct;
100399100620
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100400100621
pGroupBy = p->pGroupBy;
100401100622
pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102618102839
aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102619102840
if( aRegIdx==0 ) goto update_cleanup;
102620102841
}
102621102842
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102622102843
int reg;
102623
- if( hasFK || chngRowid ){
102844
+ if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102624102845
reg = ++pParse->nMem;
102625102846
}else{
102626102847
reg = 0;
102627102848
for(i=0; i<pIdx->nColumn; i++){
102628102849
if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105158105379
** the pWC->a[] array.
105159105380
*/
105160105381
static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105161105382
WhereTerm *pTerm;
105162105383
int idx;
105163
- testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105384
+ testcase( wtFlags & TERM_VIRTUAL );
105164105385
if( pWC->nTerm>=pWC->nSlot ){
105165105386
WhereTerm *pOld = pWC->a;
105166105387
sqlite3 *db = pWC->pWInfo->pParse->db;
105167105388
pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105168105389
if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105303105524
105304105525
/*
105305105526
** Return TRUE if the given operator is one of the operators that is
105306105527
** allowed for an indexable WHERE clause term. The allowed operators are
105307105528
** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105308
-**
105309
-** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105310
-** of one of the following forms: column = expression column > expression
105311
-** column >= expression column < expression column <= expression
105312
-** expression = column expression > column expression >= column
105313
-** expression < column expression <= column column IN
105314
-** (expression-list) column IN (subquery) column IS NULL
105315105529
*/
105316105530
static int allowedOp(int op){
105317105531
assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105318105532
assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105319105533
assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105628105842
op = pRight->op2;
105629105843
}
105630105844
if( op==TK_VARIABLE ){
105631105845
Vdbe *pReprepare = pParse->pReprepare;
105632105846
int iCol = pRight->iColumn;
105633
- pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105847
+ pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105634105848
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105635105849
z = (char *)sqlite3_value_text(pVal);
105636105850
}
105637105851
sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105638105852
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
105983106197
}
105984106198
105985106199
/* At this point, okToChngToIN is true if original pTerm satisfies
105986106200
** case 1. In that case, construct a new virtual term that is
105987106201
** pTerm converted into an IN operator.
105988
- **
105989
- ** EV: R-00211-15100
105990106202
*/
105991106203
if( okToChngToIN ){
105992106204
Expr *pDup; /* A transient duplicate expression */
105993106205
ExprList *pList = 0; /* The RHS of the IN operator */
105994106206
Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106226106438
** wildcard. But if we increment '@', that will push it into the
106227106439
** alphabetic range where case conversions will mess up the
106228106440
** inequality. To avoid this, make sure to also run the full
106229106441
** LIKE on all candidate expressions by clearing the isComplete flag
106230106442
*/
106231
- if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106232
-
106233
-
106443
+ if( c=='A'-1 ) isComplete = 0;
106234106444
c = sqlite3UpperToLower[c];
106235106445
}
106236106446
*pC = c + 1;
106237106447
}
106238106448
sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106735106945
VdbeComment((v, "for %s", pTable->zName));
106736106946
106737106947
/* Fill the automatic index with content */
106738106948
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106739106949
regRecord = sqlite3GetTempReg(pParse);
106740
- sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106950
+ sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106741106951
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106742106952
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106743106953
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106744106954
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106745106955
sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107092107302
if( pExpr->op==TK_VARIABLE
107093107303
|| (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107094107304
){
107095107305
int iVar = pExpr->iColumn;
107096107306
sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107097
- *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107307
+ *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107098107308
return SQLITE_OK;
107099107309
}
107100107310
return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107101107311
}
107102107312
#endif
@@ -107318,13 +107528,10 @@
107318107528
**
107319107529
** The t2.z='ok' is disabled in the in (2) because it originates
107320107530
** in the ON clause. The term is disabled in (3) because it is not part
107321107531
** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107322107532
**
107323
-** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107324
-** completely satisfied by indices.
107325
-**
107326107533
** Disabling a term causes that term to not be tested in the inner loop
107327107534
** of the join. Disabling is an optimization. When terms are satisfied
107328107535
** by indices, we disable them to prevent redundant tests in the inner
107329107536
** loop. We would get the correct results if nothing were ever disabled,
107330107537
** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107550107757
pTerm = pLoop->aLTerm[j];
107551107758
assert( pTerm!=0 );
107552107759
/* The following true for indices with redundant columns.
107553107760
** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107554107761
testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107555
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107762
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107556107763
r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107557107764
if( r1!=regBase+j ){
107558107765
if( nReg==1 ){
107559107766
sqlite3ReleaseTempReg(pParse, regBase);
107560107767
regBase = r1;
@@ -107750,10 +107957,11 @@
107750107957
WhereLevel *pLevel; /* The where level to be coded */
107751107958
WhereLoop *pLoop; /* The WhereLoop object being coded */
107752107959
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753107960
WhereTerm *pTerm; /* A WHERE clause term */
107754107961
Parse *pParse; /* Parsing context */
107962
+ sqlite3 *db; /* Database connection */
107755107963
Vdbe *v; /* The prepared stmt under constructions */
107756107964
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757107965
int addrBrk; /* Jump here to break out of the loop */
107758107966
int addrCont; /* Jump here to continue with next cycle */
107759107967
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107761107969
Bitmask newNotReady; /* Return value */
107762107970
107763107971
pParse = pWInfo->pParse;
107764107972
v = pParse->pVdbe;
107765107973
pWC = &pWInfo->sWC;
107974
+ db = pParse->db;
107766107975
pLevel = &pWInfo->a[iLevel];
107767107976
pLoop = pLevel->pWLoop;
107768107977
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769107978
iCur = pTabItem->iCursor;
107770107979
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
107859108068
iReleaseReg = sqlite3GetTempReg(pParse);
107860108069
pTerm = pLoop->aLTerm[0];
107861108070
assert( pTerm!=0 );
107862108071
assert( pTerm->pExpr!=0 );
107863108072
assert( omitTable==0 );
107864
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108073
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107865108074
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107866108075
addrNxt = pLevel->addrNxt;
107867108076
sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107868108077
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107869108078
sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
107907108116
assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107908108117
assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107909108118
assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107910108119
107911108120
assert( (pStart->wtFlags & TERM_VNULL)==0 );
107912
- testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108121
+ testcase( pStart->wtFlags & TERM_VIRTUAL );
107913108122
pX = pStart->pExpr;
107914108123
assert( pX!=0 );
107915108124
testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107916108125
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107917108126
sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
107926108135
Expr *pX;
107927108136
pX = pEnd->pExpr;
107928108137
assert( pX!=0 );
107929108138
assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107930108139
testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107931
- testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140
+ testcase( pEnd->wtFlags & TERM_VIRTUAL );
107932108141
memEndValue = ++pParse->nMem;
107933108142
sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107934108143
if( pX->op==TK_LT || pX->op==TK_GT ){
107935108144
testOp = bRev ? OP_Le : OP_Ge;
107936108145
}else{
@@ -108051,11 +108260,11 @@
108051108260
/* Generate code to evaluate all constraint terms using == or IN
108052108261
** and store the values of those terms in an array of registers
108053108262
** starting at regBase.
108054108263
*/
108055108264
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056
- zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108265
+ zEndAff = sqlite3DbStrDup(db, zStartAff);
108057108266
addrNxt = pLevel->addrNxt;
108058108267
108059108268
/* If we are doing a reverse order scan on an ascending index, or
108060108269
** a forward order scan on a descending index, interchange the
108061108270
** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108092108301
if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108093108302
zStartAff[nEq] = SQLITE_AFF_NONE;
108094108303
}
108095108304
}
108096108305
nConstraint++;
108097
- testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108306
+ testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108098108307
}else if( isMinQuery ){
108099108308
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108100108309
nConstraint++;
108101108310
startEq = 0;
108102108311
start_constraints = 1;
@@ -108134,14 +108343,14 @@
108134108343
zEndAff[nEq] = SQLITE_AFF_NONE;
108135108344
}
108136108345
}
108137108346
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138108347
nConstraint++;
108139
- testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108348
+ testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108140108349
}
108141
- sqlite3DbFree(pParse->db, zStartAff);
108142
- sqlite3DbFree(pParse->db, zEndAff);
108350
+ sqlite3DbFree(db, zStartAff);
108351
+ sqlite3DbFree(db, zEndAff);
108143108352
108144108353
/* Top of the loop body */
108145108354
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146108355
108147108356
/* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108264108473
*/
108265108474
if( pWInfo->nLevel>1 ){
108266108475
int nNotReady; /* The number of notReady tables */
108267108476
struct SrcList_item *origSrc; /* Original list of tables */
108268108477
nNotReady = pWInfo->nLevel - iLevel - 1;
108269
- pOrTab = sqlite3StackAllocRaw(pParse->db,
108478
+ pOrTab = sqlite3StackAllocRaw(db,
108270108479
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271108480
if( pOrTab==0 ) return notReady;
108272108481
pOrTab->nAlloc = (u8)(nNotReady + 1);
108273108482
pOrTab->nSrc = pOrTab->nAlloc;
108274108483
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108318108527
Expr *pExpr = pWC->a[iTerm].pExpr;
108319108528
if( &pWC->a[iTerm] == pTerm ) continue;
108320108529
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321108530
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322108531
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323
- pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324
- pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108532
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
108533
+ pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108325108534
}
108326108535
if( pAndExpr ){
108327108536
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328108537
}
108329108538
}
@@ -108339,11 +108548,11 @@
108339108548
}
108340108549
/* Loop through table entries that match term pOrTerm. */
108341108550
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342108551
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343108552
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344
- assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108553
+ assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108345108554
if( pSubWInfo ){
108346108555
WhereLoop *pSubLoop;
108347108556
explainOneScan(
108348108557
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349108558
);
@@ -108394,17 +108603,17 @@
108394108603
}
108395108604
pLevel->u.pCovidx = pCov;
108396108605
if( pCov ) pLevel->iIdxCur = iCovCur;
108397108606
if( pAndExpr ){
108398108607
pAndExpr->pLeft = 0;
108399
- sqlite3ExprDelete(pParse->db, pAndExpr);
108608
+ sqlite3ExprDelete(db, pAndExpr);
108400108609
}
108401108610
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402108611
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403108612
sqlite3VdbeResolveLabel(v, iLoopBody);
108404108613
108405
- if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108614
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108406108615
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407108616
}else
108408108617
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409108618
108410108619
{
@@ -108421,18 +108630,14 @@
108421108630
}
108422108631
newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108423108632
108424108633
/* Insert code to test every subexpression that can be completely
108425108634
** computed using the current set of tables.
108426
- **
108427
- ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108428
- ** the use of indices become tests that are evaluated against each row of
108429
- ** the relevant input tables.
108430108635
*/
108431108636
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108432108637
Expr *pE;
108433
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108638
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108434108639
testcase( pTerm->wtFlags & TERM_CODED );
108435108640
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108436108641
if( (pTerm->prereqAll & newNotReady)!=0 ){
108437108642
testcase( pWInfo->untestedTerms==0
108438108643
&& (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108455108660
** and we are coding the t1 loop and the t2 loop has not yet coded,
108456108661
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457108662
** the implied "t1.a=123" constraint.
108458108663
*/
108459108664
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460
- Expr *pE;
108665
+ Expr *pE, *pEAlt;
108461108666
WhereTerm *pAlt;
108462
- Expr sEq;
108463108667
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464108668
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465108669
if( pTerm->leftCursor!=iCur ) continue;
108466108670
if( pLevel->iLeftJoin ) continue;
108467108671
pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108471108675
if( pAlt==0 ) continue;
108472108676
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473108677
testcase( pAlt->eOperator & WO_EQ );
108474108678
testcase( pAlt->eOperator & WO_IN );
108475108679
VdbeNoopComment((v, "begin transitive constraint"));
108476
- sEq = *pAlt->pExpr;
108477
- sEq.pLeft = pE->pLeft;
108478
- sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108680
+ pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108681
+ if( pEAlt ){
108682
+ *pEAlt = *pAlt->pExpr;
108683
+ pEAlt->pLeft = pE->pLeft;
108684
+ sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108685
+ sqlite3StackFree(db, pEAlt);
108686
+ }
108479108687
}
108480108688
108481108689
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108482108690
** at least one row of the right table has matched the left table.
108483108691
*/
@@ -108485,11 +108693,11 @@
108485108693
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108486108694
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108487108695
VdbeComment((v, "record LEFT JOIN hit"));
108488108696
sqlite3ExprCacheClear(pParse);
108489108697
for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108490
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108698
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108491108699
testcase( pTerm->wtFlags & TERM_CODED );
108492108700
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108493108701
if( (pTerm->prereqAll & newNotReady)!=0 ){
108494108702
assert( pWInfo->untestedTerms );
108495108703
continue;
@@ -108926,11 +109134,12 @@
108926109134
rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108927109135
}else if( (pTerm->eOperator & WO_IN)
108928109136
&& !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108929109137
rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108930109138
}
108931
- if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
109139
+ assert( nOut==0 || rc==SQLITE_OK );
109140
+ if( nOut ) pNew->nOut = whereCost(nOut);
108932109141
}
108933109142
#endif
108934109143
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108935109144
/* Each row involves a step of the index, then a binary search of
108936109145
** the main table */
@@ -108998,10 +109207,21 @@
108998109207
if( x<BMS-1 ) m |= MASKBIT(x);
108999109208
}
109000109209
return m;
109001109210
}
109002109211
109212
+/* Check to see if a partial index with pPartIndexWhere can be used
109213
+** in the current query. Return true if it can be and false if not.
109214
+*/
109215
+static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109216
+ int i;
109217
+ WhereTerm *pTerm;
109218
+ for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109219
+ if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109220
+ }
109221
+ return 0;
109222
+}
109003109223
109004109224
/*
109005109225
** Add all WhereLoop objects for a single table of the join where the table
109006109226
** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109007109227
** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109021109241
int rc = SQLITE_OK; /* Return code */
109022109242
int iSortIdx = 1; /* Index number */
109023109243
int b; /* A boolean value */
109024109244
WhereCost rSize; /* number of rows in the table */
109025109245
WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109246
+ WhereClause *pWC; /* The parsed WHERE clause */
109026109247
109027109248
pNew = pBuilder->pNew;
109028109249
pWInfo = pBuilder->pWInfo;
109029109250
pTabList = pWInfo->pTabList;
109030109251
pSrc = pTabList->a + pNew->iTab;
109252
+ pWC = pBuilder->pWC;
109031109253
assert( !IsVirtual(pSrc->pTab) );
109032109254
109033109255
if( pSrc->pIndex ){
109034109256
/* An INDEXED BY clause specifies a particular index to use */
109035109257
pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109065109287
&& !pSrc->viaCoroutine
109066109288
&& !pSrc->notIndexed
109067109289
&& !pSrc->isCorrelated
109068109290
){
109069109291
/* Generate auto-index WhereLoops */
109070
- WhereClause *pWC = pBuilder->pWC;
109071109292
WhereTerm *pTerm;
109072109293
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109073109294
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109074109295
if( pTerm->prereqRight & pNew->maskSelf ) continue;
109075109296
if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109095109316
}
109096109317
109097109318
/* Loop over all indices
109098109319
*/
109099109320
for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109321
+ if( pProbe->pPartIdxWhere!=0
109322
+ && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109323
+ continue; /* Partial index inappropriate for this query */
109324
+ }
109100109325
pNew->u.btree.nEq = 0;
109101109326
pNew->nLTerm = 0;
109102109327
pNew->iSortIdx = 0;
109103109328
pNew->rSetup = 0;
109104109329
pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110035110260
pLoop->u.btree.nEq = 1;
110036110261
/* TUNING: Cost of a rowid lookup is 10 */
110037110262
pLoop->rRun = 33; /* 33==whereCost(10) */
110038110263
}else{
110039110264
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110040
- if( pIdx->onError==OE_None ) continue;
110265
+ if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
110041110266
for(j=0; j<pIdx->nColumn; j++){
110042110267
pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110043110268
if( pTerm==0 ) break;
110044110269
whereLoopResize(pWInfo->pParse->db, pLoop, j);
110045110270
pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110241110466
** subexpression is separated by an AND operator.
110242110467
*/
110243110468
initMaskSet(pMaskSet);
110244110469
whereClauseInit(&pWInfo->sWC, pWInfo);
110245110470
sqlite3ExprCodeConstants(pParse, pWhere);
110246
- whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110471
+ whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110247110472
sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110248110473
110249110474
/* Special case: a WHERE clause that is constant. Evaluate the
110250110475
** expression and either jump over all of the code or fall thru.
110251110476
*/
@@ -110875,11 +111100,11 @@
110875111100
#endif
110876111101
#define sqlite3ParserARG_SDECL Parse *pParse;
110877111102
#define sqlite3ParserARG_PDECL ,Parse *pParse
110878111103
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110879111104
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
110880
-#define YYNSTATE 627
111105
+#define YYNSTATE 628
110881111106
#define YYNRULE 327
110882111107
#define YYFALLBACK 1
110883111108
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110884111109
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110885111110
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
110948111173
** shifting non-terminals after a reduce.
110949111174
** yy_default[] Default action for each state.
110950111175
*/
110951111176
#define YY_ACTTAB_COUNT (1564)
110952111177
static const YYACTIONTYPE yy_action[] = {
110953
- /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
111178
+ /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
110954111179
/* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110955
- /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110956
- /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110957
- /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110958
- /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110959
- /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110960
- /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
111180
+ /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111181
+ /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111182
+ /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111183
+ /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111184
+ /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111185
+ /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
110961111186
/* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110962
- /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110963
- /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
111187
+ /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111188
+ /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
110964111189
/* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110965
- /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
111190
+ /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
110966111191
/* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110967
- /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110968
- /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110969
- /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110970
- /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110971
- /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110972
- /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110973
- /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110974
- /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110975
- /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110976
- /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110977
- /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110978
- /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110979
- /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110980
- /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110981
- /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110982
- /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110983
- /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110984
- /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110985
- /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110986
- /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110987
- /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110988
- /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
111192
+ /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111193
+ /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111194
+ /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111195
+ /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111196
+ /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111197
+ /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111198
+ /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111199
+ /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111200
+ /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111201
+ /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111202
+ /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111203
+ /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111204
+ /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111205
+ /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111206
+ /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111207
+ /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111208
+ /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111209
+ /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111210
+ /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111211
+ /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111212
+ /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111213
+ /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
110989111214
/* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110990
- /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110991
- /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110992
- /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110993
- /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110994
- /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110995
- /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111215
+ /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111216
+ /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111217
+ /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111218
+ /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111219
+ /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111220
+ /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
110996111221
/* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110997
- /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110998
- /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110999
- /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
111000
- /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
111001
- /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
111002
- /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
111003
- /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
111004
- /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
111005
- /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
111006
- /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
111007
- /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
111008
- /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
111009
- /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
111010
- /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111011
- /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111012
- /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
111013
- /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
111014
- /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
111015
- /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
111016
- /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
111017
- /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
111222
+ /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111223
+ /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111224
+ /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111225
+ /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111226
+ /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111227
+ /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111228
+ /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111229
+ /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111230
+ /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111231
+ /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111232
+ /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111233
+ /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111234
+ /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111235
+ /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111236
+ /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111237
+ /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111238
+ /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111239
+ /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111240
+ /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111241
+ /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111242
+ /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111018111243
/* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111019
- /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
111020
- /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
111021
- /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
111022
- /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
111023
- /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
111024
- /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
111025
- /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111244
+ /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111245
+ /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111246
+ /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111247
+ /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111248
+ /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111249
+ /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111250
+ /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111026111251
/* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111027
- /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
111028
- /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
111029
- /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
111030
- /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
111031
- /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
111032
- /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111033
- /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
111034
- /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
111035
- /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
111036
- /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
111037
- /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
111038
- /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
111039
- /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
111040
- /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
111041
- /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
111042
- /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111043
- /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111044
- /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111045
- /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111046
- /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111047
- /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111048
- /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111049
- /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111050
- /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111051
- /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111052
- /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111053
- /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111054
- /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111055
- /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111056
- /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111057
- /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111058
- /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111059
- /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111060
- /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111061
- /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111062
- /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111252
+ /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111253
+ /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111254
+ /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111255
+ /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111256
+ /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111257
+ /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111258
+ /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111259
+ /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111260
+ /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111261
+ /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111262
+ /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111263
+ /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111264
+ /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111265
+ /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111266
+ /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111267
+ /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111268
+ /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111269
+ /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111270
+ /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111271
+ /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111272
+ /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111273
+ /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111274
+ /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111275
+ /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111276
+ /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111277
+ /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111278
+ /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111279
+ /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111280
+ /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111281
+ /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111282
+ /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111283
+ /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111284
+ /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111285
+ /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111286
+ /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111287
+ /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111063111288
/* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111064
- /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111065
- /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111066
- /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111067
- /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111068
- /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111069
- /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111070
- /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111071
- /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111072
- /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111073
- /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111074
- /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111075
- /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111076
- /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111077
- /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111078
- /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111079
- /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111080
- /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111081
- /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111082
- /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111083
- /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111084
- /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111085
- /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111086
- /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111087
- /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111088
- /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111089
- /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111090
- /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111091
- /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111092
- /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111093
- /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111094
- /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111095
- /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111096
- /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111097
- /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111098
- /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111099
- /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111100
- /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111101
- /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111102
- /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111103
- /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111104
- /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111105
- /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111106
- /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111107
- /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111108
- /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111109
- /* 1560 */ 295, 498, 956, 488,
111289
+ /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111290
+ /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111291
+ /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111292
+ /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111293
+ /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111294
+ /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111295
+ /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111296
+ /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111297
+ /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111298
+ /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111299
+ /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111300
+ /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111301
+ /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111302
+ /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111303
+ /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111304
+ /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111305
+ /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111306
+ /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111307
+ /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111308
+ /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111309
+ /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111310
+ /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111311
+ /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111312
+ /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111313
+ /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111314
+ /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111315
+ /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111316
+ /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111317
+ /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111318
+ /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111319
+ /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111320
+ /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111321
+ /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111322
+ /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111323
+ /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111324
+ /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111325
+ /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111326
+ /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111327
+ /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111328
+ /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111329
+ /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111330
+ /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111331
+ /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111332
+ /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111333
+ /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111334
+ /* 1560 */ 400, 499, 523, 233,
111110111335
};
111111111336
static const YYCODETYPE yy_lookahead[] = {
111112111337
/* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111113111338
/* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111114111339
/* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111256111481
/* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111257111482
/* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111258111483
/* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111259111484
/* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111260111485
/* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111261
- /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111486
+ /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111262111487
/* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111263
- /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111264
- /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111265
- /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111266
- /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111267
- /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111268
- /* 1560 */ 195, 182, 250, 186,
111488
+ /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111489
+ /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111490
+ /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111491
+ /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111492
+ /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111493
+ /* 1560 */ 191, 182, 173, 92,
111269111494
};
111270111495
#define YY_SHIFT_USE_DFLT (-70)
111271
-#define YY_SHIFT_COUNT (416)
111496
+#define YY_SHIFT_COUNT (417)
111272111497
#define YY_SHIFT_MIN (-69)
111273111498
#define YY_SHIFT_MAX (1487)
111274111499
static const short yy_shift_ofst[] = {
111275111500
/* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111276111501
/* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111283111508
/* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111284111509
/* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111285111510
/* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111286111511
/* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111287111512
/* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111288
- /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111513
+ /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111289111514
/* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111290111515
/* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111291111516
/* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111292111517
/* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111293111518
/* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111294111519
/* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111295111520
/* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111296111521
/* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111297111522
/* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111298
- /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111299
- /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111300
- /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111301
- /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111302
- /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111303
- /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111304
- /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111305
- /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111306
- /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111307
- /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111308
- /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111309
- /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111310
- /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111311
- /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111312
- /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111313
- /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111314
- /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111315
- /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111316
- /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111523
+ /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111524
+ /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111525
+ /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111526
+ /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111527
+ /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111528
+ /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111529
+ /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111530
+ /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111531
+ /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111532
+ /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111533
+ /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111534
+ /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111535
+ /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111536
+ /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111537
+ /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111538
+ /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111539
+ /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111540
+ /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111541
+ /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111317111542
};
111318111543
#define YY_REDUCE_USE_DFLT (-169)
111319
-#define YY_REDUCE_COUNT (308)
111544
+#define YY_REDUCE_COUNT (309)
111320111545
#define YY_REDUCE_MIN (-168)
111321
-#define YY_REDUCE_MAX (1391)
111546
+#define YY_REDUCE_MAX (1397)
111322111547
static const short yy_reduce_ofst[] = {
111323111548
/* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111324111549
/* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111325111550
/* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111326111551
/* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111337111562
/* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111338111563
/* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111339111564
/* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111340111565
/* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111341111566
/* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111342
- /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111343
- /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111344
- /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111345
- /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111346
- /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111347
- /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111348
- /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111349
- /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111350
- /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111351
- /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111352
- /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111353
- /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111567
+ /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111568
+ /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111569
+ /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111570
+ /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111571
+ /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111572
+ /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111573
+ /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111574
+ /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111575
+ /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111576
+ /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111577
+ /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111578
+ /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111354111579
};
111355111580
static const YYACTIONTYPE yy_default[] = {
111356
- /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111357
- /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111358
- /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111359
- /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111360
- /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111361
- /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111362
- /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111363
- /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111364
- /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111365
- /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111366
- /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111367
- /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111368
- /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111369
- /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111370
- /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111371
- /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111372
- /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111373
- /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111374
- /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111375
- /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111376
- /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111377
- /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111378
- /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111379
- /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111380
- /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111381
- /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111382
- /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111383
- /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111384
- /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111385
- /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111386
- /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111387
- /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111388
- /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111389
- /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111390
- /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111391
- /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111392
- /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111393
- /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111394
- /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111395
- /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111396
- /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111397
- /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111398
- /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111399
- /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111400
- /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111401
- /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111402
- /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111403
- /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111404
- /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111405
- /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111406
- /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111407
- /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111408
- /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111409
- /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111410
- /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111411
- /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111412
- /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111413
- /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111414
- /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111415
- /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111416
- /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111417
- /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111418
- /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111581
+ /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111582
+ /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111583
+ /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111584
+ /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111585
+ /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111586
+ /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111587
+ /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111588
+ /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111589
+ /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111590
+ /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111591
+ /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111592
+ /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111593
+ /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111594
+ /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111595
+ /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111596
+ /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111597
+ /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111598
+ /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111599
+ /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111600
+ /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111601
+ /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111602
+ /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111603
+ /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111604
+ /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111605
+ /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111606
+ /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111607
+ /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111608
+ /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111609
+ /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111610
+ /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111611
+ /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111612
+ /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111613
+ /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111614
+ /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111615
+ /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111616
+ /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111617
+ /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111618
+ /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111619
+ /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111620
+ /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111621
+ /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111622
+ /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111623
+ /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111624
+ /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111625
+ /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111626
+ /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111627
+ /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111628
+ /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111629
+ /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111630
+ /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111631
+ /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111632
+ /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111633
+ /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111634
+ /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111635
+ /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111636
+ /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111637
+ /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111638
+ /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111639
+ /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111640
+ /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111641
+ /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111642
+ /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111643
+ /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111419111644
};
111420111645
111421111646
/* The next table maps tokens into fallback tokens. If a construct
111422111647
** like the following:
111423111648
**
@@ -111885,11 +112110,11 @@
111885112110
/* 237 */ "case_operand ::=",
111886112111
/* 238 */ "exprlist ::= nexprlist",
111887112112
/* 239 */ "exprlist ::=",
111888112113
/* 240 */ "nexprlist ::= nexprlist COMMA expr",
111889112114
/* 241 */ "nexprlist ::= expr",
111890
- /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
112115
+ /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
111891112116
/* 243 */ "uniqueflag ::= UNIQUE",
111892112117
/* 244 */ "uniqueflag ::=",
111893112118
/* 245 */ "idxlist_opt ::=",
111894112119
/* 246 */ "idxlist_opt ::= LP idxlist RP",
111895112120
/* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112604112829
{ 224, 0 },
112605112830
{ 220, 1 },
112606112831
{ 220, 0 },
112607112832
{ 215, 3 },
112608112833
{ 215, 1 },
112609
- { 147, 11 },
112834
+ { 147, 12 },
112610112835
{ 227, 1 },
112611112836
{ 227, 0 },
112612112837
{ 178, 0 },
112613112838
{ 178, 3 },
112614112839
{ 187, 5 },
@@ -113046,10 +113271,11 @@
113046113271
case 114: /* select ::= select multiselect_op oneselect */
113047113272
{
113048113273
if( yymsp[0].minor.yy159 ){
113049113274
yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113050113275
yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113276
+ if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113051113277
}else{
113052113278
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113053113279
}
113054113280
yygotominor.yy159 = yymsp[0].minor.yy159;
113055113281
}
@@ -113608,15 +113834,15 @@
113608113834
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113609113835
break;
113610113836
case 241: /* nexprlist ::= expr */
113611113837
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113612113838
break;
113613
- case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113839
+ case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113614113840
{
113615
- sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113616
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113617
- &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113841
+ sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113842
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113843
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113618113844
}
113619113845
break;
113620113846
case 243: /* uniqueflag ::= UNIQUE */
113621113847
case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113622113848
{yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114538114764
*tokenType = TK_SPACE;
114539114765
return i;
114540114766
}
114541114767
case '-': {
114542114768
if( z[1]=='-' ){
114543
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114544114769
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114545114770
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114546114771
return i;
114547114772
}
114548114773
*tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114571114796
case '/': {
114572114797
if( z[1]!='*' || z[2]==0 ){
114573114798
*tokenType = TK_SLASH;
114574114799
return 1;
114575114800
}
114576
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114577114801
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114578114802
if( c ) i++;
114579114803
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114580114804
return i;
114581114805
}
@@ -116416,10 +116640,11 @@
116416116640
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417116641
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418116642
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419116643
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420116644
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116645
+ case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116421116646
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422116647
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423116648
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424116649
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425116650
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117771117996
db->autoCommit = 1;
117772117997
db->nextAutovac = -1;
117773117998
db->szMmap = sqlite3GlobalConfig.szMmap;
117774117999
db->nextPagesize = 0;
117775118000
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776
-#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
118001
+#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777118002
| SQLITE_AutoIndex
117778118003
#endif
117779118004
#if SQLITE_DEFAULT_FILE_FORMAT<4
117780118005
| SQLITE_LegacyFileFmt
117781118006
#endif
@@ -128244,11 +128469,11 @@
128244128469
}
128245128470
128246128471
128247128472
#ifdef SQLITE_TEST
128248128473
128249
-/* #include <tcl.h> */
128474
+#include <tcl.h>
128250128475
/* #include <string.h> */
128251128476
128252128477
/*
128253128478
** Implementation of a special SQL scalar function for testing tokenizers
128254128479
** designed to be used in concert with the Tcl testing framework. This
128255128480
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
411 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -670,11 +656,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1039,10 +1025,11 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
3122 ** interface is to keep a GUI updated during a large query.
3123 **
3124 ** ^The parameter P is passed through as the only parameter to the
3125 ** callback function X. ^The parameter N is the approximate number of
3126 ** [virtual machine instructions] that are evaluated between successive
3127 ** invocations of the callback X.
 
3128 **
3129 ** ^Only a single progress handler may be defined at one time per
3130 ** [database connection]; setting a new progress handler cancels the
3131 ** old one. ^Setting parameter X to NULL disables the progress handler.
3132 ** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
4742 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4743
4744 /*
4745 ** CAPI3REF: Function Auxiliary Data
4746 **
4747 ** The following two functions may be used by scalar SQL functions to
4748 ** associate metadata with argument values. If the same value is passed to
4749 ** multiple invocations of the same SQL function during query execution, under
4750 ** some circumstances the associated metadata may be preserved. This might
4751 ** be used, for example, in a regular-expression matching
4752 ** function. The compiled version of the regular expression is stored as
4753 ** metadata associated with the SQL value passed as the regular expression
4754 ** pattern. The compiled regular expression can be reused on multiple
4755 ** invocations of the same function so that the original pattern string
4756 ** does not need to be recompiled on each invocation.
4757 **
4758 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4759 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4760 ** value to the application-defined function. ^If no metadata has been ever
4761 ** been set for the Nth argument of the function, or if the corresponding
4762 ** function parameter has changed since the meta-data was set,
4763 ** then sqlite3_get_auxdata() returns a NULL pointer.
4764 **
4765 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4766 ** argument of the application-defined function. ^Subsequent
4767 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769 ** NULL if the data has been dropped.
4770 ** ^(If it is not NULL, SQLite will invoke the destructor
4771 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772 ** <li> the corresponding function parameter changes,
4773 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774 ** SQL statement,
4775 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4777 **
4778 ** SQLite is free to call the destructor and drop metadata on any
4779 ** parameter of any function at any time. ^The only guarantee is that
4780 ** the destructor will be called when the [prepared statement] is destroyed.
4781 ** Note in particular that the destructor X in the call to
4782 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4784 ** should be called near the end of the function implementation and the
4785 ** implementation should not make any use of P after sqlite3_set_auxdata()
4786 ** has been called.
4787 **
4788 ** ^(In practice, metadata is preserved between function calls for
4789 ** function parameters that are compile-time constants, including literal
4790 ** values and [parameters] and expressions composed from the same.)^
4791 **
@@ -6829,13 +6816,13 @@
6829 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6830 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6831 ** </dd>
6832 **
6833 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6834 ** <dd>This parameter returns the zero for the current value if and only if
6835 ** there all foreign key constraints (deferred or immediate) have been
6836 ** resolved. The highwater mark is always 0.
6837 ** </dd>
6838 ** </dl>
6839 */
6840 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6841 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
8824
8825 /*
8826 ** The names of the following types declared in vdbeInt.h are required
8827 ** for the VdbeOp definition.
8828 */
8829 typedef struct VdbeFunc VdbeFunc;
8830 typedef struct Mem Mem;
8831 typedef struct SubProgram SubProgram;
8832
8833 /*
8834 ** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
8848 void *p; /* Generic pointer */
8849 char *z; /* Pointer to data for string (char array) types */
8850 i64 *pI64; /* Used when p4type is P4_INT64 */
8851 double *pReal; /* Used when p4type is P4_REAL */
8852 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853 VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
8854 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8855 Mem *pMem; /* Used when p4type is P4_MEM */
8856 VTable *pVtab; /* Used when p4type is P4_VTAB */
8857 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8858 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
8902 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8903 #define P4_STATIC (-2) /* Pointer to a static string */
8904 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8905 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8906 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907 #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
8908 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8909 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8910 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8911 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8912 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
8959 */
8960 /************** Include opcodes.h in the middle of vdbe.h ********************/
8961 /************** Begin file opcodes.h *****************************************/
8962 /* Automatically generated. Do not edit */
8963 /* See the mkopcodeh.awk script for details */
8964 #define OP_Goto 1
8965 #define OP_Gosub 2
8966 #define OP_Return 3
8967 #define OP_Yield 4
8968 #define OP_HaltIfNull 5
8969 #define OP_Halt 6
8970 #define OP_Integer 7
8971 #define OP_Int64 8
8972 #define OP_Real 130 /* same as TK_FLOAT */
8973 #define OP_String8 94 /* same as TK_STRING */
8974 #define OP_String 9
8975 #define OP_Null 10
8976 #define OP_Blob 11
8977 #define OP_Variable 12
8978 #define OP_Move 13
8979 #define OP_Copy 14
8980 #define OP_SCopy 15
8981 #define OP_ResultRow 16
8982 #define OP_Concat 91 /* same as TK_CONCAT */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8983 #define OP_Add 86 /* same as TK_PLUS */
8984 #define OP_Subtract 87 /* same as TK_MINUS */
8985 #define OP_Multiply 88 /* same as TK_STAR */
8986 #define OP_Divide 89 /* same as TK_SLASH */
8987 #define OP_Remainder 90 /* same as TK_REM */
8988 #define OP_CollSeq 17
8989 #define OP_Function 18
8990 #define OP_BitAnd 82 /* same as TK_BITAND */
8991 #define OP_BitOr 83 /* same as TK_BITOR */
8992 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8993 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
8994 #define OP_AddImm 20
8995 #define OP_MustBeInt 21
8996 #define OP_RealAffinity 22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8997 #define OP_ToText 141 /* same as TK_TO_TEXT */
8998 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
8999 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
9000 #define OP_ToInt 144 /* same as TK_TO_INT */
9001 #define OP_ToReal 145 /* same as TK_TO_REAL */
9002 #define OP_Eq 76 /* same as TK_EQ */
9003 #define OP_Ne 75 /* same as TK_NE */
9004 #define OP_Lt 79 /* same as TK_LT */
9005 #define OP_Le 78 /* same as TK_LE */
9006 #define OP_Gt 77 /* same as TK_GT */
9007 #define OP_Ge 80 /* same as TK_GE */
9008 #define OP_Permutation 23
9009 #define OP_Compare 24
9010 #define OP_Jump 25
9011 #define OP_And 69 /* same as TK_AND */
9012 #define OP_Or 68 /* same as TK_OR */
9013 #define OP_Not 19 /* same as TK_NOT */
9014 #define OP_BitNot 93 /* same as TK_BITNOT */
9015 #define OP_Once 26
9016 #define OP_If 27
9017 #define OP_IfNot 28
9018 #define OP_IsNull 73 /* same as TK_ISNULL */
9019 #define OP_NotNull 74 /* same as TK_NOTNULL */
9020 #define OP_Column 29
9021 #define OP_Affinity 30
9022 #define OP_MakeRecord 31
9023 #define OP_Count 32
9024 #define OP_Savepoint 33
9025 #define OP_AutoCommit 34
9026 #define OP_Transaction 35
9027 #define OP_ReadCookie 36
9028 #define OP_SetCookie 37
9029 #define OP_VerifyCookie 38
9030 #define OP_OpenRead 39
9031 #define OP_OpenWrite 40
9032 #define OP_OpenAutoindex 41
9033 #define OP_OpenEphemeral 42
9034 #define OP_SorterOpen 43
9035 #define OP_OpenPseudo 44
9036 #define OP_Close 45
9037 #define OP_SeekLt 46
9038 #define OP_SeekLe 47
9039 #define OP_SeekGe 48
9040 #define OP_SeekGt 49
9041 #define OP_Seek 50
9042 #define OP_NotFound 51
9043 #define OP_Found 52
9044 #define OP_IsUnique 53
9045 #define OP_NotExists 54
9046 #define OP_Sequence 55
9047 #define OP_NewRowid 56
9048 #define OP_Insert 57
9049 #define OP_InsertInt 58
9050 #define OP_Delete 59
9051 #define OP_ResetCount 60
9052 #define OP_SorterCompare 61
9053 #define OP_SorterData 62
9054 #define OP_RowKey 63
9055 #define OP_RowData 64
9056 #define OP_Rowid 65
9057 #define OP_NullRow 66
9058 #define OP_Last 67
9059 #define OP_SorterSort 70
9060 #define OP_Sort 71
9061 #define OP_Rewind 72
9062 #define OP_SorterNext 81
9063 #define OP_Prev 92
9064 #define OP_Next 95
9065 #define OP_SorterInsert 96
9066 #define OP_IdxInsert 97
9067 #define OP_IdxDelete 98
9068 #define OP_IdxRowid 99
9069 #define OP_IdxLT 100
9070 #define OP_IdxGE 101
9071 #define OP_Destroy 102
9072 #define OP_Clear 103
9073 #define OP_CreateIndex 104
9074 #define OP_CreateTable 105
9075 #define OP_ParseSchema 106
9076 #define OP_LoadAnalysis 107
9077 #define OP_DropTable 108
9078 #define OP_DropIndex 109
9079 #define OP_DropTrigger 110
9080 #define OP_IntegrityCk 111
9081 #define OP_RowSetAdd 112
9082 #define OP_RowSetRead 113
9083 #define OP_RowSetTest 114
9084 #define OP_Program 115
9085 #define OP_Param 116
9086 #define OP_FkCounter 117
9087 #define OP_FkIfZero 118
9088 #define OP_MemMax 119
9089 #define OP_IfPos 120
9090 #define OP_IfNeg 121
9091 #define OP_IfZero 122
9092 #define OP_AggStep 123
9093 #define OP_AggFinal 124
9094 #define OP_Checkpoint 125
9095 #define OP_JournalMode 126
9096 #define OP_Vacuum 127
9097 #define OP_IncrVacuum 128
9098 #define OP_Expire 129
9099 #define OP_TableLock 131
9100 #define OP_VBegin 132
9101 #define OP_VCreate 133
9102 #define OP_VDestroy 134
9103 #define OP_VOpen 135
9104 #define OP_VFilter 136
9105 #define OP_VColumn 137
9106 #define OP_VNext 138
9107 #define OP_VRename 139
9108 #define OP_VUpdate 140
9109 #define OP_Pagecount 146
9110 #define OP_MaxPgcnt 147
9111 #define OP_Trace 148
9112 #define OP_Noop 149
9113 #define OP_Explain 150
@@ -9123,28 +9107,28 @@
9123 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9124 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9125 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9126 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9127 #define OPFLG_INITIALIZER {\
9128 /* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9129 /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9130 /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9131 /* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9132 /* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9133 /* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9134 /* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9135 /* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9136 /* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9137 /* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9138 /* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9139 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9140 /* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9141 /* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9142 /* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9143 /* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9144 /* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9145 /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9146 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9147
9148 /************** End of opcodes.h *********************************************/
9149 /************** Continuing where we left off in vdbe.h ***********************/
9150
@@ -9190,11 +9174,11 @@
9190 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
9191 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
9192 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
9193 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
9194 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9195 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
9196 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
9197 #ifndef SQLITE_OMIT_TRACE
9198 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
9199 #endif
9200
@@ -10688,16 +10672,20 @@
10688
10689 /*
10690 ** An instance of the following structure is passed as the first
10691 ** argument to sqlite3VdbeKeyCompare and is used to control the
10692 ** comparison of the two index keys.
 
 
 
 
10693 */
10694 struct KeyInfo {
10695 sqlite3 *db; /* The database connection */
10696 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10697 u16 nField; /* Number of entries in aColl[] */
10698 u8 *aSortOrder; /* Sort order for each column. May be NULL */
10699 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10700 };
10701
10702 /*
10703 ** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
10762 char *zColAff; /* String defining the affinity of each column */
10763 Index *pNext; /* The next index associated with the same table */
10764 Schema *pSchema; /* Schema containing this index */
10765 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
10766 char **azColl; /* Array of collation sequence names for index */
 
10767 int tnum; /* DB Page containing root of this index */
10768 u16 nColumn; /* Number of columns in table used by this index */
10769 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
10770 unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
10771 unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
11242 #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
11243 #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
11244 #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
11245 #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
11246 ** if no other resolution is available */
 
11247
11248 /*
11249 ** An instance of the following structure contains all information
11250 ** needed to generate code for a single SELECT statement.
11251 **
@@ -11296,10 +11286,11 @@
11296 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11297 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11298 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11299 #define SF_Materialize 0x0100 /* Force materialization of views */
11300 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
 
11301
11302
11303 /*
11304 ** The results of a select can be distributed in several ways. The
11305 ** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
11417 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11418 u8 nColCache; /* Number of entries in aColCache[] */
11419 u8 iColCache; /* Next entry in aColCache[] to replace */
11420 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11421 u8 mayAbort; /* True if statement may throw an ABORT exception */
 
11422 int aTempReg[8]; /* Holding area for temporary registers */
11423 int nRangeReg; /* Size of the temporary register block */
11424 int iRangeReg; /* First register in temporary register block */
11425 int nErr; /* Number of errors seen */
11426 int nTab; /* Number of previously allocated VDBE cursors */
11427 int nMem; /* Number of memory cells used so far */
11428 int nSet; /* Number of sets used so far */
11429 int nOnce; /* Number of OP_Once instructions so far */
11430 int ckBase; /* Base register of data during check constraints */
 
11431 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
11432 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
11433 struct yColCache {
11434 int iTable; /* Table cursor number */
11435 int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
12007 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
12008 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
12009 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
12010 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
12011 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12012 Token*, int, int);
12013 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
12014 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
12015 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
12016 Expr*,ExprList*,u16,Expr*,Expr*);
12017 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
12055 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
12056 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
12057 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
12058 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
12059 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12060 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
12061 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
 
12062 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
12063 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
12064 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
12065 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
12066 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
12083 SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
12084 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
12085 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
12086 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
12087 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12088 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
12089 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
12090 int*,int,int,int,int,int*);
12091 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
12092 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
12093 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
12286 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
12287 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
12288 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
12289 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
12290 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
 
12291 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
12292 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12293 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
12294 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
12295 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
12305 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12306 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12307 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12308 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12309 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 
12310 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12311 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12312 void (*)(sqlite3_context*,int,sqlite3_value **),
12313 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12314 FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
13257 typedef struct VdbeSorter VdbeSorter;
13258
13259 /* Opaque type used by the explainer */
13260 typedef struct Explain Explain;
13261
 
 
 
13262 /*
13263 ** A cursor is a pointer into a single BTree within a database file.
13264 ** The cursor can seek to a BTree entry with a particular key, or
13265 ** loop over all entries of the Btree. You can also insert new BTree
13266 ** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
13443 */
13444 #ifdef SQLITE_DEBUG
13445 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13446 #endif
13447
13448
13449 /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450 ** additional information about auxiliary information bound to arguments
13451 ** of the function. This is used to implement the sqlite3_get_auxdata()
13452 ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453 ** that can be associated with a constant argument to a function. This
13454 ** allows functions such as "regexp" to compile their constant regular
13455 ** expression argument once and reused the compiled code for multiple
13456 ** invocations.
13457 */
13458 struct VdbeFunc {
13459 FuncDef *pFunc; /* The definition of the function */
13460 int nAux; /* Number of entries allocated for apAux[] */
13461 struct AuxData {
13462 void *pAux; /* Aux data for the i-th argument */
13463 void (*xDelete)(void *); /* Destructor for the aux data */
13464 } apAux[1]; /* One slot for each function argument */
13465 };
13466
13467 /*
13468 ** The "context" argument for a installable function. A pointer to an
13469 ** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
13477 ** This structure is defined inside of vdbeInt.h because it uses substructures
13478 ** (Mem) which are only defined there.
13479 */
13480 struct sqlite3_context {
13481 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482 VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
13483 Mem s; /* The return value is stored here */
13484 Mem *pMem; /* Memory cell used to store aggregate context */
13485 CollSeq *pColl; /* Collating sequence */
13486 int isError; /* Error code returned by the function. */
13487 int skipFlag; /* Skip skip accumulator loading if true */
 
 
13488 };
13489
13490 /*
13491 ** An Explain object accumulates indented output which is helpful
13492 ** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
13581 int nFrame; /* Number of frames in pFrame list */
13582 u32 expmask; /* Binding to these vars invalidates VM */
13583 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13584 int nOnceFlag; /* Size of array aOnceFlag[] */
13585 u8 *aOnceFlag; /* Flags for OP_Once */
 
13586 };
13587
13588 /*
13589 ** The following are allowed values for Vdbe.magic
13590 */
@@ -13604,11 +13601,11 @@
13604 #endif
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13606 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13607 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13608 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13610
13611 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13612 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13613 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13614 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
22703 /* Automatically generated. Do not edit */
22704 /* See the mkopcodec.awk script for details. */
22705 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22706 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22707 static const char *const azName[] = { "?",
22708 /* 1 */ "Goto",
22709 /* 2 */ "Gosub",
22710 /* 3 */ "Return",
22711 /* 4 */ "Yield",
22712 /* 5 */ "HaltIfNull",
22713 /* 6 */ "Halt",
22714 /* 7 */ "Integer",
22715 /* 8 */ "Int64",
22716 /* 9 */ "String",
22717 /* 10 */ "Null",
22718 /* 11 */ "Blob",
22719 /* 12 */ "Variable",
22720 /* 13 */ "Move",
22721 /* 14 */ "Copy",
22722 /* 15 */ "SCopy",
22723 /* 16 */ "ResultRow",
22724 /* 17 */ "CollSeq",
22725 /* 18 */ "Function",
22726 /* 19 */ "Not",
22727 /* 20 */ "AddImm",
22728 /* 21 */ "MustBeInt",
22729 /* 22 */ "RealAffinity",
22730 /* 23 */ "Permutation",
22731 /* 24 */ "Compare",
22732 /* 25 */ "Jump",
22733 /* 26 */ "Once",
22734 /* 27 */ "If",
22735 /* 28 */ "IfNot",
22736 /* 29 */ "Column",
22737 /* 30 */ "Affinity",
22738 /* 31 */ "MakeRecord",
22739 /* 32 */ "Count",
22740 /* 33 */ "Savepoint",
22741 /* 34 */ "AutoCommit",
22742 /* 35 */ "Transaction",
22743 /* 36 */ "ReadCookie",
22744 /* 37 */ "SetCookie",
22745 /* 38 */ "VerifyCookie",
22746 /* 39 */ "OpenRead",
22747 /* 40 */ "OpenWrite",
22748 /* 41 */ "OpenAutoindex",
22749 /* 42 */ "OpenEphemeral",
22750 /* 43 */ "SorterOpen",
22751 /* 44 */ "OpenPseudo",
22752 /* 45 */ "Close",
22753 /* 46 */ "SeekLt",
22754 /* 47 */ "SeekLe",
22755 /* 48 */ "SeekGe",
22756 /* 49 */ "SeekGt",
22757 /* 50 */ "Seek",
22758 /* 51 */ "NotFound",
22759 /* 52 */ "Found",
22760 /* 53 */ "IsUnique",
22761 /* 54 */ "NotExists",
22762 /* 55 */ "Sequence",
22763 /* 56 */ "NewRowid",
22764 /* 57 */ "Insert",
22765 /* 58 */ "InsertInt",
22766 /* 59 */ "Delete",
22767 /* 60 */ "ResetCount",
22768 /* 61 */ "SorterCompare",
22769 /* 62 */ "SorterData",
22770 /* 63 */ "RowKey",
22771 /* 64 */ "RowData",
22772 /* 65 */ "Rowid",
22773 /* 66 */ "NullRow",
22774 /* 67 */ "Last",
22775 /* 68 */ "Or",
22776 /* 69 */ "And",
22777 /* 70 */ "SorterSort",
22778 /* 71 */ "Sort",
22779 /* 72 */ "Rewind",
22780 /* 73 */ "IsNull",
22781 /* 74 */ "NotNull",
22782 /* 75 */ "Ne",
22783 /* 76 */ "Eq",
22784 /* 77 */ "Gt",
22785 /* 78 */ "Le",
22786 /* 79 */ "Lt",
22787 /* 80 */ "Ge",
22788 /* 81 */ "SorterNext",
22789 /* 82 */ "BitAnd",
22790 /* 83 */ "BitOr",
22791 /* 84 */ "ShiftLeft",
22792 /* 85 */ "ShiftRight",
22793 /* 86 */ "Add",
@@ -22794,59 +22791,59 @@
22794 /* 87 */ "Subtract",
22795 /* 88 */ "Multiply",
22796 /* 89 */ "Divide",
22797 /* 90 */ "Remainder",
22798 /* 91 */ "Concat",
22799 /* 92 */ "Prev",
22800 /* 93 */ "BitNot",
22801 /* 94 */ "String8",
22802 /* 95 */ "Next",
22803 /* 96 */ "SorterInsert",
22804 /* 97 */ "IdxInsert",
22805 /* 98 */ "IdxDelete",
22806 /* 99 */ "IdxRowid",
22807 /* 100 */ "IdxLT",
22808 /* 101 */ "IdxGE",
22809 /* 102 */ "Destroy",
22810 /* 103 */ "Clear",
22811 /* 104 */ "CreateIndex",
22812 /* 105 */ "CreateTable",
22813 /* 106 */ "ParseSchema",
22814 /* 107 */ "LoadAnalysis",
22815 /* 108 */ "DropTable",
22816 /* 109 */ "DropIndex",
22817 /* 110 */ "DropTrigger",
22818 /* 111 */ "IntegrityCk",
22819 /* 112 */ "RowSetAdd",
22820 /* 113 */ "RowSetRead",
22821 /* 114 */ "RowSetTest",
22822 /* 115 */ "Program",
22823 /* 116 */ "Param",
22824 /* 117 */ "FkCounter",
22825 /* 118 */ "FkIfZero",
22826 /* 119 */ "MemMax",
22827 /* 120 */ "IfPos",
22828 /* 121 */ "IfNeg",
22829 /* 122 */ "IfZero",
22830 /* 123 */ "AggStep",
22831 /* 124 */ "AggFinal",
22832 /* 125 */ "Checkpoint",
22833 /* 126 */ "JournalMode",
22834 /* 127 */ "Vacuum",
22835 /* 128 */ "IncrVacuum",
22836 /* 129 */ "Expire",
22837 /* 130 */ "Real",
22838 /* 131 */ "TableLock",
22839 /* 132 */ "VBegin",
22840 /* 133 */ "VCreate",
22841 /* 134 */ "VDestroy",
22842 /* 135 */ "VOpen",
22843 /* 136 */ "VFilter",
22844 /* 137 */ "VColumn",
22845 /* 138 */ "VNext",
22846 /* 139 */ "VRename",
22847 /* 140 */ "VUpdate",
22848 /* 141 */ "ToText",
22849 /* 142 */ "ToBlob",
22850 /* 143 */ "ToNumeric",
22851 /* 144 */ "ToInt",
22852 /* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
30499 */
30500 #if SQLITE_OS_WIN /* This file is used for Windows only */
30501
30502 #ifdef __CYGWIN__
30503 # include <sys/cygwin.h>
 
30504 #endif
30505
30506 /*
30507 ** Include code that is common to all os_*.c files
30508 */
@@ -30727,19 +30725,19 @@
30727
30728 /*
30729 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30730 ** based on the sub-platform)?
30731 */
30732 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30733 # define SQLITE_WIN32_HAS_ANSI
30734 #endif
30735
30736 /*
30737 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30738 ** based on the sub-platform)?
30739 */
30740 #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT || defined(__CYGWIN__)
30741 # define SQLITE_WIN32_HAS_WIDE
30742 #endif
30743
30744 /*
30745 ** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
30919 * zero for the default behavior.
30920 */
30921 #ifndef SQLITE_WIN32_HEAP_FLAGS
30922 # define SQLITE_WIN32_HEAP_FLAGS (0)
30923 #endif
 
30924
30925 /*
30926 ** The winMemData structure stores information required by the Win32-specific
30927 ** sqlite3_mem_methods implementation.
30928 */
@@ -31267,11 +31266,11 @@
31267 { "GetTempPathA", (SYSCALL)0, 0 },
31268 #endif
31269
31270 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
31271
31272 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
31273 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
31274 #else
31275 { "GetTempPathW", (SYSCALL)0, 0 },
31276 #endif
31277
@@ -34384,14 +34383,14 @@
34384 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34385 osGetCurrentProcessId(), pFd));
34386 return SQLITE_OK;
34387 }
34388 assert( (nMap % winSysInfo.dwPageSize)==0 );
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391 #else
34392 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
 
 
 
34393 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34394 #endif
34395 if( pNew==NULL ){
34396 osCloseHandle(pFd->hMap);
34397 pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
34556 #endif
34557 /* caller will handle out of memory */
34558 return zConverted;
34559 }
34560
 
 
 
 
 
 
 
 
 
34561 static int winIsDir(const void *zConverted);
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
34582 memset(zTempPath, 0, MAX_PATH+2);
34583
34584 if( sqlite3_temp_directory ){
34585 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34586 }
34587 #if defined(__CYGWIN__)
34588 else{
34589 static const char *azDirs[] = {
34590 0,
@@ -34621,42 +34628,64 @@
34621 if( winIsDir(zWidePath) ){
34622 break;
34623 }
34624 azDirs[i] = ""; /* Don't retry in future call */
34625 }
34626 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34627 }
34628 #elif !SQLITE_OS_WINRT
34629 else if( isNT() ){
34630 char *zMulti;
34631 WCHAR zWidePath[MAX_PATH];
34632 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34633 zMulti = unicodeToUtf8(zWidePath);
34634 if( zMulti ){
34635 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34636 sqlite3_free(zMulti);
34637 }else{
34638 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34639 return SQLITE_IOERR_NOMEM;
34640 }
34641 }
34642 #ifdef SQLITE_WIN32_HAS_ANSI
34643 else{
34644 char *zUtf8;
34645 char zMbcsPath[MAX_PATH];
34646 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34647 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34648 if( zUtf8 ){
34649 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34650 sqlite3_free(zUtf8);
34651 }else{
34652 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34653 return SQLITE_IOERR_NOMEM;
34654 }
34655 }
34656 #endif
34657 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34658
34659 /* Check that the output buffer is large enough for the temporary file
34660 ** name. If it is not, return SQLITE_ERROR.
34661 */
34662 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
34738 int cnt = 0;
34739
34740 /* If argument zPath is a NULL pointer, this function is required to open
34741 ** a temporary file. Use this buffer to store the file name in.
34742 */
34743 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34744
34745 int rc = SQLITE_OK; /* Function Return Code */
34746 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34747 int eType = flags&0xFFFFFF00; /* Type of file to open */
34748 #endif
@@ -34804,12 +34833,11 @@
34804 /* If the second argument to this function is NULL, generate a
34805 ** temporary file name to use
34806 */
34807 if( !zUtf8Name ){
34808 assert(isDelete && !isOpenJournal);
34809 memset(zTmpname, 0, MAX_PATH+2);
34810 rc = getTempname(MAX_PATH+2, zTmpname);
34811 if( rc!=SQLITE_OK ){
34812 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34813 return rc;
34814 }
34815 zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
35236 ){
35237
35238 #if defined(__CYGWIN__)
35239 SimulateIOError( return SQLITE_ERROR );
35240 UNUSED_PARAMETER(nFull);
35241 assert( pVfs->mxPathname>=MAX_PATH );
35242 assert( nFull>=pVfs->mxPathname );
35243 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35244 /*
35245 ** NOTE: We are dealing with a relative path name and the data
35246 ** directory has been set. Therefore, use it as the basis
35247 ** for converting the relative path name to an absolute
35248 ** one by prepending the data directory and a slash.
35249 */
35250 char zOut[MAX_PATH+1];
35251 memset(zOut, 0, MAX_PATH+1);
35252 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253 MAX_PATH+1);
 
 
 
35254 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35255 sqlite3_data_directory, zOut);
35256 }else{
35257 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35258 }
35259 return SQLITE_OK;
35260 #endif
35261
35262 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
35594 */
35595 SQLITE_API int sqlite3_os_init(void){
35596 static sqlite3_vfs winVfs = {
35597 3, /* iVersion */
35598 sizeof(winFile), /* szOsFile */
35599 MAX_PATH, /* mxPathname */
35600 0, /* pNext */
35601 "win32", /* zName */
35602 0, /* pAppData */
35603 winOpen, /* xOpen */
35604 winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
60219 ** a prior call to sqlite3VdbeMakeLabel().
60220 */
60221 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60222 int j = -1-x;
60223 assert( p->magic==VDBE_MAGIC_INIT );
60224 assert( j>=0 && j<p->nLabel );
60225 if( p->aLabel ){
60226 p->aLabel[j] = p->nOp;
60227 }
60228 }
60229
60230 /*
@@ -60376,44 +60411,64 @@
60376 p->readOnly = 1;
60377 p->bIsReader = 0;
60378 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60379 u8 opcode = pOp->opcode;
60380
60381 pOp->opflags = sqlite3OpcodeProperty[opcode];
60382 if( opcode==OP_Function || opcode==OP_AggStep ){
60383 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60384 }else if( opcode==OP_Transaction ){
60385 if( pOp->p2!=0 ) p->readOnly = 0;
60386 p->bIsReader = 1;
60387 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60388 p->bIsReader = 1;
60389 }else if( opcode==OP_Vacuum
60390 || opcode==OP_JournalMode
 
 
 
 
 
 
 
60391 #ifndef SQLITE_OMIT_WAL
60392 || opcode==OP_Checkpoint
60393 #endif
60394 ){
60395 p->readOnly = 0;
60396 p->bIsReader = 1;
 
 
 
60397 #ifndef SQLITE_OMIT_VIRTUALTABLE
60398 }else if( opcode==OP_VUpdate ){
60399 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60400 }else if( opcode==OP_VFilter ){
60401 int n;
60402 assert( p->nOp - i >= 3 );
60403 assert( pOp[-1].opcode==OP_Integer );
60404 n = pOp[-1].p1;
60405 if( n>nMaxArgs ) nMaxArgs = n;
60406 #endif
60407 }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60408 pOp->p4.xAdvance = sqlite3BtreeNext;
60409 pOp->p4type = P4_ADVANCE;
60410 }else if( opcode==OP_Prev ){
60411 pOp->p4.xAdvance = sqlite3BtreePrevious;
60412 pOp->p4type = P4_ADVANCE;
60413 }
60414
 
 
 
 
 
 
 
 
 
 
60415 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60416 assert( -1-pOp->p2<p->nLabel );
60417 pOp->p2 = aLabel[-1-pOp->p2];
60418 }
60419 }
@@ -60544,12 +60599,11 @@
60544 /*
60545 ** Change the P2 operand of instruction addr so that it points to
60546 ** the address of the next instruction to be coded.
60547 */
60548 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60549 assert( addr>=0 || p->db->mallocFailed );
60550 if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60551 }
60552
60553
60554 /*
60555 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
60581 }
60582 case P4_MPRINTF: {
60583 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60584 break;
60585 }
60586 case P4_VDBEFUNC: {
60587 VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588 freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589 if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590 sqlite3DbFree(db, pVdbeFunc);
60591 break;
60592 }
60593 case P4_FUNCDEF: {
60594 freeEphemeralFunction(db, (FuncDef*)p4);
60595 break;
60596 }
60597 case P4_MEM: {
@@ -60706,24 +60753,17 @@
60706 pOp->p4type = P4_INT32;
60707 }else if( zP4==0 ){
60708 pOp->p4.p = 0;
60709 pOp->p4type = P4_NOTUSED;
60710 }else if( n==P4_KEYINFO ){
60711 KeyInfo *pKeyInfo;
60712 int nField, nByte;
60713
60714 nField = ((KeyInfo*)zP4)->nField;
60715 nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60716 pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60717 pOp->p4.pKeyInfo = pKeyInfo;
60718 if( pKeyInfo ){
60719 u8 *aSortOrder;
60720 memcpy((char*)pKeyInfo, zP4, nByte - nField);
60721 aSortOrder = pKeyInfo->aSortOrder;
60722 assert( aSortOrder!=0 );
60723 pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60724 memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60725 pOp->p4type = P4_KEYINFO;
60726 }else{
60727 p->db->mallocFailed = 1;
60728 pOp->p4type = P4_NOTUSED;
60729 }
@@ -61617,10 +61657,14 @@
61617 while( p->pDelFrame ){
61618 VdbeFrame *pDel = p->pDelFrame;
61619 p->pDelFrame = pDel->pParent;
61620 sqlite3VdbeFrameDelete(pDel);
61621 }
 
 
 
 
61622 }
61623
61624 /*
61625 ** Clean up the VM after execution.
61626 **
@@ -62415,24 +62459,39 @@
62415 sqlite3VdbeDelete(p);
62416 return rc;
62417 }
62418
62419 /*
62420 ** Call the destructor for each auxdata entry in pVdbeFunc for which
62421 ** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422 ** are always destroyed. To destroy all auxdata entries, call this
62423 ** routine with mask==0.
 
 
 
 
 
 
 
 
 
 
62424 */
62425 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426 int i;
62427 for(i=0; i<pVdbeFunc->nAux; i++){
62428 struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429 if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
 
 
62430 if( pAux->xDelete ){
62431 pAux->xDelete(pAux->pAux);
62432 }
62433 pAux->pAux = 0;
 
 
 
62434 }
62435 }
62436 }
62437
62438 /*
@@ -62947,15 +63006,14 @@
62947 */
62948 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
62949 int nKey1, const void *pKey1, /* Left key */
62950 UnpackedRecord *pPKey2 /* Right key */
62951 ){
62952 int d1; /* Offset into aKey[] of next data element */
62953 u32 idx1; /* Offset into aKey[] of next header element */
62954 u32 szHdr1; /* Number of bytes in header */
62955 int i = 0;
62956 int nField;
62957 int rc = 0;
62958 const unsigned char *aKey1 = (const unsigned char *)pKey1;
62959 KeyInfo *pKeyInfo;
62960 Mem mem1;
62961
@@ -62974,32 +63032,42 @@
62974 */
62975 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
62976
62977 idx1 = getVarint32(aKey1, szHdr1);
62978 d1 = szHdr1;
62979 nField = pKeyInfo->nField;
62980 assert( pKeyInfo->aSortOrder!=0 );
62981 while( idx1<szHdr1 && i<pPKey2->nField ){
62982 u32 serial_type1;
62983
62984 /* Read the serial types for the next element in each key. */
62985 idx1 += getVarint32( aKey1+idx1, serial_type1 );
62986 if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
 
 
 
 
 
 
 
 
 
 
 
62987
62988 /* Extract the values to be compared.
62989 */
62990 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
62991
62992 /* Do the comparison
62993 */
62994 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62995 i<nField ? pKeyInfo->aColl[i] : 0);
62996 if( rc!=0 ){
62997 assert( mem1.zMalloc==0 ); /* See comment below */
62998
62999 /* Invert the result if we are using DESC sort order. */
63000 if( i<nField && pKeyInfo->aSortOrder[i] ){
63001 rc = -rc;
63002 }
63003
63004 /* If the PREFIX_SEARCH flag is set and all fields except the final
63005 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
63210 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63211 ** constants) to the value before returning it.
63212 **
63213 ** The returned value must be freed by the caller using sqlite3ValueFree().
63214 */
63215 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63216 assert( iVar>0 );
63217 if( v ){
63218 Mem *pMem = &v->aVar[iVar-1];
63219 if( 0==(pMem->flags & MEM_Null) ){
63220 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
63827 /*
63828 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63829 ** the user-function defined by pCtx.
63830 */
63831 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832 VdbeFunc *pVdbeFunc;
63833
63834 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835 pVdbeFunc = pCtx->pVdbeFunc;
63836 if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837 return 0;
63838 }
63839 return pVdbeFunc->apAux[iArg].pAux;
 
63840 }
63841
63842 /*
63843 ** Set the auxilary data pointer and delete function, for the iArg'th
63844 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
63848 sqlite3_context *pCtx,
63849 int iArg,
63850 void *pAux,
63851 void (*xDelete)(void*)
63852 ){
63853 struct AuxData *pAuxData;
63854 VdbeFunc *pVdbeFunc;
63855 if( iArg<0 ) goto failed;
63856
63857 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858 pVdbeFunc = pCtx->pVdbeFunc;
63859 if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860 int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861 int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862 pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863 if( !pVdbeFunc ){
63864 goto failed;
63865 }
63866 pCtx->pVdbeFunc = pVdbeFunc;
63867 memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868 pVdbeFunc->nAux = iArg+1;
63869 pVdbeFunc->pFunc = pCtx->pFunc;
63870 }
63871
63872 pAuxData = &pVdbeFunc->apAux[iArg];
63873 if( pAuxData->pAux && pAuxData->xDelete ){
63874 pAuxData->xDelete(pAuxData->pAux);
63875 }
 
63876 pAuxData->pAux = pAux;
63877 pAuxData->xDelete = xDelete;
63878 return;
63879
63880 failed:
@@ -65482,11 +65547,11 @@
65482 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65483 u8 encoding = ENC(db); /* The database encoding */
65484 int iCompare = 0; /* Result of last OP_Compare operation */
65485 unsigned nVmStep = 0; /* Number of virtual machine steps */
65486 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487 unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65488 #endif
65489 Mem *aMem = p->aMem; /* Copy of p->aMem */
65490 Mem *pIn1 = 0; /* 1st input operand */
65491 Mem *pIn2 = 0; /* 2nd input operand */
65492 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
65941 assert( p->explain==0 );
65942 p->pResultSet = 0;
65943 db->busyHandler.nBusy = 0;
65944 CHECK_FOR_INTERRUPT;
65945 sqlite3VdbeIOTraceSql(p);
 
 
 
 
 
 
 
 
 
 
 
65946 #ifdef SQLITE_DEBUG
65947 sqlite3BeginBenignMalloc();
65948 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65949 int i;
65950 printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
66101 ** of VDBE ops have been executed (either since this invocation of
66102 ** sqlite3VdbeExec() or since last time the progress callback was called).
66103 ** If the progress callback returns non-zero, exit the virtual machine with
66104 ** a return code SQLITE_ABORT.
66105 */
66106 if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66107 int prc;
66108 prc = db->xProgress(db->pProgressArg);
66109 if( prc!=0 ){
66110 rc = SQLITE_INTERRUPT;
66111 goto vdbe_error_halt;
66112 }
66113 nProgressOps = nVmStep;
 
 
66114 }
66115 #endif
66116
66117 break;
66118 }
@@ -66794,23 +66872,18 @@
66794 Deephemeralize(u.ai.pArg);
66795 sqlite3VdbeMemStoreType(u.ai.pArg);
66796 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66797 }
66798
66799 assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800 if( pOp->p4type==P4_FUNCDEF ){
66801 u.ai.ctx.pFunc = pOp->p4.pFunc;
66802 u.ai.ctx.pVdbeFunc = 0;
66803 }else{
66804 u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805 u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806 }
66807
66808 u.ai.ctx.s.flags = MEM_Null;
66809 u.ai.ctx.s.db = db;
66810 u.ai.ctx.s.xDel = 0;
66811 u.ai.ctx.s.zMalloc = 0;
 
 
66812
66813 /* The output cell may already have a buffer allocated. Move
66814 ** the pointer to u.ai.ctx.s so in case the user-function can use
66815 ** the already allocated buffer instead of allocating a new one.
66816 */
@@ -66829,15 +66902,11 @@
66829 lastRowid = db->lastRowid;
66830
66831 /* If any auxiliary data functions have been called by this user function,
66832 ** immediately call the destructor for any non-static values.
66833 */
66834 if( u.ai.ctx.pVdbeFunc ){
66835 sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836 pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837 pOp->p4type = P4_VDBEFUNC;
66838 }
66839
66840 if( db->mallocFailed ){
66841 /* Even though a malloc() has failed, the implementation of the
66842 ** user function may have called an sqlite3_result_XXX() function
66843 ** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
74200 /* Translate the schema name in zDb into a pointer to the corresponding
74201 ** schema. If not found, pSchema will remain NULL and nothing will match
74202 ** resulting in an appropriate error message toward the end of this routine
74203 */
74204 if( zDb ){
74205 for(i=0; i<db->nDb; i++){
74206 assert( db->aDb[i].zName );
74207 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74208 pSchema = db->aDb[i].pSchema;
74209 break;
 
 
 
 
 
 
 
 
 
74210 }
74211 }
74212 }
74213
74214 /* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
74481 }
74482 ExprSetProperty(p, EP_Resolved);
74483 }
74484 return p;
74485 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74486
74487 /*
74488 ** This routine is callback for sqlite3WalkExpr().
74489 **
74490 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
74581 FuncDef *pDef; /* Information about the function */
74582 u8 enc = ENC(pParse->db); /* The database encoding */
74583
74584 testcase( pExpr->op==TK_CONST_FUNC );
74585 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
 
74586 zId = pExpr->u.zToken;
74587 nId = sqlite3Strlen30(zId);
74588 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74589 if( pDef==0 ){
74590 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
74646 #endif
74647 case TK_IN: {
74648 testcase( pExpr->op==TK_IN );
74649 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74650 int nRef = pNC->nRef;
74651 #ifndef SQLITE_OMIT_CHECK
74652 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74653 sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74654 }
74655 #endif
74656 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74657 assert( pNC->nRef>=nRef );
74658 if( nRef!=pNC->nRef ){
74659 ExprSetProperty(pExpr, EP_VarSelect);
74660 }
74661 }
74662 break;
74663 }
74664 #ifndef SQLITE_OMIT_CHECK
74665 case TK_VARIABLE: {
74666 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74667 sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74668 }
74669 break;
74670 }
74671 #endif
74672 }
74673 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74674 }
74675
74676 /*
@@ -74757,11 +74863,11 @@
74757 /* Try to match the ORDER BY expression against an expression
74758 ** in the result set. Return an 1-based index of the matching
74759 ** result-set entry.
74760 */
74761 for(i=0; i<pEList->nExpr; i++){
74762 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74763 return i+1;
74764 }
74765 }
74766
74767 /* If no match, return 0. */
@@ -74985,11 +75091,11 @@
74985 pItem->iOrderByCol = 0;
74986 if( sqlite3ResolveExprNames(pNC, pE) ){
74987 return 1;
74988 }
74989 for(j=0; j<pSelect->pEList->nExpr; j++){
74990 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
74991 pItem->iOrderByCol = j+1;
74992 }
74993 }
74994 }
74995 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
75291 w.xSelectCallback = resolveSelectStep;
75292 w.pParse = pParse;
75293 w.u.pNC = pOuterNC;
75294 sqlite3WalkSelect(&w, p);
75295 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75296
75297 /************** End of resolve.c *********************************************/
75298 /************** Begin file expr.c ********************************************/
75299 /*
75300 ** 2001 September 15
@@ -76987,14 +77135,13 @@
76987 #endif
76988
76989 switch( pExpr->op ){
76990 case TK_IN: {
76991 char affinity; /* Affinity of the LHS of the IN */
76992 KeyInfo keyInfo; /* Keyinfo for the generated table */
76993 static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
76994 int addr; /* Address of OP_OpenEphemeral instruction */
76995 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
 
76996
76997 if( rMayHaveNull ){
76998 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
76999 }
77000
@@ -77014,13 +77161,11 @@
77014 ** is used.
77015 */
77016 pExpr->iTable = pParse->nTab++;
77017 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77018 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77019 memset(&keyInfo, 0, sizeof(keyInfo));
77020 keyInfo.nField = 1;
77021 keyInfo.aSortOrder = &sortOrder;
77022
77023 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77024 /* Case 1: expr IN (SELECT ...)
77025 **
77026 ** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
77033 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77034 dest.affSdst = (u8)affinity;
77035 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77036 pExpr->x.pSelect->iLimit = 0;
77037 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
 
77038 return 0;
77039 }
77040 pEList = pExpr->x.pSelect->pEList;
77041 if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77042 keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77043 pEList->a[0].pExpr);
77044 }
77045 }else if( ALWAYS(pExpr->x.pList!=0) ){
77046 /* Case 2: expr IN (exprlist)
77047 **
@@ -77056,12 +77202,13 @@
77056 int r1, r2, r3;
77057
77058 if( !affinity ){
77059 affinity = SQLITE_AFF_NONE;
77060 }
77061 keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77062 keyInfo.aSortOrder = &sortOrder;
 
77063
77064 /* Loop through each expression in <exprlist>. */
77065 r1 = sqlite3GetTempReg(pParse);
77066 r2 = sqlite3GetTempReg(pParse);
77067 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
77096 }
77097 }
77098 sqlite3ReleaseTempReg(pParse, r1);
77099 sqlite3ReleaseTempReg(pParse, r2);
77100 }
77101 if( !isRowid ){
77102 sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77103 }
77104 break;
77105 }
77106
77107 case TK_EXISTS:
@@ -77657,19 +77804,24 @@
77657 break;
77658 }
77659 /* Otherwise, fall thru into the TK_COLUMN case */
77660 }
77661 case TK_COLUMN: {
77662 if( pExpr->iTable<0 ){
77663 /* This only happens when coding check constraints */
77664 assert( pParse->ckBase>0 );
77665 inReg = pExpr->iColumn + pParse->ckBase;
77666 }else{
77667 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77668 pExpr->iColumn, pExpr->iTable, target,
77669 pExpr->op2);
77670 }
 
 
 
 
 
77671 break;
77672 }
77673 case TK_INTEGER: {
77674 codeInteger(pParse, pExpr, 0, target);
77675 break;
@@ -79088,10 +79240,16 @@
79088 ** Do a deep comparison of two expression trees. Return 0 if the two
79089 ** expressions are completely identical. Return 1 if they differ only
79090 ** by a COLLATE operator at the top level. Return 2 if there are differences
79091 ** other than the top-level COLLATE operator.
79092 **
 
 
 
 
 
 
79093 ** Sometimes this routine will return 2 even if the two expressions
79094 ** really are equivalent. If we cannot prove that the expressions are
79095 ** identical, we return 2 just to be safe. So if this routine
79096 ** returns 2, then you do not really know for certain if the two
79097 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
79098 ** can be sure the expressions are the same. In the places where
79099 ** this routine is used, it does not hurt to get an extra 2 - that
79100 ** just might result in some slightly slower code. But returning
79101 ** an incorrect 0 or 1 could lead to a malfunction.
79102 */
79103 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79104 if( pA==0||pB==0 ){
79105 return pB==pA ? 0 : 2;
79106 }
79107 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79108 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79109 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79110 return 2;
79111 }
79112 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79113 if( pA->op!=pB->op ){
79114 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79115 return 1;
79116 }
79117 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79118 return 1;
79119 }
79120 return 2;
79121 }
79122 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79123 if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79124 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79125 if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
 
 
 
79126 if( ExprHasProperty(pA, EP_IntValue) ){
79127 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79128 return 2;
79129 }
79130 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
79138
79139 /*
79140 ** Compare two ExprList objects. Return 0 if they are identical and
79141 ** non-zero if they differ in any way.
79142 **
 
 
 
79143 ** This routine might return non-zero for equivalent ExprLists. The
79144 ** only consequence will be disabled optimizations. But this routine
79145 ** must never return 0 if the two ExprList objects are different, or
79146 ** a malfunction will result.
79147 **
79148 ** Two NULL pointers are considered to be the same. But a NULL pointer
79149 ** always differs from a non-NULL pointer.
79150 */
79151 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79152 int i;
79153 if( pA==0 && pB==0 ) return 0;
79154 if( pA==0 || pB==0 ) return 1;
79155 if( pA->nExpr!=pB->nExpr ) return 1;
79156 for(i=0; i<pA->nExpr; i++){
79157 Expr *pExprA = pA->a[i].pExpr;
79158 Expr *pExprB = pB->a[i].pExpr;
79159 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79160 if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79161 }
79162 return 0;
79163 }
79164
79165 /*
@@ -79340,11 +79543,11 @@
79340 /* Check to see if pExpr is a duplicate of another aggregate
79341 ** function that is already in the pAggInfo structure
79342 */
79343 struct AggInfo_func *pItem = pAggInfo->aFunc;
79344 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79345 if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79346 break;
79347 }
79348 }
79349 if( i>=pAggInfo->nFunc ){
79350 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
80757 int i; /* Loop counter */
80758 int topOfLoop; /* The top of the loop */
80759 int endOfLoop; /* The end of the loop */
80760 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80761 int iDb; /* Index of database containing pTab */
 
80762 int regTabname = iMem++; /* Register containing table name */
80763 int regIdxname = iMem++; /* Register containing index name */
80764 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80765 #ifdef SQLITE_ENABLE_STAT3
80766 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
80816 KeyInfo *pKey;
80817 int addrIfNot = 0; /* address of OP_IfNot */
80818 int *aChngAddr; /* Array of jump instruction addresses */
80819
80820 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
 
80821 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
80822 nCol = pIdx->nColumn;
80823 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
80824 if( aChngAddr==0 ) continue;
80825 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
80975 ** If K==0 then no entry is made into the sqlite_stat1 table.
80976 ** If K>0 then it is always the case the D>0 so division by zero
80977 ** is never possible.
80978 */
80979 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80980 if( jZeroRows<0 ){
80981 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80982 }
80983 for(i=0; i<nCol; i++){
80984 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
80985 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80986 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
80987 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
80988 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
80989 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
80990 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80991 }
 
80992 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
80993 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
80994 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
80995 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
 
80996 }
80997
80998 /* If the table has no indices, create a single sqlite_stat1 entry
80999 ** containing NULL as the index name and the row count as the content.
81000 */
81001 if( pTab->pIndex==0 ){
81002 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
81003 VdbeComment((v, "%s", pTab->zName));
81004 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
81005 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
81006 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81007 }else{
81008 sqlite3VdbeJumpHere(v, jZeroRows);
81009 jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
81010 }
81011 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81012 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81013 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81014 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81015 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81016 if( pParse->nMem<regRec ) pParse->nMem = regRec;
81017 sqlite3VdbeJumpHere(v, jZeroRows);
81018 }
81019
81020
81021 /*
81022 ** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
81195 v = 0;
81196 while( (c=z[0])>='0' && c<='9' ){
81197 v = v*10 + c - '0';
81198 z++;
81199 }
81200 if( i==0 ) pTable->nRowEst = v;
81201 if( pIndex==0 ) break;
 
 
81202 pIndex->aiRowEst[i] = v;
81203 if( *z==' ' ) z++;
81204 if( strcmp(z, "unordered")==0 ){
81205 pIndex->bUnordered = 1;
81206 break;
@@ -82636,10 +82840,11 @@
82636 */
82637 static void freeIndex(sqlite3 *db, Index *p){
82638 #ifndef SQLITE_OMIT_ANALYZE
82639 sqlite3DeleteIndexSamples(db, p);
82640 #endif
 
82641 sqlite3DbFree(db, p->zColAff);
82642 sqlite3DbFree(db, p);
82643 }
82644
82645 /*
@@ -83479,11 +83684,12 @@
83479 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83480 "INTEGER PRIMARY KEY");
83481 #endif
83482 }else{
83483 Index *p;
83484 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
 
83485 if( p ){
83486 p->autoIndex = 2;
83487 }
83488 pList = 0;
83489 }
@@ -83774,30 +83980,11 @@
83774
83775 #ifndef SQLITE_OMIT_CHECK
83776 /* Resolve names in all CHECK constraint expressions.
83777 */
83778 if( p->pCheck ){
83779 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83780 NameContext sNC; /* Name context for pParse->pNewTable */
83781 ExprList *pList; /* List of all CHECK constraints */
83782 int i; /* Loop counter */
83783
83784 memset(&sNC, 0, sizeof(sNC));
83785 memset(&sSrc, 0, sizeof(sSrc));
83786 sSrc.nSrc = 1;
83787 sSrc.a[0].zName = p->zName;
83788 sSrc.a[0].pTab = p;
83789 sSrc.a[0].iCursor = -1;
83790 sNC.pParse = pParse;
83791 sNC.pSrcList = &sSrc;
83792 sNC.ncFlags = NC_IsCheck;
83793 pList = p->pCheck;
83794 for(i=0; i<pList->nExpr; i++){
83795 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83796 return;
83797 }
83798 }
83799 }
83800 #endif /* !defined(SQLITE_OMIT_CHECK) */
83801
83802 /* If the db->init.busy is 1 it means we are reading the SQL off the
83803 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
84645 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84646 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84647 int addr1; /* Address of top of loop */
84648 int addr2; /* Address to jump to for next iteration */
84649 int tnum; /* Root page of index */
 
84650 Vdbe *v; /* Generate code into this virtual machine */
84651 KeyInfo *pKey; /* KeyInfo for index */
84652 int regRecord; /* Register holding assemblied index record */
84653 sqlite3 *db = pParse->db; /* The database connection */
84654 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
84684 ** records into the sorter. */
84685 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84686 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84687 regRecord = sqlite3GetTempReg(pParse);
84688
84689 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84690 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
 
84691 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84692 sqlite3VdbeJumpHere(v, addr1);
84693 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84694 if( pIndex->onError!=OE_None ){
84695 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
84736 Token *pName2, /* Second part of index name. May be NULL */
84737 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84738 ExprList *pList, /* A list of columns to be indexed */
84739 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84740 Token *pStart, /* The CREATE token that begins this statement */
84741 Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84742 int sortOrder, /* Sort order of primary key when pList==NULL */
84743 int ifNotExist /* Omit error if index already exists */
84744 ){
84745 Index *pRet = 0; /* Pointer to return */
84746 Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
84758 struct ExprList_item *pListItem; /* For looping over pList */
84759 int nCol;
84760 int nExtra = 0;
84761 char *zExtra;
84762
84763 assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
84764 assert( pParse->nErr==0 ); /* Never called with prior errors */
84765 if( db->mallocFailed || IN_DECLARE_VTAB ){
84766 goto exit_create_index;
84767 }
84768 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
84804 assert(0);
84805 }
84806 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84807 assert( db->mallocFailed==0 || pTab==0 );
84808 if( pTab==0 ) goto exit_create_index;
84809 assert( db->aDb[iDb].pSchema==pTab->pSchema );
 
 
 
 
 
84810 }else{
84811 assert( pName==0 );
84812 assert( pStart==0 );
84813 pTab = pParse->pNewTable;
84814 if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
84953 pIndex->nColumn = pList->nExpr;
84954 pIndex->onError = (u8)onError;
84955 pIndex->uniqNotNull = onError==OE_Abort;
84956 pIndex->autoIndex = (u8)(pName==0);
84957 pIndex->pSchema = db->aDb[iDb].pSchema;
 
 
 
 
 
84958 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
84959
84960 /* Check to see if we should honor DESC requests on index columns
84961 */
84962 if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
85108 ** If pTblName==0 it means this index is generated as a primary key
85109 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85110 ** has just been created, it contains no data and the index initialization
85111 ** step can be skipped.
85112 */
85113 else{ /* if( db->init.busy==0 ) */
85114 Vdbe *v;
85115 char *zStmt;
85116 int iMem = ++pParse->nMem;
85117
85118 v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
85126
85127 /* Gather the complete text of the CREATE INDEX statement into
85128 ** the zStmt variable
85129 */
85130 if( pStart ){
85131 assert( pEnd!=0 );
 
85132 /* A named index with an explicit CREATE INDEX statement */
85133 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85134 onError==OE_None ? "" : " UNIQUE",
85135 (int)(pEnd->z - pName->z) + 1,
85136 pName->z);
85137 }else{
85138 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85139 /* zStmt = sqlite3MPrintf(""); */
85140 zStmt = 0;
85141 }
@@ -85187,14 +85384,12 @@
85187 pIndex = 0;
85188 }
85189
85190 /* Clean up before exiting */
85191 exit_create_index:
85192 if( pIndex ){
85193 sqlite3DbFree(db, pIndex->zColAff);
85194 sqlite3DbFree(db, pIndex);
85195 }
85196 sqlite3ExprListDelete(db, pList);
85197 sqlite3SrcListDelete(db, pTblName);
85198 sqlite3DbFree(db, zName);
85199 return pRet;
85200 }
@@ -86068,29 +86263,24 @@
86068 ** the error.
86069 */
86070 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86071 int i;
86072 int nCol = pIdx->nColumn;
86073 int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86074 sqlite3 *db = pParse->db;
86075 KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86076
86077 if( pKey ){
86078 pKey->db = pParse->db;
86079 pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86080 assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86081 for(i=0; i<nCol; i++){
86082 char *zColl = pIdx->azColl[i];
86083 assert( zColl );
86084 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86085 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86086 }
86087 pKey->nField = (u16)nCol;
86088 }
86089
86090 if( pParse->nErr ){
86091 sqlite3DbFree(db, pKey);
86092 pKey = 0;
86093 }
86094 return pKey;
86095 }
86096
@@ -87166,15 +87356,18 @@
87166 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87167 ){
87168 int i;
87169 Index *pIdx;
87170 int r1;
 
 
87171
87172 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87173 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87174 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87175 sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
 
87176 }
87177 }
87178
87179 /*
87180 ** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
87184 **
87185 ** Return a register number which is the first in a block of
87186 ** registers that holds the elements of the index key. The
87187 ** block of registers has already been deallocated by the time
87188 ** this routine returns.
 
 
 
 
 
 
 
87189 */
87190 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87191 Parse *pParse, /* Parsing context */
87192 Index *pIdx, /* The index for which to generate a key */
87193 int iCur, /* Cursor number for the pIdx->pTable table */
87194 int regOut, /* Write the new index key to this register */
87195 int doMakeRec /* Run the OP_MakeRecord instruction if true */
 
87196 ){
87197 Vdbe *v = pParse->pVdbe;
87198 int j;
87199 Table *pTab = pIdx->pTable;
87200 int regBase;
87201 int nCol;
87202
 
 
 
 
 
 
 
 
 
 
87203 nCol = pIdx->nColumn;
87204 regBase = sqlite3GetTempRange(pParse, nCol+1);
87205 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87206 for(j=0; j<nCol; j++){
87207 int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
91561 ** Add the new records to the indices as we go.
91562 */
91563 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91564 int regIdx;
91565 int regR;
 
91566
91567 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
 
 
 
 
 
 
 
 
 
91568
91569 /* Create a key for accessing the index entry */
91570 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91571 for(i=0; i<pIdx->nColumn; i++){
91572 int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
91583
91584 /* Find out what action to take in case there is an indexing conflict */
91585 onError = pIdx->onError;
91586 if( onError==OE_None ){
91587 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
 
91588 continue; /* pIdx is not a UNIQUE index */
91589 }
91590 if( overrideError!=OE_Default ){
91591 onError = overrideError;
91592 }else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
91652 seenReplace = 1;
91653 break;
91654 }
91655 }
91656 sqlite3VdbeJumpHere(v, j3);
 
91657 sqlite3ReleaseTempReg(pParse, regR);
91658 }
91659
91660 if( pbMayReplace ){
91661 *pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
91681 int appendBias, /* True if this is likely to be an append */
91682 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91683 ){
91684 int i;
91685 Vdbe *v;
91686 int nIdx;
91687 Index *pIdx;
91688 u8 pik_flags;
91689 int regData;
91690 int regRec;
91691
91692 v = sqlite3GetVdbe(pParse);
91693 assert( v!=0 );
91694 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91695 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91696 for(i=nIdx-1; i>=0; i--){
91697 if( aRegIdx[i]==0 ) continue;
 
 
 
91698 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91699 if( useSeekResult ){
91700 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91701 }
91702 }
@@ -91794,10 +92018,11 @@
91794 **
91795 ** * The index is over the same set of columns
91796 ** * The same DESC and ASC markings occurs on all columns
91797 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
91798 ** * The same collating sequence on each column
 
91799 */
91800 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
91801 int i;
91802 assert( pDest && pSrc );
91803 assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
91815 return 0; /* Different sort orders */
91816 }
91817 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
91818 return 0; /* Different collating sequences */
91819 }
 
 
 
91820 }
91821
91822 /* If no test above fails then the indices must be compatible */
91823 return 1;
91824 }
@@ -91971,11 +92199,11 @@
91971 if( pSrcIdx==0 ){
91972 return 0; /* pDestIdx has no corresponding index in pSrc */
91973 }
91974 }
91975 #ifndef SQLITE_OMIT_CHECK
91976 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
91977 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
91978 }
91979 #endif
91980 #ifndef SQLITE_OMIT_FOREIGN_KEY
91981 /* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
94884 cnt++;
94885 }
94886 }
94887
94888 /* Make sure sufficient number of registers have been allocated */
94889 if( pParse->nMem < cnt+4 ){
94890 pParse->nMem = cnt+4;
94891 }
94892
94893 /* Do the b-tree integrity checks */
94894 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
94895 sqlite3VdbeChangeP5(v, (u8)i);
94896 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
94911
94912 if( pTab->pIndex==0 ) continue;
94913 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
94914 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94915 sqlite3VdbeJumpHere(v, addr);
 
94916 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94917 sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94918 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94919 sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
 
 
94920 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94921 int jmp2;
94922 int r1;
94923 static const VdbeOpList idxErr[] = {
94924 { OP_AddImm, 1, -1, 0},
94925 { OP_String8, 0, 3, 0}, /* 1 */
94926 { OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
94931 { OP_Concat, 6, 3, 3},
94932 { OP_ResultRow, 3, 1, 0},
94933 { OP_IfPos, 1, 0, 0}, /* 9 */
94934 { OP_Halt, 0, 0, 0},
94935 };
94936 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
 
94937 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
94938 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
94939 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
94940 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
94941 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
94942 sqlite3VdbeJumpHere(v, addr+9);
94943 sqlite3VdbeJumpHere(v, jmp2);
 
94944 }
94945 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94946 sqlite3VdbeJumpHere(v, loopTop);
 
 
 
94947 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94948 static const VdbeOpList cntIdx[] = {
94949 { OP_Integer, 0, 3, 0},
94950 { OP_Rewind, 0, 0, 0}, /* 1 */
94951 { OP_AddImm, 3, 1, 0},
94952 { OP_Next, 0, 0, 0}, /* 3 */
94953 { OP_Eq, 2, 0, 3}, /* 4 */
94954 { OP_AddImm, 1, -1, 0},
94955 { OP_String8, 0, 2, 0}, /* 6 */
94956 { OP_String8, 0, 3, 0}, /* 7 */
94957 { OP_Concat, 3, 2, 2},
94958 { OP_ResultRow, 2, 1, 0},
94959 };
94960 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
94961 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94962 sqlite3VdbeJumpHere(v, addr);
94963 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94964 sqlite3VdbeChangeP1(v, addr+1, j+2);
94965 sqlite3VdbeChangeP2(v, addr+1, addr+4);
94966 sqlite3VdbeChangeP1(v, addr+3, j+2);
94967 sqlite3VdbeChangeP2(v, addr+3, addr+2);
94968 sqlite3VdbeJumpHere(v, addr+4);
94969 sqlite3VdbeChangeP4(v, addr+6,
94970 "wrong # of entries in index ", P4_STATIC);
94971 sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94972 }
94973 }
94974 }
94975 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
94976 sqlite3VdbeChangeP2(v, addr, -mxErr);
94977 sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
96994 */
96995 if( pOrderBy==0 && p->iLimit ){
96996 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
96997 }
96998 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96999
97000 /*
97001 ** Given an expression list, generate a KeyInfo structure that records
97002 ** the collating sequence for each expression in that expression list.
97003 **
@@ -97011,29 +97250,23 @@
97011 ** function is responsible for seeing that this structure is eventually
97012 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97013 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97014 */
97015 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97016 sqlite3 *db = pParse->db;
97017 int nExpr;
97018 KeyInfo *pInfo;
97019 struct ExprList_item *pItem;
 
97020 int i;
97021
97022 nExpr = pList->nExpr;
97023 pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97024 if( pInfo ){
97025 pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97026 pInfo->nField = (u16)nExpr;
97027 pInfo->enc = ENC(db);
97028 pInfo->db = db;
97029 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97030 CollSeq *pColl;
97031 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97032 if( !pColl ){
97033 pColl = db->pDfltColl;
97034 }
97035 pInfo->aColl[i] = pColl;
97036 pInfo->aSortOrder[i] = pItem->sortOrder;
97037 }
97038 }
97039 return pInfo;
@@ -98135,27 +98368,21 @@
98135 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98136 int nCol; /* Number of columns in result set */
98137
98138 assert( p->pRightmost==p );
98139 nCol = p->pEList->nExpr;
98140 pKeyInfo = sqlite3DbMallocZero(db,
98141 sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98142 if( !pKeyInfo ){
98143 rc = SQLITE_NOMEM;
98144 goto multi_select_end;
98145 }
98146
98147 pKeyInfo->enc = ENC(db);
98148 pKeyInfo->nField = (u16)nCol;
98149
98150 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98151 *apColl = multiSelectCollSeq(pParse, p, i);
98152 if( 0==*apColl ){
98153 *apColl = db->pDfltColl;
98154 }
98155 }
98156 pKeyInfo->aSortOrder = (u8*)apColl;
98157
98158 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98159 for(i=0; i<2; i++){
98160 int addr = pLoop->addrOpenEphm[i];
98161 if( addr<0 ){
@@ -98520,16 +98747,12 @@
98520 struct ExprList_item *pItem;
98521 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98522 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98523 aPermute[i] = pItem->iOrderByCol - 1;
98524 }
98525 pKeyMerge =
98526 sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98527 if( pKeyMerge ){
98528 pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98529 pKeyMerge->nField = (u16)nOrderBy;
98530 pKeyMerge->enc = ENC(db);
98531 for(i=0; i<nOrderBy; i++){
98532 CollSeq *pColl;
98533 Expr *pTerm = pOrderBy->a[i].pExpr;
98534 if( pTerm->flags & EP_Collate ){
98535 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
98562 int nExpr = p->pEList->nExpr;
98563 assert( nOrderBy>=nExpr || db->mallocFailed );
98564 regPrev = pParse->nMem+1;
98565 pParse->nMem += nExpr+1;
98566 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98567 pKeyDup = sqlite3DbMallocZero(db,
98568 sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98569 if( pKeyDup ){
98570 pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98571 pKeyDup->nField = (u16)nExpr;
98572 pKeyDup->enc = ENC(db);
98573 for(i=0; i<nExpr; i++){
98574 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98575 pKeyDup->aSortOrder[i] = 0;
98576 }
98577 }
@@ -99833,14 +100052,16 @@
99833 ** and/or pParse->db->mallocFailed.
99834 */
99835 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99836 Walker w;
99837 memset(&w, 0, sizeof(w));
99838 w.xSelectCallback = convertCompoundSelectToSubquery;
99839 w.xExprCallback = exprWalkNoop;
99840 w.pParse = pParse;
99841 sqlite3WalkSelect(&w, pSelect);
 
 
 
99842 w.xSelectCallback = selectExpander;
99843 sqlite3WalkSelect(&w, pSelect);
99844 }
99845
99846
@@ -100370,11 +100591,11 @@
100370 ** will cause elements to come out in the correct order. This is
100371 ** an optimization - the correct answer should result regardless.
100372 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100373 ** to disable this optimization for testing purposes.
100374 */
100375 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100376 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100377 pOrderBy = 0;
100378 }
100379
100380 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100391 ** used for both the ORDER BY and DISTINCT processing. As originally
100392 ** written the query must use a temp-table for at least one of the ORDER
100393 ** BY and DISTINCT, and an index or separate temp-table for the other.
100394 */
100395 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100396 && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100397 ){
100398 p->selFlags &= ~SF_Distinct;
100399 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100400 pGroupBy = p->pGroupBy;
100401 pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102618 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102619 if( aRegIdx==0 ) goto update_cleanup;
102620 }
102621 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102622 int reg;
102623 if( hasFK || chngRowid ){
102624 reg = ++pParse->nMem;
102625 }else{
102626 reg = 0;
102627 for(i=0; i<pIdx->nColumn; i++){
102628 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105158 ** the pWC->a[] array.
105159 */
105160 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105161 WhereTerm *pTerm;
105162 int idx;
105163 testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105164 if( pWC->nTerm>=pWC->nSlot ){
105165 WhereTerm *pOld = pWC->a;
105166 sqlite3 *db = pWC->pWInfo->pParse->db;
105167 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105168 if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105303
105304 /*
105305 ** Return TRUE if the given operator is one of the operators that is
105306 ** allowed for an indexable WHERE clause term. The allowed operators are
105307 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105308 **
105309 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105310 ** of one of the following forms: column = expression column > expression
105311 ** column >= expression column < expression column <= expression
105312 ** expression = column expression > column expression >= column
105313 ** expression < column expression <= column column IN
105314 ** (expression-list) column IN (subquery) column IS NULL
105315 */
105316 static int allowedOp(int op){
105317 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105318 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105319 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105628 op = pRight->op2;
105629 }
105630 if( op==TK_VARIABLE ){
105631 Vdbe *pReprepare = pParse->pReprepare;
105632 int iCol = pRight->iColumn;
105633 pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105634 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105635 z = (char *)sqlite3_value_text(pVal);
105636 }
105637 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105638 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
105983 }
105984
105985 /* At this point, okToChngToIN is true if original pTerm satisfies
105986 ** case 1. In that case, construct a new virtual term that is
105987 ** pTerm converted into an IN operator.
105988 **
105989 ** EV: R-00211-15100
105990 */
105991 if( okToChngToIN ){
105992 Expr *pDup; /* A transient duplicate expression */
105993 ExprList *pList = 0; /* The RHS of the IN operator */
105994 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106226 ** wildcard. But if we increment '@', that will push it into the
106227 ** alphabetic range where case conversions will mess up the
106228 ** inequality. To avoid this, make sure to also run the full
106229 ** LIKE on all candidate expressions by clearing the isComplete flag
106230 */
106231 if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106232
106233
106234 c = sqlite3UpperToLower[c];
106235 }
106236 *pC = c + 1;
106237 }
106238 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106735 VdbeComment((v, "for %s", pTable->zName));
106736
106737 /* Fill the automatic index with content */
106738 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106739 regRecord = sqlite3GetTempReg(pParse);
106740 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106741 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106742 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106743 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106744 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106745 sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107092 if( pExpr->op==TK_VARIABLE
107093 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107094 ){
107095 int iVar = pExpr->iColumn;
107096 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107097 *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107098 return SQLITE_OK;
107099 }
107100 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107101 }
107102 #endif
@@ -107318,13 +107528,10 @@
107318 **
107319 ** The t2.z='ok' is disabled in the in (2) because it originates
107320 ** in the ON clause. The term is disabled in (3) because it is not part
107321 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107322 **
107323 ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107324 ** completely satisfied by indices.
107325 **
107326 ** Disabling a term causes that term to not be tested in the inner loop
107327 ** of the join. Disabling is an optimization. When terms are satisfied
107328 ** by indices, we disable them to prevent redundant tests in the inner
107329 ** loop. We would get the correct results if nothing were ever disabled,
107330 ** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107550 pTerm = pLoop->aLTerm[j];
107551 assert( pTerm!=0 );
107552 /* The following true for indices with redundant columns.
107553 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107554 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107555 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107556 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107557 if( r1!=regBase+j ){
107558 if( nReg==1 ){
107559 sqlite3ReleaseTempReg(pParse, regBase);
107560 regBase = r1;
@@ -107750,10 +107957,11 @@
107750 WhereLevel *pLevel; /* The where level to be coded */
107751 WhereLoop *pLoop; /* The WhereLoop object being coded */
107752 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753 WhereTerm *pTerm; /* A WHERE clause term */
107754 Parse *pParse; /* Parsing context */
 
107755 Vdbe *v; /* The prepared stmt under constructions */
107756 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757 int addrBrk; /* Jump here to break out of the loop */
107758 int addrCont; /* Jump here to continue with next cycle */
107759 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107761 Bitmask newNotReady; /* Return value */
107762
107763 pParse = pWInfo->pParse;
107764 v = pParse->pVdbe;
107765 pWC = &pWInfo->sWC;
 
107766 pLevel = &pWInfo->a[iLevel];
107767 pLoop = pLevel->pWLoop;
107768 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769 iCur = pTabItem->iCursor;
107770 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
107859 iReleaseReg = sqlite3GetTempReg(pParse);
107860 pTerm = pLoop->aLTerm[0];
107861 assert( pTerm!=0 );
107862 assert( pTerm->pExpr!=0 );
107863 assert( omitTable==0 );
107864 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107865 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107866 addrNxt = pLevel->addrNxt;
107867 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107868 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107869 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
107907 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107908 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107909 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107910
107911 assert( (pStart->wtFlags & TERM_VNULL)==0 );
107912 testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107913 pX = pStart->pExpr;
107914 assert( pX!=0 );
107915 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107916 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107917 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
107926 Expr *pX;
107927 pX = pEnd->pExpr;
107928 assert( pX!=0 );
107929 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107930 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107931 testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107932 memEndValue = ++pParse->nMem;
107933 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107934 if( pX->op==TK_LT || pX->op==TK_GT ){
107935 testOp = bRev ? OP_Le : OP_Ge;
107936 }else{
@@ -108051,11 +108260,11 @@
108051 /* Generate code to evaluate all constraint terms using == or IN
108052 ** and store the values of those terms in an array of registers
108053 ** starting at regBase.
108054 */
108055 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108057 addrNxt = pLevel->addrNxt;
108058
108059 /* If we are doing a reverse order scan on an ascending index, or
108060 ** a forward order scan on a descending index, interchange the
108061 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108092 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108093 zStartAff[nEq] = SQLITE_AFF_NONE;
108094 }
108095 }
108096 nConstraint++;
108097 testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108098 }else if( isMinQuery ){
108099 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108100 nConstraint++;
108101 startEq = 0;
108102 start_constraints = 1;
@@ -108134,14 +108343,14 @@
108134 zEndAff[nEq] = SQLITE_AFF_NONE;
108135 }
108136 }
108137 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138 nConstraint++;
108139 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140 }
108141 sqlite3DbFree(pParse->db, zStartAff);
108142 sqlite3DbFree(pParse->db, zEndAff);
108143
108144 /* Top of the loop body */
108145 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146
108147 /* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108264 */
108265 if( pWInfo->nLevel>1 ){
108266 int nNotReady; /* The number of notReady tables */
108267 struct SrcList_item *origSrc; /* Original list of tables */
108268 nNotReady = pWInfo->nLevel - iLevel - 1;
108269 pOrTab = sqlite3StackAllocRaw(pParse->db,
108270 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271 if( pOrTab==0 ) return notReady;
108272 pOrTab->nAlloc = (u8)(nNotReady + 1);
108273 pOrTab->nSrc = pOrTab->nAlloc;
108274 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108318 Expr *pExpr = pWC->a[iTerm].pExpr;
108319 if( &pWC->a[iTerm] == pTerm ) continue;
108320 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108325 }
108326 if( pAndExpr ){
108327 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328 }
108329 }
@@ -108339,11 +108548,11 @@
108339 }
108340 /* Loop through table entries that match term pOrTerm. */
108341 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108345 if( pSubWInfo ){
108346 WhereLoop *pSubLoop;
108347 explainOneScan(
108348 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349 );
@@ -108394,17 +108603,17 @@
108394 }
108395 pLevel->u.pCovidx = pCov;
108396 if( pCov ) pLevel->iIdxCur = iCovCur;
108397 if( pAndExpr ){
108398 pAndExpr->pLeft = 0;
108399 sqlite3ExprDelete(pParse->db, pAndExpr);
108400 }
108401 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403 sqlite3VdbeResolveLabel(v, iLoopBody);
108404
108405 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108406 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407 }else
108408 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409
108410 {
@@ -108421,18 +108630,14 @@
108421 }
108422 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108423
108424 /* Insert code to test every subexpression that can be completely
108425 ** computed using the current set of tables.
108426 **
108427 ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108428 ** the use of indices become tests that are evaluated against each row of
108429 ** the relevant input tables.
108430 */
108431 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108432 Expr *pE;
108433 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108434 testcase( pTerm->wtFlags & TERM_CODED );
108435 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108436 if( (pTerm->prereqAll & newNotReady)!=0 ){
108437 testcase( pWInfo->untestedTerms==0
108438 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108455 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108456 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457 ** the implied "t1.a=123" constraint.
108458 */
108459 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460 Expr *pE;
108461 WhereTerm *pAlt;
108462 Expr sEq;
108463 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465 if( pTerm->leftCursor!=iCur ) continue;
108466 if( pLevel->iLeftJoin ) continue;
108467 pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108471 if( pAlt==0 ) continue;
108472 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473 testcase( pAlt->eOperator & WO_EQ );
108474 testcase( pAlt->eOperator & WO_IN );
108475 VdbeNoopComment((v, "begin transitive constraint"));
108476 sEq = *pAlt->pExpr;
108477 sEq.pLeft = pE->pLeft;
108478 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108479 }
108480
108481 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108482 ** at least one row of the right table has matched the left table.
108483 */
@@ -108485,11 +108693,11 @@
108485 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108486 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108487 VdbeComment((v, "record LEFT JOIN hit"));
108488 sqlite3ExprCacheClear(pParse);
108489 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108490 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108491 testcase( pTerm->wtFlags & TERM_CODED );
108492 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108493 if( (pTerm->prereqAll & newNotReady)!=0 ){
108494 assert( pWInfo->untestedTerms );
108495 continue;
@@ -108926,11 +109134,12 @@
108926 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108927 }else if( (pTerm->eOperator & WO_IN)
108928 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108929 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108930 }
108931 if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
 
108932 }
108933 #endif
108934 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108935 /* Each row involves a step of the index, then a binary search of
108936 ** the main table */
@@ -108998,10 +109207,21 @@
108998 if( x<BMS-1 ) m |= MASKBIT(x);
108999 }
109000 return m;
109001 }
109002
 
 
 
 
 
 
 
 
 
 
 
109003
109004 /*
109005 ** Add all WhereLoop objects for a single table of the join where the table
109006 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109007 ** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109021 int rc = SQLITE_OK; /* Return code */
109022 int iSortIdx = 1; /* Index number */
109023 int b; /* A boolean value */
109024 WhereCost rSize; /* number of rows in the table */
109025 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
 
109026
109027 pNew = pBuilder->pNew;
109028 pWInfo = pBuilder->pWInfo;
109029 pTabList = pWInfo->pTabList;
109030 pSrc = pTabList->a + pNew->iTab;
 
109031 assert( !IsVirtual(pSrc->pTab) );
109032
109033 if( pSrc->pIndex ){
109034 /* An INDEXED BY clause specifies a particular index to use */
109035 pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109065 && !pSrc->viaCoroutine
109066 && !pSrc->notIndexed
109067 && !pSrc->isCorrelated
109068 ){
109069 /* Generate auto-index WhereLoops */
109070 WhereClause *pWC = pBuilder->pWC;
109071 WhereTerm *pTerm;
109072 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109073 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109074 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109075 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109095 }
109096
109097 /* Loop over all indices
109098 */
109099 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
 
 
 
 
109100 pNew->u.btree.nEq = 0;
109101 pNew->nLTerm = 0;
109102 pNew->iSortIdx = 0;
109103 pNew->rSetup = 0;
109104 pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110035 pLoop->u.btree.nEq = 1;
110036 /* TUNING: Cost of a rowid lookup is 10 */
110037 pLoop->rRun = 33; /* 33==whereCost(10) */
110038 }else{
110039 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110040 if( pIdx->onError==OE_None ) continue;
110041 for(j=0; j<pIdx->nColumn; j++){
110042 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110043 if( pTerm==0 ) break;
110044 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110045 pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110241 ** subexpression is separated by an AND operator.
110242 */
110243 initMaskSet(pMaskSet);
110244 whereClauseInit(&pWInfo->sWC, pWInfo);
110245 sqlite3ExprCodeConstants(pParse, pWhere);
110246 whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110247 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110248
110249 /* Special case: a WHERE clause that is constant. Evaluate the
110250 ** expression and either jump over all of the code or fall thru.
110251 */
@@ -110875,11 +111100,11 @@
110875 #endif
110876 #define sqlite3ParserARG_SDECL Parse *pParse;
110877 #define sqlite3ParserARG_PDECL ,Parse *pParse
110878 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110879 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
110880 #define YYNSTATE 627
110881 #define YYNRULE 327
110882 #define YYFALLBACK 1
110883 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110884 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110885 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
110948 ** shifting non-terminals after a reduce.
110949 ** yy_default[] Default action for each state.
110950 */
110951 #define YY_ACTTAB_COUNT (1564)
110952 static const YYACTIONTYPE yy_action[] = {
110953 /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
110954 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110955 /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110956 /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110957 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110958 /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110959 /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110960 /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
110961 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110962 /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110963 /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
110964 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110965 /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
110966 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110967 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110968 /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110969 /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110970 /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110971 /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110972 /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110973 /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110974 /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110975 /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110976 /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110977 /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110978 /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110979 /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110980 /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110981 /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110982 /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110983 /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110984 /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110985 /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110986 /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110987 /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110988 /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
110989 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110990 /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110991 /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110992 /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110993 /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110994 /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110995 /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110996 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110997 /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110998 /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110999 /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
111000 /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
111001 /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
111002 /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
111003 /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
111004 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
111005 /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
111006 /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
111007 /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
111008 /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
111009 /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
111010 /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111011 /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111012 /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
111013 /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
111014 /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
111015 /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
111016 /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
111017 /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
111018 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111019 /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
111020 /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
111021 /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
111022 /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
111023 /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
111024 /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
111025 /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111026 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111027 /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
111028 /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
111029 /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
111030 /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
111031 /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
111032 /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111033 /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
111034 /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
111035 /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
111036 /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
111037 /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
111038 /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
111039 /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
111040 /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
111041 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
111042 /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111043 /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111044 /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111045 /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111046 /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111047 /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111048 /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111049 /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111050 /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111051 /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111052 /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111053 /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111054 /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111055 /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111056 /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111057 /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111058 /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111059 /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111060 /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111061 /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111062 /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111063 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111064 /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111065 /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111066 /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111067 /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111068 /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111069 /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111070 /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111071 /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111072 /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111073 /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111074 /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111075 /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111076 /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111077 /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111078 /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111079 /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111080 /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111081 /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111082 /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111083 /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111084 /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111085 /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111086 /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111087 /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111088 /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111089 /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111090 /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111091 /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111092 /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111093 /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111094 /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111095 /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111096 /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111097 /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111098 /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111099 /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111100 /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111101 /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111102 /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111103 /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111104 /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111105 /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111106 /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111107 /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111108 /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111109 /* 1560 */ 295, 498, 956, 488,
111110 };
111111 static const YYCODETYPE yy_lookahead[] = {
111112 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111113 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111114 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111256 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111257 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111258 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111259 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111260 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111261 /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111262 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111263 /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111264 /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111265 /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111266 /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111267 /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111268 /* 1560 */ 195, 182, 250, 186,
111269 };
111270 #define YY_SHIFT_USE_DFLT (-70)
111271 #define YY_SHIFT_COUNT (416)
111272 #define YY_SHIFT_MIN (-69)
111273 #define YY_SHIFT_MAX (1487)
111274 static const short yy_shift_ofst[] = {
111275 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111276 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111283 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111284 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111285 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111286 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111287 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111288 /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111289 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111290 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111291 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111292 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111293 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111294 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111295 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111296 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111297 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111298 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111299 /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111300 /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111301 /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111302 /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111303 /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111304 /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111305 /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111306 /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111307 /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111308 /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111309 /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111310 /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111311 /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111312 /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111313 /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111314 /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111315 /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111316 /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111317 };
111318 #define YY_REDUCE_USE_DFLT (-169)
111319 #define YY_REDUCE_COUNT (308)
111320 #define YY_REDUCE_MIN (-168)
111321 #define YY_REDUCE_MAX (1391)
111322 static const short yy_reduce_ofst[] = {
111323 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111324 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111325 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111326 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111337 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111338 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111339 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111340 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111341 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111342 /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111343 /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111344 /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111345 /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111346 /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111347 /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111348 /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111349 /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111350 /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111351 /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111352 /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111353 /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111354 };
111355 static const YYACTIONTYPE yy_default[] = {
111356 /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111357 /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111358 /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111359 /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111360 /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111361 /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111362 /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111363 /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111364 /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111365 /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111366 /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111367 /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111368 /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111369 /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111370 /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111371 /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111372 /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111373 /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111374 /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111375 /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111376 /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111377 /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111378 /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111379 /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111380 /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111381 /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111382 /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111383 /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111384 /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111385 /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111386 /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111387 /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111388 /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111389 /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111390 /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111391 /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111392 /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111393 /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111394 /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111395 /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111396 /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111397 /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111398 /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111399 /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111400 /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111401 /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111402 /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111403 /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111404 /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111405 /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111406 /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111407 /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111408 /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111409 /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111410 /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111411 /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111412 /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111413 /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111414 /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111415 /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111416 /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111417 /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111418 /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111419 };
111420
111421 /* The next table maps tokens into fallback tokens. If a construct
111422 ** like the following:
111423 **
@@ -111885,11 +112110,11 @@
111885 /* 237 */ "case_operand ::=",
111886 /* 238 */ "exprlist ::= nexprlist",
111887 /* 239 */ "exprlist ::=",
111888 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
111889 /* 241 */ "nexprlist ::= expr",
111890 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
111891 /* 243 */ "uniqueflag ::= UNIQUE",
111892 /* 244 */ "uniqueflag ::=",
111893 /* 245 */ "idxlist_opt ::=",
111894 /* 246 */ "idxlist_opt ::= LP idxlist RP",
111895 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112604 { 224, 0 },
112605 { 220, 1 },
112606 { 220, 0 },
112607 { 215, 3 },
112608 { 215, 1 },
112609 { 147, 11 },
112610 { 227, 1 },
112611 { 227, 0 },
112612 { 178, 0 },
112613 { 178, 3 },
112614 { 187, 5 },
@@ -113046,10 +113271,11 @@
113046 case 114: /* select ::= select multiselect_op oneselect */
113047 {
113048 if( yymsp[0].minor.yy159 ){
113049 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113050 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
 
113051 }else{
113052 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113053 }
113054 yygotominor.yy159 = yymsp[0].minor.yy159;
113055 }
@@ -113608,15 +113834,15 @@
113608 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113609 break;
113610 case 241: /* nexprlist ::= expr */
113611 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113612 break;
113613 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113614 {
113615 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113616 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113617 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113618 }
113619 break;
113620 case 243: /* uniqueflag ::= UNIQUE */
113621 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113622 {yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114538 *tokenType = TK_SPACE;
114539 return i;
114540 }
114541 case '-': {
114542 if( z[1]=='-' ){
114543 /* IMP: R-50417-27976 -- syntax diagram for comments */
114544 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114545 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114546 return i;
114547 }
114548 *tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114571 case '/': {
114572 if( z[1]!='*' || z[2]==0 ){
114573 *tokenType = TK_SLASH;
114574 return 1;
114575 }
114576 /* IMP: R-50417-27976 -- syntax diagram for comments */
114577 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114578 if( c ) i++;
114579 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114580 return i;
114581 }
@@ -116416,10 +116640,11 @@
116416 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116421 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117771 db->autoCommit = 1;
117772 db->nextAutovac = -1;
117773 db->szMmap = sqlite3GlobalConfig.szMmap;
117774 db->nextPagesize = 0;
117775 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777 | SQLITE_AutoIndex
117778 #endif
117779 #if SQLITE_DEFAULT_FILE_FORMAT<4
117780 | SQLITE_LegacyFileFmt
117781 #endif
@@ -128244,11 +128469,11 @@
128244 }
128245
128246
128247 #ifdef SQLITE_TEST
128248
128249 /* #include <tcl.h> */
128250 /* #include <string.h> */
128251
128252 /*
128253 ** Implementation of a special SQL scalar function for testing tokenizers
128254 ** designed to be used in concert with the Tcl testing framework. This
128255
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
 
 
 
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
408 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -670,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1039,10 +1025,11 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
3109 ** interface is to keep a GUI updated during a large query.
3110 **
3111 ** ^The parameter P is passed through as the only parameter to the
3112 ** callback function X. ^The parameter N is the approximate number of
3113 ** [virtual machine instructions] that are evaluated between successive
3114 ** invocations of the callback X. ^If N is less than one then the progress
3115 ** handler is disabled.
3116 **
3117 ** ^Only a single progress handler may be defined at one time per
3118 ** [database connection]; setting a new progress handler cancels the
3119 ** old one. ^Setting parameter X to NULL disables the progress handler.
3120 ** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
4730 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4731
4732 /*
4733 ** CAPI3REF: Function Auxiliary Data
4734 **
4735 ** These functions may be used by (non-aggregate) SQL functions to
4736 ** associate metadata with argument values. If the same value is passed to
4737 ** multiple invocations of the same SQL function during query execution, under
4738 ** some circumstances the associated metadata may be preserved. An example
4739 ** of where this might be useful is in a regular-expression matching
4740 ** function. The compiled version of the regular expression can be stored as
4741 ** metadata associated with the pattern string.
4742 ** Then as long as the pattern string remains the same,
4743 ** the compiled regular expression can be reused on multiple
4744 ** invocations of the same function.
4745 **
4746 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4747 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4748 ** value to the application-defined function. ^If there is no metadata
4749 ** associated with the function argument, this sqlite3_get_auxdata() interface
4750 ** returns a NULL pointer.
 
4751 **
4752 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4753 ** argument of the application-defined function. ^Subsequent
4754 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756 ** NULL if the metadata has been discarded.
4757 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758 ** SQLite will invoke the destructor function X with parameter P exactly
4759 ** once, when the metadata is discarded.
4760 ** SQLite is free to discard the metadata at any time, including: <ul>
4761 ** <li> when the corresponding function parameter changes, or
4762 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763 ** SQL statement, or
4764 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765 ** <li> during the original sqlite3_set_auxdata() call when a memory
4766 ** allocation error occurs. </ul>)^
4767 **
4768 ** Note the last bullet in particular. The destructor X in
4769 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4771 ** should be called near the end of the function implementation and the
4772 ** function implementation should not make any use of P after
4773 ** sqlite3_set_auxdata() has been called.
4774 **
4775 ** ^(In practice, metadata is preserved between function calls for
4776 ** function parameters that are compile-time constants, including literal
4777 ** values and [parameters] and expressions composed from the same.)^
4778 **
@@ -6829,13 +6816,13 @@
6816 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6817 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6818 ** </dd>
6819 **
6820 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6821 ** <dd>This parameter returns zero for the current value if and only if
6822 ** all foreign key constraints (deferred or immediate) have been
6823 ** resolved.)^ ^The highwater mark is always 0.
6824 ** </dd>
6825 ** </dl>
6826 */
6827 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6828 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
8811
8812 /*
8813 ** The names of the following types declared in vdbeInt.h are required
8814 ** for the VdbeOp definition.
8815 */
 
8816 typedef struct Mem Mem;
8817 typedef struct SubProgram SubProgram;
8818
8819 /*
8820 ** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
8834 void *p; /* Generic pointer */
8835 char *z; /* Pointer to data for string (char array) types */
8836 i64 *pI64; /* Used when p4type is P4_INT64 */
8837 double *pReal; /* Used when p4type is P4_REAL */
8838 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
 
8839 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8840 Mem *pMem; /* Used when p4type is P4_MEM */
8841 VTable *pVtab; /* Used when p4type is P4_VTAB */
8842 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8843 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
8887 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8888 #define P4_STATIC (-2) /* Pointer to a static string */
8889 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8890 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8891 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
 
8892 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8893 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8894 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8895 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8896 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
8943 */
8944 /************** Include opcodes.h in the middle of vdbe.h ********************/
8945 /************** Begin file opcodes.h *****************************************/
8946 /* Automatically generated. Do not edit */
8947 /* See the mkopcodeh.awk script for details */
8948 #define OP_Function 1
8949 #define OP_Savepoint 2
8950 #define OP_AutoCommit 3
8951 #define OP_Transaction 4
8952 #define OP_SorterNext 5
8953 #define OP_Prev 6
8954 #define OP_Next 7
8955 #define OP_AggStep 8
8956 #define OP_Checkpoint 9
8957 #define OP_JournalMode 10
8958 #define OP_Vacuum 11
8959 #define OP_VFilter 12
8960 #define OP_VUpdate 13
8961 #define OP_Goto 14
8962 #define OP_Gosub 15
8963 #define OP_Return 16
8964 #define OP_Yield 17
8965 #define OP_HaltIfNull 18
8966 #define OP_Not 19 /* same as TK_NOT */
8967 #define OP_Halt 20
8968 #define OP_Integer 21
8969 #define OP_Int64 22
8970 #define OP_String 23
8971 #define OP_Null 24
8972 #define OP_Blob 25
8973 #define OP_Variable 26
8974 #define OP_Move 27
8975 #define OP_Copy 28
8976 #define OP_SCopy 29
8977 #define OP_ResultRow 30
8978 #define OP_CollSeq 31
8979 #define OP_AddImm 32
8980 #define OP_MustBeInt 33
8981 #define OP_RealAffinity 34
8982 #define OP_Permutation 35
8983 #define OP_Compare 36
8984 #define OP_Jump 37
8985 #define OP_Once 38
8986 #define OP_If 39
8987 #define OP_IfNot 40
8988 #define OP_Column 41
8989 #define OP_Affinity 42
8990 #define OP_MakeRecord 43
8991 #define OP_Count 44
8992 #define OP_ReadCookie 45
8993 #define OP_SetCookie 46
8994 #define OP_VerifyCookie 47
8995 #define OP_OpenRead 48
8996 #define OP_OpenWrite 49
8997 #define OP_OpenAutoindex 50
8998 #define OP_OpenEphemeral 51
8999 #define OP_SorterOpen 52
9000 #define OP_OpenPseudo 53
9001 #define OP_Close 54
9002 #define OP_SeekLt 55
9003 #define OP_SeekLe 56
9004 #define OP_SeekGe 57
9005 #define OP_SeekGt 58
9006 #define OP_Seek 59
9007 #define OP_NotFound 60
9008 #define OP_Found 61
9009 #define OP_IsUnique 62
9010 #define OP_NotExists 63
9011 #define OP_Sequence 64
9012 #define OP_NewRowid 65
9013 #define OP_Insert 66
9014 #define OP_InsertInt 67
9015 #define OP_Or 68 /* same as TK_OR */
9016 #define OP_And 69 /* same as TK_AND */
9017 #define OP_Delete 70
9018 #define OP_ResetCount 71
9019 #define OP_SorterCompare 72
9020 #define OP_IsNull 73 /* same as TK_ISNULL */
9021 #define OP_NotNull 74 /* same as TK_NOTNULL */
9022 #define OP_Ne 75 /* same as TK_NE */
9023 #define OP_Eq 76 /* same as TK_EQ */
9024 #define OP_Gt 77 /* same as TK_GT */
9025 #define OP_Le 78 /* same as TK_LE */
9026 #define OP_Lt 79 /* same as TK_LT */
9027 #define OP_Ge 80 /* same as TK_GE */
9028 #define OP_SorterData 81
9029 #define OP_BitAnd 82 /* same as TK_BITAND */
9030 #define OP_BitOr 83 /* same as TK_BITOR */
9031 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
9033 #define OP_Add 86 /* same as TK_PLUS */
9034 #define OP_Subtract 87 /* same as TK_MINUS */
9035 #define OP_Multiply 88 /* same as TK_STAR */
9036 #define OP_Divide 89 /* same as TK_SLASH */
9037 #define OP_Remainder 90 /* same as TK_REM */
9038 #define OP_Concat 91 /* same as TK_CONCAT */
9039 #define OP_RowKey 92
9040 #define OP_BitNot 93 /* same as TK_BITNOT */
9041 #define OP_String8 94 /* same as TK_STRING */
9042 #define OP_RowData 95
9043 #define OP_Rowid 96
9044 #define OP_NullRow 97
9045 #define OP_Last 98
9046 #define OP_SorterSort 99
9047 #define OP_Sort 100
9048 #define OP_Rewind 101
9049 #define OP_SorterInsert 102
9050 #define OP_IdxInsert 103
9051 #define OP_IdxDelete 104
9052 #define OP_IdxRowid 105
9053 #define OP_IdxLT 106
9054 #define OP_IdxGE 107
9055 #define OP_Destroy 108
9056 #define OP_Clear 109
9057 #define OP_CreateIndex 110
9058 #define OP_CreateTable 111
9059 #define OP_ParseSchema 112
9060 #define OP_LoadAnalysis 113
9061 #define OP_DropTable 114
9062 #define OP_DropIndex 115
9063 #define OP_DropTrigger 116
9064 #define OP_IntegrityCk 117
9065 #define OP_RowSetAdd 118
9066 #define OP_RowSetRead 119
9067 #define OP_RowSetTest 120
9068 #define OP_Program 121
9069 #define OP_Param 122
9070 #define OP_FkCounter 123
9071 #define OP_FkIfZero 124
9072 #define OP_MemMax 125
9073 #define OP_IfPos 126
9074 #define OP_IfNeg 127
9075 #define OP_IfZero 128
9076 #define OP_AggFinal 129
9077 #define OP_Real 130 /* same as TK_FLOAT */
9078 #define OP_IncrVacuum 131
9079 #define OP_Expire 132
9080 #define OP_TableLock 133
9081 #define OP_VBegin 134
9082 #define OP_VCreate 135
9083 #define OP_VDestroy 136
9084 #define OP_VOpen 137
9085 #define OP_VColumn 138
9086 #define OP_VNext 139
9087 #define OP_VRename 140
9088 #define OP_ToText 141 /* same as TK_TO_TEXT */
9089 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
9090 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
9091 #define OP_ToInt 144 /* same as TK_TO_INT */
9092 #define OP_ToReal 145 /* same as TK_TO_REAL */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9093 #define OP_Pagecount 146
9094 #define OP_MaxPgcnt 147
9095 #define OP_Trace 148
9096 #define OP_Noop 149
9097 #define OP_Explain 150
@@ -9123,28 +9107,28 @@
9107 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9108 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9109 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9110 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9111 #define OPFLG_INITIALIZER {\
9112 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113 /* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114 /* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115 /* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116 /* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117 /* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118 /* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119 /* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120 /* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121 /* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122 /* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124 /* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125 /* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127 /* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128 /* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129 /* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
9130 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9131
9132 /************** End of opcodes.h *********************************************/
9133 /************** Continuing where we left off in vdbe.h ***********************/
9134
@@ -9190,11 +9174,11 @@
9174 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
9175 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
9176 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
9177 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
9178 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9179 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
9180 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
9181 #ifndef SQLITE_OMIT_TRACE
9182 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
9183 #endif
9184
@@ -10688,16 +10672,20 @@
10672
10673 /*
10674 ** An instance of the following structure is passed as the first
10675 ** argument to sqlite3VdbeKeyCompare and is used to control the
10676 ** comparison of the two index keys.
10677 **
10678 ** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679 ** are nField slots for the columns of an index then one extra slot
10680 ** for the rowid at the end.
10681 */
10682 struct KeyInfo {
10683 sqlite3 *db; /* The database connection */
10684 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10685 u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686 u8 *aSortOrder; /* Sort order for each column. */
10687 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10688 };
10689
10690 /*
10691 ** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
10750 char *zColAff; /* String defining the affinity of each column */
10751 Index *pNext; /* The next index associated with the same table */
10752 Schema *pSchema; /* Schema containing this index */
10753 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
10754 char **azColl; /* Array of collation sequence names for index */
10755 Expr *pPartIdxWhere; /* WHERE clause for partial indices */
10756 int tnum; /* DB Page containing root of this index */
10757 u16 nColumn; /* Number of columns in table used by this index */
10758 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
10759 unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
10760 unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
11231 #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
11232 #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
11233 #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
11234 #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
11235 ** if no other resolution is available */
11236 #define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
11237
11238 /*
11239 ** An instance of the following structure contains all information
11240 ** needed to generate code for a single SELECT statement.
11241 **
@@ -11296,10 +11286,11 @@
11286 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11287 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11288 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11289 #define SF_Materialize 0x0100 /* Force materialization of views */
11290 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
11292
11293
11294 /*
11295 ** The results of a select can be distributed in several ways. The
11296 ** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
11408 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11409 u8 nColCache; /* Number of entries in aColCache[] */
11410 u8 iColCache; /* Next entry in aColCache[] to replace */
11411 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11412 u8 mayAbort; /* True if statement may throw an ABORT exception */
11413 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
11414 int aTempReg[8]; /* Holding area for temporary registers */
11415 int nRangeReg; /* Size of the temporary register block */
11416 int iRangeReg; /* First register in temporary register block */
11417 int nErr; /* Number of errors seen */
11418 int nTab; /* Number of previously allocated VDBE cursors */
11419 int nMem; /* Number of memory cells used so far */
11420 int nSet; /* Number of sets used so far */
11421 int nOnce; /* Number of OP_Once instructions so far */
11422 int ckBase; /* Base register of data during check constraints */
11423 int iPartIdxTab; /* Table corresponding to a partial index */
11424 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
11425 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
11426 struct yColCache {
11427 int iTable; /* Table cursor number */
11428 int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
12000 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
12001 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
12002 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
12003 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
12004 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12005 Expr*, int, int);
12006 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
12007 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
12008 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
12009 Expr*,ExprList*,u16,Expr*,Expr*);
12010 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
12048 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
12049 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
12050 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
12051 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
12052 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12053 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12054 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12055 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
12056 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
12057 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
12058 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
12059 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
12060 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
12077 SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
12078 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
12079 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
12080 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
12081 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12082 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
12083 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
12084 int*,int,int,int,int,int*);
12085 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
12086 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
12087 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
12280 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
12281 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
12282 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
12283 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
12284 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12285 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
12286 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
12287 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12288 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
12289 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
12290 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
12300 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12301 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12302 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12303 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12304 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
12306 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12307 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12308 void (*)(sqlite3_context*,int,sqlite3_value **),
12309 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12310 FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
13253 typedef struct VdbeSorter VdbeSorter;
13254
13255 /* Opaque type used by the explainer */
13256 typedef struct Explain Explain;
13257
13258 /* Elements of the linked list at Vdbe.pAuxData */
13259 typedef struct AuxData AuxData;
13260
13261 /*
13262 ** A cursor is a pointer into a single BTree within a database file.
13263 ** The cursor can seek to a BTree entry with a particular key, or
13264 ** loop over all entries of the Btree. You can also insert new BTree
13265 ** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
13442 */
13443 #ifdef SQLITE_DEBUG
13444 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13445 #endif
13446
13447 /*
13448 ** Each auxilliary data pointer stored by a user defined function
13449 ** implementation calling sqlite3_set_auxdata() is stored in an instance
13450 ** of this structure. All such structures associated with a single VM
13451 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13452 ** when the VM is halted (if not before).
 
 
 
13453 */
13454 struct AuxData {
13455 int iOp; /* Instruction number of OP_Function opcode */
13456 int iArg; /* Index of function argument. */
13457 void *pAux; /* Aux data pointer */
13458 void (*xDelete)(void *); /* Destructor for the aux data */
13459 AuxData *pNext; /* Next element in list */
 
13460 };
13461
13462 /*
13463 ** The "context" argument for a installable function. A pointer to an
13464 ** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
13472 ** This structure is defined inside of vdbeInt.h because it uses substructures
13473 ** (Mem) which are only defined there.
13474 */
13475 struct sqlite3_context {
13476 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
 
13477 Mem s; /* The return value is stored here */
13478 Mem *pMem; /* Memory cell used to store aggregate context */
13479 CollSeq *pColl; /* Collating sequence */
13480 int isError; /* Error code returned by the function. */
13481 int skipFlag; /* Skip skip accumulator loading if true */
13482 int iOp; /* Instruction number of OP_Function */
13483 Vdbe *pVdbe; /* The VM that owns this context */
13484 };
13485
13486 /*
13487 ** An Explain object accumulates indented output which is helpful
13488 ** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
13577 int nFrame; /* Number of frames in pFrame list */
13578 u32 expmask; /* Binding to these vars invalidates VM */
13579 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13580 int nOnceFlag; /* Size of array aOnceFlag[] */
13581 u8 *aOnceFlag; /* Flags for OP_Once */
13582 AuxData *pAuxData; /* Linked list of auxdata allocations */
13583 };
13584
13585 /*
13586 ** The following are allowed values for Vdbe.magic
13587 */
@@ -13604,11 +13601,11 @@
13601 #endif
13602 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13603 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13604 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13606 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13607
13608 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13609 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13610 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13611 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
22700 /* Automatically generated. Do not edit */
22701 /* See the mkopcodec.awk script for details. */
22702 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22703 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22704 static const char *const azName[] = { "?",
22705 /* 1 */ "Function",
22706 /* 2 */ "Savepoint",
22707 /* 3 */ "AutoCommit",
22708 /* 4 */ "Transaction",
22709 /* 5 */ "SorterNext",
22710 /* 6 */ "Prev",
22711 /* 7 */ "Next",
22712 /* 8 */ "AggStep",
22713 /* 9 */ "Checkpoint",
22714 /* 10 */ "JournalMode",
22715 /* 11 */ "Vacuum",
22716 /* 12 */ "VFilter",
22717 /* 13 */ "VUpdate",
22718 /* 14 */ "Goto",
22719 /* 15 */ "Gosub",
22720 /* 16 */ "Return",
22721 /* 17 */ "Yield",
22722 /* 18 */ "HaltIfNull",
22723 /* 19 */ "Not",
22724 /* 20 */ "Halt",
22725 /* 21 */ "Integer",
22726 /* 22 */ "Int64",
22727 /* 23 */ "String",
22728 /* 24 */ "Null",
22729 /* 25 */ "Blob",
22730 /* 26 */ "Variable",
22731 /* 27 */ "Move",
22732 /* 28 */ "Copy",
22733 /* 29 */ "SCopy",
22734 /* 30 */ "ResultRow",
22735 /* 31 */ "CollSeq",
22736 /* 32 */ "AddImm",
22737 /* 33 */ "MustBeInt",
22738 /* 34 */ "RealAffinity",
22739 /* 35 */ "Permutation",
22740 /* 36 */ "Compare",
22741 /* 37 */ "Jump",
22742 /* 38 */ "Once",
22743 /* 39 */ "If",
22744 /* 40 */ "IfNot",
22745 /* 41 */ "Column",
22746 /* 42 */ "Affinity",
22747 /* 43 */ "MakeRecord",
22748 /* 44 */ "Count",
22749 /* 45 */ "ReadCookie",
22750 /* 46 */ "SetCookie",
22751 /* 47 */ "VerifyCookie",
22752 /* 48 */ "OpenRead",
22753 /* 49 */ "OpenWrite",
22754 /* 50 */ "OpenAutoindex",
22755 /* 51 */ "OpenEphemeral",
22756 /* 52 */ "SorterOpen",
22757 /* 53 */ "OpenPseudo",
22758 /* 54 */ "Close",
22759 /* 55 */ "SeekLt",
22760 /* 56 */ "SeekLe",
22761 /* 57 */ "SeekGe",
22762 /* 58 */ "SeekGt",
22763 /* 59 */ "Seek",
22764 /* 60 */ "NotFound",
22765 /* 61 */ "Found",
22766 /* 62 */ "IsUnique",
22767 /* 63 */ "NotExists",
22768 /* 64 */ "Sequence",
22769 /* 65 */ "NewRowid",
22770 /* 66 */ "Insert",
22771 /* 67 */ "InsertInt",
22772 /* 68 */ "Or",
22773 /* 69 */ "And",
22774 /* 70 */ "Delete",
22775 /* 71 */ "ResetCount",
22776 /* 72 */ "SorterCompare",
22777 /* 73 */ "IsNull",
22778 /* 74 */ "NotNull",
22779 /* 75 */ "Ne",
22780 /* 76 */ "Eq",
22781 /* 77 */ "Gt",
22782 /* 78 */ "Le",
22783 /* 79 */ "Lt",
22784 /* 80 */ "Ge",
22785 /* 81 */ "SorterData",
22786 /* 82 */ "BitAnd",
22787 /* 83 */ "BitOr",
22788 /* 84 */ "ShiftLeft",
22789 /* 85 */ "ShiftRight",
22790 /* 86 */ "Add",
@@ -22794,59 +22791,59 @@
22791 /* 87 */ "Subtract",
22792 /* 88 */ "Multiply",
22793 /* 89 */ "Divide",
22794 /* 90 */ "Remainder",
22795 /* 91 */ "Concat",
22796 /* 92 */ "RowKey",
22797 /* 93 */ "BitNot",
22798 /* 94 */ "String8",
22799 /* 95 */ "RowData",
22800 /* 96 */ "Rowid",
22801 /* 97 */ "NullRow",
22802 /* 98 */ "Last",
22803 /* 99 */ "SorterSort",
22804 /* 100 */ "Sort",
22805 /* 101 */ "Rewind",
22806 /* 102 */ "SorterInsert",
22807 /* 103 */ "IdxInsert",
22808 /* 104 */ "IdxDelete",
22809 /* 105 */ "IdxRowid",
22810 /* 106 */ "IdxLT",
22811 /* 107 */ "IdxGE",
22812 /* 108 */ "Destroy",
22813 /* 109 */ "Clear",
22814 /* 110 */ "CreateIndex",
22815 /* 111 */ "CreateTable",
22816 /* 112 */ "ParseSchema",
22817 /* 113 */ "LoadAnalysis",
22818 /* 114 */ "DropTable",
22819 /* 115 */ "DropIndex",
22820 /* 116 */ "DropTrigger",
22821 /* 117 */ "IntegrityCk",
22822 /* 118 */ "RowSetAdd",
22823 /* 119 */ "RowSetRead",
22824 /* 120 */ "RowSetTest",
22825 /* 121 */ "Program",
22826 /* 122 */ "Param",
22827 /* 123 */ "FkCounter",
22828 /* 124 */ "FkIfZero",
22829 /* 125 */ "MemMax",
22830 /* 126 */ "IfPos",
22831 /* 127 */ "IfNeg",
22832 /* 128 */ "IfZero",
22833 /* 129 */ "AggFinal",
22834 /* 130 */ "Real",
22835 /* 131 */ "IncrVacuum",
22836 /* 132 */ "Expire",
22837 /* 133 */ "TableLock",
22838 /* 134 */ "VBegin",
22839 /* 135 */ "VCreate",
22840 /* 136 */ "VDestroy",
22841 /* 137 */ "VOpen",
22842 /* 138 */ "VColumn",
22843 /* 139 */ "VNext",
22844 /* 140 */ "VRename",
22845 /* 141 */ "ToText",
22846 /* 142 */ "ToBlob",
22847 /* 143 */ "ToNumeric",
22848 /* 144 */ "ToInt",
22849 /* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
30496 */
30497 #if SQLITE_OS_WIN /* This file is used for Windows only */
30498
30499 #ifdef __CYGWIN__
30500 # include <sys/cygwin.h>
30501 /* # include <errno.h> */
30502 #endif
30503
30504 /*
30505 ** Include code that is common to all os_*.c files
30506 */
@@ -30727,19 +30725,19 @@
30725
30726 /*
30727 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30728 ** based on the sub-platform)?
30729 */
30730 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30731 # define SQLITE_WIN32_HAS_ANSI
30732 #endif
30733
30734 /*
30735 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30736 ** based on the sub-platform)?
30737 */
30738 #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
30739 # define SQLITE_WIN32_HAS_WIDE
30740 #endif
30741
30742 /*
30743 ** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
30917 * zero for the default behavior.
30918 */
30919 #ifndef SQLITE_WIN32_HEAP_FLAGS
30920 # define SQLITE_WIN32_HEAP_FLAGS (0)
30921 #endif
30922
30923
30924 /*
30925 ** The winMemData structure stores information required by the Win32-specific
30926 ** sqlite3_mem_methods implementation.
30927 */
@@ -31267,11 +31266,11 @@
31266 { "GetTempPathA", (SYSCALL)0, 0 },
31267 #endif
31268
31269 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
31270
31271 #if !SQLITE_OS_WINRT && !defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE)
31272 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
31273 #else
31274 { "GetTempPathW", (SYSCALL)0, 0 },
31275 #endif
31276
@@ -34384,14 +34383,14 @@
34383 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34384 osGetCurrentProcessId(), pFd));
34385 return SQLITE_OK;
34386 }
34387 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
 
 
34388 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34391 #else
34392 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34393 #endif
34394 if( pNew==NULL ){
34395 osCloseHandle(pFd->hMap);
34396 pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
34555 #endif
34556 /* caller will handle out of memory */
34557 return zConverted;
34558 }
34559
34560 /*
34561 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34562 ** in characters, so we allocate 3 bytes per character assuming worst-case
34563 ** 3-bytes-per-character UTF8.
34564 */
34565 #ifndef SQLITE_WIN32_MAX_PATH
34566 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34567 #endif
34568
34569 static int winIsDir(const void *zConverted);
34570
34571 /*
34572 ** Create a temporary file name in zBuf. zBuf must be big enough to
34573 ** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
34577 "abcdefghijklmnopqrstuvwxyz"
34578 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34579 "0123456789";
34580 size_t i, j;
34581 int nTempPath;
34582 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34583
34584 /* It's odd to simulate an io-error here, but really this is just
34585 ** using the io-error infrastructure to test that SQLite handles this
34586 ** function failing.
34587 */
34588 SimulateIOError( return SQLITE_IOERR );
34589
 
 
34590 if( sqlite3_temp_directory ){
34591 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34592 sqlite3_temp_directory);
34593 }
34594 #if defined(__CYGWIN__)
34595 else{
34596 static const char *azDirs[] = {
34597 0,
@@ -34621,42 +34628,64 @@
34628 if( winIsDir(zWidePath) ){
34629 break;
34630 }
34631 azDirs[i] = ""; /* Don't retry in future call */
34632 }
34633 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zDir);
34634 }
34635 #elif !SQLITE_OS_WINRT
34636 else if( isNT() ){
34637 char *zMulti;
34638 WCHAR zWidePath[MAX_PATH];
34639 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34641 return SQLITE_IOERR_GETTEMPPATH;
34642 }
34643 zMulti = unicodeToUtf8(zWidePath);
34644 if( zMulti ){
34645 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34646 sqlite3_free(zMulti);
34647 }else{
34648 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34649 return SQLITE_IOERR_NOMEM;
34650 }
34651 }
34652 #ifdef SQLITE_WIN32_HAS_ANSI
34653 else{
34654 char *zUtf8;
34655 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34656 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34658 return SQLITE_IOERR_GETTEMPPATH;
34659 }
34660 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34661 if( zUtf8 ){
34662 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34663 sqlite3_free(zUtf8);
34664 }else{
34665 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34666 return SQLITE_IOERR_NOMEM;
34667 }
34668 }
34669 #else
34670 else{
34671 /*
34672 ** Compiled without ANSI support and the current operating system
34673 ** is not Windows NT; therefore, just zero the temporary buffer.
34674 */
34675 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34676 }
34677 #endif /* SQLITE_WIN32_HAS_ANSI */
34678 #else
34679 else{
34680 /*
34681 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34682 ** therefore, just zero the temporary buffer.
34683 */
34684 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34685 }
34686 #endif /* !SQLITE_OS_WINRT */
34687
34688 /* Check that the output buffer is large enough for the temporary file
34689 ** name. If it is not, return SQLITE_ERROR.
34690 */
34691 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
34767 int cnt = 0;
34768
34769 /* If argument zPath is a NULL pointer, this function is required to open
34770 ** a temporary file. Use this buffer to store the file name in.
34771 */
34772 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34773
34774 int rc = SQLITE_OK; /* Function Return Code */
34775 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34776 int eType = flags&0xFFFFFF00; /* Type of file to open */
34777 #endif
@@ -34804,12 +34833,11 @@
34833 /* If the second argument to this function is NULL, generate a
34834 ** temporary file name to use
34835 */
34836 if( !zUtf8Name ){
34837 assert(isDelete && !isOpenJournal);
34838 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34839 if( rc!=SQLITE_OK ){
34840 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34841 return rc;
34842 }
34843 zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
35264 ){
35265
35266 #if defined(__CYGWIN__)
35267 SimulateIOError( return SQLITE_ERROR );
35268 UNUSED_PARAMETER(nFull);
35269 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35270 assert( nFull>=pVfs->mxPathname );
35271 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35272 /*
35273 ** NOTE: We are dealing with a relative path name and the data
35274 ** directory has been set. Therefore, use it as the basis
35275 ** for converting the relative path name to an absolute
35276 ** one by prepending the data directory and a slash.
35277 */
35278 char zOut[SQLITE_WIN32_MAX_PATH+1];
35279 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35280 SQLITE_WIN32_MAX_PATH+1)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35286 sqlite3_data_directory, zOut);
35287 }else{
35288 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35289 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35290 zRelative);
35291 return SQLITE_CANTOPEN_FULLPATH;
35292 }
35293 }
35294 return SQLITE_OK;
35295 #endif
35296
35297 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
35629 */
35630 SQLITE_API int sqlite3_os_init(void){
35631 static sqlite3_vfs winVfs = {
35632 3, /* iVersion */
35633 sizeof(winFile), /* szOsFile */
35634 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35635 0, /* pNext */
35636 "win32", /* zName */
35637 0, /* pAppData */
35638 winOpen, /* xOpen */
35639 winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
60254 ** a prior call to sqlite3VdbeMakeLabel().
60255 */
60256 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60257 int j = -1-x;
60258 assert( p->magic==VDBE_MAGIC_INIT );
60259 assert( j<p->nLabel );
60260 if( j>=0 && p->aLabel ){
60261 p->aLabel[j] = p->nOp;
60262 }
60263 }
60264
60265 /*
@@ -60376,44 +60411,64 @@
60411 p->readOnly = 1;
60412 p->bIsReader = 0;
60413 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60414 u8 opcode = pOp->opcode;
60415
60416 /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60417 ** cases from this switch! */
60418 switch( opcode ){
60419 case OP_Function:
60420 case OP_AggStep: {
60421 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60422 break;
60423 }
60424 case OP_Transaction: {
60425 if( pOp->p2!=0 ) p->readOnly = 0;
60426 /* fall thru */
60427 }
60428 case OP_AutoCommit:
60429 case OP_Savepoint: {
60430 p->bIsReader = 1;
60431 break;
60432 }
60433 #ifndef SQLITE_OMIT_WAL
60434 case OP_Checkpoint:
60435 #endif
60436 case OP_Vacuum:
60437 case OP_JournalMode: {
60438 p->readOnly = 0;
60439 p->bIsReader = 1;
60440 break;
60441 }
60442 #ifndef SQLITE_OMIT_VIRTUALTABLE
60443 case OP_VUpdate: {
60444 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60445 break;
60446 }
60447 case OP_VFilter: {
60448 int n;
60449 assert( p->nOp - i >= 3 );
60450 assert( pOp[-1].opcode==OP_Integer );
60451 n = pOp[-1].p1;
60452 if( n>nMaxArgs ) nMaxArgs = n;
60453 break;
60454 }
60455 #endif
60456 case OP_Next:
60457 case OP_SorterNext: {
60458 pOp->p4.xAdvance = sqlite3BtreeNext;
60459 pOp->p4type = P4_ADVANCE;
60460 break;
60461 }
60462 case OP_Prev: {
60463 pOp->p4.xAdvance = sqlite3BtreePrevious;
60464 pOp->p4type = P4_ADVANCE;
60465 break;
60466 }
60467 }
60468
60469 pOp->opflags = sqlite3OpcodeProperty[opcode];
60470 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60471 assert( -1-pOp->p2<p->nLabel );
60472 pOp->p2 = aLabel[-1-pOp->p2];
60473 }
60474 }
@@ -60544,12 +60599,11 @@
60599 /*
60600 ** Change the P2 operand of instruction addr so that it points to
60601 ** the address of the next instruction to be coded.
60602 */
60603 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60604 if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
 
60605 }
60606
60607
60608 /*
60609 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
60635 }
60636 case P4_MPRINTF: {
60637 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60638 break;
60639 }
 
 
 
 
 
 
 
60640 case P4_FUNCDEF: {
60641 freeEphemeralFunction(db, (FuncDef*)p4);
60642 break;
60643 }
60644 case P4_MEM: {
@@ -60706,24 +60753,17 @@
60753 pOp->p4type = P4_INT32;
60754 }else if( zP4==0 ){
60755 pOp->p4.p = 0;
60756 pOp->p4type = P4_NOTUSED;
60757 }else if( n==P4_KEYINFO ){
60758 KeyInfo *pOrig, *pNew;
60759
60760 pOrig = (KeyInfo*)zP4;
60761 pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60762 if( pNew ){
60763 memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60764 memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
 
 
 
 
 
 
 
60765 pOp->p4type = P4_KEYINFO;
60766 }else{
60767 p->db->mallocFailed = 1;
60768 pOp->p4type = P4_NOTUSED;
60769 }
@@ -61617,10 +61657,14 @@
61657 while( p->pDelFrame ){
61658 VdbeFrame *pDel = p->pDelFrame;
61659 p->pDelFrame = pDel->pParent;
61660 sqlite3VdbeFrameDelete(pDel);
61661 }
61662
61663 /* Delete any auxdata allocations made by the VM */
61664 sqlite3VdbeDeleteAuxData(p, -1, 0);
61665 assert( p->pAuxData==0 );
61666 }
61667
61668 /*
61669 ** Clean up the VM after execution.
61670 **
@@ -62415,24 +62459,39 @@
62459 sqlite3VdbeDelete(p);
62460 return rc;
62461 }
62462
62463 /*
62464 ** If parameter iOp is less than zero, then invoke the destructor for
62465 ** all auxiliary data pointers currently cached by the VM passed as
62466 ** the first argument.
62467 **
62468 ** Or, if iOp is greater than or equal to zero, then the destructor is
62469 ** only invoked for those auxiliary data pointers created by the user
62470 ** function invoked by the OP_Function opcode at instruction iOp of
62471 ** VM pVdbe, and only then if:
62472 **
62473 ** * the associated function parameter is the 32nd or later (counting
62474 ** from left to right), or
62475 **
62476 ** * the corresponding bit in argument mask is clear (where the first
62477 ** function parameter corrsponds to bit 0 etc.).
62478 */
62479 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62480 AuxData **pp = &pVdbe->pAuxData;
62481 while( *pp ){
62482 AuxData *pAux = *pp;
62483 if( (iOp<0)
62484 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62485 ){
62486 if( pAux->xDelete ){
62487 pAux->xDelete(pAux->pAux);
62488 }
62489 *pp = pAux->pNext;
62490 sqlite3DbFree(pVdbe->db, pAux);
62491 }else{
62492 pp= &pAux->pNext;
62493 }
62494 }
62495 }
62496
62497 /*
@@ -62947,15 +63006,14 @@
63006 */
63007 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
63008 int nKey1, const void *pKey1, /* Left key */
63009 UnpackedRecord *pPKey2 /* Right key */
63010 ){
63011 u32 d1; /* Offset into aKey[] of next data element */
63012 u32 idx1; /* Offset into aKey[] of next header element */
63013 u32 szHdr1; /* Number of bytes in header */
63014 int i = 0;
 
63015 int rc = 0;
63016 const unsigned char *aKey1 = (const unsigned char *)pKey1;
63017 KeyInfo *pKeyInfo;
63018 Mem mem1;
63019
@@ -62974,32 +63032,42 @@
63032 */
63033 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
63034
63035 idx1 = getVarint32(aKey1, szHdr1);
63036 d1 = szHdr1;
63037 assert( pKeyInfo->nField+1>=pPKey2->nField );
63038 assert( pKeyInfo->aSortOrder!=0 );
63039 while( idx1<szHdr1 && i<pPKey2->nField ){
63040 u32 serial_type1;
63041
63042 /* Read the serial types for the next element in each key. */
63043 idx1 += getVarint32( aKey1+idx1, serial_type1 );
63044
63045 /* Verify that there is enough key space remaining to avoid
63046 ** a buffer overread. The "d1+serial_type1+2" subexpression will
63047 ** always be greater than or equal to the amount of required key space.
63048 ** Use that approximation to avoid the more expensive call to
63049 ** sqlite3VdbeSerialTypeLen() in the common case.
63050 */
63051 if( d1+serial_type1+2>(u32)nKey1
63052 && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63053 ){
63054 break;
63055 }
63056
63057 /* Extract the values to be compared.
63058 */
63059 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
63060
63061 /* Do the comparison
63062 */
63063 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
 
63064 if( rc!=0 ){
63065 assert( mem1.zMalloc==0 ); /* See comment below */
63066
63067 /* Invert the result if we are using DESC sort order. */
63068 if( pKeyInfo->aSortOrder[i] ){
63069 rc = -rc;
63070 }
63071
63072 /* If the PREFIX_SEARCH flag is set and all fields except the final
63073 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
63278 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63279 ** constants) to the value before returning it.
63280 **
63281 ** The returned value must be freed by the caller using sqlite3ValueFree().
63282 */
63283 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
63284 assert( iVar>0 );
63285 if( v ){
63286 Mem *pMem = &v->aVar[iVar-1];
63287 if( 0==(pMem->flags & MEM_Null) ){
63288 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
63895 /*
63896 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63897 ** the user-function defined by pCtx.
63898 */
63899 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63900 AuxData *pAuxData;
63901
63902 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63903 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63904 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
63905 }
63906
63907 return (pAuxData ? pAuxData->pAux : 0);
63908 }
63909
63910 /*
63911 ** Set the auxilary data pointer and delete function, for the iArg'th
63912 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
63916 sqlite3_context *pCtx,
63917 int iArg,
63918 void *pAux,
63919 void (*xDelete)(void*)
63920 ){
63921 AuxData *pAuxData;
63922 Vdbe *pVdbe = pCtx->pVdbe;
 
63923
63924 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63925 if( iArg<0 ) goto failed;
63926
63927 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63928 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63929 }
63930 if( pAuxData==0 ){
63931 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63932 if( !pAuxData ) goto failed;
63933 pAuxData->iOp = pCtx->iOp;
63934 pAuxData->iArg = iArg;
63935 pAuxData->pNext = pVdbe->pAuxData;
63936 pVdbe->pAuxData = pAuxData;
63937 }else if( pAuxData->xDelete ){
 
 
 
63938 pAuxData->xDelete(pAuxData->pAux);
63939 }
63940
63941 pAuxData->pAux = pAux;
63942 pAuxData->xDelete = xDelete;
63943 return;
63944
63945 failed:
@@ -65482,11 +65547,11 @@
65547 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65548 u8 encoding = ENC(db); /* The database encoding */
65549 int iCompare = 0; /* Result of last OP_Compare operation */
65550 unsigned nVmStep = 0; /* Number of virtual machine steps */
65551 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65552 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
65553 #endif
65554 Mem *aMem = p->aMem; /* Copy of p->aMem */
65555 Mem *pIn1 = 0; /* 1st input operand */
65556 Mem *pIn2 = 0; /* 2nd input operand */
65557 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
66006 assert( p->explain==0 );
66007 p->pResultSet = 0;
66008 db->busyHandler.nBusy = 0;
66009 CHECK_FOR_INTERRUPT;
66010 sqlite3VdbeIOTraceSql(p);
66011 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
66012 if( db->xProgress ){
66013 assert( 0 < db->nProgressOps );
66014 nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
66015 if( nProgressLimit==0 ){
66016 nProgressLimit = db->nProgressOps;
66017 }else{
66018 nProgressLimit %= (unsigned)db->nProgressOps;
66019 }
66020 }
66021 #endif
66022 #ifdef SQLITE_DEBUG
66023 sqlite3BeginBenignMalloc();
66024 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
66025 int i;
66026 printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
66177 ** of VDBE ops have been executed (either since this invocation of
66178 ** sqlite3VdbeExec() or since last time the progress callback was called).
66179 ** If the progress callback returns non-zero, exit the virtual machine with
66180 ** a return code SQLITE_ABORT.
66181 */
66182 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66183 int prc;
66184 prc = db->xProgress(db->pProgressArg);
66185 if( prc!=0 ){
66186 rc = SQLITE_INTERRUPT;
66187 goto vdbe_error_halt;
66188 }
66189 if( db->xProgress!=0 ){
66190 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66191 }
66192 }
66193 #endif
66194
66195 break;
66196 }
@@ -66794,23 +66872,18 @@
66872 Deephemeralize(u.ai.pArg);
66873 sqlite3VdbeMemStoreType(u.ai.pArg);
66874 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66875 }
66876
66877 assert( pOp->p4type==P4_FUNCDEF );
66878 u.ai.ctx.pFunc = pOp->p4.pFunc;
 
 
 
 
 
 
 
66879 u.ai.ctx.s.flags = MEM_Null;
66880 u.ai.ctx.s.db = db;
66881 u.ai.ctx.s.xDel = 0;
66882 u.ai.ctx.s.zMalloc = 0;
66883 u.ai.ctx.iOp = pc;
66884 u.ai.ctx.pVdbe = p;
66885
66886 /* The output cell may already have a buffer allocated. Move
66887 ** the pointer to u.ai.ctx.s so in case the user-function can use
66888 ** the already allocated buffer instead of allocating a new one.
66889 */
@@ -66829,15 +66902,11 @@
66902 lastRowid = db->lastRowid;
66903
66904 /* If any auxiliary data functions have been called by this user function,
66905 ** immediately call the destructor for any non-static values.
66906 */
66907 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
 
 
 
 
66908
66909 if( db->mallocFailed ){
66910 /* Even though a malloc() has failed, the implementation of the
66911 ** user function may have called an sqlite3_result_XXX() function
66912 ** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
74269 /* Translate the schema name in zDb into a pointer to the corresponding
74270 ** schema. If not found, pSchema will remain NULL and nothing will match
74271 ** resulting in an appropriate error message toward the end of this routine
74272 */
74273 if( zDb ){
74274 testcase( pNC->ncFlags & NC_PartIdx );
74275 testcase( pNC->ncFlags & NC_IsCheck );
74276 if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74277 /* Silently ignore database qualifiers inside CHECK constraints and partial
74278 ** indices. Do not raise errors because that might break legacy and
74279 ** because it does not hurt anything to just ignore the database name. */
74280 zDb = 0;
74281 }else{
74282 for(i=0; i<db->nDb; i++){
74283 assert( db->aDb[i].zName );
74284 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74285 pSchema = db->aDb[i].pSchema;
74286 break;
74287 }
74288 }
74289 }
74290 }
74291
74292 /* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
74559 }
74560 ExprSetProperty(p, EP_Resolved);
74561 }
74562 return p;
74563 }
74564
74565 /*
74566 ** Report an error that an expression is not valid for a partial index WHERE
74567 ** clause.
74568 */
74569 static void notValidPartIdxWhere(
74570 Parse *pParse, /* Leave error message here */
74571 NameContext *pNC, /* The name context */
74572 const char *zMsg /* Type of error */
74573 ){
74574 if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74575 sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74576 zMsg);
74577 }
74578 }
74579
74580 #ifndef SQLITE_OMIT_CHECK
74581 /*
74582 ** Report an error that an expression is not valid for a CHECK constraint.
74583 */
74584 static void notValidCheckConstraint(
74585 Parse *pParse, /* Leave error message here */
74586 NameContext *pNC, /* The name context */
74587 const char *zMsg /* Type of error */
74588 ){
74589 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74590 sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74591 }
74592 }
74593 #else
74594 # define notValidCheckConstraint(P,N,M)
74595 #endif
74596
74597
74598 /*
74599 ** This routine is callback for sqlite3WalkExpr().
74600 **
74601 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
74692 FuncDef *pDef; /* Information about the function */
74693 u8 enc = ENC(pParse->db); /* The database encoding */
74694
74695 testcase( pExpr->op==TK_CONST_FUNC );
74696 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74697 notValidPartIdxWhere(pParse, pNC, "functions");
74698 zId = pExpr->u.zToken;
74699 nId = sqlite3Strlen30(zId);
74700 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74701 if( pDef==0 ){
74702 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
74758 #endif
74759 case TK_IN: {
74760 testcase( pExpr->op==TK_IN );
74761 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74762 int nRef = pNC->nRef;
74763 notValidCheckConstraint(pParse, pNC, "subqueries");
74764 notValidPartIdxWhere(pParse, pNC, "subqueries");
 
 
 
74765 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74766 assert( pNC->nRef>=nRef );
74767 if( nRef!=pNC->nRef ){
74768 ExprSetProperty(pExpr, EP_VarSelect);
74769 }
74770 }
74771 break;
74772 }
 
74773 case TK_VARIABLE: {
74774 notValidCheckConstraint(pParse, pNC, "parameters");
74775 notValidPartIdxWhere(pParse, pNC, "parameters");
 
74776 break;
74777 }
 
74778 }
74779 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74780 }
74781
74782 /*
@@ -74757,11 +74863,11 @@
74863 /* Try to match the ORDER BY expression against an expression
74864 ** in the result set. Return an 1-based index of the matching
74865 ** result-set entry.
74866 */
74867 for(i=0; i<pEList->nExpr; i++){
74868 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
74869 return i+1;
74870 }
74871 }
74872
74873 /* If no match, return 0. */
@@ -74985,11 +75091,11 @@
75091 pItem->iOrderByCol = 0;
75092 if( sqlite3ResolveExprNames(pNC, pE) ){
75093 return 1;
75094 }
75095 for(j=0; j<pSelect->pEList->nExpr; j++){
75096 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
75097 pItem->iOrderByCol = j+1;
75098 }
75099 }
75100 }
75101 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
75397 w.xSelectCallback = resolveSelectStep;
75398 w.pParse = pParse;
75399 w.u.pNC = pOuterNC;
75400 sqlite3WalkSelect(&w, p);
75401 }
75402
75403 /*
75404 ** Resolve names in expressions that can only reference a single table:
75405 **
75406 ** * CHECK constraints
75407 ** * WHERE clauses on partial indices
75408 **
75409 ** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75410 ** is set to -1 and the Expr.iColumn value is set to the column number.
75411 **
75412 ** Any errors cause an error message to be set in pParse.
75413 */
75414 SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75415 Parse *pParse, /* Parsing context */
75416 Table *pTab, /* The table being referenced */
75417 int type, /* NC_IsCheck or NC_PartIdx */
75418 Expr *pExpr, /* Expression to resolve. May be NULL. */
75419 ExprList *pList /* Expression list to resolve. May be NUL. */
75420 ){
75421 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75422 NameContext sNC; /* Name context for pParse->pNewTable */
75423 int i; /* Loop counter */
75424
75425 assert( type==NC_IsCheck || type==NC_PartIdx );
75426 memset(&sNC, 0, sizeof(sNC));
75427 memset(&sSrc, 0, sizeof(sSrc));
75428 sSrc.nSrc = 1;
75429 sSrc.a[0].zName = pTab->zName;
75430 sSrc.a[0].pTab = pTab;
75431 sSrc.a[0].iCursor = -1;
75432 sNC.pParse = pParse;
75433 sNC.pSrcList = &sSrc;
75434 sNC.ncFlags = type;
75435 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75436 if( pList ){
75437 for(i=0; i<pList->nExpr; i++){
75438 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75439 return;
75440 }
75441 }
75442 }
75443 }
75444
75445 /************** End of resolve.c *********************************************/
75446 /************** Begin file expr.c ********************************************/
75447 /*
75448 ** 2001 September 15
@@ -76987,14 +77135,13 @@
77135 #endif
77136
77137 switch( pExpr->op ){
77138 case TK_IN: {
77139 char affinity; /* Affinity of the LHS of the IN */
 
 
77140 int addr; /* Address of OP_OpenEphemeral instruction */
77141 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77142 KeyInfo *pKeyInfo = 0; /* Key information */
77143
77144 if( rMayHaveNull ){
77145 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
77146 }
77147
@@ -77014,13 +77161,11 @@
77161 ** is used.
77162 */
77163 pExpr->iTable = pParse->nTab++;
77164 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77165 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77166 pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
 
 
77167
77168 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77169 /* Case 1: expr IN (SELECT ...)
77170 **
77171 ** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
77178 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77179 dest.affSdst = (u8)affinity;
77180 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77181 pExpr->x.pSelect->iLimit = 0;
77182 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77183 sqlite3DbFree(pParse->db, pKeyInfo);
77184 return 0;
77185 }
77186 pEList = pExpr->x.pSelect->pEList;
77187 if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77188 pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77189 pEList->a[0].pExpr);
77190 }
77191 }else if( ALWAYS(pExpr->x.pList!=0) ){
77192 /* Case 2: expr IN (exprlist)
77193 **
@@ -77056,12 +77202,13 @@
77202 int r1, r2, r3;
77203
77204 if( !affinity ){
77205 affinity = SQLITE_AFF_NONE;
77206 }
77207 if( pKeyInfo ){
77208 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77209 }
77210
77211 /* Loop through each expression in <exprlist>. */
77212 r1 = sqlite3GetTempReg(pParse);
77213 r2 = sqlite3GetTempReg(pParse);
77214 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
77243 }
77244 }
77245 sqlite3ReleaseTempReg(pParse, r1);
77246 sqlite3ReleaseTempReg(pParse, r2);
77247 }
77248 if( pKeyInfo ){
77249 sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
77250 }
77251 break;
77252 }
77253
77254 case TK_EXISTS:
@@ -77657,19 +77804,24 @@
77804 break;
77805 }
77806 /* Otherwise, fall thru into the TK_COLUMN case */
77807 }
77808 case TK_COLUMN: {
77809 int iTab = pExpr->iTable;
77810 if( iTab<0 ){
77811 if( pParse->ckBase>0 ){
77812 /* Generating CHECK constraints or inserting into partial index */
77813 inReg = pExpr->iColumn + pParse->ckBase;
77814 break;
77815 }else{
77816 /* Deleting from a partial index */
77817 iTab = pParse->iPartIdxTab;
77818 }
77819 }
77820 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77821 pExpr->iColumn, iTab, target,
77822 pExpr->op2);
77823 break;
77824 }
77825 case TK_INTEGER: {
77826 codeInteger(pParse, pExpr, 0, target);
77827 break;
@@ -79088,10 +79240,16 @@
79240 ** Do a deep comparison of two expression trees. Return 0 if the two
79241 ** expressions are completely identical. Return 1 if they differ only
79242 ** by a COLLATE operator at the top level. Return 2 if there are differences
79243 ** other than the top-level COLLATE operator.
79244 **
79245 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79246 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79247 **
79248 ** The pA side might be using TK_REGISTER. If that is the case and pB is
79249 ** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79250 **
79251 ** Sometimes this routine will return 2 even if the two expressions
79252 ** really are equivalent. If we cannot prove that the expressions are
79253 ** identical, we return 2 just to be safe. So if this routine
79254 ** returns 2, then you do not really know for certain if the two
79255 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
79256 ** can be sure the expressions are the same. In the places where
79257 ** this routine is used, it does not hurt to get an extra 2 - that
79258 ** just might result in some slightly slower code. But returning
79259 ** an incorrect 0 or 1 could lead to a malfunction.
79260 */
79261 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
79262 if( pA==0||pB==0 ){
79263 return pB==pA ? 0 : 2;
79264 }
79265 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79266 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79267 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79268 return 2;
79269 }
79270 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79271 if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79272 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
79273 return 1;
79274 }
79275 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
79276 return 1;
79277 }
79278 return 2;
79279 }
79280 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79281 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79282 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79283 if( pA->iColumn!=pB->iColumn ) return 2;
79284 if( pA->iTable!=pB->iTable
79285 && pA->op!=TK_REGISTER
79286 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
79287 if( ExprHasProperty(pA, EP_IntValue) ){
79288 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79289 return 2;
79290 }
79291 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
79299
79300 /*
79301 ** Compare two ExprList objects. Return 0 if they are identical and
79302 ** non-zero if they differ in any way.
79303 **
79304 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79305 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79306 **
79307 ** This routine might return non-zero for equivalent ExprLists. The
79308 ** only consequence will be disabled optimizations. But this routine
79309 ** must never return 0 if the two ExprList objects are different, or
79310 ** a malfunction will result.
79311 **
79312 ** Two NULL pointers are considered to be the same. But a NULL pointer
79313 ** always differs from a non-NULL pointer.
79314 */
79315 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
79316 int i;
79317 if( pA==0 && pB==0 ) return 0;
79318 if( pA==0 || pB==0 ) return 1;
79319 if( pA->nExpr!=pB->nExpr ) return 1;
79320 for(i=0; i<pA->nExpr; i++){
79321 Expr *pExprA = pA->a[i].pExpr;
79322 Expr *pExprB = pB->a[i].pExpr;
79323 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79324 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79325 }
79326 return 0;
79327 }
79328
79329 /*
79330 ** Return true if we can prove the pE2 will always be true if pE1 is
79331 ** true. Return false if we cannot complete the proof or if pE2 might
79332 ** be false. Examples:
79333 **
79334 ** pE1: x==5 pE2: x==5 Result: true
79335 ** pE1: x>0 pE2: x==5 Result: false
79336 ** pE1: x=21 pE2: x=21 OR y=43 Result: true
79337 ** pE1: x!=123 pE2: x IS NOT NULL Result: true
79338 ** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79339 ** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79340 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79341 **
79342 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79343 ** Expr.iTable<0 then assume a table number given by iTab.
79344 **
79345 ** When in doubt, return false. Returning true might give a performance
79346 ** improvement. Returning false might cause a performance reduction, but
79347 ** it will always give the correct answer and is hence always safe.
79348 */
79349 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79350 if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79351 return 1;
79352 }
79353 if( pE2->op==TK_OR
79354 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79355 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79356 ){
79357 return 1;
79358 }
79359 if( pE2->op==TK_NOTNULL
79360 && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79361 && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79362 ){
79363 return 1;
79364 }
79365 return 0;
79366 }
79367
79368 /*
@@ -79340,11 +79543,11 @@
79543 /* Check to see if pExpr is a duplicate of another aggregate
79544 ** function that is already in the pAggInfo structure
79545 */
79546 struct AggInfo_func *pItem = pAggInfo->aFunc;
79547 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79548 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
79549 break;
79550 }
79551 }
79552 if( i>=pAggInfo->nFunc ){
79553 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
80960 int i; /* Loop counter */
80961 int topOfLoop; /* The top of the loop */
80962 int endOfLoop; /* The end of the loop */
80963 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80964 int iDb; /* Index of database containing pTab */
80965 u8 needTableCnt = 1; /* True to count the table */
80966 int regTabname = iMem++; /* Register containing table name */
80967 int regIdxname = iMem++; /* Register containing index name */
80968 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80969 #ifdef SQLITE_ENABLE_STAT3
80970 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
81020 KeyInfo *pKey;
81021 int addrIfNot = 0; /* address of OP_IfNot */
81022 int *aChngAddr; /* Array of jump instruction addresses */
81023
81024 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
81025 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
81026 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
81027 nCol = pIdx->nColumn;
81028 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
81029 if( aChngAddr==0 ) continue;
81030 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
81180 ** If K==0 then no entry is made into the sqlite_stat1 table.
81181 ** If K>0 then it is always the case the D>0 so division by zero
81182 ** is never possible.
81183 */
81184 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
81185 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
 
 
81186 for(i=0; i<nCol; i++){
81187 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
81188 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81189 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
81190 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
81191 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
81192 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
81193 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81194 }
81195 if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81196 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81197 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81198 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81199 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81200 if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81201 }
81202
81203 /* Create a single sqlite_stat1 entry containing NULL as the index
81204 ** name and the row count as the content.
81205 */
81206 if( pOnlyIdx==0 && needTableCnt ){
81207 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
81208 VdbeComment((v, "%s", pTab->zName));
81209 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
81210 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
81211 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81212 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81213 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81214 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81215 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81216 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81217 sqlite3VdbeJumpHere(v, jZeroRows);
81218 }
81219 if( pParse->nMem<regRec ) pParse->nMem = regRec;
 
 
 
81220 }
81221
81222
81223 /*
81224 ** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
81397 v = 0;
81398 while( (c=z[0])>='0' && c<='9' ){
81399 v = v*10 + c - '0';
81400 z++;
81401 }
81402 if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81403 if( v>0 ) pTable->nRowEst = v;
81404 if( pIndex==0 ) break;
81405 }
81406 pIndex->aiRowEst[i] = v;
81407 if( *z==' ' ) z++;
81408 if( strcmp(z, "unordered")==0 ){
81409 pIndex->bUnordered = 1;
81410 break;
@@ -82636,10 +82840,11 @@
82840 */
82841 static void freeIndex(sqlite3 *db, Index *p){
82842 #ifndef SQLITE_OMIT_ANALYZE
82843 sqlite3DeleteIndexSamples(db, p);
82844 #endif
82845 sqlite3ExprDelete(db, p->pPartIdxWhere);
82846 sqlite3DbFree(db, p->zColAff);
82847 sqlite3DbFree(db, p);
82848 }
82849
82850 /*
@@ -83479,11 +83684,12 @@
83684 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83685 "INTEGER PRIMARY KEY");
83686 #endif
83687 }else{
83688 Index *p;
83689 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83690 0, sortOrder, 0);
83691 if( p ){
83692 p->autoIndex = 2;
83693 }
83694 pList = 0;
83695 }
@@ -83774,30 +83980,11 @@
83980
83981 #ifndef SQLITE_OMIT_CHECK
83982 /* Resolve names in all CHECK constraint expressions.
83983 */
83984 if( p->pCheck ){
83985 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83986 }
83987 #endif /* !defined(SQLITE_OMIT_CHECK) */
83988
83989 /* If the db->init.busy is 1 it means we are reading the SQL off the
83990 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
84832 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84833 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84834 int addr1; /* Address of top of loop */
84835 int addr2; /* Address to jump to for next iteration */
84836 int tnum; /* Root page of index */
84837 int iPartIdxLabel; /* Jump to this label to skip a row */
84838 Vdbe *v; /* Generate code into this virtual machine */
84839 KeyInfo *pKey; /* KeyInfo for index */
84840 int regRecord; /* Register holding assemblied index record */
84841 sqlite3 *db = pParse->db; /* The database connection */
84842 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
84872 ** records into the sorter. */
84873 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84874 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84875 regRecord = sqlite3GetTempReg(pParse);
84876
84877 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
84878 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84879 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
84880 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84881 sqlite3VdbeJumpHere(v, addr1);
84882 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84883 if( pIndex->onError!=OE_None ){
84884 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
84925 Token *pName2, /* Second part of index name. May be NULL */
84926 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84927 ExprList *pList, /* A list of columns to be indexed */
84928 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84929 Token *pStart, /* The CREATE token that begins this statement */
84930 Expr *pPIWhere, /* WHERE clause for partial indices */
84931 int sortOrder, /* Sort order of primary key when pList==NULL */
84932 int ifNotExist /* Omit error if index already exists */
84933 ){
84934 Index *pRet = 0; /* Pointer to return */
84935 Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
84947 struct ExprList_item *pListItem; /* For looping over pList */
84948 int nCol;
84949 int nExtra = 0;
84950 char *zExtra;
84951
 
84952 assert( pParse->nErr==0 ); /* Never called with prior errors */
84953 if( db->mallocFailed || IN_DECLARE_VTAB ){
84954 goto exit_create_index;
84955 }
84956 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
84992 assert(0);
84993 }
84994 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84995 assert( db->mallocFailed==0 || pTab==0 );
84996 if( pTab==0 ) goto exit_create_index;
84997 if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84998 sqlite3ErrorMsg(pParse,
84999 "cannot create a TEMP index on non-TEMP table \"%s\"",
85000 pTab->zName);
85001 goto exit_create_index;
85002 }
85003 }else{
85004 assert( pName==0 );
85005 assert( pStart==0 );
85006 pTab = pParse->pNewTable;
85007 if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
85146 pIndex->nColumn = pList->nExpr;
85147 pIndex->onError = (u8)onError;
85148 pIndex->uniqNotNull = onError==OE_Abort;
85149 pIndex->autoIndex = (u8)(pName==0);
85150 pIndex->pSchema = db->aDb[iDb].pSchema;
85151 if( pPIWhere ){
85152 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85153 pIndex->pPartIdxWhere = pPIWhere;
85154 pPIWhere = 0;
85155 }
85156 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
85157
85158 /* Check to see if we should honor DESC requests on index columns
85159 */
85160 if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
85306 ** If pTblName==0 it means this index is generated as a primary key
85307 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85308 ** has just been created, it contains no data and the index initialization
85309 ** step can be skipped.
85310 */
85311 else if( pParse->nErr==0 ){
85312 Vdbe *v;
85313 char *zStmt;
85314 int iMem = ++pParse->nMem;
85315
85316 v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
85324
85325 /* Gather the complete text of the CREATE INDEX statement into
85326 ** the zStmt variable
85327 */
85328 if( pStart ){
85329 int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85330 if( pName->z[n-1]==';' ) n--;
85331 /* A named index with an explicit CREATE INDEX statement */
85332 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85333 onError==OE_None ? "" : " UNIQUE", n, pName->z);
 
 
85334 }else{
85335 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85336 /* zStmt = sqlite3MPrintf(""); */
85337 zStmt = 0;
85338 }
@@ -85187,14 +85384,12 @@
85384 pIndex = 0;
85385 }
85386
85387 /* Clean up before exiting */
85388 exit_create_index:
85389 if( pIndex ) freeIndex(db, pIndex);
85390 sqlite3ExprDelete(db, pPIWhere);
 
 
85391 sqlite3ExprListDelete(db, pList);
85392 sqlite3SrcListDelete(db, pTblName);
85393 sqlite3DbFree(db, zName);
85394 return pRet;
85395 }
@@ -86068,29 +86263,24 @@
86263 ** the error.
86264 */
86265 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86266 int i;
86267 int nCol = pIdx->nColumn;
86268 KeyInfo *pKey;
86269
86270 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86271 if( pKey ){
 
 
 
 
86272 for(i=0; i<nCol; i++){
86273 char *zColl = pIdx->azColl[i];
86274 assert( zColl );
86275 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86276 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86277 }
 
86278 }
86279
86280 if( pParse->nErr ){
86281 sqlite3DbFree(pParse->db, pKey);
86282 pKey = 0;
86283 }
86284 return pKey;
86285 }
86286
@@ -87166,15 +87356,18 @@
87356 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87357 ){
87358 int i;
87359 Index *pIdx;
87360 int r1;
87361 int iPartIdxLabel;
87362 Vdbe *v = pParse->pVdbe;
87363
87364 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87365 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87366 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87367 sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87368 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
87369 }
87370 }
87371
87372 /*
87373 ** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
87377 **
87378 ** Return a register number which is the first in a block of
87379 ** registers that holds the elements of the index key. The
87380 ** block of registers has already been deallocated by the time
87381 ** this routine returns.
87382 **
87383 ** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87384 ** to that label if pIdx is a partial index that should be skipped.
87385 ** A partial index should be skipped if its WHERE clause evaluates
87386 ** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87387 ** will be set to zero which is an empty label that is ignored by
87388 ** sqlite3VdbeResolveLabel().
87389 */
87390 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87391 Parse *pParse, /* Parsing context */
87392 Index *pIdx, /* The index for which to generate a key */
87393 int iCur, /* Cursor number for the pIdx->pTable table */
87394 int regOut, /* Write the new index key to this register */
87395 int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87396 int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
87397 ){
87398 Vdbe *v = pParse->pVdbe;
87399 int j;
87400 Table *pTab = pIdx->pTable;
87401 int regBase;
87402 int nCol;
87403
87404 if( piPartIdxLabel ){
87405 if( pIdx->pPartIdxWhere ){
87406 *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87407 pParse->iPartIdxTab = iCur;
87408 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87409 SQLITE_JUMPIFNULL);
87410 }else{
87411 *piPartIdxLabel = 0;
87412 }
87413 }
87414 nCol = pIdx->nColumn;
87415 regBase = sqlite3GetTempRange(pParse, nCol+1);
87416 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87417 for(j=0; j<nCol; j++){
87418 int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
91772 ** Add the new records to the indices as we go.
91773 */
91774 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91775 int regIdx;
91776 int regR;
91777 int addrSkipRow = 0;
91778
91779 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91780
91781 if( pIdx->pPartIdxWhere ){
91782 sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91783 addrSkipRow = sqlite3VdbeMakeLabel(v);
91784 pParse->ckBase = regData;
91785 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91786 SQLITE_JUMPIFNULL);
91787 pParse->ckBase = 0;
91788 }
91789
91790 /* Create a key for accessing the index entry */
91791 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91792 for(i=0; i<pIdx->nColumn; i++){
91793 int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
91804
91805 /* Find out what action to take in case there is an indexing conflict */
91806 onError = pIdx->onError;
91807 if( onError==OE_None ){
91808 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91809 sqlite3VdbeResolveLabel(v, addrSkipRow);
91810 continue; /* pIdx is not a UNIQUE index */
91811 }
91812 if( overrideError!=OE_Default ){
91813 onError = overrideError;
91814 }else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
91874 seenReplace = 1;
91875 break;
91876 }
91877 }
91878 sqlite3VdbeJumpHere(v, j3);
91879 sqlite3VdbeResolveLabel(v, addrSkipRow);
91880 sqlite3ReleaseTempReg(pParse, regR);
91881 }
91882
91883 if( pbMayReplace ){
91884 *pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
91904 int appendBias, /* True if this is likely to be an append */
91905 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91906 ){
91907 int i;
91908 Vdbe *v;
 
91909 Index *pIdx;
91910 u8 pik_flags;
91911 int regData;
91912 int regRec;
91913
91914 v = sqlite3GetVdbe(pParse);
91915 assert( v!=0 );
91916 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91917 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
 
91918 if( aRegIdx[i]==0 ) continue;
91919 if( pIdx->pPartIdxWhere ){
91920 sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91921 }
91922 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91923 if( useSeekResult ){
91924 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91925 }
91926 }
@@ -91794,10 +92018,11 @@
92018 **
92019 ** * The index is over the same set of columns
92020 ** * The same DESC and ASC markings occurs on all columns
92021 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
92022 ** * The same collating sequence on each column
92023 ** * The index has the exact same WHERE clause
92024 */
92025 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
92026 int i;
92027 assert( pDest && pSrc );
92028 assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
92040 return 0; /* Different sort orders */
92041 }
92042 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
92043 return 0; /* Different collating sequences */
92044 }
92045 }
92046 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
92047 return 0; /* Different WHERE clauses */
92048 }
92049
92050 /* If no test above fails then the indices must be compatible */
92051 return 1;
92052 }
@@ -91971,11 +92199,11 @@
92199 if( pSrcIdx==0 ){
92200 return 0; /* pDestIdx has no corresponding index in pSrc */
92201 }
92202 }
92203 #ifndef SQLITE_OMIT_CHECK
92204 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
92205 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
92206 }
92207 #endif
92208 #ifndef SQLITE_OMIT_FOREIGN_KEY
92209 /* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
95112 cnt++;
95113 }
95114 }
95115
95116 /* Make sure sufficient number of registers have been allocated */
95117 pParse->nMem = MAX( pParse->nMem, cnt+7 );
 
 
95118
95119 /* Do the b-tree integrity checks */
95120 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
95121 sqlite3VdbeChangeP5(v, (u8)i);
95122 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
95137
95138 if( pTab->pIndex==0 ) continue;
95139 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
95140 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95141 sqlite3VdbeJumpHere(v, addr);
95142 sqlite3ExprCacheClear(pParse);
95143 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
95144 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95145 sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95146 }
95147 pParse->nMem = MAX(pParse->nMem, 7+j);
95148 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
95149 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95150 int jmp2, jmp3;
95151 int r1;
95152 static const VdbeOpList idxErr[] = {
95153 { OP_AddImm, 1, -1, 0},
95154 { OP_String8, 0, 3, 0}, /* 1 */
95155 { OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
95160 { OP_Concat, 6, 3, 3},
95161 { OP_ResultRow, 3, 1, 0},
95162 { OP_IfPos, 1, 0, 0}, /* 9 */
95163 { OP_Halt, 0, 0, 0},
95164 };
95165 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95166 sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
95167 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
95168 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
95169 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
95170 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
95171 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
95172 sqlite3VdbeJumpHere(v, addr+9);
95173 sqlite3VdbeJumpHere(v, jmp2);
95174 sqlite3VdbeResolveLabel(v, jmp3);
95175 }
95176 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95177 sqlite3VdbeJumpHere(v, loopTop-1);
95178 #ifndef SQLITE_OMIT_BTREECOUNT
95179 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95180 "wrong # of entries in index ", P4_STATIC);
95181 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95182 addr = sqlite3VdbeCurrentAddr(v);
95183 sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
 
 
 
 
 
 
 
 
 
 
 
95184 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95185 sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95186 sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95187 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95188 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95189 sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95190 sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95191 }
95192 #endif /* SQLITE_OMIT_BTREECOUNT */
 
 
 
95193 }
95194 }
95195 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
95196 sqlite3VdbeChangeP2(v, addr, -mxErr);
95197 sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
97214 */
97215 if( pOrderBy==0 && p->iLimit ){
97216 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
97217 }
97218 }
97219
97220 /*
97221 ** Allocate a KeyInfo object sufficient for an index of N columns.
97222 **
97223 ** Actually, always allocate one extra column for the rowid at the end
97224 ** of the index. So the KeyInfo returned will have space sufficient for
97225 ** N+1 columns.
97226 */
97227 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97228 KeyInfo *p = sqlite3DbMallocZero(db,
97229 sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97230 if( p ){
97231 p->aSortOrder = (u8*)&p->aColl[N+1];
97232 p->nField = (u16)N;
97233 p->enc = ENC(db);
97234 p->db = db;
97235 }
97236 return p;
97237 }
97238
97239 /*
97240 ** Given an expression list, generate a KeyInfo structure that records
97241 ** the collating sequence for each expression in that expression list.
97242 **
@@ -97011,29 +97250,23 @@
97250 ** function is responsible for seeing that this structure is eventually
97251 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97252 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97253 */
97254 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
 
97255 int nExpr;
97256 KeyInfo *pInfo;
97257 struct ExprList_item *pItem;
97258 sqlite3 *db = pParse->db;
97259 int i;
97260
97261 nExpr = pList->nExpr;
97262 pInfo = sqlite3KeyInfoAlloc(db, nExpr);
97263 if( pInfo ){
 
 
 
 
97264 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97265 CollSeq *pColl;
97266 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97267 if( !pColl ) pColl = db->pDfltColl;
 
 
97268 pInfo->aColl[i] = pColl;
97269 pInfo->aSortOrder[i] = pItem->sortOrder;
97270 }
97271 }
97272 return pInfo;
@@ -98135,27 +98368,21 @@
98368 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98369 int nCol; /* Number of columns in result set */
98370
98371 assert( p->pRightmost==p );
98372 nCol = p->pEList->nExpr;
98373 pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
 
98374 if( !pKeyInfo ){
98375 rc = SQLITE_NOMEM;
98376 goto multi_select_end;
98377 }
 
 
 
 
98378 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98379 *apColl = multiSelectCollSeq(pParse, p, i);
98380 if( 0==*apColl ){
98381 *apColl = db->pDfltColl;
98382 }
98383 }
 
98384
98385 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98386 for(i=0; i<2; i++){
98387 int addr = pLoop->addrOpenEphm[i];
98388 if( addr<0 ){
@@ -98520,16 +98747,12 @@
98747 struct ExprList_item *pItem;
98748 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98749 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98750 aPermute[i] = pItem->iOrderByCol - 1;
98751 }
98752 pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
 
98753 if( pKeyMerge ){
 
 
 
98754 for(i=0; i<nOrderBy; i++){
98755 CollSeq *pColl;
98756 Expr *pTerm = pOrderBy->a[i].pExpr;
98757 if( pTerm->flags & EP_Collate ){
98758 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
98785 int nExpr = p->pEList->nExpr;
98786 assert( nOrderBy>=nExpr || db->mallocFailed );
98787 regPrev = pParse->nMem+1;
98788 pParse->nMem += nExpr+1;
98789 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98790 pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
 
98791 if( pKeyDup ){
 
 
 
98792 for(i=0; i<nExpr; i++){
98793 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98794 pKeyDup->aSortOrder[i] = 0;
98795 }
98796 }
@@ -99833,14 +100052,16 @@
100052 ** and/or pParse->db->mallocFailed.
100053 */
100054 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
100055 Walker w;
100056 memset(&w, 0, sizeof(w));
 
100057 w.xExprCallback = exprWalkNoop;
100058 w.pParse = pParse;
100059 if( pParse->hasCompound ){
100060 w.xSelectCallback = convertCompoundSelectToSubquery;
100061 sqlite3WalkSelect(&w, pSelect);
100062 }
100063 w.xSelectCallback = selectExpander;
100064 sqlite3WalkSelect(&w, pSelect);
100065 }
100066
100067
@@ -100370,11 +100591,11 @@
100591 ** will cause elements to come out in the correct order. This is
100592 ** an optimization - the correct answer should result regardless.
100593 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100594 ** to disable this optimization for testing purposes.
100595 */
100596 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100597 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100598 pOrderBy = 0;
100599 }
100600
100601 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100612 ** used for both the ORDER BY and DISTINCT processing. As originally
100613 ** written the query must use a temp-table for at least one of the ORDER
100614 ** BY and DISTINCT, and an index or separate temp-table for the other.
100615 */
100616 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100617 && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100618 ){
100619 p->selFlags &= ~SF_Distinct;
100620 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100621 pGroupBy = p->pGroupBy;
100622 pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102839 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102840 if( aRegIdx==0 ) goto update_cleanup;
102841 }
102842 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102843 int reg;
102844 if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102845 reg = ++pParse->nMem;
102846 }else{
102847 reg = 0;
102848 for(i=0; i<pIdx->nColumn; i++){
102849 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105379 ** the pWC->a[] array.
105380 */
105381 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105382 WhereTerm *pTerm;
105383 int idx;
105384 testcase( wtFlags & TERM_VIRTUAL );
105385 if( pWC->nTerm>=pWC->nSlot ){
105386 WhereTerm *pOld = pWC->a;
105387 sqlite3 *db = pWC->pWInfo->pParse->db;
105388 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105389 if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105524
105525 /*
105526 ** Return TRUE if the given operator is one of the operators that is
105527 ** allowed for an indexable WHERE clause term. The allowed operators are
105528 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
 
 
 
 
 
 
 
105529 */
105530 static int allowedOp(int op){
105531 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105532 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105533 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105842 op = pRight->op2;
105843 }
105844 if( op==TK_VARIABLE ){
105845 Vdbe *pReprepare = pParse->pReprepare;
105846 int iCol = pRight->iColumn;
105847 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105848 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105849 z = (char *)sqlite3_value_text(pVal);
105850 }
105851 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105852 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
106197 }
106198
106199 /* At this point, okToChngToIN is true if original pTerm satisfies
106200 ** case 1. In that case, construct a new virtual term that is
106201 ** pTerm converted into an IN operator.
 
 
106202 */
106203 if( okToChngToIN ){
106204 Expr *pDup; /* A transient duplicate expression */
106205 ExprList *pList = 0; /* The RHS of the IN operator */
106206 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106438 ** wildcard. But if we increment '@', that will push it into the
106439 ** alphabetic range where case conversions will mess up the
106440 ** inequality. To avoid this, make sure to also run the full
106441 ** LIKE on all candidate expressions by clearing the isComplete flag
106442 */
106443 if( c=='A'-1 ) isComplete = 0;
 
 
106444 c = sqlite3UpperToLower[c];
106445 }
106446 *pC = c + 1;
106447 }
106448 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106945 VdbeComment((v, "for %s", pTable->zName));
106946
106947 /* Fill the automatic index with content */
106948 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106949 regRecord = sqlite3GetTempReg(pParse);
106950 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106951 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106952 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106953 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106954 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106955 sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107302 if( pExpr->op==TK_VARIABLE
107303 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107304 ){
107305 int iVar = pExpr->iColumn;
107306 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107307 *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107308 return SQLITE_OK;
107309 }
107310 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107311 }
107312 #endif
@@ -107318,13 +107528,10 @@
107528 **
107529 ** The t2.z='ok' is disabled in the in (2) because it originates
107530 ** in the ON clause. The term is disabled in (3) because it is not part
107531 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107532 **
 
 
 
107533 ** Disabling a term causes that term to not be tested in the inner loop
107534 ** of the join. Disabling is an optimization. When terms are satisfied
107535 ** by indices, we disable them to prevent redundant tests in the inner
107536 ** loop. We would get the correct results if nothing were ever disabled,
107537 ** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107757 pTerm = pLoop->aLTerm[j];
107758 assert( pTerm!=0 );
107759 /* The following true for indices with redundant columns.
107760 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107761 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107762 testcase( pTerm->wtFlags & TERM_VIRTUAL );
107763 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107764 if( r1!=regBase+j ){
107765 if( nReg==1 ){
107766 sqlite3ReleaseTempReg(pParse, regBase);
107767 regBase = r1;
@@ -107750,10 +107957,11 @@
107957 WhereLevel *pLevel; /* The where level to be coded */
107958 WhereLoop *pLoop; /* The WhereLoop object being coded */
107959 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107960 WhereTerm *pTerm; /* A WHERE clause term */
107961 Parse *pParse; /* Parsing context */
107962 sqlite3 *db; /* Database connection */
107963 Vdbe *v; /* The prepared stmt under constructions */
107964 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107965 int addrBrk; /* Jump here to break out of the loop */
107966 int addrCont; /* Jump here to continue with next cycle */
107967 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107969 Bitmask newNotReady; /* Return value */
107970
107971 pParse = pWInfo->pParse;
107972 v = pParse->pVdbe;
107973 pWC = &pWInfo->sWC;
107974 db = pParse->db;
107975 pLevel = &pWInfo->a[iLevel];
107976 pLoop = pLevel->pWLoop;
107977 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107978 iCur = pTabItem->iCursor;
107979 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
108068 iReleaseReg = sqlite3GetTempReg(pParse);
108069 pTerm = pLoop->aLTerm[0];
108070 assert( pTerm!=0 );
108071 assert( pTerm->pExpr!=0 );
108072 assert( omitTable==0 );
108073 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108074 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
108075 addrNxt = pLevel->addrNxt;
108076 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
108077 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
108078 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
108116 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
108117 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
108118 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
108119
108120 assert( (pStart->wtFlags & TERM_VNULL)==0 );
108121 testcase( pStart->wtFlags & TERM_VIRTUAL );
108122 pX = pStart->pExpr;
108123 assert( pX!=0 );
108124 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
108125 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
108126 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
108135 Expr *pX;
108136 pX = pEnd->pExpr;
108137 assert( pX!=0 );
108138 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
108139 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
108140 testcase( pEnd->wtFlags & TERM_VIRTUAL );
108141 memEndValue = ++pParse->nMem;
108142 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
108143 if( pX->op==TK_LT || pX->op==TK_GT ){
108144 testOp = bRev ? OP_Le : OP_Ge;
108145 }else{
@@ -108051,11 +108260,11 @@
108260 /* Generate code to evaluate all constraint terms using == or IN
108261 ** and store the values of those terms in an array of registers
108262 ** starting at regBase.
108263 */
108264 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108265 zEndAff = sqlite3DbStrDup(db, zStartAff);
108266 addrNxt = pLevel->addrNxt;
108267
108268 /* If we are doing a reverse order scan on an ascending index, or
108269 ** a forward order scan on a descending index, interchange the
108270 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108301 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108302 zStartAff[nEq] = SQLITE_AFF_NONE;
108303 }
108304 }
108305 nConstraint++;
108306 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108307 }else if( isMinQuery ){
108308 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108309 nConstraint++;
108310 startEq = 0;
108311 start_constraints = 1;
@@ -108134,14 +108343,14 @@
108343 zEndAff[nEq] = SQLITE_AFF_NONE;
108344 }
108345 }
108346 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108347 nConstraint++;
108348 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108349 }
108350 sqlite3DbFree(db, zStartAff);
108351 sqlite3DbFree(db, zEndAff);
108352
108353 /* Top of the loop body */
108354 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108355
108356 /* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108473 */
108474 if( pWInfo->nLevel>1 ){
108475 int nNotReady; /* The number of notReady tables */
108476 struct SrcList_item *origSrc; /* Original list of tables */
108477 nNotReady = pWInfo->nLevel - iLevel - 1;
108478 pOrTab = sqlite3StackAllocRaw(db,
108479 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108480 if( pOrTab==0 ) return notReady;
108481 pOrTab->nAlloc = (u8)(nNotReady + 1);
108482 pOrTab->nSrc = pOrTab->nAlloc;
108483 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108527 Expr *pExpr = pWC->a[iTerm].pExpr;
108528 if( &pWC->a[iTerm] == pTerm ) continue;
108529 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108530 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108531 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108532 pExpr = sqlite3ExprDup(db, pExpr, 0);
108533 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108534 }
108535 if( pAndExpr ){
108536 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108537 }
108538 }
@@ -108339,11 +108548,11 @@
108548 }
108549 /* Loop through table entries that match term pOrTerm. */
108550 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108551 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108552 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108553 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108554 if( pSubWInfo ){
108555 WhereLoop *pSubLoop;
108556 explainOneScan(
108557 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108558 );
@@ -108394,17 +108603,17 @@
108603 }
108604 pLevel->u.pCovidx = pCov;
108605 if( pCov ) pLevel->iIdxCur = iCovCur;
108606 if( pAndExpr ){
108607 pAndExpr->pLeft = 0;
108608 sqlite3ExprDelete(db, pAndExpr);
108609 }
108610 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108611 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108612 sqlite3VdbeResolveLabel(v, iLoopBody);
108613
108614 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108615 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108616 }else
108617 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108618
108619 {
@@ -108421,18 +108630,14 @@
108630 }
108631 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108632
108633 /* Insert code to test every subexpression that can be completely
108634 ** computed using the current set of tables.
 
 
 
 
108635 */
108636 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108637 Expr *pE;
108638 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108639 testcase( pTerm->wtFlags & TERM_CODED );
108640 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108641 if( (pTerm->prereqAll & newNotReady)!=0 ){
108642 testcase( pWInfo->untestedTerms==0
108643 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108660 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108661 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108662 ** the implied "t1.a=123" constraint.
108663 */
108664 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108665 Expr *pE, *pEAlt;
108666 WhereTerm *pAlt;
 
108667 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108668 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108669 if( pTerm->leftCursor!=iCur ) continue;
108670 if( pLevel->iLeftJoin ) continue;
108671 pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108675 if( pAlt==0 ) continue;
108676 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108677 testcase( pAlt->eOperator & WO_EQ );
108678 testcase( pAlt->eOperator & WO_IN );
108679 VdbeNoopComment((v, "begin transitive constraint"));
108680 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108681 if( pEAlt ){
108682 *pEAlt = *pAlt->pExpr;
108683 pEAlt->pLeft = pE->pLeft;
108684 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108685 sqlite3StackFree(db, pEAlt);
108686 }
108687 }
108688
108689 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108690 ** at least one row of the right table has matched the left table.
108691 */
@@ -108485,11 +108693,11 @@
108693 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108694 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108695 VdbeComment((v, "record LEFT JOIN hit"));
108696 sqlite3ExprCacheClear(pParse);
108697 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108698 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108699 testcase( pTerm->wtFlags & TERM_CODED );
108700 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108701 if( (pTerm->prereqAll & newNotReady)!=0 ){
108702 assert( pWInfo->untestedTerms );
108703 continue;
@@ -108926,11 +109134,12 @@
109134 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
109135 }else if( (pTerm->eOperator & WO_IN)
109136 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
109137 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
109138 }
109139 assert( nOut==0 || rc==SQLITE_OK );
109140 if( nOut ) pNew->nOut = whereCost(nOut);
109141 }
109142 #endif
109143 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
109144 /* Each row involves a step of the index, then a binary search of
109145 ** the main table */
@@ -108998,10 +109207,21 @@
109207 if( x<BMS-1 ) m |= MASKBIT(x);
109208 }
109209 return m;
109210 }
109211
109212 /* Check to see if a partial index with pPartIndexWhere can be used
109213 ** in the current query. Return true if it can be and false if not.
109214 */
109215 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109216 int i;
109217 WhereTerm *pTerm;
109218 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109219 if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109220 }
109221 return 0;
109222 }
109223
109224 /*
109225 ** Add all WhereLoop objects for a single table of the join where the table
109226 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109227 ** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109241 int rc = SQLITE_OK; /* Return code */
109242 int iSortIdx = 1; /* Index number */
109243 int b; /* A boolean value */
109244 WhereCost rSize; /* number of rows in the table */
109245 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109246 WhereClause *pWC; /* The parsed WHERE clause */
109247
109248 pNew = pBuilder->pNew;
109249 pWInfo = pBuilder->pWInfo;
109250 pTabList = pWInfo->pTabList;
109251 pSrc = pTabList->a + pNew->iTab;
109252 pWC = pBuilder->pWC;
109253 assert( !IsVirtual(pSrc->pTab) );
109254
109255 if( pSrc->pIndex ){
109256 /* An INDEXED BY clause specifies a particular index to use */
109257 pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109287 && !pSrc->viaCoroutine
109288 && !pSrc->notIndexed
109289 && !pSrc->isCorrelated
109290 ){
109291 /* Generate auto-index WhereLoops */
 
109292 WhereTerm *pTerm;
109293 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109294 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109295 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109296 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109316 }
109317
109318 /* Loop over all indices
109319 */
109320 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109321 if( pProbe->pPartIdxWhere!=0
109322 && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109323 continue; /* Partial index inappropriate for this query */
109324 }
109325 pNew->u.btree.nEq = 0;
109326 pNew->nLTerm = 0;
109327 pNew->iSortIdx = 0;
109328 pNew->rSetup = 0;
109329 pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110260 pLoop->u.btree.nEq = 1;
110261 /* TUNING: Cost of a rowid lookup is 10 */
110262 pLoop->rRun = 33; /* 33==whereCost(10) */
110263 }else{
110264 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110265 if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
110266 for(j=0; j<pIdx->nColumn; j++){
110267 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110268 if( pTerm==0 ) break;
110269 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110270 pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110466 ** subexpression is separated by an AND operator.
110467 */
110468 initMaskSet(pMaskSet);
110469 whereClauseInit(&pWInfo->sWC, pWInfo);
110470 sqlite3ExprCodeConstants(pParse, pWhere);
110471 whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110472 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110473
110474 /* Special case: a WHERE clause that is constant. Evaluate the
110475 ** expression and either jump over all of the code or fall thru.
110476 */
@@ -110875,11 +111100,11 @@
111100 #endif
111101 #define sqlite3ParserARG_SDECL Parse *pParse;
111102 #define sqlite3ParserARG_PDECL ,Parse *pParse
111103 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
111104 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
111105 #define YYNSTATE 628
111106 #define YYNRULE 327
111107 #define YYFALLBACK 1
111108 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
111109 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
111110 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
111173 ** shifting non-terminals after a reduce.
111174 ** yy_default[] Default action for each state.
111175 */
111176 #define YY_ACTTAB_COUNT (1564)
111177 static const YYACTIONTYPE yy_action[] = {
111178 /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
111179 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
111180 /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111181 /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111182 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111183 /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111184 /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111185 /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
111186 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111187 /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111188 /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
111189 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
111190 /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
111191 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
111192 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111193 /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111194 /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111195 /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111196 /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111197 /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111198 /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111199 /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111200 /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111201 /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111202 /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111203 /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111204 /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111205 /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111206 /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111207 /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111208 /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111209 /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111210 /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111211 /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111212 /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111213 /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
111214 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111215 /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111216 /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111217 /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111218 /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111219 /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111220 /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111221 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
111222 /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111223 /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111224 /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111225 /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111226 /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111227 /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111228 /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111229 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111230 /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111231 /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111232 /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111233 /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111234 /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111235 /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111236 /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111237 /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111238 /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111239 /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111240 /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111241 /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111242 /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111243 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111244 /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111245 /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111246 /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111247 /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111248 /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111249 /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111250 /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111251 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111252 /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111253 /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111254 /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111255 /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111256 /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111257 /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111258 /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111259 /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111260 /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111261 /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111262 /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111263 /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111264 /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111265 /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111266 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111267 /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111268 /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111269 /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111270 /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111271 /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111272 /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111273 /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111274 /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111275 /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111276 /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111277 /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111278 /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111279 /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111280 /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111281 /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111282 /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111283 /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111284 /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111285 /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111286 /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111287 /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111288 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111289 /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111290 /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111291 /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111292 /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111293 /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111294 /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111295 /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111296 /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111297 /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111298 /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111299 /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111300 /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111301 /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111302 /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111303 /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111304 /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111305 /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111306 /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111307 /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111308 /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111309 /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111310 /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111311 /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111312 /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111313 /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111314 /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111315 /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111316 /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111317 /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111318 /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111319 /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111320 /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111321 /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111322 /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111323 /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111324 /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111325 /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111326 /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111327 /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111328 /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111329 /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111330 /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111331 /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111332 /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111333 /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111334 /* 1560 */ 400, 499, 523, 233,
111335 };
111336 static const YYCODETYPE yy_lookahead[] = {
111337 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111338 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111339 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111481 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111482 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111483 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111484 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111485 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111486 /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111487 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111488 /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111489 /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111490 /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111491 /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111492 /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111493 /* 1560 */ 191, 182, 173, 92,
111494 };
111495 #define YY_SHIFT_USE_DFLT (-70)
111496 #define YY_SHIFT_COUNT (417)
111497 #define YY_SHIFT_MIN (-69)
111498 #define YY_SHIFT_MAX (1487)
111499 static const short yy_shift_ofst[] = {
111500 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111501 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111508 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111509 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111510 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111511 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111512 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111513 /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111514 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111515 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111516 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111517 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111518 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111519 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111520 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111521 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111522 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111523 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111524 /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111525 /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111526 /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111527 /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111528 /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111529 /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111530 /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111531 /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111532 /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111533 /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111534 /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111535 /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111536 /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111537 /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111538 /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111539 /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111540 /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111541 /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111542 };
111543 #define YY_REDUCE_USE_DFLT (-169)
111544 #define YY_REDUCE_COUNT (309)
111545 #define YY_REDUCE_MIN (-168)
111546 #define YY_REDUCE_MAX (1397)
111547 static const short yy_reduce_ofst[] = {
111548 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111549 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111550 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111551 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111562 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111563 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111564 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111565 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111566 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111567 /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111568 /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111569 /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111570 /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111571 /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111572 /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111573 /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111574 /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111575 /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111576 /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111577 /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111578 /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111579 };
111580 static const YYACTIONTYPE yy_default[] = {
111581 /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111582 /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111583 /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111584 /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111585 /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111586 /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111587 /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111588 /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111589 /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111590 /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111591 /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111592 /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111593 /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111594 /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111595 /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111596 /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111597 /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111598 /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111599 /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111600 /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111601 /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111602 /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111603 /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111604 /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111605 /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111606 /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111607 /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111608 /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111609 /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111610 /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111611 /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111612 /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111613 /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111614 /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111615 /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111616 /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111617 /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111618 /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111619 /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111620 /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111621 /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111622 /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111623 /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111624 /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111625 /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111626 /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111627 /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111628 /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111629 /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111630 /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111631 /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111632 /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111633 /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111634 /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111635 /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111636 /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111637 /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111638 /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111639 /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111640 /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111641 /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111642 /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111643 /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111644 };
111645
111646 /* The next table maps tokens into fallback tokens. If a construct
111647 ** like the following:
111648 **
@@ -111885,11 +112110,11 @@
112110 /* 237 */ "case_operand ::=",
112111 /* 238 */ "exprlist ::= nexprlist",
112112 /* 239 */ "exprlist ::=",
112113 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
112114 /* 241 */ "nexprlist ::= expr",
112115 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
112116 /* 243 */ "uniqueflag ::= UNIQUE",
112117 /* 244 */ "uniqueflag ::=",
112118 /* 245 */ "idxlist_opt ::=",
112119 /* 246 */ "idxlist_opt ::= LP idxlist RP",
112120 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112829 { 224, 0 },
112830 { 220, 1 },
112831 { 220, 0 },
112832 { 215, 3 },
112833 { 215, 1 },
112834 { 147, 12 },
112835 { 227, 1 },
112836 { 227, 0 },
112837 { 178, 0 },
112838 { 178, 3 },
112839 { 187, 5 },
@@ -113046,10 +113271,11 @@
113271 case 114: /* select ::= select multiselect_op oneselect */
113272 {
113273 if( yymsp[0].minor.yy159 ){
113274 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113275 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113276 if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113277 }else{
113278 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113279 }
113280 yygotominor.yy159 = yymsp[0].minor.yy159;
113281 }
@@ -113608,15 +113834,15 @@
113834 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113835 break;
113836 case 241: /* nexprlist ::= expr */
113837 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113838 break;
113839 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113840 {
113841 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113842 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113843 &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113844 }
113845 break;
113846 case 243: /* uniqueflag ::= UNIQUE */
113847 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113848 {yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114764 *tokenType = TK_SPACE;
114765 return i;
114766 }
114767 case '-': {
114768 if( z[1]=='-' ){
 
114769 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114770 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114771 return i;
114772 }
114773 *tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114796 case '/': {
114797 if( z[1]!='*' || z[2]==0 ){
114798 *tokenType = TK_SLASH;
114799 return 1;
114800 }
 
114801 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114802 if( c ) i++;
114803 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114804 return i;
114805 }
@@ -116416,10 +116640,11 @@
116640 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116641 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116642 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116643 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116644 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116645 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116646 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116647 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116648 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116649 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116650 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117996 db->autoCommit = 1;
117997 db->nextAutovac = -1;
117998 db->szMmap = sqlite3GlobalConfig.szMmap;
117999 db->nextPagesize = 0;
118000 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
118001 #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
118002 | SQLITE_AutoIndex
118003 #endif
118004 #if SQLITE_DEFAULT_FILE_FORMAT<4
118005 | SQLITE_LegacyFileFmt
118006 #endif
@@ -128244,11 +128469,11 @@
128469 }
128470
128471
128472 #ifdef SQLITE_TEST
128473
128474 #include <tcl.h>
128475 /* #include <string.h> */
128476
128477 /*
128478 ** Implementation of a special SQL scalar function for testing tokenizers
128479 ** designed to be used in concert with the Tcl testing framework. This
128480
+1221 -996
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403403
**
404
-** (Historical note: There used to be several other options, but we've
405
-** pared it down to just these three.)
406
-**
407404
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408405
** the default.
409406
*/
410407
#if defined(SQLITE_SYSTEM_MALLOC) \
411408
+ defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439436
*/
440437
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441438
# define _XOPEN_SOURCE 600
442439
#endif
443440
444
-/*
445
-** The TCL headers are only needed when compiling the TCL bindings.
446
-*/
447
-#if defined(SQLITE_TCL) || defined(TCLSH)
448
-# include <tcl.h>
449
-#endif
450
-
451441
/*
452442
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453443
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454444
** make it true by defining or undefining NDEBUG.
455445
**
456
-** Setting NDEBUG makes the code smaller and run faster by disabling the
457
-** number assert() statements in the code. So we want the default action
446
+** Setting NDEBUG makes the code smaller and faster by disabling the
447
+** assert() statements in the code. So we want the default action
458448
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459449
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460450
** feature.
461451
*/
462452
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522512
** hint of unplanned behavior.
523513
**
524514
** In other words, ALWAYS and NEVER are added for defensive code.
525515
**
526516
** When doing coverage testing ALWAYS and NEVER are hard-coded to
527
-** be true and false so that the unreachable code then specify will
517
+** be true and false so that the unreachable code they specify will
528518
** not be counted as untested code.
529519
*/
530520
#if defined(SQLITE_COVERAGE_TEST)
531521
# define ALWAYS(X) (1)
532522
# define NEVER(X) (0)
@@ -546,20 +536,16 @@
546536
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547537
548538
/*
549539
** The macro unlikely() is a hint that surrounds a boolean
550540
** expression that is usually false. Macro likely() surrounds
551
-** a boolean expression that is usually true. GCC is able to
552
-** use these hints to generate better code, sometimes.
541
+** a boolean expression that is usually true. These hints could,
542
+** in theory, be used by the compiler to generate better code, but
543
+** currently they are just comments for human readers.
553544
*/
554
-#if defined(__GNUC__) && 0
555
-# define likely(X) __builtin_expect((X),1)
556
-# define unlikely(X) __builtin_expect((X),0)
557
-#else
558
-# define likely(X) !!(X)
559
-# define unlikely(X) !!(X)
560
-#endif
545
+#define likely(X) (X)
546
+#define unlikely(X) (X)
561547
562548
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563549
/************** Begin file sqlite3.h *****************************************/
564550
/*
565551
** 2001 September 15
@@ -670,11 +656,11 @@
670656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671657
** [sqlite_version()] and [sqlite_source_id()].
672658
*/
673659
#define SQLITE_VERSION "3.8.0"
674660
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
661
+#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
676662
677663
/*
678664
** CAPI3REF: Run-Time Library Version Numbers
679665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680666
**
@@ -1039,10 +1025,11 @@
10391025
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10401026
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10411027
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10421028
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10431029
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10441031
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10451032
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10461033
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10471034
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10481035
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
31223109
** interface is to keep a GUI updated during a large query.
31233110
**
31243111
** ^The parameter P is passed through as the only parameter to the
31253112
** callback function X. ^The parameter N is the approximate number of
31263113
** [virtual machine instructions] that are evaluated between successive
3127
-** invocations of the callback X.
3114
+** invocations of the callback X. ^If N is less than one then the progress
3115
+** handler is disabled.
31283116
**
31293117
** ^Only a single progress handler may be defined at one time per
31303118
** [database connection]; setting a new progress handler cancels the
31313119
** old one. ^Setting parameter X to NULL disables the progress handler.
31323120
** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
47424730
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
47434731
47444732
/*
47454733
** CAPI3REF: Function Auxiliary Data
47464734
**
4747
-** The following two functions may be used by scalar SQL functions to
4735
+** These functions may be used by (non-aggregate) SQL functions to
47484736
** associate metadata with argument values. If the same value is passed to
47494737
** multiple invocations of the same SQL function during query execution, under
4750
-** some circumstances the associated metadata may be preserved. This might
4751
-** be used, for example, in a regular-expression matching
4752
-** function. The compiled version of the regular expression is stored as
4753
-** metadata associated with the SQL value passed as the regular expression
4754
-** pattern. The compiled regular expression can be reused on multiple
4755
-** invocations of the same function so that the original pattern string
4756
-** does not need to be recompiled on each invocation.
4738
+** some circumstances the associated metadata may be preserved. An example
4739
+** of where this might be useful is in a regular-expression matching
4740
+** function. The compiled version of the regular expression can be stored as
4741
+** metadata associated with the pattern string.
4742
+** Then as long as the pattern string remains the same,
4743
+** the compiled regular expression can be reused on multiple
4744
+** invocations of the same function.
47574745
**
47584746
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
47594747
** associated by the sqlite3_set_auxdata() function with the Nth argument
4760
-** value to the application-defined function. ^If no metadata has been ever
4761
-** been set for the Nth argument of the function, or if the corresponding
4762
-** function parameter has changed since the meta-data was set,
4763
-** then sqlite3_get_auxdata() returns a NULL pointer.
4748
+** value to the application-defined function. ^If there is no metadata
4749
+** associated with the function argument, this sqlite3_get_auxdata() interface
4750
+** returns a NULL pointer.
47644751
**
47654752
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
47664753
** argument of the application-defined function. ^Subsequent
47674754
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768
-** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769
-** NULL if the data has been dropped.
4770
-** ^(If it is not NULL, SQLite will invoke the destructor
4771
-** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772
-** <li> the corresponding function parameter changes,
4773
-** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774
-** SQL statement,
4775
-** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776
-** <li> a memory allocation error occurs. </ul>)^
4755
+** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756
+** NULL if the metadata has been discarded.
4757
+** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758
+** SQLite will invoke the destructor function X with parameter P exactly
4759
+** once, when the metadata is discarded.
4760
+** SQLite is free to discard the metadata at any time, including: <ul>
4761
+** <li> when the corresponding function parameter changes, or
4762
+** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763
+** SQL statement, or
4764
+** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765
+** <li> during the original sqlite3_set_auxdata() call when a memory
4766
+** allocation error occurs. </ul>)^
47774767
**
4778
-** SQLite is free to call the destructor and drop metadata on any
4779
-** parameter of any function at any time. ^The only guarantee is that
4780
-** the destructor will be called when the [prepared statement] is destroyed.
4781
-** Note in particular that the destructor X in the call to
4782
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783
-** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4768
+** Note the last bullet in particular. The destructor X in
4769
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770
+** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
47844771
** should be called near the end of the function implementation and the
4785
-** implementation should not make any use of P after sqlite3_set_auxdata()
4786
-** has been called.
4772
+** function implementation should not make any use of P after
4773
+** sqlite3_set_auxdata() has been called.
47874774
**
47884775
** ^(In practice, metadata is preserved between function calls for
47894776
** function parameters that are compile-time constants, including literal
47904777
** values and [parameters] and expressions composed from the same.)^
47914778
**
@@ -6829,13 +6816,13 @@
68296816
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
68306817
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
68316818
** </dd>
68326819
**
68336820
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6834
-** <dd>This parameter returns the zero for the current value if and only if
6835
-** there all foreign key constraints (deferred or immediate) have been
6836
-** resolved. The highwater mark is always 0.
6821
+** <dd>This parameter returns zero for the current value if and only if
6822
+** all foreign key constraints (deferred or immediate) have been
6823
+** resolved.)^ ^The highwater mark is always 0.
68376824
** </dd>
68386825
** </dl>
68396826
*/
68406827
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
68416828
#define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
88248811
88258812
/*
88268813
** The names of the following types declared in vdbeInt.h are required
88278814
** for the VdbeOp definition.
88288815
*/
8829
-typedef struct VdbeFunc VdbeFunc;
88308816
typedef struct Mem Mem;
88318817
typedef struct SubProgram SubProgram;
88328818
88338819
/*
88348820
** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
88488834
void *p; /* Generic pointer */
88498835
char *z; /* Pointer to data for string (char array) types */
88508836
i64 *pI64; /* Used when p4type is P4_INT64 */
88518837
double *pReal; /* Used when p4type is P4_REAL */
88528838
FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853
- VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
88548839
CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
88558840
Mem *pMem; /* Used when p4type is P4_MEM */
88568841
VTable *pVtab; /* Used when p4type is P4_VTAB */
88578842
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
88588843
int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
89028887
#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
89038888
#define P4_STATIC (-2) /* Pointer to a static string */
89048889
#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
89058890
#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
89068891
#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907
-#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
89088892
#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
89098893
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
89108894
#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
89118895
#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
89128896
#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
89598943
*/
89608944
/************** Include opcodes.h in the middle of vdbe.h ********************/
89618945
/************** Begin file opcodes.h *****************************************/
89628946
/* Automatically generated. Do not edit */
89638947
/* See the mkopcodeh.awk script for details */
8964
-#define OP_Goto 1
8965
-#define OP_Gosub 2
8966
-#define OP_Return 3
8967
-#define OP_Yield 4
8968
-#define OP_HaltIfNull 5
8969
-#define OP_Halt 6
8970
-#define OP_Integer 7
8971
-#define OP_Int64 8
8972
-#define OP_Real 130 /* same as TK_FLOAT */
8973
-#define OP_String8 94 /* same as TK_STRING */
8974
-#define OP_String 9
8975
-#define OP_Null 10
8976
-#define OP_Blob 11
8977
-#define OP_Variable 12
8978
-#define OP_Move 13
8979
-#define OP_Copy 14
8980
-#define OP_SCopy 15
8981
-#define OP_ResultRow 16
8982
-#define OP_Concat 91 /* same as TK_CONCAT */
8948
+#define OP_Function 1
8949
+#define OP_Savepoint 2
8950
+#define OP_AutoCommit 3
8951
+#define OP_Transaction 4
8952
+#define OP_SorterNext 5
8953
+#define OP_Prev 6
8954
+#define OP_Next 7
8955
+#define OP_AggStep 8
8956
+#define OP_Checkpoint 9
8957
+#define OP_JournalMode 10
8958
+#define OP_Vacuum 11
8959
+#define OP_VFilter 12
8960
+#define OP_VUpdate 13
8961
+#define OP_Goto 14
8962
+#define OP_Gosub 15
8963
+#define OP_Return 16
8964
+#define OP_Yield 17
8965
+#define OP_HaltIfNull 18
8966
+#define OP_Not 19 /* same as TK_NOT */
8967
+#define OP_Halt 20
8968
+#define OP_Integer 21
8969
+#define OP_Int64 22
8970
+#define OP_String 23
8971
+#define OP_Null 24
8972
+#define OP_Blob 25
8973
+#define OP_Variable 26
8974
+#define OP_Move 27
8975
+#define OP_Copy 28
8976
+#define OP_SCopy 29
8977
+#define OP_ResultRow 30
8978
+#define OP_CollSeq 31
8979
+#define OP_AddImm 32
8980
+#define OP_MustBeInt 33
8981
+#define OP_RealAffinity 34
8982
+#define OP_Permutation 35
8983
+#define OP_Compare 36
8984
+#define OP_Jump 37
8985
+#define OP_Once 38
8986
+#define OP_If 39
8987
+#define OP_IfNot 40
8988
+#define OP_Column 41
8989
+#define OP_Affinity 42
8990
+#define OP_MakeRecord 43
8991
+#define OP_Count 44
8992
+#define OP_ReadCookie 45
8993
+#define OP_SetCookie 46
8994
+#define OP_VerifyCookie 47
8995
+#define OP_OpenRead 48
8996
+#define OP_OpenWrite 49
8997
+#define OP_OpenAutoindex 50
8998
+#define OP_OpenEphemeral 51
8999
+#define OP_SorterOpen 52
9000
+#define OP_OpenPseudo 53
9001
+#define OP_Close 54
9002
+#define OP_SeekLt 55
9003
+#define OP_SeekLe 56
9004
+#define OP_SeekGe 57
9005
+#define OP_SeekGt 58
9006
+#define OP_Seek 59
9007
+#define OP_NotFound 60
9008
+#define OP_Found 61
9009
+#define OP_IsUnique 62
9010
+#define OP_NotExists 63
9011
+#define OP_Sequence 64
9012
+#define OP_NewRowid 65
9013
+#define OP_Insert 66
9014
+#define OP_InsertInt 67
9015
+#define OP_Or 68 /* same as TK_OR */
9016
+#define OP_And 69 /* same as TK_AND */
9017
+#define OP_Delete 70
9018
+#define OP_ResetCount 71
9019
+#define OP_SorterCompare 72
9020
+#define OP_IsNull 73 /* same as TK_ISNULL */
9021
+#define OP_NotNull 74 /* same as TK_NOTNULL */
9022
+#define OP_Ne 75 /* same as TK_NE */
9023
+#define OP_Eq 76 /* same as TK_EQ */
9024
+#define OP_Gt 77 /* same as TK_GT */
9025
+#define OP_Le 78 /* same as TK_LE */
9026
+#define OP_Lt 79 /* same as TK_LT */
9027
+#define OP_Ge 80 /* same as TK_GE */
9028
+#define OP_SorterData 81
9029
+#define OP_BitAnd 82 /* same as TK_BITAND */
9030
+#define OP_BitOr 83 /* same as TK_BITOR */
9031
+#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032
+#define OP_ShiftRight 85 /* same as TK_RSHIFT */
89839033
#define OP_Add 86 /* same as TK_PLUS */
89849034
#define OP_Subtract 87 /* same as TK_MINUS */
89859035
#define OP_Multiply 88 /* same as TK_STAR */
89869036
#define OP_Divide 89 /* same as TK_SLASH */
89879037
#define OP_Remainder 90 /* same as TK_REM */
8988
-#define OP_CollSeq 17
8989
-#define OP_Function 18
8990
-#define OP_BitAnd 82 /* same as TK_BITAND */
8991
-#define OP_BitOr 83 /* same as TK_BITOR */
8992
-#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8993
-#define OP_ShiftRight 85 /* same as TK_RSHIFT */
8994
-#define OP_AddImm 20
8995
-#define OP_MustBeInt 21
8996
-#define OP_RealAffinity 22
9038
+#define OP_Concat 91 /* same as TK_CONCAT */
9039
+#define OP_RowKey 92
9040
+#define OP_BitNot 93 /* same as TK_BITNOT */
9041
+#define OP_String8 94 /* same as TK_STRING */
9042
+#define OP_RowData 95
9043
+#define OP_Rowid 96
9044
+#define OP_NullRow 97
9045
+#define OP_Last 98
9046
+#define OP_SorterSort 99
9047
+#define OP_Sort 100
9048
+#define OP_Rewind 101
9049
+#define OP_SorterInsert 102
9050
+#define OP_IdxInsert 103
9051
+#define OP_IdxDelete 104
9052
+#define OP_IdxRowid 105
9053
+#define OP_IdxLT 106
9054
+#define OP_IdxGE 107
9055
+#define OP_Destroy 108
9056
+#define OP_Clear 109
9057
+#define OP_CreateIndex 110
9058
+#define OP_CreateTable 111
9059
+#define OP_ParseSchema 112
9060
+#define OP_LoadAnalysis 113
9061
+#define OP_DropTable 114
9062
+#define OP_DropIndex 115
9063
+#define OP_DropTrigger 116
9064
+#define OP_IntegrityCk 117
9065
+#define OP_RowSetAdd 118
9066
+#define OP_RowSetRead 119
9067
+#define OP_RowSetTest 120
9068
+#define OP_Program 121
9069
+#define OP_Param 122
9070
+#define OP_FkCounter 123
9071
+#define OP_FkIfZero 124
9072
+#define OP_MemMax 125
9073
+#define OP_IfPos 126
9074
+#define OP_IfNeg 127
9075
+#define OP_IfZero 128
9076
+#define OP_AggFinal 129
9077
+#define OP_Real 130 /* same as TK_FLOAT */
9078
+#define OP_IncrVacuum 131
9079
+#define OP_Expire 132
9080
+#define OP_TableLock 133
9081
+#define OP_VBegin 134
9082
+#define OP_VCreate 135
9083
+#define OP_VDestroy 136
9084
+#define OP_VOpen 137
9085
+#define OP_VColumn 138
9086
+#define OP_VNext 139
9087
+#define OP_VRename 140
89979088
#define OP_ToText 141 /* same as TK_TO_TEXT */
89989089
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
89999090
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
90009091
#define OP_ToInt 144 /* same as TK_TO_INT */
90019092
#define OP_ToReal 145 /* same as TK_TO_REAL */
9002
-#define OP_Eq 76 /* same as TK_EQ */
9003
-#define OP_Ne 75 /* same as TK_NE */
9004
-#define OP_Lt 79 /* same as TK_LT */
9005
-#define OP_Le 78 /* same as TK_LE */
9006
-#define OP_Gt 77 /* same as TK_GT */
9007
-#define OP_Ge 80 /* same as TK_GE */
9008
-#define OP_Permutation 23
9009
-#define OP_Compare 24
9010
-#define OP_Jump 25
9011
-#define OP_And 69 /* same as TK_AND */
9012
-#define OP_Or 68 /* same as TK_OR */
9013
-#define OP_Not 19 /* same as TK_NOT */
9014
-#define OP_BitNot 93 /* same as TK_BITNOT */
9015
-#define OP_Once 26
9016
-#define OP_If 27
9017
-#define OP_IfNot 28
9018
-#define OP_IsNull 73 /* same as TK_ISNULL */
9019
-#define OP_NotNull 74 /* same as TK_NOTNULL */
9020
-#define OP_Column 29
9021
-#define OP_Affinity 30
9022
-#define OP_MakeRecord 31
9023
-#define OP_Count 32
9024
-#define OP_Savepoint 33
9025
-#define OP_AutoCommit 34
9026
-#define OP_Transaction 35
9027
-#define OP_ReadCookie 36
9028
-#define OP_SetCookie 37
9029
-#define OP_VerifyCookie 38
9030
-#define OP_OpenRead 39
9031
-#define OP_OpenWrite 40
9032
-#define OP_OpenAutoindex 41
9033
-#define OP_OpenEphemeral 42
9034
-#define OP_SorterOpen 43
9035
-#define OP_OpenPseudo 44
9036
-#define OP_Close 45
9037
-#define OP_SeekLt 46
9038
-#define OP_SeekLe 47
9039
-#define OP_SeekGe 48
9040
-#define OP_SeekGt 49
9041
-#define OP_Seek 50
9042
-#define OP_NotFound 51
9043
-#define OP_Found 52
9044
-#define OP_IsUnique 53
9045
-#define OP_NotExists 54
9046
-#define OP_Sequence 55
9047
-#define OP_NewRowid 56
9048
-#define OP_Insert 57
9049
-#define OP_InsertInt 58
9050
-#define OP_Delete 59
9051
-#define OP_ResetCount 60
9052
-#define OP_SorterCompare 61
9053
-#define OP_SorterData 62
9054
-#define OP_RowKey 63
9055
-#define OP_RowData 64
9056
-#define OP_Rowid 65
9057
-#define OP_NullRow 66
9058
-#define OP_Last 67
9059
-#define OP_SorterSort 70
9060
-#define OP_Sort 71
9061
-#define OP_Rewind 72
9062
-#define OP_SorterNext 81
9063
-#define OP_Prev 92
9064
-#define OP_Next 95
9065
-#define OP_SorterInsert 96
9066
-#define OP_IdxInsert 97
9067
-#define OP_IdxDelete 98
9068
-#define OP_IdxRowid 99
9069
-#define OP_IdxLT 100
9070
-#define OP_IdxGE 101
9071
-#define OP_Destroy 102
9072
-#define OP_Clear 103
9073
-#define OP_CreateIndex 104
9074
-#define OP_CreateTable 105
9075
-#define OP_ParseSchema 106
9076
-#define OP_LoadAnalysis 107
9077
-#define OP_DropTable 108
9078
-#define OP_DropIndex 109
9079
-#define OP_DropTrigger 110
9080
-#define OP_IntegrityCk 111
9081
-#define OP_RowSetAdd 112
9082
-#define OP_RowSetRead 113
9083
-#define OP_RowSetTest 114
9084
-#define OP_Program 115
9085
-#define OP_Param 116
9086
-#define OP_FkCounter 117
9087
-#define OP_FkIfZero 118
9088
-#define OP_MemMax 119
9089
-#define OP_IfPos 120
9090
-#define OP_IfNeg 121
9091
-#define OP_IfZero 122
9092
-#define OP_AggStep 123
9093
-#define OP_AggFinal 124
9094
-#define OP_Checkpoint 125
9095
-#define OP_JournalMode 126
9096
-#define OP_Vacuum 127
9097
-#define OP_IncrVacuum 128
9098
-#define OP_Expire 129
9099
-#define OP_TableLock 131
9100
-#define OP_VBegin 132
9101
-#define OP_VCreate 133
9102
-#define OP_VDestroy 134
9103
-#define OP_VOpen 135
9104
-#define OP_VFilter 136
9105
-#define OP_VColumn 137
9106
-#define OP_VNext 138
9107
-#define OP_VRename 139
9108
-#define OP_VUpdate 140
91099093
#define OP_Pagecount 146
91109094
#define OP_MaxPgcnt 147
91119095
#define OP_Trace 148
91129096
#define OP_Noop 149
91139097
#define OP_Explain 150
@@ -9123,28 +9107,28 @@
91239107
#define OPFLG_IN2 0x0008 /* in2: P2 is an input */
91249108
#define OPFLG_IN3 0x0010 /* in3: P3 is an input */
91259109
#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
91269110
#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
91279111
#define OPFLG_INITIALIZER {\
9128
-/* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9129
-/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9130
-/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9131
-/* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9132
-/* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9133
-/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9134
-/* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9135
-/* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9136
-/* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9137
-/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9138
-/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9139
-/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9140
-/* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9141
-/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9142
-/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9143
-/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9144
-/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9145
-/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9112
+/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113
+/* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114
+/* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115
+/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116
+/* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117
+/* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118
+/* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119
+/* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120
+/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121
+/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122
+/* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123
+/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124
+/* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125
+/* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126
+/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127
+/* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128
+/* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129
+/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
91469130
/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
91479131
91489132
/************** End of opcodes.h *********************************************/
91499133
/************** Continuing where we left off in vdbe.h ***********************/
91509134
@@ -9190,11 +9174,11 @@
91909174
SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
91919175
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
91929176
SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
91939177
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
91949178
SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9195
-SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
9179
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
91969180
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
91979181
#ifndef SQLITE_OMIT_TRACE
91989182
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
91999183
#endif
92009184
@@ -10688,16 +10672,20 @@
1068810672
1068910673
/*
1069010674
** An instance of the following structure is passed as the first
1069110675
** argument to sqlite3VdbeKeyCompare and is used to control the
1069210676
** comparison of the two index keys.
10677
+**
10678
+** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679
+** are nField slots for the columns of an index then one extra slot
10680
+** for the rowid at the end.
1069310681
*/
1069410682
struct KeyInfo {
1069510683
sqlite3 *db; /* The database connection */
1069610684
u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10697
- u16 nField; /* Number of entries in aColl[] */
10698
- u8 *aSortOrder; /* Sort order for each column. May be NULL */
10685
+ u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686
+ u8 *aSortOrder; /* Sort order for each column. */
1069910687
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
1070010688
};
1070110689
1070210690
/*
1070310691
** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
1076210750
char *zColAff; /* String defining the affinity of each column */
1076310751
Index *pNext; /* The next index associated with the same table */
1076410752
Schema *pSchema; /* Schema containing this index */
1076510753
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
1076610754
char **azColl; /* Array of collation sequence names for index */
10755
+ Expr *pPartIdxWhere; /* WHERE clause for partial indices */
1076710756
int tnum; /* DB Page containing root of this index */
1076810757
u16 nColumn; /* Number of columns in table used by this index */
1076910758
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
1077010759
unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
1077110760
unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
1124211231
#define NC_HasAgg 0x02 /* One or more aggregate functions seen */
1124311232
#define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
1124411233
#define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
1124511234
#define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
1124611235
** if no other resolution is available */
11236
+#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
1124711237
1124811238
/*
1124911239
** An instance of the following structure contains all information
1125011240
** needed to generate code for a single SELECT statement.
1125111241
**
@@ -11296,10 +11286,11 @@
1129611286
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
1129711287
#define SF_UseSorter 0x0040 /* Sort using a sorter */
1129811288
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
1129911289
#define SF_Materialize 0x0100 /* Force materialization of views */
1130011290
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291
+#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
1130111292
1130211293
1130311294
/*
1130411295
** The results of a select can be distributed in several ways. The
1130511296
** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
1141711408
u8 nTempInUse; /* Number of aTempReg[] currently checked out */
1141811409
u8 nColCache; /* Number of entries in aColCache[] */
1141911410
u8 iColCache; /* Next entry in aColCache[] to replace */
1142011411
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
1142111412
u8 mayAbort; /* True if statement may throw an ABORT exception */
11413
+ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
1142211414
int aTempReg[8]; /* Holding area for temporary registers */
1142311415
int nRangeReg; /* Size of the temporary register block */
1142411416
int iRangeReg; /* First register in temporary register block */
1142511417
int nErr; /* Number of errors seen */
1142611418
int nTab; /* Number of previously allocated VDBE cursors */
1142711419
int nMem; /* Number of memory cells used so far */
1142811420
int nSet; /* Number of sets used so far */
1142911421
int nOnce; /* Number of OP_Once instructions so far */
1143011422
int ckBase; /* Base register of data during check constraints */
11423
+ int iPartIdxTab; /* Table corresponding to a partial index */
1143111424
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
1143211425
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
1143311426
struct yColCache {
1143411427
int iTable; /* Table cursor number */
1143511428
int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
1200712000
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
1200812001
SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
1200912002
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
1201012003
SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
1201112004
SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12012
- Token*, int, int);
12005
+ Expr*, int, int);
1201312006
SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
1201412007
SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
1201512008
SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
1201612009
Expr*,ExprList*,u16,Expr*,Expr*);
1201712010
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
1205512048
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
1205612049
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1205712050
SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
1205812051
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
1205912052
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12060
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
12061
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
12053
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12054
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12055
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1206212056
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1206312057
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1206412058
SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
1206512059
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
1206612060
SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
1208312077
SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
1208412078
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
1208512079
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
1208612080
SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
1208712081
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12088
-SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
12082
+SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
1208912083
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
1209012084
int*,int,int,int,int,int*);
1209112085
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
1209212086
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
1209312087
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
1228612280
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
1228712281
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1228812282
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
1228912283
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
1229012284
SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12285
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
1229112286
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
1229212287
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
1229312288
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
1229412289
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
1229512290
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
1230512300
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
1230612301
SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
1230712302
SQLITE_PRIVATE void sqlite3SchemaClear(void *);
1230812303
SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
1230912304
SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
1231012306
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
1231112307
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
1231212308
void (*)(sqlite3_context*,int,sqlite3_value **),
1231312309
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
1231412310
FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
1325713253
typedef struct VdbeSorter VdbeSorter;
1325813254
1325913255
/* Opaque type used by the explainer */
1326013256
typedef struct Explain Explain;
1326113257
13258
+/* Elements of the linked list at Vdbe.pAuxData */
13259
+typedef struct AuxData AuxData;
13260
+
1326213261
/*
1326313262
** A cursor is a pointer into a single BTree within a database file.
1326413263
** The cursor can seek to a BTree entry with a particular key, or
1326513264
** loop over all entries of the Btree. You can also insert new BTree
1326613265
** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
1344313442
*/
1344413443
#ifdef SQLITE_DEBUG
1344513444
#define memIsValid(M) ((M)->flags & MEM_Invalid)==0
1344613445
#endif
1344713446
13448
-
13449
-/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450
-** additional information about auxiliary information bound to arguments
13451
-** of the function. This is used to implement the sqlite3_get_auxdata()
13452
-** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453
-** that can be associated with a constant argument to a function. This
13454
-** allows functions such as "regexp" to compile their constant regular
13455
-** expression argument once and reused the compiled code for multiple
13456
-** invocations.
13447
+/*
13448
+** Each auxilliary data pointer stored by a user defined function
13449
+** implementation calling sqlite3_set_auxdata() is stored in an instance
13450
+** of this structure. All such structures associated with a single VM
13451
+** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13452
+** when the VM is halted (if not before).
1345713453
*/
13458
-struct VdbeFunc {
13459
- FuncDef *pFunc; /* The definition of the function */
13460
- int nAux; /* Number of entries allocated for apAux[] */
13461
- struct AuxData {
13462
- void *pAux; /* Aux data for the i-th argument */
13463
- void (*xDelete)(void *); /* Destructor for the aux data */
13464
- } apAux[1]; /* One slot for each function argument */
13454
+struct AuxData {
13455
+ int iOp; /* Instruction number of OP_Function opcode */
13456
+ int iArg; /* Index of function argument. */
13457
+ void *pAux; /* Aux data pointer */
13458
+ void (*xDelete)(void *); /* Destructor for the aux data */
13459
+ AuxData *pNext; /* Next element in list */
1346513460
};
1346613461
1346713462
/*
1346813463
** The "context" argument for a installable function. A pointer to an
1346913464
** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
1347713472
** This structure is defined inside of vdbeInt.h because it uses substructures
1347813473
** (Mem) which are only defined there.
1347913474
*/
1348013475
struct sqlite3_context {
1348113476
FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482
- VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
1348313477
Mem s; /* The return value is stored here */
1348413478
Mem *pMem; /* Memory cell used to store aggregate context */
1348513479
CollSeq *pColl; /* Collating sequence */
1348613480
int isError; /* Error code returned by the function. */
1348713481
int skipFlag; /* Skip skip accumulator loading if true */
13482
+ int iOp; /* Instruction number of OP_Function */
13483
+ Vdbe *pVdbe; /* The VM that owns this context */
1348813484
};
1348913485
1349013486
/*
1349113487
** An Explain object accumulates indented output which is helpful
1349213488
** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
1358113577
int nFrame; /* Number of frames in pFrame list */
1358213578
u32 expmask; /* Binding to these vars invalidates VM */
1358313579
SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
1358413580
int nOnceFlag; /* Size of array aOnceFlag[] */
1358513581
u8 *aOnceFlag; /* Flags for OP_Once */
13582
+ AuxData *pAuxData; /* Linked list of auxdata allocations */
1358613583
};
1358713584
1358813585
/*
1358913586
** The following are allowed values for Vdbe.magic
1359013587
*/
@@ -13604,11 +13601,11 @@
1360413601
#endif
1360513602
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
1360613603
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
1360713604
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
1360813605
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13606
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
1361013607
1361113608
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
1361213609
SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
1361313610
SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
1361413611
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
2270322700
/* Automatically generated. Do not edit */
2270422701
/* See the mkopcodec.awk script for details. */
2270522702
#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
2270622703
SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
2270722704
static const char *const azName[] = { "?",
22708
- /* 1 */ "Goto",
22709
- /* 2 */ "Gosub",
22710
- /* 3 */ "Return",
22711
- /* 4 */ "Yield",
22712
- /* 5 */ "HaltIfNull",
22713
- /* 6 */ "Halt",
22714
- /* 7 */ "Integer",
22715
- /* 8 */ "Int64",
22716
- /* 9 */ "String",
22717
- /* 10 */ "Null",
22718
- /* 11 */ "Blob",
22719
- /* 12 */ "Variable",
22720
- /* 13 */ "Move",
22721
- /* 14 */ "Copy",
22722
- /* 15 */ "SCopy",
22723
- /* 16 */ "ResultRow",
22724
- /* 17 */ "CollSeq",
22725
- /* 18 */ "Function",
22705
+ /* 1 */ "Function",
22706
+ /* 2 */ "Savepoint",
22707
+ /* 3 */ "AutoCommit",
22708
+ /* 4 */ "Transaction",
22709
+ /* 5 */ "SorterNext",
22710
+ /* 6 */ "Prev",
22711
+ /* 7 */ "Next",
22712
+ /* 8 */ "AggStep",
22713
+ /* 9 */ "Checkpoint",
22714
+ /* 10 */ "JournalMode",
22715
+ /* 11 */ "Vacuum",
22716
+ /* 12 */ "VFilter",
22717
+ /* 13 */ "VUpdate",
22718
+ /* 14 */ "Goto",
22719
+ /* 15 */ "Gosub",
22720
+ /* 16 */ "Return",
22721
+ /* 17 */ "Yield",
22722
+ /* 18 */ "HaltIfNull",
2272622723
/* 19 */ "Not",
22727
- /* 20 */ "AddImm",
22728
- /* 21 */ "MustBeInt",
22729
- /* 22 */ "RealAffinity",
22730
- /* 23 */ "Permutation",
22731
- /* 24 */ "Compare",
22732
- /* 25 */ "Jump",
22733
- /* 26 */ "Once",
22734
- /* 27 */ "If",
22735
- /* 28 */ "IfNot",
22736
- /* 29 */ "Column",
22737
- /* 30 */ "Affinity",
22738
- /* 31 */ "MakeRecord",
22739
- /* 32 */ "Count",
22740
- /* 33 */ "Savepoint",
22741
- /* 34 */ "AutoCommit",
22742
- /* 35 */ "Transaction",
22743
- /* 36 */ "ReadCookie",
22744
- /* 37 */ "SetCookie",
22745
- /* 38 */ "VerifyCookie",
22746
- /* 39 */ "OpenRead",
22747
- /* 40 */ "OpenWrite",
22748
- /* 41 */ "OpenAutoindex",
22749
- /* 42 */ "OpenEphemeral",
22750
- /* 43 */ "SorterOpen",
22751
- /* 44 */ "OpenPseudo",
22752
- /* 45 */ "Close",
22753
- /* 46 */ "SeekLt",
22754
- /* 47 */ "SeekLe",
22755
- /* 48 */ "SeekGe",
22756
- /* 49 */ "SeekGt",
22757
- /* 50 */ "Seek",
22758
- /* 51 */ "NotFound",
22759
- /* 52 */ "Found",
22760
- /* 53 */ "IsUnique",
22761
- /* 54 */ "NotExists",
22762
- /* 55 */ "Sequence",
22763
- /* 56 */ "NewRowid",
22764
- /* 57 */ "Insert",
22765
- /* 58 */ "InsertInt",
22766
- /* 59 */ "Delete",
22767
- /* 60 */ "ResetCount",
22768
- /* 61 */ "SorterCompare",
22769
- /* 62 */ "SorterData",
22770
- /* 63 */ "RowKey",
22771
- /* 64 */ "RowData",
22772
- /* 65 */ "Rowid",
22773
- /* 66 */ "NullRow",
22774
- /* 67 */ "Last",
22724
+ /* 20 */ "Halt",
22725
+ /* 21 */ "Integer",
22726
+ /* 22 */ "Int64",
22727
+ /* 23 */ "String",
22728
+ /* 24 */ "Null",
22729
+ /* 25 */ "Blob",
22730
+ /* 26 */ "Variable",
22731
+ /* 27 */ "Move",
22732
+ /* 28 */ "Copy",
22733
+ /* 29 */ "SCopy",
22734
+ /* 30 */ "ResultRow",
22735
+ /* 31 */ "CollSeq",
22736
+ /* 32 */ "AddImm",
22737
+ /* 33 */ "MustBeInt",
22738
+ /* 34 */ "RealAffinity",
22739
+ /* 35 */ "Permutation",
22740
+ /* 36 */ "Compare",
22741
+ /* 37 */ "Jump",
22742
+ /* 38 */ "Once",
22743
+ /* 39 */ "If",
22744
+ /* 40 */ "IfNot",
22745
+ /* 41 */ "Column",
22746
+ /* 42 */ "Affinity",
22747
+ /* 43 */ "MakeRecord",
22748
+ /* 44 */ "Count",
22749
+ /* 45 */ "ReadCookie",
22750
+ /* 46 */ "SetCookie",
22751
+ /* 47 */ "VerifyCookie",
22752
+ /* 48 */ "OpenRead",
22753
+ /* 49 */ "OpenWrite",
22754
+ /* 50 */ "OpenAutoindex",
22755
+ /* 51 */ "OpenEphemeral",
22756
+ /* 52 */ "SorterOpen",
22757
+ /* 53 */ "OpenPseudo",
22758
+ /* 54 */ "Close",
22759
+ /* 55 */ "SeekLt",
22760
+ /* 56 */ "SeekLe",
22761
+ /* 57 */ "SeekGe",
22762
+ /* 58 */ "SeekGt",
22763
+ /* 59 */ "Seek",
22764
+ /* 60 */ "NotFound",
22765
+ /* 61 */ "Found",
22766
+ /* 62 */ "IsUnique",
22767
+ /* 63 */ "NotExists",
22768
+ /* 64 */ "Sequence",
22769
+ /* 65 */ "NewRowid",
22770
+ /* 66 */ "Insert",
22771
+ /* 67 */ "InsertInt",
2277522772
/* 68 */ "Or",
2277622773
/* 69 */ "And",
22777
- /* 70 */ "SorterSort",
22778
- /* 71 */ "Sort",
22779
- /* 72 */ "Rewind",
22774
+ /* 70 */ "Delete",
22775
+ /* 71 */ "ResetCount",
22776
+ /* 72 */ "SorterCompare",
2278022777
/* 73 */ "IsNull",
2278122778
/* 74 */ "NotNull",
2278222779
/* 75 */ "Ne",
2278322780
/* 76 */ "Eq",
2278422781
/* 77 */ "Gt",
2278522782
/* 78 */ "Le",
2278622783
/* 79 */ "Lt",
2278722784
/* 80 */ "Ge",
22788
- /* 81 */ "SorterNext",
22785
+ /* 81 */ "SorterData",
2278922786
/* 82 */ "BitAnd",
2279022787
/* 83 */ "BitOr",
2279122788
/* 84 */ "ShiftLeft",
2279222789
/* 85 */ "ShiftRight",
2279322790
/* 86 */ "Add",
@@ -22794,59 +22791,59 @@
2279422791
/* 87 */ "Subtract",
2279522792
/* 88 */ "Multiply",
2279622793
/* 89 */ "Divide",
2279722794
/* 90 */ "Remainder",
2279822795
/* 91 */ "Concat",
22799
- /* 92 */ "Prev",
22796
+ /* 92 */ "RowKey",
2280022797
/* 93 */ "BitNot",
2280122798
/* 94 */ "String8",
22802
- /* 95 */ "Next",
22803
- /* 96 */ "SorterInsert",
22804
- /* 97 */ "IdxInsert",
22805
- /* 98 */ "IdxDelete",
22806
- /* 99 */ "IdxRowid",
22807
- /* 100 */ "IdxLT",
22808
- /* 101 */ "IdxGE",
22809
- /* 102 */ "Destroy",
22810
- /* 103 */ "Clear",
22811
- /* 104 */ "CreateIndex",
22812
- /* 105 */ "CreateTable",
22813
- /* 106 */ "ParseSchema",
22814
- /* 107 */ "LoadAnalysis",
22815
- /* 108 */ "DropTable",
22816
- /* 109 */ "DropIndex",
22817
- /* 110 */ "DropTrigger",
22818
- /* 111 */ "IntegrityCk",
22819
- /* 112 */ "RowSetAdd",
22820
- /* 113 */ "RowSetRead",
22821
- /* 114 */ "RowSetTest",
22822
- /* 115 */ "Program",
22823
- /* 116 */ "Param",
22824
- /* 117 */ "FkCounter",
22825
- /* 118 */ "FkIfZero",
22826
- /* 119 */ "MemMax",
22827
- /* 120 */ "IfPos",
22828
- /* 121 */ "IfNeg",
22829
- /* 122 */ "IfZero",
22830
- /* 123 */ "AggStep",
22831
- /* 124 */ "AggFinal",
22832
- /* 125 */ "Checkpoint",
22833
- /* 126 */ "JournalMode",
22834
- /* 127 */ "Vacuum",
22835
- /* 128 */ "IncrVacuum",
22836
- /* 129 */ "Expire",
22799
+ /* 95 */ "RowData",
22800
+ /* 96 */ "Rowid",
22801
+ /* 97 */ "NullRow",
22802
+ /* 98 */ "Last",
22803
+ /* 99 */ "SorterSort",
22804
+ /* 100 */ "Sort",
22805
+ /* 101 */ "Rewind",
22806
+ /* 102 */ "SorterInsert",
22807
+ /* 103 */ "IdxInsert",
22808
+ /* 104 */ "IdxDelete",
22809
+ /* 105 */ "IdxRowid",
22810
+ /* 106 */ "IdxLT",
22811
+ /* 107 */ "IdxGE",
22812
+ /* 108 */ "Destroy",
22813
+ /* 109 */ "Clear",
22814
+ /* 110 */ "CreateIndex",
22815
+ /* 111 */ "CreateTable",
22816
+ /* 112 */ "ParseSchema",
22817
+ /* 113 */ "LoadAnalysis",
22818
+ /* 114 */ "DropTable",
22819
+ /* 115 */ "DropIndex",
22820
+ /* 116 */ "DropTrigger",
22821
+ /* 117 */ "IntegrityCk",
22822
+ /* 118 */ "RowSetAdd",
22823
+ /* 119 */ "RowSetRead",
22824
+ /* 120 */ "RowSetTest",
22825
+ /* 121 */ "Program",
22826
+ /* 122 */ "Param",
22827
+ /* 123 */ "FkCounter",
22828
+ /* 124 */ "FkIfZero",
22829
+ /* 125 */ "MemMax",
22830
+ /* 126 */ "IfPos",
22831
+ /* 127 */ "IfNeg",
22832
+ /* 128 */ "IfZero",
22833
+ /* 129 */ "AggFinal",
2283722834
/* 130 */ "Real",
22838
- /* 131 */ "TableLock",
22839
- /* 132 */ "VBegin",
22840
- /* 133 */ "VCreate",
22841
- /* 134 */ "VDestroy",
22842
- /* 135 */ "VOpen",
22843
- /* 136 */ "VFilter",
22844
- /* 137 */ "VColumn",
22845
- /* 138 */ "VNext",
22846
- /* 139 */ "VRename",
22847
- /* 140 */ "VUpdate",
22835
+ /* 131 */ "IncrVacuum",
22836
+ /* 132 */ "Expire",
22837
+ /* 133 */ "TableLock",
22838
+ /* 134 */ "VBegin",
22839
+ /* 135 */ "VCreate",
22840
+ /* 136 */ "VDestroy",
22841
+ /* 137 */ "VOpen",
22842
+ /* 138 */ "VColumn",
22843
+ /* 139 */ "VNext",
22844
+ /* 140 */ "VRename",
2284822845
/* 141 */ "ToText",
2284922846
/* 142 */ "ToBlob",
2285022847
/* 143 */ "ToNumeric",
2285122848
/* 144 */ "ToInt",
2285222849
/* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
3049930496
*/
3050030497
#if SQLITE_OS_WIN /* This file is used for Windows only */
3050130498
3050230499
#ifdef __CYGWIN__
3050330500
# include <sys/cygwin.h>
30501
+/* # include <errno.h> */
3050430502
#endif
3050530503
3050630504
/*
3050730505
** Include code that is common to all os_*.c files
3050830506
*/
@@ -30727,19 +30725,19 @@
3072730725
3072830726
/*
3072930727
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
3073030728
** based on the sub-platform)?
3073130729
*/
30732
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30730
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
3073330731
# define SQLITE_WIN32_HAS_ANSI
3073430732
#endif
3073530733
3073630734
/*
3073730735
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
3073830736
** based on the sub-platform)?
3073930737
*/
30740
-#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT || defined(__CYGWIN__)
30738
+#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
3074130739
# define SQLITE_WIN32_HAS_WIDE
3074230740
#endif
3074330741
3074430742
/*
3074530743
** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
3091930917
* zero for the default behavior.
3092030918
*/
3092130919
#ifndef SQLITE_WIN32_HEAP_FLAGS
3092230920
# define SQLITE_WIN32_HEAP_FLAGS (0)
3092330921
#endif
30922
+
3092430923
3092530924
/*
3092630925
** The winMemData structure stores information required by the Win32-specific
3092730926
** sqlite3_mem_methods implementation.
3092830927
*/
@@ -31267,11 +31266,11 @@
3126731266
{ "GetTempPathA", (SYSCALL)0, 0 },
3126831267
#endif
3126931268
3127031269
#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
3127131270
31272
-#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
31271
+#if !SQLITE_OS_WINRT && !defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE)
3127331272
{ "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
3127431273
#else
3127531274
{ "GetTempPathW", (SYSCALL)0, 0 },
3127631275
#endif
3127731276
@@ -34384,14 +34383,14 @@
3438434383
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3438534384
osGetCurrentProcessId(), pFd));
3438634385
return SQLITE_OK;
3438734386
}
3438834387
assert( (nMap % winSysInfo.dwPageSize)==0 );
34389
-#if SQLITE_OS_WINRT
34390
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391
-#else
3439234388
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34389
+#if SQLITE_OS_WINRT
34390
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34391
+#else
3439334392
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3439434393
#endif
3439534394
if( pNew==NULL ){
3439634395
osCloseHandle(pFd->hMap);
3439734396
pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
3455634555
#endif
3455734556
/* caller will handle out of memory */
3455834557
return zConverted;
3455934558
}
3456034559
34560
+/*
34561
+** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34562
+** in characters, so we allocate 3 bytes per character assuming worst-case
34563
+** 3-bytes-per-character UTF8.
34564
+*/
34565
+#ifndef SQLITE_WIN32_MAX_PATH
34566
+# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34567
+#endif
34568
+
3456134569
static int winIsDir(const void *zConverted);
3456234570
3456334571
/*
3456434572
** Create a temporary file name in zBuf. zBuf must be big enough to
3456534573
** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
3456934577
"abcdefghijklmnopqrstuvwxyz"
3457034578
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457134579
"0123456789";
3457234580
size_t i, j;
3457334581
int nTempPath;
34574
- char zTempPath[MAX_PATH+2];
34582
+ char zTempPath[SQLITE_WIN32_MAX_PATH+2];
3457534583
3457634584
/* It's odd to simulate an io-error here, but really this is just
3457734585
** using the io-error infrastructure to test that SQLite handles this
3457834586
** function failing.
3457934587
*/
3458034588
SimulateIOError( return SQLITE_IOERR );
3458134589
34582
- memset(zTempPath, 0, MAX_PATH+2);
34583
-
3458434590
if( sqlite3_temp_directory ){
34585
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
34591
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34592
+ sqlite3_temp_directory);
3458634593
}
3458734594
#if defined(__CYGWIN__)
3458834595
else{
3458934596
static const char *azDirs[] = {
3459034597
0,
@@ -34621,42 +34628,64 @@
3462134628
if( winIsDir(zWidePath) ){
3462234629
break;
3462334630
}
3462434631
azDirs[i] = ""; /* Don't retry in future call */
3462534632
}
34626
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34633
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zDir);
3462734634
}
3462834635
#elif !SQLITE_OS_WINRT
3462934636
else if( isNT() ){
3463034637
char *zMulti;
3463134638
WCHAR zWidePath[MAX_PATH];
34632
- osGetTempPathW(MAX_PATH-30, zWidePath);
34639
+ if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34640
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34641
+ return SQLITE_IOERR_GETTEMPPATH;
34642
+ }
3463334643
zMulti = unicodeToUtf8(zWidePath);
3463434644
if( zMulti ){
34635
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34645
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
3463634646
sqlite3_free(zMulti);
3463734647
}else{
3463834648
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3463934649
return SQLITE_IOERR_NOMEM;
3464034650
}
3464134651
}
3464234652
#ifdef SQLITE_WIN32_HAS_ANSI
3464334653
else{
3464434654
char *zUtf8;
34645
- char zMbcsPath[MAX_PATH];
34646
- osGetTempPathA(MAX_PATH-30, zMbcsPath);
34655
+ char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34656
+ if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34657
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34658
+ return SQLITE_IOERR_GETTEMPPATH;
34659
+ }
3464734660
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3464834661
if( zUtf8 ){
34649
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34662
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
3465034663
sqlite3_free(zUtf8);
3465134664
}else{
3465234665
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3465334666
return SQLITE_IOERR_NOMEM;
3465434667
}
3465534668
}
34656
-#endif
34657
-#endif
34669
+#else
34670
+ else{
34671
+ /*
34672
+ ** Compiled without ANSI support and the current operating system
34673
+ ** is not Windows NT; therefore, just zero the temporary buffer.
34674
+ */
34675
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34676
+ }
34677
+#endif /* SQLITE_WIN32_HAS_ANSI */
34678
+#else
34679
+ else{
34680
+ /*
34681
+ ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34682
+ ** therefore, just zero the temporary buffer.
34683
+ */
34684
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34685
+ }
34686
+#endif /* !SQLITE_OS_WINRT */
3465834687
3465934688
/* Check that the output buffer is large enough for the temporary file
3466034689
** name. If it is not, return SQLITE_ERROR.
3466134690
*/
3466234691
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
3473834767
int cnt = 0;
3473934768
3474034769
/* If argument zPath is a NULL pointer, this function is required to open
3474134770
** a temporary file. Use this buffer to store the file name in.
3474234771
*/
34743
- char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34772
+ char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
3474434773
3474534774
int rc = SQLITE_OK; /* Function Return Code */
3474634775
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3474734776
int eType = flags&0xFFFFFF00; /* Type of file to open */
3474834777
#endif
@@ -34804,12 +34833,11 @@
3480434833
/* If the second argument to this function is NULL, generate a
3480534834
** temporary file name to use
3480634835
*/
3480734836
if( !zUtf8Name ){
3480834837
assert(isDelete && !isOpenJournal);
34809
- memset(zTmpname, 0, MAX_PATH+2);
34810
- rc = getTempname(MAX_PATH+2, zTmpname);
34838
+ rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
3481134839
if( rc!=SQLITE_OK ){
3481234840
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3481334841
return rc;
3481434842
}
3481534843
zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
3523635264
){
3523735265
3523835266
#if defined(__CYGWIN__)
3523935267
SimulateIOError( return SQLITE_ERROR );
3524035268
UNUSED_PARAMETER(nFull);
35241
- assert( pVfs->mxPathname>=MAX_PATH );
35269
+ assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
3524235270
assert( nFull>=pVfs->mxPathname );
3524335271
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3524435272
/*
3524535273
** NOTE: We are dealing with a relative path name and the data
3524635274
** directory has been set. Therefore, use it as the basis
3524735275
** for converting the relative path name to an absolute
3524835276
** one by prepending the data directory and a slash.
3524935277
*/
35250
- char zOut[MAX_PATH+1];
35251
- memset(zOut, 0, MAX_PATH+1);
35252
- cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253
- MAX_PATH+1);
35278
+ char zOut[SQLITE_WIN32_MAX_PATH+1];
35279
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35280
+ SQLITE_WIN32_MAX_PATH+1)<0 ){
35281
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
+ zRelative);
35283
+ return SQLITE_CANTOPEN_FULLPATH;
35284
+ }
3525435285
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3525535286
sqlite3_data_directory, zOut);
3525635287
}else{
35257
- cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
35288
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35289
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35290
+ zRelative);
35291
+ return SQLITE_CANTOPEN_FULLPATH;
35292
+ }
3525835293
}
3525935294
return SQLITE_OK;
3526035295
#endif
3526135296
3526235297
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
3559435629
*/
3559535630
SQLITE_API int sqlite3_os_init(void){
3559635631
static sqlite3_vfs winVfs = {
3559735632
3, /* iVersion */
3559835633
sizeof(winFile), /* szOsFile */
35599
- MAX_PATH, /* mxPathname */
35634
+ SQLITE_WIN32_MAX_PATH, /* mxPathname */
3560035635
0, /* pNext */
3560135636
"win32", /* zName */
3560235637
0, /* pAppData */
3560335638
winOpen, /* xOpen */
3560435639
winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
6021960254
** a prior call to sqlite3VdbeMakeLabel().
6022060255
*/
6022160256
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
6022260257
int j = -1-x;
6022360258
assert( p->magic==VDBE_MAGIC_INIT );
60224
- assert( j>=0 && j<p->nLabel );
60225
- if( p->aLabel ){
60259
+ assert( j<p->nLabel );
60260
+ if( j>=0 && p->aLabel ){
6022660261
p->aLabel[j] = p->nOp;
6022760262
}
6022860263
}
6022960264
6023060265
/*
@@ -60376,44 +60411,64 @@
6037660411
p->readOnly = 1;
6037760412
p->bIsReader = 0;
6037860413
for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
6037960414
u8 opcode = pOp->opcode;
6038060415
60381
- pOp->opflags = sqlite3OpcodeProperty[opcode];
60382
- if( opcode==OP_Function || opcode==OP_AggStep ){
60383
- if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60384
- }else if( opcode==OP_Transaction ){
60385
- if( pOp->p2!=0 ) p->readOnly = 0;
60386
- p->bIsReader = 1;
60387
- }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60388
- p->bIsReader = 1;
60389
- }else if( opcode==OP_Vacuum
60390
- || opcode==OP_JournalMode
60416
+ /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60417
+ ** cases from this switch! */
60418
+ switch( opcode ){
60419
+ case OP_Function:
60420
+ case OP_AggStep: {
60421
+ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60422
+ break;
60423
+ }
60424
+ case OP_Transaction: {
60425
+ if( pOp->p2!=0 ) p->readOnly = 0;
60426
+ /* fall thru */
60427
+ }
60428
+ case OP_AutoCommit:
60429
+ case OP_Savepoint: {
60430
+ p->bIsReader = 1;
60431
+ break;
60432
+ }
6039160433
#ifndef SQLITE_OMIT_WAL
60392
- || opcode==OP_Checkpoint
60434
+ case OP_Checkpoint:
6039360435
#endif
60394
- ){
60395
- p->readOnly = 0;
60396
- p->bIsReader = 1;
60436
+ case OP_Vacuum:
60437
+ case OP_JournalMode: {
60438
+ p->readOnly = 0;
60439
+ p->bIsReader = 1;
60440
+ break;
60441
+ }
6039760442
#ifndef SQLITE_OMIT_VIRTUALTABLE
60398
- }else if( opcode==OP_VUpdate ){
60399
- if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60400
- }else if( opcode==OP_VFilter ){
60401
- int n;
60402
- assert( p->nOp - i >= 3 );
60403
- assert( pOp[-1].opcode==OP_Integer );
60404
- n = pOp[-1].p1;
60405
- if( n>nMaxArgs ) nMaxArgs = n;
60406
-#endif
60407
- }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60408
- pOp->p4.xAdvance = sqlite3BtreeNext;
60409
- pOp->p4type = P4_ADVANCE;
60410
- }else if( opcode==OP_Prev ){
60411
- pOp->p4.xAdvance = sqlite3BtreePrevious;
60412
- pOp->p4type = P4_ADVANCE;
60413
- }
60414
-
60443
+ case OP_VUpdate: {
60444
+ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60445
+ break;
60446
+ }
60447
+ case OP_VFilter: {
60448
+ int n;
60449
+ assert( p->nOp - i >= 3 );
60450
+ assert( pOp[-1].opcode==OP_Integer );
60451
+ n = pOp[-1].p1;
60452
+ if( n>nMaxArgs ) nMaxArgs = n;
60453
+ break;
60454
+ }
60455
+#endif
60456
+ case OP_Next:
60457
+ case OP_SorterNext: {
60458
+ pOp->p4.xAdvance = sqlite3BtreeNext;
60459
+ pOp->p4type = P4_ADVANCE;
60460
+ break;
60461
+ }
60462
+ case OP_Prev: {
60463
+ pOp->p4.xAdvance = sqlite3BtreePrevious;
60464
+ pOp->p4type = P4_ADVANCE;
60465
+ break;
60466
+ }
60467
+ }
60468
+
60469
+ pOp->opflags = sqlite3OpcodeProperty[opcode];
6041560470
if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
6041660471
assert( -1-pOp->p2<p->nLabel );
6041760472
pOp->p2 = aLabel[-1-pOp->p2];
6041860473
}
6041960474
}
@@ -60544,12 +60599,11 @@
6054460599
/*
6054560600
** Change the P2 operand of instruction addr so that it points to
6054660601
** the address of the next instruction to be coded.
6054760602
*/
6054860603
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60549
- assert( addr>=0 || p->db->mallocFailed );
60550
- if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60604
+ if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
6055160605
}
6055260606
6055360607
6055460608
/*
6055560609
** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
6058160635
}
6058260636
case P4_MPRINTF: {
6058360637
if( db->pnBytesFreed==0 ) sqlite3_free(p4);
6058460638
break;
6058560639
}
60586
- case P4_VDBEFUNC: {
60587
- VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588
- freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589
- if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590
- sqlite3DbFree(db, pVdbeFunc);
60591
- break;
60592
- }
6059360640
case P4_FUNCDEF: {
6059460641
freeEphemeralFunction(db, (FuncDef*)p4);
6059560642
break;
6059660643
}
6059760644
case P4_MEM: {
@@ -60706,24 +60753,17 @@
6070660753
pOp->p4type = P4_INT32;
6070760754
}else if( zP4==0 ){
6070860755
pOp->p4.p = 0;
6070960756
pOp->p4type = P4_NOTUSED;
6071060757
}else if( n==P4_KEYINFO ){
60711
- KeyInfo *pKeyInfo;
60712
- int nField, nByte;
60713
-
60714
- nField = ((KeyInfo*)zP4)->nField;
60715
- nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60716
- pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60717
- pOp->p4.pKeyInfo = pKeyInfo;
60718
- if( pKeyInfo ){
60719
- u8 *aSortOrder;
60720
- memcpy((char*)pKeyInfo, zP4, nByte - nField);
60721
- aSortOrder = pKeyInfo->aSortOrder;
60722
- assert( aSortOrder!=0 );
60723
- pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60724
- memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60758
+ KeyInfo *pOrig, *pNew;
60759
+
60760
+ pOrig = (KeyInfo*)zP4;
60761
+ pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60762
+ if( pNew ){
60763
+ memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60764
+ memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
6072560765
pOp->p4type = P4_KEYINFO;
6072660766
}else{
6072760767
p->db->mallocFailed = 1;
6072860768
pOp->p4type = P4_NOTUSED;
6072960769
}
@@ -61617,10 +61657,14 @@
6161761657
while( p->pDelFrame ){
6161861658
VdbeFrame *pDel = p->pDelFrame;
6161961659
p->pDelFrame = pDel->pParent;
6162061660
sqlite3VdbeFrameDelete(pDel);
6162161661
}
61662
+
61663
+ /* Delete any auxdata allocations made by the VM */
61664
+ sqlite3VdbeDeleteAuxData(p, -1, 0);
61665
+ assert( p->pAuxData==0 );
6162261666
}
6162361667
6162461668
/*
6162561669
** Clean up the VM after execution.
6162661670
**
@@ -62415,24 +62459,39 @@
6241562459
sqlite3VdbeDelete(p);
6241662460
return rc;
6241762461
}
6241862462
6241962463
/*
62420
-** Call the destructor for each auxdata entry in pVdbeFunc for which
62421
-** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422
-** are always destroyed. To destroy all auxdata entries, call this
62423
-** routine with mask==0.
62464
+** If parameter iOp is less than zero, then invoke the destructor for
62465
+** all auxiliary data pointers currently cached by the VM passed as
62466
+** the first argument.
62467
+**
62468
+** Or, if iOp is greater than or equal to zero, then the destructor is
62469
+** only invoked for those auxiliary data pointers created by the user
62470
+** function invoked by the OP_Function opcode at instruction iOp of
62471
+** VM pVdbe, and only then if:
62472
+**
62473
+** * the associated function parameter is the 32nd or later (counting
62474
+** from left to right), or
62475
+**
62476
+** * the corresponding bit in argument mask is clear (where the first
62477
+** function parameter corrsponds to bit 0 etc.).
6242462478
*/
62425
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426
- int i;
62427
- for(i=0; i<pVdbeFunc->nAux; i++){
62428
- struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429
- if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
62479
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62480
+ AuxData **pp = &pVdbe->pAuxData;
62481
+ while( *pp ){
62482
+ AuxData *pAux = *pp;
62483
+ if( (iOp<0)
62484
+ || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62485
+ ){
6243062486
if( pAux->xDelete ){
6243162487
pAux->xDelete(pAux->pAux);
6243262488
}
62433
- pAux->pAux = 0;
62489
+ *pp = pAux->pNext;
62490
+ sqlite3DbFree(pVdbe->db, pAux);
62491
+ }else{
62492
+ pp= &pAux->pNext;
6243462493
}
6243562494
}
6243662495
}
6243762496
6243862497
/*
@@ -62947,15 +63006,14 @@
6294763006
*/
6294863007
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
6294963008
int nKey1, const void *pKey1, /* Left key */
6295063009
UnpackedRecord *pPKey2 /* Right key */
6295163010
){
62952
- int d1; /* Offset into aKey[] of next data element */
63011
+ u32 d1; /* Offset into aKey[] of next data element */
6295363012
u32 idx1; /* Offset into aKey[] of next header element */
6295463013
u32 szHdr1; /* Number of bytes in header */
6295563014
int i = 0;
62956
- int nField;
6295763015
int rc = 0;
6295863016
const unsigned char *aKey1 = (const unsigned char *)pKey1;
6295963017
KeyInfo *pKeyInfo;
6296063018
Mem mem1;
6296163019
@@ -62974,32 +63032,42 @@
6297463032
*/
6297563033
/* mem1.u.i = 0; // not needed, here to silence compiler warning */
6297663034
6297763035
idx1 = getVarint32(aKey1, szHdr1);
6297863036
d1 = szHdr1;
62979
- nField = pKeyInfo->nField;
63037
+ assert( pKeyInfo->nField+1>=pPKey2->nField );
6298063038
assert( pKeyInfo->aSortOrder!=0 );
6298163039
while( idx1<szHdr1 && i<pPKey2->nField ){
6298263040
u32 serial_type1;
6298363041
6298463042
/* Read the serial types for the next element in each key. */
6298563043
idx1 += getVarint32( aKey1+idx1, serial_type1 );
62986
- if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
63044
+
63045
+ /* Verify that there is enough key space remaining to avoid
63046
+ ** a buffer overread. The "d1+serial_type1+2" subexpression will
63047
+ ** always be greater than or equal to the amount of required key space.
63048
+ ** Use that approximation to avoid the more expensive call to
63049
+ ** sqlite3VdbeSerialTypeLen() in the common case.
63050
+ */
63051
+ if( d1+serial_type1+2>(u32)nKey1
63052
+ && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63053
+ ){
63054
+ break;
63055
+ }
6298763056
6298863057
/* Extract the values to be compared.
6298963058
*/
6299063059
d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
6299163060
6299263061
/* Do the comparison
6299363062
*/
62994
- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62995
- i<nField ? pKeyInfo->aColl[i] : 0);
63063
+ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
6299663064
if( rc!=0 ){
6299763065
assert( mem1.zMalloc==0 ); /* See comment below */
6299863066
6299963067
/* Invert the result if we are using DESC sort order. */
63000
- if( i<nField && pKeyInfo->aSortOrder[i] ){
63068
+ if( pKeyInfo->aSortOrder[i] ){
6300163069
rc = -rc;
6300263070
}
6300363071
6300463072
/* If the PREFIX_SEARCH flag is set and all fields except the final
6300563073
** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
6321063278
** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
6321163279
** constants) to the value before returning it.
6321263280
**
6321363281
** The returned value must be freed by the caller using sqlite3ValueFree().
6321463282
*/
63215
-SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63283
+SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
6321663284
assert( iVar>0 );
6321763285
if( v ){
6321863286
Mem *pMem = &v->aVar[iVar-1];
6321963287
if( 0==(pMem->flags & MEM_Null) ){
6322063288
sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
6382763895
/*
6382863896
** Return the auxilary data pointer, if any, for the iArg'th argument to
6382963897
** the user-function defined by pCtx.
6383063898
*/
6383163899
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832
- VdbeFunc *pVdbeFunc;
63900
+ AuxData *pAuxData;
6383363901
6383463902
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835
- pVdbeFunc = pCtx->pVdbeFunc;
63836
- if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837
- return 0;
63903
+ for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63904
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
6383863905
}
63839
- return pVdbeFunc->apAux[iArg].pAux;
63906
+
63907
+ return (pAuxData ? pAuxData->pAux : 0);
6384063908
}
6384163909
6384263910
/*
6384363911
** Set the auxilary data pointer and delete function, for the iArg'th
6384463912
** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
6384863916
sqlite3_context *pCtx,
6384963917
int iArg,
6385063918
void *pAux,
6385163919
void (*xDelete)(void*)
6385263920
){
63853
- struct AuxData *pAuxData;
63854
- VdbeFunc *pVdbeFunc;
63855
- if( iArg<0 ) goto failed;
63921
+ AuxData *pAuxData;
63922
+ Vdbe *pVdbe = pCtx->pVdbe;
6385663923
6385763924
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858
- pVdbeFunc = pCtx->pVdbeFunc;
63859
- if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860
- int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861
- int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862
- pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863
- if( !pVdbeFunc ){
63864
- goto failed;
63865
- }
63866
- pCtx->pVdbeFunc = pVdbeFunc;
63867
- memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868
- pVdbeFunc->nAux = iArg+1;
63869
- pVdbeFunc->pFunc = pCtx->pFunc;
63870
- }
63871
-
63872
- pAuxData = &pVdbeFunc->apAux[iArg];
63873
- if( pAuxData->pAux && pAuxData->xDelete ){
63925
+ if( iArg<0 ) goto failed;
63926
+
63927
+ for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63928
+ if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63929
+ }
63930
+ if( pAuxData==0 ){
63931
+ pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63932
+ if( !pAuxData ) goto failed;
63933
+ pAuxData->iOp = pCtx->iOp;
63934
+ pAuxData->iArg = iArg;
63935
+ pAuxData->pNext = pVdbe->pAuxData;
63936
+ pVdbe->pAuxData = pAuxData;
63937
+ }else if( pAuxData->xDelete ){
6387463938
pAuxData->xDelete(pAuxData->pAux);
6387563939
}
63940
+
6387663941
pAuxData->pAux = pAux;
6387763942
pAuxData->xDelete = xDelete;
6387863943
return;
6387963944
6388063945
failed:
@@ -65482,11 +65547,11 @@
6548265547
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6548365548
u8 encoding = ENC(db); /* The database encoding */
6548465549
int iCompare = 0; /* Result of last OP_Compare operation */
6548565550
unsigned nVmStep = 0; /* Number of virtual machine steps */
6548665551
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487
- unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65552
+ unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
6548865553
#endif
6548965554
Mem *aMem = p->aMem; /* Copy of p->aMem */
6549065555
Mem *pIn1 = 0; /* 1st input operand */
6549165556
Mem *pIn2 = 0; /* 2nd input operand */
6549265557
Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
6594166006
assert( p->explain==0 );
6594266007
p->pResultSet = 0;
6594366008
db->busyHandler.nBusy = 0;
6594466009
CHECK_FOR_INTERRUPT;
6594566010
sqlite3VdbeIOTraceSql(p);
66011
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
66012
+ if( db->xProgress ){
66013
+ assert( 0 < db->nProgressOps );
66014
+ nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
66015
+ if( nProgressLimit==0 ){
66016
+ nProgressLimit = db->nProgressOps;
66017
+ }else{
66018
+ nProgressLimit %= (unsigned)db->nProgressOps;
66019
+ }
66020
+ }
66021
+#endif
6594666022
#ifdef SQLITE_DEBUG
6594766023
sqlite3BeginBenignMalloc();
6594866024
if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
6594966025
int i;
6595066026
printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
6610166177
** of VDBE ops have been executed (either since this invocation of
6610266178
** sqlite3VdbeExec() or since last time the progress callback was called).
6610366179
** If the progress callback returns non-zero, exit the virtual machine with
6610466180
** a return code SQLITE_ABORT.
6610566181
*/
66106
- if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66182
+ if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
6610766183
int prc;
6610866184
prc = db->xProgress(db->pProgressArg);
6610966185
if( prc!=0 ){
6611066186
rc = SQLITE_INTERRUPT;
6611166187
goto vdbe_error_halt;
6611266188
}
66113
- nProgressOps = nVmStep;
66189
+ if( db->xProgress!=0 ){
66190
+ nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66191
+ }
6611466192
}
6611566193
#endif
6611666194
6611766195
break;
6611866196
}
@@ -66794,23 +66872,18 @@
6679466872
Deephemeralize(u.ai.pArg);
6679566873
sqlite3VdbeMemStoreType(u.ai.pArg);
6679666874
REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
6679766875
}
6679866876
66799
- assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800
- if( pOp->p4type==P4_FUNCDEF ){
66801
- u.ai.ctx.pFunc = pOp->p4.pFunc;
66802
- u.ai.ctx.pVdbeFunc = 0;
66803
- }else{
66804
- u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805
- u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806
- }
66807
-
66877
+ assert( pOp->p4type==P4_FUNCDEF );
66878
+ u.ai.ctx.pFunc = pOp->p4.pFunc;
6680866879
u.ai.ctx.s.flags = MEM_Null;
6680966880
u.ai.ctx.s.db = db;
6681066881
u.ai.ctx.s.xDel = 0;
6681166882
u.ai.ctx.s.zMalloc = 0;
66883
+ u.ai.ctx.iOp = pc;
66884
+ u.ai.ctx.pVdbe = p;
6681266885
6681366886
/* The output cell may already have a buffer allocated. Move
6681466887
** the pointer to u.ai.ctx.s so in case the user-function can use
6681566888
** the already allocated buffer instead of allocating a new one.
6681666889
*/
@@ -66829,15 +66902,11 @@
6682966902
lastRowid = db->lastRowid;
6683066903
6683166904
/* If any auxiliary data functions have been called by this user function,
6683266905
** immediately call the destructor for any non-static values.
6683366906
*/
66834
- if( u.ai.ctx.pVdbeFunc ){
66835
- sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836
- pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837
- pOp->p4type = P4_VDBEFUNC;
66838
- }
66907
+ sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
6683966908
6684066909
if( db->mallocFailed ){
6684166910
/* Even though a malloc() has failed, the implementation of the
6684266911
** user function may have called an sqlite3_result_XXX() function
6684366912
** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
7420074269
/* Translate the schema name in zDb into a pointer to the corresponding
7420174270
** schema. If not found, pSchema will remain NULL and nothing will match
7420274271
** resulting in an appropriate error message toward the end of this routine
7420374272
*/
7420474273
if( zDb ){
74205
- for(i=0; i<db->nDb; i++){
74206
- assert( db->aDb[i].zName );
74207
- if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74208
- pSchema = db->aDb[i].pSchema;
74209
- break;
74274
+ testcase( pNC->ncFlags & NC_PartIdx );
74275
+ testcase( pNC->ncFlags & NC_IsCheck );
74276
+ if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74277
+ /* Silently ignore database qualifiers inside CHECK constraints and partial
74278
+ ** indices. Do not raise errors because that might break legacy and
74279
+ ** because it does not hurt anything to just ignore the database name. */
74280
+ zDb = 0;
74281
+ }else{
74282
+ for(i=0; i<db->nDb; i++){
74283
+ assert( db->aDb[i].zName );
74284
+ if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74285
+ pSchema = db->aDb[i].pSchema;
74286
+ break;
74287
+ }
7421074288
}
7421174289
}
7421274290
}
7421374291
7421474292
/* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
7448174559
}
7448274560
ExprSetProperty(p, EP_Resolved);
7448374561
}
7448474562
return p;
7448574563
}
74564
+
74565
+/*
74566
+** Report an error that an expression is not valid for a partial index WHERE
74567
+** clause.
74568
+*/
74569
+static void notValidPartIdxWhere(
74570
+ Parse *pParse, /* Leave error message here */
74571
+ NameContext *pNC, /* The name context */
74572
+ const char *zMsg /* Type of error */
74573
+){
74574
+ if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74575
+ sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74576
+ zMsg);
74577
+ }
74578
+}
74579
+
74580
+#ifndef SQLITE_OMIT_CHECK
74581
+/*
74582
+** Report an error that an expression is not valid for a CHECK constraint.
74583
+*/
74584
+static void notValidCheckConstraint(
74585
+ Parse *pParse, /* Leave error message here */
74586
+ NameContext *pNC, /* The name context */
74587
+ const char *zMsg /* Type of error */
74588
+){
74589
+ if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74590
+ sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74591
+ }
74592
+}
74593
+#else
74594
+# define notValidCheckConstraint(P,N,M)
74595
+#endif
74596
+
7448674597
7448774598
/*
7448874599
** This routine is callback for sqlite3WalkExpr().
7448974600
**
7449074601
** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
7458174692
FuncDef *pDef; /* Information about the function */
7458274693
u8 enc = ENC(pParse->db); /* The database encoding */
7458374694
7458474695
testcase( pExpr->op==TK_CONST_FUNC );
7458574696
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74697
+ notValidPartIdxWhere(pParse, pNC, "functions");
7458674698
zId = pExpr->u.zToken;
7458774699
nId = sqlite3Strlen30(zId);
7458874700
pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
7458974701
if( pDef==0 ){
7459074702
pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
7464674758
#endif
7464774759
case TK_IN: {
7464874760
testcase( pExpr->op==TK_IN );
7464974761
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7465074762
int nRef = pNC->nRef;
74651
-#ifndef SQLITE_OMIT_CHECK
74652
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74653
- sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74654
- }
74655
-#endif
74763
+ notValidCheckConstraint(pParse, pNC, "subqueries");
74764
+ notValidPartIdxWhere(pParse, pNC, "subqueries");
7465674765
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
7465774766
assert( pNC->nRef>=nRef );
7465874767
if( nRef!=pNC->nRef ){
7465974768
ExprSetProperty(pExpr, EP_VarSelect);
7466074769
}
7466174770
}
7466274771
break;
7466374772
}
74664
-#ifndef SQLITE_OMIT_CHECK
7466574773
case TK_VARIABLE: {
74666
- if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74667
- sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74668
- }
74774
+ notValidCheckConstraint(pParse, pNC, "parameters");
74775
+ notValidPartIdxWhere(pParse, pNC, "parameters");
7466974776
break;
7467074777
}
74671
-#endif
7467274778
}
7467374779
return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
7467474780
}
7467574781
7467674782
/*
@@ -74757,11 +74863,11 @@
7475774863
/* Try to match the ORDER BY expression against an expression
7475874864
** in the result set. Return an 1-based index of the matching
7475974865
** result-set entry.
7476074866
*/
7476174867
for(i=0; i<pEList->nExpr; i++){
74762
- if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74868
+ if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
7476374869
return i+1;
7476474870
}
7476574871
}
7476674872
7476774873
/* If no match, return 0. */
@@ -74985,11 +75091,11 @@
7498575091
pItem->iOrderByCol = 0;
7498675092
if( sqlite3ResolveExprNames(pNC, pE) ){
7498775093
return 1;
7498875094
}
7498975095
for(j=0; j<pSelect->pEList->nExpr; j++){
74990
- if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
75096
+ if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
7499175097
pItem->iOrderByCol = j+1;
7499275098
}
7499375099
}
7499475100
}
7499575101
return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
7529175397
w.xSelectCallback = resolveSelectStep;
7529275398
w.pParse = pParse;
7529375399
w.u.pNC = pOuterNC;
7529475400
sqlite3WalkSelect(&w, p);
7529575401
}
75402
+
75403
+/*
75404
+** Resolve names in expressions that can only reference a single table:
75405
+**
75406
+** * CHECK constraints
75407
+** * WHERE clauses on partial indices
75408
+**
75409
+** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75410
+** is set to -1 and the Expr.iColumn value is set to the column number.
75411
+**
75412
+** Any errors cause an error message to be set in pParse.
75413
+*/
75414
+SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75415
+ Parse *pParse, /* Parsing context */
75416
+ Table *pTab, /* The table being referenced */
75417
+ int type, /* NC_IsCheck or NC_PartIdx */
75418
+ Expr *pExpr, /* Expression to resolve. May be NULL. */
75419
+ ExprList *pList /* Expression list to resolve. May be NUL. */
75420
+){
75421
+ SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75422
+ NameContext sNC; /* Name context for pParse->pNewTable */
75423
+ int i; /* Loop counter */
75424
+
75425
+ assert( type==NC_IsCheck || type==NC_PartIdx );
75426
+ memset(&sNC, 0, sizeof(sNC));
75427
+ memset(&sSrc, 0, sizeof(sSrc));
75428
+ sSrc.nSrc = 1;
75429
+ sSrc.a[0].zName = pTab->zName;
75430
+ sSrc.a[0].pTab = pTab;
75431
+ sSrc.a[0].iCursor = -1;
75432
+ sNC.pParse = pParse;
75433
+ sNC.pSrcList = &sSrc;
75434
+ sNC.ncFlags = type;
75435
+ if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75436
+ if( pList ){
75437
+ for(i=0; i<pList->nExpr; i++){
75438
+ if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75439
+ return;
75440
+ }
75441
+ }
75442
+ }
75443
+}
7529675444
7529775445
/************** End of resolve.c *********************************************/
7529875446
/************** Begin file expr.c ********************************************/
7529975447
/*
7530075448
** 2001 September 15
@@ -76987,14 +77135,13 @@
7698777135
#endif
7698877136
7698977137
switch( pExpr->op ){
7699077138
case TK_IN: {
7699177139
char affinity; /* Affinity of the LHS of the IN */
76992
- KeyInfo keyInfo; /* Keyinfo for the generated table */
76993
- static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
7699477140
int addr; /* Address of OP_OpenEphemeral instruction */
7699577141
Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77142
+ KeyInfo *pKeyInfo = 0; /* Key information */
7699677143
7699777144
if( rMayHaveNull ){
7699877145
sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
7699977146
}
7700077147
@@ -77014,13 +77161,11 @@
7701477161
** is used.
7701577162
*/
7701677163
pExpr->iTable = pParse->nTab++;
7701777164
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
7701877165
if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77019
- memset(&keyInfo, 0, sizeof(keyInfo));
77020
- keyInfo.nField = 1;
77021
- keyInfo.aSortOrder = &sortOrder;
77166
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
7702277167
7702377168
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7702477169
/* Case 1: expr IN (SELECT ...)
7702577170
**
7702677171
** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
7703377178
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
7703477179
dest.affSdst = (u8)affinity;
7703577180
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
7703677181
pExpr->x.pSelect->iLimit = 0;
7703777182
if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77183
+ sqlite3DbFree(pParse->db, pKeyInfo);
7703877184
return 0;
7703977185
}
7704077186
pEList = pExpr->x.pSelect->pEList;
77041
- if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77042
- keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77187
+ if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77188
+ pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
7704377189
pEList->a[0].pExpr);
7704477190
}
7704577191
}else if( ALWAYS(pExpr->x.pList!=0) ){
7704677192
/* Case 2: expr IN (exprlist)
7704777193
**
@@ -77056,12 +77202,13 @@
7705677202
int r1, r2, r3;
7705777203
7705877204
if( !affinity ){
7705977205
affinity = SQLITE_AFF_NONE;
7706077206
}
77061
- keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77062
- keyInfo.aSortOrder = &sortOrder;
77207
+ if( pKeyInfo ){
77208
+ pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77209
+ }
7706377210
7706477211
/* Loop through each expression in <exprlist>. */
7706577212
r1 = sqlite3GetTempReg(pParse);
7706677213
r2 = sqlite3GetTempReg(pParse);
7706777214
sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
7709677243
}
7709777244
}
7709877245
sqlite3ReleaseTempReg(pParse, r1);
7709977246
sqlite3ReleaseTempReg(pParse, r2);
7710077247
}
77101
- if( !isRowid ){
77102
- sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77248
+ if( pKeyInfo ){
77249
+ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
7710377250
}
7710477251
break;
7710577252
}
7710677253
7710777254
case TK_EXISTS:
@@ -77657,19 +77804,24 @@
7765777804
break;
7765877805
}
7765977806
/* Otherwise, fall thru into the TK_COLUMN case */
7766077807
}
7766177808
case TK_COLUMN: {
77662
- if( pExpr->iTable<0 ){
77663
- /* This only happens when coding check constraints */
77664
- assert( pParse->ckBase>0 );
77665
- inReg = pExpr->iColumn + pParse->ckBase;
77666
- }else{
77667
- inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77668
- pExpr->iColumn, pExpr->iTable, target,
77669
- pExpr->op2);
77670
- }
77809
+ int iTab = pExpr->iTable;
77810
+ if( iTab<0 ){
77811
+ if( pParse->ckBase>0 ){
77812
+ /* Generating CHECK constraints or inserting into partial index */
77813
+ inReg = pExpr->iColumn + pParse->ckBase;
77814
+ break;
77815
+ }else{
77816
+ /* Deleting from a partial index */
77817
+ iTab = pParse->iPartIdxTab;
77818
+ }
77819
+ }
77820
+ inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77821
+ pExpr->iColumn, iTab, target,
77822
+ pExpr->op2);
7767177823
break;
7767277824
}
7767377825
case TK_INTEGER: {
7767477826
codeInteger(pParse, pExpr, 0, target);
7767577827
break;
@@ -79088,10 +79240,16 @@
7908879240
** Do a deep comparison of two expression trees. Return 0 if the two
7908979241
** expressions are completely identical. Return 1 if they differ only
7909079242
** by a COLLATE operator at the top level. Return 2 if there are differences
7909179243
** other than the top-level COLLATE operator.
7909279244
**
79245
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79246
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79247
+**
79248
+** The pA side might be using TK_REGISTER. If that is the case and pB is
79249
+** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79250
+**
7909379251
** Sometimes this routine will return 2 even if the two expressions
7909479252
** really are equivalent. If we cannot prove that the expressions are
7909579253
** identical, we return 2 just to be safe. So if this routine
7909679254
** returns 2, then you do not really know for certain if the two
7909779255
** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
7909879256
** can be sure the expressions are the same. In the places where
7909979257
** this routine is used, it does not hurt to get an extra 2 - that
7910079258
** just might result in some slightly slower code. But returning
7910179259
** an incorrect 0 or 1 could lead to a malfunction.
7910279260
*/
79103
-SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79261
+SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
7910479262
if( pA==0||pB==0 ){
7910579263
return pB==pA ? 0 : 2;
7910679264
}
7910779265
assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
7910879266
assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
7910979267
if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
7911079268
return 2;
7911179269
}
7911279270
if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79113
- if( pA->op!=pB->op ){
79114
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79271
+ if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79272
+ if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
7911579273
return 1;
7911679274
}
79117
- if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79275
+ if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
7911879276
return 1;
7911979277
}
7912079278
return 2;
7912179279
}
79122
- if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79123
- if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79124
- if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79125
- if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
79280
+ if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79281
+ if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79282
+ if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79283
+ if( pA->iColumn!=pB->iColumn ) return 2;
79284
+ if( pA->iTable!=pB->iTable
79285
+ && pA->op!=TK_REGISTER
79286
+ && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
7912679287
if( ExprHasProperty(pA, EP_IntValue) ){
7912779288
if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
7912879289
return 2;
7912979290
}
7913079291
}else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
7913879299
7913979300
/*
7914079301
** Compare two ExprList objects. Return 0 if they are identical and
7914179302
** non-zero if they differ in any way.
7914279303
**
79304
+** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79305
+** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79306
+**
7914379307
** This routine might return non-zero for equivalent ExprLists. The
7914479308
** only consequence will be disabled optimizations. But this routine
7914579309
** must never return 0 if the two ExprList objects are different, or
7914679310
** a malfunction will result.
7914779311
**
7914879312
** Two NULL pointers are considered to be the same. But a NULL pointer
7914979313
** always differs from a non-NULL pointer.
7915079314
*/
79151
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79315
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
7915279316
int i;
7915379317
if( pA==0 && pB==0 ) return 0;
7915479318
if( pA==0 || pB==0 ) return 1;
7915579319
if( pA->nExpr!=pB->nExpr ) return 1;
7915679320
for(i=0; i<pA->nExpr; i++){
7915779321
Expr *pExprA = pA->a[i].pExpr;
7915879322
Expr *pExprB = pB->a[i].pExpr;
7915979323
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79160
- if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
79324
+ if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79325
+ }
79326
+ return 0;
79327
+}
79328
+
79329
+/*
79330
+** Return true if we can prove the pE2 will always be true if pE1 is
79331
+** true. Return false if we cannot complete the proof or if pE2 might
79332
+** be false. Examples:
79333
+**
79334
+** pE1: x==5 pE2: x==5 Result: true
79335
+** pE1: x>0 pE2: x==5 Result: false
79336
+** pE1: x=21 pE2: x=21 OR y=43 Result: true
79337
+** pE1: x!=123 pE2: x IS NOT NULL Result: true
79338
+** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79339
+** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79340
+** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79341
+**
79342
+** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79343
+** Expr.iTable<0 then assume a table number given by iTab.
79344
+**
79345
+** When in doubt, return false. Returning true might give a performance
79346
+** improvement. Returning false might cause a performance reduction, but
79347
+** it will always give the correct answer and is hence always safe.
79348
+*/
79349
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79350
+ if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79351
+ return 1;
79352
+ }
79353
+ if( pE2->op==TK_OR
79354
+ && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79355
+ || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79356
+ ){
79357
+ return 1;
79358
+ }
79359
+ if( pE2->op==TK_NOTNULL
79360
+ && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79361
+ && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79362
+ ){
79363
+ return 1;
7916179364
}
7916279365
return 0;
7916379366
}
7916479367
7916579368
/*
@@ -79340,11 +79543,11 @@
7934079543
/* Check to see if pExpr is a duplicate of another aggregate
7934179544
** function that is already in the pAggInfo structure
7934279545
*/
7934379546
struct AggInfo_func *pItem = pAggInfo->aFunc;
7934479547
for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79345
- if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79548
+ if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
7934679549
break;
7934779550
}
7934879551
}
7934979552
if( i>=pAggInfo->nFunc ){
7935079553
/* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
8075780960
int i; /* Loop counter */
8075880961
int topOfLoop; /* The top of the loop */
8075980962
int endOfLoop; /* The end of the loop */
8076080963
int jZeroRows = -1; /* Jump from here if number of rows is zero */
8076180964
int iDb; /* Index of database containing pTab */
80965
+ u8 needTableCnt = 1; /* True to count the table */
8076280966
int regTabname = iMem++; /* Register containing table name */
8076380967
int regIdxname = iMem++; /* Register containing index name */
8076480968
int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
8076580969
#ifdef SQLITE_ENABLE_STAT3
8076680970
int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
8081681020
KeyInfo *pKey;
8081781021
int addrIfNot = 0; /* address of OP_IfNot */
8081881022
int *aChngAddr; /* Array of jump instruction addresses */
8081981023
8082081024
if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
81025
+ if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
8082181026
VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
8082281027
nCol = pIdx->nColumn;
8082381028
aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
8082481029
if( aChngAddr==0 ) continue;
8082581030
pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
8097581180
** If K==0 then no entry is made into the sqlite_stat1 table.
8097681181
** If K>0 then it is always the case the D>0 so division by zero
8097781182
** is never possible.
8097881183
*/
8097981184
sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80980
- if( jZeroRows<0 ){
80981
- jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80982
- }
81185
+ jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
8098381186
for(i=0; i<nCol; i++){
8098481187
sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
8098581188
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8098681189
sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
8098781190
sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
8098881191
sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
8098981192
sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
8099081193
sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
8099181194
}
81195
+ if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8099281196
sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
8099381197
sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
8099481198
sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
8099581199
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81200
+ if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
8099681201
}
8099781202
80998
- /* If the table has no indices, create a single sqlite_stat1 entry
80999
- ** containing NULL as the index name and the row count as the content.
81203
+ /* Create a single sqlite_stat1 entry containing NULL as the index
81204
+ ** name and the row count as the content.
8100081205
*/
81001
- if( pTab->pIndex==0 ){
81206
+ if( pOnlyIdx==0 && needTableCnt ){
8100281207
sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
8100381208
VdbeComment((v, "%s", pTab->zName));
8100481209
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
8100581210
sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
8100681211
jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81007
- }else{
81008
- sqlite3VdbeJumpHere(v, jZeroRows);
81009
- jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
81010
- }
81011
- sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81012
- sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81013
- sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81014
- sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81015
- sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81016
- if( pParse->nMem<regRec ) pParse->nMem = regRec;
81017
- sqlite3VdbeJumpHere(v, jZeroRows);
81212
+ sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81213
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81214
+ sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81215
+ sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81216
+ sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81217
+ sqlite3VdbeJumpHere(v, jZeroRows);
81218
+ }
81219
+ if( pParse->nMem<regRec ) pParse->nMem = regRec;
8101881220
}
8101981221
8102081222
8102181223
/*
8102281224
** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
8119581397
v = 0;
8119681398
while( (c=z[0])>='0' && c<='9' ){
8119781399
v = v*10 + c - '0';
8119881400
z++;
8119981401
}
81200
- if( i==0 ) pTable->nRowEst = v;
81201
- if( pIndex==0 ) break;
81402
+ if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81403
+ if( v>0 ) pTable->nRowEst = v;
81404
+ if( pIndex==0 ) break;
81405
+ }
8120281406
pIndex->aiRowEst[i] = v;
8120381407
if( *z==' ' ) z++;
8120481408
if( strcmp(z, "unordered")==0 ){
8120581409
pIndex->bUnordered = 1;
8120681410
break;
@@ -82636,10 +82840,11 @@
8263682840
*/
8263782841
static void freeIndex(sqlite3 *db, Index *p){
8263882842
#ifndef SQLITE_OMIT_ANALYZE
8263982843
sqlite3DeleteIndexSamples(db, p);
8264082844
#endif
82845
+ sqlite3ExprDelete(db, p->pPartIdxWhere);
8264182846
sqlite3DbFree(db, p->zColAff);
8264282847
sqlite3DbFree(db, p);
8264382848
}
8264482849
8264582850
/*
@@ -83479,11 +83684,12 @@
8347983684
sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
8348083685
"INTEGER PRIMARY KEY");
8348183686
#endif
8348283687
}else{
8348383688
Index *p;
83484
- p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
83689
+ p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83690
+ 0, sortOrder, 0);
8348583691
if( p ){
8348683692
p->autoIndex = 2;
8348783693
}
8348883694
pList = 0;
8348983695
}
@@ -83774,30 +83980,11 @@
8377483980
8377583981
#ifndef SQLITE_OMIT_CHECK
8377683982
/* Resolve names in all CHECK constraint expressions.
8377783983
*/
8377883984
if( p->pCheck ){
83779
- SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83780
- NameContext sNC; /* Name context for pParse->pNewTable */
83781
- ExprList *pList; /* List of all CHECK constraints */
83782
- int i; /* Loop counter */
83783
-
83784
- memset(&sNC, 0, sizeof(sNC));
83785
- memset(&sSrc, 0, sizeof(sSrc));
83786
- sSrc.nSrc = 1;
83787
- sSrc.a[0].zName = p->zName;
83788
- sSrc.a[0].pTab = p;
83789
- sSrc.a[0].iCursor = -1;
83790
- sNC.pParse = pParse;
83791
- sNC.pSrcList = &sSrc;
83792
- sNC.ncFlags = NC_IsCheck;
83793
- pList = p->pCheck;
83794
- for(i=0; i<pList->nExpr; i++){
83795
- if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83796
- return;
83797
- }
83798
- }
83985
+ sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
8379983986
}
8380083987
#endif /* !defined(SQLITE_OMIT_CHECK) */
8380183988
8380283989
/* If the db->init.busy is 1 it means we are reading the SQL off the
8380383990
** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
8464584832
int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
8464684833
int iSorter; /* Cursor opened by OpenSorter (if in use) */
8464784834
int addr1; /* Address of top of loop */
8464884835
int addr2; /* Address to jump to for next iteration */
8464984836
int tnum; /* Root page of index */
84837
+ int iPartIdxLabel; /* Jump to this label to skip a row */
8465084838
Vdbe *v; /* Generate code into this virtual machine */
8465184839
KeyInfo *pKey; /* KeyInfo for index */
8465284840
int regRecord; /* Register holding assemblied index record */
8465384841
sqlite3 *db = pParse->db; /* The database connection */
8465484842
int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
8468484872
** records into the sorter. */
8468584873
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
8468684874
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
8468784875
regRecord = sqlite3GetTempReg(pParse);
8468884876
84689
- sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84877
+ sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
8469084878
sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84879
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8469184880
sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
8469284881
sqlite3VdbeJumpHere(v, addr1);
8469384882
addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
8469484883
if( pIndex->onError!=OE_None ){
8469584884
int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
8473684925
Token *pName2, /* Second part of index name. May be NULL */
8473784926
SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
8473884927
ExprList *pList, /* A list of columns to be indexed */
8473984928
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
8474084929
Token *pStart, /* The CREATE token that begins this statement */
84741
- Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84930
+ Expr *pPIWhere, /* WHERE clause for partial indices */
8474284931
int sortOrder, /* Sort order of primary key when pList==NULL */
8474384932
int ifNotExist /* Omit error if index already exists */
8474484933
){
8474584934
Index *pRet = 0; /* Pointer to return */
8474684935
Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
8475884947
struct ExprList_item *pListItem; /* For looping over pList */
8475984948
int nCol;
8476084949
int nExtra = 0;
8476184950
char *zExtra;
8476284951
84763
- assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
8476484952
assert( pParse->nErr==0 ); /* Never called with prior errors */
8476584953
if( db->mallocFailed || IN_DECLARE_VTAB ){
8476684954
goto exit_create_index;
8476784955
}
8476884956
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
8480484992
assert(0);
8480584993
}
8480684994
pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
8480784995
assert( db->mallocFailed==0 || pTab==0 );
8480884996
if( pTab==0 ) goto exit_create_index;
84809
- assert( db->aDb[iDb].pSchema==pTab->pSchema );
84997
+ if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84998
+ sqlite3ErrorMsg(pParse,
84999
+ "cannot create a TEMP index on non-TEMP table \"%s\"",
85000
+ pTab->zName);
85001
+ goto exit_create_index;
85002
+ }
8481085003
}else{
8481185004
assert( pName==0 );
8481285005
assert( pStart==0 );
8481385006
pTab = pParse->pNewTable;
8481485007
if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
8495385146
pIndex->nColumn = pList->nExpr;
8495485147
pIndex->onError = (u8)onError;
8495585148
pIndex->uniqNotNull = onError==OE_Abort;
8495685149
pIndex->autoIndex = (u8)(pName==0);
8495785150
pIndex->pSchema = db->aDb[iDb].pSchema;
85151
+ if( pPIWhere ){
85152
+ sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85153
+ pIndex->pPartIdxWhere = pPIWhere;
85154
+ pPIWhere = 0;
85155
+ }
8495885156
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
8495985157
8496085158
/* Check to see if we should honor DESC requests on index columns
8496185159
*/
8496285160
if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
8510885306
** If pTblName==0 it means this index is generated as a primary key
8510985307
** or UNIQUE constraint of a CREATE TABLE statement. Since the table
8511085308
** has just been created, it contains no data and the index initialization
8511185309
** step can be skipped.
8511285310
*/
85113
- else{ /* if( db->init.busy==0 ) */
85311
+ else if( pParse->nErr==0 ){
8511485312
Vdbe *v;
8511585313
char *zStmt;
8511685314
int iMem = ++pParse->nMem;
8511785315
8511885316
v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
8512685324
8512785325
/* Gather the complete text of the CREATE INDEX statement into
8512885326
** the zStmt variable
8512985327
*/
8513085328
if( pStart ){
85131
- assert( pEnd!=0 );
85329
+ int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85330
+ if( pName->z[n-1]==';' ) n--;
8513285331
/* A named index with an explicit CREATE INDEX statement */
8513385332
zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85134
- onError==OE_None ? "" : " UNIQUE",
85135
- (int)(pEnd->z - pName->z) + 1,
85136
- pName->z);
85333
+ onError==OE_None ? "" : " UNIQUE", n, pName->z);
8513785334
}else{
8513885335
/* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
8513985336
/* zStmt = sqlite3MPrintf(""); */
8514085337
zStmt = 0;
8514185338
}
@@ -85187,14 +85384,12 @@
8518785384
pIndex = 0;
8518885385
}
8518985386
8519085387
/* Clean up before exiting */
8519185388
exit_create_index:
85192
- if( pIndex ){
85193
- sqlite3DbFree(db, pIndex->zColAff);
85194
- sqlite3DbFree(db, pIndex);
85195
- }
85389
+ if( pIndex ) freeIndex(db, pIndex);
85390
+ sqlite3ExprDelete(db, pPIWhere);
8519685391
sqlite3ExprListDelete(db, pList);
8519785392
sqlite3SrcListDelete(db, pTblName);
8519885393
sqlite3DbFree(db, zName);
8519985394
return pRet;
8520085395
}
@@ -86068,29 +86263,24 @@
8606886263
** the error.
8606986264
*/
8607086265
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
8607186266
int i;
8607286267
int nCol = pIdx->nColumn;
86073
- int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86074
- sqlite3 *db = pParse->db;
86075
- KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86076
-
86077
- if( pKey ){
86078
- pKey->db = pParse->db;
86079
- pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86080
- assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86268
+ KeyInfo *pKey;
86269
+
86270
+ pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86271
+ if( pKey ){
8608186272
for(i=0; i<nCol; i++){
8608286273
char *zColl = pIdx->azColl[i];
8608386274
assert( zColl );
8608486275
pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
8608586276
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
8608686277
}
86087
- pKey->nField = (u16)nCol;
8608886278
}
8608986279
8609086280
if( pParse->nErr ){
86091
- sqlite3DbFree(db, pKey);
86281
+ sqlite3DbFree(pParse->db, pKey);
8609286282
pKey = 0;
8609386283
}
8609486284
return pKey;
8609586285
}
8609686286
@@ -87166,15 +87356,18 @@
8716687356
int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
8716787357
){
8716887358
int i;
8716987359
Index *pIdx;
8717087360
int r1;
87361
+ int iPartIdxLabel;
87362
+ Vdbe *v = pParse->pVdbe;
8717187363
8717287364
for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
8717387365
if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87174
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87175
- sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
87366
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87367
+ sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87368
+ sqlite3VdbeResolveLabel(v, iPartIdxLabel);
8717687369
}
8717787370
}
8717887371
8717987372
/*
8718087373
** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
8718487377
**
8718587378
** Return a register number which is the first in a block of
8718687379
** registers that holds the elements of the index key. The
8718787380
** block of registers has already been deallocated by the time
8718887381
** this routine returns.
87382
+**
87383
+** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87384
+** to that label if pIdx is a partial index that should be skipped.
87385
+** A partial index should be skipped if its WHERE clause evaluates
87386
+** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87387
+** will be set to zero which is an empty label that is ignored by
87388
+** sqlite3VdbeResolveLabel().
8718987389
*/
8719087390
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87191
- Parse *pParse, /* Parsing context */
87192
- Index *pIdx, /* The index for which to generate a key */
87193
- int iCur, /* Cursor number for the pIdx->pTable table */
87194
- int regOut, /* Write the new index key to this register */
87195
- int doMakeRec /* Run the OP_MakeRecord instruction if true */
87391
+ Parse *pParse, /* Parsing context */
87392
+ Index *pIdx, /* The index for which to generate a key */
87393
+ int iCur, /* Cursor number for the pIdx->pTable table */
87394
+ int regOut, /* Write the new index key to this register */
87395
+ int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87396
+ int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
8719687397
){
8719787398
Vdbe *v = pParse->pVdbe;
8719887399
int j;
8719987400
Table *pTab = pIdx->pTable;
8720087401
int regBase;
8720187402
int nCol;
8720287403
87404
+ if( piPartIdxLabel ){
87405
+ if( pIdx->pPartIdxWhere ){
87406
+ *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87407
+ pParse->iPartIdxTab = iCur;
87408
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87409
+ SQLITE_JUMPIFNULL);
87410
+ }else{
87411
+ *piPartIdxLabel = 0;
87412
+ }
87413
+ }
8720387414
nCol = pIdx->nColumn;
8720487415
regBase = sqlite3GetTempRange(pParse, nCol+1);
8720587416
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
8720687417
for(j=0; j<nCol; j++){
8720787418
int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
9156191772
** Add the new records to the indices as we go.
9156291773
*/
9156391774
for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
9156491775
int regIdx;
9156591776
int regR;
91777
+ int addrSkipRow = 0;
9156691778
9156791779
if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91780
+
91781
+ if( pIdx->pPartIdxWhere ){
91782
+ sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91783
+ addrSkipRow = sqlite3VdbeMakeLabel(v);
91784
+ pParse->ckBase = regData;
91785
+ sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91786
+ SQLITE_JUMPIFNULL);
91787
+ pParse->ckBase = 0;
91788
+ }
9156891789
9156991790
/* Create a key for accessing the index entry */
9157091791
regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
9157191792
for(i=0; i<pIdx->nColumn; i++){
9157291793
int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
9158391804
9158491805
/* Find out what action to take in case there is an indexing conflict */
9158591806
onError = pIdx->onError;
9158691807
if( onError==OE_None ){
9158791808
sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91809
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9158891810
continue; /* pIdx is not a UNIQUE index */
9158991811
}
9159091812
if( overrideError!=OE_Default ){
9159191813
onError = overrideError;
9159291814
}else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
9165291874
seenReplace = 1;
9165391875
break;
9165491876
}
9165591877
}
9165691878
sqlite3VdbeJumpHere(v, j3);
91879
+ sqlite3VdbeResolveLabel(v, addrSkipRow);
9165791880
sqlite3ReleaseTempReg(pParse, regR);
9165891881
}
9165991882
9166091883
if( pbMayReplace ){
9166191884
*pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
9168191904
int appendBias, /* True if this is likely to be an append */
9168291905
int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
9168391906
){
9168491907
int i;
9168591908
Vdbe *v;
91686
- int nIdx;
9168791909
Index *pIdx;
9168891910
u8 pik_flags;
9168991911
int regData;
9169091912
int regRec;
9169191913
9169291914
v = sqlite3GetVdbe(pParse);
9169391915
assert( v!=0 );
9169491916
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91695
- for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91696
- for(i=nIdx-1; i>=0; i--){
91917
+ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
9169791918
if( aRegIdx[i]==0 ) continue;
91919
+ if( pIdx->pPartIdxWhere ){
91920
+ sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91921
+ }
9169891922
sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
9169991923
if( useSeekResult ){
9170091924
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
9170191925
}
9170291926
}
@@ -91794,10 +92018,11 @@
9179492018
**
9179592019
** * The index is over the same set of columns
9179692020
** * The same DESC and ASC markings occurs on all columns
9179792021
** * The same onError processing (OE_Abort, OE_Ignore, etc)
9179892022
** * The same collating sequence on each column
92023
+** * The index has the exact same WHERE clause
9179992024
*/
9180092025
static int xferCompatibleIndex(Index *pDest, Index *pSrc){
9180192026
int i;
9180292027
assert( pDest && pSrc );
9180392028
assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
9181592040
return 0; /* Different sort orders */
9181692041
}
9181792042
if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
9181892043
return 0; /* Different collating sequences */
9181992044
}
92045
+ }
92046
+ if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
92047
+ return 0; /* Different WHERE clauses */
9182092048
}
9182192049
9182292050
/* If no test above fails then the indices must be compatible */
9182392051
return 1;
9182492052
}
@@ -91971,11 +92199,11 @@
9197192199
if( pSrcIdx==0 ){
9197292200
return 0; /* pDestIdx has no corresponding index in pSrc */
9197392201
}
9197492202
}
9197592203
#ifndef SQLITE_OMIT_CHECK
91976
- if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
92204
+ if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
9197792205
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
9197892206
}
9197992207
#endif
9198092208
#ifndef SQLITE_OMIT_FOREIGN_KEY
9198192209
/* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
9488495112
cnt++;
9488595113
}
9488695114
}
9488795115
9488895116
/* Make sure sufficient number of registers have been allocated */
94889
- if( pParse->nMem < cnt+4 ){
94890
- pParse->nMem = cnt+4;
94891
- }
95117
+ pParse->nMem = MAX( pParse->nMem, cnt+7 );
9489295118
9489395119
/* Do the b-tree integrity checks */
9489495120
sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
9489595121
sqlite3VdbeChangeP5(v, (u8)i);
9489695122
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
9491195137
9491295138
if( pTab->pIndex==0 ) continue;
9491395139
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
9491495140
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
9491595141
sqlite3VdbeJumpHere(v, addr);
95142
+ sqlite3ExprCacheClear(pParse);
9491695143
sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94917
- sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94918
- loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94919
- sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
95144
+ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95145
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95146
+ }
95147
+ pParse->nMem = MAX(pParse->nMem, 7+j);
95148
+ loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
9492095149
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94921
- int jmp2;
95150
+ int jmp2, jmp3;
9492295151
int r1;
9492395152
static const VdbeOpList idxErr[] = {
9492495153
{ OP_AddImm, 1, -1, 0},
9492595154
{ OP_String8, 0, 3, 0}, /* 1 */
9492695155
{ OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
9493195160
{ OP_Concat, 6, 3, 3},
9493295161
{ OP_ResultRow, 3, 1, 0},
9493395162
{ OP_IfPos, 1, 0, 0}, /* 9 */
9493495163
{ OP_Halt, 0, 0, 0},
9493595164
};
94936
- r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
95165
+ r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95166
+ sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
9493795167
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
9493895168
addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
9493995169
sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
9494095170
sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
9494195171
sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
9494295172
sqlite3VdbeJumpHere(v, addr+9);
9494395173
sqlite3VdbeJumpHere(v, jmp2);
95174
+ sqlite3VdbeResolveLabel(v, jmp3);
9494495175
}
94945
- sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94946
- sqlite3VdbeJumpHere(v, loopTop);
95176
+ sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95177
+ sqlite3VdbeJumpHere(v, loopTop-1);
95178
+#ifndef SQLITE_OMIT_BTREECOUNT
95179
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95180
+ "wrong # of entries in index ", P4_STATIC);
9494795181
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94948
- static const VdbeOpList cntIdx[] = {
94949
- { OP_Integer, 0, 3, 0},
94950
- { OP_Rewind, 0, 0, 0}, /* 1 */
94951
- { OP_AddImm, 3, 1, 0},
94952
- { OP_Next, 0, 0, 0}, /* 3 */
94953
- { OP_Eq, 2, 0, 3}, /* 4 */
94954
- { OP_AddImm, 1, -1, 0},
94955
- { OP_String8, 0, 2, 0}, /* 6 */
94956
- { OP_String8, 0, 3, 0}, /* 7 */
94957
- { OP_Concat, 3, 2, 2},
94958
- { OP_ResultRow, 2, 1, 0},
94959
- };
94960
- addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
95182
+ addr = sqlite3VdbeCurrentAddr(v);
95183
+ sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
9496195184
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94962
- sqlite3VdbeJumpHere(v, addr);
94963
- addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94964
- sqlite3VdbeChangeP1(v, addr+1, j+2);
94965
- sqlite3VdbeChangeP2(v, addr+1, addr+4);
94966
- sqlite3VdbeChangeP1(v, addr+3, j+2);
94967
- sqlite3VdbeChangeP2(v, addr+3, addr+2);
94968
- sqlite3VdbeJumpHere(v, addr+4);
94969
- sqlite3VdbeChangeP4(v, addr+6,
94970
- "wrong # of entries in index ", P4_STATIC);
94971
- sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94972
- }
95185
+ sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95186
+ sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95187
+ sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95188
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95189
+ sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95190
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95191
+ }
95192
+#endif /* SQLITE_OMIT_BTREECOUNT */
9497395193
}
9497495194
}
9497595195
addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
9497695196
sqlite3VdbeChangeP2(v, addr, -mxErr);
9497795197
sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
9699497214
*/
9699597215
if( pOrderBy==0 && p->iLimit ){
9699697216
sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
9699797217
}
9699897218
}
97219
+
97220
+/*
97221
+** Allocate a KeyInfo object sufficient for an index of N columns.
97222
+**
97223
+** Actually, always allocate one extra column for the rowid at the end
97224
+** of the index. So the KeyInfo returned will have space sufficient for
97225
+** N+1 columns.
97226
+*/
97227
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97228
+ KeyInfo *p = sqlite3DbMallocZero(db,
97229
+ sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97230
+ if( p ){
97231
+ p->aSortOrder = (u8*)&p->aColl[N+1];
97232
+ p->nField = (u16)N;
97233
+ p->enc = ENC(db);
97234
+ p->db = db;
97235
+ }
97236
+ return p;
97237
+}
9699997238
9700097239
/*
9700197240
** Given an expression list, generate a KeyInfo structure that records
9700297241
** the collating sequence for each expression in that expression list.
9700397242
**
@@ -97011,29 +97250,23 @@
9701197250
** function is responsible for seeing that this structure is eventually
9701297251
** freed. Add the KeyInfo structure to the P4 field of an opcode using
9701397252
** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
9701497253
*/
9701597254
static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97016
- sqlite3 *db = pParse->db;
9701797255
int nExpr;
9701897256
KeyInfo *pInfo;
9701997257
struct ExprList_item *pItem;
97258
+ sqlite3 *db = pParse->db;
9702097259
int i;
9702197260
9702297261
nExpr = pList->nExpr;
97023
- pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97262
+ pInfo = sqlite3KeyInfoAlloc(db, nExpr);
9702497263
if( pInfo ){
97025
- pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97026
- pInfo->nField = (u16)nExpr;
97027
- pInfo->enc = ENC(db);
97028
- pInfo->db = db;
9702997264
for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
9703097265
CollSeq *pColl;
9703197266
pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97032
- if( !pColl ){
97033
- pColl = db->pDfltColl;
97034
- }
97267
+ if( !pColl ) pColl = db->pDfltColl;
9703597268
pInfo->aColl[i] = pColl;
9703697269
pInfo->aSortOrder[i] = pItem->sortOrder;
9703797270
}
9703897271
}
9703997272
return pInfo;
@@ -98135,27 +98368,21 @@
9813598368
CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
9813698369
int nCol; /* Number of columns in result set */
9813798370
9813898371
assert( p->pRightmost==p );
9813998372
nCol = p->pEList->nExpr;
98140
- pKeyInfo = sqlite3DbMallocZero(db,
98141
- sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98373
+ pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
9814298374
if( !pKeyInfo ){
9814398375
rc = SQLITE_NOMEM;
9814498376
goto multi_select_end;
9814598377
}
98146
-
98147
- pKeyInfo->enc = ENC(db);
98148
- pKeyInfo->nField = (u16)nCol;
98149
-
9815098378
for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
9815198379
*apColl = multiSelectCollSeq(pParse, p, i);
9815298380
if( 0==*apColl ){
9815398381
*apColl = db->pDfltColl;
9815498382
}
9815598383
}
98156
- pKeyInfo->aSortOrder = (u8*)apColl;
9815798384
9815898385
for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
9815998386
for(i=0; i<2; i++){
9816098387
int addr = pLoop->addrOpenEphm[i];
9816198388
if( addr<0 ){
@@ -98520,16 +98747,12 @@
9852098747
struct ExprList_item *pItem;
9852198748
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
9852298749
assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
9852398750
aPermute[i] = pItem->iOrderByCol - 1;
9852498751
}
98525
- pKeyMerge =
98526
- sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98752
+ pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
9852798753
if( pKeyMerge ){
98528
- pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98529
- pKeyMerge->nField = (u16)nOrderBy;
98530
- pKeyMerge->enc = ENC(db);
9853198754
for(i=0; i<nOrderBy; i++){
9853298755
CollSeq *pColl;
9853398756
Expr *pTerm = pOrderBy->a[i].pExpr;
9853498757
if( pTerm->flags & EP_Collate ){
9853598758
pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
9856298785
int nExpr = p->pEList->nExpr;
9856398786
assert( nOrderBy>=nExpr || db->mallocFailed );
9856498787
regPrev = pParse->nMem+1;
9856598788
pParse->nMem += nExpr+1;
9856698789
sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98567
- pKeyDup = sqlite3DbMallocZero(db,
98568
- sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98790
+ pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
9856998791
if( pKeyDup ){
98570
- pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98571
- pKeyDup->nField = (u16)nExpr;
98572
- pKeyDup->enc = ENC(db);
9857398792
for(i=0; i<nExpr; i++){
9857498793
pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
9857598794
pKeyDup->aSortOrder[i] = 0;
9857698795
}
9857798796
}
@@ -99833,14 +100052,16 @@
99833100052
** and/or pParse->db->mallocFailed.
99834100053
*/
99835100054
static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99836100055
Walker w;
99837100056
memset(&w, 0, sizeof(w));
99838
- w.xSelectCallback = convertCompoundSelectToSubquery;
99839100057
w.xExprCallback = exprWalkNoop;
99840100058
w.pParse = pParse;
99841
- sqlite3WalkSelect(&w, pSelect);
100059
+ if( pParse->hasCompound ){
100060
+ w.xSelectCallback = convertCompoundSelectToSubquery;
100061
+ sqlite3WalkSelect(&w, pSelect);
100062
+ }
99842100063
w.xSelectCallback = selectExpander;
99843100064
sqlite3WalkSelect(&w, pSelect);
99844100065
}
99845100066
99846100067
@@ -100370,11 +100591,11 @@
100370100591
** will cause elements to come out in the correct order. This is
100371100592
** an optimization - the correct answer should result regardless.
100372100593
** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100373100594
** to disable this optimization for testing purposes.
100374100595
*/
100375
- if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100596
+ if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100376100597
&& OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100377100598
pOrderBy = 0;
100378100599
}
100379100600
100380100601
/* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100391100612
** used for both the ORDER BY and DISTINCT processing. As originally
100392100613
** written the query must use a temp-table for at least one of the ORDER
100393100614
** BY and DISTINCT, and an index or separate temp-table for the other.
100394100615
*/
100395100616
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100396
- && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100617
+ && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100397100618
){
100398100619
p->selFlags &= ~SF_Distinct;
100399100620
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100400100621
pGroupBy = p->pGroupBy;
100401100622
pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102618102839
aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102619102840
if( aRegIdx==0 ) goto update_cleanup;
102620102841
}
102621102842
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102622102843
int reg;
102623
- if( hasFK || chngRowid ){
102844
+ if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102624102845
reg = ++pParse->nMem;
102625102846
}else{
102626102847
reg = 0;
102627102848
for(i=0; i<pIdx->nColumn; i++){
102628102849
if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105158105379
** the pWC->a[] array.
105159105380
*/
105160105381
static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105161105382
WhereTerm *pTerm;
105162105383
int idx;
105163
- testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105384
+ testcase( wtFlags & TERM_VIRTUAL );
105164105385
if( pWC->nTerm>=pWC->nSlot ){
105165105386
WhereTerm *pOld = pWC->a;
105166105387
sqlite3 *db = pWC->pWInfo->pParse->db;
105167105388
pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105168105389
if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105303105524
105304105525
/*
105305105526
** Return TRUE if the given operator is one of the operators that is
105306105527
** allowed for an indexable WHERE clause term. The allowed operators are
105307105528
** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105308
-**
105309
-** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105310
-** of one of the following forms: column = expression column > expression
105311
-** column >= expression column < expression column <= expression
105312
-** expression = column expression > column expression >= column
105313
-** expression < column expression <= column column IN
105314
-** (expression-list) column IN (subquery) column IS NULL
105315105529
*/
105316105530
static int allowedOp(int op){
105317105531
assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105318105532
assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105319105533
assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105628105842
op = pRight->op2;
105629105843
}
105630105844
if( op==TK_VARIABLE ){
105631105845
Vdbe *pReprepare = pParse->pReprepare;
105632105846
int iCol = pRight->iColumn;
105633
- pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105847
+ pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105634105848
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105635105849
z = (char *)sqlite3_value_text(pVal);
105636105850
}
105637105851
sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105638105852
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
105983106197
}
105984106198
105985106199
/* At this point, okToChngToIN is true if original pTerm satisfies
105986106200
** case 1. In that case, construct a new virtual term that is
105987106201
** pTerm converted into an IN operator.
105988
- **
105989
- ** EV: R-00211-15100
105990106202
*/
105991106203
if( okToChngToIN ){
105992106204
Expr *pDup; /* A transient duplicate expression */
105993106205
ExprList *pList = 0; /* The RHS of the IN operator */
105994106206
Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106226106438
** wildcard. But if we increment '@', that will push it into the
106227106439
** alphabetic range where case conversions will mess up the
106228106440
** inequality. To avoid this, make sure to also run the full
106229106441
** LIKE on all candidate expressions by clearing the isComplete flag
106230106442
*/
106231
- if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106232
-
106233
-
106443
+ if( c=='A'-1 ) isComplete = 0;
106234106444
c = sqlite3UpperToLower[c];
106235106445
}
106236106446
*pC = c + 1;
106237106447
}
106238106448
sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106735106945
VdbeComment((v, "for %s", pTable->zName));
106736106946
106737106947
/* Fill the automatic index with content */
106738106948
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106739106949
regRecord = sqlite3GetTempReg(pParse);
106740
- sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106950
+ sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106741106951
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106742106952
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106743106953
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106744106954
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106745106955
sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107092107302
if( pExpr->op==TK_VARIABLE
107093107303
|| (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107094107304
){
107095107305
int iVar = pExpr->iColumn;
107096107306
sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107097
- *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107307
+ *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107098107308
return SQLITE_OK;
107099107309
}
107100107310
return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107101107311
}
107102107312
#endif
@@ -107318,13 +107528,10 @@
107318107528
**
107319107529
** The t2.z='ok' is disabled in the in (2) because it originates
107320107530
** in the ON clause. The term is disabled in (3) because it is not part
107321107531
** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107322107532
**
107323
-** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107324
-** completely satisfied by indices.
107325
-**
107326107533
** Disabling a term causes that term to not be tested in the inner loop
107327107534
** of the join. Disabling is an optimization. When terms are satisfied
107328107535
** by indices, we disable them to prevent redundant tests in the inner
107329107536
** loop. We would get the correct results if nothing were ever disabled,
107330107537
** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107550107757
pTerm = pLoop->aLTerm[j];
107551107758
assert( pTerm!=0 );
107552107759
/* The following true for indices with redundant columns.
107553107760
** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107554107761
testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107555
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107762
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107556107763
r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107557107764
if( r1!=regBase+j ){
107558107765
if( nReg==1 ){
107559107766
sqlite3ReleaseTempReg(pParse, regBase);
107560107767
regBase = r1;
@@ -107750,10 +107957,11 @@
107750107957
WhereLevel *pLevel; /* The where level to be coded */
107751107958
WhereLoop *pLoop; /* The WhereLoop object being coded */
107752107959
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753107960
WhereTerm *pTerm; /* A WHERE clause term */
107754107961
Parse *pParse; /* Parsing context */
107962
+ sqlite3 *db; /* Database connection */
107755107963
Vdbe *v; /* The prepared stmt under constructions */
107756107964
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757107965
int addrBrk; /* Jump here to break out of the loop */
107758107966
int addrCont; /* Jump here to continue with next cycle */
107759107967
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107761107969
Bitmask newNotReady; /* Return value */
107762107970
107763107971
pParse = pWInfo->pParse;
107764107972
v = pParse->pVdbe;
107765107973
pWC = &pWInfo->sWC;
107974
+ db = pParse->db;
107766107975
pLevel = &pWInfo->a[iLevel];
107767107976
pLoop = pLevel->pWLoop;
107768107977
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769107978
iCur = pTabItem->iCursor;
107770107979
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
107859108068
iReleaseReg = sqlite3GetTempReg(pParse);
107860108069
pTerm = pLoop->aLTerm[0];
107861108070
assert( pTerm!=0 );
107862108071
assert( pTerm->pExpr!=0 );
107863108072
assert( omitTable==0 );
107864
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108073
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
107865108074
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107866108075
addrNxt = pLevel->addrNxt;
107867108076
sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107868108077
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107869108078
sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
107907108116
assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107908108117
assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107909108118
assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107910108119
107911108120
assert( (pStart->wtFlags & TERM_VNULL)==0 );
107912
- testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108121
+ testcase( pStart->wtFlags & TERM_VIRTUAL );
107913108122
pX = pStart->pExpr;
107914108123
assert( pX!=0 );
107915108124
testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107916108125
r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107917108126
sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
107926108135
Expr *pX;
107927108136
pX = pEnd->pExpr;
107928108137
assert( pX!=0 );
107929108138
assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107930108139
testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107931
- testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140
+ testcase( pEnd->wtFlags & TERM_VIRTUAL );
107932108141
memEndValue = ++pParse->nMem;
107933108142
sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107934108143
if( pX->op==TK_LT || pX->op==TK_GT ){
107935108144
testOp = bRev ? OP_Le : OP_Ge;
107936108145
}else{
@@ -108051,11 +108260,11 @@
108051108260
/* Generate code to evaluate all constraint terms using == or IN
108052108261
** and store the values of those terms in an array of registers
108053108262
** starting at regBase.
108054108263
*/
108055108264
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056
- zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108265
+ zEndAff = sqlite3DbStrDup(db, zStartAff);
108057108266
addrNxt = pLevel->addrNxt;
108058108267
108059108268
/* If we are doing a reverse order scan on an ascending index, or
108060108269
** a forward order scan on a descending index, interchange the
108061108270
** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108092108301
if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108093108302
zStartAff[nEq] = SQLITE_AFF_NONE;
108094108303
}
108095108304
}
108096108305
nConstraint++;
108097
- testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108306
+ testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108098108307
}else if( isMinQuery ){
108099108308
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108100108309
nConstraint++;
108101108310
startEq = 0;
108102108311
start_constraints = 1;
@@ -108134,14 +108343,14 @@
108134108343
zEndAff[nEq] = SQLITE_AFF_NONE;
108135108344
}
108136108345
}
108137108346
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138108347
nConstraint++;
108139
- testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108348
+ testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108140108349
}
108141
- sqlite3DbFree(pParse->db, zStartAff);
108142
- sqlite3DbFree(pParse->db, zEndAff);
108350
+ sqlite3DbFree(db, zStartAff);
108351
+ sqlite3DbFree(db, zEndAff);
108143108352
108144108353
/* Top of the loop body */
108145108354
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146108355
108147108356
/* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108264108473
*/
108265108474
if( pWInfo->nLevel>1 ){
108266108475
int nNotReady; /* The number of notReady tables */
108267108476
struct SrcList_item *origSrc; /* Original list of tables */
108268108477
nNotReady = pWInfo->nLevel - iLevel - 1;
108269
- pOrTab = sqlite3StackAllocRaw(pParse->db,
108478
+ pOrTab = sqlite3StackAllocRaw(db,
108270108479
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271108480
if( pOrTab==0 ) return notReady;
108272108481
pOrTab->nAlloc = (u8)(nNotReady + 1);
108273108482
pOrTab->nSrc = pOrTab->nAlloc;
108274108483
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108318108527
Expr *pExpr = pWC->a[iTerm].pExpr;
108319108528
if( &pWC->a[iTerm] == pTerm ) continue;
108320108529
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321108530
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322108531
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323
- pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324
- pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108532
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
108533
+ pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108325108534
}
108326108535
if( pAndExpr ){
108327108536
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328108537
}
108329108538
}
@@ -108339,11 +108548,11 @@
108339108548
}
108340108549
/* Loop through table entries that match term pOrTerm. */
108341108550
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342108551
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343108552
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344
- assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108553
+ assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108345108554
if( pSubWInfo ){
108346108555
WhereLoop *pSubLoop;
108347108556
explainOneScan(
108348108557
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349108558
);
@@ -108394,17 +108603,17 @@
108394108603
}
108395108604
pLevel->u.pCovidx = pCov;
108396108605
if( pCov ) pLevel->iIdxCur = iCovCur;
108397108606
if( pAndExpr ){
108398108607
pAndExpr->pLeft = 0;
108399
- sqlite3ExprDelete(pParse->db, pAndExpr);
108608
+ sqlite3ExprDelete(db, pAndExpr);
108400108609
}
108401108610
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402108611
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403108612
sqlite3VdbeResolveLabel(v, iLoopBody);
108404108613
108405
- if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108614
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108406108615
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407108616
}else
108408108617
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409108618
108410108619
{
@@ -108421,18 +108630,14 @@
108421108630
}
108422108631
newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108423108632
108424108633
/* Insert code to test every subexpression that can be completely
108425108634
** computed using the current set of tables.
108426
- **
108427
- ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108428
- ** the use of indices become tests that are evaluated against each row of
108429
- ** the relevant input tables.
108430108635
*/
108431108636
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108432108637
Expr *pE;
108433
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108638
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108434108639
testcase( pTerm->wtFlags & TERM_CODED );
108435108640
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108436108641
if( (pTerm->prereqAll & newNotReady)!=0 ){
108437108642
testcase( pWInfo->untestedTerms==0
108438108643
&& (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108455108660
** and we are coding the t1 loop and the t2 loop has not yet coded,
108456108661
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457108662
** the implied "t1.a=123" constraint.
108458108663
*/
108459108664
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460
- Expr *pE;
108665
+ Expr *pE, *pEAlt;
108461108666
WhereTerm *pAlt;
108462
- Expr sEq;
108463108667
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464108668
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465108669
if( pTerm->leftCursor!=iCur ) continue;
108466108670
if( pLevel->iLeftJoin ) continue;
108467108671
pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108471108675
if( pAlt==0 ) continue;
108472108676
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473108677
testcase( pAlt->eOperator & WO_EQ );
108474108678
testcase( pAlt->eOperator & WO_IN );
108475108679
VdbeNoopComment((v, "begin transitive constraint"));
108476
- sEq = *pAlt->pExpr;
108477
- sEq.pLeft = pE->pLeft;
108478
- sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108680
+ pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108681
+ if( pEAlt ){
108682
+ *pEAlt = *pAlt->pExpr;
108683
+ pEAlt->pLeft = pE->pLeft;
108684
+ sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108685
+ sqlite3StackFree(db, pEAlt);
108686
+ }
108479108687
}
108480108688
108481108689
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108482108690
** at least one row of the right table has matched the left table.
108483108691
*/
@@ -108485,11 +108693,11 @@
108485108693
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108486108694
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108487108695
VdbeComment((v, "record LEFT JOIN hit"));
108488108696
sqlite3ExprCacheClear(pParse);
108489108697
for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108490
- testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108698
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
108491108699
testcase( pTerm->wtFlags & TERM_CODED );
108492108700
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108493108701
if( (pTerm->prereqAll & newNotReady)!=0 ){
108494108702
assert( pWInfo->untestedTerms );
108495108703
continue;
@@ -108926,11 +109134,12 @@
108926109134
rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108927109135
}else if( (pTerm->eOperator & WO_IN)
108928109136
&& !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108929109137
rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108930109138
}
108931
- if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
109139
+ assert( nOut==0 || rc==SQLITE_OK );
109140
+ if( nOut ) pNew->nOut = whereCost(nOut);
108932109141
}
108933109142
#endif
108934109143
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108935109144
/* Each row involves a step of the index, then a binary search of
108936109145
** the main table */
@@ -108998,10 +109207,21 @@
108998109207
if( x<BMS-1 ) m |= MASKBIT(x);
108999109208
}
109000109209
return m;
109001109210
}
109002109211
109212
+/* Check to see if a partial index with pPartIndexWhere can be used
109213
+** in the current query. Return true if it can be and false if not.
109214
+*/
109215
+static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109216
+ int i;
109217
+ WhereTerm *pTerm;
109218
+ for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109219
+ if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109220
+ }
109221
+ return 0;
109222
+}
109003109223
109004109224
/*
109005109225
** Add all WhereLoop objects for a single table of the join where the table
109006109226
** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109007109227
** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109021109241
int rc = SQLITE_OK; /* Return code */
109022109242
int iSortIdx = 1; /* Index number */
109023109243
int b; /* A boolean value */
109024109244
WhereCost rSize; /* number of rows in the table */
109025109245
WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109246
+ WhereClause *pWC; /* The parsed WHERE clause */
109026109247
109027109248
pNew = pBuilder->pNew;
109028109249
pWInfo = pBuilder->pWInfo;
109029109250
pTabList = pWInfo->pTabList;
109030109251
pSrc = pTabList->a + pNew->iTab;
109252
+ pWC = pBuilder->pWC;
109031109253
assert( !IsVirtual(pSrc->pTab) );
109032109254
109033109255
if( pSrc->pIndex ){
109034109256
/* An INDEXED BY clause specifies a particular index to use */
109035109257
pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109065109287
&& !pSrc->viaCoroutine
109066109288
&& !pSrc->notIndexed
109067109289
&& !pSrc->isCorrelated
109068109290
){
109069109291
/* Generate auto-index WhereLoops */
109070
- WhereClause *pWC = pBuilder->pWC;
109071109292
WhereTerm *pTerm;
109072109293
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109073109294
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109074109295
if( pTerm->prereqRight & pNew->maskSelf ) continue;
109075109296
if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109095109316
}
109096109317
109097109318
/* Loop over all indices
109098109319
*/
109099109320
for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109321
+ if( pProbe->pPartIdxWhere!=0
109322
+ && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109323
+ continue; /* Partial index inappropriate for this query */
109324
+ }
109100109325
pNew->u.btree.nEq = 0;
109101109326
pNew->nLTerm = 0;
109102109327
pNew->iSortIdx = 0;
109103109328
pNew->rSetup = 0;
109104109329
pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110035110260
pLoop->u.btree.nEq = 1;
110036110261
/* TUNING: Cost of a rowid lookup is 10 */
110037110262
pLoop->rRun = 33; /* 33==whereCost(10) */
110038110263
}else{
110039110264
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110040
- if( pIdx->onError==OE_None ) continue;
110265
+ if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
110041110266
for(j=0; j<pIdx->nColumn; j++){
110042110267
pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110043110268
if( pTerm==0 ) break;
110044110269
whereLoopResize(pWInfo->pParse->db, pLoop, j);
110045110270
pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110241110466
** subexpression is separated by an AND operator.
110242110467
*/
110243110468
initMaskSet(pMaskSet);
110244110469
whereClauseInit(&pWInfo->sWC, pWInfo);
110245110470
sqlite3ExprCodeConstants(pParse, pWhere);
110246
- whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110471
+ whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110247110472
sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110248110473
110249110474
/* Special case: a WHERE clause that is constant. Evaluate the
110250110475
** expression and either jump over all of the code or fall thru.
110251110476
*/
@@ -110875,11 +111100,11 @@
110875111100
#endif
110876111101
#define sqlite3ParserARG_SDECL Parse *pParse;
110877111102
#define sqlite3ParserARG_PDECL ,Parse *pParse
110878111103
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110879111104
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
110880
-#define YYNSTATE 627
111105
+#define YYNSTATE 628
110881111106
#define YYNRULE 327
110882111107
#define YYFALLBACK 1
110883111108
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110884111109
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110885111110
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
110948111173
** shifting non-terminals after a reduce.
110949111174
** yy_default[] Default action for each state.
110950111175
*/
110951111176
#define YY_ACTTAB_COUNT (1564)
110952111177
static const YYACTIONTYPE yy_action[] = {
110953
- /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
111178
+ /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
110954111179
/* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110955
- /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110956
- /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110957
- /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110958
- /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110959
- /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110960
- /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
111180
+ /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111181
+ /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111182
+ /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111183
+ /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111184
+ /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111185
+ /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
110961111186
/* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110962
- /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110963
- /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
111187
+ /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111188
+ /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
110964111189
/* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110965
- /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
111190
+ /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
110966111191
/* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110967
- /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110968
- /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110969
- /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110970
- /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110971
- /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110972
- /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110973
- /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110974
- /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110975
- /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110976
- /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110977
- /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110978
- /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110979
- /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110980
- /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110981
- /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110982
- /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110983
- /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110984
- /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110985
- /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110986
- /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110987
- /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110988
- /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
111192
+ /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111193
+ /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111194
+ /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111195
+ /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111196
+ /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111197
+ /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111198
+ /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111199
+ /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111200
+ /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111201
+ /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111202
+ /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111203
+ /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111204
+ /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111205
+ /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111206
+ /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111207
+ /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111208
+ /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111209
+ /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111210
+ /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111211
+ /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111212
+ /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111213
+ /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
110989111214
/* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110990
- /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110991
- /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110992
- /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110993
- /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110994
- /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110995
- /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111215
+ /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111216
+ /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111217
+ /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111218
+ /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111219
+ /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111220
+ /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
110996111221
/* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110997
- /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110998
- /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110999
- /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
111000
- /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
111001
- /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
111002
- /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
111003
- /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
111004
- /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
111005
- /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
111006
- /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
111007
- /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
111008
- /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
111009
- /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
111010
- /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111011
- /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111012
- /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
111013
- /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
111014
- /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
111015
- /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
111016
- /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
111017
- /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
111222
+ /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111223
+ /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111224
+ /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111225
+ /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111226
+ /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111227
+ /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111228
+ /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111229
+ /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111230
+ /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111231
+ /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111232
+ /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111233
+ /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111234
+ /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111235
+ /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111236
+ /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111237
+ /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111238
+ /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111239
+ /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111240
+ /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111241
+ /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111242
+ /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111018111243
/* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111019
- /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
111020
- /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
111021
- /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
111022
- /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
111023
- /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
111024
- /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
111025
- /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111244
+ /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111245
+ /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111246
+ /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111247
+ /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111248
+ /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111249
+ /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111250
+ /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111026111251
/* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111027
- /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
111028
- /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
111029
- /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
111030
- /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
111031
- /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
111032
- /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111033
- /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
111034
- /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
111035
- /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
111036
- /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
111037
- /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
111038
- /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
111039
- /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
111040
- /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
111041
- /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
111042
- /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111043
- /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111044
- /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111045
- /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111046
- /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111047
- /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111048
- /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111049
- /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111050
- /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111051
- /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111052
- /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111053
- /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111054
- /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111055
- /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111056
- /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111057
- /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111058
- /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111059
- /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111060
- /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111061
- /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111062
- /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111252
+ /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111253
+ /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111254
+ /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111255
+ /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111256
+ /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111257
+ /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111258
+ /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111259
+ /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111260
+ /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111261
+ /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111262
+ /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111263
+ /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111264
+ /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111265
+ /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111266
+ /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111267
+ /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111268
+ /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111269
+ /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111270
+ /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111271
+ /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111272
+ /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111273
+ /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111274
+ /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111275
+ /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111276
+ /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111277
+ /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111278
+ /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111279
+ /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111280
+ /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111281
+ /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111282
+ /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111283
+ /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111284
+ /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111285
+ /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111286
+ /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111287
+ /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111063111288
/* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111064
- /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111065
- /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111066
- /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111067
- /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111068
- /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111069
- /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111070
- /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111071
- /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111072
- /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111073
- /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111074
- /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111075
- /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111076
- /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111077
- /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111078
- /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111079
- /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111080
- /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111081
- /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111082
- /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111083
- /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111084
- /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111085
- /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111086
- /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111087
- /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111088
- /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111089
- /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111090
- /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111091
- /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111092
- /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111093
- /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111094
- /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111095
- /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111096
- /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111097
- /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111098
- /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111099
- /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111100
- /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111101
- /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111102
- /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111103
- /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111104
- /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111105
- /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111106
- /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111107
- /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111108
- /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111109
- /* 1560 */ 295, 498, 956, 488,
111289
+ /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111290
+ /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111291
+ /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111292
+ /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111293
+ /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111294
+ /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111295
+ /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111296
+ /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111297
+ /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111298
+ /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111299
+ /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111300
+ /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111301
+ /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111302
+ /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111303
+ /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111304
+ /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111305
+ /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111306
+ /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111307
+ /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111308
+ /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111309
+ /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111310
+ /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111311
+ /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111312
+ /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111313
+ /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111314
+ /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111315
+ /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111316
+ /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111317
+ /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111318
+ /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111319
+ /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111320
+ /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111321
+ /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111322
+ /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111323
+ /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111324
+ /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111325
+ /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111326
+ /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111327
+ /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111328
+ /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111329
+ /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111330
+ /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111331
+ /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111332
+ /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111333
+ /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111334
+ /* 1560 */ 400, 499, 523, 233,
111110111335
};
111111111336
static const YYCODETYPE yy_lookahead[] = {
111112111337
/* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111113111338
/* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111114111339
/* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111256111481
/* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111257111482
/* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111258111483
/* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111259111484
/* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111260111485
/* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111261
- /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111486
+ /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111262111487
/* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111263
- /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111264
- /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111265
- /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111266
- /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111267
- /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111268
- /* 1560 */ 195, 182, 250, 186,
111488
+ /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111489
+ /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111490
+ /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111491
+ /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111492
+ /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111493
+ /* 1560 */ 191, 182, 173, 92,
111269111494
};
111270111495
#define YY_SHIFT_USE_DFLT (-70)
111271
-#define YY_SHIFT_COUNT (416)
111496
+#define YY_SHIFT_COUNT (417)
111272111497
#define YY_SHIFT_MIN (-69)
111273111498
#define YY_SHIFT_MAX (1487)
111274111499
static const short yy_shift_ofst[] = {
111275111500
/* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111276111501
/* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111283111508
/* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111284111509
/* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111285111510
/* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111286111511
/* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111287111512
/* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111288
- /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111513
+ /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111289111514
/* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111290111515
/* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111291111516
/* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111292111517
/* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111293111518
/* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111294111519
/* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111295111520
/* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111296111521
/* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111297111522
/* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111298
- /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111299
- /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111300
- /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111301
- /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111302
- /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111303
- /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111304
- /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111305
- /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111306
- /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111307
- /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111308
- /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111309
- /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111310
- /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111311
- /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111312
- /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111313
- /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111314
- /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111315
- /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111316
- /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111523
+ /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111524
+ /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111525
+ /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111526
+ /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111527
+ /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111528
+ /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111529
+ /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111530
+ /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111531
+ /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111532
+ /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111533
+ /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111534
+ /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111535
+ /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111536
+ /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111537
+ /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111538
+ /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111539
+ /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111540
+ /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111541
+ /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111317111542
};
111318111543
#define YY_REDUCE_USE_DFLT (-169)
111319
-#define YY_REDUCE_COUNT (308)
111544
+#define YY_REDUCE_COUNT (309)
111320111545
#define YY_REDUCE_MIN (-168)
111321
-#define YY_REDUCE_MAX (1391)
111546
+#define YY_REDUCE_MAX (1397)
111322111547
static const short yy_reduce_ofst[] = {
111323111548
/* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111324111549
/* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111325111550
/* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111326111551
/* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111337111562
/* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111338111563
/* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111339111564
/* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111340111565
/* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111341111566
/* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111342
- /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111343
- /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111344
- /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111345
- /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111346
- /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111347
- /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111348
- /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111349
- /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111350
- /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111351
- /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111352
- /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111353
- /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111567
+ /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111568
+ /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111569
+ /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111570
+ /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111571
+ /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111572
+ /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111573
+ /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111574
+ /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111575
+ /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111576
+ /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111577
+ /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111578
+ /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111354111579
};
111355111580
static const YYACTIONTYPE yy_default[] = {
111356
- /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111357
- /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111358
- /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111359
- /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111360
- /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111361
- /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111362
- /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111363
- /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111364
- /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111365
- /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111366
- /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111367
- /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111368
- /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111369
- /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111370
- /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111371
- /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111372
- /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111373
- /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111374
- /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111375
- /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111376
- /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111377
- /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111378
- /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111379
- /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111380
- /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111381
- /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111382
- /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111383
- /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111384
- /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111385
- /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111386
- /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111387
- /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111388
- /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111389
- /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111390
- /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111391
- /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111392
- /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111393
- /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111394
- /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111395
- /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111396
- /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111397
- /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111398
- /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111399
- /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111400
- /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111401
- /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111402
- /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111403
- /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111404
- /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111405
- /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111406
- /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111407
- /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111408
- /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111409
- /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111410
- /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111411
- /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111412
- /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111413
- /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111414
- /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111415
- /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111416
- /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111417
- /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111418
- /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111581
+ /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111582
+ /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111583
+ /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111584
+ /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111585
+ /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111586
+ /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111587
+ /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111588
+ /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111589
+ /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111590
+ /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111591
+ /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111592
+ /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111593
+ /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111594
+ /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111595
+ /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111596
+ /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111597
+ /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111598
+ /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111599
+ /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111600
+ /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111601
+ /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111602
+ /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111603
+ /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111604
+ /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111605
+ /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111606
+ /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111607
+ /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111608
+ /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111609
+ /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111610
+ /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111611
+ /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111612
+ /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111613
+ /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111614
+ /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111615
+ /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111616
+ /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111617
+ /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111618
+ /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111619
+ /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111620
+ /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111621
+ /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111622
+ /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111623
+ /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111624
+ /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111625
+ /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111626
+ /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111627
+ /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111628
+ /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111629
+ /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111630
+ /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111631
+ /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111632
+ /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111633
+ /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111634
+ /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111635
+ /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111636
+ /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111637
+ /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111638
+ /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111639
+ /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111640
+ /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111641
+ /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111642
+ /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111643
+ /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111419111644
};
111420111645
111421111646
/* The next table maps tokens into fallback tokens. If a construct
111422111647
** like the following:
111423111648
**
@@ -111885,11 +112110,11 @@
111885112110
/* 237 */ "case_operand ::=",
111886112111
/* 238 */ "exprlist ::= nexprlist",
111887112112
/* 239 */ "exprlist ::=",
111888112113
/* 240 */ "nexprlist ::= nexprlist COMMA expr",
111889112114
/* 241 */ "nexprlist ::= expr",
111890
- /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
112115
+ /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
111891112116
/* 243 */ "uniqueflag ::= UNIQUE",
111892112117
/* 244 */ "uniqueflag ::=",
111893112118
/* 245 */ "idxlist_opt ::=",
111894112119
/* 246 */ "idxlist_opt ::= LP idxlist RP",
111895112120
/* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112604112829
{ 224, 0 },
112605112830
{ 220, 1 },
112606112831
{ 220, 0 },
112607112832
{ 215, 3 },
112608112833
{ 215, 1 },
112609
- { 147, 11 },
112834
+ { 147, 12 },
112610112835
{ 227, 1 },
112611112836
{ 227, 0 },
112612112837
{ 178, 0 },
112613112838
{ 178, 3 },
112614112839
{ 187, 5 },
@@ -113046,10 +113271,11 @@
113046113271
case 114: /* select ::= select multiselect_op oneselect */
113047113272
{
113048113273
if( yymsp[0].minor.yy159 ){
113049113274
yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113050113275
yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113276
+ if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113051113277
}else{
113052113278
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113053113279
}
113054113280
yygotominor.yy159 = yymsp[0].minor.yy159;
113055113281
}
@@ -113608,15 +113834,15 @@
113608113834
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113609113835
break;
113610113836
case 241: /* nexprlist ::= expr */
113611113837
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113612113838
break;
113613
- case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113839
+ case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113614113840
{
113615
- sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113616
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113617
- &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113841
+ sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113842
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113843
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113618113844
}
113619113845
break;
113620113846
case 243: /* uniqueflag ::= UNIQUE */
113621113847
case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113622113848
{yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114538114764
*tokenType = TK_SPACE;
114539114765
return i;
114540114766
}
114541114767
case '-': {
114542114768
if( z[1]=='-' ){
114543
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114544114769
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114545114770
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114546114771
return i;
114547114772
}
114548114773
*tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114571114796
case '/': {
114572114797
if( z[1]!='*' || z[2]==0 ){
114573114798
*tokenType = TK_SLASH;
114574114799
return 1;
114575114800
}
114576
- /* IMP: R-50417-27976 -- syntax diagram for comments */
114577114801
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114578114802
if( c ) i++;
114579114803
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114580114804
return i;
114581114805
}
@@ -116416,10 +116640,11 @@
116416116640
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417116641
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418116642
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419116643
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420116644
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116645
+ case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116421116646
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422116647
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423116648
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424116649
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425116650
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117771117996
db->autoCommit = 1;
117772117997
db->nextAutovac = -1;
117773117998
db->szMmap = sqlite3GlobalConfig.szMmap;
117774117999
db->nextPagesize = 0;
117775118000
db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776
-#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
118001
+#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777118002
| SQLITE_AutoIndex
117778118003
#endif
117779118004
#if SQLITE_DEFAULT_FILE_FORMAT<4
117780118005
| SQLITE_LegacyFileFmt
117781118006
#endif
@@ -128244,11 +128469,11 @@
128244128469
}
128245128470
128246128471
128247128472
#ifdef SQLITE_TEST
128248128473
128249
-/* #include <tcl.h> */
128474
+#include <tcl.h>
128250128475
/* #include <string.h> */
128251128476
128252128477
/*
128253128478
** Implementation of a special SQL scalar function for testing tokenizers
128254128479
** designed to be used in concert with the Tcl testing framework. This
128255128480
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
411 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -670,11 +656,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1039,10 +1025,11 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
3122 ** interface is to keep a GUI updated during a large query.
3123 **
3124 ** ^The parameter P is passed through as the only parameter to the
3125 ** callback function X. ^The parameter N is the approximate number of
3126 ** [virtual machine instructions] that are evaluated between successive
3127 ** invocations of the callback X.
 
3128 **
3129 ** ^Only a single progress handler may be defined at one time per
3130 ** [database connection]; setting a new progress handler cancels the
3131 ** old one. ^Setting parameter X to NULL disables the progress handler.
3132 ** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
4742 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4743
4744 /*
4745 ** CAPI3REF: Function Auxiliary Data
4746 **
4747 ** The following two functions may be used by scalar SQL functions to
4748 ** associate metadata with argument values. If the same value is passed to
4749 ** multiple invocations of the same SQL function during query execution, under
4750 ** some circumstances the associated metadata may be preserved. This might
4751 ** be used, for example, in a regular-expression matching
4752 ** function. The compiled version of the regular expression is stored as
4753 ** metadata associated with the SQL value passed as the regular expression
4754 ** pattern. The compiled regular expression can be reused on multiple
4755 ** invocations of the same function so that the original pattern string
4756 ** does not need to be recompiled on each invocation.
4757 **
4758 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4759 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4760 ** value to the application-defined function. ^If no metadata has been ever
4761 ** been set for the Nth argument of the function, or if the corresponding
4762 ** function parameter has changed since the meta-data was set,
4763 ** then sqlite3_get_auxdata() returns a NULL pointer.
4764 **
4765 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4766 ** argument of the application-defined function. ^Subsequent
4767 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4768 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4769 ** NULL if the data has been dropped.
4770 ** ^(If it is not NULL, SQLite will invoke the destructor
4771 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4772 ** <li> the corresponding function parameter changes,
4773 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4774 ** SQL statement,
4775 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4776 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4777 **
4778 ** SQLite is free to call the destructor and drop metadata on any
4779 ** parameter of any function at any time. ^The only guarantee is that
4780 ** the destructor will be called when the [prepared statement] is destroyed.
4781 ** Note in particular that the destructor X in the call to
4782 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4783 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4784 ** should be called near the end of the function implementation and the
4785 ** implementation should not make any use of P after sqlite3_set_auxdata()
4786 ** has been called.
4787 **
4788 ** ^(In practice, metadata is preserved between function calls for
4789 ** function parameters that are compile-time constants, including literal
4790 ** values and [parameters] and expressions composed from the same.)^
4791 **
@@ -6829,13 +6816,13 @@
6829 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6830 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6831 ** </dd>
6832 **
6833 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6834 ** <dd>This parameter returns the zero for the current value if and only if
6835 ** there all foreign key constraints (deferred or immediate) have been
6836 ** resolved. The highwater mark is always 0.
6837 ** </dd>
6838 ** </dl>
6839 */
6840 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6841 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
8824
8825 /*
8826 ** The names of the following types declared in vdbeInt.h are required
8827 ** for the VdbeOp definition.
8828 */
8829 typedef struct VdbeFunc VdbeFunc;
8830 typedef struct Mem Mem;
8831 typedef struct SubProgram SubProgram;
8832
8833 /*
8834 ** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
8848 void *p; /* Generic pointer */
8849 char *z; /* Pointer to data for string (char array) types */
8850 i64 *pI64; /* Used when p4type is P4_INT64 */
8851 double *pReal; /* Used when p4type is P4_REAL */
8852 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
8853 VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */
8854 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8855 Mem *pMem; /* Used when p4type is P4_MEM */
8856 VTable *pVtab; /* Used when p4type is P4_VTAB */
8857 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8858 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
8902 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8903 #define P4_STATIC (-2) /* Pointer to a static string */
8904 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8905 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8906 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
8907 #define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */
8908 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8909 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8910 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8911 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8912 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
8959 */
8960 /************** Include opcodes.h in the middle of vdbe.h ********************/
8961 /************** Begin file opcodes.h *****************************************/
8962 /* Automatically generated. Do not edit */
8963 /* See the mkopcodeh.awk script for details */
8964 #define OP_Goto 1
8965 #define OP_Gosub 2
8966 #define OP_Return 3
8967 #define OP_Yield 4
8968 #define OP_HaltIfNull 5
8969 #define OP_Halt 6
8970 #define OP_Integer 7
8971 #define OP_Int64 8
8972 #define OP_Real 130 /* same as TK_FLOAT */
8973 #define OP_String8 94 /* same as TK_STRING */
8974 #define OP_String 9
8975 #define OP_Null 10
8976 #define OP_Blob 11
8977 #define OP_Variable 12
8978 #define OP_Move 13
8979 #define OP_Copy 14
8980 #define OP_SCopy 15
8981 #define OP_ResultRow 16
8982 #define OP_Concat 91 /* same as TK_CONCAT */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8983 #define OP_Add 86 /* same as TK_PLUS */
8984 #define OP_Subtract 87 /* same as TK_MINUS */
8985 #define OP_Multiply 88 /* same as TK_STAR */
8986 #define OP_Divide 89 /* same as TK_SLASH */
8987 #define OP_Remainder 90 /* same as TK_REM */
8988 #define OP_CollSeq 17
8989 #define OP_Function 18
8990 #define OP_BitAnd 82 /* same as TK_BITAND */
8991 #define OP_BitOr 83 /* same as TK_BITOR */
8992 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8993 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
8994 #define OP_AddImm 20
8995 #define OP_MustBeInt 21
8996 #define OP_RealAffinity 22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8997 #define OP_ToText 141 /* same as TK_TO_TEXT */
8998 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
8999 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
9000 #define OP_ToInt 144 /* same as TK_TO_INT */
9001 #define OP_ToReal 145 /* same as TK_TO_REAL */
9002 #define OP_Eq 76 /* same as TK_EQ */
9003 #define OP_Ne 75 /* same as TK_NE */
9004 #define OP_Lt 79 /* same as TK_LT */
9005 #define OP_Le 78 /* same as TK_LE */
9006 #define OP_Gt 77 /* same as TK_GT */
9007 #define OP_Ge 80 /* same as TK_GE */
9008 #define OP_Permutation 23
9009 #define OP_Compare 24
9010 #define OP_Jump 25
9011 #define OP_And 69 /* same as TK_AND */
9012 #define OP_Or 68 /* same as TK_OR */
9013 #define OP_Not 19 /* same as TK_NOT */
9014 #define OP_BitNot 93 /* same as TK_BITNOT */
9015 #define OP_Once 26
9016 #define OP_If 27
9017 #define OP_IfNot 28
9018 #define OP_IsNull 73 /* same as TK_ISNULL */
9019 #define OP_NotNull 74 /* same as TK_NOTNULL */
9020 #define OP_Column 29
9021 #define OP_Affinity 30
9022 #define OP_MakeRecord 31
9023 #define OP_Count 32
9024 #define OP_Savepoint 33
9025 #define OP_AutoCommit 34
9026 #define OP_Transaction 35
9027 #define OP_ReadCookie 36
9028 #define OP_SetCookie 37
9029 #define OP_VerifyCookie 38
9030 #define OP_OpenRead 39
9031 #define OP_OpenWrite 40
9032 #define OP_OpenAutoindex 41
9033 #define OP_OpenEphemeral 42
9034 #define OP_SorterOpen 43
9035 #define OP_OpenPseudo 44
9036 #define OP_Close 45
9037 #define OP_SeekLt 46
9038 #define OP_SeekLe 47
9039 #define OP_SeekGe 48
9040 #define OP_SeekGt 49
9041 #define OP_Seek 50
9042 #define OP_NotFound 51
9043 #define OP_Found 52
9044 #define OP_IsUnique 53
9045 #define OP_NotExists 54
9046 #define OP_Sequence 55
9047 #define OP_NewRowid 56
9048 #define OP_Insert 57
9049 #define OP_InsertInt 58
9050 #define OP_Delete 59
9051 #define OP_ResetCount 60
9052 #define OP_SorterCompare 61
9053 #define OP_SorterData 62
9054 #define OP_RowKey 63
9055 #define OP_RowData 64
9056 #define OP_Rowid 65
9057 #define OP_NullRow 66
9058 #define OP_Last 67
9059 #define OP_SorterSort 70
9060 #define OP_Sort 71
9061 #define OP_Rewind 72
9062 #define OP_SorterNext 81
9063 #define OP_Prev 92
9064 #define OP_Next 95
9065 #define OP_SorterInsert 96
9066 #define OP_IdxInsert 97
9067 #define OP_IdxDelete 98
9068 #define OP_IdxRowid 99
9069 #define OP_IdxLT 100
9070 #define OP_IdxGE 101
9071 #define OP_Destroy 102
9072 #define OP_Clear 103
9073 #define OP_CreateIndex 104
9074 #define OP_CreateTable 105
9075 #define OP_ParseSchema 106
9076 #define OP_LoadAnalysis 107
9077 #define OP_DropTable 108
9078 #define OP_DropIndex 109
9079 #define OP_DropTrigger 110
9080 #define OP_IntegrityCk 111
9081 #define OP_RowSetAdd 112
9082 #define OP_RowSetRead 113
9083 #define OP_RowSetTest 114
9084 #define OP_Program 115
9085 #define OP_Param 116
9086 #define OP_FkCounter 117
9087 #define OP_FkIfZero 118
9088 #define OP_MemMax 119
9089 #define OP_IfPos 120
9090 #define OP_IfNeg 121
9091 #define OP_IfZero 122
9092 #define OP_AggStep 123
9093 #define OP_AggFinal 124
9094 #define OP_Checkpoint 125
9095 #define OP_JournalMode 126
9096 #define OP_Vacuum 127
9097 #define OP_IncrVacuum 128
9098 #define OP_Expire 129
9099 #define OP_TableLock 131
9100 #define OP_VBegin 132
9101 #define OP_VCreate 133
9102 #define OP_VDestroy 134
9103 #define OP_VOpen 135
9104 #define OP_VFilter 136
9105 #define OP_VColumn 137
9106 #define OP_VNext 138
9107 #define OP_VRename 139
9108 #define OP_VUpdate 140
9109 #define OP_Pagecount 146
9110 #define OP_MaxPgcnt 147
9111 #define OP_Trace 148
9112 #define OP_Noop 149
9113 #define OP_Explain 150
@@ -9123,28 +9107,28 @@
9123 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9124 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9125 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9126 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9127 #define OPFLG_INITIALIZER {\
9128 /* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9129 /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9130 /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9131 /* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9132 /* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9133 /* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9134 /* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9135 /* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9136 /* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9137 /* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9138 /* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9139 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9140 /* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9141 /* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9142 /* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9143 /* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9144 /* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9145 /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9146 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9147
9148 /************** End of opcodes.h *********************************************/
9149 /************** Continuing where we left off in vdbe.h ***********************/
9150
@@ -9190,11 +9174,11 @@
9190 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
9191 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
9192 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
9193 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
9194 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9195 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
9196 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
9197 #ifndef SQLITE_OMIT_TRACE
9198 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
9199 #endif
9200
@@ -10688,16 +10672,20 @@
10688
10689 /*
10690 ** An instance of the following structure is passed as the first
10691 ** argument to sqlite3VdbeKeyCompare and is used to control the
10692 ** comparison of the two index keys.
 
 
 
 
10693 */
10694 struct KeyInfo {
10695 sqlite3 *db; /* The database connection */
10696 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10697 u16 nField; /* Number of entries in aColl[] */
10698 u8 *aSortOrder; /* Sort order for each column. May be NULL */
10699 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10700 };
10701
10702 /*
10703 ** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
10762 char *zColAff; /* String defining the affinity of each column */
10763 Index *pNext; /* The next index associated with the same table */
10764 Schema *pSchema; /* Schema containing this index */
10765 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
10766 char **azColl; /* Array of collation sequence names for index */
 
10767 int tnum; /* DB Page containing root of this index */
10768 u16 nColumn; /* Number of columns in table used by this index */
10769 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
10770 unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
10771 unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
11242 #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
11243 #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
11244 #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
11245 #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
11246 ** if no other resolution is available */
 
11247
11248 /*
11249 ** An instance of the following structure contains all information
11250 ** needed to generate code for a single SELECT statement.
11251 **
@@ -11296,10 +11286,11 @@
11296 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11297 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11298 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11299 #define SF_Materialize 0x0100 /* Force materialization of views */
11300 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
 
11301
11302
11303 /*
11304 ** The results of a select can be distributed in several ways. The
11305 ** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
11417 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11418 u8 nColCache; /* Number of entries in aColCache[] */
11419 u8 iColCache; /* Next entry in aColCache[] to replace */
11420 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11421 u8 mayAbort; /* True if statement may throw an ABORT exception */
 
11422 int aTempReg[8]; /* Holding area for temporary registers */
11423 int nRangeReg; /* Size of the temporary register block */
11424 int iRangeReg; /* First register in temporary register block */
11425 int nErr; /* Number of errors seen */
11426 int nTab; /* Number of previously allocated VDBE cursors */
11427 int nMem; /* Number of memory cells used so far */
11428 int nSet; /* Number of sets used so far */
11429 int nOnce; /* Number of OP_Once instructions so far */
11430 int ckBase; /* Base register of data during check constraints */
 
11431 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
11432 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
11433 struct yColCache {
11434 int iTable; /* Table cursor number */
11435 int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
12007 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
12008 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
12009 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
12010 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
12011 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12012 Token*, int, int);
12013 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
12014 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
12015 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
12016 Expr*,ExprList*,u16,Expr*,Expr*);
12017 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
12055 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
12056 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
12057 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
12058 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
12059 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12060 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
12061 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
 
12062 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
12063 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
12064 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
12065 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
12066 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
12083 SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
12084 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
12085 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
12086 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
12087 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12088 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);
12089 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
12090 int*,int,int,int,int,int*);
12091 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
12092 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
12093 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
12286 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
12287 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
12288 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
12289 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
12290 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
 
12291 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
12292 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12293 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
12294 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
12295 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
12305 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12306 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12307 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12308 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12309 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 
12310 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12311 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12312 void (*)(sqlite3_context*,int,sqlite3_value **),
12313 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12314 FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
13257 typedef struct VdbeSorter VdbeSorter;
13258
13259 /* Opaque type used by the explainer */
13260 typedef struct Explain Explain;
13261
 
 
 
13262 /*
13263 ** A cursor is a pointer into a single BTree within a database file.
13264 ** The cursor can seek to a BTree entry with a particular key, or
13265 ** loop over all entries of the Btree. You can also insert new BTree
13266 ** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
13443 */
13444 #ifdef SQLITE_DEBUG
13445 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13446 #endif
13447
13448
13449 /* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
13450 ** additional information about auxiliary information bound to arguments
13451 ** of the function. This is used to implement the sqlite3_get_auxdata()
13452 ** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data
13453 ** that can be associated with a constant argument to a function. This
13454 ** allows functions such as "regexp" to compile their constant regular
13455 ** expression argument once and reused the compiled code for multiple
13456 ** invocations.
13457 */
13458 struct VdbeFunc {
13459 FuncDef *pFunc; /* The definition of the function */
13460 int nAux; /* Number of entries allocated for apAux[] */
13461 struct AuxData {
13462 void *pAux; /* Aux data for the i-th argument */
13463 void (*xDelete)(void *); /* Destructor for the aux data */
13464 } apAux[1]; /* One slot for each function argument */
13465 };
13466
13467 /*
13468 ** The "context" argument for a installable function. A pointer to an
13469 ** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
13477 ** This structure is defined inside of vdbeInt.h because it uses substructures
13478 ** (Mem) which are only defined there.
13479 */
13480 struct sqlite3_context {
13481 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
13482 VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */
13483 Mem s; /* The return value is stored here */
13484 Mem *pMem; /* Memory cell used to store aggregate context */
13485 CollSeq *pColl; /* Collating sequence */
13486 int isError; /* Error code returned by the function. */
13487 int skipFlag; /* Skip skip accumulator loading if true */
 
 
13488 };
13489
13490 /*
13491 ** An Explain object accumulates indented output which is helpful
13492 ** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
13581 int nFrame; /* Number of frames in pFrame list */
13582 u32 expmask; /* Binding to these vars invalidates VM */
13583 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13584 int nOnceFlag; /* Size of array aOnceFlag[] */
13585 u8 *aOnceFlag; /* Flags for OP_Once */
 
13586 };
13587
13588 /*
13589 ** The following are allowed values for Vdbe.magic
13590 */
@@ -13604,11 +13601,11 @@
13604 #endif
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13606 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13607 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13608 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13609 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
13610
13611 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13612 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13613 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13614 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
22703 /* Automatically generated. Do not edit */
22704 /* See the mkopcodec.awk script for details. */
22705 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22706 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22707 static const char *const azName[] = { "?",
22708 /* 1 */ "Goto",
22709 /* 2 */ "Gosub",
22710 /* 3 */ "Return",
22711 /* 4 */ "Yield",
22712 /* 5 */ "HaltIfNull",
22713 /* 6 */ "Halt",
22714 /* 7 */ "Integer",
22715 /* 8 */ "Int64",
22716 /* 9 */ "String",
22717 /* 10 */ "Null",
22718 /* 11 */ "Blob",
22719 /* 12 */ "Variable",
22720 /* 13 */ "Move",
22721 /* 14 */ "Copy",
22722 /* 15 */ "SCopy",
22723 /* 16 */ "ResultRow",
22724 /* 17 */ "CollSeq",
22725 /* 18 */ "Function",
22726 /* 19 */ "Not",
22727 /* 20 */ "AddImm",
22728 /* 21 */ "MustBeInt",
22729 /* 22 */ "RealAffinity",
22730 /* 23 */ "Permutation",
22731 /* 24 */ "Compare",
22732 /* 25 */ "Jump",
22733 /* 26 */ "Once",
22734 /* 27 */ "If",
22735 /* 28 */ "IfNot",
22736 /* 29 */ "Column",
22737 /* 30 */ "Affinity",
22738 /* 31 */ "MakeRecord",
22739 /* 32 */ "Count",
22740 /* 33 */ "Savepoint",
22741 /* 34 */ "AutoCommit",
22742 /* 35 */ "Transaction",
22743 /* 36 */ "ReadCookie",
22744 /* 37 */ "SetCookie",
22745 /* 38 */ "VerifyCookie",
22746 /* 39 */ "OpenRead",
22747 /* 40 */ "OpenWrite",
22748 /* 41 */ "OpenAutoindex",
22749 /* 42 */ "OpenEphemeral",
22750 /* 43 */ "SorterOpen",
22751 /* 44 */ "OpenPseudo",
22752 /* 45 */ "Close",
22753 /* 46 */ "SeekLt",
22754 /* 47 */ "SeekLe",
22755 /* 48 */ "SeekGe",
22756 /* 49 */ "SeekGt",
22757 /* 50 */ "Seek",
22758 /* 51 */ "NotFound",
22759 /* 52 */ "Found",
22760 /* 53 */ "IsUnique",
22761 /* 54 */ "NotExists",
22762 /* 55 */ "Sequence",
22763 /* 56 */ "NewRowid",
22764 /* 57 */ "Insert",
22765 /* 58 */ "InsertInt",
22766 /* 59 */ "Delete",
22767 /* 60 */ "ResetCount",
22768 /* 61 */ "SorterCompare",
22769 /* 62 */ "SorterData",
22770 /* 63 */ "RowKey",
22771 /* 64 */ "RowData",
22772 /* 65 */ "Rowid",
22773 /* 66 */ "NullRow",
22774 /* 67 */ "Last",
22775 /* 68 */ "Or",
22776 /* 69 */ "And",
22777 /* 70 */ "SorterSort",
22778 /* 71 */ "Sort",
22779 /* 72 */ "Rewind",
22780 /* 73 */ "IsNull",
22781 /* 74 */ "NotNull",
22782 /* 75 */ "Ne",
22783 /* 76 */ "Eq",
22784 /* 77 */ "Gt",
22785 /* 78 */ "Le",
22786 /* 79 */ "Lt",
22787 /* 80 */ "Ge",
22788 /* 81 */ "SorterNext",
22789 /* 82 */ "BitAnd",
22790 /* 83 */ "BitOr",
22791 /* 84 */ "ShiftLeft",
22792 /* 85 */ "ShiftRight",
22793 /* 86 */ "Add",
@@ -22794,59 +22791,59 @@
22794 /* 87 */ "Subtract",
22795 /* 88 */ "Multiply",
22796 /* 89 */ "Divide",
22797 /* 90 */ "Remainder",
22798 /* 91 */ "Concat",
22799 /* 92 */ "Prev",
22800 /* 93 */ "BitNot",
22801 /* 94 */ "String8",
22802 /* 95 */ "Next",
22803 /* 96 */ "SorterInsert",
22804 /* 97 */ "IdxInsert",
22805 /* 98 */ "IdxDelete",
22806 /* 99 */ "IdxRowid",
22807 /* 100 */ "IdxLT",
22808 /* 101 */ "IdxGE",
22809 /* 102 */ "Destroy",
22810 /* 103 */ "Clear",
22811 /* 104 */ "CreateIndex",
22812 /* 105 */ "CreateTable",
22813 /* 106 */ "ParseSchema",
22814 /* 107 */ "LoadAnalysis",
22815 /* 108 */ "DropTable",
22816 /* 109 */ "DropIndex",
22817 /* 110 */ "DropTrigger",
22818 /* 111 */ "IntegrityCk",
22819 /* 112 */ "RowSetAdd",
22820 /* 113 */ "RowSetRead",
22821 /* 114 */ "RowSetTest",
22822 /* 115 */ "Program",
22823 /* 116 */ "Param",
22824 /* 117 */ "FkCounter",
22825 /* 118 */ "FkIfZero",
22826 /* 119 */ "MemMax",
22827 /* 120 */ "IfPos",
22828 /* 121 */ "IfNeg",
22829 /* 122 */ "IfZero",
22830 /* 123 */ "AggStep",
22831 /* 124 */ "AggFinal",
22832 /* 125 */ "Checkpoint",
22833 /* 126 */ "JournalMode",
22834 /* 127 */ "Vacuum",
22835 /* 128 */ "IncrVacuum",
22836 /* 129 */ "Expire",
22837 /* 130 */ "Real",
22838 /* 131 */ "TableLock",
22839 /* 132 */ "VBegin",
22840 /* 133 */ "VCreate",
22841 /* 134 */ "VDestroy",
22842 /* 135 */ "VOpen",
22843 /* 136 */ "VFilter",
22844 /* 137 */ "VColumn",
22845 /* 138 */ "VNext",
22846 /* 139 */ "VRename",
22847 /* 140 */ "VUpdate",
22848 /* 141 */ "ToText",
22849 /* 142 */ "ToBlob",
22850 /* 143 */ "ToNumeric",
22851 /* 144 */ "ToInt",
22852 /* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
30499 */
30500 #if SQLITE_OS_WIN /* This file is used for Windows only */
30501
30502 #ifdef __CYGWIN__
30503 # include <sys/cygwin.h>
 
30504 #endif
30505
30506 /*
30507 ** Include code that is common to all os_*.c files
30508 */
@@ -30727,19 +30725,19 @@
30727
30728 /*
30729 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30730 ** based on the sub-platform)?
30731 */
30732 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)
30733 # define SQLITE_WIN32_HAS_ANSI
30734 #endif
30735
30736 /*
30737 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30738 ** based on the sub-platform)?
30739 */
30740 #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT || defined(__CYGWIN__)
30741 # define SQLITE_WIN32_HAS_WIDE
30742 #endif
30743
30744 /*
30745 ** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
30919 * zero for the default behavior.
30920 */
30921 #ifndef SQLITE_WIN32_HEAP_FLAGS
30922 # define SQLITE_WIN32_HEAP_FLAGS (0)
30923 #endif
 
30924
30925 /*
30926 ** The winMemData structure stores information required by the Win32-specific
30927 ** sqlite3_mem_methods implementation.
30928 */
@@ -31267,11 +31266,11 @@
31267 { "GetTempPathA", (SYSCALL)0, 0 },
31268 #endif
31269
31270 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
31271
31272 #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
31273 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
31274 #else
31275 { "GetTempPathW", (SYSCALL)0, 0 },
31276 #endif
31277
@@ -34384,14 +34383,14 @@
34384 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34385 osGetCurrentProcessId(), pFd));
34386 return SQLITE_OK;
34387 }
34388 assert( (nMap % winSysInfo.dwPageSize)==0 );
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34391 #else
34392 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
 
 
 
34393 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34394 #endif
34395 if( pNew==NULL ){
34396 osCloseHandle(pFd->hMap);
34397 pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
34556 #endif
34557 /* caller will handle out of memory */
34558 return zConverted;
34559 }
34560
 
 
 
 
 
 
 
 
 
34561 static int winIsDir(const void *zConverted);
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
34582 memset(zTempPath, 0, MAX_PATH+2);
34583
34584 if( sqlite3_temp_directory ){
34585 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34586 }
34587 #if defined(__CYGWIN__)
34588 else{
34589 static const char *azDirs[] = {
34590 0,
@@ -34621,42 +34628,64 @@
34621 if( winIsDir(zWidePath) ){
34622 break;
34623 }
34624 azDirs[i] = ""; /* Don't retry in future call */
34625 }
34626 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34627 }
34628 #elif !SQLITE_OS_WINRT
34629 else if( isNT() ){
34630 char *zMulti;
34631 WCHAR zWidePath[MAX_PATH];
34632 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34633 zMulti = unicodeToUtf8(zWidePath);
34634 if( zMulti ){
34635 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34636 sqlite3_free(zMulti);
34637 }else{
34638 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34639 return SQLITE_IOERR_NOMEM;
34640 }
34641 }
34642 #ifdef SQLITE_WIN32_HAS_ANSI
34643 else{
34644 char *zUtf8;
34645 char zMbcsPath[MAX_PATH];
34646 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34647 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34648 if( zUtf8 ){
34649 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34650 sqlite3_free(zUtf8);
34651 }else{
34652 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34653 return SQLITE_IOERR_NOMEM;
34654 }
34655 }
34656 #endif
34657 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34658
34659 /* Check that the output buffer is large enough for the temporary file
34660 ** name. If it is not, return SQLITE_ERROR.
34661 */
34662 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
34738 int cnt = 0;
34739
34740 /* If argument zPath is a NULL pointer, this function is required to open
34741 ** a temporary file. Use this buffer to store the file name in.
34742 */
34743 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34744
34745 int rc = SQLITE_OK; /* Function Return Code */
34746 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34747 int eType = flags&0xFFFFFF00; /* Type of file to open */
34748 #endif
@@ -34804,12 +34833,11 @@
34804 /* If the second argument to this function is NULL, generate a
34805 ** temporary file name to use
34806 */
34807 if( !zUtf8Name ){
34808 assert(isDelete && !isOpenJournal);
34809 memset(zTmpname, 0, MAX_PATH+2);
34810 rc = getTempname(MAX_PATH+2, zTmpname);
34811 if( rc!=SQLITE_OK ){
34812 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34813 return rc;
34814 }
34815 zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
35236 ){
35237
35238 #if defined(__CYGWIN__)
35239 SimulateIOError( return SQLITE_ERROR );
35240 UNUSED_PARAMETER(nFull);
35241 assert( pVfs->mxPathname>=MAX_PATH );
35242 assert( nFull>=pVfs->mxPathname );
35243 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35244 /*
35245 ** NOTE: We are dealing with a relative path name and the data
35246 ** directory has been set. Therefore, use it as the basis
35247 ** for converting the relative path name to an absolute
35248 ** one by prepending the data directory and a slash.
35249 */
35250 char zOut[MAX_PATH+1];
35251 memset(zOut, 0, MAX_PATH+1);
35252 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35253 MAX_PATH+1);
 
 
 
35254 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35255 sqlite3_data_directory, zOut);
35256 }else{
35257 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35258 }
35259 return SQLITE_OK;
35260 #endif
35261
35262 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
35594 */
35595 SQLITE_API int sqlite3_os_init(void){
35596 static sqlite3_vfs winVfs = {
35597 3, /* iVersion */
35598 sizeof(winFile), /* szOsFile */
35599 MAX_PATH, /* mxPathname */
35600 0, /* pNext */
35601 "win32", /* zName */
35602 0, /* pAppData */
35603 winOpen, /* xOpen */
35604 winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
60219 ** a prior call to sqlite3VdbeMakeLabel().
60220 */
60221 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60222 int j = -1-x;
60223 assert( p->magic==VDBE_MAGIC_INIT );
60224 assert( j>=0 && j<p->nLabel );
60225 if( p->aLabel ){
60226 p->aLabel[j] = p->nOp;
60227 }
60228 }
60229
60230 /*
@@ -60376,44 +60411,64 @@
60376 p->readOnly = 1;
60377 p->bIsReader = 0;
60378 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60379 u8 opcode = pOp->opcode;
60380
60381 pOp->opflags = sqlite3OpcodeProperty[opcode];
60382 if( opcode==OP_Function || opcode==OP_AggStep ){
60383 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60384 }else if( opcode==OP_Transaction ){
60385 if( pOp->p2!=0 ) p->readOnly = 0;
60386 p->bIsReader = 1;
60387 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60388 p->bIsReader = 1;
60389 }else if( opcode==OP_Vacuum
60390 || opcode==OP_JournalMode
 
 
 
 
 
 
 
60391 #ifndef SQLITE_OMIT_WAL
60392 || opcode==OP_Checkpoint
60393 #endif
60394 ){
60395 p->readOnly = 0;
60396 p->bIsReader = 1;
 
 
 
60397 #ifndef SQLITE_OMIT_VIRTUALTABLE
60398 }else if( opcode==OP_VUpdate ){
60399 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60400 }else if( opcode==OP_VFilter ){
60401 int n;
60402 assert( p->nOp - i >= 3 );
60403 assert( pOp[-1].opcode==OP_Integer );
60404 n = pOp[-1].p1;
60405 if( n>nMaxArgs ) nMaxArgs = n;
60406 #endif
60407 }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60408 pOp->p4.xAdvance = sqlite3BtreeNext;
60409 pOp->p4type = P4_ADVANCE;
60410 }else if( opcode==OP_Prev ){
60411 pOp->p4.xAdvance = sqlite3BtreePrevious;
60412 pOp->p4type = P4_ADVANCE;
60413 }
60414
 
 
 
 
 
 
 
 
 
 
60415 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60416 assert( -1-pOp->p2<p->nLabel );
60417 pOp->p2 = aLabel[-1-pOp->p2];
60418 }
60419 }
@@ -60544,12 +60599,11 @@
60544 /*
60545 ** Change the P2 operand of instruction addr so that it points to
60546 ** the address of the next instruction to be coded.
60547 */
60548 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60549 assert( addr>=0 || p->db->mallocFailed );
60550 if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);
60551 }
60552
60553
60554 /*
60555 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
60581 }
60582 case P4_MPRINTF: {
60583 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60584 break;
60585 }
60586 case P4_VDBEFUNC: {
60587 VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
60588 freeEphemeralFunction(db, pVdbeFunc->pFunc);
60589 if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
60590 sqlite3DbFree(db, pVdbeFunc);
60591 break;
60592 }
60593 case P4_FUNCDEF: {
60594 freeEphemeralFunction(db, (FuncDef*)p4);
60595 break;
60596 }
60597 case P4_MEM: {
@@ -60706,24 +60753,17 @@
60706 pOp->p4type = P4_INT32;
60707 }else if( zP4==0 ){
60708 pOp->p4.p = 0;
60709 pOp->p4type = P4_NOTUSED;
60710 }else if( n==P4_KEYINFO ){
60711 KeyInfo *pKeyInfo;
60712 int nField, nByte;
60713
60714 nField = ((KeyInfo*)zP4)->nField;
60715 nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60716 pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60717 pOp->p4.pKeyInfo = pKeyInfo;
60718 if( pKeyInfo ){
60719 u8 *aSortOrder;
60720 memcpy((char*)pKeyInfo, zP4, nByte - nField);
60721 aSortOrder = pKeyInfo->aSortOrder;
60722 assert( aSortOrder!=0 );
60723 pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60724 memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60725 pOp->p4type = P4_KEYINFO;
60726 }else{
60727 p->db->mallocFailed = 1;
60728 pOp->p4type = P4_NOTUSED;
60729 }
@@ -61617,10 +61657,14 @@
61617 while( p->pDelFrame ){
61618 VdbeFrame *pDel = p->pDelFrame;
61619 p->pDelFrame = pDel->pParent;
61620 sqlite3VdbeFrameDelete(pDel);
61621 }
 
 
 
 
61622 }
61623
61624 /*
61625 ** Clean up the VM after execution.
61626 **
@@ -62415,24 +62459,39 @@
62415 sqlite3VdbeDelete(p);
62416 return rc;
62417 }
62418
62419 /*
62420 ** Call the destructor for each auxdata entry in pVdbeFunc for which
62421 ** the corresponding bit in mask is clear. Auxdata entries beyond 31
62422 ** are always destroyed. To destroy all auxdata entries, call this
62423 ** routine with mask==0.
 
 
 
 
 
 
 
 
 
 
62424 */
62425 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
62426 int i;
62427 for(i=0; i<pVdbeFunc->nAux; i++){
62428 struct AuxData *pAux = &pVdbeFunc->apAux[i];
62429 if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){
 
 
62430 if( pAux->xDelete ){
62431 pAux->xDelete(pAux->pAux);
62432 }
62433 pAux->pAux = 0;
 
 
 
62434 }
62435 }
62436 }
62437
62438 /*
@@ -62947,15 +63006,14 @@
62947 */
62948 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
62949 int nKey1, const void *pKey1, /* Left key */
62950 UnpackedRecord *pPKey2 /* Right key */
62951 ){
62952 int d1; /* Offset into aKey[] of next data element */
62953 u32 idx1; /* Offset into aKey[] of next header element */
62954 u32 szHdr1; /* Number of bytes in header */
62955 int i = 0;
62956 int nField;
62957 int rc = 0;
62958 const unsigned char *aKey1 = (const unsigned char *)pKey1;
62959 KeyInfo *pKeyInfo;
62960 Mem mem1;
62961
@@ -62974,32 +63032,42 @@
62974 */
62975 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
62976
62977 idx1 = getVarint32(aKey1, szHdr1);
62978 d1 = szHdr1;
62979 nField = pKeyInfo->nField;
62980 assert( pKeyInfo->aSortOrder!=0 );
62981 while( idx1<szHdr1 && i<pPKey2->nField ){
62982 u32 serial_type1;
62983
62984 /* Read the serial types for the next element in each key. */
62985 idx1 += getVarint32( aKey1+idx1, serial_type1 );
62986 if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;
 
 
 
 
 
 
 
 
 
 
 
62987
62988 /* Extract the values to be compared.
62989 */
62990 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
62991
62992 /* Do the comparison
62993 */
62994 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62995 i<nField ? pKeyInfo->aColl[i] : 0);
62996 if( rc!=0 ){
62997 assert( mem1.zMalloc==0 ); /* See comment below */
62998
62999 /* Invert the result if we are using DESC sort order. */
63000 if( i<nField && pKeyInfo->aSortOrder[i] ){
63001 rc = -rc;
63002 }
63003
63004 /* If the PREFIX_SEARCH flag is set and all fields except the final
63005 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
63210 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63211 ** constants) to the value before returning it.
63212 **
63213 ** The returned value must be freed by the caller using sqlite3ValueFree().
63214 */
63215 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
63216 assert( iVar>0 );
63217 if( v ){
63218 Mem *pMem = &v->aVar[iVar-1];
63219 if( 0==(pMem->flags & MEM_Null) ){
63220 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
63827 /*
63828 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63829 ** the user-function defined by pCtx.
63830 */
63831 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63832 VdbeFunc *pVdbeFunc;
63833
63834 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63835 pVdbeFunc = pCtx->pVdbeFunc;
63836 if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){
63837 return 0;
63838 }
63839 return pVdbeFunc->apAux[iArg].pAux;
 
63840 }
63841
63842 /*
63843 ** Set the auxilary data pointer and delete function, for the iArg'th
63844 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
63848 sqlite3_context *pCtx,
63849 int iArg,
63850 void *pAux,
63851 void (*xDelete)(void*)
63852 ){
63853 struct AuxData *pAuxData;
63854 VdbeFunc *pVdbeFunc;
63855 if( iArg<0 ) goto failed;
63856
63857 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63858 pVdbeFunc = pCtx->pVdbeFunc;
63859 if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
63860 int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
63861 int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
63862 pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);
63863 if( !pVdbeFunc ){
63864 goto failed;
63865 }
63866 pCtx->pVdbeFunc = pVdbeFunc;
63867 memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
63868 pVdbeFunc->nAux = iArg+1;
63869 pVdbeFunc->pFunc = pCtx->pFunc;
63870 }
63871
63872 pAuxData = &pVdbeFunc->apAux[iArg];
63873 if( pAuxData->pAux && pAuxData->xDelete ){
63874 pAuxData->xDelete(pAuxData->pAux);
63875 }
 
63876 pAuxData->pAux = pAux;
63877 pAuxData->xDelete = xDelete;
63878 return;
63879
63880 failed:
@@ -65482,11 +65547,11 @@
65482 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65483 u8 encoding = ENC(db); /* The database encoding */
65484 int iCompare = 0; /* Result of last OP_Compare operation */
65485 unsigned nVmStep = 0; /* Number of virtual machine steps */
65486 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65487 unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
65488 #endif
65489 Mem *aMem = p->aMem; /* Copy of p->aMem */
65490 Mem *pIn1 = 0; /* 1st input operand */
65491 Mem *pIn2 = 0; /* 2nd input operand */
65492 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
65941 assert( p->explain==0 );
65942 p->pResultSet = 0;
65943 db->busyHandler.nBusy = 0;
65944 CHECK_FOR_INTERRUPT;
65945 sqlite3VdbeIOTraceSql(p);
 
 
 
 
 
 
 
 
 
 
 
65946 #ifdef SQLITE_DEBUG
65947 sqlite3BeginBenignMalloc();
65948 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
65949 int i;
65950 printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
66101 ** of VDBE ops have been executed (either since this invocation of
66102 ** sqlite3VdbeExec() or since last time the progress callback was called).
66103 ** If the progress callback returns non-zero, exit the virtual machine with
66104 ** a return code SQLITE_ABORT.
66105 */
66106 if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
66107 int prc;
66108 prc = db->xProgress(db->pProgressArg);
66109 if( prc!=0 ){
66110 rc = SQLITE_INTERRUPT;
66111 goto vdbe_error_halt;
66112 }
66113 nProgressOps = nVmStep;
 
 
66114 }
66115 #endif
66116
66117 break;
66118 }
@@ -66794,23 +66872,18 @@
66794 Deephemeralize(u.ai.pArg);
66795 sqlite3VdbeMemStoreType(u.ai.pArg);
66796 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66797 }
66798
66799 assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
66800 if( pOp->p4type==P4_FUNCDEF ){
66801 u.ai.ctx.pFunc = pOp->p4.pFunc;
66802 u.ai.ctx.pVdbeFunc = 0;
66803 }else{
66804 u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;
66805 u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;
66806 }
66807
66808 u.ai.ctx.s.flags = MEM_Null;
66809 u.ai.ctx.s.db = db;
66810 u.ai.ctx.s.xDel = 0;
66811 u.ai.ctx.s.zMalloc = 0;
 
 
66812
66813 /* The output cell may already have a buffer allocated. Move
66814 ** the pointer to u.ai.ctx.s so in case the user-function can use
66815 ** the already allocated buffer instead of allocating a new one.
66816 */
@@ -66829,15 +66902,11 @@
66829 lastRowid = db->lastRowid;
66830
66831 /* If any auxiliary data functions have been called by this user function,
66832 ** immediately call the destructor for any non-static values.
66833 */
66834 if( u.ai.ctx.pVdbeFunc ){
66835 sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);
66836 pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;
66837 pOp->p4type = P4_VDBEFUNC;
66838 }
66839
66840 if( db->mallocFailed ){
66841 /* Even though a malloc() has failed, the implementation of the
66842 ** user function may have called an sqlite3_result_XXX() function
66843 ** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
74200 /* Translate the schema name in zDb into a pointer to the corresponding
74201 ** schema. If not found, pSchema will remain NULL and nothing will match
74202 ** resulting in an appropriate error message toward the end of this routine
74203 */
74204 if( zDb ){
74205 for(i=0; i<db->nDb; i++){
74206 assert( db->aDb[i].zName );
74207 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74208 pSchema = db->aDb[i].pSchema;
74209 break;
 
 
 
 
 
 
 
 
 
74210 }
74211 }
74212 }
74213
74214 /* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
74481 }
74482 ExprSetProperty(p, EP_Resolved);
74483 }
74484 return p;
74485 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74486
74487 /*
74488 ** This routine is callback for sqlite3WalkExpr().
74489 **
74490 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
74581 FuncDef *pDef; /* Information about the function */
74582 u8 enc = ENC(pParse->db); /* The database encoding */
74583
74584 testcase( pExpr->op==TK_CONST_FUNC );
74585 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
 
74586 zId = pExpr->u.zToken;
74587 nId = sqlite3Strlen30(zId);
74588 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74589 if( pDef==0 ){
74590 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
74646 #endif
74647 case TK_IN: {
74648 testcase( pExpr->op==TK_IN );
74649 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74650 int nRef = pNC->nRef;
74651 #ifndef SQLITE_OMIT_CHECK
74652 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74653 sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints");
74654 }
74655 #endif
74656 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74657 assert( pNC->nRef>=nRef );
74658 if( nRef!=pNC->nRef ){
74659 ExprSetProperty(pExpr, EP_VarSelect);
74660 }
74661 }
74662 break;
74663 }
74664 #ifndef SQLITE_OMIT_CHECK
74665 case TK_VARIABLE: {
74666 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74667 sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints");
74668 }
74669 break;
74670 }
74671 #endif
74672 }
74673 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74674 }
74675
74676 /*
@@ -74757,11 +74863,11 @@
74757 /* Try to match the ORDER BY expression against an expression
74758 ** in the result set. Return an 1-based index of the matching
74759 ** result-set entry.
74760 */
74761 for(i=0; i<pEList->nExpr; i++){
74762 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){
74763 return i+1;
74764 }
74765 }
74766
74767 /* If no match, return 0. */
@@ -74985,11 +75091,11 @@
74985 pItem->iOrderByCol = 0;
74986 if( sqlite3ResolveExprNames(pNC, pE) ){
74987 return 1;
74988 }
74989 for(j=0; j<pSelect->pEList->nExpr; j++){
74990 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){
74991 pItem->iOrderByCol = j+1;
74992 }
74993 }
74994 }
74995 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
75291 w.xSelectCallback = resolveSelectStep;
75292 w.pParse = pParse;
75293 w.u.pNC = pOuterNC;
75294 sqlite3WalkSelect(&w, p);
75295 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75296
75297 /************** End of resolve.c *********************************************/
75298 /************** Begin file expr.c ********************************************/
75299 /*
75300 ** 2001 September 15
@@ -76987,14 +77135,13 @@
76987 #endif
76988
76989 switch( pExpr->op ){
76990 case TK_IN: {
76991 char affinity; /* Affinity of the LHS of the IN */
76992 KeyInfo keyInfo; /* Keyinfo for the generated table */
76993 static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
76994 int addr; /* Address of OP_OpenEphemeral instruction */
76995 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
 
76996
76997 if( rMayHaveNull ){
76998 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
76999 }
77000
@@ -77014,13 +77161,11 @@
77014 ** is used.
77015 */
77016 pExpr->iTable = pParse->nTab++;
77017 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77018 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77019 memset(&keyInfo, 0, sizeof(keyInfo));
77020 keyInfo.nField = 1;
77021 keyInfo.aSortOrder = &sortOrder;
77022
77023 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77024 /* Case 1: expr IN (SELECT ...)
77025 **
77026 ** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
77033 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77034 dest.affSdst = (u8)affinity;
77035 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77036 pExpr->x.pSelect->iLimit = 0;
77037 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
 
77038 return 0;
77039 }
77040 pEList = pExpr->x.pSelect->pEList;
77041 if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77042 keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77043 pEList->a[0].pExpr);
77044 }
77045 }else if( ALWAYS(pExpr->x.pList!=0) ){
77046 /* Case 2: expr IN (exprlist)
77047 **
@@ -77056,12 +77202,13 @@
77056 int r1, r2, r3;
77057
77058 if( !affinity ){
77059 affinity = SQLITE_AFF_NONE;
77060 }
77061 keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77062 keyInfo.aSortOrder = &sortOrder;
 
77063
77064 /* Loop through each expression in <exprlist>. */
77065 r1 = sqlite3GetTempReg(pParse);
77066 r2 = sqlite3GetTempReg(pParse);
77067 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
77096 }
77097 }
77098 sqlite3ReleaseTempReg(pParse, r1);
77099 sqlite3ReleaseTempReg(pParse, r2);
77100 }
77101 if( !isRowid ){
77102 sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77103 }
77104 break;
77105 }
77106
77107 case TK_EXISTS:
@@ -77657,19 +77804,24 @@
77657 break;
77658 }
77659 /* Otherwise, fall thru into the TK_COLUMN case */
77660 }
77661 case TK_COLUMN: {
77662 if( pExpr->iTable<0 ){
77663 /* This only happens when coding check constraints */
77664 assert( pParse->ckBase>0 );
77665 inReg = pExpr->iColumn + pParse->ckBase;
77666 }else{
77667 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77668 pExpr->iColumn, pExpr->iTable, target,
77669 pExpr->op2);
77670 }
 
 
 
 
 
77671 break;
77672 }
77673 case TK_INTEGER: {
77674 codeInteger(pParse, pExpr, 0, target);
77675 break;
@@ -79088,10 +79240,16 @@
79088 ** Do a deep comparison of two expression trees. Return 0 if the two
79089 ** expressions are completely identical. Return 1 if they differ only
79090 ** by a COLLATE operator at the top level. Return 2 if there are differences
79091 ** other than the top-level COLLATE operator.
79092 **
 
 
 
 
 
 
79093 ** Sometimes this routine will return 2 even if the two expressions
79094 ** really are equivalent. If we cannot prove that the expressions are
79095 ** identical, we return 2 just to be safe. So if this routine
79096 ** returns 2, then you do not really know for certain if the two
79097 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
79098 ** can be sure the expressions are the same. In the places where
79099 ** this routine is used, it does not hurt to get an extra 2 - that
79100 ** just might result in some slightly slower code. But returning
79101 ** an incorrect 0 or 1 could lead to a malfunction.
79102 */
79103 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
79104 if( pA==0||pB==0 ){
79105 return pB==pA ? 0 : 2;
79106 }
79107 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79108 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79109 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79110 return 2;
79111 }
79112 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79113 if( pA->op!=pB->op ){
79114 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){
79115 return 1;
79116 }
79117 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){
79118 return 1;
79119 }
79120 return 2;
79121 }
79122 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
79123 if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
79124 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
79125 if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
 
 
 
79126 if( ExprHasProperty(pA, EP_IntValue) ){
79127 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79128 return 2;
79129 }
79130 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
79138
79139 /*
79140 ** Compare two ExprList objects. Return 0 if they are identical and
79141 ** non-zero if they differ in any way.
79142 **
 
 
 
79143 ** This routine might return non-zero for equivalent ExprLists. The
79144 ** only consequence will be disabled optimizations. But this routine
79145 ** must never return 0 if the two ExprList objects are different, or
79146 ** a malfunction will result.
79147 **
79148 ** Two NULL pointers are considered to be the same. But a NULL pointer
79149 ** always differs from a non-NULL pointer.
79150 */
79151 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
79152 int i;
79153 if( pA==0 && pB==0 ) return 0;
79154 if( pA==0 || pB==0 ) return 1;
79155 if( pA->nExpr!=pB->nExpr ) return 1;
79156 for(i=0; i<pA->nExpr; i++){
79157 Expr *pExprA = pA->a[i].pExpr;
79158 Expr *pExprB = pB->a[i].pExpr;
79159 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79160 if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79161 }
79162 return 0;
79163 }
79164
79165 /*
@@ -79340,11 +79543,11 @@
79340 /* Check to see if pExpr is a duplicate of another aggregate
79341 ** function that is already in the pAggInfo structure
79342 */
79343 struct AggInfo_func *pItem = pAggInfo->aFunc;
79344 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79345 if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){
79346 break;
79347 }
79348 }
79349 if( i>=pAggInfo->nFunc ){
79350 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
80757 int i; /* Loop counter */
80758 int topOfLoop; /* The top of the loop */
80759 int endOfLoop; /* The end of the loop */
80760 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80761 int iDb; /* Index of database containing pTab */
 
80762 int regTabname = iMem++; /* Register containing table name */
80763 int regIdxname = iMem++; /* Register containing index name */
80764 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80765 #ifdef SQLITE_ENABLE_STAT3
80766 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
80816 KeyInfo *pKey;
80817 int addrIfNot = 0; /* address of OP_IfNot */
80818 int *aChngAddr; /* Array of jump instruction addresses */
80819
80820 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
 
80821 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
80822 nCol = pIdx->nColumn;
80823 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
80824 if( aChngAddr==0 ) continue;
80825 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
80975 ** If K==0 then no entry is made into the sqlite_stat1 table.
80976 ** If K>0 then it is always the case the D>0 so division by zero
80977 ** is never possible.
80978 */
80979 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
80980 if( jZeroRows<0 ){
80981 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
80982 }
80983 for(i=0; i<nCol; i++){
80984 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
80985 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80986 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
80987 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
80988 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
80989 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
80990 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
80991 }
 
80992 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
80993 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
80994 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
80995 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
 
80996 }
80997
80998 /* If the table has no indices, create a single sqlite_stat1 entry
80999 ** containing NULL as the index name and the row count as the content.
81000 */
81001 if( pTab->pIndex==0 ){
81002 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
81003 VdbeComment((v, "%s", pTab->zName));
81004 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
81005 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
81006 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81007 }else{
81008 sqlite3VdbeJumpHere(v, jZeroRows);
81009 jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);
81010 }
81011 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81012 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81013 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81014 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81015 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81016 if( pParse->nMem<regRec ) pParse->nMem = regRec;
81017 sqlite3VdbeJumpHere(v, jZeroRows);
81018 }
81019
81020
81021 /*
81022 ** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
81195 v = 0;
81196 while( (c=z[0])>='0' && c<='9' ){
81197 v = v*10 + c - '0';
81198 z++;
81199 }
81200 if( i==0 ) pTable->nRowEst = v;
81201 if( pIndex==0 ) break;
 
 
81202 pIndex->aiRowEst[i] = v;
81203 if( *z==' ' ) z++;
81204 if( strcmp(z, "unordered")==0 ){
81205 pIndex->bUnordered = 1;
81206 break;
@@ -82636,10 +82840,11 @@
82636 */
82637 static void freeIndex(sqlite3 *db, Index *p){
82638 #ifndef SQLITE_OMIT_ANALYZE
82639 sqlite3DeleteIndexSamples(db, p);
82640 #endif
 
82641 sqlite3DbFree(db, p->zColAff);
82642 sqlite3DbFree(db, p);
82643 }
82644
82645 /*
@@ -83479,11 +83684,12 @@
83479 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83480 "INTEGER PRIMARY KEY");
83481 #endif
83482 }else{
83483 Index *p;
83484 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
 
83485 if( p ){
83486 p->autoIndex = 2;
83487 }
83488 pList = 0;
83489 }
@@ -83774,30 +83980,11 @@
83774
83775 #ifndef SQLITE_OMIT_CHECK
83776 /* Resolve names in all CHECK constraint expressions.
83777 */
83778 if( p->pCheck ){
83779 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
83780 NameContext sNC; /* Name context for pParse->pNewTable */
83781 ExprList *pList; /* List of all CHECK constraints */
83782 int i; /* Loop counter */
83783
83784 memset(&sNC, 0, sizeof(sNC));
83785 memset(&sSrc, 0, sizeof(sSrc));
83786 sSrc.nSrc = 1;
83787 sSrc.a[0].zName = p->zName;
83788 sSrc.a[0].pTab = p;
83789 sSrc.a[0].iCursor = -1;
83790 sNC.pParse = pParse;
83791 sNC.pSrcList = &sSrc;
83792 sNC.ncFlags = NC_IsCheck;
83793 pList = p->pCheck;
83794 for(i=0; i<pList->nExpr; i++){
83795 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
83796 return;
83797 }
83798 }
83799 }
83800 #endif /* !defined(SQLITE_OMIT_CHECK) */
83801
83802 /* If the db->init.busy is 1 it means we are reading the SQL off the
83803 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
84645 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84646 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84647 int addr1; /* Address of top of loop */
84648 int addr2; /* Address to jump to for next iteration */
84649 int tnum; /* Root page of index */
 
84650 Vdbe *v; /* Generate code into this virtual machine */
84651 KeyInfo *pKey; /* KeyInfo for index */
84652 int regRecord; /* Register holding assemblied index record */
84653 sqlite3 *db = pParse->db; /* The database connection */
84654 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
84684 ** records into the sorter. */
84685 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84686 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84687 regRecord = sqlite3GetTempReg(pParse);
84688
84689 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
84690 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
 
84691 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84692 sqlite3VdbeJumpHere(v, addr1);
84693 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84694 if( pIndex->onError!=OE_None ){
84695 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
84736 Token *pName2, /* Second part of index name. May be NULL */
84737 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84738 ExprList *pList, /* A list of columns to be indexed */
84739 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84740 Token *pStart, /* The CREATE token that begins this statement */
84741 Token *pEnd, /* The ")" that closes the CREATE INDEX statement */
84742 int sortOrder, /* Sort order of primary key when pList==NULL */
84743 int ifNotExist /* Omit error if index already exists */
84744 ){
84745 Index *pRet = 0; /* Pointer to return */
84746 Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
84758 struct ExprList_item *pListItem; /* For looping over pList */
84759 int nCol;
84760 int nExtra = 0;
84761 char *zExtra;
84762
84763 assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
84764 assert( pParse->nErr==0 ); /* Never called with prior errors */
84765 if( db->mallocFailed || IN_DECLARE_VTAB ){
84766 goto exit_create_index;
84767 }
84768 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
84804 assert(0);
84805 }
84806 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84807 assert( db->mallocFailed==0 || pTab==0 );
84808 if( pTab==0 ) goto exit_create_index;
84809 assert( db->aDb[iDb].pSchema==pTab->pSchema );
 
 
 
 
 
84810 }else{
84811 assert( pName==0 );
84812 assert( pStart==0 );
84813 pTab = pParse->pNewTable;
84814 if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
84953 pIndex->nColumn = pList->nExpr;
84954 pIndex->onError = (u8)onError;
84955 pIndex->uniqNotNull = onError==OE_Abort;
84956 pIndex->autoIndex = (u8)(pName==0);
84957 pIndex->pSchema = db->aDb[iDb].pSchema;
 
 
 
 
 
84958 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
84959
84960 /* Check to see if we should honor DESC requests on index columns
84961 */
84962 if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
85108 ** If pTblName==0 it means this index is generated as a primary key
85109 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85110 ** has just been created, it contains no data and the index initialization
85111 ** step can be skipped.
85112 */
85113 else{ /* if( db->init.busy==0 ) */
85114 Vdbe *v;
85115 char *zStmt;
85116 int iMem = ++pParse->nMem;
85117
85118 v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
85126
85127 /* Gather the complete text of the CREATE INDEX statement into
85128 ** the zStmt variable
85129 */
85130 if( pStart ){
85131 assert( pEnd!=0 );
 
85132 /* A named index with an explicit CREATE INDEX statement */
85133 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85134 onError==OE_None ? "" : " UNIQUE",
85135 (int)(pEnd->z - pName->z) + 1,
85136 pName->z);
85137 }else{
85138 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85139 /* zStmt = sqlite3MPrintf(""); */
85140 zStmt = 0;
85141 }
@@ -85187,14 +85384,12 @@
85187 pIndex = 0;
85188 }
85189
85190 /* Clean up before exiting */
85191 exit_create_index:
85192 if( pIndex ){
85193 sqlite3DbFree(db, pIndex->zColAff);
85194 sqlite3DbFree(db, pIndex);
85195 }
85196 sqlite3ExprListDelete(db, pList);
85197 sqlite3SrcListDelete(db, pTblName);
85198 sqlite3DbFree(db, zName);
85199 return pRet;
85200 }
@@ -86068,29 +86263,24 @@
86068 ** the error.
86069 */
86070 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86071 int i;
86072 int nCol = pIdx->nColumn;
86073 int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86074 sqlite3 *db = pParse->db;
86075 KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86076
86077 if( pKey ){
86078 pKey->db = pParse->db;
86079 pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86080 assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86081 for(i=0; i<nCol; i++){
86082 char *zColl = pIdx->azColl[i];
86083 assert( zColl );
86084 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86085 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86086 }
86087 pKey->nField = (u16)nCol;
86088 }
86089
86090 if( pParse->nErr ){
86091 sqlite3DbFree(db, pKey);
86092 pKey = 0;
86093 }
86094 return pKey;
86095 }
86096
@@ -87166,15 +87356,18 @@
87166 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87167 ){
87168 int i;
87169 Index *pIdx;
87170 int r1;
 
 
87171
87172 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87173 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87174 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);
87175 sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);
 
87176 }
87177 }
87178
87179 /*
87180 ** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
87184 **
87185 ** Return a register number which is the first in a block of
87186 ** registers that holds the elements of the index key. The
87187 ** block of registers has already been deallocated by the time
87188 ** this routine returns.
 
 
 
 
 
 
 
87189 */
87190 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87191 Parse *pParse, /* Parsing context */
87192 Index *pIdx, /* The index for which to generate a key */
87193 int iCur, /* Cursor number for the pIdx->pTable table */
87194 int regOut, /* Write the new index key to this register */
87195 int doMakeRec /* Run the OP_MakeRecord instruction if true */
 
87196 ){
87197 Vdbe *v = pParse->pVdbe;
87198 int j;
87199 Table *pTab = pIdx->pTable;
87200 int regBase;
87201 int nCol;
87202
 
 
 
 
 
 
 
 
 
 
87203 nCol = pIdx->nColumn;
87204 regBase = sqlite3GetTempRange(pParse, nCol+1);
87205 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87206 for(j=0; j<nCol; j++){
87207 int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
91561 ** Add the new records to the indices as we go.
91562 */
91563 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91564 int regIdx;
91565 int regR;
 
91566
91567 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
 
 
 
 
 
 
 
 
 
91568
91569 /* Create a key for accessing the index entry */
91570 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91571 for(i=0; i<pIdx->nColumn; i++){
91572 int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
91583
91584 /* Find out what action to take in case there is an indexing conflict */
91585 onError = pIdx->onError;
91586 if( onError==OE_None ){
91587 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
 
91588 continue; /* pIdx is not a UNIQUE index */
91589 }
91590 if( overrideError!=OE_Default ){
91591 onError = overrideError;
91592 }else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
91652 seenReplace = 1;
91653 break;
91654 }
91655 }
91656 sqlite3VdbeJumpHere(v, j3);
 
91657 sqlite3ReleaseTempReg(pParse, regR);
91658 }
91659
91660 if( pbMayReplace ){
91661 *pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
91681 int appendBias, /* True if this is likely to be an append */
91682 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91683 ){
91684 int i;
91685 Vdbe *v;
91686 int nIdx;
91687 Index *pIdx;
91688 u8 pik_flags;
91689 int regData;
91690 int regRec;
91691
91692 v = sqlite3GetVdbe(pParse);
91693 assert( v!=0 );
91694 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91695 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
91696 for(i=nIdx-1; i>=0; i--){
91697 if( aRegIdx[i]==0 ) continue;
 
 
 
91698 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91699 if( useSeekResult ){
91700 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91701 }
91702 }
@@ -91794,10 +92018,11 @@
91794 **
91795 ** * The index is over the same set of columns
91796 ** * The same DESC and ASC markings occurs on all columns
91797 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
91798 ** * The same collating sequence on each column
 
91799 */
91800 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
91801 int i;
91802 assert( pDest && pSrc );
91803 assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
91815 return 0; /* Different sort orders */
91816 }
91817 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
91818 return 0; /* Different collating sequences */
91819 }
 
 
 
91820 }
91821
91822 /* If no test above fails then the indices must be compatible */
91823 return 1;
91824 }
@@ -91971,11 +92199,11 @@
91971 if( pSrcIdx==0 ){
91972 return 0; /* pDestIdx has no corresponding index in pSrc */
91973 }
91974 }
91975 #ifndef SQLITE_OMIT_CHECK
91976 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
91977 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
91978 }
91979 #endif
91980 #ifndef SQLITE_OMIT_FOREIGN_KEY
91981 /* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
94884 cnt++;
94885 }
94886 }
94887
94888 /* Make sure sufficient number of registers have been allocated */
94889 if( pParse->nMem < cnt+4 ){
94890 pParse->nMem = cnt+4;
94891 }
94892
94893 /* Do the b-tree integrity checks */
94894 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
94895 sqlite3VdbeChangeP5(v, (u8)i);
94896 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
94911
94912 if( pTab->pIndex==0 ) continue;
94913 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
94914 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94915 sqlite3VdbeJumpHere(v, addr);
 
94916 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
94917 sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
94918 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
94919 sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
 
 
94920 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94921 int jmp2;
94922 int r1;
94923 static const VdbeOpList idxErr[] = {
94924 { OP_AddImm, 1, -1, 0},
94925 { OP_String8, 0, 3, 0}, /* 1 */
94926 { OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
94931 { OP_Concat, 6, 3, 3},
94932 { OP_ResultRow, 3, 1, 0},
94933 { OP_IfPos, 1, 0, 0}, /* 9 */
94934 { OP_Halt, 0, 0, 0},
94935 };
94936 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
 
94937 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
94938 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
94939 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
94940 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
94941 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
94942 sqlite3VdbeJumpHere(v, addr+9);
94943 sqlite3VdbeJumpHere(v, jmp2);
 
94944 }
94945 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
94946 sqlite3VdbeJumpHere(v, loopTop);
 
 
 
94947 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
94948 static const VdbeOpList cntIdx[] = {
94949 { OP_Integer, 0, 3, 0},
94950 { OP_Rewind, 0, 0, 0}, /* 1 */
94951 { OP_AddImm, 3, 1, 0},
94952 { OP_Next, 0, 0, 0}, /* 3 */
94953 { OP_Eq, 2, 0, 3}, /* 4 */
94954 { OP_AddImm, 1, -1, 0},
94955 { OP_String8, 0, 2, 0}, /* 6 */
94956 { OP_String8, 0, 3, 0}, /* 7 */
94957 { OP_Concat, 3, 2, 2},
94958 { OP_ResultRow, 2, 1, 0},
94959 };
94960 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
94961 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
94962 sqlite3VdbeJumpHere(v, addr);
94963 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
94964 sqlite3VdbeChangeP1(v, addr+1, j+2);
94965 sqlite3VdbeChangeP2(v, addr+1, addr+4);
94966 sqlite3VdbeChangeP1(v, addr+3, j+2);
94967 sqlite3VdbeChangeP2(v, addr+3, addr+2);
94968 sqlite3VdbeJumpHere(v, addr+4);
94969 sqlite3VdbeChangeP4(v, addr+6,
94970 "wrong # of entries in index ", P4_STATIC);
94971 sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
94972 }
94973 }
94974 }
94975 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
94976 sqlite3VdbeChangeP2(v, addr, -mxErr);
94977 sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
96994 */
96995 if( pOrderBy==0 && p->iLimit ){
96996 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
96997 }
96998 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96999
97000 /*
97001 ** Given an expression list, generate a KeyInfo structure that records
97002 ** the collating sequence for each expression in that expression list.
97003 **
@@ -97011,29 +97250,23 @@
97011 ** function is responsible for seeing that this structure is eventually
97012 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97013 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97014 */
97015 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97016 sqlite3 *db = pParse->db;
97017 int nExpr;
97018 KeyInfo *pInfo;
97019 struct ExprList_item *pItem;
 
97020 int i;
97021
97022 nExpr = pList->nExpr;
97023 pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97024 if( pInfo ){
97025 pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97026 pInfo->nField = (u16)nExpr;
97027 pInfo->enc = ENC(db);
97028 pInfo->db = db;
97029 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97030 CollSeq *pColl;
97031 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97032 if( !pColl ){
97033 pColl = db->pDfltColl;
97034 }
97035 pInfo->aColl[i] = pColl;
97036 pInfo->aSortOrder[i] = pItem->sortOrder;
97037 }
97038 }
97039 return pInfo;
@@ -98135,27 +98368,21 @@
98135 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98136 int nCol; /* Number of columns in result set */
98137
98138 assert( p->pRightmost==p );
98139 nCol = p->pEList->nExpr;
98140 pKeyInfo = sqlite3DbMallocZero(db,
98141 sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98142 if( !pKeyInfo ){
98143 rc = SQLITE_NOMEM;
98144 goto multi_select_end;
98145 }
98146
98147 pKeyInfo->enc = ENC(db);
98148 pKeyInfo->nField = (u16)nCol;
98149
98150 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98151 *apColl = multiSelectCollSeq(pParse, p, i);
98152 if( 0==*apColl ){
98153 *apColl = db->pDfltColl;
98154 }
98155 }
98156 pKeyInfo->aSortOrder = (u8*)apColl;
98157
98158 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98159 for(i=0; i<2; i++){
98160 int addr = pLoop->addrOpenEphm[i];
98161 if( addr<0 ){
@@ -98520,16 +98747,12 @@
98520 struct ExprList_item *pItem;
98521 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98522 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98523 aPermute[i] = pItem->iOrderByCol - 1;
98524 }
98525 pKeyMerge =
98526 sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98527 if( pKeyMerge ){
98528 pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98529 pKeyMerge->nField = (u16)nOrderBy;
98530 pKeyMerge->enc = ENC(db);
98531 for(i=0; i<nOrderBy; i++){
98532 CollSeq *pColl;
98533 Expr *pTerm = pOrderBy->a[i].pExpr;
98534 if( pTerm->flags & EP_Collate ){
98535 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
98562 int nExpr = p->pEList->nExpr;
98563 assert( nOrderBy>=nExpr || db->mallocFailed );
98564 regPrev = pParse->nMem+1;
98565 pParse->nMem += nExpr+1;
98566 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98567 pKeyDup = sqlite3DbMallocZero(db,
98568 sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98569 if( pKeyDup ){
98570 pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98571 pKeyDup->nField = (u16)nExpr;
98572 pKeyDup->enc = ENC(db);
98573 for(i=0; i<nExpr; i++){
98574 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98575 pKeyDup->aSortOrder[i] = 0;
98576 }
98577 }
@@ -99833,14 +100052,16 @@
99833 ** and/or pParse->db->mallocFailed.
99834 */
99835 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99836 Walker w;
99837 memset(&w, 0, sizeof(w));
99838 w.xSelectCallback = convertCompoundSelectToSubquery;
99839 w.xExprCallback = exprWalkNoop;
99840 w.pParse = pParse;
99841 sqlite3WalkSelect(&w, pSelect);
 
 
 
99842 w.xSelectCallback = selectExpander;
99843 sqlite3WalkSelect(&w, pSelect);
99844 }
99845
99846
@@ -100370,11 +100591,11 @@
100370 ** will cause elements to come out in the correct order. This is
100371 ** an optimization - the correct answer should result regardless.
100372 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100373 ** to disable this optimization for testing purposes.
100374 */
100375 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
100376 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100377 pOrderBy = 0;
100378 }
100379
100380 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100391 ** used for both the ORDER BY and DISTINCT processing. As originally
100392 ** written the query must use a temp-table for at least one of the ORDER
100393 ** BY and DISTINCT, and an index or separate temp-table for the other.
100394 */
100395 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100396 && sqlite3ExprListCompare(pOrderBy, p->pEList)==0
100397 ){
100398 p->selFlags &= ~SF_Distinct;
100399 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100400 pGroupBy = p->pGroupBy;
100401 pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102618 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102619 if( aRegIdx==0 ) goto update_cleanup;
102620 }
102621 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102622 int reg;
102623 if( hasFK || chngRowid ){
102624 reg = ++pParse->nMem;
102625 }else{
102626 reg = 0;
102627 for(i=0; i<pIdx->nColumn; i++){
102628 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105158 ** the pWC->a[] array.
105159 */
105160 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105161 WhereTerm *pTerm;
105162 int idx;
105163 testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */
105164 if( pWC->nTerm>=pWC->nSlot ){
105165 WhereTerm *pOld = pWC->a;
105166 sqlite3 *db = pWC->pWInfo->pParse->db;
105167 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105168 if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105303
105304 /*
105305 ** Return TRUE if the given operator is one of the operators that is
105306 ** allowed for an indexable WHERE clause term. The allowed operators are
105307 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
105308 **
105309 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
105310 ** of one of the following forms: column = expression column > expression
105311 ** column >= expression column < expression column <= expression
105312 ** expression = column expression > column expression >= column
105313 ** expression < column expression <= column column IN
105314 ** (expression-list) column IN (subquery) column IS NULL
105315 */
105316 static int allowedOp(int op){
105317 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105318 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105319 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105628 op = pRight->op2;
105629 }
105630 if( op==TK_VARIABLE ){
105631 Vdbe *pReprepare = pParse->pReprepare;
105632 int iCol = pRight->iColumn;
105633 pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
105634 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105635 z = (char *)sqlite3_value_text(pVal);
105636 }
105637 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105638 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
105983 }
105984
105985 /* At this point, okToChngToIN is true if original pTerm satisfies
105986 ** case 1. In that case, construct a new virtual term that is
105987 ** pTerm converted into an IN operator.
105988 **
105989 ** EV: R-00211-15100
105990 */
105991 if( okToChngToIN ){
105992 Expr *pDup; /* A transient duplicate expression */
105993 ExprList *pList = 0; /* The RHS of the IN operator */
105994 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106226 ** wildcard. But if we increment '@', that will push it into the
106227 ** alphabetic range where case conversions will mess up the
106228 ** inequality. To avoid this, make sure to also run the full
106229 ** LIKE on all candidate expressions by clearing the isComplete flag
106230 */
106231 if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */
106232
106233
106234 c = sqlite3UpperToLower[c];
106235 }
106236 *pC = c + 1;
106237 }
106238 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106735 VdbeComment((v, "for %s", pTable->zName));
106736
106737 /* Fill the automatic index with content */
106738 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106739 regRecord = sqlite3GetTempReg(pParse);
106740 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
106741 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106742 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106743 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106744 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106745 sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107092 if( pExpr->op==TK_VARIABLE
107093 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107094 ){
107095 int iVar = pExpr->iColumn;
107096 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107097 *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
107098 return SQLITE_OK;
107099 }
107100 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107101 }
107102 #endif
@@ -107318,13 +107528,10 @@
107318 **
107319 ** The t2.z='ok' is disabled in the in (2) because it originates
107320 ** in the ON clause. The term is disabled in (3) because it is not part
107321 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107322 **
107323 ** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
107324 ** completely satisfied by indices.
107325 **
107326 ** Disabling a term causes that term to not be tested in the inner loop
107327 ** of the join. Disabling is an optimization. When terms are satisfied
107328 ** by indices, we disable them to prevent redundant tests in the inner
107329 ** loop. We would get the correct results if nothing were ever disabled,
107330 ** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107550 pTerm = pLoop->aLTerm[j];
107551 assert( pTerm!=0 );
107552 /* The following true for indices with redundant columns.
107553 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107554 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107555 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107556 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107557 if( r1!=regBase+j ){
107558 if( nReg==1 ){
107559 sqlite3ReleaseTempReg(pParse, regBase);
107560 regBase = r1;
@@ -107750,10 +107957,11 @@
107750 WhereLevel *pLevel; /* The where level to be coded */
107751 WhereLoop *pLoop; /* The WhereLoop object being coded */
107752 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107753 WhereTerm *pTerm; /* A WHERE clause term */
107754 Parse *pParse; /* Parsing context */
 
107755 Vdbe *v; /* The prepared stmt under constructions */
107756 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107757 int addrBrk; /* Jump here to break out of the loop */
107758 int addrCont; /* Jump here to continue with next cycle */
107759 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107761 Bitmask newNotReady; /* Return value */
107762
107763 pParse = pWInfo->pParse;
107764 v = pParse->pVdbe;
107765 pWC = &pWInfo->sWC;
 
107766 pLevel = &pWInfo->a[iLevel];
107767 pLoop = pLevel->pWLoop;
107768 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107769 iCur = pTabItem->iCursor;
107770 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
107859 iReleaseReg = sqlite3GetTempReg(pParse);
107860 pTerm = pLoop->aLTerm[0];
107861 assert( pTerm!=0 );
107862 assert( pTerm->pExpr!=0 );
107863 assert( omitTable==0 );
107864 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107865 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
107866 addrNxt = pLevel->addrNxt;
107867 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107868 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107869 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
107907 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
107908 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
107909 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
107910
107911 assert( (pStart->wtFlags & TERM_VNULL)==0 );
107912 testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107913 pX = pStart->pExpr;
107914 assert( pX!=0 );
107915 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
107916 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
107917 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
107926 Expr *pX;
107927 pX = pEnd->pExpr;
107928 assert( pX!=0 );
107929 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
107930 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
107931 testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107932 memEndValue = ++pParse->nMem;
107933 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
107934 if( pX->op==TK_LT || pX->op==TK_GT ){
107935 testOp = bRev ? OP_Le : OP_Ge;
107936 }else{
@@ -108051,11 +108260,11 @@
108051 /* Generate code to evaluate all constraint terms using == or IN
108052 ** and store the values of those terms in an array of registers
108053 ** starting at regBase.
108054 */
108055 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108056 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108057 addrNxt = pLevel->addrNxt;
108058
108059 /* If we are doing a reverse order scan on an ascending index, or
108060 ** a forward order scan on a descending index, interchange the
108061 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108092 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108093 zStartAff[nEq] = SQLITE_AFF_NONE;
108094 }
108095 }
108096 nConstraint++;
108097 testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108098 }else if( isMinQuery ){
108099 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108100 nConstraint++;
108101 startEq = 0;
108102 start_constraints = 1;
@@ -108134,14 +108343,14 @@
108134 zEndAff[nEq] = SQLITE_AFF_NONE;
108135 }
108136 }
108137 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108138 nConstraint++;
108139 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108140 }
108141 sqlite3DbFree(pParse->db, zStartAff);
108142 sqlite3DbFree(pParse->db, zEndAff);
108143
108144 /* Top of the loop body */
108145 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108146
108147 /* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108264 */
108265 if( pWInfo->nLevel>1 ){
108266 int nNotReady; /* The number of notReady tables */
108267 struct SrcList_item *origSrc; /* Original list of tables */
108268 nNotReady = pWInfo->nLevel - iLevel - 1;
108269 pOrTab = sqlite3StackAllocRaw(pParse->db,
108270 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108271 if( pOrTab==0 ) return notReady;
108272 pOrTab->nAlloc = (u8)(nNotReady + 1);
108273 pOrTab->nSrc = pOrTab->nAlloc;
108274 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108318 Expr *pExpr = pWC->a[iTerm].pExpr;
108319 if( &pWC->a[iTerm] == pTerm ) continue;
108320 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108321 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108322 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108323 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108324 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108325 }
108326 if( pAndExpr ){
108327 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108328 }
108329 }
@@ -108339,11 +108548,11 @@
108339 }
108340 /* Loop through table entries that match term pOrTerm. */
108341 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108342 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108343 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108344 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108345 if( pSubWInfo ){
108346 WhereLoop *pSubLoop;
108347 explainOneScan(
108348 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108349 );
@@ -108394,17 +108603,17 @@
108394 }
108395 pLevel->u.pCovidx = pCov;
108396 if( pCov ) pLevel->iIdxCur = iCovCur;
108397 if( pAndExpr ){
108398 pAndExpr->pLeft = 0;
108399 sqlite3ExprDelete(pParse->db, pAndExpr);
108400 }
108401 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108402 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108403 sqlite3VdbeResolveLabel(v, iLoopBody);
108404
108405 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108406 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108407 }else
108408 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108409
108410 {
@@ -108421,18 +108630,14 @@
108421 }
108422 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108423
108424 /* Insert code to test every subexpression that can be completely
108425 ** computed using the current set of tables.
108426 **
108427 ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
108428 ** the use of indices become tests that are evaluated against each row of
108429 ** the relevant input tables.
108430 */
108431 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108432 Expr *pE;
108433 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108434 testcase( pTerm->wtFlags & TERM_CODED );
108435 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108436 if( (pTerm->prereqAll & newNotReady)!=0 ){
108437 testcase( pWInfo->untestedTerms==0
108438 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108455 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108456 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108457 ** the implied "t1.a=123" constraint.
108458 */
108459 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108460 Expr *pE;
108461 WhereTerm *pAlt;
108462 Expr sEq;
108463 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108464 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108465 if( pTerm->leftCursor!=iCur ) continue;
108466 if( pLevel->iLeftJoin ) continue;
108467 pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108471 if( pAlt==0 ) continue;
108472 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108473 testcase( pAlt->eOperator & WO_EQ );
108474 testcase( pAlt->eOperator & WO_IN );
108475 VdbeNoopComment((v, "begin transitive constraint"));
108476 sEq = *pAlt->pExpr;
108477 sEq.pLeft = pE->pLeft;
108478 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108479 }
108480
108481 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108482 ** at least one row of the right table has matched the left table.
108483 */
@@ -108485,11 +108693,11 @@
108485 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108486 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108487 VdbeComment((v, "record LEFT JOIN hit"));
108488 sqlite3ExprCacheClear(pParse);
108489 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108490 testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
108491 testcase( pTerm->wtFlags & TERM_CODED );
108492 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108493 if( (pTerm->prereqAll & newNotReady)!=0 ){
108494 assert( pWInfo->untestedTerms );
108495 continue;
@@ -108926,11 +109134,12 @@
108926 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
108927 }else if( (pTerm->eOperator & WO_IN)
108928 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
108929 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
108930 }
108931 if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
 
108932 }
108933 #endif
108934 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
108935 /* Each row involves a step of the index, then a binary search of
108936 ** the main table */
@@ -108998,10 +109207,21 @@
108998 if( x<BMS-1 ) m |= MASKBIT(x);
108999 }
109000 return m;
109001 }
109002
 
 
 
 
 
 
 
 
 
 
 
109003
109004 /*
109005 ** Add all WhereLoop objects for a single table of the join where the table
109006 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109007 ** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109021 int rc = SQLITE_OK; /* Return code */
109022 int iSortIdx = 1; /* Index number */
109023 int b; /* A boolean value */
109024 WhereCost rSize; /* number of rows in the table */
109025 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
 
109026
109027 pNew = pBuilder->pNew;
109028 pWInfo = pBuilder->pWInfo;
109029 pTabList = pWInfo->pTabList;
109030 pSrc = pTabList->a + pNew->iTab;
 
109031 assert( !IsVirtual(pSrc->pTab) );
109032
109033 if( pSrc->pIndex ){
109034 /* An INDEXED BY clause specifies a particular index to use */
109035 pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109065 && !pSrc->viaCoroutine
109066 && !pSrc->notIndexed
109067 && !pSrc->isCorrelated
109068 ){
109069 /* Generate auto-index WhereLoops */
109070 WhereClause *pWC = pBuilder->pWC;
109071 WhereTerm *pTerm;
109072 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109073 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109074 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109075 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109095 }
109096
109097 /* Loop over all indices
109098 */
109099 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
 
 
 
 
109100 pNew->u.btree.nEq = 0;
109101 pNew->nLTerm = 0;
109102 pNew->iSortIdx = 0;
109103 pNew->rSetup = 0;
109104 pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110035 pLoop->u.btree.nEq = 1;
110036 /* TUNING: Cost of a rowid lookup is 10 */
110037 pLoop->rRun = 33; /* 33==whereCost(10) */
110038 }else{
110039 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110040 if( pIdx->onError==OE_None ) continue;
110041 for(j=0; j<pIdx->nColumn; j++){
110042 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110043 if( pTerm==0 ) break;
110044 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110045 pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110241 ** subexpression is separated by an AND operator.
110242 */
110243 initMaskSet(pMaskSet);
110244 whereClauseInit(&pWInfo->sWC, pWInfo);
110245 sqlite3ExprCodeConstants(pParse, pWhere);
110246 whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */
110247 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110248
110249 /* Special case: a WHERE clause that is constant. Evaluate the
110250 ** expression and either jump over all of the code or fall thru.
110251 */
@@ -110875,11 +111100,11 @@
110875 #endif
110876 #define sqlite3ParserARG_SDECL Parse *pParse;
110877 #define sqlite3ParserARG_PDECL ,Parse *pParse
110878 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
110879 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
110880 #define YYNSTATE 627
110881 #define YYNRULE 327
110882 #define YYFALLBACK 1
110883 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
110884 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
110885 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
110948 ** shifting non-terminals after a reduce.
110949 ** yy_default[] Default action for each state.
110950 */
110951 #define YY_ACTTAB_COUNT (1564)
110952 static const YYACTIONTYPE yy_action[] = {
110953 /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56,
110954 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
110955 /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234,
110956 /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54,
110957 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57,
110958 /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110959 /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52,
110960 /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194,
110961 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110962 /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376,
110963 /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59,
110964 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
110965 /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580,
110966 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
110967 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223,
110968 /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168,
110969 /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438,
110970 /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581,
110971 /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439,
110972 /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48,
110973 /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
110974 /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
110975 /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385,
110976 /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262,
110977 /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568,
110978 /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380,
110979 /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592,
110980 /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55,
110981 /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53,
110982 /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616,
110983 /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548,
110984 /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618,
110985 /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598,
110986 /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512,
110987 /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578,
110988 /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54,
110989 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
110990 /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617,
110991 /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619,
110992 /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489,
110993 /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469,
110994 /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57,
110995 /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
110996 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
110997 /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576,
110998 /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504,
110999 /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181,
111000 /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561,
111001 /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598,
111002 /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580,
111003 /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54,
111004 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327,
111005 /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248,
111006 /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557,
111007 /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581,
111008 /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69,
111009 /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48,
111010 /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111011 /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111012 /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597,
111013 /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613,
111014 /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47,
111015 /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555,
111016 /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423,
111017 /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55,
111018 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111019 /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260,
111020 /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420,
111021 /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594,
111022 /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598,
111023 /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50,
111024 /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578,
111025 /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111026 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111027 /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362,
111028 /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412,
111029 /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412,
111030 /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521,
111031 /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57,
111032 /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111033 /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52,
111034 /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50,
111035 /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337,
111036 /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98,
111037 /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618,
111038 /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93,
111039 /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580,
111040 /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54,
111041 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409,
111042 /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598,
111043 /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228,
111044 /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581,
111045 /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136,
111046 /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48,
111047 /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56,
111048 /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111049 /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597,
111050 /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618,
111051 /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598,
111052 /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598,
111053 /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597,
111054 /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55,
111055 /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53,
111056 /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412,
111057 /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370,
111058 /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618,
111059 /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618,
111060 /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85,
111061 /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578,
111062 /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54,
111063 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111064 /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591,
111065 /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412,
111066 /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412,
111067 /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257,
111068 /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447,
111069 /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56,
111070 /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52,
111071 /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459,
111072 /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348,
111073 /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618,
111074 /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412,
111075 /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216,
111076 /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618,
111077 /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123,
111078 /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411,
111079 /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598,
111080 /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598,
111081 /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597,
111082 /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13,
111083 /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3,
111084 /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590,
111085 /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34,
111086 /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330,
111087 /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79,
111088 /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610,
111089 /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235,
111090 /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618,
111091 /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61,
111092 /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618,
111093 /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31,
111094 /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589,
111095 /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299,
111096 /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590,
111097 /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533,
111098 /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240,
111099 /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486,
111100 /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371,
111101 /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476,
111102 /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116,
111103 /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111,
111104 /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606,
111105 /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570,
111106 /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302,
111107 /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444,
111108 /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399,
111109 /* 1560 */ 295, 498, 956, 488,
111110 };
111111 static const YYCODETYPE yy_lookahead[] = {
111112 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111113 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111114 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111256 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111257 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111258 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111259 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111260 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111261 /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22,
111262 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111263 /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153,
111264 /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230,
111265 /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148,
111266 /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199,
111267 /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191,
111268 /* 1560 */ 195, 182, 250, 186,
111269 };
111270 #define YY_SHIFT_USE_DFLT (-70)
111271 #define YY_SHIFT_COUNT (416)
111272 #define YY_SHIFT_MIN (-69)
111273 #define YY_SHIFT_MAX (1487)
111274 static const short yy_shift_ofst[] = {
111275 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111276 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111283 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111284 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111285 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111286 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111287 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111288 /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57,
111289 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111290 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111291 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111292 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111293 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111294 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111295 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111296 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111297 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111298 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308,
111299 /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,
111300 /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,
111301 /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,
111302 /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,
111303 /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,
111304 /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,
111305 /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013,
111306 /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667,
111307 /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300,
111308 /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,
111309 /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,
111310 /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,
111311 /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057,
111312 /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955,
111313 /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747,
111314 /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579,
111315 /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120,
111316 /* 410 */ 92, 75, 45, 114, 25, 11, 5,
111317 };
111318 #define YY_REDUCE_USE_DFLT (-169)
111319 #define YY_REDUCE_COUNT (308)
111320 #define YY_REDUCE_MIN (-168)
111321 #define YY_REDUCE_MAX (1391)
111322 static const short yy_reduce_ofst[] = {
111323 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111324 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111325 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111326 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111337 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111338 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111339 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111340 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111341 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111342 /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,
111343 /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,
111344 /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,
111345 /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,
111346 /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,
111347 /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,
111348 /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,
111349 /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,
111350 /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,
111351 /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,
111352 /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,
111353 /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111354 };
111355 static const YYACTIONTYPE yy_default[] = {
111356 /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756,
111357 /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954,
111358 /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111359 /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111360 /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111361 /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111362 /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790,
111363 /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929,
111364 /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861,
111365 /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843,
111366 /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954,
111367 /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111368 /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954,
111369 /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663,
111370 /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111371 /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954,
111372 /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111373 /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111374 /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760,
111375 /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111376 /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737,
111377 /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794,
111378 /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773,
111379 /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764,
111380 /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736,
111381 /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904,
111382 /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727,
111383 /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727,
111384 /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954,
111385 /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637,
111386 /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954,
111387 /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954,
111388 /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633,
111389 /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954,
111390 /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916,
111391 /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954,
111392 /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954,
111393 /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111394 /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954,
111395 /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954,
111396 /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954,
111397 /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950,
111398 /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935,
111399 /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886,
111400 /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735,
111401 /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914,
111402 /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657,
111403 /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662,
111404 /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664,
111405 /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702,
111406 /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691,
111407 /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728,
111408 /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854,
111409 /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776,
111410 /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781,
111411 /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921,
111412 /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894,
111413 /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848,
111414 /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819,
111415 /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747,
111416 /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651,
111417 /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
111418 /* 620 */ 665, 639, 636, 635, 631, 630, 628,
111419 };
111420
111421 /* The next table maps tokens into fallback tokens. If a construct
111422 ** like the following:
111423 **
@@ -111885,11 +112110,11 @@
111885 /* 237 */ "case_operand ::=",
111886 /* 238 */ "exprlist ::= nexprlist",
111887 /* 239 */ "exprlist ::=",
111888 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
111889 /* 241 */ "nexprlist ::= expr",
111890 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
111891 /* 243 */ "uniqueflag ::= UNIQUE",
111892 /* 244 */ "uniqueflag ::=",
111893 /* 245 */ "idxlist_opt ::=",
111894 /* 246 */ "idxlist_opt ::= LP idxlist RP",
111895 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112604 { 224, 0 },
112605 { 220, 1 },
112606 { 220, 0 },
112607 { 215, 3 },
112608 { 215, 1 },
112609 { 147, 11 },
112610 { 227, 1 },
112611 { 227, 0 },
112612 { 178, 0 },
112613 { 178, 3 },
112614 { 187, 5 },
@@ -113046,10 +113271,11 @@
113046 case 114: /* select ::= select multiselect_op oneselect */
113047 {
113048 if( yymsp[0].minor.yy159 ){
113049 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113050 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
 
113051 }else{
113052 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113053 }
113054 yygotominor.yy159 = yymsp[0].minor.yy159;
113055 }
@@ -113608,15 +113834,15 @@
113608 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113609 break;
113610 case 241: /* nexprlist ::= expr */
113611 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113612 break;
113613 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
113614 {
113615 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
113616 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
113617 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
113618 }
113619 break;
113620 case 243: /* uniqueflag ::= UNIQUE */
113621 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113622 {yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114538 *tokenType = TK_SPACE;
114539 return i;
114540 }
114541 case '-': {
114542 if( z[1]=='-' ){
114543 /* IMP: R-50417-27976 -- syntax diagram for comments */
114544 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114545 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114546 return i;
114547 }
114548 *tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114571 case '/': {
114572 if( z[1]!='*' || z[2]==0 ){
114573 *tokenType = TK_SLASH;
114574 return 1;
114575 }
114576 /* IMP: R-50417-27976 -- syntax diagram for comments */
114577 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114578 if( c ) i++;
114579 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114580 return i;
114581 }
@@ -116416,10 +116640,11 @@
116416 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116417 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116418 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116419 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116420 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116421 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116422 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116423 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116424 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116425 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117771 db->autoCommit = 1;
117772 db->nextAutovac = -1;
117773 db->szMmap = sqlite3GlobalConfig.szMmap;
117774 db->nextPagesize = 0;
117775 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117776 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117777 | SQLITE_AutoIndex
117778 #endif
117779 #if SQLITE_DEFAULT_FILE_FORMAT<4
117780 | SQLITE_LegacyFileFmt
117781 #endif
@@ -128244,11 +128469,11 @@
128244 }
128245
128246
128247 #ifdef SQLITE_TEST
128248
128249 /* #include <tcl.h> */
128250 /* #include <string.h> */
128251
128252 /*
128253 ** Implementation of a special SQL scalar function for testing tokenizers
128254 ** designed to be used in concert with the Tcl testing framework. This
128255
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
 
 
 
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
408 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -670,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1039,10 +1025,11 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -3122,11 +3109,12 @@
3109 ** interface is to keep a GUI updated during a large query.
3110 **
3111 ** ^The parameter P is passed through as the only parameter to the
3112 ** callback function X. ^The parameter N is the approximate number of
3113 ** [virtual machine instructions] that are evaluated between successive
3114 ** invocations of the callback X. ^If N is less than one then the progress
3115 ** handler is disabled.
3116 **
3117 ** ^Only a single progress handler may be defined at one time per
3118 ** [database connection]; setting a new progress handler cancels the
3119 ** old one. ^Setting parameter X to NULL disables the progress handler.
3120 ** ^The progress handler is also disabled by setting N to a value less
@@ -4742,50 +4730,49 @@
4730 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4731
4732 /*
4733 ** CAPI3REF: Function Auxiliary Data
4734 **
4735 ** These functions may be used by (non-aggregate) SQL functions to
4736 ** associate metadata with argument values. If the same value is passed to
4737 ** multiple invocations of the same SQL function during query execution, under
4738 ** some circumstances the associated metadata may be preserved. An example
4739 ** of where this might be useful is in a regular-expression matching
4740 ** function. The compiled version of the regular expression can be stored as
4741 ** metadata associated with the pattern string.
4742 ** Then as long as the pattern string remains the same,
4743 ** the compiled regular expression can be reused on multiple
4744 ** invocations of the same function.
4745 **
4746 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4747 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4748 ** value to the application-defined function. ^If there is no metadata
4749 ** associated with the function argument, this sqlite3_get_auxdata() interface
4750 ** returns a NULL pointer.
 
4751 **
4752 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4753 ** argument of the application-defined function. ^Subsequent
4754 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4755 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4756 ** NULL if the metadata has been discarded.
4757 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4758 ** SQLite will invoke the destructor function X with parameter P exactly
4759 ** once, when the metadata is discarded.
4760 ** SQLite is free to discard the metadata at any time, including: <ul>
4761 ** <li> when the corresponding function parameter changes, or
4762 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4763 ** SQL statement, or
4764 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4765 ** <li> during the original sqlite3_set_auxdata() call when a memory
4766 ** allocation error occurs. </ul>)^
4767 **
4768 ** Note the last bullet in particular. The destructor X in
4769 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4770 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4771 ** should be called near the end of the function implementation and the
4772 ** function implementation should not make any use of P after
4773 ** sqlite3_set_auxdata() has been called.
4774 **
4775 ** ^(In practice, metadata is preserved between function calls for
4776 ** function parameters that are compile-time constants, including literal
4777 ** values and [parameters] and expressions composed from the same.)^
4778 **
@@ -6829,13 +6816,13 @@
6816 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6817 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6818 ** </dd>
6819 **
6820 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6821 ** <dd>This parameter returns zero for the current value if and only if
6822 ** all foreign key constraints (deferred or immediate) have been
6823 ** resolved.)^ ^The highwater mark is always 0.
6824 ** </dd>
6825 ** </dl>
6826 */
6827 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6828 #define SQLITE_DBSTATUS_CACHE_USED 1
@@ -8824,11 +8811,10 @@
8811
8812 /*
8813 ** The names of the following types declared in vdbeInt.h are required
8814 ** for the VdbeOp definition.
8815 */
 
8816 typedef struct Mem Mem;
8817 typedef struct SubProgram SubProgram;
8818
8819 /*
8820 ** A single instruction of the virtual machine has an opcode
@@ -8848,11 +8834,10 @@
8834 void *p; /* Generic pointer */
8835 char *z; /* Pointer to data for string (char array) types */
8836 i64 *pI64; /* Used when p4type is P4_INT64 */
8837 double *pReal; /* Used when p4type is P4_REAL */
8838 FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */
 
8839 CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */
8840 Mem *pMem; /* Used when p4type is P4_MEM */
8841 VTable *pVtab; /* Used when p4type is P4_VTAB */
8842 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
8843 int *ai; /* Used when p4type is P4_INTARRAY */
@@ -8902,11 +8887,10 @@
8887 #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */
8888 #define P4_STATIC (-2) /* Pointer to a static string */
8889 #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */
8890 #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */
8891 #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */
 
8892 #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */
8893 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
8894 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8895 #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */
8896 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
@@ -8959,155 +8943,155 @@
8943 */
8944 /************** Include opcodes.h in the middle of vdbe.h ********************/
8945 /************** Begin file opcodes.h *****************************************/
8946 /* Automatically generated. Do not edit */
8947 /* See the mkopcodeh.awk script for details */
8948 #define OP_Function 1
8949 #define OP_Savepoint 2
8950 #define OP_AutoCommit 3
8951 #define OP_Transaction 4
8952 #define OP_SorterNext 5
8953 #define OP_Prev 6
8954 #define OP_Next 7
8955 #define OP_AggStep 8
8956 #define OP_Checkpoint 9
8957 #define OP_JournalMode 10
8958 #define OP_Vacuum 11
8959 #define OP_VFilter 12
8960 #define OP_VUpdate 13
8961 #define OP_Goto 14
8962 #define OP_Gosub 15
8963 #define OP_Return 16
8964 #define OP_Yield 17
8965 #define OP_HaltIfNull 18
8966 #define OP_Not 19 /* same as TK_NOT */
8967 #define OP_Halt 20
8968 #define OP_Integer 21
8969 #define OP_Int64 22
8970 #define OP_String 23
8971 #define OP_Null 24
8972 #define OP_Blob 25
8973 #define OP_Variable 26
8974 #define OP_Move 27
8975 #define OP_Copy 28
8976 #define OP_SCopy 29
8977 #define OP_ResultRow 30
8978 #define OP_CollSeq 31
8979 #define OP_AddImm 32
8980 #define OP_MustBeInt 33
8981 #define OP_RealAffinity 34
8982 #define OP_Permutation 35
8983 #define OP_Compare 36
8984 #define OP_Jump 37
8985 #define OP_Once 38
8986 #define OP_If 39
8987 #define OP_IfNot 40
8988 #define OP_Column 41
8989 #define OP_Affinity 42
8990 #define OP_MakeRecord 43
8991 #define OP_Count 44
8992 #define OP_ReadCookie 45
8993 #define OP_SetCookie 46
8994 #define OP_VerifyCookie 47
8995 #define OP_OpenRead 48
8996 #define OP_OpenWrite 49
8997 #define OP_OpenAutoindex 50
8998 #define OP_OpenEphemeral 51
8999 #define OP_SorterOpen 52
9000 #define OP_OpenPseudo 53
9001 #define OP_Close 54
9002 #define OP_SeekLt 55
9003 #define OP_SeekLe 56
9004 #define OP_SeekGe 57
9005 #define OP_SeekGt 58
9006 #define OP_Seek 59
9007 #define OP_NotFound 60
9008 #define OP_Found 61
9009 #define OP_IsUnique 62
9010 #define OP_NotExists 63
9011 #define OP_Sequence 64
9012 #define OP_NewRowid 65
9013 #define OP_Insert 66
9014 #define OP_InsertInt 67
9015 #define OP_Or 68 /* same as TK_OR */
9016 #define OP_And 69 /* same as TK_AND */
9017 #define OP_Delete 70
9018 #define OP_ResetCount 71
9019 #define OP_SorterCompare 72
9020 #define OP_IsNull 73 /* same as TK_ISNULL */
9021 #define OP_NotNull 74 /* same as TK_NOTNULL */
9022 #define OP_Ne 75 /* same as TK_NE */
9023 #define OP_Eq 76 /* same as TK_EQ */
9024 #define OP_Gt 77 /* same as TK_GT */
9025 #define OP_Le 78 /* same as TK_LE */
9026 #define OP_Lt 79 /* same as TK_LT */
9027 #define OP_Ge 80 /* same as TK_GE */
9028 #define OP_SorterData 81
9029 #define OP_BitAnd 82 /* same as TK_BITAND */
9030 #define OP_BitOr 83 /* same as TK_BITOR */
9031 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
9033 #define OP_Add 86 /* same as TK_PLUS */
9034 #define OP_Subtract 87 /* same as TK_MINUS */
9035 #define OP_Multiply 88 /* same as TK_STAR */
9036 #define OP_Divide 89 /* same as TK_SLASH */
9037 #define OP_Remainder 90 /* same as TK_REM */
9038 #define OP_Concat 91 /* same as TK_CONCAT */
9039 #define OP_RowKey 92
9040 #define OP_BitNot 93 /* same as TK_BITNOT */
9041 #define OP_String8 94 /* same as TK_STRING */
9042 #define OP_RowData 95
9043 #define OP_Rowid 96
9044 #define OP_NullRow 97
9045 #define OP_Last 98
9046 #define OP_SorterSort 99
9047 #define OP_Sort 100
9048 #define OP_Rewind 101
9049 #define OP_SorterInsert 102
9050 #define OP_IdxInsert 103
9051 #define OP_IdxDelete 104
9052 #define OP_IdxRowid 105
9053 #define OP_IdxLT 106
9054 #define OP_IdxGE 107
9055 #define OP_Destroy 108
9056 #define OP_Clear 109
9057 #define OP_CreateIndex 110
9058 #define OP_CreateTable 111
9059 #define OP_ParseSchema 112
9060 #define OP_LoadAnalysis 113
9061 #define OP_DropTable 114
9062 #define OP_DropIndex 115
9063 #define OP_DropTrigger 116
9064 #define OP_IntegrityCk 117
9065 #define OP_RowSetAdd 118
9066 #define OP_RowSetRead 119
9067 #define OP_RowSetTest 120
9068 #define OP_Program 121
9069 #define OP_Param 122
9070 #define OP_FkCounter 123
9071 #define OP_FkIfZero 124
9072 #define OP_MemMax 125
9073 #define OP_IfPos 126
9074 #define OP_IfNeg 127
9075 #define OP_IfZero 128
9076 #define OP_AggFinal 129
9077 #define OP_Real 130 /* same as TK_FLOAT */
9078 #define OP_IncrVacuum 131
9079 #define OP_Expire 132
9080 #define OP_TableLock 133
9081 #define OP_VBegin 134
9082 #define OP_VCreate 135
9083 #define OP_VDestroy 136
9084 #define OP_VOpen 137
9085 #define OP_VColumn 138
9086 #define OP_VNext 139
9087 #define OP_VRename 140
9088 #define OP_ToText 141 /* same as TK_TO_TEXT */
9089 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
9090 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
9091 #define OP_ToInt 144 /* same as TK_TO_INT */
9092 #define OP_ToReal 145 /* same as TK_TO_REAL */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9093 #define OP_Pagecount 146
9094 #define OP_MaxPgcnt 147
9095 #define OP_Trace 148
9096 #define OP_Noop 149
9097 #define OP_Explain 150
@@ -9123,28 +9107,28 @@
9107 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9108 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9109 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9110 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9111 #define OPFLG_INITIALIZER {\
9112 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113 /* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114 /* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115 /* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116 /* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117 /* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118 /* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119 /* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120 /* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121 /* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122 /* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124 /* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125 /* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127 /* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128 /* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129 /* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
9130 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9131
9132 /************** End of opcodes.h *********************************************/
9133 /************** Continuing where we left off in vdbe.h ***********************/
9134
@@ -9190,11 +9174,11 @@
9174 SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
9175 SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
9176 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
9177 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
9178 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
9179 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
9180 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
9181 #ifndef SQLITE_OMIT_TRACE
9182 SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*);
9183 #endif
9184
@@ -10688,16 +10672,20 @@
10672
10673 /*
10674 ** An instance of the following structure is passed as the first
10675 ** argument to sqlite3VdbeKeyCompare and is used to control the
10676 ** comparison of the two index keys.
10677 **
10678 ** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679 ** are nField slots for the columns of an index then one extra slot
10680 ** for the rowid at the end.
10681 */
10682 struct KeyInfo {
10683 sqlite3 *db; /* The database connection */
10684 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10685 u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686 u8 *aSortOrder; /* Sort order for each column. */
10687 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10688 };
10689
10690 /*
10691 ** An instance of the following structure holds information about a
@@ -10762,10 +10750,11 @@
10750 char *zColAff; /* String defining the affinity of each column */
10751 Index *pNext; /* The next index associated with the same table */
10752 Schema *pSchema; /* Schema containing this index */
10753 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
10754 char **azColl; /* Array of collation sequence names for index */
10755 Expr *pPartIdxWhere; /* WHERE clause for partial indices */
10756 int tnum; /* DB Page containing root of this index */
10757 u16 nColumn; /* Number of columns in table used by this index */
10758 u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
10759 unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
10760 unsigned bUnordered:1; /* Use this index for == or IN queries only */
@@ -11242,10 +11231,11 @@
11231 #define NC_HasAgg 0x02 /* One or more aggregate functions seen */
11232 #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */
11233 #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */
11234 #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only
11235 ** if no other resolution is available */
11236 #define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */
11237
11238 /*
11239 ** An instance of the following structure contains all information
11240 ** needed to generate code for a single SELECT statement.
11241 **
@@ -11296,10 +11286,11 @@
11286 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11287 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11288 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11289 #define SF_Materialize 0x0100 /* Force materialization of views */
11290 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
11292
11293
11294 /*
11295 ** The results of a select can be distributed in several ways. The
11296 ** "SRT" prefix means "SELECT Result Type".
@@ -11417,19 +11408,21 @@
11408 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11409 u8 nColCache; /* Number of entries in aColCache[] */
11410 u8 iColCache; /* Next entry in aColCache[] to replace */
11411 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11412 u8 mayAbort; /* True if statement may throw an ABORT exception */
11413 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
11414 int aTempReg[8]; /* Holding area for temporary registers */
11415 int nRangeReg; /* Size of the temporary register block */
11416 int iRangeReg; /* First register in temporary register block */
11417 int nErr; /* Number of errors seen */
11418 int nTab; /* Number of previously allocated VDBE cursors */
11419 int nMem; /* Number of memory cells used so far */
11420 int nSet; /* Number of sets used so far */
11421 int nOnce; /* Number of OP_Once instructions so far */
11422 int ckBase; /* Base register of data during check constraints */
11423 int iPartIdxTab; /* Table corresponding to a partial index */
11424 int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
11425 int iCacheCnt; /* Counter used to generate aColCache[].lru values */
11426 struct yColCache {
11427 int iTable; /* Table cursor number */
11428 int iColumn; /* Table column number */
@@ -12007,11 +12000,11 @@
12000 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
12001 SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
12002 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);
12003 SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);
12004 SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
12005 Expr*, int, int);
12006 SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);
12007 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
12008 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
12009 Expr*,ExprList*,u16,Expr*,Expr*);
12010 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
@@ -12055,12 +12048,13 @@
12048 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
12049 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
12050 SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
12051 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
12052 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
12053 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
12054 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
12055 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
12056 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
12057 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
12058 SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
12059 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
12060 SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -12083,11 +12077,11 @@
12077 SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
12078 SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
12079 SQLITE_PRIVATE int sqlite3IsRowid(const char*);
12080 SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);
12081 SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);
12082 SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*);
12083 SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,
12084 int*,int,int,int,int,int*);
12085 SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);
12086 SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
12087 SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
@@ -12286,10 +12280,11 @@
12280 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
12281 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
12282 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
12283 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
12284 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
12285 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
12286 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
12287 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
12288 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
12289 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
12290 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -12305,10 +12300,11 @@
12300 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12301 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12302 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12303 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12304 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
12306 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12307 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12308 void (*)(sqlite3_context*,int,sqlite3_value **),
12309 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12310 FuncDestructor *pDestructor
@@ -13257,10 +13253,13 @@
13253 typedef struct VdbeSorter VdbeSorter;
13254
13255 /* Opaque type used by the explainer */
13256 typedef struct Explain Explain;
13257
13258 /* Elements of the linked list at Vdbe.pAuxData */
13259 typedef struct AuxData AuxData;
13260
13261 /*
13262 ** A cursor is a pointer into a single BTree within a database file.
13263 ** The cursor can seek to a BTree entry with a particular key, or
13264 ** loop over all entries of the Btree. You can also insert new BTree
13265 ** entries or retrieve the key or data from the entry that the cursor
@@ -13443,27 +13442,23 @@
13442 */
13443 #ifdef SQLITE_DEBUG
13444 #define memIsValid(M) ((M)->flags & MEM_Invalid)==0
13445 #endif
13446
13447 /*
13448 ** Each auxilliary data pointer stored by a user defined function
13449 ** implementation calling sqlite3_set_auxdata() is stored in an instance
13450 ** of this structure. All such structures associated with a single VM
13451 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
13452 ** when the VM is halted (if not before).
 
 
 
13453 */
13454 struct AuxData {
13455 int iOp; /* Instruction number of OP_Function opcode */
13456 int iArg; /* Index of function argument. */
13457 void *pAux; /* Aux data pointer */
13458 void (*xDelete)(void *); /* Destructor for the aux data */
13459 AuxData *pNext; /* Next element in list */
 
13460 };
13461
13462 /*
13463 ** The "context" argument for a installable function. A pointer to an
13464 ** instance of this structure is the first argument to the routines used
@@ -13477,16 +13472,17 @@
13472 ** This structure is defined inside of vdbeInt.h because it uses substructures
13473 ** (Mem) which are only defined there.
13474 */
13475 struct sqlite3_context {
13476 FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */
 
13477 Mem s; /* The return value is stored here */
13478 Mem *pMem; /* Memory cell used to store aggregate context */
13479 CollSeq *pColl; /* Collating sequence */
13480 int isError; /* Error code returned by the function. */
13481 int skipFlag; /* Skip skip accumulator loading if true */
13482 int iOp; /* Instruction number of OP_Function */
13483 Vdbe *pVdbe; /* The VM that owns this context */
13484 };
13485
13486 /*
13487 ** An Explain object accumulates indented output which is helpful
13488 ** in describing recursive data structures.
@@ -13581,10 +13577,11 @@
13577 int nFrame; /* Number of frames in pFrame list */
13578 u32 expmask; /* Binding to these vars invalidates VM */
13579 SubProgram *pProgram; /* Linked list of all sub-programs used by VM */
13580 int nOnceFlag; /* Size of array aOnceFlag[] */
13581 u8 *aOnceFlag; /* Flags for OP_Once */
13582 AuxData *pAuxData; /* Linked list of auxdata allocations */
13583 };
13584
13585 /*
13586 ** The following are allowed values for Vdbe.magic
13587 */
@@ -13604,11 +13601,11 @@
13601 #endif
13602 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
13603 SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
13604 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
13605 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
13606 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
13607
13608 int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
13609 SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
13610 SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
13611 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
@@ -22703,91 +22700,91 @@
22700 /* Automatically generated. Do not edit */
22701 /* See the mkopcodec.awk script for details. */
22702 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22703 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22704 static const char *const azName[] = { "?",
22705 /* 1 */ "Function",
22706 /* 2 */ "Savepoint",
22707 /* 3 */ "AutoCommit",
22708 /* 4 */ "Transaction",
22709 /* 5 */ "SorterNext",
22710 /* 6 */ "Prev",
22711 /* 7 */ "Next",
22712 /* 8 */ "AggStep",
22713 /* 9 */ "Checkpoint",
22714 /* 10 */ "JournalMode",
22715 /* 11 */ "Vacuum",
22716 /* 12 */ "VFilter",
22717 /* 13 */ "VUpdate",
22718 /* 14 */ "Goto",
22719 /* 15 */ "Gosub",
22720 /* 16 */ "Return",
22721 /* 17 */ "Yield",
22722 /* 18 */ "HaltIfNull",
22723 /* 19 */ "Not",
22724 /* 20 */ "Halt",
22725 /* 21 */ "Integer",
22726 /* 22 */ "Int64",
22727 /* 23 */ "String",
22728 /* 24 */ "Null",
22729 /* 25 */ "Blob",
22730 /* 26 */ "Variable",
22731 /* 27 */ "Move",
22732 /* 28 */ "Copy",
22733 /* 29 */ "SCopy",
22734 /* 30 */ "ResultRow",
22735 /* 31 */ "CollSeq",
22736 /* 32 */ "AddImm",
22737 /* 33 */ "MustBeInt",
22738 /* 34 */ "RealAffinity",
22739 /* 35 */ "Permutation",
22740 /* 36 */ "Compare",
22741 /* 37 */ "Jump",
22742 /* 38 */ "Once",
22743 /* 39 */ "If",
22744 /* 40 */ "IfNot",
22745 /* 41 */ "Column",
22746 /* 42 */ "Affinity",
22747 /* 43 */ "MakeRecord",
22748 /* 44 */ "Count",
22749 /* 45 */ "ReadCookie",
22750 /* 46 */ "SetCookie",
22751 /* 47 */ "VerifyCookie",
22752 /* 48 */ "OpenRead",
22753 /* 49 */ "OpenWrite",
22754 /* 50 */ "OpenAutoindex",
22755 /* 51 */ "OpenEphemeral",
22756 /* 52 */ "SorterOpen",
22757 /* 53 */ "OpenPseudo",
22758 /* 54 */ "Close",
22759 /* 55 */ "SeekLt",
22760 /* 56 */ "SeekLe",
22761 /* 57 */ "SeekGe",
22762 /* 58 */ "SeekGt",
22763 /* 59 */ "Seek",
22764 /* 60 */ "NotFound",
22765 /* 61 */ "Found",
22766 /* 62 */ "IsUnique",
22767 /* 63 */ "NotExists",
22768 /* 64 */ "Sequence",
22769 /* 65 */ "NewRowid",
22770 /* 66 */ "Insert",
22771 /* 67 */ "InsertInt",
22772 /* 68 */ "Or",
22773 /* 69 */ "And",
22774 /* 70 */ "Delete",
22775 /* 71 */ "ResetCount",
22776 /* 72 */ "SorterCompare",
22777 /* 73 */ "IsNull",
22778 /* 74 */ "NotNull",
22779 /* 75 */ "Ne",
22780 /* 76 */ "Eq",
22781 /* 77 */ "Gt",
22782 /* 78 */ "Le",
22783 /* 79 */ "Lt",
22784 /* 80 */ "Ge",
22785 /* 81 */ "SorterData",
22786 /* 82 */ "BitAnd",
22787 /* 83 */ "BitOr",
22788 /* 84 */ "ShiftLeft",
22789 /* 85 */ "ShiftRight",
22790 /* 86 */ "Add",
@@ -22794,59 +22791,59 @@
22791 /* 87 */ "Subtract",
22792 /* 88 */ "Multiply",
22793 /* 89 */ "Divide",
22794 /* 90 */ "Remainder",
22795 /* 91 */ "Concat",
22796 /* 92 */ "RowKey",
22797 /* 93 */ "BitNot",
22798 /* 94 */ "String8",
22799 /* 95 */ "RowData",
22800 /* 96 */ "Rowid",
22801 /* 97 */ "NullRow",
22802 /* 98 */ "Last",
22803 /* 99 */ "SorterSort",
22804 /* 100 */ "Sort",
22805 /* 101 */ "Rewind",
22806 /* 102 */ "SorterInsert",
22807 /* 103 */ "IdxInsert",
22808 /* 104 */ "IdxDelete",
22809 /* 105 */ "IdxRowid",
22810 /* 106 */ "IdxLT",
22811 /* 107 */ "IdxGE",
22812 /* 108 */ "Destroy",
22813 /* 109 */ "Clear",
22814 /* 110 */ "CreateIndex",
22815 /* 111 */ "CreateTable",
22816 /* 112 */ "ParseSchema",
22817 /* 113 */ "LoadAnalysis",
22818 /* 114 */ "DropTable",
22819 /* 115 */ "DropIndex",
22820 /* 116 */ "DropTrigger",
22821 /* 117 */ "IntegrityCk",
22822 /* 118 */ "RowSetAdd",
22823 /* 119 */ "RowSetRead",
22824 /* 120 */ "RowSetTest",
22825 /* 121 */ "Program",
22826 /* 122 */ "Param",
22827 /* 123 */ "FkCounter",
22828 /* 124 */ "FkIfZero",
22829 /* 125 */ "MemMax",
22830 /* 126 */ "IfPos",
22831 /* 127 */ "IfNeg",
22832 /* 128 */ "IfZero",
22833 /* 129 */ "AggFinal",
22834 /* 130 */ "Real",
22835 /* 131 */ "IncrVacuum",
22836 /* 132 */ "Expire",
22837 /* 133 */ "TableLock",
22838 /* 134 */ "VBegin",
22839 /* 135 */ "VCreate",
22840 /* 136 */ "VDestroy",
22841 /* 137 */ "VOpen",
22842 /* 138 */ "VColumn",
22843 /* 139 */ "VNext",
22844 /* 140 */ "VRename",
22845 /* 141 */ "ToText",
22846 /* 142 */ "ToBlob",
22847 /* 143 */ "ToNumeric",
22848 /* 144 */ "ToInt",
22849 /* 145 */ "ToReal",
@@ -30499,10 +30496,11 @@
30496 */
30497 #if SQLITE_OS_WIN /* This file is used for Windows only */
30498
30499 #ifdef __CYGWIN__
30500 # include <sys/cygwin.h>
30501 /* # include <errno.h> */
30502 #endif
30503
30504 /*
30505 ** Include code that is common to all os_*.c files
30506 */
@@ -30727,19 +30725,19 @@
30725
30726 /*
30727 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30728 ** based on the sub-platform)?
30729 */
30730 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30731 # define SQLITE_WIN32_HAS_ANSI
30732 #endif
30733
30734 /*
30735 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30736 ** based on the sub-platform)?
30737 */
30738 #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
30739 # define SQLITE_WIN32_HAS_WIDE
30740 #endif
30741
30742 /*
30743 ** Do we need to manually define the Win32 file mapping APIs for use with WAL
@@ -30919,10 +30917,11 @@
30917 * zero for the default behavior.
30918 */
30919 #ifndef SQLITE_WIN32_HEAP_FLAGS
30920 # define SQLITE_WIN32_HEAP_FLAGS (0)
30921 #endif
30922
30923
30924 /*
30925 ** The winMemData structure stores information required by the Win32-specific
30926 ** sqlite3_mem_methods implementation.
30927 */
@@ -31267,11 +31266,11 @@
31266 { "GetTempPathA", (SYSCALL)0, 0 },
31267 #endif
31268
31269 #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)
31270
31271 #if !SQLITE_OS_WINRT && !defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE)
31272 { "GetTempPathW", (SYSCALL)GetTempPathW, 0 },
31273 #else
31274 { "GetTempPathW", (SYSCALL)0, 0 },
31275 #endif
31276
@@ -34384,14 +34383,14 @@
34383 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34384 osGetCurrentProcessId(), pFd));
34385 return SQLITE_OK;
34386 }
34387 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
 
 
34388 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34389 #if SQLITE_OS_WINRT
34390 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34391 #else
34392 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34393 #endif
34394 if( pNew==NULL ){
34395 osCloseHandle(pFd->hMap);
34396 pFd->hMap = NULL;
@@ -34556,10 +34555,19 @@
34555 #endif
34556 /* caller will handle out of memory */
34557 return zConverted;
34558 }
34559
34560 /*
34561 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34562 ** in characters, so we allocate 3 bytes per character assuming worst-case
34563 ** 3-bytes-per-character UTF8.
34564 */
34565 #ifndef SQLITE_WIN32_MAX_PATH
34566 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34567 #endif
34568
34569 static int winIsDir(const void *zConverted);
34570
34571 /*
34572 ** Create a temporary file name in zBuf. zBuf must be big enough to
34573 ** hold at pVfs->mxPathname characters.
@@ -34569,22 +34577,21 @@
34577 "abcdefghijklmnopqrstuvwxyz"
34578 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34579 "0123456789";
34580 size_t i, j;
34581 int nTempPath;
34582 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34583
34584 /* It's odd to simulate an io-error here, but really this is just
34585 ** using the io-error infrastructure to test that SQLite handles this
34586 ** function failing.
34587 */
34588 SimulateIOError( return SQLITE_IOERR );
34589
 
 
34590 if( sqlite3_temp_directory ){
34591 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34592 sqlite3_temp_directory);
34593 }
34594 #if defined(__CYGWIN__)
34595 else{
34596 static const char *azDirs[] = {
34597 0,
@@ -34621,42 +34628,64 @@
34628 if( winIsDir(zWidePath) ){
34629 break;
34630 }
34631 azDirs[i] = ""; /* Don't retry in future call */
34632 }
34633 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zDir);
34634 }
34635 #elif !SQLITE_OS_WINRT
34636 else if( isNT() ){
34637 char *zMulti;
34638 WCHAR zWidePath[MAX_PATH];
34639 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34641 return SQLITE_IOERR_GETTEMPPATH;
34642 }
34643 zMulti = unicodeToUtf8(zWidePath);
34644 if( zMulti ){
34645 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34646 sqlite3_free(zMulti);
34647 }else{
34648 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34649 return SQLITE_IOERR_NOMEM;
34650 }
34651 }
34652 #ifdef SQLITE_WIN32_HAS_ANSI
34653 else{
34654 char *zUtf8;
34655 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34656 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34658 return SQLITE_IOERR_GETTEMPPATH;
34659 }
34660 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34661 if( zUtf8 ){
34662 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34663 sqlite3_free(zUtf8);
34664 }else{
34665 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34666 return SQLITE_IOERR_NOMEM;
34667 }
34668 }
34669 #else
34670 else{
34671 /*
34672 ** Compiled without ANSI support and the current operating system
34673 ** is not Windows NT; therefore, just zero the temporary buffer.
34674 */
34675 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34676 }
34677 #endif /* SQLITE_WIN32_HAS_ANSI */
34678 #else
34679 else{
34680 /*
34681 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34682 ** therefore, just zero the temporary buffer.
34683 */
34684 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34685 }
34686 #endif /* !SQLITE_OS_WINRT */
34687
34688 /* Check that the output buffer is large enough for the temporary file
34689 ** name. If it is not, return SQLITE_ERROR.
34690 */
34691 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34738,11 +34767,11 @@
34767 int cnt = 0;
34768
34769 /* If argument zPath is a NULL pointer, this function is required to open
34770 ** a temporary file. Use this buffer to store the file name in.
34771 */
34772 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34773
34774 int rc = SQLITE_OK; /* Function Return Code */
34775 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34776 int eType = flags&0xFFFFFF00; /* Type of file to open */
34777 #endif
@@ -34804,12 +34833,11 @@
34833 /* If the second argument to this function is NULL, generate a
34834 ** temporary file name to use
34835 */
34836 if( !zUtf8Name ){
34837 assert(isDelete && !isOpenJournal);
34838 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34839 if( rc!=SQLITE_OK ){
34840 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34841 return rc;
34842 }
34843 zUtf8Name = zTmpname;
@@ -35236,27 +35264,34 @@
35264 ){
35265
35266 #if defined(__CYGWIN__)
35267 SimulateIOError( return SQLITE_ERROR );
35268 UNUSED_PARAMETER(nFull);
35269 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35270 assert( nFull>=pVfs->mxPathname );
35271 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35272 /*
35273 ** NOTE: We are dealing with a relative path name and the data
35274 ** directory has been set. Therefore, use it as the basis
35275 ** for converting the relative path name to an absolute
35276 ** one by prepending the data directory and a slash.
35277 */
35278 char zOut[SQLITE_WIN32_MAX_PATH+1];
35279 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35280 SQLITE_WIN32_MAX_PATH+1)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35286 sqlite3_data_directory, zOut);
35287 }else{
35288 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35289 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35290 zRelative);
35291 return SQLITE_CANTOPEN_FULLPATH;
35292 }
35293 }
35294 return SQLITE_OK;
35295 #endif
35296
35297 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35594,11 +35629,11 @@
35629 */
35630 SQLITE_API int sqlite3_os_init(void){
35631 static sqlite3_vfs winVfs = {
35632 3, /* iVersion */
35633 sizeof(winFile), /* szOsFile */
35634 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35635 0, /* pNext */
35636 "win32", /* zName */
35637 0, /* pAppData */
35638 winOpen, /* xOpen */
35639 winDelete, /* xDelete */
@@ -60219,12 +60254,12 @@
60254 ** a prior call to sqlite3VdbeMakeLabel().
60255 */
60256 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){
60257 int j = -1-x;
60258 assert( p->magic==VDBE_MAGIC_INIT );
60259 assert( j<p->nLabel );
60260 if( j>=0 && p->aLabel ){
60261 p->aLabel[j] = p->nOp;
60262 }
60263 }
60264
60265 /*
@@ -60376,44 +60411,64 @@
60411 p->readOnly = 1;
60412 p->bIsReader = 0;
60413 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60414 u8 opcode = pOp->opcode;
60415
60416 /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60417 ** cases from this switch! */
60418 switch( opcode ){
60419 case OP_Function:
60420 case OP_AggStep: {
60421 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60422 break;
60423 }
60424 case OP_Transaction: {
60425 if( pOp->p2!=0 ) p->readOnly = 0;
60426 /* fall thru */
60427 }
60428 case OP_AutoCommit:
60429 case OP_Savepoint: {
60430 p->bIsReader = 1;
60431 break;
60432 }
60433 #ifndef SQLITE_OMIT_WAL
60434 case OP_Checkpoint:
60435 #endif
60436 case OP_Vacuum:
60437 case OP_JournalMode: {
60438 p->readOnly = 0;
60439 p->bIsReader = 1;
60440 break;
60441 }
60442 #ifndef SQLITE_OMIT_VIRTUALTABLE
60443 case OP_VUpdate: {
60444 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60445 break;
60446 }
60447 case OP_VFilter: {
60448 int n;
60449 assert( p->nOp - i >= 3 );
60450 assert( pOp[-1].opcode==OP_Integer );
60451 n = pOp[-1].p1;
60452 if( n>nMaxArgs ) nMaxArgs = n;
60453 break;
60454 }
60455 #endif
60456 case OP_Next:
60457 case OP_SorterNext: {
60458 pOp->p4.xAdvance = sqlite3BtreeNext;
60459 pOp->p4type = P4_ADVANCE;
60460 break;
60461 }
60462 case OP_Prev: {
60463 pOp->p4.xAdvance = sqlite3BtreePrevious;
60464 pOp->p4type = P4_ADVANCE;
60465 break;
60466 }
60467 }
60468
60469 pOp->opflags = sqlite3OpcodeProperty[opcode];
60470 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60471 assert( -1-pOp->p2<p->nLabel );
60472 pOp->p2 = aLabel[-1-pOp->p2];
60473 }
60474 }
@@ -60544,12 +60599,11 @@
60599 /*
60600 ** Change the P2 operand of instruction addr so that it points to
60601 ** the address of the next instruction to be coded.
60602 */
60603 SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
60604 if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp);
 
60605 }
60606
60607
60608 /*
60609 ** If the input FuncDef structure is ephemeral, then free it. If
@@ -60581,17 +60635,10 @@
60635 }
60636 case P4_MPRINTF: {
60637 if( db->pnBytesFreed==0 ) sqlite3_free(p4);
60638 break;
60639 }
 
 
 
 
 
 
 
60640 case P4_FUNCDEF: {
60641 freeEphemeralFunction(db, (FuncDef*)p4);
60642 break;
60643 }
60644 case P4_MEM: {
@@ -60706,24 +60753,17 @@
60753 pOp->p4type = P4_INT32;
60754 }else if( zP4==0 ){
60755 pOp->p4.p = 0;
60756 pOp->p4type = P4_NOTUSED;
60757 }else if( n==P4_KEYINFO ){
60758 KeyInfo *pOrig, *pNew;
60759
60760 pOrig = (KeyInfo*)zP4;
60761 pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60762 if( pNew ){
60763 memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60764 memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
 
 
 
 
 
 
 
60765 pOp->p4type = P4_KEYINFO;
60766 }else{
60767 p->db->mallocFailed = 1;
60768 pOp->p4type = P4_NOTUSED;
60769 }
@@ -61617,10 +61657,14 @@
61657 while( p->pDelFrame ){
61658 VdbeFrame *pDel = p->pDelFrame;
61659 p->pDelFrame = pDel->pParent;
61660 sqlite3VdbeFrameDelete(pDel);
61661 }
61662
61663 /* Delete any auxdata allocations made by the VM */
61664 sqlite3VdbeDeleteAuxData(p, -1, 0);
61665 assert( p->pAuxData==0 );
61666 }
61667
61668 /*
61669 ** Clean up the VM after execution.
61670 **
@@ -62415,24 +62459,39 @@
62459 sqlite3VdbeDelete(p);
62460 return rc;
62461 }
62462
62463 /*
62464 ** If parameter iOp is less than zero, then invoke the destructor for
62465 ** all auxiliary data pointers currently cached by the VM passed as
62466 ** the first argument.
62467 **
62468 ** Or, if iOp is greater than or equal to zero, then the destructor is
62469 ** only invoked for those auxiliary data pointers created by the user
62470 ** function invoked by the OP_Function opcode at instruction iOp of
62471 ** VM pVdbe, and only then if:
62472 **
62473 ** * the associated function parameter is the 32nd or later (counting
62474 ** from left to right), or
62475 **
62476 ** * the corresponding bit in argument mask is clear (where the first
62477 ** function parameter corrsponds to bit 0 etc.).
62478 */
62479 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
62480 AuxData **pp = &pVdbe->pAuxData;
62481 while( *pp ){
62482 AuxData *pAux = *pp;
62483 if( (iOp<0)
62484 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
62485 ){
62486 if( pAux->xDelete ){
62487 pAux->xDelete(pAux->pAux);
62488 }
62489 *pp = pAux->pNext;
62490 sqlite3DbFree(pVdbe->db, pAux);
62491 }else{
62492 pp= &pAux->pNext;
62493 }
62494 }
62495 }
62496
62497 /*
@@ -62947,15 +63006,14 @@
63006 */
63007 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
63008 int nKey1, const void *pKey1, /* Left key */
63009 UnpackedRecord *pPKey2 /* Right key */
63010 ){
63011 u32 d1; /* Offset into aKey[] of next data element */
63012 u32 idx1; /* Offset into aKey[] of next header element */
63013 u32 szHdr1; /* Number of bytes in header */
63014 int i = 0;
 
63015 int rc = 0;
63016 const unsigned char *aKey1 = (const unsigned char *)pKey1;
63017 KeyInfo *pKeyInfo;
63018 Mem mem1;
63019
@@ -62974,32 +63032,42 @@
63032 */
63033 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
63034
63035 idx1 = getVarint32(aKey1, szHdr1);
63036 d1 = szHdr1;
63037 assert( pKeyInfo->nField+1>=pPKey2->nField );
63038 assert( pKeyInfo->aSortOrder!=0 );
63039 while( idx1<szHdr1 && i<pPKey2->nField ){
63040 u32 serial_type1;
63041
63042 /* Read the serial types for the next element in each key. */
63043 idx1 += getVarint32( aKey1+idx1, serial_type1 );
63044
63045 /* Verify that there is enough key space remaining to avoid
63046 ** a buffer overread. The "d1+serial_type1+2" subexpression will
63047 ** always be greater than or equal to the amount of required key space.
63048 ** Use that approximation to avoid the more expensive call to
63049 ** sqlite3VdbeSerialTypeLen() in the common case.
63050 */
63051 if( d1+serial_type1+2>(u32)nKey1
63052 && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63053 ){
63054 break;
63055 }
63056
63057 /* Extract the values to be compared.
63058 */
63059 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
63060
63061 /* Do the comparison
63062 */
63063 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
 
63064 if( rc!=0 ){
63065 assert( mem1.zMalloc==0 ); /* See comment below */
63066
63067 /* Invert the result if we are using DESC sort order. */
63068 if( pKeyInfo->aSortOrder[i] ){
63069 rc = -rc;
63070 }
63071
63072 /* If the PREFIX_SEARCH flag is set and all fields except the final
63073 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -63210,11 +63278,11 @@
63278 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
63279 ** constants) to the value before returning it.
63280 **
63281 ** The returned value must be freed by the caller using sqlite3ValueFree().
63282 */
63283 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){
63284 assert( iVar>0 );
63285 if( v ){
63286 Mem *pMem = &v->aVar[iVar-1];
63287 if( 0==(pMem->flags & MEM_Null) ){
63288 sqlite3_value *pRet = sqlite3ValueNew(v->db);
@@ -63827,18 +63895,18 @@
63895 /*
63896 ** Return the auxilary data pointer, if any, for the iArg'th argument to
63897 ** the user-function defined by pCtx.
63898 */
63899 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
63900 AuxData *pAuxData;
63901
63902 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63903 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63904 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
63905 }
63906
63907 return (pAuxData ? pAuxData->pAux : 0);
63908 }
63909
63910 /*
63911 ** Set the auxilary data pointer and delete function, for the iArg'th
63912 ** argument to the user-function defined by pCtx. Any previous value is
@@ -63848,33 +63916,30 @@
63916 sqlite3_context *pCtx,
63917 int iArg,
63918 void *pAux,
63919 void (*xDelete)(void*)
63920 ){
63921 AuxData *pAuxData;
63922 Vdbe *pVdbe = pCtx->pVdbe;
 
63923
63924 assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
63925 if( iArg<0 ) goto failed;
63926
63927 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
63928 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
63929 }
63930 if( pAuxData==0 ){
63931 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
63932 if( !pAuxData ) goto failed;
63933 pAuxData->iOp = pCtx->iOp;
63934 pAuxData->iArg = iArg;
63935 pAuxData->pNext = pVdbe->pAuxData;
63936 pVdbe->pAuxData = pAuxData;
63937 }else if( pAuxData->xDelete ){
 
 
 
63938 pAuxData->xDelete(pAuxData->pAux);
63939 }
63940
63941 pAuxData->pAux = pAux;
63942 pAuxData->xDelete = xDelete;
63943 return;
63944
63945 failed:
@@ -65482,11 +65547,11 @@
65547 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65548 u8 encoding = ENC(db); /* The database encoding */
65549 int iCompare = 0; /* Result of last OP_Compare operation */
65550 unsigned nVmStep = 0; /* Number of virtual machine steps */
65551 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65552 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
65553 #endif
65554 Mem *aMem = p->aMem; /* Copy of p->aMem */
65555 Mem *pIn1 = 0; /* 1st input operand */
65556 Mem *pIn2 = 0; /* 2nd input operand */
65557 Mem *pIn3 = 0; /* 3rd input operand */
@@ -65941,10 +66006,21 @@
66006 assert( p->explain==0 );
66007 p->pResultSet = 0;
66008 db->busyHandler.nBusy = 0;
66009 CHECK_FOR_INTERRUPT;
66010 sqlite3VdbeIOTraceSql(p);
66011 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
66012 if( db->xProgress ){
66013 assert( 0 < db->nProgressOps );
66014 nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
66015 if( nProgressLimit==0 ){
66016 nProgressLimit = db->nProgressOps;
66017 }else{
66018 nProgressLimit %= (unsigned)db->nProgressOps;
66019 }
66020 }
66021 #endif
66022 #ifdef SQLITE_DEBUG
66023 sqlite3BeginBenignMalloc();
66024 if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){
66025 int i;
66026 printf("VDBE Program Listing:\n");
@@ -66101,18 +66177,20 @@
66177 ** of VDBE ops have been executed (either since this invocation of
66178 ** sqlite3VdbeExec() or since last time the progress callback was called).
66179 ** If the progress callback returns non-zero, exit the virtual machine with
66180 ** a return code SQLITE_ABORT.
66181 */
66182 if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
66183 int prc;
66184 prc = db->xProgress(db->pProgressArg);
66185 if( prc!=0 ){
66186 rc = SQLITE_INTERRUPT;
66187 goto vdbe_error_halt;
66188 }
66189 if( db->xProgress!=0 ){
66190 nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
66191 }
66192 }
66193 #endif
66194
66195 break;
66196 }
@@ -66794,23 +66872,18 @@
66872 Deephemeralize(u.ai.pArg);
66873 sqlite3VdbeMemStoreType(u.ai.pArg);
66874 REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);
66875 }
66876
66877 assert( pOp->p4type==P4_FUNCDEF );
66878 u.ai.ctx.pFunc = pOp->p4.pFunc;
 
 
 
 
 
 
 
66879 u.ai.ctx.s.flags = MEM_Null;
66880 u.ai.ctx.s.db = db;
66881 u.ai.ctx.s.xDel = 0;
66882 u.ai.ctx.s.zMalloc = 0;
66883 u.ai.ctx.iOp = pc;
66884 u.ai.ctx.pVdbe = p;
66885
66886 /* The output cell may already have a buffer allocated. Move
66887 ** the pointer to u.ai.ctx.s so in case the user-function can use
66888 ** the already allocated buffer instead of allocating a new one.
66889 */
@@ -66829,15 +66902,11 @@
66902 lastRowid = db->lastRowid;
66903
66904 /* If any auxiliary data functions have been called by this user function,
66905 ** immediately call the destructor for any non-static values.
66906 */
66907 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
 
 
 
 
66908
66909 if( db->mallocFailed ){
66910 /* Even though a malloc() has failed, the implementation of the
66911 ** user function may have called an sqlite3_result_XXX() function
66912 ** to return a value. The following call releases any resources
@@ -74200,15 +74269,24 @@
74269 /* Translate the schema name in zDb into a pointer to the corresponding
74270 ** schema. If not found, pSchema will remain NULL and nothing will match
74271 ** resulting in an appropriate error message toward the end of this routine
74272 */
74273 if( zDb ){
74274 testcase( pNC->ncFlags & NC_PartIdx );
74275 testcase( pNC->ncFlags & NC_IsCheck );
74276 if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
74277 /* Silently ignore database qualifiers inside CHECK constraints and partial
74278 ** indices. Do not raise errors because that might break legacy and
74279 ** because it does not hurt anything to just ignore the database name. */
74280 zDb = 0;
74281 }else{
74282 for(i=0; i<db->nDb; i++){
74283 assert( db->aDb[i].zName );
74284 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
74285 pSchema = db->aDb[i].pSchema;
74286 break;
74287 }
74288 }
74289 }
74290 }
74291
74292 /* Start at the inner-most context and move outward until a match is found */
@@ -74481,10 +74559,43 @@
74559 }
74560 ExprSetProperty(p, EP_Resolved);
74561 }
74562 return p;
74563 }
74564
74565 /*
74566 ** Report an error that an expression is not valid for a partial index WHERE
74567 ** clause.
74568 */
74569 static void notValidPartIdxWhere(
74570 Parse *pParse, /* Leave error message here */
74571 NameContext *pNC, /* The name context */
74572 const char *zMsg /* Type of error */
74573 ){
74574 if( (pNC->ncFlags & NC_PartIdx)!=0 ){
74575 sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses",
74576 zMsg);
74577 }
74578 }
74579
74580 #ifndef SQLITE_OMIT_CHECK
74581 /*
74582 ** Report an error that an expression is not valid for a CHECK constraint.
74583 */
74584 static void notValidCheckConstraint(
74585 Parse *pParse, /* Leave error message here */
74586 NameContext *pNC, /* The name context */
74587 const char *zMsg /* Type of error */
74588 ){
74589 if( (pNC->ncFlags & NC_IsCheck)!=0 ){
74590 sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg);
74591 }
74592 }
74593 #else
74594 # define notValidCheckConstraint(P,N,M)
74595 #endif
74596
74597
74598 /*
74599 ** This routine is callback for sqlite3WalkExpr().
74600 **
74601 ** Resolve symbolic names into TK_COLUMN operators for the current
@@ -74581,10 +74692,11 @@
74692 FuncDef *pDef; /* Information about the function */
74693 u8 enc = ENC(pParse->db); /* The database encoding */
74694
74695 testcase( pExpr->op==TK_CONST_FUNC );
74696 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
74697 notValidPartIdxWhere(pParse, pNC, "functions");
74698 zId = pExpr->u.zToken;
74699 nId = sqlite3Strlen30(zId);
74700 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);
74701 if( pDef==0 ){
74702 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);
@@ -74646,31 +74758,25 @@
74758 #endif
74759 case TK_IN: {
74760 testcase( pExpr->op==TK_IN );
74761 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
74762 int nRef = pNC->nRef;
74763 notValidCheckConstraint(pParse, pNC, "subqueries");
74764 notValidPartIdxWhere(pParse, pNC, "subqueries");
 
 
 
74765 sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
74766 assert( pNC->nRef>=nRef );
74767 if( nRef!=pNC->nRef ){
74768 ExprSetProperty(pExpr, EP_VarSelect);
74769 }
74770 }
74771 break;
74772 }
 
74773 case TK_VARIABLE: {
74774 notValidCheckConstraint(pParse, pNC, "parameters");
74775 notValidPartIdxWhere(pParse, pNC, "parameters");
 
74776 break;
74777 }
 
74778 }
74779 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
74780 }
74781
74782 /*
@@ -74757,11 +74863,11 @@
74863 /* Try to match the ORDER BY expression against an expression
74864 ** in the result set. Return an 1-based index of the matching
74865 ** result-set entry.
74866 */
74867 for(i=0; i<pEList->nExpr; i++){
74868 if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){
74869 return i+1;
74870 }
74871 }
74872
74873 /* If no match, return 0. */
@@ -74985,11 +75091,11 @@
75091 pItem->iOrderByCol = 0;
75092 if( sqlite3ResolveExprNames(pNC, pE) ){
75093 return 1;
75094 }
75095 for(j=0; j<pSelect->pEList->nExpr; j++){
75096 if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){
75097 pItem->iOrderByCol = j+1;
75098 }
75099 }
75100 }
75101 return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
@@ -75291,10 +75397,52 @@
75397 w.xSelectCallback = resolveSelectStep;
75398 w.pParse = pParse;
75399 w.u.pNC = pOuterNC;
75400 sqlite3WalkSelect(&w, p);
75401 }
75402
75403 /*
75404 ** Resolve names in expressions that can only reference a single table:
75405 **
75406 ** * CHECK constraints
75407 ** * WHERE clauses on partial indices
75408 **
75409 ** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
75410 ** is set to -1 and the Expr.iColumn value is set to the column number.
75411 **
75412 ** Any errors cause an error message to be set in pParse.
75413 */
75414 SQLITE_PRIVATE void sqlite3ResolveSelfReference(
75415 Parse *pParse, /* Parsing context */
75416 Table *pTab, /* The table being referenced */
75417 int type, /* NC_IsCheck or NC_PartIdx */
75418 Expr *pExpr, /* Expression to resolve. May be NULL. */
75419 ExprList *pList /* Expression list to resolve. May be NUL. */
75420 ){
75421 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
75422 NameContext sNC; /* Name context for pParse->pNewTable */
75423 int i; /* Loop counter */
75424
75425 assert( type==NC_IsCheck || type==NC_PartIdx );
75426 memset(&sNC, 0, sizeof(sNC));
75427 memset(&sSrc, 0, sizeof(sSrc));
75428 sSrc.nSrc = 1;
75429 sSrc.a[0].zName = pTab->zName;
75430 sSrc.a[0].pTab = pTab;
75431 sSrc.a[0].iCursor = -1;
75432 sNC.pParse = pParse;
75433 sNC.pSrcList = &sSrc;
75434 sNC.ncFlags = type;
75435 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
75436 if( pList ){
75437 for(i=0; i<pList->nExpr; i++){
75438 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
75439 return;
75440 }
75441 }
75442 }
75443 }
75444
75445 /************** End of resolve.c *********************************************/
75446 /************** Begin file expr.c ********************************************/
75447 /*
75448 ** 2001 September 15
@@ -76987,14 +77135,13 @@
77135 #endif
77136
77137 switch( pExpr->op ){
77138 case TK_IN: {
77139 char affinity; /* Affinity of the LHS of the IN */
 
 
77140 int addr; /* Address of OP_OpenEphemeral instruction */
77141 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77142 KeyInfo *pKeyInfo = 0; /* Key information */
77143
77144 if( rMayHaveNull ){
77145 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
77146 }
77147
@@ -77014,13 +77161,11 @@
77161 ** is used.
77162 */
77163 pExpr->iTable = pParse->nTab++;
77164 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77165 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77166 pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
 
 
77167
77168 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77169 /* Case 1: expr IN (SELECT ...)
77170 **
77171 ** Generate code to write the results of the select into the temporary
@@ -77033,15 +77178,16 @@
77178 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77179 dest.affSdst = (u8)affinity;
77180 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77181 pExpr->x.pSelect->iLimit = 0;
77182 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77183 sqlite3DbFree(pParse->db, pKeyInfo);
77184 return 0;
77185 }
77186 pEList = pExpr->x.pSelect->pEList;
77187 if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77188 pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77189 pEList->a[0].pExpr);
77190 }
77191 }else if( ALWAYS(pExpr->x.pList!=0) ){
77192 /* Case 2: expr IN (exprlist)
77193 **
@@ -77056,12 +77202,13 @@
77202 int r1, r2, r3;
77203
77204 if( !affinity ){
77205 affinity = SQLITE_AFF_NONE;
77206 }
77207 if( pKeyInfo ){
77208 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77209 }
77210
77211 /* Loop through each expression in <exprlist>. */
77212 r1 = sqlite3GetTempReg(pParse);
77213 r2 = sqlite3GetTempReg(pParse);
77214 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77096,12 +77243,12 @@
77243 }
77244 }
77245 sqlite3ReleaseTempReg(pParse, r1);
77246 sqlite3ReleaseTempReg(pParse, r2);
77247 }
77248 if( pKeyInfo ){
77249 sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
77250 }
77251 break;
77252 }
77253
77254 case TK_EXISTS:
@@ -77657,19 +77804,24 @@
77804 break;
77805 }
77806 /* Otherwise, fall thru into the TK_COLUMN case */
77807 }
77808 case TK_COLUMN: {
77809 int iTab = pExpr->iTable;
77810 if( iTab<0 ){
77811 if( pParse->ckBase>0 ){
77812 /* Generating CHECK constraints or inserting into partial index */
77813 inReg = pExpr->iColumn + pParse->ckBase;
77814 break;
77815 }else{
77816 /* Deleting from a partial index */
77817 iTab = pParse->iPartIdxTab;
77818 }
77819 }
77820 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
77821 pExpr->iColumn, iTab, target,
77822 pExpr->op2);
77823 break;
77824 }
77825 case TK_INTEGER: {
77826 codeInteger(pParse, pExpr, 0, target);
77827 break;
@@ -79088,10 +79240,16 @@
79240 ** Do a deep comparison of two expression trees. Return 0 if the two
79241 ** expressions are completely identical. Return 1 if they differ only
79242 ** by a COLLATE operator at the top level. Return 2 if there are differences
79243 ** other than the top-level COLLATE operator.
79244 **
79245 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79246 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79247 **
79248 ** The pA side might be using TK_REGISTER. If that is the case and pB is
79249 ** not using TK_REGISTER but is otherwise equivalent, then still return 0.
79250 **
79251 ** Sometimes this routine will return 2 even if the two expressions
79252 ** really are equivalent. If we cannot prove that the expressions are
79253 ** identical, we return 2 just to be safe. So if this routine
79254 ** returns 2, then you do not really know for certain if the two
79255 ** expressions are the same. But if you get a 0 or 1 return, then you
@@ -79098,33 +79256,36 @@
79256 ** can be sure the expressions are the same. In the places where
79257 ** this routine is used, it does not hurt to get an extra 2 - that
79258 ** just might result in some slightly slower code. But returning
79259 ** an incorrect 0 or 1 could lead to a malfunction.
79260 */
79261 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
79262 if( pA==0||pB==0 ){
79263 return pB==pA ? 0 : 2;
79264 }
79265 assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );
79266 assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );
79267 if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){
79268 return 2;
79269 }
79270 if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
79271 if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){
79272 if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){
79273 return 1;
79274 }
79275 if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){
79276 return 1;
79277 }
79278 return 2;
79279 }
79280 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
79281 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
79282 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
79283 if( pA->iColumn!=pB->iColumn ) return 2;
79284 if( pA->iTable!=pB->iTable
79285 && pA->op!=TK_REGISTER
79286 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
79287 if( ExprHasProperty(pA, EP_IntValue) ){
79288 if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
79289 return 2;
79290 }
79291 }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){
@@ -79138,28 +79299,70 @@
79299
79300 /*
79301 ** Compare two ExprList objects. Return 0 if they are identical and
79302 ** non-zero if they differ in any way.
79303 **
79304 ** If any subelement of pB has Expr.iTable==(-1) then it is allowed
79305 ** to compare equal to an equivalent element in pA with Expr.iTable==iTab.
79306 **
79307 ** This routine might return non-zero for equivalent ExprLists. The
79308 ** only consequence will be disabled optimizations. But this routine
79309 ** must never return 0 if the two ExprList objects are different, or
79310 ** a malfunction will result.
79311 **
79312 ** Two NULL pointers are considered to be the same. But a NULL pointer
79313 ** always differs from a non-NULL pointer.
79314 */
79315 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
79316 int i;
79317 if( pA==0 && pB==0 ) return 0;
79318 if( pA==0 || pB==0 ) return 1;
79319 if( pA->nExpr!=pB->nExpr ) return 1;
79320 for(i=0; i<pA->nExpr; i++){
79321 Expr *pExprA = pA->a[i].pExpr;
79322 Expr *pExprB = pB->a[i].pExpr;
79323 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
79324 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
79325 }
79326 return 0;
79327 }
79328
79329 /*
79330 ** Return true if we can prove the pE2 will always be true if pE1 is
79331 ** true. Return false if we cannot complete the proof or if pE2 might
79332 ** be false. Examples:
79333 **
79334 ** pE1: x==5 pE2: x==5 Result: true
79335 ** pE1: x>0 pE2: x==5 Result: false
79336 ** pE1: x=21 pE2: x=21 OR y=43 Result: true
79337 ** pE1: x!=123 pE2: x IS NOT NULL Result: true
79338 ** pE1: x!=?1 pE2: x IS NOT NULL Result: true
79339 ** pE1: x IS NULL pE2: x IS NOT NULL Result: false
79340 ** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false
79341 **
79342 ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
79343 ** Expr.iTable<0 then assume a table number given by iTab.
79344 **
79345 ** When in doubt, return false. Returning true might give a performance
79346 ** improvement. Returning false might cause a performance reduction, but
79347 ** it will always give the correct answer and is hence always safe.
79348 */
79349 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
79350 if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){
79351 return 1;
79352 }
79353 if( pE2->op==TK_OR
79354 && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab)
79355 || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) )
79356 ){
79357 return 1;
79358 }
79359 if( pE2->op==TK_NOTNULL
79360 && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0
79361 && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS)
79362 ){
79363 return 1;
79364 }
79365 return 0;
79366 }
79367
79368 /*
@@ -79340,11 +79543,11 @@
79543 /* Check to see if pExpr is a duplicate of another aggregate
79544 ** function that is already in the pAggInfo structure
79545 */
79546 struct AggInfo_func *pItem = pAggInfo->aFunc;
79547 for(i=0; i<pAggInfo->nFunc; i++, pItem++){
79548 if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){
79549 break;
79550 }
79551 }
79552 if( i>=pAggInfo->nFunc ){
79553 /* pExpr is original. Make a new entry in pAggInfo->aFunc[]
@@ -80757,10 +80960,11 @@
80960 int i; /* Loop counter */
80961 int topOfLoop; /* The top of the loop */
80962 int endOfLoop; /* The end of the loop */
80963 int jZeroRows = -1; /* Jump from here if number of rows is zero */
80964 int iDb; /* Index of database containing pTab */
80965 u8 needTableCnt = 1; /* True to count the table */
80966 int regTabname = iMem++; /* Register containing table name */
80967 int regIdxname = iMem++; /* Register containing index name */
80968 int regStat1 = iMem++; /* The stat column of sqlite_stat1 */
80969 #ifdef SQLITE_ENABLE_STAT3
80970 int regNumEq = regStat1; /* Number of instances. Same as regStat1 */
@@ -80816,10 +81020,11 @@
81020 KeyInfo *pKey;
81021 int addrIfNot = 0; /* address of OP_IfNot */
81022 int *aChngAddr; /* Array of jump instruction addresses */
81023
81024 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
81025 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
81026 VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
81027 nCol = pIdx->nColumn;
81028 aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);
81029 if( aChngAddr==0 ) continue;
81030 pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -80975,48 +81180,45 @@
81180 ** If K==0 then no entry is made into the sqlite_stat1 table.
81181 ** If K>0 then it is always the case the D>0 so division by zero
81182 ** is never possible.
81183 */
81184 sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);
81185 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
 
 
81186 for(i=0; i<nCol; i++){
81187 sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
81188 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81189 sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);
81190 sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);
81191 sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);
81192 sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);
81193 sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);
81194 }
81195 if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81196 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81197 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81198 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81199 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81200 if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows);
81201 }
81202
81203 /* Create a single sqlite_stat1 entry containing NULL as the index
81204 ** name and the row count as the content.
81205 */
81206 if( pOnlyIdx==0 && needTableCnt ){
81207 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
81208 VdbeComment((v, "%s", pTab->zName));
81209 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);
81210 sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
81211 jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
81212 sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
81213 sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
81214 sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);
81215 sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);
81216 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
81217 sqlite3VdbeJumpHere(v, jZeroRows);
81218 }
81219 if( pParse->nMem<regRec ) pParse->nMem = regRec;
 
 
 
81220 }
81221
81222
81223 /*
81224 ** Generate code that will cause the most recent index analysis to
@@ -81195,12 +81397,14 @@
81397 v = 0;
81398 while( (c=z[0])>='0' && c<='9' ){
81399 v = v*10 + c - '0';
81400 z++;
81401 }
81402 if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){
81403 if( v>0 ) pTable->nRowEst = v;
81404 if( pIndex==0 ) break;
81405 }
81406 pIndex->aiRowEst[i] = v;
81407 if( *z==' ' ) z++;
81408 if( strcmp(z, "unordered")==0 ){
81409 pIndex->bUnordered = 1;
81410 break;
@@ -82636,10 +82840,11 @@
82840 */
82841 static void freeIndex(sqlite3 *db, Index *p){
82842 #ifndef SQLITE_OMIT_ANALYZE
82843 sqlite3DeleteIndexSamples(db, p);
82844 #endif
82845 sqlite3ExprDelete(db, p->pPartIdxWhere);
82846 sqlite3DbFree(db, p->zColAff);
82847 sqlite3DbFree(db, p);
82848 }
82849
82850 /*
@@ -83479,11 +83684,12 @@
83684 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
83685 "INTEGER PRIMARY KEY");
83686 #endif
83687 }else{
83688 Index *p;
83689 p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,
83690 0, sortOrder, 0);
83691 if( p ){
83692 p->autoIndex = 2;
83693 }
83694 pList = 0;
83695 }
@@ -83774,30 +83980,11 @@
83980
83981 #ifndef SQLITE_OMIT_CHECK
83982 /* Resolve names in all CHECK constraint expressions.
83983 */
83984 if( p->pCheck ){
83985 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83986 }
83987 #endif /* !defined(SQLITE_OMIT_CHECK) */
83988
83989 /* If the db->init.busy is 1 it means we are reading the SQL off the
83990 ** "sqlite_master" or "sqlite_temp_master" table on the disk.
@@ -84645,10 +84832,11 @@
84832 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */
84833 int iSorter; /* Cursor opened by OpenSorter (if in use) */
84834 int addr1; /* Address of top of loop */
84835 int addr2; /* Address to jump to for next iteration */
84836 int tnum; /* Root page of index */
84837 int iPartIdxLabel; /* Jump to this label to skip a row */
84838 Vdbe *v; /* Generate code into this virtual machine */
84839 KeyInfo *pKey; /* KeyInfo for index */
84840 int regRecord; /* Register holding assemblied index record */
84841 sqlite3 *db = pParse->db; /* The database connection */
84842 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
@@ -84684,12 +84872,13 @@
84872 ** records into the sorter. */
84873 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
84874 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
84875 regRecord = sqlite3GetTempReg(pParse);
84876
84877 sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel);
84878 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
84879 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
84880 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
84881 sqlite3VdbeJumpHere(v, addr1);
84882 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
84883 if( pIndex->onError!=OE_None ){
84884 int j2 = sqlite3VdbeCurrentAddr(v) + 3;
@@ -84736,11 +84925,11 @@
84925 Token *pName2, /* Second part of index name. May be NULL */
84926 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
84927 ExprList *pList, /* A list of columns to be indexed */
84928 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
84929 Token *pStart, /* The CREATE token that begins this statement */
84930 Expr *pPIWhere, /* WHERE clause for partial indices */
84931 int sortOrder, /* Sort order of primary key when pList==NULL */
84932 int ifNotExist /* Omit error if index already exists */
84933 ){
84934 Index *pRet = 0; /* Pointer to return */
84935 Table *pTab = 0; /* Table to be indexed */
@@ -84758,11 +84947,10 @@
84947 struct ExprList_item *pListItem; /* For looping over pList */
84948 int nCol;
84949 int nExtra = 0;
84950 char *zExtra;
84951
 
84952 assert( pParse->nErr==0 ); /* Never called with prior errors */
84953 if( db->mallocFailed || IN_DECLARE_VTAB ){
84954 goto exit_create_index;
84955 }
84956 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
@@ -84804,11 +84992,16 @@
84992 assert(0);
84993 }
84994 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
84995 assert( db->mallocFailed==0 || pTab==0 );
84996 if( pTab==0 ) goto exit_create_index;
84997 if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
84998 sqlite3ErrorMsg(pParse,
84999 "cannot create a TEMP index on non-TEMP table \"%s\"",
85000 pTab->zName);
85001 goto exit_create_index;
85002 }
85003 }else{
85004 assert( pName==0 );
85005 assert( pStart==0 );
85006 pTab = pParse->pNewTable;
85007 if( !pTab ) goto exit_create_index;
@@ -84953,10 +85146,15 @@
85146 pIndex->nColumn = pList->nExpr;
85147 pIndex->onError = (u8)onError;
85148 pIndex->uniqNotNull = onError==OE_Abort;
85149 pIndex->autoIndex = (u8)(pName==0);
85150 pIndex->pSchema = db->aDb[iDb].pSchema;
85151 if( pPIWhere ){
85152 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);
85153 pIndex->pPartIdxWhere = pPIWhere;
85154 pPIWhere = 0;
85155 }
85156 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
85157
85158 /* Check to see if we should honor DESC requests on index columns
85159 */
85160 if( pDb->pSchema->file_format>=4 ){
@@ -85108,11 +85306,11 @@
85306 ** If pTblName==0 it means this index is generated as a primary key
85307 ** or UNIQUE constraint of a CREATE TABLE statement. Since the table
85308 ** has just been created, it contains no data and the index initialization
85309 ** step can be skipped.
85310 */
85311 else if( pParse->nErr==0 ){
85312 Vdbe *v;
85313 char *zStmt;
85314 int iMem = ++pParse->nMem;
85315
85316 v = sqlite3GetVdbe(pParse);
@@ -85126,16 +85324,15 @@
85324
85325 /* Gather the complete text of the CREATE INDEX statement into
85326 ** the zStmt variable
85327 */
85328 if( pStart ){
85329 int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
85330 if( pName->z[n-1]==';' ) n--;
85331 /* A named index with an explicit CREATE INDEX statement */
85332 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
85333 onError==OE_None ? "" : " UNIQUE", n, pName->z);
 
 
85334 }else{
85335 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
85336 /* zStmt = sqlite3MPrintf(""); */
85337 zStmt = 0;
85338 }
@@ -85187,14 +85384,12 @@
85384 pIndex = 0;
85385 }
85386
85387 /* Clean up before exiting */
85388 exit_create_index:
85389 if( pIndex ) freeIndex(db, pIndex);
85390 sqlite3ExprDelete(db, pPIWhere);
 
 
85391 sqlite3ExprListDelete(db, pList);
85392 sqlite3SrcListDelete(db, pTblName);
85393 sqlite3DbFree(db, zName);
85394 return pRet;
85395 }
@@ -86068,29 +86263,24 @@
86263 ** the error.
86264 */
86265 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86266 int i;
86267 int nCol = pIdx->nColumn;
86268 KeyInfo *pKey;
86269
86270 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86271 if( pKey ){
 
 
 
 
86272 for(i=0; i<nCol; i++){
86273 char *zColl = pIdx->azColl[i];
86274 assert( zColl );
86275 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86276 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86277 }
 
86278 }
86279
86280 if( pParse->nErr ){
86281 sqlite3DbFree(pParse->db, pKey);
86282 pKey = 0;
86283 }
86284 return pKey;
86285 }
86286
@@ -87166,15 +87356,18 @@
87356 int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
87357 ){
87358 int i;
87359 Index *pIdx;
87360 int r1;
87361 int iPartIdxLabel;
87362 Vdbe *v = pParse->pVdbe;
87363
87364 for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
87365 if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;
87366 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel);
87367 sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1);
87368 sqlite3VdbeResolveLabel(v, iPartIdxLabel);
87369 }
87370 }
87371
87372 /*
87373 ** Generate code that will assemble an index key and put it in register
@@ -87184,24 +87377,42 @@
87377 **
87378 ** Return a register number which is the first in a block of
87379 ** registers that holds the elements of the index key. The
87380 ** block of registers has already been deallocated by the time
87381 ** this routine returns.
87382 **
87383 ** If *piPartIdxLabel is not NULL, fill it in with a label and jump
87384 ** to that label if pIdx is a partial index that should be skipped.
87385 ** A partial index should be skipped if its WHERE clause evaluates
87386 ** to false or null. If pIdx is not a partial index, *piPartIdxLabel
87387 ** will be set to zero which is an empty label that is ignored by
87388 ** sqlite3VdbeResolveLabel().
87389 */
87390 SQLITE_PRIVATE int sqlite3GenerateIndexKey(
87391 Parse *pParse, /* Parsing context */
87392 Index *pIdx, /* The index for which to generate a key */
87393 int iCur, /* Cursor number for the pIdx->pTable table */
87394 int regOut, /* Write the new index key to this register */
87395 int doMakeRec, /* Run the OP_MakeRecord instruction if true */
87396 int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */
87397 ){
87398 Vdbe *v = pParse->pVdbe;
87399 int j;
87400 Table *pTab = pIdx->pTable;
87401 int regBase;
87402 int nCol;
87403
87404 if( piPartIdxLabel ){
87405 if( pIdx->pPartIdxWhere ){
87406 *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
87407 pParse->iPartIdxTab = iCur;
87408 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
87409 SQLITE_JUMPIFNULL);
87410 }else{
87411 *piPartIdxLabel = 0;
87412 }
87413 }
87414 nCol = pIdx->nColumn;
87415 regBase = sqlite3GetTempRange(pParse, nCol+1);
87416 sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);
87417 for(j=0; j<nCol; j++){
87418 int idx = pIdx->aiColumn[j];
@@ -91561,12 +91772,22 @@
91772 ** Add the new records to the indices as we go.
91773 */
91774 for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
91775 int regIdx;
91776 int regR;
91777 int addrSkipRow = 0;
91778
91779 if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
91780
91781 if( pIdx->pPartIdxWhere ){
91782 sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
91783 addrSkipRow = sqlite3VdbeMakeLabel(v);
91784 pParse->ckBase = regData;
91785 sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
91786 SQLITE_JUMPIFNULL);
91787 pParse->ckBase = 0;
91788 }
91789
91790 /* Create a key for accessing the index entry */
91791 regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
91792 for(i=0; i<pIdx->nColumn; i++){
91793 int idx = pIdx->aiColumn[i];
@@ -91583,10 +91804,11 @@
91804
91805 /* Find out what action to take in case there is an indexing conflict */
91806 onError = pIdx->onError;
91807 if( onError==OE_None ){
91808 sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
91809 sqlite3VdbeResolveLabel(v, addrSkipRow);
91810 continue; /* pIdx is not a UNIQUE index */
91811 }
91812 if( overrideError!=OE_Default ){
91813 onError = overrideError;
91814 }else if( onError==OE_Default ){
@@ -91652,10 +91874,11 @@
91874 seenReplace = 1;
91875 break;
91876 }
91877 }
91878 sqlite3VdbeJumpHere(v, j3);
91879 sqlite3VdbeResolveLabel(v, addrSkipRow);
91880 sqlite3ReleaseTempReg(pParse, regR);
91881 }
91882
91883 if( pbMayReplace ){
91884 *pbMayReplace = seenReplace;
@@ -91681,22 +91904,23 @@
91904 int appendBias, /* True if this is likely to be an append */
91905 int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
91906 ){
91907 int i;
91908 Vdbe *v;
 
91909 Index *pIdx;
91910 u8 pik_flags;
91911 int regData;
91912 int regRec;
91913
91914 v = sqlite3GetVdbe(pParse);
91915 assert( v!=0 );
91916 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
91917 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
 
91918 if( aRegIdx[i]==0 ) continue;
91919 if( pIdx->pPartIdxWhere ){
91920 sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
91921 }
91922 sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
91923 if( useSeekResult ){
91924 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
91925 }
91926 }
@@ -91794,10 +92018,11 @@
92018 **
92019 ** * The index is over the same set of columns
92020 ** * The same DESC and ASC markings occurs on all columns
92021 ** * The same onError processing (OE_Abort, OE_Ignore, etc)
92022 ** * The same collating sequence on each column
92023 ** * The index has the exact same WHERE clause
92024 */
92025 static int xferCompatibleIndex(Index *pDest, Index *pSrc){
92026 int i;
92027 assert( pDest && pSrc );
92028 assert( pDest->pTable!=pSrc->pTable );
@@ -91815,10 +92040,13 @@
92040 return 0; /* Different sort orders */
92041 }
92042 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
92043 return 0; /* Different collating sequences */
92044 }
92045 }
92046 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
92047 return 0; /* Different WHERE clauses */
92048 }
92049
92050 /* If no test above fails then the indices must be compatible */
92051 return 1;
92052 }
@@ -91971,11 +92199,11 @@
92199 if( pSrcIdx==0 ){
92200 return 0; /* pDestIdx has no corresponding index in pSrc */
92201 }
92202 }
92203 #ifndef SQLITE_OMIT_CHECK
92204 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
92205 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
92206 }
92207 #endif
92208 #ifndef SQLITE_OMIT_FOREIGN_KEY
92209 /* Disallow the transfer optimization if the destination table constains
@@ -94884,13 +95112,11 @@
95112 cnt++;
95113 }
95114 }
95115
95116 /* Make sure sufficient number of registers have been allocated */
95117 pParse->nMem = MAX( pParse->nMem, cnt+7 );
 
 
95118
95119 /* Do the b-tree integrity checks */
95120 sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
95121 sqlite3VdbeChangeP5(v, (u8)i);
95122 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
@@ -94911,16 +95137,19 @@
95137
95138 if( pTab->pIndex==0 ) continue;
95139 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
95140 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95141 sqlite3VdbeJumpHere(v, addr);
95142 sqlite3ExprCacheClear(pParse);
95143 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
95144 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95145 sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */
95146 }
95147 pParse->nMem = MAX(pParse->nMem, 7+j);
95148 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1;
95149 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95150 int jmp2, jmp3;
95151 int r1;
95152 static const VdbeOpList idxErr[] = {
95153 { OP_AddImm, 1, -1, 0},
95154 { OP_String8, 0, 3, 0}, /* 1 */
95155 { OP_Rowid, 1, 4, 0},
@@ -94931,47 +95160,38 @@
95160 { OP_Concat, 6, 3, 3},
95161 { OP_ResultRow, 3, 1, 0},
95162 { OP_IfPos, 1, 0, 0}, /* 9 */
95163 { OP_Halt, 0, 0, 0},
95164 };
95165 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3);
95166 sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */
95167 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
95168 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
95169 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
95170 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
95171 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
95172 sqlite3VdbeJumpHere(v, addr+9);
95173 sqlite3VdbeJumpHere(v, jmp2);
95174 sqlite3VdbeResolveLabel(v, jmp3);
95175 }
95176 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop);
95177 sqlite3VdbeJumpHere(v, loopTop-1);
95178 #ifndef SQLITE_OMIT_BTREECOUNT
95179 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0,
95180 "wrong # of entries in index ", P4_STATIC);
95181 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
95182 addr = sqlite3VdbeCurrentAddr(v);
95183 sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2);
 
 
 
 
 
 
 
 
 
 
 
95184 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
95185 sqlite3VdbeAddOp2(v, OP_Count, j+2, 3);
95186 sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3);
95187 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
95188 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT);
95189 sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
95190 sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
95191 }
95192 #endif /* SQLITE_OMIT_BTREECOUNT */
 
 
 
95193 }
95194 }
95195 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
95196 sqlite3VdbeChangeP2(v, addr, -mxErr);
95197 sqlite3VdbeJumpHere(v, addr+1);
@@ -96994,10 +97214,29 @@
97214 */
97215 if( pOrderBy==0 && p->iLimit ){
97216 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
97217 }
97218 }
97219
97220 /*
97221 ** Allocate a KeyInfo object sufficient for an index of N columns.
97222 **
97223 ** Actually, always allocate one extra column for the rowid at the end
97224 ** of the index. So the KeyInfo returned will have space sufficient for
97225 ** N+1 columns.
97226 */
97227 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97228 KeyInfo *p = sqlite3DbMallocZero(db,
97229 sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97230 if( p ){
97231 p->aSortOrder = (u8*)&p->aColl[N+1];
97232 p->nField = (u16)N;
97233 p->enc = ENC(db);
97234 p->db = db;
97235 }
97236 return p;
97237 }
97238
97239 /*
97240 ** Given an expression list, generate a KeyInfo structure that records
97241 ** the collating sequence for each expression in that expression list.
97242 **
@@ -97011,29 +97250,23 @@
97250 ** function is responsible for seeing that this structure is eventually
97251 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97252 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97253 */
97254 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
 
97255 int nExpr;
97256 KeyInfo *pInfo;
97257 struct ExprList_item *pItem;
97258 sqlite3 *db = pParse->db;
97259 int i;
97260
97261 nExpr = pList->nExpr;
97262 pInfo = sqlite3KeyInfoAlloc(db, nExpr);
97263 if( pInfo ){
 
 
 
 
97264 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97265 CollSeq *pColl;
97266 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97267 if( !pColl ) pColl = db->pDfltColl;
 
 
97268 pInfo->aColl[i] = pColl;
97269 pInfo->aSortOrder[i] = pItem->sortOrder;
97270 }
97271 }
97272 return pInfo;
@@ -98135,27 +98368,21 @@
98368 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98369 int nCol; /* Number of columns in result set */
98370
98371 assert( p->pRightmost==p );
98372 nCol = p->pEList->nExpr;
98373 pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
 
98374 if( !pKeyInfo ){
98375 rc = SQLITE_NOMEM;
98376 goto multi_select_end;
98377 }
 
 
 
 
98378 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98379 *apColl = multiSelectCollSeq(pParse, p, i);
98380 if( 0==*apColl ){
98381 *apColl = db->pDfltColl;
98382 }
98383 }
 
98384
98385 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98386 for(i=0; i<2; i++){
98387 int addr = pLoop->addrOpenEphm[i];
98388 if( addr<0 ){
@@ -98520,16 +98747,12 @@
98747 struct ExprList_item *pItem;
98748 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98749 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98750 aPermute[i] = pItem->iOrderByCol - 1;
98751 }
98752 pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
 
98753 if( pKeyMerge ){
 
 
 
98754 for(i=0; i<nOrderBy; i++){
98755 CollSeq *pColl;
98756 Expr *pTerm = pOrderBy->a[i].pExpr;
98757 if( pTerm->flags & EP_Collate ){
98758 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98562,16 +98785,12 @@
98785 int nExpr = p->pEList->nExpr;
98786 assert( nOrderBy>=nExpr || db->mallocFailed );
98787 regPrev = pParse->nMem+1;
98788 pParse->nMem += nExpr+1;
98789 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98790 pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
 
98791 if( pKeyDup ){
 
 
 
98792 for(i=0; i<nExpr; i++){
98793 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98794 pKeyDup->aSortOrder[i] = 0;
98795 }
98796 }
@@ -99833,14 +100052,16 @@
100052 ** and/or pParse->db->mallocFailed.
100053 */
100054 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
100055 Walker w;
100056 memset(&w, 0, sizeof(w));
 
100057 w.xExprCallback = exprWalkNoop;
100058 w.pParse = pParse;
100059 if( pParse->hasCompound ){
100060 w.xSelectCallback = convertCompoundSelectToSubquery;
100061 sqlite3WalkSelect(&w, pSelect);
100062 }
100063 w.xSelectCallback = selectExpander;
100064 sqlite3WalkSelect(&w, pSelect);
100065 }
100066
100067
@@ -100370,11 +100591,11 @@
100591 ** will cause elements to come out in the correct order. This is
100592 ** an optimization - the correct answer should result regardless.
100593 ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
100594 ** to disable this optimization for testing purposes.
100595 */
100596 if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0
100597 && OptimizationEnabled(db, SQLITE_GroupByOrder) ){
100598 pOrderBy = 0;
100599 }
100600
100601 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
@@ -100391,11 +100612,11 @@
100612 ** used for both the ORDER BY and DISTINCT processing. As originally
100613 ** written the query must use a temp-table for at least one of the ORDER
100614 ** BY and DISTINCT, and an index or separate temp-table for the other.
100615 */
100616 if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
100617 && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0
100618 ){
100619 p->selFlags &= ~SF_Distinct;
100620 p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
100621 pGroupBy = p->pGroupBy;
100622 pOrderBy = 0;
@@ -102618,11 +102839,11 @@
102839 aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );
102840 if( aRegIdx==0 ) goto update_cleanup;
102841 }
102842 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
102843 int reg;
102844 if( hasFK || chngRowid || pIdx->pPartIdxWhere ){
102845 reg = ++pParse->nMem;
102846 }else{
102847 reg = 0;
102848 for(i=0; i<pIdx->nColumn; i++){
102849 if( aXRef[pIdx->aiColumn[i]]>=0 ){
@@ -105158,11 +105379,11 @@
105379 ** the pWC->a[] array.
105380 */
105381 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
105382 WhereTerm *pTerm;
105383 int idx;
105384 testcase( wtFlags & TERM_VIRTUAL );
105385 if( pWC->nTerm>=pWC->nSlot ){
105386 WhereTerm *pOld = pWC->a;
105387 sqlite3 *db = pWC->pWInfo->pParse->db;
105388 pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
105389 if( pWC->a==0 ){
@@ -105303,17 +105524,10 @@
105524
105525 /*
105526 ** Return TRUE if the given operator is one of the operators that is
105527 ** allowed for an indexable WHERE clause term. The allowed operators are
105528 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
 
 
 
 
 
 
 
105529 */
105530 static int allowedOp(int op){
105531 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
105532 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
105533 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -105628,11 +105842,11 @@
105842 op = pRight->op2;
105843 }
105844 if( op==TK_VARIABLE ){
105845 Vdbe *pReprepare = pParse->pReprepare;
105846 int iCol = pRight->iColumn;
105847 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
105848 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
105849 z = (char *)sqlite3_value_text(pVal);
105850 }
105851 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
105852 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
@@ -105983,12 +106197,10 @@
106197 }
106198
106199 /* At this point, okToChngToIN is true if original pTerm satisfies
106200 ** case 1. In that case, construct a new virtual term that is
106201 ** pTerm converted into an IN operator.
 
 
106202 */
106203 if( okToChngToIN ){
106204 Expr *pDup; /* A transient duplicate expression */
106205 ExprList *pList = 0; /* The RHS of the IN operator */
106206 Expr *pLeft = 0; /* The LHS of the IN operator */
@@ -106226,13 +106438,11 @@
106438 ** wildcard. But if we increment '@', that will push it into the
106439 ** alphabetic range where case conversions will mess up the
106440 ** inequality. To avoid this, make sure to also run the full
106441 ** LIKE on all candidate expressions by clearing the isComplete flag
106442 */
106443 if( c=='A'-1 ) isComplete = 0;
 
 
106444 c = sqlite3UpperToLower[c];
106445 }
106446 *pC = c + 1;
106447 }
106448 sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
@@ -106735,11 +106945,11 @@
106945 VdbeComment((v, "for %s", pTable->zName));
106946
106947 /* Fill the automatic index with content */
106948 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
106949 regRecord = sqlite3GetTempReg(pParse);
106950 sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0);
106951 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
106952 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
106953 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
106954 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
106955 sqlite3VdbeJumpHere(v, addrTop);
@@ -107092,11 +107302,11 @@
107302 if( pExpr->op==TK_VARIABLE
107303 || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
107304 ){
107305 int iVar = pExpr->iColumn;
107306 sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
107307 *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff);
107308 return SQLITE_OK;
107309 }
107310 return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);
107311 }
107312 #endif
@@ -107318,13 +107528,10 @@
107528 **
107529 ** The t2.z='ok' is disabled in the in (2) because it originates
107530 ** in the ON clause. The term is disabled in (3) because it is not part
107531 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
107532 **
 
 
 
107533 ** Disabling a term causes that term to not be tested in the inner loop
107534 ** of the join. Disabling is an optimization. When terms are satisfied
107535 ** by indices, we disable them to prevent redundant tests in the inner
107536 ** loop. We would get the correct results if nothing were ever disabled,
107537 ** but joins might run a little slower. The trick is to disable as much
@@ -107550,11 +107757,11 @@
107757 pTerm = pLoop->aLTerm[j];
107758 assert( pTerm!=0 );
107759 /* The following true for indices with redundant columns.
107760 ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
107761 testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
107762 testcase( pTerm->wtFlags & TERM_VIRTUAL );
107763 r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
107764 if( r1!=regBase+j ){
107765 if( nReg==1 ){
107766 sqlite3ReleaseTempReg(pParse, regBase);
107767 regBase = r1;
@@ -107750,10 +107957,11 @@
107957 WhereLevel *pLevel; /* The where level to be coded */
107958 WhereLoop *pLoop; /* The WhereLoop object being coded */
107959 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107960 WhereTerm *pTerm; /* A WHERE clause term */
107961 Parse *pParse; /* Parsing context */
107962 sqlite3 *db; /* Database connection */
107963 Vdbe *v; /* The prepared stmt under constructions */
107964 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107965 int addrBrk; /* Jump here to break out of the loop */
107966 int addrCont; /* Jump here to continue with next cycle */
107967 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107761,10 +107969,11 @@
107969 Bitmask newNotReady; /* Return value */
107970
107971 pParse = pWInfo->pParse;
107972 v = pParse->pVdbe;
107973 pWC = &pWInfo->sWC;
107974 db = pParse->db;
107975 pLevel = &pWInfo->a[iLevel];
107976 pLoop = pLevel->pWLoop;
107977 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107978 iCur = pTabItem->iCursor;
107979 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -107859,11 +108068,11 @@
108068 iReleaseReg = sqlite3GetTempReg(pParse);
108069 pTerm = pLoop->aLTerm[0];
108070 assert( pTerm!=0 );
108071 assert( pTerm->pExpr!=0 );
108072 assert( omitTable==0 );
108073 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108074 iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
108075 addrNxt = pLevel->addrNxt;
108076 sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
108077 sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
108078 sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
@@ -107907,11 +108116,11 @@
108116 assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */
108117 assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */
108118 assert( TK_GE==TK_GT+3 ); /* ... is correcct. */
108119
108120 assert( (pStart->wtFlags & TERM_VNULL)==0 );
108121 testcase( pStart->wtFlags & TERM_VIRTUAL );
108122 pX = pStart->pExpr;
108123 assert( pX!=0 );
108124 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
108125 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
108126 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
@@ -107926,11 +108135,11 @@
108135 Expr *pX;
108136 pX = pEnd->pExpr;
108137 assert( pX!=0 );
108138 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
108139 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
108140 testcase( pEnd->wtFlags & TERM_VIRTUAL );
108141 memEndValue = ++pParse->nMem;
108142 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
108143 if( pX->op==TK_LT || pX->op==TK_GT ){
108144 testOp = bRev ? OP_Le : OP_Ge;
108145 }else{
@@ -108051,11 +108260,11 @@
108260 /* Generate code to evaluate all constraint terms using == or IN
108261 ** and store the values of those terms in an array of registers
108262 ** starting at regBase.
108263 */
108264 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108265 zEndAff = sqlite3DbStrDup(db, zStartAff);
108266 addrNxt = pLevel->addrNxt;
108267
108268 /* If we are doing a reverse order scan on an ascending index, or
108269 ** a forward order scan on a descending index, interchange the
108270 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108092,11 +108301,11 @@
108301 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
108302 zStartAff[nEq] = SQLITE_AFF_NONE;
108303 }
108304 }
108305 nConstraint++;
108306 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
108307 }else if( isMinQuery ){
108308 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
108309 nConstraint++;
108310 startEq = 0;
108311 start_constraints = 1;
@@ -108134,14 +108343,14 @@
108343 zEndAff[nEq] = SQLITE_AFF_NONE;
108344 }
108345 }
108346 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108347 nConstraint++;
108348 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
108349 }
108350 sqlite3DbFree(db, zStartAff);
108351 sqlite3DbFree(db, zEndAff);
108352
108353 /* Top of the loop body */
108354 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108355
108356 /* Check if the index cursor is past the end of the range. */
@@ -108264,11 +108473,11 @@
108473 */
108474 if( pWInfo->nLevel>1 ){
108475 int nNotReady; /* The number of notReady tables */
108476 struct SrcList_item *origSrc; /* Original list of tables */
108477 nNotReady = pWInfo->nLevel - iLevel - 1;
108478 pOrTab = sqlite3StackAllocRaw(db,
108479 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108480 if( pOrTab==0 ) return notReady;
108481 pOrTab->nAlloc = (u8)(nNotReady + 1);
108482 pOrTab->nSrc = pOrTab->nAlloc;
108483 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108318,12 +108527,12 @@
108527 Expr *pExpr = pWC->a[iTerm].pExpr;
108528 if( &pWC->a[iTerm] == pTerm ) continue;
108529 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108530 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108531 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108532 pExpr = sqlite3ExprDup(db, pExpr, 0);
108533 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108534 }
108535 if( pAndExpr ){
108536 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108537 }
108538 }
@@ -108339,11 +108548,11 @@
108548 }
108549 /* Loop through table entries that match term pOrTerm. */
108550 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108551 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108552 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108553 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108554 if( pSubWInfo ){
108555 WhereLoop *pSubLoop;
108556 explainOneScan(
108557 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108558 );
@@ -108394,17 +108603,17 @@
108603 }
108604 pLevel->u.pCovidx = pCov;
108605 if( pCov ) pLevel->iIdxCur = iCovCur;
108606 if( pAndExpr ){
108607 pAndExpr->pLeft = 0;
108608 sqlite3ExprDelete(db, pAndExpr);
108609 }
108610 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108611 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108612 sqlite3VdbeResolveLabel(v, iLoopBody);
108613
108614 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108615 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108616 }else
108617 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108618
108619 {
@@ -108421,18 +108630,14 @@
108630 }
108631 newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur);
108632
108633 /* Insert code to test every subexpression that can be completely
108634 ** computed using the current set of tables.
 
 
 
 
108635 */
108636 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108637 Expr *pE;
108638 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108639 testcase( pTerm->wtFlags & TERM_CODED );
108640 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108641 if( (pTerm->prereqAll & newNotReady)!=0 ){
108642 testcase( pWInfo->untestedTerms==0
108643 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
@@ -108455,13 +108660,12 @@
108660 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108661 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108662 ** the implied "t1.a=123" constraint.
108663 */
108664 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108665 Expr *pE, *pEAlt;
108666 WhereTerm *pAlt;
 
108667 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108668 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108669 if( pTerm->leftCursor!=iCur ) continue;
108670 if( pLevel->iLeftJoin ) continue;
108671 pE = pTerm->pExpr;
@@ -108471,13 +108675,17 @@
108675 if( pAlt==0 ) continue;
108676 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108677 testcase( pAlt->eOperator & WO_EQ );
108678 testcase( pAlt->eOperator & WO_IN );
108679 VdbeNoopComment((v, "begin transitive constraint"));
108680 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108681 if( pEAlt ){
108682 *pEAlt = *pAlt->pExpr;
108683 pEAlt->pLeft = pE->pLeft;
108684 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108685 sqlite3StackFree(db, pEAlt);
108686 }
108687 }
108688
108689 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108690 ** at least one row of the right table has matched the left table.
108691 */
@@ -108485,11 +108693,11 @@
108693 pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
108694 sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
108695 VdbeComment((v, "record LEFT JOIN hit"));
108696 sqlite3ExprCacheClear(pParse);
108697 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
108698 testcase( pTerm->wtFlags & TERM_VIRTUAL );
108699 testcase( pTerm->wtFlags & TERM_CODED );
108700 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108701 if( (pTerm->prereqAll & newNotReady)!=0 ){
108702 assert( pWInfo->untestedTerms );
108703 continue;
@@ -108926,11 +109134,12 @@
109134 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
109135 }else if( (pTerm->eOperator & WO_IN)
109136 && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){
109137 rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
109138 }
109139 assert( nOut==0 || rc==SQLITE_OK );
109140 if( nOut ) pNew->nOut = whereCost(nOut);
109141 }
109142 #endif
109143 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
109144 /* Each row involves a step of the index, then a binary search of
109145 ** the main table */
@@ -108998,10 +109207,21 @@
109207 if( x<BMS-1 ) m |= MASKBIT(x);
109208 }
109209 return m;
109210 }
109211
109212 /* Check to see if a partial index with pPartIndexWhere can be used
109213 ** in the current query. Return true if it can be and false if not.
109214 */
109215 static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
109216 int i;
109217 WhereTerm *pTerm;
109218 for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
109219 if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
109220 }
109221 return 0;
109222 }
109223
109224 /*
109225 ** Add all WhereLoop objects for a single table of the join where the table
109226 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
109227 ** a b-tree table, not a virtual table.
@@ -109021,15 +109241,17 @@
109241 int rc = SQLITE_OK; /* Return code */
109242 int iSortIdx = 1; /* Index number */
109243 int b; /* A boolean value */
109244 WhereCost rSize; /* number of rows in the table */
109245 WhereCost rLogSize; /* Logarithm of the number of rows in the table */
109246 WhereClause *pWC; /* The parsed WHERE clause */
109247
109248 pNew = pBuilder->pNew;
109249 pWInfo = pBuilder->pWInfo;
109250 pTabList = pWInfo->pTabList;
109251 pSrc = pTabList->a + pNew->iTab;
109252 pWC = pBuilder->pWC;
109253 assert( !IsVirtual(pSrc->pTab) );
109254
109255 if( pSrc->pIndex ){
109256 /* An INDEXED BY clause specifies a particular index to use */
109257 pProbe = pSrc->pIndex;
@@ -109065,11 +109287,10 @@
109287 && !pSrc->viaCoroutine
109288 && !pSrc->notIndexed
109289 && !pSrc->isCorrelated
109290 ){
109291 /* Generate auto-index WhereLoops */
 
109292 WhereTerm *pTerm;
109293 WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
109294 for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
109295 if( pTerm->prereqRight & pNew->maskSelf ) continue;
109296 if( termCanDriveIndex(pTerm, pSrc, 0) ){
@@ -109095,10 +109316,14 @@
109316 }
109317
109318 /* Loop over all indices
109319 */
109320 for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
109321 if( pProbe->pPartIdxWhere!=0
109322 && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
109323 continue; /* Partial index inappropriate for this query */
109324 }
109325 pNew->u.btree.nEq = 0;
109326 pNew->nLTerm = 0;
109327 pNew->iSortIdx = 0;
109328 pNew->rSetup = 0;
109329 pNew->prereq = mExtra;
@@ -110035,11 +110260,11 @@
110260 pLoop->u.btree.nEq = 1;
110261 /* TUNING: Cost of a rowid lookup is 10 */
110262 pLoop->rRun = 33; /* 33==whereCost(10) */
110263 }else{
110264 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
110265 if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue;
110266 for(j=0; j<pIdx->nColumn; j++){
110267 pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
110268 if( pTerm==0 ) break;
110269 whereLoopResize(pWInfo->pParse->db, pLoop, j);
110270 pLoop->aLTerm[j] = pTerm;
@@ -110241,11 +110466,11 @@
110466 ** subexpression is separated by an AND operator.
110467 */
110468 initMaskSet(pMaskSet);
110469 whereClauseInit(&pWInfo->sWC, pWInfo);
110470 sqlite3ExprCodeConstants(pParse, pWhere);
110471 whereSplit(&pWInfo->sWC, pWhere, TK_AND);
110472 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
110473
110474 /* Special case: a WHERE clause that is constant. Evaluate the
110475 ** expression and either jump over all of the code or fall thru.
110476 */
@@ -110875,11 +111100,11 @@
111100 #endif
111101 #define sqlite3ParserARG_SDECL Parse *pParse;
111102 #define sqlite3ParserARG_PDECL ,Parse *pParse
111103 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
111104 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
111105 #define YYNSTATE 628
111106 #define YYNRULE 327
111107 #define YYFALLBACK 1
111108 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
111109 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
111110 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
@@ -110948,167 +111173,167 @@
111173 ** shifting non-terminals after a reduce.
111174 ** yy_default[] Default action for each state.
111175 */
111176 #define YY_ACTTAB_COUNT (1564)
111177 static const YYACTIONTYPE yy_action[] = {
111178 /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56,
111179 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
111180 /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234,
111181 /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54,
111182 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57,
111183 /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111184 /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52,
111185 /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194,
111186 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111187 /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377,
111188 /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59,
111189 /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146,
111190 /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581,
111191 /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54,
111192 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
111193 /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168,
111194 /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439,
111195 /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582,
111196 /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440,
111197 /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48,
111198 /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111199 /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111200 /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386,
111201 /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263,
111202 /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569,
111203 /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381,
111204 /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593,
111205 /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111206 /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
111207 /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617,
111208 /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549,
111209 /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619,
111210 /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599,
111211 /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513,
111212 /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579,
111213 /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54,
111214 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111215 /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618,
111216 /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620,
111217 /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490,
111218 /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470,
111219 /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57,
111220 /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111221 /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52,
111222 /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577,
111223 /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505,
111224 /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181,
111225 /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562,
111226 /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599,
111227 /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581,
111228 /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54,
111229 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328,
111230 /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248,
111231 /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558,
111232 /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582,
111233 /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69,
111234 /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48,
111235 /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111236 /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111237 /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598,
111238 /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614,
111239 /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47,
111240 /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556,
111241 /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424,
111242 /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55,
111243 /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53,
111244 /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261,
111245 /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421,
111246 /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595,
111247 /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599,
111248 /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50,
111249 /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579,
111250 /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111251 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111252 /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363,
111253 /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413,
111254 /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413,
111255 /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522,
111256 /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57,
111257 /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111258 /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
111259 /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50,
111260 /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338,
111261 /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98,
111262 /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619,
111263 /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93,
111264 /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581,
111265 /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
111266 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410,
111267 /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599,
111268 /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228,
111269 /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582,
111270 /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136,
111271 /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48,
111272 /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
111273 /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
111274 /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598,
111275 /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619,
111276 /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599,
111277 /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599,
111278 /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598,
111279 /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55,
111280 /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
111281 /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413,
111282 /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371,
111283 /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619,
111284 /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619,
111285 /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85,
111286 /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579,
111287 /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54,
111288 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
111289 /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592,
111290 /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413,
111291 /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413,
111292 /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258,
111293 /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448,
111294 /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56,
111295 /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52,
111296 /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460,
111297 /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349,
111298 /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619,
111299 /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413,
111300 /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216,
111301 /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619,
111302 /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123,
111303 /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412,
111304 /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599,
111305 /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599,
111306 /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598,
111307 /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13,
111308 /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3,
111309 /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591,
111310 /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34,
111311 /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331,
111312 /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79,
111313 /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611,
111314 /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235,
111315 /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619,
111316 /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61,
111317 /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619,
111318 /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31,
111319 /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590,
111320 /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300,
111321 /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591,
111322 /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534,
111323 /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240,
111324 /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487,
111325 /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372,
111326 /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477,
111327 /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116,
111328 /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111,
111329 /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427,
111330 /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594,
111331 /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403,
111332 /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5,
111333 /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369,
111334 /* 1560 */ 400, 499, 523, 233,
111335 };
111336 static const YYCODETYPE yy_lookahead[] = {
111337 /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78,
111338 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
111339 /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197,
@@ -111256,21 +111481,21 @@
111481 /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211,
111482 /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42,
111483 /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175,
111484 /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18,
111485 /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157,
111486 /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22,
111487 /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192,
111488 /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38,
111489 /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166,
111490 /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226,
111491 /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196,
111492 /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234,
111493 /* 1560 */ 191, 182, 173, 92,
111494 };
111495 #define YY_SHIFT_USE_DFLT (-70)
111496 #define YY_SHIFT_COUNT (417)
111497 #define YY_SHIFT_MIN (-69)
111498 #define YY_SHIFT_MAX (1487)
111499 static const short yy_shift_ofst[] = {
111500 /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19,
111501 /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165,
@@ -111283,44 +111508,44 @@
111508 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
111509 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
111510 /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362,
111511 /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111512 /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362,
111513 /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57,
111514 /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362,
111515 /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111516 /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111517 /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
111518 /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70,
111519 /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511,
111520 /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12,
111521 /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730,
111522 /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723,
111523 /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308,
111524 /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487,
111525 /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355,
111526 /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348,
111527 /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408,
111528 /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308,
111529 /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346,
111530 /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70,
111531 /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760,
111532 /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306,
111533 /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174,
111534 /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184,
111535 /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152,
111536 /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960,
111537 /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910,
111538 /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834,
111539 /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603,
111540 /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185,
111541 /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5,
111542 };
111543 #define YY_REDUCE_USE_DFLT (-169)
111544 #define YY_REDUCE_COUNT (309)
111545 #define YY_REDUCE_MIN (-168)
111546 #define YY_REDUCE_MAX (1397)
111547 static const short yy_reduce_ofst[] = {
111548 /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104,
111549 /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181,
111550 /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962,
111551 /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813,
@@ -111337,87 +111562,87 @@
111562 /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222,
111563 /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,
111564 /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,
111565 /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894,
111566 /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646,
111567 /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369,
111568 /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352,
111569 /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341,
111570 /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318,
111571 /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358,
111572 /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312,
111573 /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252,
111574 /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301,
111575 /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274,
111576 /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266,
111577 /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219,
111578 /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,
111579 };
111580 static const YYACTIONTYPE yy_default[] = {
111581 /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757,
111582 /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955,
111583 /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111584 /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111585 /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111586 /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111587 /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791,
111588 /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930,
111589 /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862,
111590 /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844,
111591 /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955,
111592 /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111593 /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955,
111594 /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664,
111595 /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111596 /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955,
111597 /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111598 /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111599 /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761,
111600 /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111601 /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738,
111602 /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795,
111603 /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774,
111604 /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765,
111605 /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737,
111606 /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907,
111607 /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728,
111608 /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712,
111609 /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765,
111610 /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649,
111611 /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682,
111612 /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955,
111613 /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111614 /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800,
111615 /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111616 /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955,
111617 /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955,
111618 /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111619 /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955,
111620 /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955,
111621 /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816,
111622 /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635,
111623 /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937,
111624 /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888,
111625 /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739,
111626 /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916,
111627 /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870,
111628 /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654,
111629 /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717,
111630 /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704,
111631 /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
111632 /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732,
111633 /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812,
111634 /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809,
111635 /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
111636 /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923,
111637 /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893,
111638 /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852,
111639 /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821,
111640 /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811,
111641 /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650,
111642 /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669,
111643 /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629,
111644 };
111645
111646 /* The next table maps tokens into fallback tokens. If a construct
111647 ** like the following:
111648 **
@@ -111885,11 +112110,11 @@
112110 /* 237 */ "case_operand ::=",
112111 /* 238 */ "exprlist ::= nexprlist",
112112 /* 239 */ "exprlist ::=",
112113 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
112114 /* 241 */ "nexprlist ::= expr",
112115 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt",
112116 /* 243 */ "uniqueflag ::= UNIQUE",
112117 /* 244 */ "uniqueflag ::=",
112118 /* 245 */ "idxlist_opt ::=",
112119 /* 246 */ "idxlist_opt ::= LP idxlist RP",
112120 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
@@ -112604,11 +112829,11 @@
112829 { 224, 0 },
112830 { 220, 1 },
112831 { 220, 0 },
112832 { 215, 3 },
112833 { 215, 1 },
112834 { 147, 12 },
112835 { 227, 1 },
112836 { 227, 0 },
112837 { 178, 0 },
112838 { 178, 3 },
112839 { 187, 5 },
@@ -113046,10 +113271,11 @@
113271 case 114: /* select ::= select multiselect_op oneselect */
113272 {
113273 if( yymsp[0].minor.yy159 ){
113274 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113275 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113276 if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113277 }else{
113278 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113279 }
113280 yygotominor.yy159 = yymsp[0].minor.yy159;
113281 }
@@ -113608,15 +113834,15 @@
113834 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
113835 break;
113836 case 241: /* nexprlist ::= expr */
113837 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
113838 break;
113839 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
113840 {
113841 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
113842 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392,
113843 &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392);
113844 }
113845 break;
113846 case 243: /* uniqueflag ::= UNIQUE */
113847 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
113848 {yygotominor.yy392 = OE_Abort;}
@@ -114538,11 +114764,10 @@
114764 *tokenType = TK_SPACE;
114765 return i;
114766 }
114767 case '-': {
114768 if( z[1]=='-' ){
 
114769 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
114770 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114771 return i;
114772 }
114773 *tokenType = TK_MINUS;
@@ -114571,11 +114796,10 @@
114796 case '/': {
114797 if( z[1]!='*' || z[2]==0 ){
114798 *tokenType = TK_SLASH;
114799 return 1;
114800 }
 
114801 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
114802 if( c ) i++;
114803 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
114804 return i;
114805 }
@@ -116416,10 +116640,11 @@
116640 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116641 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116642 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116643 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116644 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116645 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116646 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116647 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116648 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116649 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116650 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -117771,11 +117996,11 @@
117996 db->autoCommit = 1;
117997 db->nextAutovac = -1;
117998 db->szMmap = sqlite3GlobalConfig.szMmap;
117999 db->nextPagesize = 0;
118000 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
118001 #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
118002 | SQLITE_AutoIndex
118003 #endif
118004 #if SQLITE_DEFAULT_FILE_FORMAT<4
118005 | SQLITE_LegacyFileFmt
118006 #endif
@@ -128244,11 +128469,11 @@
128469 }
128470
128471
128472 #ifdef SQLITE_TEST
128473
128474 #include <tcl.h>
128475 /* #include <string.h> */
128476
128477 /*
128478 ** Implementation of a special SQL scalar function for testing tokenizers
128479 ** designed to be used in concert with the Tcl testing framework. This
128480
+35 -34
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
112
+#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -476,10 +476,11 @@
476476
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477477
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
481482
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482483
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483484
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484485
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485486
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2559,11 +2560,12 @@
25592560
** interface is to keep a GUI updated during a large query.
25602561
**
25612562
** ^The parameter P is passed through as the only parameter to the
25622563
** callback function X. ^The parameter N is the approximate number of
25632564
** [virtual machine instructions] that are evaluated between successive
2564
-** invocations of the callback X.
2565
+** invocations of the callback X. ^If N is less than one then the progress
2566
+** handler is disabled.
25652567
**
25662568
** ^Only a single progress handler may be defined at one time per
25672569
** [database connection]; setting a new progress handler cancels the
25682570
** old one. ^Setting parameter X to NULL disables the progress handler.
25692571
** ^The progress handler is also disabled by setting N to a value less
@@ -4179,50 +4181,49 @@
41794181
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
41804182
41814183
/*
41824184
** CAPI3REF: Function Auxiliary Data
41834185
**
4184
-** The following two functions may be used by scalar SQL functions to
4186
+** These functions may be used by (non-aggregate) SQL functions to
41854187
** associate metadata with argument values. If the same value is passed to
41864188
** multiple invocations of the same SQL function during query execution, under
4187
-** some circumstances the associated metadata may be preserved. This might
4188
-** be used, for example, in a regular-expression matching
4189
-** function. The compiled version of the regular expression is stored as
4190
-** metadata associated with the SQL value passed as the regular expression
4191
-** pattern. The compiled regular expression can be reused on multiple
4192
-** invocations of the same function so that the original pattern string
4193
-** does not need to be recompiled on each invocation.
4189
+** some circumstances the associated metadata may be preserved. An example
4190
+** of where this might be useful is in a regular-expression matching
4191
+** function. The compiled version of the regular expression can be stored as
4192
+** metadata associated with the pattern string.
4193
+** Then as long as the pattern string remains the same,
4194
+** the compiled regular expression can be reused on multiple
4195
+** invocations of the same function.
41944196
**
41954197
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
41964198
** associated by the sqlite3_set_auxdata() function with the Nth argument
4197
-** value to the application-defined function. ^If no metadata has been ever
4198
-** been set for the Nth argument of the function, or if the corresponding
4199
-** function parameter has changed since the meta-data was set,
4200
-** then sqlite3_get_auxdata() returns a NULL pointer.
4199
+** value to the application-defined function. ^If there is no metadata
4200
+** associated with the function argument, this sqlite3_get_auxdata() interface
4201
+** returns a NULL pointer.
42014202
**
42024203
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
42034204
** argument of the application-defined function. ^Subsequent
42044205
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4205
-** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4206
-** NULL if the data has been dropped.
4207
-** ^(If it is not NULL, SQLite will invoke the destructor
4208
-** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4209
-** <li> the corresponding function parameter changes,
4210
-** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4211
-** SQL statement,
4212
-** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4213
-** <li> a memory allocation error occurs. </ul>)^
4206
+** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4207
+** NULL if the metadata has been discarded.
4208
+** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4209
+** SQLite will invoke the destructor function X with parameter P exactly
4210
+** once, when the metadata is discarded.
4211
+** SQLite is free to discard the metadata at any time, including: <ul>
4212
+** <li> when the corresponding function parameter changes, or
4213
+** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4214
+** SQL statement, or
4215
+** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4216
+** <li> during the original sqlite3_set_auxdata() call when a memory
4217
+** allocation error occurs. </ul>)^
42144218
**
4215
-** SQLite is free to call the destructor and drop metadata on any
4216
-** parameter of any function at any time. ^The only guarantee is that
4217
-** the destructor will be called when the [prepared statement] is destroyed.
4218
-** Note in particular that the destructor X in the call to
4219
-** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4220
-** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4219
+** Note the last bullet in particular. The destructor X in
4220
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4221
+** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
42214222
** should be called near the end of the function implementation and the
4222
-** implementation should not make any use of P after sqlite3_set_auxdata()
4223
-** has been called.
4223
+** function implementation should not make any use of P after
4224
+** sqlite3_set_auxdata() has been called.
42244225
**
42254226
** ^(In practice, metadata is preserved between function calls for
42264227
** function parameters that are compile-time constants, including literal
42274228
** values and [parameters] and expressions composed from the same.)^
42284229
**
@@ -6266,13 +6267,13 @@
62666267
** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
62676268
** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
62686269
** </dd>
62696270
**
62706271
** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6271
-** <dd>This parameter returns the zero for the current value if and only if
6272
-** there all foreign key constraints (deferred or immediate) have been
6273
-** resolved. The highwater mark is always 0.
6272
+** <dd>This parameter returns zero for the current value if and only if
6273
+** all foreign key constraints (deferred or immediate) have been
6274
+** resolved.)^ ^The highwater mark is always 0.
62746275
** </dd>
62756276
** </dl>
62766277
*/
62776278
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
62786279
#define SQLITE_DBSTATUS_CACHE_USED 1
62796280
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2559,11 +2560,12 @@
2559 ** interface is to keep a GUI updated during a large query.
2560 **
2561 ** ^The parameter P is passed through as the only parameter to the
2562 ** callback function X. ^The parameter N is the approximate number of
2563 ** [virtual machine instructions] that are evaluated between successive
2564 ** invocations of the callback X.
 
2565 **
2566 ** ^Only a single progress handler may be defined at one time per
2567 ** [database connection]; setting a new progress handler cancels the
2568 ** old one. ^Setting parameter X to NULL disables the progress handler.
2569 ** ^The progress handler is also disabled by setting N to a value less
@@ -4179,50 +4181,49 @@
4179 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4180
4181 /*
4182 ** CAPI3REF: Function Auxiliary Data
4183 **
4184 ** The following two functions may be used by scalar SQL functions to
4185 ** associate metadata with argument values. If the same value is passed to
4186 ** multiple invocations of the same SQL function during query execution, under
4187 ** some circumstances the associated metadata may be preserved. This might
4188 ** be used, for example, in a regular-expression matching
4189 ** function. The compiled version of the regular expression is stored as
4190 ** metadata associated with the SQL value passed as the regular expression
4191 ** pattern. The compiled regular expression can be reused on multiple
4192 ** invocations of the same function so that the original pattern string
4193 ** does not need to be recompiled on each invocation.
4194 **
4195 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4196 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4197 ** value to the application-defined function. ^If no metadata has been ever
4198 ** been set for the Nth argument of the function, or if the corresponding
4199 ** function parameter has changed since the meta-data was set,
4200 ** then sqlite3_get_auxdata() returns a NULL pointer.
4201 **
4202 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4203 ** argument of the application-defined function. ^Subsequent
4204 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4205 ** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or
4206 ** NULL if the data has been dropped.
4207 ** ^(If it is not NULL, SQLite will invoke the destructor
4208 ** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul>
4209 ** <li> the corresponding function parameter changes,
4210 ** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4211 ** SQL statement,
4212 ** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or
4213 ** <li> a memory allocation error occurs. </ul>)^
 
 
 
4214 **
4215 ** SQLite is free to call the destructor and drop metadata on any
4216 ** parameter of any function at any time. ^The only guarantee is that
4217 ** the destructor will be called when the [prepared statement] is destroyed.
4218 ** Note in particular that the destructor X in the call to
4219 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before
4220 ** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata()
4221 ** should be called near the end of the function implementation and the
4222 ** implementation should not make any use of P after sqlite3_set_auxdata()
4223 ** has been called.
4224 **
4225 ** ^(In practice, metadata is preserved between function calls for
4226 ** function parameters that are compile-time constants, including literal
4227 ** values and [parameters] and expressions composed from the same.)^
4228 **
@@ -6266,13 +6267,13 @@
6266 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6267 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6268 ** </dd>
6269 **
6270 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6271 ** <dd>This parameter returns the zero for the current value if and only if
6272 ** there all foreign key constraints (deferred or immediate) have been
6273 ** resolved. The highwater mark is always 0.
6274 ** </dd>
6275 ** </dl>
6276 */
6277 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6278 #define SQLITE_DBSTATUS_CACHE_USED 1
6279
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -2559,11 +2560,12 @@
2560 ** interface is to keep a GUI updated during a large query.
2561 **
2562 ** ^The parameter P is passed through as the only parameter to the
2563 ** callback function X. ^The parameter N is the approximate number of
2564 ** [virtual machine instructions] that are evaluated between successive
2565 ** invocations of the callback X. ^If N is less than one then the progress
2566 ** handler is disabled.
2567 **
2568 ** ^Only a single progress handler may be defined at one time per
2569 ** [database connection]; setting a new progress handler cancels the
2570 ** old one. ^Setting parameter X to NULL disables the progress handler.
2571 ** ^The progress handler is also disabled by setting N to a value less
@@ -4179,50 +4181,49 @@
4181 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4182
4183 /*
4184 ** CAPI3REF: Function Auxiliary Data
4185 **
4186 ** These functions may be used by (non-aggregate) SQL functions to
4187 ** associate metadata with argument values. If the same value is passed to
4188 ** multiple invocations of the same SQL function during query execution, under
4189 ** some circumstances the associated metadata may be preserved. An example
4190 ** of where this might be useful is in a regular-expression matching
4191 ** function. The compiled version of the regular expression can be stored as
4192 ** metadata associated with the pattern string.
4193 ** Then as long as the pattern string remains the same,
4194 ** the compiled regular expression can be reused on multiple
4195 ** invocations of the same function.
4196 **
4197 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4198 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4199 ** value to the application-defined function. ^If there is no metadata
4200 ** associated with the function argument, this sqlite3_get_auxdata() interface
4201 ** returns a NULL pointer.
 
4202 **
4203 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4204 ** argument of the application-defined function. ^Subsequent
4205 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4206 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4207 ** NULL if the metadata has been discarded.
4208 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4209 ** SQLite will invoke the destructor function X with parameter P exactly
4210 ** once, when the metadata is discarded.
4211 ** SQLite is free to discard the metadata at any time, including: <ul>
4212 ** <li> when the corresponding function parameter changes, or
4213 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4214 ** SQL statement, or
4215 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4216 ** <li> during the original sqlite3_set_auxdata() call when a memory
4217 ** allocation error occurs. </ul>)^
4218 **
4219 ** Note the last bullet in particular. The destructor X in
4220 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4221 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
 
 
 
4222 ** should be called near the end of the function implementation and the
4223 ** function implementation should not make any use of P after
4224 ** sqlite3_set_auxdata() has been called.
4225 **
4226 ** ^(In practice, metadata is preserved between function calls for
4227 ** function parameters that are compile-time constants, including literal
4228 ** values and [parameters] and expressions composed from the same.)^
4229 **
@@ -6266,13 +6267,13 @@
6267 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6268 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6269 ** </dd>
6270 **
6271 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6272 ** <dd>This parameter returns zero for the current value if and only if
6273 ** all foreign key constraints (deferred or immediate) have been
6274 ** resolved.)^ ^The highwater mark is always 0.
6275 ** </dd>
6276 ** </dl>
6277 */
6278 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6279 #define SQLITE_DBSTATUS_CACHE_USED 1
6280
+12 -1
--- src/style.c
+++ src/style.c
@@ -657,10 +657,15 @@
657657
{ "td.timelineTableCell",
658658
"the format for the timeline data cells",
659659
@ vertical-align: top;
660660
@ text-align: left;
661661
},
662
+ { "tr.timelineCurrent td.timelineTableCell",
663
+ "the format for the timeline data cell of the current checkout",
664
+ @ padding: .1em .2em;
665
+ @ border: 1px dashed #446979;
666
+ },
662667
{ "span.timelineLeaf",
663668
"the format for the timeline leaf marks",
664669
@ font-weight: bold;
665670
},
666671
{ "a.timelineHistLink",
@@ -1174,12 +1179,18 @@
11741179
@ g.userUid = %d(g.userUid)<br />
11751180
@ g.zLogin = %h(g.zLogin)<br />
11761181
@ capabilities = %s(zCap)<br />
11771182
@ <hr>
11781183
P("HTTP_USER_AGENT");
1179
- cgi_print_all(atoi(PD("showall","0")));
1184
+ cgi_print_all(showAll);
1185
+ if( showAll && blob_size(&g.httpHeader)>0 ){
1186
+ @ <hr>
1187
+ @ <pre>
1188
+ @ %h(blob_str(&g.httpHeader))
1189
+ @ </pre>
1190
+ }
11801191
if( g.perm.Setup ){
11811192
const char *zRedir = P("redirect");
11821193
if( zRedir ) cgi_redirect(zRedir);
11831194
}
11841195
style_footer();
11851196
}
11861197
--- src/style.c
+++ src/style.c
@@ -657,10 +657,15 @@
657 { "td.timelineTableCell",
658 "the format for the timeline data cells",
659 @ vertical-align: top;
660 @ text-align: left;
661 },
 
 
 
 
 
662 { "span.timelineLeaf",
663 "the format for the timeline leaf marks",
664 @ font-weight: bold;
665 },
666 { "a.timelineHistLink",
@@ -1174,12 +1179,18 @@
1174 @ g.userUid = %d(g.userUid)<br />
1175 @ g.zLogin = %h(g.zLogin)<br />
1176 @ capabilities = %s(zCap)<br />
1177 @ <hr>
1178 P("HTTP_USER_AGENT");
1179 cgi_print_all(atoi(PD("showall","0")));
 
 
 
 
 
 
1180 if( g.perm.Setup ){
1181 const char *zRedir = P("redirect");
1182 if( zRedir ) cgi_redirect(zRedir);
1183 }
1184 style_footer();
1185 }
1186
--- src/style.c
+++ src/style.c
@@ -657,10 +657,15 @@
657 { "td.timelineTableCell",
658 "the format for the timeline data cells",
659 @ vertical-align: top;
660 @ text-align: left;
661 },
662 { "tr.timelineCurrent td.timelineTableCell",
663 "the format for the timeline data cell of the current checkout",
664 @ padding: .1em .2em;
665 @ border: 1px dashed #446979;
666 },
667 { "span.timelineLeaf",
668 "the format for the timeline leaf marks",
669 @ font-weight: bold;
670 },
671 { "a.timelineHistLink",
@@ -1174,12 +1179,18 @@
1179 @ g.userUid = %d(g.userUid)<br />
1180 @ g.zLogin = %h(g.zLogin)<br />
1181 @ capabilities = %s(zCap)<br />
1182 @ <hr>
1183 P("HTTP_USER_AGENT");
1184 cgi_print_all(showAll);
1185 if( showAll && blob_size(&g.httpHeader)>0 ){
1186 @ <hr>
1187 @ <pre>
1188 @ %h(blob_str(&g.httpHeader))
1189 @ </pre>
1190 }
1191 if( g.perm.Setup ){
1192 const char *zRedir = P("redirect");
1193 if( zRedir ) cgi_redirect(zRedir);
1194 }
1195 style_footer();
1196 }
1197
+6
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,16 @@
9393
if( find_option("private",0,0)!=0 ){
9494
*pSyncFlags |= SYNC_PRIVATE;
9595
}
9696
if( find_option("verbose","v",0)!=0 ){
9797
*pSyncFlags |= SYNC_VERBOSE;
98
+ }
99
+ /* The --verily option to sync, push, and pull forces extra igot cards
100
+ ** to be exchanged. This can overcome malfunctions in the sync protocol.
101
+ */
102
+ if( find_option("verily",0,0)!=0 ){
103
+ *pSyncFlags |= SYNC_RESYNC;
98104
}
99105
url_proxy_options();
100106
db_find_and_open_repository(0, 0);
101107
db_open_config(0);
102108
if( g.argc==2 ){
103109
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,16 @@
93 if( find_option("private",0,0)!=0 ){
94 *pSyncFlags |= SYNC_PRIVATE;
95 }
96 if( find_option("verbose","v",0)!=0 ){
97 *pSyncFlags |= SYNC_VERBOSE;
 
 
 
 
 
 
98 }
99 url_proxy_options();
100 db_find_and_open_repository(0, 0);
101 db_open_config(0);
102 if( g.argc==2 ){
103
--- src/sync.c
+++ src/sync.c
@@ -93,10 +93,16 @@
93 if( find_option("private",0,0)!=0 ){
94 *pSyncFlags |= SYNC_PRIVATE;
95 }
96 if( find_option("verbose","v",0)!=0 ){
97 *pSyncFlags |= SYNC_VERBOSE;
98 }
99 /* The --verily option to sync, push, and pull forces extra igot cards
100 ** to be exchanged. This can overcome malfunctions in the sync protocol.
101 */
102 if( find_option("verily",0,0)!=0 ){
103 *pSyncFlags |= SYNC_RESYNC;
104 }
105 url_proxy_options();
106 db_find_and_open_repository(0, 0);
107 db_open_config(0);
108 if( g.argc==2 ){
109
+19 -5
--- src/tag.c
+++ src/tag.c
@@ -348,14 +348,15 @@
348348
** %fossil tag cancel ?--raw? TAGNAME CHECK-IN
349349
**
350350
** Remove the tag TAGNAME from CHECK-IN, and also remove
351351
** the propagation of the tag to any descendants.
352352
**
353
-** %fossil tag find ?--raw? ?-t|--type TYPE? TAGNAME
353
+** %fossil tag find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME
354354
**
355355
** List all objects that use TAGNAME. TYPE can be "ci" for
356
-** checkins or "e" for events.
356
+** checkins or "e" for events. The limit option limits the number
357
+** of results to the given value.
357358
**
358359
** %fossil tag list ?--raw? ?CHECK-IN?
359360
**
360361
** List all tags, or if CHECK-IN is supplied, list
361362
** all tags and their values for CHECK-IN.
@@ -387,10 +388,12 @@
387388
void tag_cmd(void){
388389
int n;
389390
int fRaw = find_option("raw","",0)!=0;
390391
int fPropagate = find_option("propagate","",0)!=0;
391392
const char *zPrefix = fRaw ? "" : "sym-";
393
+ char const * zFindLimit = find_option("limit","n",1);
394
+ int const nFindLimit = zFindLimit ? atoi(zFindLimit) : 0;
392395
393396
db_find_and_open_repository(0, 0);
394397
if( g.argc<3 ){
395398
goto tag_cmd_usage;
396399
}
@@ -428,40 +431,51 @@
428431
}else
429432
430433
if( strncmp(g.argv[2],"find",n)==0 ){
431434
Stmt q;
432435
const char *zType = find_option("type","t",1);
436
+ Blob sql = empty_blob;
433437
if( zType==0 || zType[0]==0 ) zType = "*";
434438
if( g.argc!=4 ){
435
- usage("find ?--raw? ?-t|--type TYPE? TAGNAME");
439
+ usage("find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME");
436440
}
437441
if( fRaw ){
438
- db_prepare(&q,
442
+ blob_appendf(&sql,
439443
"SELECT blob.uuid FROM tagxref, blob"
440444
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
441445
" AND tagxref.tagtype>0"
442446
" AND blob.rid=tagxref.rid",
443447
g.argv[3]
444448
);
449
+ if(nFindLimit>0){
450
+ blob_appendf(&sql, " LIMIT %d", nFindLimit);
451
+ }
452
+ db_prepare(&q, "%s", blob_str(&sql));
453
+ blob_reset(&sql);
445454
while( db_step(&q)==SQLITE_ROW ){
446455
fossil_print("%s\n", db_column_text(&q, 0));
447456
}
448457
db_finalize(&q);
449458
}else{
450459
int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
451460
g.argv[3]);
452461
if( tagid>0 ){
453
- db_prepare(&q,
462
+ blob_appendf(&sql,
454463
"%s"
455464
" AND event.type GLOB '%q'"
456465
" AND blob.rid IN ("
457466
" SELECT rid FROM tagxref"
458467
" WHERE tagtype>0 AND tagid=%d"
459468
")"
460469
" ORDER BY event.mtime DESC",
461470
timeline_query_for_tty(), zType, tagid
462471
);
472
+ if(nFindLimit>0){
473
+ blob_appendf(&sql, " LIMIT %d", nFindLimit);
474
+ }
475
+ db_prepare(&q, "%s", blob_str(&sql));
476
+ blob_reset(&sql);
463477
print_timeline(&q, 2000, 0);
464478
db_finalize(&q);
465479
}
466480
}
467481
}else
468482
--- src/tag.c
+++ src/tag.c
@@ -348,14 +348,15 @@
348 ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN
349 **
350 ** Remove the tag TAGNAME from CHECK-IN, and also remove
351 ** the propagation of the tag to any descendants.
352 **
353 ** %fossil tag find ?--raw? ?-t|--type TYPE? TAGNAME
354 **
355 ** List all objects that use TAGNAME. TYPE can be "ci" for
356 ** checkins or "e" for events.
 
357 **
358 ** %fossil tag list ?--raw? ?CHECK-IN?
359 **
360 ** List all tags, or if CHECK-IN is supplied, list
361 ** all tags and their values for CHECK-IN.
@@ -387,10 +388,12 @@
387 void tag_cmd(void){
388 int n;
389 int fRaw = find_option("raw","",0)!=0;
390 int fPropagate = find_option("propagate","",0)!=0;
391 const char *zPrefix = fRaw ? "" : "sym-";
 
 
392
393 db_find_and_open_repository(0, 0);
394 if( g.argc<3 ){
395 goto tag_cmd_usage;
396 }
@@ -428,40 +431,51 @@
428 }else
429
430 if( strncmp(g.argv[2],"find",n)==0 ){
431 Stmt q;
432 const char *zType = find_option("type","t",1);
 
433 if( zType==0 || zType[0]==0 ) zType = "*";
434 if( g.argc!=4 ){
435 usage("find ?--raw? ?-t|--type TYPE? TAGNAME");
436 }
437 if( fRaw ){
438 db_prepare(&q,
439 "SELECT blob.uuid FROM tagxref, blob"
440 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
441 " AND tagxref.tagtype>0"
442 " AND blob.rid=tagxref.rid",
443 g.argv[3]
444 );
 
 
 
 
 
445 while( db_step(&q)==SQLITE_ROW ){
446 fossil_print("%s\n", db_column_text(&q, 0));
447 }
448 db_finalize(&q);
449 }else{
450 int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
451 g.argv[3]);
452 if( tagid>0 ){
453 db_prepare(&q,
454 "%s"
455 " AND event.type GLOB '%q'"
456 " AND blob.rid IN ("
457 " SELECT rid FROM tagxref"
458 " WHERE tagtype>0 AND tagid=%d"
459 ")"
460 " ORDER BY event.mtime DESC",
461 timeline_query_for_tty(), zType, tagid
462 );
 
 
 
 
 
463 print_timeline(&q, 2000, 0);
464 db_finalize(&q);
465 }
466 }
467 }else
468
--- src/tag.c
+++ src/tag.c
@@ -348,14 +348,15 @@
348 ** %fossil tag cancel ?--raw? TAGNAME CHECK-IN
349 **
350 ** Remove the tag TAGNAME from CHECK-IN, and also remove
351 ** the propagation of the tag to any descendants.
352 **
353 ** %fossil tag find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME
354 **
355 ** List all objects that use TAGNAME. TYPE can be "ci" for
356 ** checkins or "e" for events. The limit option limits the number
357 ** of results to the given value.
358 **
359 ** %fossil tag list ?--raw? ?CHECK-IN?
360 **
361 ** List all tags, or if CHECK-IN is supplied, list
362 ** all tags and their values for CHECK-IN.
@@ -387,10 +388,12 @@
388 void tag_cmd(void){
389 int n;
390 int fRaw = find_option("raw","",0)!=0;
391 int fPropagate = find_option("propagate","",0)!=0;
392 const char *zPrefix = fRaw ? "" : "sym-";
393 char const * zFindLimit = find_option("limit","n",1);
394 int const nFindLimit = zFindLimit ? atoi(zFindLimit) : 0;
395
396 db_find_and_open_repository(0, 0);
397 if( g.argc<3 ){
398 goto tag_cmd_usage;
399 }
@@ -428,40 +431,51 @@
431 }else
432
433 if( strncmp(g.argv[2],"find",n)==0 ){
434 Stmt q;
435 const char *zType = find_option("type","t",1);
436 Blob sql = empty_blob;
437 if( zType==0 || zType[0]==0 ) zType = "*";
438 if( g.argc!=4 ){
439 usage("find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME");
440 }
441 if( fRaw ){
442 blob_appendf(&sql,
443 "SELECT blob.uuid FROM tagxref, blob"
444 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
445 " AND tagxref.tagtype>0"
446 " AND blob.rid=tagxref.rid",
447 g.argv[3]
448 );
449 if(nFindLimit>0){
450 blob_appendf(&sql, " LIMIT %d", nFindLimit);
451 }
452 db_prepare(&q, "%s", blob_str(&sql));
453 blob_reset(&sql);
454 while( db_step(&q)==SQLITE_ROW ){
455 fossil_print("%s\n", db_column_text(&q, 0));
456 }
457 db_finalize(&q);
458 }else{
459 int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
460 g.argv[3]);
461 if( tagid>0 ){
462 blob_appendf(&sql,
463 "%s"
464 " AND event.type GLOB '%q'"
465 " AND blob.rid IN ("
466 " SELECT rid FROM tagxref"
467 " WHERE tagtype>0 AND tagid=%d"
468 ")"
469 " ORDER BY event.mtime DESC",
470 timeline_query_for_tty(), zType, tagid
471 );
472 if(nFindLimit>0){
473 blob_appendf(&sql, " LIMIT %d", nFindLimit);
474 }
475 db_prepare(&q, "%s", blob_str(&sql));
476 blob_reset(&sql);
477 print_timeline(&q, 2000, 0);
478 db_finalize(&q);
479 }
480 }
481 }else
482
+14 -7
--- src/timeline.c
+++ src/timeline.c
@@ -245,11 +245,15 @@
245245
int prevWasDivider = 0; /* True if previous output row was <hr> */
246246
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247247
Stmt fchngQuery; /* Query for file changes on check-ins */
248248
static Stmt qbranch;
249249
int pendingEndTr = 0; /* True if a </td></tr> is needed */
250
-
250
+ int vid = 0; /* Current checkout version */
251
+
252
+ if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
253
+ vid = db_lget_int("checkout", 0);
254
+ }
251255
zPrevDate[0] = 0;
252256
mxWikiLen = db_get_int("timeline-max-comment", 0);
253257
if( tmFlags & TIMELINE_GRAPH ){
254258
pGraph = graph_init();
255259
/* style is not moved to css, because this is
@@ -318,11 +322,15 @@
318322
@ <div class="divider">%s(zPrevDate)</div>
319323
@ </td><td></td><td></td></tr>
320324
}
321325
memcpy(zTime, &zDate[11], 5);
322326
zTime[5] = 0;
323
- @ <tr>
327
+ if( rid == vid ){
328
+ @ <tr class="timelineCurrent">
329
+ }else {
330
+ @ <tr>
331
+ }
324332
@ <td class="timelineTime">%s(zTime)</td>
325333
@ <td class="timelineGraph">
326334
if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
327335
if( zType[0]=='c'
328336
&& (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
@@ -1866,11 +1874,11 @@
18661874
}
18671875
db_finalize(&stWeek);
18681876
}
18691877
18701878
/*
1871
-** Implements the "byyear" and "bymonth" reports for /stats_report.
1879
+** Implements the "byyear" and "bymonth" reports for /reports.
18721880
** If includeMonth is true then it generates the "bymonth" report,
18731881
** else the "byyear" report. If zUserName is not NULL and not empty
18741882
** then the report is restricted to events created by the named user
18751883
** account.
18761884
*/
@@ -2020,11 +2028,11 @@
20202028
output_table_sorting_javascript("statsTable","tnx");
20212029
}
20222030
}
20232031
20242032
/*
2025
-** Implements the "byuser" view for /stats_report.
2033
+** Implements the "byuser" view for /reports.
20262034
*/
20272035
static void stats_report_by_user(){
20282036
Stmt query = empty_Stmt;
20292037
int nRowNumber = 0; /* current TR number */
20302038
int nEventTotal = 0; /* Total event count */
@@ -2065,11 +2073,11 @@
20652073
if(!nCount) continue /* arguable! Possible? */;
20662074
rowClass = ++nRowNumber % 2;
20672075
nEventTotal += nCount;
20682076
@<tr class='row%d(rowClass)'>
20692077
@ <td>
2070
- @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2078
+ @ <a href="?view=bymonth&user=%h(zUser)">%h(zUser)</a>
20712079
@ </td><td>%d(nCount)</td>
20722080
@ <td>
20732081
@ <div class='statistics-report-graph-line'
20742082
@ style='height:16px;width:%d(nSize)%%;'>
20752083
@ </div></td>
@@ -2201,11 +2209,10 @@
22012209
output_table_sorting_javascript("statsTable","tnx");
22022210
}
22032211
}
22042212
22052213
/*
2206
-** WEBPAGE: stats_report
22072214
** WEBPAGE: reports
22082215
**
22092216
** Shows activity reports for the repository.
22102217
**
22112218
** Query Parameters:
@@ -2216,11 +2223,11 @@
22162223
void stats_report_page(){
22172224
HQuery url; /* URL for various branch links */
22182225
const char * zView = P("view"); /* Which view/report to show. */
22192226
const char *zUserName = P("user");
22202227
if(!zUserName) zUserName = P("u");
2221
- url_initialize(&url, "stats_report");
2228
+ url_initialize(&url, "reports");
22222229
22232230
if(zUserName && *zUserName){
22242231
url_add_parameter(&url,"user", zUserName);
22252232
timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
22262233
}
22272234
--- src/timeline.c
+++ src/timeline.c
@@ -245,11 +245,15 @@
245 int prevWasDivider = 0; /* True if previous output row was <hr> */
246 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247 Stmt fchngQuery; /* Query for file changes on check-ins */
248 static Stmt qbranch;
249 int pendingEndTr = 0; /* True if a </td></tr> is needed */
250
 
 
 
 
251 zPrevDate[0] = 0;
252 mxWikiLen = db_get_int("timeline-max-comment", 0);
253 if( tmFlags & TIMELINE_GRAPH ){
254 pGraph = graph_init();
255 /* style is not moved to css, because this is
@@ -318,11 +322,15 @@
318 @ <div class="divider">%s(zPrevDate)</div>
319 @ </td><td></td><td></td></tr>
320 }
321 memcpy(zTime, &zDate[11], 5);
322 zTime[5] = 0;
323 @ <tr>
 
 
 
 
324 @ <td class="timelineTime">%s(zTime)</td>
325 @ <td class="timelineGraph">
326 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
327 if( zType[0]=='c'
328 && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
@@ -1866,11 +1874,11 @@
1866 }
1867 db_finalize(&stWeek);
1868 }
1869
1870 /*
1871 ** Implements the "byyear" and "bymonth" reports for /stats_report.
1872 ** If includeMonth is true then it generates the "bymonth" report,
1873 ** else the "byyear" report. If zUserName is not NULL and not empty
1874 ** then the report is restricted to events created by the named user
1875 ** account.
1876 */
@@ -2020,11 +2028,11 @@
2020 output_table_sorting_javascript("statsTable","tnx");
2021 }
2022 }
2023
2024 /*
2025 ** Implements the "byuser" view for /stats_report.
2026 */
2027 static void stats_report_by_user(){
2028 Stmt query = empty_Stmt;
2029 int nRowNumber = 0; /* current TR number */
2030 int nEventTotal = 0; /* Total event count */
@@ -2065,11 +2073,11 @@
2065 if(!nCount) continue /* arguable! Possible? */;
2066 rowClass = ++nRowNumber % 2;
2067 nEventTotal += nCount;
2068 @<tr class='row%d(rowClass)'>
2069 @ <td>
2070 @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2071 @ </td><td>%d(nCount)</td>
2072 @ <td>
2073 @ <div class='statistics-report-graph-line'
2074 @ style='height:16px;width:%d(nSize)%%;'>
2075 @ </div></td>
@@ -2201,11 +2209,10 @@
2201 output_table_sorting_javascript("statsTable","tnx");
2202 }
2203 }
2204
2205 /*
2206 ** WEBPAGE: stats_report
2207 ** WEBPAGE: reports
2208 **
2209 ** Shows activity reports for the repository.
2210 **
2211 ** Query Parameters:
@@ -2216,11 +2223,11 @@
2216 void stats_report_page(){
2217 HQuery url; /* URL for various branch links */
2218 const char * zView = P("view"); /* Which view/report to show. */
2219 const char *zUserName = P("user");
2220 if(!zUserName) zUserName = P("u");
2221 url_initialize(&url, "stats_report");
2222
2223 if(zUserName && *zUserName){
2224 url_add_parameter(&url,"user", zUserName);
2225 timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
2226 }
2227
--- src/timeline.c
+++ src/timeline.c
@@ -245,11 +245,15 @@
245 int prevWasDivider = 0; /* True if previous output row was <hr> */
246 int fchngQueryInit = 0; /* True if fchngQuery is initialized */
247 Stmt fchngQuery; /* Query for file changes on check-ins */
248 static Stmt qbranch;
249 int pendingEndTr = 0; /* True if a </td></tr> is needed */
250 int vid = 0; /* Current checkout version */
251
252 if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
253 vid = db_lget_int("checkout", 0);
254 }
255 zPrevDate[0] = 0;
256 mxWikiLen = db_get_int("timeline-max-comment", 0);
257 if( tmFlags & TIMELINE_GRAPH ){
258 pGraph = graph_init();
259 /* style is not moved to css, because this is
@@ -318,11 +322,15 @@
322 @ <div class="divider">%s(zPrevDate)</div>
323 @ </td><td></td><td></td></tr>
324 }
325 memcpy(zTime, &zDate[11], 5);
326 zTime[5] = 0;
327 if( rid == vid ){
328 @ <tr class="timelineCurrent">
329 }else {
330 @ <tr>
331 }
332 @ <td class="timelineTime">%s(zTime)</td>
333 @ <td class="timelineGraph">
334 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
335 if( zType[0]=='c'
336 && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
@@ -1866,11 +1874,11 @@
1874 }
1875 db_finalize(&stWeek);
1876 }
1877
1878 /*
1879 ** Implements the "byyear" and "bymonth" reports for /reports.
1880 ** If includeMonth is true then it generates the "bymonth" report,
1881 ** else the "byyear" report. If zUserName is not NULL and not empty
1882 ** then the report is restricted to events created by the named user
1883 ** account.
1884 */
@@ -2020,11 +2028,11 @@
2028 output_table_sorting_javascript("statsTable","tnx");
2029 }
2030 }
2031
2032 /*
2033 ** Implements the "byuser" view for /reports.
2034 */
2035 static void stats_report_by_user(){
2036 Stmt query = empty_Stmt;
2037 int nRowNumber = 0; /* current TR number */
2038 int nEventTotal = 0; /* Total event count */
@@ -2065,11 +2073,11 @@
2073 if(!nCount) continue /* arguable! Possible? */;
2074 rowClass = ++nRowNumber % 2;
2075 nEventTotal += nCount;
2076 @<tr class='row%d(rowClass)'>
2077 @ <td>
2078 @ <a href="?view=bymonth&user=%h(zUser)">%h(zUser)</a>
2079 @ </td><td>%d(nCount)</td>
2080 @ <td>
2081 @ <div class='statistics-report-graph-line'
2082 @ style='height:16px;width:%d(nSize)%%;'>
2083 @ </div></td>
@@ -2201,11 +2209,10 @@
2209 output_table_sorting_javascript("statsTable","tnx");
2210 }
2211 }
2212
2213 /*
 
2214 ** WEBPAGE: reports
2215 **
2216 ** Shows activity reports for the repository.
2217 **
2218 ** Query Parameters:
@@ -2216,11 +2223,11 @@
2223 void stats_report_page(){
2224 HQuery url; /* URL for various branch links */
2225 const char * zView = P("view"); /* Which view/report to show. */
2226 const char *zUserName = P("user");
2227 if(!zUserName) zUserName = P("u");
2228 url_initialize(&url, "reports");
2229
2230 if(zUserName && *zUserName){
2231 url_add_parameter(&url,"user", zUserName);
2232 timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
2233 }
2234
+36 -6
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
4646
int nDeltaSent; /* Number of deltas sent */
4747
int nFileRcvd; /* Number of files received */
4848
int nDeltaRcvd; /* Number of deltas received */
4949
int nDanglingFile; /* Number of dangling deltas received */
5050
int mxSend; /* Stop sending "file" with pOut reaches this size */
51
+ int resync; /* Send igot cards for all holdings */
5152
u8 syncPrivate; /* True to enable syncing private content */
5253
u8 nextIsPrivate; /* If true, next "file" received is a private */
5354
time_t maxTime; /* Time when this transfer should be finished */
5455
};
5556
@@ -736,21 +737,37 @@
736737
** Return the number of cards sent.
737738
*/
738739
static int send_unclustered(Xfer *pXfer){
739740
Stmt q;
740741
int cnt = 0;
741
- db_prepare(&q,
742
- "SELECT uuid FROM unclustered JOIN blob USING(rid)"
743
- " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
744
- " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
745
- " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
746
- );
742
+ if( pXfer->resync ){
743
+ db_prepare(&q,
744
+ "SELECT uuid, rid FROM blob"
745
+ " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
746
+ " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
747
+ " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
748
+ " AND blob.rid<=%d"
749
+ " ORDER BY blob.rid DESC",
750
+ pXfer->resync
751
+ );
752
+ }else{
753
+ db_prepare(&q,
754
+ "SELECT uuid FROM unclustered JOIN blob USING(rid)"
755
+ " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
756
+ " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
757
+ " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
758
+ );
759
+ }
747760
while( db_step(&q)==SQLITE_ROW ){
748761
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
749762
cnt++;
763
+ if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){
764
+ pXfer->resync = db_column_int(&q, 1)-1;
765
+ }
750766
}
751767
db_finalize(&q);
768
+ if( cnt==0 ) pXfer->resync = 0;
752769
return cnt;
753770
}
754771
755772
/*
756773
** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
11951212
server_private_xfer_not_authorized();
11961213
}else{
11971214
xfer.syncPrivate = 1;
11981215
}
11991216
}
1217
+ /* pragma send-catalog
1218
+ **
1219
+ ** Send igot cards for all known artifacts.
1220
+ */
1221
+ if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1222
+ xfer.resync = 0x7fffffff;
1223
+ }
12001224
}else
12011225
12021226
/* Unknown message
12031227
*/
12041228
{
@@ -1292,10 +1316,11 @@
12921316
#define SYNC_PUSH 0x0001
12931317
#define SYNC_PULL 0x0002
12941318
#define SYNC_CLONE 0x0004
12951319
#define SYNC_PRIVATE 0x0008
12961320
#define SYNC_VERBOSE 0x0010
1321
+#define SYNC_RESYNC 0x0020
12971322
#endif
12981323
12991324
/*
13001325
** Sync to the host identified in g.urlName and g.urlPath. This
13011326
** routine is called by the client.
@@ -1380,15 +1405,20 @@
13801405
zOpType = "Clone";
13811406
}else if( syncFlags & SYNC_PULL ){
13821407
blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
13831408
nCardSent++;
13841409
zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1410
+ if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1411
+ blob_appendf(&send, "pragma send-catalog\n");
1412
+ nCardSent++;
1413
+ }
13851414
}
13861415
if( syncFlags & SYNC_PUSH ){
13871416
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
13881417
nCardSent++;
13891418
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
1419
+ if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
13901420
}
13911421
manifest_crosslink_begin();
13921422
transport_global_startup();
13931423
if( syncFlags & SYNC_VERBOSE ){
13941424
fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
13951425
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
46 int nDeltaSent; /* Number of deltas sent */
47 int nFileRcvd; /* Number of files received */
48 int nDeltaRcvd; /* Number of deltas received */
49 int nDanglingFile; /* Number of dangling deltas received */
50 int mxSend; /* Stop sending "file" with pOut reaches this size */
 
51 u8 syncPrivate; /* True to enable syncing private content */
52 u8 nextIsPrivate; /* If true, next "file" received is a private */
53 time_t maxTime; /* Time when this transfer should be finished */
54 };
55
@@ -736,21 +737,37 @@
736 ** Return the number of cards sent.
737 */
738 static int send_unclustered(Xfer *pXfer){
739 Stmt q;
740 int cnt = 0;
741 db_prepare(&q,
742 "SELECT uuid FROM unclustered JOIN blob USING(rid)"
743 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
744 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
745 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
746 );
 
 
 
 
 
 
 
 
 
 
 
 
747 while( db_step(&q)==SQLITE_ROW ){
748 blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
749 cnt++;
 
 
 
750 }
751 db_finalize(&q);
 
752 return cnt;
753 }
754
755 /*
756 ** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
1195 server_private_xfer_not_authorized();
1196 }else{
1197 xfer.syncPrivate = 1;
1198 }
1199 }
 
 
 
 
 
 
 
1200 }else
1201
1202 /* Unknown message
1203 */
1204 {
@@ -1292,10 +1316,11 @@
1292 #define SYNC_PUSH 0x0001
1293 #define SYNC_PULL 0x0002
1294 #define SYNC_CLONE 0x0004
1295 #define SYNC_PRIVATE 0x0008
1296 #define SYNC_VERBOSE 0x0010
 
1297 #endif
1298
1299 /*
1300 ** Sync to the host identified in g.urlName and g.urlPath. This
1301 ** routine is called by the client.
@@ -1380,15 +1405,20 @@
1380 zOpType = "Clone";
1381 }else if( syncFlags & SYNC_PULL ){
1382 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
1383 nCardSent++;
1384 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
 
 
 
 
1385 }
1386 if( syncFlags & SYNC_PUSH ){
1387 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
1388 nCardSent++;
1389 if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
 
1390 }
1391 manifest_crosslink_begin();
1392 transport_global_startup();
1393 if( syncFlags & SYNC_VERBOSE ){
1394 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1395
--- src/xfer.c
+++ src/xfer.c
@@ -46,10 +46,11 @@
46 int nDeltaSent; /* Number of deltas sent */
47 int nFileRcvd; /* Number of files received */
48 int nDeltaRcvd; /* Number of deltas received */
49 int nDanglingFile; /* Number of dangling deltas received */
50 int mxSend; /* Stop sending "file" with pOut reaches this size */
51 int resync; /* Send igot cards for all holdings */
52 u8 syncPrivate; /* True to enable syncing private content */
53 u8 nextIsPrivate; /* If true, next "file" received is a private */
54 time_t maxTime; /* Time when this transfer should be finished */
55 };
56
@@ -736,21 +737,37 @@
737 ** Return the number of cards sent.
738 */
739 static int send_unclustered(Xfer *pXfer){
740 Stmt q;
741 int cnt = 0;
742 if( pXfer->resync ){
743 db_prepare(&q,
744 "SELECT uuid, rid FROM blob"
745 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
746 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
747 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
748 " AND blob.rid<=%d"
749 " ORDER BY blob.rid DESC",
750 pXfer->resync
751 );
752 }else{
753 db_prepare(&q,
754 "SELECT uuid FROM unclustered JOIN blob USING(rid)"
755 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
756 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
757 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)"
758 );
759 }
760 while( db_step(&q)==SQLITE_ROW ){
761 blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
762 cnt++;
763 if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){
764 pXfer->resync = db_column_int(&q, 1)-1;
765 }
766 }
767 db_finalize(&q);
768 if( cnt==0 ) pXfer->resync = 0;
769 return cnt;
770 }
771
772 /*
773 ** Send an igot message for every artifact.
@@ -1195,10 +1212,17 @@
1212 server_private_xfer_not_authorized();
1213 }else{
1214 xfer.syncPrivate = 1;
1215 }
1216 }
1217 /* pragma send-catalog
1218 **
1219 ** Send igot cards for all known artifacts.
1220 */
1221 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1222 xfer.resync = 0x7fffffff;
1223 }
1224 }else
1225
1226 /* Unknown message
1227 */
1228 {
@@ -1292,10 +1316,11 @@
1316 #define SYNC_PUSH 0x0001
1317 #define SYNC_PULL 0x0002
1318 #define SYNC_CLONE 0x0004
1319 #define SYNC_PRIVATE 0x0008
1320 #define SYNC_VERBOSE 0x0010
1321 #define SYNC_RESYNC 0x0020
1322 #endif
1323
1324 /*
1325 ** Sync to the host identified in g.urlName and g.urlPath. This
1326 ** routine is called by the client.
@@ -1380,15 +1405,20 @@
1405 zOpType = "Clone";
1406 }else if( syncFlags & SYNC_PULL ){
1407 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
1408 nCardSent++;
1409 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1410 if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1411 blob_appendf(&send, "pragma send-catalog\n");
1412 nCardSent++;
1413 }
1414 }
1415 if( syncFlags & SYNC_PUSH ){
1416 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
1417 nCardSent++;
1418 if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
1419 if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
1420 }
1421 manifest_crosslink_begin();
1422 transport_global_startup();
1423 if( syncFlags & SYNC_VERBOSE ){
1424 fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
1425
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
1313
#
1414
1515
#### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
1616
# By default, this is an empty string (i.e. use the native compiler).
1717
#
18
-# PREFIX =
18
+PREFIX =
1919
# PREFIX = mingw32-
2020
# PREFIX = i686-pc-mingw32-
2121
# PREFIX = i686-w64-mingw32-
22
-PREFIX = x86_64-w64-mingw32-
22
+# PREFIX = x86_64-w64-mingw32-
2323
2424
#### The toplevel directory of the source tree. Fossil can be built
2525
# in a directory that is separate from the source tree. Just change
2626
# the following to point from the build directory to the src/ folder.
2727
#
2828
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 # PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,15 +13,15 @@
13 #
14
15 #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers.
16 # By default, this is an empty string (i.e. use the native compiler).
17 #
18 PREFIX =
19 # PREFIX = mingw32-
20 # PREFIX = i686-pc-mingw32-
21 # PREFIX = i686-w64-mingw32-
22 # PREFIX = x86_64-w64-mingw32-
23
24 #### The toplevel directory of the source tree. Fossil can be built
25 # in a directory that is separate from the source tree. Just change
26 # the following to point from the build directory to the src/ folder.
27 #
28
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -296,11 +296,11 @@
296296
<b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name artifact-id ?value?</i><br />
297297
<b>U</b> <i>user-name</i><br />
298298
<b>Z</b> <i>checksum</i><br />
299299
</blockquote>
300300
301
-A control artifact must have one D card and one Z card and
301
+A control artifact must have one D card, one U card, one Z card and
302302
one or more T cards. No other cards or other text is
303303
allowed in a control artifact. Control artifacts might be PGP
304304
clearsigned.
305305
306306
The D card and the Z card of a control artifact are the same
307307
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -296,11 +296,11 @@
296 <b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name artifact-id ?value?</i><br />
297 <b>U</b> <i>user-name</i><br />
298 <b>Z</b> <i>checksum</i><br />
299 </blockquote>
300
301 A control artifact must have one D card and one Z card and
302 one or more T cards. No other cards or other text is
303 allowed in a control artifact. Control artifacts might be PGP
304 clearsigned.
305
306 The D card and the Z card of a control artifact are the same
307
--- www/fileformat.wiki
+++ www/fileformat.wiki
@@ -296,11 +296,11 @@
296 <b>T</b> (<b>+</b>|<b>-</b>|<b>*</b>)<i>tag-name artifact-id ?value?</i><br />
297 <b>U</b> <i>user-name</i><br />
298 <b>Z</b> <i>checksum</i><br />
299 </blockquote>
300
301 A control artifact must have one D card, one U card, one Z card and
302 one or more T cards. No other cards or other text is
303 allowed in a control artifact. Control artifacts might be PGP
304 clearsigned.
305
306 The D card and the Z card of a control artifact are the same
307

Keyboard Shortcuts

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